akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

struct Point {
  lint x, y;
};
vector<Point> ans;
int main(void) {
  lint k, x, y;
  cin >> k >> x >> y;
  bool negx = (x < 0), negy = (y < 0);
  x = abs(x);
  y = abs(y);
  bool bigy = (x < y);
  if (bigy) swap(x, y);
  lint xy = x + y;
  lint n  = 0;
  if (!(k & 1) && (xy & 1)) {
    n = -1;
  } else if (xy == k) {
    n = 1;
    ans.push_back({x, y});
  } else  {
    Point now;
    now.x = now.y = 0;
    while ((xy > 2 * k) || (xy & 1)) {
      if (y != now.y) {
        if (y - now.y >= k) {
          now.y += k;
        } else {
          now.x = k - (y - now.y);
          now.y = y;
        }
      } else {
        now.x += k;
      }
      xy -= k;
      ++n;
      ans.push_back(now);
    }
    n += 2;
    lint half  = (2 * k - abs(xy)) / 2;
    int  minus = (xy < 0 ? -1 : 1);
    ans.push_back({now.x + (k - half) * minus, now.y - half * minus});
    ans.push_back({x, y});
  }
  cout << n << "\n";
  allrep (p, ans) {
    if (bigy) swap(p.x, p.y);
    cout << (negx ? -p.x : p.x) << " ";
    cout << (negy ? -p.y : p.y) << "\n";
  }
  return 0;
}

Measured memory_bytes: 6256
N_size = int(input())

cnt_AC = 0
cnt_WA = 0
cnt_TLE = 0
cnt_RE = 0

for i in range(N_size):
    str_input = input()
    if str_input == "AC":
        cnt_AC = cnt_AC + 1
    elif str_input == "WA":
        cnt_WA = cnt_WA + 1
    elif str_input == "TLE":
        cnt_TLE = cnt_TLE + 1
    elif str_input == "RE":
        cnt_RE = cnt_RE + 1

print("AC x " + str(cnt_AC))
print("WA x " + str(cnt_WA))
print("TLE x " + str(cnt_TLE))
print("RE x " + str(cnt_RE))

Measured memory_bytes: 9160
#include<stdio.h>
 
int main(void)
{
	double a, b, c;
	scanf("%lf%lf%lf", &a, &b, &c);
 
	if (a > c)
	{
		printf("%.0f %.0f",a-c,b);
	}else if((a+b)>c) {
		printf("0 %.0f", b - (c - a));
	}else {
      printf("0 0");
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool hamming[1000001]={};
    for(int i=1;i<1000001;i*=5){
        for(int j=i;j<1000001;j*=3){
            for(int k=j;k<1000001;k*=2)hamming[k]=1;
        }
    }
    int m;
    while(cin>>m,m){
        int n,co=0;
        cin>>n;
        for(int i=m;i<=n;i++)if(hamming[i])co++;
        cout<<co<<endl;
    }
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define EPS                 0.00000001
#define LL_MAX              0x3f3f3f3f3f3f3f3f
#define LL_MIN              -0x3f3f3f3f3f3f3f3f
#define MAX                 0x3f3f3f3f
#define MIN                 -0x3f3f3f3f
#define MOD                 1000000007
#define DEBUG(x)            cout << '>' << #x << ':' << x << endl;
#define REP(i,n)            for(int i=0;i<(n);i++)
#define FOR(i,a,b)          for(int i=(a);i<=(b);i++)
#define FORD(i,a,b)         for(int i=(a);i>=(b);i--)
#define n1                  '\n'

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> pt;
typedef vector<pt> pol;

ll power(ll b, int e) {
    ll res = 1;
    for ( ; e>0; e/=2) {
        if (e&1) res = res*b % MOD;
        b = b*b % MOD;
    }
    return res;
}

inline void IOS() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    IOS();
    int n, w;
    cin >> n >> w;
    vector<ll> ws(n+1);
    vector<ll> vs(n+1);
    FOR(i, 1, n) {
        cin >> ws[i];
        cin >> vs[i];
    }
    // dp stores the minimum weight to get total value of j with i items
    ll dp[n+1][100050];
    FOR(i, 0, n) {
        dp[i][0] = 0;
        FOR(j, 1, 100000) {
            dp[i][j] = LL_MAX;
        }
    }
     
    FOR(i, 1, n) {
        FOR(j, 1, 100000) {
            dp[i][j] = dp[i-1][j];
            if (j >= vs[i]) dp[i][j] = min(dp[i][j], dp[i-1][j-vs[i]] + ws[i]);
        }
    }

    ll ret = 0;
    FORD(i, 100000, 0) {
        if (dp[n][i] <= w) {
            ret = i;
            break;
        }
    }

    cout << ret << n1;
    
    return 0;
}


Measured memory_bytes: 79360
#include<iostream>
#include<cstdio>
const int mod=1e9+7;
const int M=2e3+10;
const int N=4e6+10;
using namespace std;
int n,k,h[N],inv[N],finv[N],f[M][M];
int C(int n,int m) {
	return 1ll*h[n]*finv[m]%mod*finv[n-m]%mod;
}
void Pre() {
	h[0]=finv[0]=inv[1]=1;
	for(int i=1;i<=4e6;i++) h[i]=1ll*h[i-1]*i%mod;
	for(int i=2;i<=4e6;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=4e6;i++) finv[i]=1ll*finv[i-1]*inv[i]%mod;
}
int main() {
	Pre();
	scanf("%d%d",&n,&k);
	if(k==1) {puts("1");return 0;}
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++) {
			if(!j) f[i][j]=f[i-1][j];
			else f[i][j]=(f[i-1][j]+1ll*f[i][j-1]*(n-j+1)%mod*C(n-i+(n-j+1)*(k-1)-1,k-2)%mod)%mod;
	}
	printf("%d\n",f[n][n]);
	return 0;
}

Measured memory_bytes: 62080
N = int(input())
s = set()
dic = {}
memo = [0]*(N+1)
sm = {}
memo[0] = 1
P = 10**9 + 7
b = 0

for i in range(1,N+1):
  c = int(input())
  if c not in s:
    s.add(c)
    dic[c] = [i]
    memo[i] = memo[i-1]
  else:
    memo[i] = memo[i-1]
    if b != c:
      if len(dic[c]) == 1:
        sm[c] = memo[dic[c][0]-1]
      else:
        sm[c] += memo[dic[c][-1]-1]
      memo[i] += sm[c]
      memo[i] %= P
      dic[c].append(i)
  b = c
      
print(memo[N])

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
// #define F first
// #define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(){
    string S, left, right, C;
    int Q, rev, T, F;
    cin >> S;
    cin >> Q;
    rev = 0;
    FOR(i,1,Q) {
        cin >> T;
        if (T==1) rev+=1;
        else {
            cin >> F >> C;
            if ((F+rev) % 2 == 1) left+=C;
            else right+=C;
        }
    }

    if (rev % 2 == 0) {
        reverse(ALL(left));
        cout << left+S+right << endl;
    } 
    else {
        reverse(ALL(right));
        reverse(ALL(S));
        cout << right + S + left << endl;
    }
}


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

constexpr int MAX = 200200;
constexpr long long INF = (1LL<<60);

int main() {
    int n;
    long long c;
    cin >> n >> c;
    vector<long long> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    long long dp[MAX];
    int que[MAX];
    dp[0] = 0;
    que[0] = 0;
    
    auto f = [&](int j, int i) -> long long {
        return (-2LL * h[j] * h[i] + dp[j] + h[j] * h[j]);
    };
    
    auto check = [&](int i, int j, int k) {
        long long a1 = -2LL * h[i], b1 = dp[i] + h[i] * h[i];
        long long a2 = -2LL * h[j], b2 = dp[j] + h[j] * h[j];
        long long a3 = -2LL * h[k], b3 = dp[k] + h[k] * h[k];
        return (a2 - a1) * (b3 - b2) >= (b2 - b1) * (a3 - a2);
    };
    
    int s = 0, t = 1;
    for (int i = 1; i < n; i++) {
        while (s + 1 < t and f(que[s], i) >= f(que[s + 1], i)) s++;
        dp[i] = h[i] * h[i] + c + f(que[s], i);
        while (s + 1 < t and check(que[t - 2], que[t - 1], i)) t--;
        que[t++] = i;
    }
    
    cout << dp[n-1] << '\n';
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
typedef pair<int, bool> P;
int main()
{
    int N, M;
    scanf("%d%d", &N, &M);
    vector<bool> flag(N + 1);
    vector<int> e(M + 1);
    rep(i, M) scanf("%d", &e[i]);
    for (int i = M - 1; i >= 0; i--)
    {
        if (flag[e[i]])
            continue;
        flag[e[i]] = true;
        printf("%d\n", e[i]);
    }
    for (int i = 1; i <= N; i++)
    {
        if (!flag[i])
            printf("%d\n", i);
    }
    return 0;
}



Measured memory_bytes: 3412
#include <bits/stdc++.h>

template <typename T> inline void Read(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void Read(T& x, Args&... args) { Read(x); Read(args...); }

typedef long long ll;

const int kN = 1e5 + 5, kInf = 0x3f3f3f3f;

ll x[kN], f[kN];
std::deque<int> que;

int main() {
	memset(f, 0xff, sizeof(f));
	int n; ll T, E; Read(n, E, T);
	for(int i = 1; i <= n; ++i) Read(x[i]);
	x[n + 1] = E;
	int ptr = 0; ll min_fi = kInf;
	f[0] = x[1];
	que.push_back(0);
	for(int i = 1; i <= n; ++i) {
		for(; 2 * (x[i] - x[ptr + 1]) >= T; ++ptr)
			min_fi = std::min(min_fi, f[ptr] - 3 * x[ptr + 1]);
		while(!que.empty() && que.front() < ptr) que.pop_front();
		if(!que.empty()) {
			int tmp = que.front();
			f[i] = f[tmp] - x[tmp + 1] + T;
		}
		f[i] = std::min(f[i], min_fi + 2 * x[i]) + x[i + 1];
		while(!que.empty() && f[que.back()] - x[que.back() + 1] > f[i] - x[i + 1])
			que.pop_back();
		que.push_back(i);
	}
	printf("%lld", f[n]);
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;

void swap(int *a,int *b){
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){

	int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0)break;
		int *d,*p;
		long long int ans;
		ans = 0;
		d = new int[n];
		p = new int[n];
		for(int i=0;i<n;i++){
			cin>>d[i]>>p[i];
			ans += p[i]*d[i];
		}

		for(int i=0;i<n;i++){
			for(int j=n-1;j>i;j--){
				if(p[j]>=p[j-1]){
					swap(&p[j],&p[j-1]);
					swap(&d[j],&d[j-1]);
				}
			}
		}
		for(int i=0;i<n;i++){
			if(m>=d[i]){
				ans-=p[i]*d[i];
				m-=d[i];
			}
			else if(m<d[i]){
				ans-=p[i]*m;
				m-=m;
			}
			else if(m==0)break;
		}

		cout<<ans<<endl;
	}

	return 0;
}

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

typedef long long ll;
int main()
{
    string S;
    cin >> S;

    bool A = S == "hi";
    bool B = S == "hihi";
    bool C = S == "hihihi";
    bool D = S == "hihihihi";
    bool E = S == "hihihihihi";
    if (A || B || C || D || E)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;
int h, w;

char grid[1001][1001];
int dp[1001][1001];



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

    cin >> h >> w;
    for(int i=0;i<h;++i) for(int j=0; j<w; ++j) cin >> grid[i][j];
    dp[0][0]=1;

    for(int i=0;i<h; ++i) {
        for(int j=0; j<w; ++j) {
            if(grid[i][j]=='.')
                dp[i][j+1]+=dp[i][j]%MOD, dp[i+1][j]+=dp[i][j]%MOD;
        }
    }

    cout << dp[h-1][w-1]%MOD << endl;


    return 0;

}



Measured memory_bytes: 5120
#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

const int INF = 1e9 + 1;
const int MAX_N = 3e5 + 1;

int N;
string s;

// 0:w, 1:e
int memo[MAX_N][2];

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

  cin >> N;
  cin >> s;

  int ans = 0;
  int eCnt, wCnt;
  eCnt = wCnt = 0;
  REP(i, N) {
    // e
    if (s[i] == 'E') eCnt++;
    if (s[i] == 'W') wCnt++; 
  }

  ans = min(eCnt, wCnt);

  REP(i, N) {
    if (i > 0) {
      memo[i][0] += memo[i - 1][0];
      memo[i][1] += memo[i - 1][1];
    }
    if (s[i] == 'W') {
      memo[i][0]++;
    } else {
      memo[i][1]++;
    }
  }

  REP(i, N) {
    int tmp = 0;
    tmp += memo[i][0];
    tmp += memo[N - 1][1] - memo[i][1];

    ans = min(ans, tmp);
  }

  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 2964
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;
 
#include <bits/stdc++.h>
using namespace std;
 
using i64 = long long;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k, t; cin >> k >> t;
    vector<int> a(t);
    for(int& x : a) cin >> x;
    int ma = *max_element(a.begin(), a.end());
    cout << max(0, ma * 2 - k - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[4545][2521][2];
int main()
{
	int N,M,K,x,y;cin>>N>>M>>K;
	x=(N+M-1);y=(K-1);
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	lint out=0,mo=1000000007;
	rep(i,x/y) rep(j,M+1){
		if(i*y-j<0 || i*y-j>N-1) dp[i][j][0]=dp[i][j][1]=0;
		lint now=(dp[i][j][0]+dp[i][j][1])%mo;
		dp[i+1][j][0]+=now;dp[i][j][0]%=mo;
		REP(k,1,y+1){
			dp[i+1][j+k][1]+=now;
			dp[i+1][j+k][1]%=mo;
		}
	}
	rep(i,x/y+1) rep(j,M+1){
		if(i*y-j<0 || i*y-j>N-1) continue;
		if((M-j)%y>0) continue;
		//cout<<i<<' '<<j<<' '<<dp[i][j][0]<<' '<<dp[i][j][1]<<endl;
		out+=dp[i][j][1];out%=mo;
	}
	cout<<out%mo<<endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=40;
const ll INF=0x3f3f3f3f;
const ll MOD=998244353;
ll N,ans;
char S[MAX],s1[MAX],s2[MAX];
string tmp;
map<string,ll> m[MAX];
int main(){
    scanf("%lld%s",&N,S);
    for(ll i=0;i<N;i++) s1[i]=S[i],s2[i]=S[2*N-1-i];
    for(ll i=0;i<(1<<N);i++){
        ll cnt=0;
        tmp.clear();
        for(ll j=0;j<N;j++) if((i>>j)&1) tmp.append(1u,s1[j]),cnt++;
        for(ll j=N-1;j>=0;j--) if(!((i>>j)&1)) tmp.append(1u,s1[j]);
        m[cnt][tmp]++;
    }
    for(ll i=0;i<(1<<N);i++){
        ll cnt=0;
        tmp.clear();
        for(ll j=0;j<N;j++) if((i>>j)&1) tmp.append(1u,s2[j]),cnt++;
        for(ll j=N-1;j>=0;j--) if(!((i>>j)&1)) tmp.append(1u,s2[j]);
        ans+=m[cnt][tmp];
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 73984
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------

import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading



threading.stack_size(10**8)
sys.setrecursionlimit(300000)

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
        self.write = self.buffer.write if self.writable else None
     
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
  
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#-------------------game starts now-----------------------------------------------------
n=int(input())
ans=0
d=defaultdict(int)
d1=defaultdict(int)
m=-10**13
m1=-10**13
mi=10**13
mi1=10**13
for i in range(n):
    a,b=map(int,input().split())
    m=max(m,a+b)
    mi=min(mi,a+b)
    m1=max(m1,a-b)
    mi1=min(mi1,a-b)
#print(mi,mi1,m,m1)
print(max(m-mi,m1-mi1))

Measured memory_bytes: 88636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

constexpr ll MOD = 1e9 + 7;

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

    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        cout << "x";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [0]*(K+1)
for k in range(1,K+1) :
    for a in A :
        if k-a >= 0 and dp[k-a] == 0 :
            dp[k] = 1

print("First" if dp[K] else "Second")


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

int main() {
  int a, b;
  cin >> a >> b;
  int i = 0;
  
  if (a >= b) {
    while (i < a) {
      cout << b;
      i++;
    }
  }
    
  else if (a < b) {
    while (i < b) {
      cout << a;
      i++;
    }
  }
    
}

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

int main()
{
    int k;
    int even = 0, odd = 0;

    cin >> k;

    for (int i = 1; i <= k; i++) {
        if (i % 2 == 0) {
            even++;
        } else {
            odd++;
        }
    }

    cout << even * odd << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

int32_t main(){

    int n,a,b;
    cin>>n>>a>>b;
    int d=b-a;
    if(d&1){
        int ans=n+n;
        {
            int pot=a;
            int x=1,y=b-a;
            pot+=(y-x)/2;
            upn(ans,pot);
            dbg(pot);
        }
        {
            int pot=n-b+1;
            int x=a+pot,y=n;
            pot+=(y-x)/2;
            upn(ans,pot);
            dbg(pot);
        }
        cout<<ans<<'\n';
    }else{
        cout<<d/2<<'\n';
    }

    return 0;
}


Measured memory_bytes: 256
M, D= map(int, input().split())


count = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        if len(str(d)) < 2:
            continue
        if int(str(d)[0]) >= 2 and int(str(d)[1]) >= 2:
            if m == int(str(d)[0]) * int(str(d)[1]):
                count += 1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  int a, b, c, d; //かっている数//最大100
  priority_queue<int> v;

  cin >> a;
	if (a<1200){
      cout <<"ABC";
    }else if (a <2800){
      cout <<"ARC";
    }else{
      cout <<"AGC";
    }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int _max(int a[], int n)
{
    int maxn = a[0];
    for (int i = 0; i < n; i++)
        if (a[i] > maxn)
            maxn = a[i];
    return maxn;
}

int _min(int a[], int n)
{
    int minn = a[0];
    for (int i = 0; i < n; i++)
        if (a[i] < minn)
            minn = a[i];
    return minn;
}

int main(void)
{
    int n, m, x, y;
    int xn[105] = {0};
    int yn[105] = {0};
    scanf("%d%d%d%d", &n, &m, &x, &y);

    for (int i = 0; i < n; i++)
        scanf("%d", &xn[i]);
    for (int i = 0; i < m; i++)
        scanf("%d", &yn[i]);

    int maxn = _max(xn, n);
    int minn = _min(yn, m);

    int i;
    for (i = x + 1; i <= y; i++)
    {
        if (i > maxn && i <= minn)
        {
            printf("No War\n");
            break;
        }
    }
    if (i > y)
        printf("War\n");

    return 0;
}

Measured memory_bytes: 128
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n,c = li()
x = []
v = []
for _ in range(n):
    xi,vi = li()
    x.append(xi)
    v.append(vi)

# 時計回りのmax
cw_dist = [0] + x
value_cum = [0] + list(accumulate(v))
cw_value = [value - dist for dist,value in zip(cw_dist, value_cum)]
cw_max = [0]
for i in range(1,n+1):
    cw_max.append(max(cw_max[-1], cw_value[i]))

# 反時計回りのmax
ccw_dist = [0] + [c-xi for xi in x[::-1]]
value_cum2 = [0] + list(accumulate(v[::-1]))
ccw_value = [value - dist for dist,value in zip(ccw_dist, value_cum2)]
ccw_max = [0]
for i in range(1,n+1):
    ccw_max.append(max(ccw_max[-1], ccw_value[i]))
    
#
cands = [0]
for i in range(n+1):
    cand = max(cw_max[i],
               ccw_max[n-i],
               cw_max[i]+ccw_max[n-i] - min(cw_dist[i], ccw_dist[n-i]))
               
    cands.append(max(cands[-1],cand))

print(max(cands))


Measured memory_bytes: 37660
S = input()
st = [(0, 0, -1)]
cur = 0; ma = 0
for i, c in enumerate(S):
    if c == '/':
        cur += 1
        s = 0
        while st and st[-1][0] == cur-1 and cur <= ma:
            lev, su, j = st.pop()
            s += su
        if st and st[-1][0] == cur:
            s += i - st[-1][2] - 1
        ma = max(ma, cur)
        st.append((cur, s, i))
    elif c == '\\':
        cur -= 1
        st.append((cur, 0, i))
    elif c == '_':
        st.append((cur, 0, i))
ans = []
for lev, su, j in st:
    if su > 0:
        ans.append(su)
print(sum(ans))
print(len(ans), *ans)



Measured memory_bytes: 8288
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int t1=c/b+((c%b)?1:0);
    int t2=a/d+((a%d)?1:0);
   // cout<<c%b<<endl;
   // cout<<t1<<' '<<t2<<endl;
    if(t1<=t2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3624
n = int(input())
s = list(map(str,input().split()))

arr = [0] * 4
for i in range(n):
    if s[i] == 'P':
        arr[0] = 1
    elif s[i] == 'W':
        arr[1] = 1
    elif s[i] == 'G':
        arr[2] = 1
    elif s[i] == 'Y':
        arr[3] = 1

if sum(arr) == 3:
    print('Three')
else:
    print('Four')


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

int main(){
        int n,w;
        while(cin>>n>>w,n){
                vector<int> v(n);
                for(int i=0;i<n;i++) cin>>v[i];

                double res=0.01;
                vector<int> height(11,0);
                for(int i=0;i<n;i++){
                        int h=0;
                        int val=v[i];
                        for(;w<=val;h++) val-=w;
                        height[h]++;
                }
                int rigmost=0;
                for(int i=0;i<11;i++) rigmost=max(rigmost,i*(height[i]!=0));
                int highest=*max_element(height.begin(),height.end());

                for(int i=0;i<=rigmost;i++){
                        res+=double(height[i])/highest*double(rigmost-i)/(rigmost);
                }
                cout<<fixed<<setprecision(10);
                cout<<res<<endl;
        }

}

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

int main(){
    int n, m, i, x, y, t;
    cin >> n >> m >> x >> y;
    for(i=0; i<n; i++){
        cin >> t;
        x = max(x, t);
    }
    for(i=0; i<m; i++){
        cin >> t;
        y = min(y, t);
    }
    if(x < y){
        cout << "No War";
    }else{
        cout << "War";
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var city = ToInt32(input[0]);
        var road = ToInt32(input[1]);
        var counter = new int[city];
        for(var i = 0; i < road; i++)
        {
            var input2 = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            counter[input2[0] - 1]++;
            counter[input2[1] - 1]++;
        }

        foreach(var val in counter)
        {
            WriteLine(val);
        }
    }
}

Measured memory_bytes: 11092
def main():
    X = int(input())
    N = X // 100
    M = X % 100
    if M == 0:
        print(1)
        return
    if M % 5 == 0 and M // 5 <= N:
        print(1)
    elif M % 5 > 0 and M // 5 + 1 <= N:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61764
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
#include<cstdio>
#include <numeric>
#include <queue>
#include <list>
#include <math.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
long long mod=1000000007;
int main(){
  int X,Y;cin>>X>>Y;
  if(Y%2==1)cout<<"No"<<endl;
  else{
    if(2*X<=Y&&4*X>=Y){
      cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  }
  





}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    vector<pair<int, int>> v;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(b, a));
    }
    SORT(v);
    int time = 0;
    REP(i, N) {
        time += v[i].second;
        if(v[i].first < time) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 2420
import Data.Ord (comparing)
import Data.List (sortBy)
import Data.Maybe (fromJust)
import Control.Monad (replicateM, foldM)
import qualified Data.ByteString.Char8 as BS


toInt = fst . fromJust . BS.readInt

toIntPair =
    let
        toTuple = \(a : b : _) -> (a, b)
    in
        toTuple . map toInt . BS.words

sortByTime = sortBy $ comparing snd

accepts acc (a, b) =
    let
        cost = a + acc
    in
        if cost <= b then Just cost else Nothing

work = foldM accepts 0

main = do
    n <- toInt <$> BS.getLine
    pairs <- map toIntPair <$> replicateM n BS.getLine

    case work . sortByTime $ pairs of
        Nothing -> putStrLn "No"
        _       -> putStrLn "Yes"


Measured memory_bytes: 94588
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n, b, c, d, e, f = 0;
	cin >> n >> b >> c >> d >> e;
	if (e == 1) {
		cout << min(n * 4, min(b * 2, c)) << endl;
	}
	else {
		f += min(min(n * 8, b * 4), min(c * 2, d)) * (e / 2);
		if (e % 2 == 1) {
			f += min(n * 4, min(b * 2, c));
		}
		cout << f << endl;
	}
	cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  ll n; cin >> n;
  ll n1 = sqrt(n);
  ll n2;
  for (int i = n1+1; i >= 1; i--) {
      if (n%i == 0) {
        n2 = i+n/i-2;
        cout << n2 << endl;
        return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


Int n, K, M;

Int Add(Int &a,Int b){return a = (a + b%M)%M;}

void DP2(Int num, Int dp[310][310]){

  // dp[i][j] := 長さiで残り(j+1)箇所にinsertできる時の通り数。
  for(Int i=0;i<=n;i++) //長さ
    for(Int j=n; j >= 0; j--){ //カーソル
      if(j) Add(dp[i][j-1],dp[i][j]); //カーソルを左に動かす
      if(i < n) Add(dp[i+1][j], dp[i][j] * (j + 1));  //現在のカーソルの左側のどこかにinsert
    }
}

Int DP(){
  // dp[i][j] := iまでの数を使って長さjの数列を作る。
  vector<vector<Int> > dp(K+2, vector<Int>(n+1,0));
  dp[0][0] = 1;

  Int dp2[310][310];
  for(Int i=1;i<=K;i++){ // 使う数

    memset(dp2,0,sizeof(dp2));
    for(Int x=0;x<=n;x++) dp2[x][x] = dp[i-1][x]; //今ままでに作った長さxの物をカーソルxで初期化
    DP2(i, dp2);
    
    for(Int j=0;j<=n;j++) dp[i][j] = dp2[j][0];
  }
  return dp[K][n];
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>n>>K>>M;

  Int ans = DP();
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

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

    int L = scanner.nextInt();
    int N = scanner.nextInt();
    int[] x = new int[N];
    int[] y = new int[N];
    for (int i = 0; i < N; i++) {
      x[i] = scanner.nextInt();
      y[N - i - 1] = L - x[i];
    }
    long[] x2 = new long[N + 1];
    long[] y2 = new long[N + 1];
    for (int i = 1; i <= N; i++) x2[i] = x2[i - 1] + x[i - 1] * 2L;
    for (int i = 1; i <= N; i++) y2[i] = y2[i - 1] + y[i - 1] * 2L;

    long max = x[N - 1];
    for (int n = N - 1; n > 0; n--) {
      int m = N - n;
      max = Math.max(max, Math.max(
          x2[n - 1] - x2[Math.max(n - m - 1, 0)] + y2[m] - y2[Math.max(m - n, 0)] + x[n - 1],
          x2[n] - x2[Math.max(n - m, 0)] + y2[m - 1] - y2[Math.max(m - n - 1, 0)] + y[m - 1]
      ));
    }
    max = Math.max(max, y[N - 1]);
    System.out.println(max);
  }
}


Measured memory_bytes: 94208
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int n, m,a[40][40],ans=0;
	array <int, 40> k, l = {0};
	cin >> n >> m;
	for (int i = 1; i <= n;i++) {
		cin >> k[i];
		for (int j = 1; j <= k[i];j++) {
			cin >> a[i][j];
			l[a[i][j]]++;
		}
	}
	for (int i = 1; i <= m;i++) {
		if (l[i]==n) {
			ans++;
		}
	}
	cout << ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>

int main()
{
    /* INPUT */
    std::vector<std::vector<int>> A(3, std::vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            std::cin >> A[i][j];
        }
    }

    int N;
    std::cin >> N;

    std::vector<int> b(N);
    for (int i = 0; i < N; i++)
        std::cin >> b[i];

    /* SOLVE */
    
    // init
    std::vector<std::vector<int>> B(3, std::vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            B[i][j] = false;
        }
    }

    // 穴をあける
    for (int n = 0; n < N; n++)
    {
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (A[i][j] == b[n])
                    B[i][j] = true;
            }
        } 
    }

    // 確認
    bool ans = false;
    if (B[0][0] == true && B[0][1] == true && B[0][2])
        ans = true;
    if (B[1][0] == true && B[1][1] == true && B[1][2])
        ans = true;
    if (B[2][0] == true && B[2][1] == true && B[2][2])
        ans = true;
    if (B[0][0] == true && B[1][0] == true && B[2][0])
        ans = true;
    if (B[0][1] == true && B[1][1] == true && B[2][1])
        ans = true;
    if (B[0][2] == true && B[1][2] == true && B[2][2])
        ans = true;
    if (B[0][0] == true && B[1][1] == true && B[2][2])
        ans = true;
    if (B[0][2] == true && B[1][1] == true && B[2][0])
        ans = true;
    
    // 表示
    if (ans == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var L = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int max = int.MinValue, sum = 0;
            for (var i = 0; i < L.Length; i++)
            {
                if (L[i] > max) max = L[i];
                sum += L[i];
            }

            Console.WriteLine(sum - max > max ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+1;
long long a[MAXN];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n,i,br=0,l=0,s=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<0)br++;
		if(abs(a[i])<abs(a[l]))l=i;
		s+=abs(a[i]);
	}
	cout<<s-(br&1)*abs(a[l])*2<<'\n';
}


Measured memory_bytes: 1024
import itertools
N, M, X = map(int, input().split())
C = []
for i in range(N):
    C.append(list(map(int, input().split())))
# C = sorted(C)
# num = []
ans = 10000000
rikai = [0] * M
num = [0, 1]
num_list = list(itertools.product(num, repeat=N))


for a in num_list:
    rikai = [0] * M
    kane = 0
    for i in range(N):
        if a[i] == 1:
            for j in range(1, M + 1):
                rikai[j - 1] = rikai[j - 1] + C[i][j]
            kane += C[i][0]
    if all(elem >= X for elem in rikai):
        ans = min(ans, kane)
if ans == 10000000:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define LOG 19
#define off 2

#define mod 1000000007LL

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less< i64 >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 100005

int yes[35] ;
int a[maxn] ;

int main()
{
    int n ;

    scanf("%d",&n) ;

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

    int x = 0 ;

    for(int i=1 ; i<=n ; i++)
    {
        x ^= a[i] ;
        int c = 0 ;
        while( a[i]%2 == 0 )
        {
            a[i] /= 2 ;
            c++ ;
        }
        yes[c] = 1 ;
    }

    int ans = 0 ;

    for(int i=29 ; i>=0 ; i--)
    {
        if( (x&(1<<i)) )
        {
            if( yes[i] ) x ^= ( (1<<(i+1)) - 1 ) ;
            ans++ ;
        }
    }

    if(x!=0)
    {
        printf("-1\n") ;
    }
    else printf("%d\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 640
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}
ll mypow(ll n,ll p){
  if (p == 0)return 1;
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret;
  if (p&1)ret=ret*n;
  return ret;
}
 
int main(){
  int a[10] = {0};

  rep(i,4){
    int tmp;
    cin >> tmp;
    a[tmp]++;
  }
  if (a[1] == 1 && a[9] == 1 && a[7] == 1 && a[4] == 1){
    cout << "YES" << endl;
  } else {
    cout <<"NO" << endl;
  }

  return 0;
}
 
 


Measured memory_bytes: 256
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
signed main()
{
    fasino
    char ch;
    cin>>ch;
    if(ch>='A' and ch<='Z') cout<<'A';
    else cout<<'a';
    return 0;
}

Measured memory_bytes: 3636
S = input()
ok = True
for i in range(len(S)):
  c = S[i]
  if i%2 == 0:
    if c not in "RUD":
      ok = False
      break
  if i%2 == 1:
    if c not in "LUD":
      ok = False
      break
if ok:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i=0;i<3;i++)
            {
                Console.Write(Console.ReadLine().ToCharArray()[i]);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fo(i,a,b) for(i=a;i<=b;i++)
const int maxn=100000+10;
int a[maxn],dis[maxn],co[maxn],h[maxn],go[maxn],nxt[maxn],cnt[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,t,n,m,tot,top,ans,mi;
void add(int x,int y) {
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void travel(int x) {
	int t=h[x];
	while (t) {
		if (!bz[go[t]]) {
			bz[go[t]]=1;
			co[go[t]]=(co[x]+1)%k;
			cnt[(k-co[go[t]])%k]++;
			travel(go[t]);
		}
		t=nxt[t];
	}
}
void dfs(int x) {
	dis[x]=1;
	int t=h[x];
	while (t) {
		dfs(go[t]);
		dis[x]=max(dis[x],dis[go[t]]+1);
		t=nxt[t];
	}
	if (dis[x]>=k&&a[x]>1) {
		ans++;
		dis[x]=0;
	}
}
int sleep() {
	int j=0;
	for(int i=1; i<2000001; i++) j++;
	return j;
}
int main() {
	scanf("%d%d",&n,&k);
	fo(i,1,n) scanf("%d",&a[i]);
	if (a[1]!=1) {
		ans++;
		a[1]=1;
	}
	fo(i,2,n) add(a[i],i);
	dfs(1);
	printf("%d\n",ans);
	sleep();
	return 0;
}

Measured memory_bytes: 5376
def f(n, x):
    count = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                if i < j and j  < k:
                    if i+j+k == x:
                        count += 1
    print(count)
    
while True:
    n, x = map(int, input().split())
    if n ==0 and x == 0:
        break
    else:
        f(n, x)


Measured memory_bytes: 5592
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>

using namespace std;

int main()
{
	string s, ans = { "" };
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '0')ans += "0";
		else if (s[i] == '1')ans += "1";
		else if (s[i] == 'B' && ans != "")ans.replace(ans.length()-1, 1, "");
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int len;
  cin >> len;
  int nums[len];
  for(int i=0; i<len; i++) {
    cin >> nums[i];
  }
  sort(nums, nums+len);
  for(int i=0; i<len-1; i++) {
    if (nums[i] == nums[i+1]) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
} 

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

// [0, MaxNumPlusOne - 1 ] の範囲の整数が素数であるかどうかを表す配列を返す関数
// 配列の要素が 1であれば素数
// 配列の要素が-1であれば素数でない
vector<int> Eratosthenes(int MaxNumPlusOne) {
	vector<int> isPrimeArray(MaxNumPlusOne, 1);
	int MaxNum = MaxNumPlusOne - 1;
	isPrimeArray[0] = -1;
	isPrimeArray[1] = -1;
	for (int i = 2; i <= sqrt(MaxNum); i++) {
		if (isPrimeArray[i] == 1) {
			for (int j = 2; j <= MaxNum; j++) {
				if (i * j > MaxNum) break;
				isPrimeArray[i * j] = -1;
			}
		}
	}
	return isPrimeArray;
}

int main() {

	int n; cin >> n;
	const int p = 55555 +1;
	vector<int> isPrimeNumber = Eratosthenes(p); // [0, p - 1] の範囲を調べる場合
	vector<int> c;
	for (int i = 0; i < isPrimeNumber.size(); i++) {
		if (isPrimeNumber[i] == 1 && i % 5 == 1) {
			c.push_back(i);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << c[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, N, sum;
  sum=0;
  cin >> H >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
    sum+=vec.at(i);
  }
  
  if (sum<H) {
    cout << "No" << endl;
  }
  
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;

const std::string ans[2] = { "No\n", "Yes\n" };
constexpr ll MOD = 1'000'000'007;
// constexpr ll MOD = 998'244'353;
int main() {
    using namespace std;
    int n,r;
    cin>>n>>r;
    int ir=r;
    if(n<10){
        ir+=100*(10-n);
    }
    cout << ir << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
from collections import deque
def main(N, X, Y):
    X -= 1
    Y -= 1
    D = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            D[i][j] = abs(j-i)
            D[j][i] = abs(j-i)
    D[X][Y] = 1
    D[Y][X] = 1
    queue = deque([[X, Y]])
    visited = [[False for _ in range(N)] for _ in range(N)]
    visited[X][Y] = True 
    while queue:
        x,y = queue.popleft()
        for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+i, y+j
            if nx < 0 or nx >= N or ny < 0 or ny >= N:
                continue
            if visited[nx][ny]:
                continue
            else:
                visited[nx][ny] = True
                D[nx][ny] = min(D[nx][ny], D[x][y]+1)
                queue.append([nx, ny])
    ans = [0 for _ in range(N)]
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            v = D[i][j]
            ans[v-1] += 1
    print(*ans[:-1], sep="\n")
if __name__ == "__main__":
    N, X, Y = map(int, input().split())
    main(N, X, Y)

Measured memory_bytes: 147464
import numpy as np
from collections import Counter
# 最頻値
def mode(list):
    c = Counter(list)
    freq_scores = c.most_common()
    max_count = freq_scores[0][1]
    modes = []
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

n = int(input())
s_list = ["a"] * n
for i in range(n):
  s_list[i] = input()
ans_list = mode(s_list)
ans_list.sort()
for i in ans_list:
  print(i)

Measured memory_bytes: 53728