akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll S;
    cin >> S;

    ll a = (S + ll(1e9) - 1) / ll(1e9);
    ll d = ll(1e9);
    ll b = a * d - S;
    ll c = 1;

    cout << 0 << " " << 0 << " " << a << " " << b << " " << c << " " << d << "\n";
    // cout << abs(a*d - b*c) << "\n";
    // if (a > 1e9 || b > 1e9 || c > 1e9 || d > 1e9) cout << "NG" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long Q,H,S,D,N;
  cin >>Q>>H>>S>>D>>N;
  long long yasui1;
  long long yasui2;
  yasui1=min(Q*4,min(H*2,S));
  yasui2=min(S*2,min(yasui1*2,D)); 
  if(N==1){
    cout<<yasui1<<endl;
  }else{
    cout<<yasui2*(N/2)+yasui1*(N%2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
a = [int(x) for x in input().split()]

a.sort()

if a[0] == 0:
    print(0)
else:
    m = 1
    i = 0
    while m < 10**18:
        m *= a[i]
        if m > 10**18:
            print(-1)
            sys.exit()
        i += 1
        if i == n:
            print(m)
            sys.exit()

Measured memory_bytes: 84688
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
const int inf = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
#define LOCAL



int main() 
{
	ios::sync_with_stdio(false);
	cout.tie(0), cin.tie(0);
	int h,w, k;
	cin >> h >> w >> k;
	std::vector<string> s(h);
	rep(i, h) cin >> s[i];
	int ans = 0;
	rep(is, 1<<h)rep(js, 1<<w) {
		int cnt = 0;
		rep(i, h)rep(j, w) {
			if (is>>i & 1) continue;
			if (js>>j & 1) continue;
			if (s[i][j] == '#') cnt++;
		}
		if (cnt == k) ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long t1 = sc.nextLong();
		long t2 = sc.nextLong();
		long a1 = sc.nextLong();
		long a2 = sc.nextLong();
		long b1 = sc.nextLong();
		long b2 = sc.nextLong();
		long a = a1 * t1 + a2 * t2;
		long b = b1 * t1 + b2 * t2;
		if (a == b) {
			System.out.println("infinity");
			return;
		}
		if ((a1 >= b1 && a2 >= b2) || (a1 <= b1 && a2 <= b2)) {
			System.out.println(0);
			return;
		}
		if (a < b) {
			long diff = b - a;
			if (a1 > b1) {
				if ((a1 * t1 - b1 * t1) % diff == 0) {
					System.out.println((a1 * t1 - b1 * t1) / diff * 2);
				} else {
					System.out.println((a1 * t1 - b1 * t1) / diff * 2 + 1);
				}
			} else {
				System.out.println(0);
			}
		} else {
			long diff = a - b;
			if (a1 < b1) {
				if ((b1 * t1 - a1 * t1) % diff == 0) {
					System.out.println((b1 * t1 - a1 * t1) / diff * 2);
				} else {
					System.out.println((b1 * t1 - a1 * t1) / diff * 2 + 1);
				}
			} else {
				System.out.println(0);
			}
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23124
N, X, Y = map(int, input().split())
ans = [0]*N

for i in range(1,N+1):
  for j in range(i+1,N+1):
    d = min(j-i,abs(i-X)+abs(j-Y)+1)
    #print(i,j,d)
    ans[d]+=1

print(*ans[1:], sep='\n')


Measured memory_bytes: 9356
#include <bits/stdc++.h>
using namespace std;
int main(){
	int M,K;
	cin>>M>>K;
	if(K>(pow(2,M)-1) ){printf("-1\n");return 0;}
	if(M == 0){
		if(K == 0)printf("0 0\n");
	}
	else if(M == 1){
		if(K == 1){
			printf("-1\n");
		}else printf("0 0 1 1\n");
	}
	else{
		if(K == 0){
			int i ;
			for(i =0;i<= (pow(2,M)-1)-1;i++){
				printf("%d %d ",i,i);
			}
			printf("%d %d",i,i);
			return 0;
		}
		printf("0 %d 0 ",K);
		queue<int> fq,seq;
		stack<int> sta;
		for(int i = 1;i<= (pow(2,M)-1);i++){
			if(i == K)continue;
			sta.push(i);
			fq.push(i);
		}
		int sz = sta.size();
		fq.push(K);
		for(int i =0;i<sz;i++){
			int no = sta.top();sta.pop();
			seq.push(no);
		}
		while(!fq.empty()){
			printf("%d ",fq.front()); fq.pop();
		}
		while(! seq.empty()){
			if(seq.size() == 1){ printf("%d",seq.front());seq.pop();}
			else {
				printf("%d ",seq.front());seq.pop();
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int ans[4];
int main(){
	int n,m;
	cin >> n >> m;
	ans[1]=ans[2]=ans[3]=-1;
	int fg=0;
	while(m--){
		int a,b;
		cin >> a >> b;
		if(ans[a]==-1||b==ans[a]){
			ans[a]=b;
		}
		else fg=1;
	}
	if(n!=1&&ans[1]==0) fg=1;
	if(fg==1) cout << -1 << endl;
	else{
		if(n==1){
			if(ans[1]==-1)
			cout << 0 << endl;
			else
			cout << ans[1] << endl;
		}
		else{
			if(ans[1]==-1)
			ans[1]=1;
			for(int i=1;i<=n;i++){
				if(ans[i]==-1) cout<< 0;
				else cout << ans[i];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import itertools as I;L=int(input());S=bin(L);N=len(S)-2;print(N,N+N+S.count("1")-3)
for i,j in I.product(range(1,N),[0,1]):
 print(i,-~i,j*2**~-i)
 if int(S[-i])&j:L^=2**~-i;print(i,N,L)

Measured memory_bytes: 3064
import re


S = input()
T = input()
S = S + r'.'
ans = 'No'
for i in T:
    if not i.islower():
        print(ans)
        exit(0)
if 1 <= len(S) <= 11:
    if re.fullmatch(S, T):
        ans = 'Yes'
print(ans)

Measured memory_bytes: 9872
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define MOD 1000000007


int main(){
    int n;
    cin>>n;

    string s;
    cin>>s;
    ll r=0,g=0,b=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='R'){
            r++;
        }else if(s.at(i)=='G'){
            g++;
        }else{
            b++;
        }
    }


    int co=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(2*j-i>=n)break;
            if(s.at(i)!=s.at(j)&&s.at(j)!=s.at(2*j-i)&&s.at(2*j-i)!=s.at(i)){
                co++;
            }
        }
    }

    cout<<r*g*b-co<<endl;



}



Measured memory_bytes: 3612
#include <iostream>
using namespace std;

int main(){
    int N;
    cin >> N;
    
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    int ans = 0;
    int flag = 0;

    while(flag == 0){
        for(int i = 0; i < N; i++){
            int c = a[i] % 2;
            if(c == 1) {
                flag = 1;
                break;
            }
            a[i] /= 2;
            if(i == N-1) ans++;
        }
    }
  
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

map<string, int> mp;

int main() {
    int n,l;
    cin >> n >> l;
    string s[100];
    rep(i, n) {
        cin >> s[i];
    }
    sort(s, s + n);
    rep(i, n) {
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 111111
int n,i,j;
double pw,w[N],f[N],v[N],t[N],l,r,p,q,ans,res;
double c(double x){
  for(res=pw*x,j=0;j<n;j++) res+=max(0.0,(t[j]-w[j]*x)*f[j]/v[j]);
  ans=min(ans,res);
  return res;
}
int main(){
  while(cin>>n,n){
    for(cin>>pw,i=0;i<n;i++) scanf("%lf%lf%lf%lf",w+i,f+i,v+i,t+i);
    for(i=0,l=0,r=1e9,ans=c(0);i<100;i++) p=l+(r-l)/3,q=l+(r-l)*2/3,(c(p)>c(q))?l=p:r=q;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 6420
#include<iostream>
#include<cstring>
using namespace std;

int main()
{
  char s[20];
  int cnt=0;
  int max = 0;

  cin >> s;

  for(int i=0; i<strlen(s); i++)
  {
    if((s[i] == 'A')||(s[i] == 'T')||(s[i] == 'G')||(s[i] == 'C'))
    {
      cnt++;
    }
    else
    {
      if(max < cnt) max = cnt;
      cnt = 0;
    }
    
  }

        if(max < cnt) max = cnt;
  cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if( a+b == c+d ){
    cout << "Balanced" << endl;
  }else if( a+b < c+d ){
    cout << "Right" << endl;
  }else{
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			list.add(k);
		}
		boolean flag = true;
		
		for (int j = 0; j < list.size(); j++) {
			list.get(j);
			int plus = 0;
			for(int l = 0; l < list.size(); l++) {
				plus += list.get(l);
			}
			plus -= list.get(j);
			if(list.get(j) >= plus) {
				flag = false;
			}
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
			
	}
}

Measured memory_bytes: 23380
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

vector<LL> flg;
queue<int> que;
vector<int> vs;
inline void check(LL t){
	int u = t & 0xfffff;
	if((flg[u] >> 40) > (t >> 40)){
		vs.push_back(u);
	}
	if((flg[u] >> 40) >= (t >> 40) && flg[u] != t){
		flg[u] = t;
		que.push(u);
	}
}

void mainmain(){
	int n, m;
	scanf("%d%d", &n, &m);
	VV(LL) G(n + 1);
	for(int i = 0; i < m; ++i){
		LL p, q, c;
		scanf("%lld%lld%lld", &p, &q, &c);
		G[p].push_back(c << 20 | q);
		G[q].push_back(c << 20 | p);
	}
	for(int i = 1; i <= n; ++i){
		sort(ALL(G[i]));
	}

	flg.assign(n + 1, LLONG_MAX);
	flg[1] = 1;
	vector<LL> nxt;
	vs.push_back(1);
	vector<unsigned> idx(n + 1);
	for(LL tm = 1; !vs.empty(); ++tm){
		nxt.clear();
		for(int u : vs){
			for(LL e : G[u]){
				nxt.push_back(tm << 40 | e);
			}
		}
		sort(ALL(nxt));
		vs.clear();
		for(LL t : nxt){
			LL comflag = t & 0xfffff00000;
			check(t);
			while(!que.empty()){
				int u = que.front();
				que.pop();
				for(unsigned &i = idx[u]; i < G[u].size(); ++i){
					LL e = G[u][i];
					LL cf = e & 0xfffff00000;
					if(cf > comflag){ break; }
					if(cf < comflag){ continue; }
					LL f = tm << 40 | e;
					check(f);
				}
			}
		}
	}
	LL ans = (flg[n] == LLONG_MAX ? -1LL : flg[n] >> 40);
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 15600
#include<iostream>
using namespace std;

int main(){
	int a,b,c,sum=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++){
		if(c%i==0){
			sum+=1;
		}
	}
	cout<<sum<<endl;
	return 0;
}	



Measured memory_bytes: 3104
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=100005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    double r;
    cin >> r;
    double ans=2*PI*r;
    cout << setprecision(10) << fixed << ans << endl;
}

Measured memory_bytes: 3784
import statistics

n = int(input())
la = [0]*n
lb = [0]*n
for i in range(n):
  a, b = map(int, input().split())
  la[i] = a
  lb[i] = b
a = statistics.median(la)
b = statistics.median(lb)
if n % 2 == 1:
  print(b - a + 1)
else:
  print(int((b - a) * 2 + 1))

Measured memory_bytes: 28828
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(),s.end()
#define fp(x) fixed<<setprecision(x)<<
template<class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template<class T>
void split(char c,T s){
    int n = s.size();
    int i = 0;
    while ((cout<<s[i],i+=1) && (i<n) && (cout<<c<<' '));
}
int digit(int a)
{
int r;
r = (a >= 1000000000) ? 9 : (a >= 100000000) ? 8 : (a >= 10000000) ? 7 : (a >= 1000000) ? 6 : (a >= 100000) ? 5 : (a >= 10000) ? 4 : (a >= 1000) ? 3 : (a >= 100) ? 2 : (a >= 10) ? 1 : 0;
return r + 1;
}
int main(){
    quickie;
    //txt;
    string s;
    cin>>s;
    for(int i = 0 ; i < s.size(); i++){
        if(s[i]==','){
            s[i] = ' ';
        }
    }
    cout<<s;
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int N, A, B;
vector<int> H;

bool check(int t) {
	ll k_sum = 0;
	for (int i = 0; i < N; ++i) {
		int d = H[i] - B * t;
		d = max(0, d);
		int k = d / (A - B);
		if (d % (A - B) != 0)
			++k;
		k_sum += (ll)k;
	}
	if (k_sum <= (ll)t)
		return true;
	else
		return false;
}

int solve(int lower, int upper) {
	int lb = lower;
	int ub = upper;
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		if (check(mid))
			ub = mid;
		else
			lb = mid;
	}
	return ub;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> A >> B;
	H.resize(N);
	int h_max = 0;
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
		if (H[i] > h_max)
			h_max = H[i];
	}
	int low = h_max / A;
	int upp = h_max / B + 1;
	int ans = solve(low, upp);

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n,a,b=map(int,input().split())
print(min(n*a,b))

Measured memory_bytes: 3316
use std::io::*;
use std::str::FromStr;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let a: u32 = iter.next().unwrap().parse().unwrap();
    let b: u32 = iter.next().unwrap().parse().unwrap();
    let t: u32 = iter.next().unwrap().parse().unwrap();
    println!("{}", (t/a)*b);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	int		S,h,m,s,ans = 0;
	
	scanf("%d", &S);

	h = S/3600;
	m = (S-h*3600)/60;
	s = S-h*3600-m*60;
	
	printf("%d:%d:%d\n",h,m,s);


	return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  bool f = true;
  FOR1(x, (ll)S.size()) {
    if (x % 2 == 0) {
      if(S.at(x-1) == 'R'){ f = false;dv("x", x)}
    } else {
      if(S.at(x-1) == 'L'){ f = false;dv("x", x)}
    }
  }

  cout << (f ? YES : NO) << endl;
}

signed main(){
  std::string S;
  std::cin >> S;
  solve(S);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    long long n,x;
    cin>>n>>x;
    long long s=1,t=1;
    for(int i=0;i<n;i++) s=s*2+3,t=t*2+1;
    long long ans=0;
    while(x>0){
        if(s/2+1<=x){
            ans+=t/2+1;
            if(x==s) x=x-s/2-2;
            else x=x-s/2-1;
            s=s/2-1;
            t=t/2;
        }
        else{
            s=s/2-1;
            t=t/2;
            x=x-1;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
   
  #define ll long long
  #define pb push_back
  #define mp make_pair
  #define ff first
  #define ss second


   
void func(){

ll x;
cin>>x;

ll ans=0;

if(x>=500){
  ll temp = x/500;
  ans =ans + temp*1000;
  x=x-500*temp;
}

if(x>=5){
  ll temp = x/5;
  ans =ans+ temp*5;
}
cout<<ans<<endl;
}
   
   
  int main(){
          ios_base::sync_with_stdio(false);
          cin.tie(0);
          cout.tie(0);
   
       /* #ifndef ONLINE_JUDGE
        freopen("input.txt", "r" , stdin);
        freopen("output.txt", "w" , stdout);
        #endif*/
   
     ll t=1;
     //cin>>t;
     while(t--)
     func();
   }

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=2003;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


int dp[M][M];
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    int s[n+3],t[m+2];
    f(i,1,n)cin>>s[i];
    f(i,1,m)cin>>t[i];
    dp[0][0]=0;
    f(i,1,n)
    {
        f(j,1,m)
        {
           int x=0;
           x=ad(dp[i][j-1],dp[i-1][j]);
           x=sub(x,dp[i-1][j-1]);
           dp[i][j]=x;
           x=0;
           if(s[i]==t[j])
           {
               x=ad(dp[i-1][j-1],1);
           }
           dp[i][j]=ad(dp[i][j],x);
        }
    }
    dp[n][m]=ad(dp[n][m],1);
    cout<<dp[n][m]<<endl;
    return 0;

}





































Measured memory_bytes: 31616
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> x(n), y(n), h(n); 
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>h[i];

    int idx = -1;
    for(int i=0;i<n;i++){
        if(h[i]) idx = i;
    }

    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            int top = h[idx] + abs(i-x[idx]) + abs(j-y[idx]);

            bool flg = true;
            for(int k=0;k<n;k++){
                if(max(top-abs(i-x[k])-abs(j-y[k]), 0)!=h[k]) flg = false;
            }

            if(flg){
                cout<<i<<' '<<j<<' '<<top<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();

            if (h == 0 && w == 0)
                break;

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++)
                    System.out.print('#');
                System.out.println();
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 37308
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    n, k = mi()
    if n <= k:
        print(min(n, k-n))
    else:
        n -= (n // k) * k
        print(min(n, k-n))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> balls(n, 1), red(n, 0);
    red[0] = 1;
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        balls[a-1]--; balls[b-1]++;
        red[b-1] |= red[a-1];
        if(balls[a-1] == 0) red[a-1] = 0;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if(red[i] && balls[i]) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
  int n,k;
  scanf("%d%d",&n,&k);

  int a[n];
  int d,tmp;
  int count = 0;

  for(int i=0; i<n; i++){
    a[i]=0;
  }

  for(int i=1; i<=k; i++){
    scanf("%d",&d);
    for(int j=1; j<=d; j++){
      scanf("%d",&tmp);
      a[tmp-1]++;
    }
  }

  for(int i=0; i<n; i++){
    if(a[i] ==0){
      count ++;
    }
  }

  printf("%d",count);

    return 0;

}



Measured memory_bytes: 1732
#include <stdio.h>

int main(int argc, char** argv)
{
	int i, max, tmp, num[2], list[20000], l_point;
	i = 0;
	l_point = 0;
	while (1) {
		scanf("%d %d", &num[0], &num[1]);

		if (num[0] == 0 && num[1] == 0) {
			break;
		}
		else {
			if (num[0] > num[1]) {
				tmp = num[0];
				num[0] = num[1];
				num[1] = tmp;
			}
		}
		list[l_point++] = num[0];
		list[l_point++] = num[1];
		i++;
	}

	max = i;
	for (i = 0; i < max; i++) {
		printf("%d %d\n", list[i*2], list[i*2+1]);
	}
	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<ll> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n;
	int ans=0;
	bool flag=true;
	cin >>n;
	vector<int>a(n,0);
	vector<vector<int>>x(n,vector<int>(n,0));
	vector<vector<int>> y(n, vector<int>(n,0));
	rep(i,n){
		cin>>a[i];
		rep(j,a[i]){
			cin>>x[i][j]>>y[i][j];
			x[i][j]--;
		}
	}
	for(int bit=0;bit<(1<<n);bit++){
		flag=true;
		rep(i,n){
			if(bit&(1<<i)){
				rep(j,a[i]){
					if((bool)y[i][j]!=(bool)(bit&(1<<x[i][j]))){
						flag=false;
					//	cout << "-" << i << " " << x[i][j] << " " << y[i][j] << " " << "+" << (bit &(1 << x[i][j])) << " ";
					}
				}
			}
		}
		if(flag==true){
		//	cout<<bit;
			chmax(ans, __builtin_popcount(bit));
		}
		//cout<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int a, b;
  cin >> a >> b;
  if (a <= 0 && 0 <= b) {
    print("Zero");

  } else {
    if (a > 0) {
      print("Positive");
    } else {
      print(((b - a + 1) % 2 == 0) ? "Positive" : "Negative");
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;



int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  int ans = INF;
  int now;
  for(int i = 0; i < N-K+1; i++){
    now = h[i+K-1] - h[i];
    ans = min(ans,now);
  }
  cout << ans << endl;
}
  
  

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define debug(x) #x << " = " << (x) << " "
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

array<ll, 19> repunit;
array<ll, 19> ten;
ll go(ll d, int log_n, int i) {
    ll e = repunit[log_n+1-i] - repunit[i];
    if (e == 0) {
        return 10 * int(d == 0);
    } else if (e < 0) {
        return int(d == 0);
    } else {
        auto digits = [&](int k) {
            int cnt = 0;
            repeat (a, 10) repeat (b, 10) {
                if (i == 0 and b == 0) continue;
                if (a - b == k) cnt += 1;
            }
            return cnt;
        };
        ll acc = 0;
        repeat_from (k, -9, 9+1) {
            if ((d - k * e) % ten[i+1] == 0) {
                acc += go(d - k * e, log_n, i + 1) * digits(k);
            }
        }
        return acc;
    }
}
ll solve(ll d) {
    repunit[0] = 0; repeat (i, repunit.size()-1) repunit[i+1] = repunit[i] * 10 + 1;
    ten[0] = 1; repeat (i, ten.size()-1) ten[i+1] = ten[i] * 10;
    if (d % 9 != 0) return 0;
    d /= 9;
    ll result = 0;
    repeat (n, 18) {
        result += go(d, n, 0);
    }
    return result;
}

int main() {
    int d; scanf("%d", &d);
    printf("%lld\n", solve(d));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n),r(n);
    for (int i = 0; i < n; i++){
        cin >> p[i];
        r[i] = i+1;
    }
    for (int i = 0; i < n; i++){
        cin >> q[i];
    }
    int a=1,b=1;
    int cnt = 1;
    do{
        if (r == p){
            a = cnt;
        }
        if (r == q){
            b = cnt;
        }
        cnt++;
    }while(next_permutation(r.begin(),r.end()));
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans=0;
  int mini=1e9;
  rep(i,n){
    mini = min(mini, p[i]);
    if(mini == p[i]) ans++;
  }
  cout << ans << endl;
  return 0;  
}

Measured memory_bytes: 4048
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int ar[n][n];
    bool ok = true;
    for(int i = 0; i<n; i++){
        for(int j = 0; j<n; j++){
            cin >> ar[i][j];
        }
    }
    for(int i = 0; i<n; i++){
        for(int j = i; j<n; j++){
            if(ar[i][j]!=ar[j][i]){
                ok = false;
            }
        }
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    int floyd[n][n];
    for(int i = 0; i<n; i++){
        for(int j = 0; j<n; j++){
            floyd[i][j] = ar[i][j];
        }
    }
    for(int k = 0; k<n; k++){
        for(int i = 0; i<n; i++){
            for(int j =0; j<n; j++){
                floyd[i][j] = min(floyd[i][j],floyd[i][k]+floyd[k][j]);
            }
        }
    }
    for(int i =0; i<n; i++){
        for(int j = 0; j<n; j++){
            ok&= (floyd[i][j]==ar[i][j]);
        }
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    long long ans = 0LL;
    for(int i = 0; i<n; i++){
        for(int j = i+1; j<n; j++){
            bool good = true;
            for(int k = 0; k<n; k++){
                if(k!=i && k!=j && ar[i][k]+ar[k][j]==ar[i][j]){
                    good = false;
                }
            }
            if(good){
                ans += (long long)ar[i][j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s1, s2; cin >> s1 >> s2;
	vector<vector<int>>dp(s1.length() + 1, vector<int>(s2.length() + 1));
	rep(i, 0, s1.length() + 1)dp[i][0] = i;
	rep(i, 0, s2.length() + 1)dp[0][i] = i;
	rep(i, 1, s1.length() + 1)rep(j, 1, s2.length() + 1) 
		dp[i][j] = min(dp[i - 1][j] + 1, min(dp[i][j - 1] + 1, dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1])));
	cout << dp[s1.length()][s2.length()] << endl;
	return 0;
}

Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == (b+c) || c == (a+b) || b == (a+c) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import std.stdio;

void main(){
	auto cin = new Cin();
	auto N = cin.line()[0];
	
	((N+N*N)/2).writeln();
}
auto solve(){
}
unittest{
	
}


import std.stdio,std.conv,std.string;
import std.algorithm,std.array;

class Cin
{
	T[] line( T = size_t , string token = " " )( size_t m = 1 ){
		T[] arr = [];
		foreach( i ; 0..m ){
			arr ~= this.read!T();
		}
		return arr;
	}
	T[][] rect( T = size_t , string token = " " )( size_t m = 1 ){
		T[][] arr = new T[][](m);
		foreach( i ; 0..m ){
			arr[i] = this.read!T(token);
		}
		return arr;
	}
	private T[] read( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

	ll x; cin >> x;
	ll tmp = x;
	ll quo500 = tmp / 500;
	tmp -= 500 * quo500;
	ll quo5 = tmp / 5;
	cout << 1000 * quo500 + 5 * quo5 << endl;
	return 0;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
int main()
{
	int n,m;cin>>n>>m;
	int a[20];
	int flag=1;
	memset(a,0,sizeof(a));
	a[1]=1;
	bool vis[20];
	memset(vis,false,sizeof(vis));
	if(n==1)
	{
		int x=0;
		while(m--)
		{
			int s,c;cin>>s>>c;
			if(vis[s]==false)
			{
				vis[s]=true;
				x=c;
			}
			else
			{
				if(x!=c)
				flag=0;
			}
		}
		 if(flag==0)
		 cout<<"-1";
		 else
		 cout<<x;
		 cout<<endl;
	}
	else
	{
		while(m--)
	{
		int s,c;cin>>s>>c;
		if(s==1&&c==0)
		flag=0;
		if(vis[s]==false)
		{
			a[s]=c;
			vis[s]=true;
		}
		else 
		{
			if(a[s]!=c)
			flag=0;
		}
		
	}
	if(flag==0)
	cout<<"-1";
	else
	for(int i=1;i<=n;i++)
	cout<<a[i];
	cout<<endl;
	 } 
	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter

def isOdd(x):
  return x % 2

def solve(n,a):
  d = Counter(a)
  return sum(map(isOdd,d.values()))


def main():
  N = int(input())
  a = [int(input()) for _ in range(N)]
  print(solve(N,a))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 20836
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>


using namespace std;

int main()
{
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << double(w) * (double)h / 2;
    cout << " ";
    if(w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2)
        cout << 1;
    else
        cout << 0;
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;


int main(){
	fast_io();
	const int N = 200005;
	int a[N],x[N] = {};
	int n;
	cin >> n;
	fu(i,1,n){
		cin >> a[i];
		x[i] = a[i];
		a[i] += a[i-1];
		x[i] ^= x[i-1];
	}
	ll ans = 0;
	fu(i,1,n){
		int l = i, r = n, m;
		int best = 0;
		while(l <= r){
			m = l + (r-l)/2;
			if(a[m] - a[i-1] == (x[m] ^ x[i-1])){
				best = m;
				l = m + 1;
			}
			else r = m - 1;
		}
		ans += best - i + 1;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 1792
def check(n, k, w, p):
    i = 0
    for j in range(k):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n:
                return n
    return i
    
n, k = map(int, input().split())
w = [int(input()) for _ in range(n)]

left, right = 0, 10 ** 10

while right - left > 1:
    mid = (left + right) // 2
    v = check(n, k, w, mid)
    if v >= n:
        right = mid
    else:
        left = mid

print(right)



Measured memory_bytes: 9564
#include <iostream>
#include <vector>
#include <set>
#include <array>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <numeric>
#include <random>
#include <iomanip>
#include <chrono>

using namespace std;

int main() {

	int n, r;
	cin >> n >> r;

	cout << ((n >= 10) ? r : r + (10 - n) * 100) << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    N, A, B = map(int, input().split())

    total_sum = 0
    for n in range(1,N+1):
        n_each_sum = sum(map(int, list(str(n))))

        if n_each_sum >= A and n_each_sum <= B:
            total_sum += n

    print(total_sum)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N) for (int i = (init); i < (int)(N); i++)

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int N, K, S;

int dfs(int sum, int n, int start) {
    if (sum == S && n == K) return 1;
    if (sum > S) return 0;
    if (n > K) return 0;

    int cnt = 0;
    REP(i, start, N + 1) {
        cnt += dfs(sum + i, n + 1, i + 1);
    }
    
    return cnt;
}

int main(void) {
    while (cin >> N >> K >> S, N) {
        cout << dfs(0, 0, 1) << endl;
    }

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);

    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

    for (int i = n - 1; i >= 0; i--)
    {
        printf("%d", a[i]);
        if (i != 0)
            printf(" ");
    }
    printf("\n");

    return NULL;
}


Measured memory_bytes: 2716
using System;

class Program
{
    static void Main()
    {
        int r = int.Parse(Console.ReadLine());
        if (r < 1200)
        {
            Console.WriteLine("ABC");
        }
        else if (r < 2800)
        {
            Console.WriteLine("ARC");
        }
        else
        {
            Console.WriteLine("AGC");
        }
    }
}

Measured memory_bytes: 11092
N, M = map(int, input().split())
H = [int(x) for x in input().split()]

Graph = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    Graph[A - 1].append(B - 1)
    Graph[B - 1].append(A - 1)

ans = 0
for i in range(N):
    is_ok = True
    for adj in Graph[i]:
        if H[i] <= H[adj]:
            is_ok = False
    if is_ok:
        ans += 1

print(ans)

Measured memory_bytes: 29436
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

int N, a[MAX];

int main()
{
    optimiza_io
    cin >> N;
    for( int i = 1; i <= N; i ++ )
        cin >> a[i];
    sort( a + 1 , a + N + 1 );
    cout << a[N/2+1] - a[N/2] << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 640
import math
import sys
from itertools import permutations
input = sys.stdin.readline

A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())

if W>=V:
    print("NO")
else:
    if abs(A-B)<=abs(V-W)*T:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 62220