source_code
stringlengths
26
62k
lang_cluster
stringclasses
11 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
difficulty
int32
-1
3.5k
exec_outcome
stringclasses
1 value
namespace topCoder { using System; using System.Collections.Generic; class p10 { static void Main(string[] args) { p10 o = new p10(); o.foo(); } public void foo() { n = int.Parse(Console.ReadLine()); int[] x = new int[n]; int[] y = new int[n]; for (int i = 0; i < n; i++) { string[]...
C#
cb4dbff31d967c3dab8fe0495eb871dc
29699f46fad0912fc253fd761a8c96cb
1,200
PASSED
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _217A { class Struct { public Struct(int x1, int y1, int set1) { x = x1; y = y1; set = set1; } public ...
C#
cb4dbff31d967c3dab8fe0495eb871dc
030988cebc2e29d1ed5ad57a7905f612
1,200
PASSED
#include <stdio.h> #include <iostream> #include <map> #include <stack> #include <cstdio> #include <algorithm> #include <vector> #include <math.h> using namespace std; void mei() { } int main() { string s; cin>>s; stack<char> st; int n = s.size(); bool prox = true; for(int i =0; i<n; i++) ...
C++
8fd51c391728b433cc94923820e908ff
baf3477386974e25b66eb3ccbdf957ac
1,200
PASSED
/* ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃\○/ ┛┗┛┗┛┃ / / ┓┏┓┏┓┃ノ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃ ┛┗┛┗┛┃ ┓┏┓┏┓┃┓ ┛┗┛┗┛┃┃ MIPTCLASSICMIPTCLASSICMIPTCLASSICMIPTCLASSICMIPTCLASSICMIPTCLASSIC */ // #define pragma #ifdef pragma #pragma GCC optimize("Ofast") #pragma GCC optimize("no-stack-protector") #pragma GC...
C++
8fd51c391728b433cc94923820e908ff
4942d914ecb99f0f730bb64a80a5492c
1,200
PASSED
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define re register #define pb(x) push_back(x) #define ce(x) cout << x << '\n'; using db = long double; using pll = pair < ll, ll >; #define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc) #define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc) #d...
C++
8fd51c391728b433cc94923820e908ff
86071e366b3a191b153211aa2c177a30
1,200
PASSED
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define re register #define pb(x) push_back(x) #define ce(x) cout << x << '\n'; using db = long double; using pll = pair < ll, ll >; #define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc) #define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc) #d...
C++
8fd51c391728b433cc94923820e908ff
6912e780e57bae95c88b9128bd30a85c
1,200
PASSED
#include <iostream> #include<bits/stdc++.h> using namespace std; #include<string> #define ll long long int int main() { vector<int> v; char ch; scanf("%c",&ch); while(ch>=97 && ch<=122) {v.push_back(ch); scanf("%c",&ch); } ll i,c=0,nnn=v.size(); for(i=0;i<nnn-1;i++) { if(v[i]==v[i+1]) { v....
C++
8fd51c391728b433cc94923820e908ff
046bc39ecb17680db37735dbddfd6dec
1,200
PASSED
/** BiSmIlLaHiR rAhMaNiR rAhIm **\ *$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$* *$* *$* *$* |||||||| |||||||| |||||||| |||||||| *$* *$* || || || || || *$* *$* |||||||| |||||||| || |||||| *$* *$* || || ...
C++
8fd51c391728b433cc94923820e908ff
87a2d56d0448938fce60a2550a4c565c
1,200
PASSED
#include<bits/stdc++.h> #define ll long long #define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; int main() { fastIO; string v; cin>>v; bool flag1=false; ll count=0; for(ll i=0;i<v.size()-1;) { if(v[i]==v[i+1]) { if(count%2==0) { ...
C++
8fd51c391728b433cc94923820e908ff
92212e2f8d572e4633a01122f406dbc0
1,200
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll i,j,k,l,m=0,n,t1,t2; string a; cin>>a; char g,d; t2=2,t1=1; stack<char>tt; tt.push(a[0]); for(i=1; i<a.size(); i++) { if(tt.empty()){tt.push(a[i]);continue;} g=tt.top(); if(!t...
C++
8fd51c391728b433cc94923820e908ff
64b2fee9a894a29d2e138ba212ad037b
1,200
PASSED
#include<cstdio> #include<iostream> using namespace std; char a[100005]; int main() { int x=0; int i=1; while(cin>>a[i]) { if(a[i]==a[i-1]) { i=i-2; x++; } i++; } if(x%2==1) cout<<"Yes"<<endl; else cout<<"No"<<endl;// re...
C++
8fd51c391728b433cc94923820e908ff
96b0fd31b279ce211d6cf4223b28715a
1,200
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int cnt = 0; int n =s.size(); vector<char> Cur; for (int i = 0; i < n; i++) { if (Cur.empty()) { Cur.push_back(s[i]); } else { if (Cur.back() == s[i]) ...
C++
8fd51c391728b433cc94923820e908ff
456d7bb66018666501dd30896828a2a6
1,200
PASSED
import os from io import BytesIO, IOBase import sys from math import * from collections import Counter def main(): n=int(input()) ans=[n]*(n+1) z=set(range(1,n+1)) while len(z)!=1: a,b=z.pop(),z.pop() print('?',a,b,flush=True) x=int(input()) print('?',b,a,flush=True) ...
Python
9bfbd68e61f4d2f3d404fd0413aded35
ee560325f27fefa25653b9210ee8221a
1,600
PASSED
n= int(input()) a= [0 ]*(n+1) i=1 j=2 if n==1: print("! 1") else: while(j<=n): print('?',i,j,flush=True) an=int(input()) print('?',j,i,flush=True) bn =int(input()) if an>bn: a[i]=an i=j else: a[j]=bn j+=1 print('?'...
Python
9bfbd68e61f4d2f3d404fd0413aded35
bda75183b2a38e1d55c7d585f2ed4047
1,600
PASSED
from sys import stdout n = int(input()) a = [-1]*n pm = 1 i = 2 mx = 1 while i<=n: print('?',mx,i) stdout.flush() v1 = int(input()) print('?',i,mx) stdout.flush() v2 = int(input()) if v1>v2: a[mx-1] = v1 mx = i else: a[i-1] = v2 i+=1 a[mx-1]=n print('!',*a)
Python
9bfbd68e61f4d2f3d404fd0413aded35
0b76780ebccb25902cf1246dd67d1246
1,600
PASSED
import sys #when pi%pj=forward and pj%pi=backward, if forward>backward, pi=forward (pi<pj). if backward>forward, pj=backward (pj<pi) n=int(input()) modulo=[dict() for _ in range(n+1)] ans=[-1 for _ in range(n+1)] i=1 j=2 for k in range(n-1): print('? {} {}'.format(i,j)) forward=int(input()) print('? {} {...
Python
9bfbd68e61f4d2f3d404fd0413aded35
ba9e1ef50a10f698ca117000d1e52967
1,600
PASSED
import sys #when pi%pj=forward and pj%pi=backward, if forward>backward, pi=forward (pi<pj). if backward>forward, pj=backward (pj<pi) n=int(input()) modulo=[dict() for _ in range(n+1)] ans=[-1 for _ in range(n+1)] i=1 j=2 for k in range(n-1): print('? {} {}'.format(i,j)) forward=int(input()) print('? {} {...
Python
9bfbd68e61f4d2f3d404fd0413aded35
2b431b6664e5be70cc8b259332360182
1,600
PASSED
import sys from collections import defaultdict n=int(input()) m=0 d=defaultdict(lambda:0) arr=[0]*(n) p=1 j=2 while(j<=n): print("? "+ str(p)+" "+str(j)) sys.stdout.flush() k1=int(input()) print("? "+ str(j)+" "+str(p)) sys.stdout.flush() k2=int(input()) if k1>k2: arr[p - 1] = k1 ...
Python
9bfbd68e61f4d2f3d404fd0413aded35
16b91428ad46e39c64e5dccaf27a876e
1,600
PASSED
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
Python
9bfbd68e61f4d2f3d404fd0413aded35
1b25e0eb428f7acb33b81656203925ba
1,600
PASSED
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
Python
9bfbd68e61f4d2f3d404fd0413aded35
f204c0ff0f102d03f3a62414b506f4b6
1,600
PASSED
import sys from collections import defaultdict as dd from collections import Counter as cc from queue import Queue import math import itertools try: sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') except: pass input = lambda: sys.stdin.buffer.readline().rstrip() def primeFactors(n): a=[...
Python
9bfbd68e61f4d2f3d404fd0413aded35
a9b3ddd47d0876d33cac724010a49286
1,600
PASSED
import os def clear_output(): # os.system('cls') # os.system('clear') pass n = int(input()) b = [-1 for i in range(n)] x, y = 1, 2 for i in range(n - 1): print(f'? {x} {y}') k1 = int(input()) clear_output() print(f'? {y} {x}') k2 = int(input()) clear_output() if k1 > k2: ...
Python
9bfbd68e61f4d2f3d404fd0413aded35
e84b00f33cf280decc696080bdd152d1
1,600
PASSED
import java.util.*; import java.io.*; public class D1305{ static int n; static ArrayList<Integer>[] adjList; static boolean[] check; static boolean[] vis; static int global; public static void clean(int u, int p) { if(u == p) return; vis = new boolean[n]; int x = getNext(u, p); global = 1; vis = ...
Java
a291ee66980d8b5856b24d1541e66fd0
8547a652f1c69eee0fd7ac311c32bacc
1,900
PASSED
/* D A R K L _ _ O R D D A K / | | \ L O R D A R _ / | | \ _ K L O R D A R K _ / | _ | \ _ L ...
Java
a291ee66980d8b5856b24d1541e66fd0
95ee8d2962aae1b0241587b42af5f4eb
1,900
PASSED
import java.io.*; import java.util.*; /* Прокрастинирую */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int INF = (int) (1e9 + 10); static final int MOD = (int) (1e9 + 7); static final int N = (int) (4e5 + 5); static fin...
Java
a291ee66980d8b5856b24d1541e66fd0
88b10a8a7968706fe6d4519825458d28
1,900
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.PriorityQueue; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayLis...
Java
a291ee66980d8b5856b24d1541e66fd0
cae1ab3c4e44e5f494cf5e6891260618
1,900
PASSED
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) throws IOException { PrintWriter out = new PrintWriter(System.out); //Scanner sc = new Scanner(); Reader in = new Reader(); Main solver = new Main(); solver....
Java
a291ee66980d8b5856b24d1541e66fd0
a38b612dab0fccfe977fd1dad3184a55
1,900
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Random; import java.util.StringTokenizer; publi...
Java
a291ee66980d8b5856b24d1541e66fd0
fef76f833df3b3aafb1e4829492b245a
1,900
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.util.ArrayList; import java.io.UncheckedIOException; import java.util.List; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import...
Java
a291ee66980d8b5856b24d1541e66fd0
5fb76e449544602e21cf9fd123e249e5
1,900
PASSED
import java.util.*; import java.io.*; import java.text.*; public class D1305 { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int[] lvl = new int[n]; ArrayList<Integer>[] adjList = new Arra...
Java
a291ee66980d8b5856b24d1541e66fd0
e11862e3ddf32f6b00844ad9f3082710
1,900
PASSED
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class D { private void work() { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in), 1 << 16)); n = Integer.parseInt(sc.nextLine().trim()); adj = new int[n][n]; deg...
Java
a291ee66980d8b5856b24d1541e66fd0
476abb64ea2996f3e08f7e20c8e860aa
1,900
PASSED
import java.io.*; import java.util.Arrays; import java.util.StringJoiner; import java.util.StringTokenizer; public class MainD { static int N; static Edge[] E; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); E = new Edge[N-1]...
Java
a291ee66980d8b5856b24d1541e66fd0
8c10112ddf8cd377f6cc023b671c17f2
1,900
PASSED
/* this code was written by Zanaty problem Name: code2.cpp */ #include <bits/stdc++.h> //#ifdef _MSC_VER //#include <hash_set> //#include <hash_map> //using namespace stdext; //#else //#include <ext/hash_set> //#include <ext/hash_map> //using namespace __gnu_cxx; //#endif using namespace std; #define rep(i,n) for...
C++
a72873b2f845f733c9b898ad81b32d29
6561b307d67c319e12222e704fcc32dc
1,800
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5+7; vector<pair<ll,ll> >E[maxn]; ll n,vis[maxn],ans; void init() { for(ll i = 1; i <= n; i ++ ) { E[i].clear(); } } void dfs(ll x,ll sum) { vis[x] = 1; if(E[x].size() == 1) { ans = max(ans,sum); ...
C++
a72873b2f845f733c9b898ad81b32d29
fa1d1df47b4662def4e23173b1e8ecf7
1,800
PASSED
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <string> #define oo 1000000000 #define mod 100000000 #define N 100010 #define next nxt using namespace std; struct node { int e,v,next; }; int h[N]; node edge[N*2]; int len; void add(int x,int y,int v) { edg...
C++
a72873b2f845f733c9b898ad81b32d29
83a2dc8480a0bfee797c096745cebf8e
1,800
PASSED
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <string> #define oo 1000000000 #define mod 100000000 #define N 100010 #define next nxt using namespace std; struct node { int e,v,next; }; int H[N]; node edge[N*2]; int Hlen; void addedge(int x,int y,int v) { ...
C++
a72873b2f845f733c9b898ad81b32d29
49149dcc01238379ad2fc08ed51f0267
1,800
PASSED
#include<stdio.h> #include<string.h> #include<string> #include<map> #include<algorithm> using namespace std; long long fu[100005]; long long cost[100005]; int main() { long long n,i,j,a,b,c,t,sum=0,mx=0,ans; scanf("%I64d",&n); for(i=0;i<=n+1;i++) fu[i]=i; for(i=1;i<n;i++) { scanf("...
C++
a72873b2f845f733c9b898ad81b32d29
6c436616cdfdc8e919c268229d914527
1,800
PASSED
#include <cstdio> #include <cstring> #include <vector> #include <iostream> using namespace std; const int MAX_NUMBER = 100007; struct Edge { int start; int end; long long dist; int next; }; vector<int> path[MAX_NUMBER]; long long dp[MAX_NUMBER], sums[MAX_NUMBER], dist[MAX_NUMBER], value[MAX_NUMBER]; int...
C++
a72873b2f845f733c9b898ad81b32d29
caae0d3dc047ab3c97c43b80592e45f1
1,800
PASSED
#include <iostream> #include <vector> #include <algorithm> #include <utility> #include <map> #include <cstdio> #include <iostream> #include <string> #include <map> #include <fstream> using namespace std; vector<pair<int,int> > adj[2222222]; int dfs(int w,int p){ int a = 0; for (int k = 0; k < adj[w].size()...
C++
a72873b2f845f733c9b898ad81b32d29
c9ecc7e6f58df026e190434713ba946f
1,800
PASSED
#include <iostream> #include <vector> #include <queue> using namespace std; const int maxn=1000*100+10; vector <int> v[maxn][2]; long long dp[maxn][2]; bool mark[maxn]; void dfs(int root,int par) { if(v[root][0].size()==1 && root!=1) { dp[root][1]=0; dp[root][0]=0; return ; } l...
C++
a72873b2f845f733c9b898ad81b32d29
cb7cedf2531f7e77cee4a8a27b325023
1,800
PASSED
#include <cstdio> #include <vector> #include <cstring> #include <algorithm> #include <iostream> #include <cmath> #include <fstream> #include <sstream> #include <map> #include <set> #include <numeric> #include <limits> #include <string.h> #include <bitset> #include <assert.h> //#include <bits/stdc++.h> #define pb push...
C++
a72873b2f845f733c9b898ad81b32d29
df154c4d0ad44820fbbf613f154ffd18
1,800
PASSED
#include <cstdio> #include <vector> #include <cstring> #include <algorithm> #include <iostream> #include <cmath> #include <fstream> #include <sstream> #include <map> #include <set> #include <numeric> #include <limits> #include <string.h> #include <bitset> #include <assert.h> //#include <bits/stdc++.h> #define pb push...
C++
a72873b2f845f733c9b898ad81b32d29
2c4d5f4bb215501837da9b200a8a6df8
1,800
PASSED
import sys import time def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def rinput(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) mod = int(1e9)+7 n, m = rinput() a = get_list() g = [[] f...
Python
875e7048b7a254992b9f62b9365fcf9b
1f978826abaf13952a87551a910eda11
1,500
PASSED
from queue import Queue # import class point(): def __init__(seft,id,preCat): seft.id = id seft.preCat = preCat n, m = map(int,input().split()) status = list(map(int,input().split())) path = [-1]*(n+1) graph = [[] for i in range(n+1)] for i in range(n-1): first, second = map(int,input().split()...
Python
875e7048b7a254992b9f62b9365fcf9b
a870afe160e6ba832f21be8a180aa6eb
1,500
PASSED
#!/usr/bin/env python # 580C_park.py - Codeforces.com/problemset/problem/580/C by Sergey 2015 import unittest import sys import collections ############################################################################### # Park Class (Main Program) ######################################################################...
Python
875e7048b7a254992b9f62b9365fcf9b
681fc804e7a0986fef5d6460623d2e8c
1,500
PASSED
#!/usr/bin/env python # 580C_park.py - Codeforces.com/problemset/problem/580/C by Sergey 2015 import unittest import sys import collections ############################################################################### # Park Class (Main Program) ######################################################################...
Python
875e7048b7a254992b9f62b9365fcf9b
4d932eb18795fa98a2d095e48d1a9b9c
1,500
PASSED
class Node: def __init__(self,value,parent=None): self.neighbors = set() self.value = value self.cat = 0 self.parent = parent self.isVisited = False def add_neighbor(self,node): self.neighbors.add(node) def __repr__(self): return f"Node{self.value}" class Graph: def __init__(self...
Python
875e7048b7a254992b9f62b9365fcf9b
c21f415a7f1ef82cc10becc827bd4343
1,500
PASSED
# recursive too deep might causing stack overflow def go_child(node, path_cat, parent): # check if too more cat m_cat = 0 if cat[node] == 0: m_cat = 0 else: m_cat = path_cat + cat[node] # too more cat then leaves are not achievable if m_cat > m: return 0 isLeaf = True...
Python
875e7048b7a254992b9f62b9365fcf9b
ae171a407a606aa04878c85511ff6137
1,500
PASSED
import queue MAX = 100000 + 5 cat = [0] * MAX visited = [False] * MAX graph = [[] for _ in range(MAX)] def BFS(s): nrestaurants = 0 q = queue.Queue() visited[s] = True q.put(s) cat[s] = (1 if a[s] == 1 else 0) while not q.empty(): u = q.get() for v in graph[u]: ...
Python
875e7048b7a254992b9f62b9365fcf9b
b597c4e20f08553c443a24deef84c865
1,500
PASSED
def solve(graph, m, has_cats): stack = [(0, 1 if has_cats[0] else 0)] visited = [False]*len(graph) visited[0] = True result = 0 while stack: curr, cats = stack.pop() if cats > m: continue if curr and len(graph[curr]) == 1: result += 1 cont...
Python
875e7048b7a254992b9f62b9365fcf9b
71b3f549e5396d0642e479e42aa056de
1,500
PASSED
# Not my code # testing https://codeforces.com/contest/580/submission/55056991 code # with my bootstraped recursion # My magical way of doing recursion in python. This # isn't the fastest, but at least it works. from types import GeneratorType def bootstrap(func, stack=[]): def wrapped_function(*args, **kwargs): ...
Python
875e7048b7a254992b9f62b9365fcf9b
25c07359b4cf88ee8b64e431b4472896
1,500
PASSED
import time startTimeProblem=time.time() import fileinput, sys, itertools, functools from math import * from bisect import * from heapq import * from collections import * def lcm(a, b): return (a*b)/gcd(a, b) class InputHelper: def __init__(self): self.myinput = fileinput.input() def isLocal(s...
Python
875e7048b7a254992b9f62b9365fcf9b
a32e7d146f6398cff2dd7d667793012f
1,500
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStrea...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
bdb9ad3f62902e27ac07d8730e93e075
1,200
PASSED
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); StringBuilder sb=new StringBuilder(); int n=sc.nextInt(); int k=sc.nextInt(); int a[]=new int[n]; ...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
663c50395c000bebb14634c364330c0c
1,200
PASSED
import java.util.*; import java.io.*; public class Solution1 { private void solve() throws IOException { int n = in.nextInt(); int k = in.nextInt(); Tovar[] t = new Tovar[n]; int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } ...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
cebb815eb653ec7e6798aac1269ae0e1
1,200
PASSED
//package yahia; import java.util.*; import java.io.*; public class yahia { public static void main (String [] Yahia_Mostafa) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(),k=sc.nextInt(),t=n-k; int [ ] x=new int [n]; int [] y=new int[n]; Integer r [] =new Integer [n]; long sum=0; for (int i=0;...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
c54a5cfb46a7fbed9f6ee9e6ab0d40b1
1,200
PASSED
import java.io.*; import java.util.*; import static java.lang.Integer.parseInt; import java.lang.Math; ; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tk; //Scanne...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
109a188e75bc6bbc63caa9b7d10aa13c
1,200
PASSED
import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { static class Obj { public int pr1; public int pr2; public int profit; public Obj() { pr1 = 0; pr2 = 0; profit = 0; } ...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
d1bf45bb87a70d72f751b904013fe17b
1,200
PASSED
import java.awt.List; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.util.*; public class Watermelon { public static void main(String[] args) t...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
0ae8bb16deaa48828b0bc160ddb78d79
1,200
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Watermelon{ static int[] a; static boolean[] visited; public static void main (String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n=sc.next...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
b3d02175120fddf9e8779c4a59dc7d72
1,200
PASSED
import java.io.*; import java.util.*; public class C { public static void main(String[] args) throws Exception { FastScannerC fs = new FastScannerC(); PrintWriter out = new PrintWriter(System.out); int n = fs.nextInt(), k = fs.nextInt(); Buy[] a = new Buy[n]; int[] x = fs.n...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
dce8f095c4ffa28b767a25ce7fac8172
1,200
PASSED
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; public class FirstApp { class Tov implements Comparable<Tov>{ int index; float sailToAfter; public Tov(int ind,float val){ index = ind; sailToAfter = val; } @Override public int compareTo(Tov tov){ if(this.sailToAfter < ...
Java
b5355e1f4439b198d2cc7dea01bc4bc3
b2bb2f031d4423815eb03fcddd3da381
1,200
PASSED
#include <cstdio> int n; int ans[300010]; int a[300010],m1[1200010],m2[1200010],m3[1200010]; inline int max(int a,int b) { return a>b?a:b; } void pushup(int k) { int l=k<<1,r=k<<1|1; m1[k]=max(m1[l],m1[r]); m2[k]=max(m2[l],m2[r]); m3[k]=max(m3[l],m3[r]); } void build(int l,int r,int k) { if(l==r) { m1[k]=a...
C++
41645bbe84910de81ac4ed2a56a046d3
1d483ee8d8ba4be8cb32a4fbeef21163
2,800
PASSED
#include <cstdio> #include <algorithm> using namespace std; int g[500000]; int i,n,s0,s1,l,r; int main() { scanf("%d",&n); for (i=1;i<=n;i++) scanf("%d",&g[i]); l=(n+1)/2,r=n/2+1; if (n&1) { if (n==1) s0=g[1]; else s1=min(g[(n+1)/2],max(g[(n-1)/2],g[(n+3)/2])); s0=max(s0,g[(n+1)/2]); l--,r++; }...
C++
41645bbe84910de81ac4ed2a56a046d3
8eeb711d4bcc6c89289701c078ced20c
2,800
PASSED
#include<iostream> #include<cstdio> using namespace std; const int MAXN = 300005; const int INF = 1000000007; int n; int l[MAXN], sol[MAXN], nep[MAXN], par[MAXN]; int abs (int x) { return x>0?x:-x; } int main () { cin >> n; for (int i=1; i<=n; i++) { sol[i]=-INF; nep[i]=par[i]=n; } for (int i=1; i<=n; i++...
C++
41645bbe84910de81ac4ed2a56a046d3
e9be49db654049e5d519e6312997abcf
2,800
PASSED
//2018.7.30 by ljz #include<bits/stdc++.h> using namespace std; #define res register int #define LL long long #define inf 0x3f3f3f3f #define eps 1e-15 inline int read() { res s=0; bool w=0; char ch=getchar(); while(ch<'0'||ch>'9') { if(ch=='-')w=1; ch=getchar(); } while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getch...
C++
41645bbe84910de81ac4ed2a56a046d3
9cb1fa7b95fc48040e979c33708e0c63
2,800
PASSED
// Author:Arturia #include<cstdio> #include<cstring> #include<algorithm> #include<cctype> #include<ctime> #include<cstdlib> #include<string> #include<queue> #include<cmath> #include<set> #include<map> #include<bitset> #include<vector> #define rep(x,a,b) for (int x=a;x<=(int)(b);x++) #define drp(x,a,b) for (int x=a;x>...
C++
41645bbe84910de81ac4ed2a56a046d3
b8ef2e8498175ea6e79785a1eb9fc194
2,800
PASSED
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmat...
C++
41645bbe84910de81ac4ed2a56a046d3
3b0853a9e6b241f3503429caf78e1f74
2,800
PASSED
#define _GLIBCXX_IOSTREAM #include<bits/stdc++.h> typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; typedef double lf; typedef long double llf; typedef std::pair<int,int> pii; #define xx first #define yy second template<typename T> inline T max(T a,T b){return a>b?a:b;} template<typena...
C++
41645bbe84910de81ac4ed2a56a046d3
73f1ea611ac1ba184b9f82060f5ffa1a
2,800
PASSED
#include <iostream> using namespace std; const int maxn = 3e5, logn = 20; int n, a[maxn], x[2][maxn], s[2]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n - 1; i++) x[0][i] = max(a[i], a[i + 1]); for (int i = 0; i < n - 2; i++) x[1][i] = min(a[i + 1], max(a[i], a[i + 2])); ...
C++
41645bbe84910de81ac4ed2a56a046d3
9155777dd9e5e00a8f12f05b3df227d1
2,800
PASSED
#include <bits/stdc++.h> using namespace std; int n; int a[300005]; int odd[600005], even[600005]; int main() { scanf("%d",&n); for(int i=0; i<n; i++) scanf("%d",&a[i]); if (n == 1) { printf("%d\n", a[0]); return 0; } for(int i=0; i<n; i++) { if (i-...
C++
41645bbe84910de81ac4ed2a56a046d3
d746ac8d69f7aa9d67acafe96dbf1a55
2,800
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <cmath> using namespace std; #define MAXN 300000 #define rint register int #define gc() getchar() inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc()) { for(; ch < '0' || ch > '9'; sgn = ch, ch = gc()); ...
C++
41645bbe84910de81ac4ed2a56a046d3
d9fce2503ba0b669f29fd71207e9fdee
2,800
PASSED
#include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; int v; cin >> v; int a[3001]; int index; int apples; for (int i=0; i<3001; i++) a[i]=0; for (int i=0; i<n; i++){ cin >> index; cin >> apples; a[index-1]+=apples; } long long ans=0; int v1=v; for (in...
C++
848ead2b878f9fd8547e1d442e2f85ff
fcbaf0c54d81525bef08017778c9232c
1,400
PASSED
#include <iostream> using namespace std; int main() { int i, n, v, v1, x, p, a[3001], ans=0; cin >> n >> v; for (i=0; i<3001; i++) a[i]=0; for (i=0; i<n; i++){ cin >> x >> p; a[x-1]+=p; } v1=v; for (i=0; i<3001; i++){ ans+=min(v+v1,a[i]); v1=min(v,max(0,v+v1-a[i])); } cout << ans; }
C++
848ead2b878f9fd8547e1d442e2f85ff
c03de433106156a059ec325c6af5ed91
1,400
PASSED
#include<iostream> using namespace std; long long cr[3007]; long long ans=0; int main() { long long n,k; cin>>n>>k; for(int i=1;i<=3001;i++) { cr[i]=0; } for(int i=1;i<=n;i++) { long long p,q; cin>>p>>q; cr[p]+=q; } long long ne=0,old=0; for(int i=...
C++
848ead2b878f9fd8547e1d442e2f85ff
36918e8cbe313c97bf7fa57e157a11ee
1,400
PASSED
#include<iostream> #include<cstdio> using namespace std; int main() { int n, v; //freopen("in.txt", "r", stdin); cin >> n >> v; int a[n + 1], b[n + 1]; for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; for(int i = 1; i < n; i++) { int min = a[i], k = i; for(int j ...
C++
848ead2b878f9fd8547e1d442e2f85ff
7f43a2b122b8c2b8cfffc0477756e8ee
1,400
PASSED
#include <iostream> #include <map> #include <algorithm> using namespace std; map<int,int>mp; int main( ) { int n , v , a , b; int temp , left , res; cin >> n >> v; for ( int i = 1 ; i<=n ; ++i ) { cin >> a >> b; mp[a] += b; } res = 0; for ( int i = 1 ; i<=3010 ; ++i ) { temp = min( mp[i-1] , v ); res...
C++
848ead2b878f9fd8547e1d442e2f85ff
2034eef3548330a58d7980ee3b7dfff0
1,400
PASSED
#include <iostream> #include <map> #include <algorithm> using namespace std; map<int,int>mp; int main( ) { int n , v , a , b; int temp , left , res; cin >> n >> v; for ( int i = 1 ; i<=n ; ++i ) { cin >> a >> b; mp[a] += b; } res = 0; for ( int i = 1 ; i<=3001 ; ++i ) { temp = min( mp[i-1] , v ); res...
C++
848ead2b878f9fd8547e1d442e2f85ff
a4e38af47f84921d3ca81aa748d51b33
1,400
PASSED
# include <stdio.h> int main() { int n,m,a,b,x[3003]={0},i,sum=0,s; scanf("%d%d",&n,&m); for(i=0;i<n;i++) { scanf("%d%d",&a,&b); x[a]+=b; } s=m; for(i=0;i<3002;i++) { if(x[i]<=s){ sum+=x[i]; s=m; continue; } sum+=s; if(x[i]-s<=m){sum=sum+x[i]-s; s=m-x[i]+s; continue ;} sum+=m; s=0; } printf("%d",sum); return 0; }
C
848ead2b878f9fd8547e1d442e2f85ff
bb3179ade15744d59c0ae9c92ad43ea4
1,400
PASSED
#include<stdio.h> int main(){ int a[3002],ripe[3002],cur=0,ans=0,day=0,rip=0,n=0,v=0,i=0; for(i=0;i<3002;i++){ a[i]=0; ripe[i]=0; } scanf("%d %d",&n,&v); for(i=0;i<n;i++){ scanf("%d",&day); scanf("%d",&rip); ripe[day]=ripe[day]+rip; } for(i=0;i<3002;i++){ if(cur+ripe[i]<=v){ ans=ans+cur+ripe[i]; ...
C
848ead2b878f9fd8547e1d442e2f85ff
51833ccf52bf3e4cddb57ad4d62d7d49
1,400
PASSED
#include<stdio.h> struct d{ int x,y; } p[4000]; int comp(struct d *a,struct d*b){ if((*a).x-(*b).x>=0) return 1; else return -1; } int main() { int a,b,c,d,e,t,m,n,i,j,k,v,ans=0; scanf("%d %d",&n,&v); for(i=0;i<n;++i){ scanf("%d %d",&p[i].x,&p[i].y); } qsort(p,n,sizeof(stru...
C
848ead2b878f9fd8547e1d442e2f85ff
59f09a5aa3289d3649acb31b614ea65c
1,400
PASSED
/* بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ */ /* رَّبِّ زِدْنِى عِلْمًا */ #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { int n,v,pre,rotting,a[4005],b[4005],i,j,bag,collect,day,v2; while(scanf("%d%d",&n,&v)!=EOF) { day=0; bag=0; for(i=0...
C
848ead2b878f9fd8547e1d442e2f85ff
30f346c1c20cb20cc87e06ec05f70b0a
1,400
PASSED
/** * author: prakhar17252 * created: 26.08.2019 00:54:51 **/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; using ld = long double; #define int ll #define pb emplace_back #define pus...
C++
c994ae45ac126c3ee16e77617b4554fc
06c67ceecd2275deac3cd7a9cc68aa31
1,900
PASSED
/** * author: prakhar17252 * created: 25.08.2019 20:46:18 **/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; using ld = long double; #define int ll #define pb emplace_back #define pus...
C++
c994ae45ac126c3ee16e77617b4554fc
17c863342db097c865031367cf174d03
1,900
PASSED
/** * author: prakhar17252 * created: 25.08.2019 23:52:51 **/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; using ld = long double; #define int ll #define pb emplace_back #define pus...
C++
c994ae45ac126c3ee16e77617b4554fc
5e737148944a954ae5a3982c2dd681fa
1,900
PASSED
/** * author: prakhar17252 * created: 26.08.2019 00:54:51 **/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; using ld = long double; #define int ll #define pb emplace_back #define pus...
C++
c994ae45ac126c3ee16e77617b4554fc
7223a7ef0d74db108d5d941acff92eae
1,900
PASSED
/** * author: prakhar17252 * created: 26.08.2019 00:54:51 **/ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; using ld = long double; #define int ll #define pb emplace_back #define pus...
C++
c994ae45ac126c3ee16e77617b4554fc
6fa531f2fd7af7582eae7232aeb4cac0
1,900
PASSED
#include <bits/stdc++.h> #define ll long long using namespace std; ll n, a[200001], ans[200001], p[200001], t[800001]; void build(int v, int tl, int tr) { if (tl == tr) { t[v] = p[tl]; } else { int tm = (tl + tr) / 2; build(2 * v, tl, tm); build(2 * v + 1, tm + 1, tr); ...
C++
c994ae45ac126c3ee16e77617b4554fc
47d5329d62ccb723f63b55832431b99b
1,900
PASSED
#include <bits/stdc++.h> #define ll long long using namespace std; ll n, a[200001], ans[200001], t[200001]; void add(int k, ll val) { while (k < n) { t[k] += val; k |= (k + 1); } } ll Prefix_sum(int k) { ll sm = 0; while (k >= 0) { sm += t[k]; k = (k & (k + 1)) - 1; ...
C++
c994ae45ac126c3ee16e77617b4554fc
06b8997fd9a3b06721564446c2a712b0
1,900
PASSED
#include <bits/stdc++.h> using namespace std; #define _ ios_base::sync_with_stdio(0);cin.tie(0); //#define endl '\n' #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #include <ext/pb_ds/detail/standard_policies.hpp> using name...
C++
c994ae45ac126c3ee16e77617b4554fc
8025dbba4717df8912653dad74adfe20
1,900
PASSED
#include <bits/stdc++.h> using namespace std; #define _ ios_base::sync_with_stdio(0);cin.tie(0); //#define endl '\n' #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #include <ext/pb_ds/detail/standard_policies.hpp> using name...
C++
c994ae45ac126c3ee16e77617b4554fc
c41769e6d01b93b09750a92680f108fa
1,900
PASSED
#include <bits/stdc++.h> using namespace std; #define _ ios_base::sync_with_stdio(0);cin.tie(0); //#define endl '\n' #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #include <ext/pb_ds/detail/standard_policies.hpp> using name...
C++
c994ae45ac126c3ee16e77617b4554fc
1ec2d2447f9b26d1c3d2816c4f15fa1a
1,900
PASSED
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; namespace Codeforces { class Program : IDisposable ...
C#
12a768b502ddb07798830c9728fba5c4
ad98d8e3ce41fbfd335a4b1aea3d23d2
1,400
PASSED
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; namespace Codeforces { class Program : IDisposable ...
C#
12a768b502ddb07798830c9728fba5c4
10eb6cddb8041b578bfb14211626e6c1
1,400
PASSED
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; namespace Codeforces { class Program : IDisposable ...
C#
12a768b502ddb07798830c9728fba5c4
7a26dde5537fea7699f89c06913017f1
1,400
PASSED
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; namespace Codeforces { class Program : IDisposable ...
C#
12a768b502ddb07798830c9728fba5c4
93fc19e9b9cb71f7db382fde68c45779
1,400
PASSED
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; namespace Codeforces { class Program : IDisposable ...
C#
12a768b502ddb07798830c9728fba5c4
1f875c963ff653e3c668c77531104df9
1,400
PASSED
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading; namespace Olymp { public class ProblemSolver { private Tokenizer input; public void Solve() { int n = i...
C#
12a768b502ddb07798830c9728fba5c4
c9a08381618fbd957ac4c09dcb6fa52d
1,400
PASSED
using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Security; using System.Security.Cryptography; namespace ConsoleApplication1 { class Program { //DON'T FORGET TO SET IT TO FALSE BEFORE SUBMIT!!!! public const boo...
C#
12a768b502ddb07798830c9728fba5c4
e31fe8c1c9241140d59489cd0b43c71d
1,400
PASSED
using System; using System.IO; using System.Linq; using System.Text; namespace One_Bomb { internal class Program { private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10); private static readonly StreamWriter writer = n...
C#
12a768b502ddb07798830c9728fba5c4
a31e32f5ce22f7802852170b0303ef1d
1,400
PASSED