akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=1e6+5;

pii a[N];

vector<pii> pos,neg;

void solve(){
	int n;
	cin>>n;
	rep(i,0,n){
		string s;
		cin>>s;
		int mn=0,tot=0;
		for(char c:s){
			if(c=='(')tot++;
			else tot--;
			amin(mn,tot);
		}
		
		int mn2=0,tot2=0;
		for(int i=sz(s)-1;i>=0;i--){
			if(s[i]==')')tot2++;
			else tot2--;
			amin(mn2,tot2);
		}
		
		
		if(tot >= 0){
			pos.pb({-mn,tot});
			// cout<<mn<<" "<<tot<<" pos\n";
		}
		else{
			neg.pb({-mn2,tot2});
			// cout<<mn<<" "<<tot<<" neg\n";
		}
	}
	
	sort(all(pos));
	sort(all(neg));
	
	int c1=0;
	for(auto k:pos){
		if(k.fr>c1){
			cout<<"No";
			return;
		}
		else c1+=k.sc;
	}
	
	int c2=0;
	for(auto k:neg){
		if(k.fr>c2){
			cout<<"No";
			return;
		}
		else c2+=k.sc;
	}
	
	if(c1==c2){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 19048
while True:
    s=[]
    t=[]
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    else:
        for i in range(n):
            x=int(input())
            s.append(x)
        for i in range(m):
            y=int(input())
            t.append(y)
        s.sort()
        t.sort()
        def search():
            for a in s:
                 for b in t:
                    if (a-b)*2==sum(s)-sum(t):
                        print(a,b)
                        return
            print(-1)
        search()


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

int main ()
{
string S;
cin>>S;
string day[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
for(int i=0;i<7;i++){
    if(day[i]==S){
        cout<<(7-i);
    }
}
return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{
	int n;
	int a[20], b[20], c[19];
	int sum = 0;
	scanf("%d", &n);

	for (size_t i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (size_t i = 0; i < n; i++)
	{
		scanf("%d", &b[i]);
	}
	for (size_t i = 0; i < n - 1; i++)
	{
		scanf("%d", &c[i]);
	}

	sum = b[0];
	for (size_t i = 1; i < n; i++)
	{
		sum += b[i];
		if (a[i - 1] + 1 == a[i])
		{
			sum += c[a[i - 1] - 1];
		}
	}

	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<atcoder/modint>
#include<atcoder/fenwicktree>
using namespace std;
using namespace atcoder;
using mint=modint998244353;
int N,K,p;
main()
{
	cin>>N>>K>>p;
	fenwick_tree<mint>A(N);
	fenwick_tree<int>B(N);
	mint ans=0,X=mint(K-1)/K;
	for(int j=1;j<N;j++)
	{
		--p;
		A.add(p,1/X.pow(max(j,K)-1));
		B.add(p,1);
		cin>>p;
		ans+=(A.sum(0,p)-A.sum(p,N))*X.pow(max(j,K-1))/2+B.sum(p,N);
	}
	cout<<ans.val()<<endl;
}

Measured memory_bytes: 4844
S = input()
N = len(S)

Sr = S[::-1]

S2 = S[:int((N-1)/2)]
S2r =S2[::-1]
S3 = S[int((N+3)/2)-1:N]
S3r =S3[::-1]

#print(S2,S2r)
#print(S3,S3r)
if S ==Sr and S2== S2r and S3==S3r:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
S = input()
keybord = [s for s in S]
editor = ''
for i in range(len(S)):
    if keybord[i] == '0':
        editor += '0'
    elif keybord[i] == '1':
        editor += '1'
    else:
        if editor == '':
            continue
        else:
            editor = editor[:-1]

print(editor)

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

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int odd,even;
    if(n%2==1){
        odd=(n+1)>>1;
        even=(n-1)>>1;
    }else{
        odd=(n)>>1;
        even=(n)>>1;
    }

    cout<<odd*even<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)
#define MOD 1000000007

ll n, k;
ll a[MAXN];
ll sl[MAXN], su[MAXN];

ll mypow(ll n, ll k) {
	ll ret = 1;
	ll cur = n;
	while (k) {
		if (k & 1) {
			ret *= cur;
			ret %= MOD;
		}
		cur *= cur;
		cur %= MOD;
		k >>= 1;
	}
	return ret;
}

ll inv(ll n) {
	return mypow(n, MOD - 2);
}

ll cnk(ll n, ll k) {
	if (k > n) {
		return 0;
	}
	ll ret = 1;
	for (int i = n - k + 1; i <= n; i++) {
		ret *= i;
		ret %= MOD;
	}
	for (int i = 1; i <= k; i++) {
		ret *= inv(i);
		ret %= MOD;
	}
	return ret;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}

	ll sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		sl[i] = sum;
	}
	sum = 0;
	for (int i = n - 1; i >= 0; i--) {
		sum += a[i];
		su[i] = sum;
	}

	ll ret = 0;
	ll cc = 1;
	for (int d = k - 1; d < n; d++) {
		ret += cc * ((su[d] - sl[n - d - 1]) % MOD);
		ret %= MOD;
		cc *= d;
		cc %= MOD;
		cc *= inv(d - k + 2);
		cc %= MOD;
	//	cnk(d - 1, k - 2)
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 5964
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define N 20
using P=pair<int, int>;
using T=tuple<int, int, int>;
#define MP make_pair
#define MT make_tuple
#define REP(x,y,z) for(int x=y;x<=z;x++)
char m[N+5][N+5];
int H, W;
int dirs[][2] = {
    {0, -1}, // up
    {0, 1},  // down
    {-1, 0}, // left
    {1, 0}   // right
};
queue<T> q;
int mw[N+5][N+5];
int maxw;
void init()
{
    maxw = 0;
    while(!q.empty()) q.pop();
    memset(mw, -1, sizeof(mw));
}
bool ok(int i, int j)
{
    return i >= 1 && i <= H && j >= 1 && j <= W &&
        m[i][j] == '.' && mw[i][j] == -1;
}
void bfs(int i, int j, int w)
{
    if(!ok(i, j)) return;
    mw[i][j] = w;
    q.push(MT(i, j, w));
    while(!q.empty())
    {
        tie(i, j, w) = q.front(); q.pop();
        // printf(">> %d %d %d\n", i, j, w);
        for(int d = 0; d < 4; d++)
        {
            int ti = i+dirs[d][0], tj = j+dirs[d][1];
            if(ok(ti, tj))
            {
                mw[ti][tj] = w+1;
                q.push(MT(ti, tj, mw[ti][tj]));
            }
        }
    }
    for(int a = 1; a <= H; a++)
        for(int b = 1; b <= W; b++)
            maxw = max(maxw, mw[a][b]);
}

void dbg()
{
    puts("mw[]: ");
    for(int a = 1; a <= H; a++)
    {
        for(int b = 1; b <= W; b++)
            printf("%3d ", mw[a][b]);
        puts("");
    }
}

int main(int argc, char *argv[])
{
    while(~scanf("%d %d", &H, &W))
    {
        // printf("> %d %d\n", h, w);
        getchar();
        for(int i = 1; i <= H; i++)
        {
            for(int j = 1; j <= W; j++)
            {
                m[i][j] = getchar();
            }
            getchar();
        }

        // for(int i = 1; i <= h; i++)
        // {
        //     for(int j = 1; j <= w; j++)
        //         printf("%c ", m[i][j]);
        //     puts("");
        // }

        int ans = 0;
        for(int i = 1; i <= H; i++)
            for(int j = 1; j <= W; j++)
            {
                init();
                bfs(i, j, 0);
                // dbg();
                // printf("> ans = %d\n", ans);
                ans = max(ans, maxw);
            }
        printf("%d\n", ans);
    }
}

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

typedef long long ll;

ll mod=1e9+7;

ll fac[300010];
 
ll modinv(ll a){
    ll b=mod,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
        }
        u%=mod;
        if(u<0) u+=mod;
    return u;
}
 
void modfac(){
    fac[0]=1;
    for(ll i=1;i<300010;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
}
 
ll modperm(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return (fac[n]*modinv(fac[n-k]))%mod;
}
 
ll modcomb(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}

ll dp[200010];

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  //2個の時を求めればOK
  ll t=(n*m)%mod;
  modfac();
  ll p=((k*(k-1))%mod*fac[t-2])%mod;
  p=((p*modinv(fac[k]))%mod*modinv(fac[t-k]))%mod;
  ll len=0;
  for(ll i=0;i<n;i++){
    len+=i*(i+1)/2;
    len%=mod;
  }
  dp[1]=len;
  for(ll i=2;i<=m;i++){
    dp[i]=(dp[i-1]+len)%mod;
    dp[i]+=((len*2)%mod*(i-1))%mod;
    dp[i]%=mod;
    dp[i]+=((n*n)%mod*((i*(i-1)/2)%mod))%mod;
    dp[i]%=mod;
  }
  cout << (dp[m]*p)%mod << endl;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll d[210];
int main(){
	rep(i,1,201)repp(j,i,201,i)d[j]++;
	ll n;
	scanf("%lld",&n);
	ll ans=0;
	repp(i,1,n+1,2)if(d[i]==8)ans++;
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  string s; cin >> s;

  if (s.front() != 'A') {
    puts("WA"); return 0;
  }

  if (count(begin(s)+2, end(s)-1, 'C') != 1) {
    puts("WA"); return 0;
  }

  s.erase(find(begin(s)+2, end(s)-1, 'C'));
  s.erase(begin(s));

  if (!all_of(ALL(s), [](int c){return islower(c);})) {
    puts("WA"); return 0;
  }

  puts("AC");

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int h,w,i,j;
    cin>>h>>w;
    char arr[h][w];
    ll mod=pow(10,9)+7;
    int dp[h][w]={0};
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            cin>>arr[i][j];
        }
    }
    for(i=1;i<h;i++)
    {
        if(arr[i][0]=='.')
        {
            dp[i][0]=dp[i-1][0];
        }
    }
    for(j=1;j<w;j++)
    {
        if(arr[0][j]=='.')
        {
            dp[0][j]=dp[0][j-1];
        }
    }
    for(i=1;i<h;i++)
    {
        for(j=1;j<w;j++)
        {
            if(arr[i][j]=='.')
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
}


Measured memory_bytes: 5120
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, x;
	cin >> a >> b >> x;
	if (x >= a && x <= a+b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long A, long long B, long long C, long long D)
{
  rep(i, 1000)
  {
    C -= B;
    if (C <= 0)
    {
      cout << "Yes" << endl;
      return;
    }

    A -= D;
    if (A <= 0)
    {
      cout << "No" << endl;
      return;
    }
  }
}

signed main()
{
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long D;
  scanf("%lld", &D);
  solve(A, B, C, D);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

class UnionFind {
private:
  int n;
  vector<int> a;
public:
  UnionFind() {}
  UnionFind(int n) : n(n), a(n, -1) {}
  int find(int x) {return a[x] < 0 ? x : (a[x] = find(a[x]));}
  bool equal(int x, int y) {return find(x) == find(y);}
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] = x;
    n--;
  }
  int size() {return n;}
  int size(int x) {return -a[find(x)];}
};

int w, h;
string p[60];

UnionFind uf;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

pair<bool, pair<int, int> > solve(int y, int x) {
  vector<int> bottom;
  queue<pair<int, int> > que;
  bool used[h][w];
  rep (i, h) rep (j, w) used[i][j] = false;
  que.push(make_pair(y, x));
  pair<int, int> weight;
  set<int> usedSet;
  while (!que.empty()) {
    pair<int, int> now = que.front();
    que.pop();
    if (used[now.first][now.second]) continue;
    used[now.first][now.second] = true;
    weight.first += now.second;
    weight.second += 1;
    if (now.first == h - 1 || (p[now.first][now.second] != p[now.first + 1][now.second] && p[now.first + 1][now.second] != '.')) bottom.push_back(now.second);
    if (now.first != 0 && p[now.first][now.second] != p[now.first - 1][now.second] && p[now.first - 1][now.second] != '.' && !usedSet.count(uf.find((now.first - 1) * w + now.second))) {
      usedSet.insert(uf.find((now.first - 1) * w + now.second));
      pair<bool, pair<int, int> > w = solve(now.first - 1, now.second);
      if (w.first == false) return make_pair(false, make_pair(0, 0));
      weight.first += w.second.first;
      weight.second += w.second.second;
    }
    rep (k, 4) {
      int yy = now.first + dy[k];
      int xx = now.second + dx[k];
      if (yy < 0 || h <= yy) continue;
      if (xx < 0 || w <= xx) continue;
      if (p[y][x] != p[yy][xx]) continue;
      que.push(make_pair(yy, xx));
    }
  }
  sort(bottom.begin(), bottom.end());
  if (2 * weight.first + weight.second <= 2 * weight.second * bottom[0]) return make_pair(false, make_pair(0, 0));
  if (2 * weight.first - weight.second >= 2 * weight.second * bottom.back()) return make_pair(false, make_pair(0, 0));
  return make_pair(true, weight);
}

int main() {
  while (true) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    rep (i, h) cin >> p[i];
    uf = UnionFind(h * w);
    rep (i, h) rep (j, w) if (p[i][j] != '.') rep (k, 4) {
	int ii = i + dy[k];
	int jj = j + dx[k];
	if (ii < 0 || h <= ii) continue;
	if (jj < 0 || w <= jj) continue;
	if (p[i][j] != p[ii][jj]) continue;
	uf.unite(i * w + j, ii * w + jj);
      }
    rep (i, w) if (p[h - 1][i] != '.') {
      if (solve(h - 1, i).first) cout << "STABLE" << endl;
      else cout << "UNSTABLE" << endl;
      goto next;
    }
  next:;
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, x[55], y[55];

int main()
{
    cin >> N;
    map<pair<int, int>, int> mp;

    for (int i = 0; i < N; i++)
        cin >> x[i] >> y[i];

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i == j)
                continue;
            pair<int, int> p = make_pair(x[i] - x[j], y[i] - y[j]);
            mp[p]++;
        }
    }

    int mx = 0;
    for (auto &p : mp)
        mx = max(mx, p.second);

    cout << N - mx << endl;
}

Measured memory_bytes: 384
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[False]*(k+1)
# dp[i]:残り石i個で自分のターンになった時、勝てるならTrue
# dp[0]=False,dp[a]=True,求めるのはdp[k]
# dp[i]={dp[i-a]の中にひとつでもFalseがあればTrue、other->False}
# <=> すべてのai(in a)についてdp[i]=False->dp[i+ai]=True
for i in range(k+1):
      for ai in a:
            if i+ai<=k and not dp[i]:
                  dp[i+ai]=True
print('First' if dp[k] else 'Second')

Measured memory_bytes: 3828
s=input()
K=int(input())
L=[]
for i in range(len(s)):
    for j in range(K+1):
        if i+j==len(s)+1:
            break
        L.append(''.join(s[i:i+j]))
LL=list(set(L))
LL.sort()
print(LL[K])

Measured memory_bytes: 5152
#include<stdio.h>
int search_pattern(int n, int s, int i, int j, int *sum, int *result);
main()
{
	int n = 0, s = 0, i = 0, j = 0, sum = 0, result = 0;
	while(scanf("%d %d", &n, &s), !((0 == n) && (0 == s)))
	{
		search_pattern(n, s, i, j, &sum, &result);
		printf("%d\n", result);
		sum = 0, 
		result = 0;
	}
	return 0;
}
int search_pattern(int n, int s, int i, int j, int *sum, int *result)
{
	for(; (i <= 9) && (j < n); i++)
	{
		*sum += i;
		j++;
		search_pattern(n, s, i + 1, j, sum, result);
		if((*sum == s) && (j == n))
		{
			*result += 1;
		}
		*sum -= i;
		j--;
	}
}

Measured memory_bytes: 600
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    set<ll>s;
    ll i,j,k;
    cin>>i>>j>>k;
    s.insert(i),s.insert(j),s.insert(k);
    cout<<(s.size()==2 ? "Yes" : "No")<<endl;
return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back

int n,m;

int main(){
	
	cin >> n >> m;
	int ans = 0;
	if ( n >= 2 ){
		ans += n * (n-1) / 2;
	}
	if ( m >= 2 ){
		ans += m * ( m-1 ) / 2;
	}
	cout << ans << endl;
	return 0;
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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 (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n, x;
vi arr;
void in(){
    cin >> n >> x;
    rep(i,0,n) arr.push_back(input());
}

void solve(){

    int ans = 1;
    int p = 0;
    rep(i,0,n){
        p += arr[i];
        ans += p <= x;
    }
    print(ans);

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//233
	string s;
	cin>>s;
	int o=0,z=0;
	for(char c:s)if(c=='1')o++;else z++;
	cout<<2*min(o,z);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    ll n; cin >> n;
    ll a[n]; 
    vector<ll> p(n);
    vector<ll> m(n);
    rep(i,n){
        cin >> a[i];
        p[i] = i + a[i];
        m[i] = i - a[i];
    }
    ll ans = 0;
    sort(all(m));
    for(int i = 0; i < n; i++){
        auto l = lower_bound(all(m),p[i]);
        auto r = upper_bound(all(m),p[i]);
        ans += distance(l,r);
    }
    cout << ans;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  
  if(n >= m){
    cout << 0 << endl;
    return 0;
  }
    
  vector<int> x(m);
  for(int i = 0; i < m; i++){
    cin >> x.at(i);
  }
  
  sort(x.begin(), x.end(), greater<int>());
  
  vector<int> dif(m - 1);
  for(int i = 0; i < m - 1; i++){
    dif.at(i) = x.at(i) - x.at(i + 1);
  }
  
  sort(dif.begin(), dif.end());
  
  int ans = 0;
  
  for(int i = 0; i < m - n; i++){
    ans += dif.at(i);
  }
  
  cout << ans << endl;
  
  return 0;
}

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

long double a, b, c;

int main(){
  cin >> a >> b >> c;
  long double left = a + b;
  left += 2 * sqrt(a * b);
  cerr << left << endl;
  cerr << c <<endl;
  if(left < c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
fn solve() {
    let (n, a): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut x: Vec<usize> = (0..n).map(|_| read::<usize>()).collect();
    // [index][sum][number]
    let mut dp = vec![vec![vec![0; n + 1]; a * n + 1]; n + 1];
    dp[0][0][0] = 1;
    for i in 1..n + 1 {
        for s in 0..a * n + 1 {
            for j in 0..i + 1 {
                if j > 0 {
                    match s.checked_sub(x[i - 1]) {
                        Some(subed) => {
                            dp[i][s][j] = dp[i - 1][subed][j - 1] + dp[i - 1][s][j];
                        }
                        None => dp[i][s][j] = dp[i - 1][s][j],
                    }
                } else {
                    dp[i][s][j] = dp[i - 1][s][j];
                }
            }
        }
    }
    let mut res: usize = 0;
    for i in 1..n + 1 {
        res += dp[n][i * a][i];
    }
    // println!("{:?}", dp);
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 56972
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 100012
#define mod 1000000007
inline int M(int x){return (x>=mod)?(x-mod):x;}
inline void Add(int &x,int v){x=M(x+v);}
inline int M1(int x){return (x<0)?(x+mod):x;}
inline int ksm(int p,int k){int res=1;while(k){if(k&1)res=1ll*res*p%mod;k>>=1;p=1ll*p*p%mod;}return res;}
int n,s[N],R[N],V[N],f[N],ne[N][3],now[3],tr[N][3],ans=0;char sc[N];
int main(){
	scanf("%s",sc+1);n=strlen(sc+1);int i,j,v;
	for(i=1;i<=n;i++)s[i]=(s[i-1]+sc[i]-'a'+1)%3;R[n]=n;for(i=n-1;i>=1;i--)R[i]=(sc[i]==sc[i+1])?i:R[i+1];if(R[1]==n){printf("1");return 0;}
	for(i=1;i<=n+1;i++){memcpy(ne[i],ne[i-1],sizeof(ne[i-1]));ne[i][s[i-1]]=i-1;}
	now[0]=now[1]=now[2]=n+1;for(i=n;i>=1;i--){for(j=0;j<=2;j++)while(ne[now[j]][j]>R[i])now[j]=ne[now[j]][j];memcpy(tr[i],now,sizeof(now));}
	f[0]=1;for(i=0;i<n;i++)if(v=f[i]){Add(f[i+1],v);Add(f[tr[i+1][(2-sc[i+1]+'a'+s[i])%3]],v);}
	for(i=1;i<=n;i++)if(s[n]==s[i])ans=M(ans+f[i]);printf("%d",ans);return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  int x[n][n];
  int y[n][n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    for(int j=0; j<a[i]; j++){
    	cin >> x[i][j] >> y[i][j];
    }
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1<<n); ++bit) {
    int v[n];
    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)){
        v[i] = 1;
      }	else{
      	v[i] = 0;
      }
    }
    bool flag = false;
    for(int i=0; i<n; i++){
      cerr << v[i] << endl;
      if(v[i] == 1){
        for(int j=0; j<a[i]; j++){
          if(v[(x[i][j]-1)] != y[i][j]){
            cerr << v[(x[i][j]-1)] << " " << y[i][j] << endl;
          	flag = true;
          	break;
          }
        }if(flag) break;
      }
    }
    if(!flag){
      int num = 0;
      for(int i=0; i<n; i++){
          num += v[i];
      }
      if(num > ans){
          ans = num;
      }
    }
    
    cerr << "-------------" << endl;
  }

  
  cout << ans << endl;

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

ll dp[3010][3010];
int main(){
    ll n,s;cin>>n>>s;
    vl a(n+1);
    rep(i,3010){
        rep(j,3010)dp[i][j]=0;
    }
    rep(i,n)cin>>a[i+1];
    dp[1][0]=1;
    dp[1][a[1]]=1;
    for(ll i=2;i<=n;i++){
      rep(j,s+1){
        dp[i][j]+=2*dp[i-1][j];
        dp[i][j]-=dp[i-2][j];
        if(j>=a[i])dp[i][j]+=dp[i-1][j-a[i]]-dp[i-2][j-a[i]];
        dp[i][j]%=MOD;
      }
      dp[i][0]++;
      dp[i][a[i]]++;
    }
    cout<<(dp[n][s]+MOD)%MOD<<endl;
    //rep(i,n+1){
        //rep(j,s+1)cout<<dp[i][j]<<" ";
        //cout<<endl;
    //}
}

Measured memory_bytes: 71040
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll a, b;
  cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Possible"
#define NO  "No"

using namespace std;

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

  bool flag = false;
  int num = 0;

  int a, b; cin >> a >> b;
  if (a % 3 == 0) flag = true;
  if (b % 3 == 0) flag = true;
  if ((a + b) % 3 == 0) flag = true;

  cout << (flag ? "Possible" : "Impossible") << endl;

  
  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

#define rep(i,n) for (int i = 0; i < (n); ++i)

int main()
{
  int n, k ,q;
  cin >> n >> k >> q;
  vector<int> man(n+1);
  rep(i,q) {
    int tmp;
    cin >> tmp;
    man[tmp]++;
  }

  for (int i = 1; i <= n; i++) {
    if (man[i] + k - q <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

}



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

long long a[101010],b[101901];
long long f[102][101010];
int n,m;
long long maxx=0;

int main()
{
    cin >> n >> m;
    for(int i=1; i<=n; i++) cin >> a[i] >> b[i];
    for(int j=1; j<=m; j++)
    {
        for(int i=1; i<=n; i++)
        {
            if(j>=a[i]) f[i][j]=max(f[i-1][j-a[i]]+b[i],f[i-1][j]);
            else f[i][j]=f[i-1][j];
            maxx=max(f[i][j],maxx);
        }
    }
    cout << maxx;
}


Measured memory_bytes: 81408
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> hh(h, false);
	vector<bool> ww(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				hh[i] = true;
				ww[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (hh[i]) {
			for (int j = 0; j < w; j++) {
				if (ww[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }





int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n;cin>>n;
    string s = "";
    n--;
    while (n>=0)
    {
        int k = n%26;
        s += 'a' + k;
        n /= 26;
        n--;
    }
    reverse(s.begin() , s.end());
    cout<<s;
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
X = input()

def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x = x + (x >> 8) 
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

a = X.count("1")
ap, am = a+1, a-1
Flag = True

if am == 0:
  Flag = False
  am += 1

Ap = [1]
Am = [1]

for i in range(N-1):
  Ap.append(Ap[-1]*2%ap)
  Am.append(Am[-1]*2%am)

Aps = 0
Ams = 0

for i in range(N):
  if X[-1-i] == "1":
    Aps += Ap[i]
    Aps %= ap
    Ams += Am[i]
    Ams %= am 

for i in range(N):
  cnt = 1
  if X[i] == "1":
    if Flag:
      p = Ams - Am[-1-i]
      p %= am
    else:
      cnt -= 1
      p = 0
  else:
    p = Aps + Ap[-1-i]
    p %= ap
  temp = p
  while temp > 0:
    temp %= popcount(temp)
    cnt += 1
  print(cnt)

Measured memory_bytes: 96532
#include<bits/stdc++.h>
using namespace std;
long long x;
int main() {
	scanf("%lld",&x);
	long long ans = 100;
	for(int i=1;;++i) {
		ans = (double)ans * (double)1.01;
		if(ans >= x) return printf("%d",i),0;
	}
	return 0;
} 

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

int main()
{
    int n, m, i, j;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    for (i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    for (i = 0; i < m; i++)
    {
        cin >> b.at(i);
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n - m + 1; j++)
        {
            int key = 0;
            while (a.at(i + key).substr(j, m) == b.at(key))
            {
                key++;
                if (key == m || i + key == n)
                {
                    if (key == m)
                    {
                        cout << "Yes" << endl;
                        return 0;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3640
# encoding:utf-8
import math

def main():
	N, P = list(map(int, input().split()))
	biscuits = list(map(int, input().split()))

	n_odd = sum([x % 2 for x in biscuits])
	n_even = N - n_odd

	out = calcNPtrn_odd(n_odd, P) * calcNPtrn_even(n_even)
	print(out)
	
def calcComb(n, m):
	return(math.factorial(n)/math.factorial(m)/math.factorial(n-m))

def calcNPtrn_odd(n, is_odd):
	if n == 0:
		if is_odd == 1:
			return(0)
		else:
			return(1)

	count = 0
	if is_odd == 1:
		for i in range(1, n + 1, 2):
			count += calcComb(n, i)
	else:
		for i in range(0, n + 1, 2):
			count += calcComb(n, i)

	return(int(count))

def calcNPtrn_even(n):
	if n == 0:
		return(1)

	count = 1
	for i in range(1, n + 1):
		count += calcComb(n, i)
	return(int(count))

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define drep(i,cc,n) for(int i=cc;i>n;--i)
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 (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main() {
    int n,k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;
    string t;
    cin>>t;

    ll ans = 0;
    string hoge;
    rep(i,0,n) {
        if(i < k - 1){
            if(t[i] == 'r') {ans += p; hoge += 'p';}
            if(t[i] == 's') {ans += r; hoge += 'r';}
            if(t[i] == 'p') {ans += s; hoge += 's';}
        }

        else{
            if(t[i] == 'r'){
                if(hoge[i - k] == 'p'){
                    //ans += 1;
                    hoge += 'g';
                }
                else{
                    ans += p;
                    hoge += 'p';
                }
            }

            if(t[i] == 's'){
                if(hoge[i - k] == 'r'){
                    //ans += 1;
                    hoge += 'g';
                }
                else{
                    ans += r;
                    hoge += 'r';
                }
            }

            if(t[i] == 'p'){
                if(hoge[i - k] == 's'){
                    //ans += 1;
                    hoge += 'g';
                }
                else{
                    ans += s;
                    hoge += 's';
                }
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
bool IsPrime(int num) {
  if (num % 2 == 0) { 
    return false;
  }
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  int X = 0;
  cin >> X;
  if(X == 2) {
    cout << 2 << endl;
  }
  else {
    for(int i = 0; i < 100000; i++) {
      if(IsPrime(X+i) == true) {
        cout << X + i << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 256
h,w,K=map(int,input().split())
c=[input() for _ in range(h)]

black=0
for i in range(h):
    black+=c[i].count('#')

import itertools

count=0

for i in list(itertools.product((0,1),repeat=h)):
    for j in list(itertools.product((0,1),repeat=w)):
        b=black
        for k in range(h):
            b-=i[k]*(c[k].count('#'))
        for l in range(w):
            b-=j[l]*([d[l] for d in c].count('#'))
        for l in range(h):
            for m in range(w):
                if i[l]==1 and j[m]==1:
                    if c[l][m]=='#':
                        b+=1
        if b==K:
            count+=1

print(count)

Measured memory_bytes: 9108
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int n;
Int cnt;

bool ok(Int n, Int k){
    Int m = (n-k)/k;
    if(m == 0)return false;
    return n/m == n%m;
}
int main(){
    cin >> n;
    for(Int i = 1;i * i <= n;i++){
        if(n % i)continue;
        if(ok(n, i))cnt+=(n-i)/i;
        if(n / i != i)if(ok(n,n/i))cnt+=(n-n/i)/(n/i);
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

long long n,P,sol;
int prime[1000050],lg;
bitset<1000050>t;

void Ciur()
{
    int i,j;
    for(i=3;i*i<1000050;i+=2)
        if(t[i]==0)
            for(j=i*i;j<1000050;j=j+2*i)
                t[j]=1;
    lg=1;
    prime[1]=2;
    for(i=3;i<1000050;i+=2)
        if(t[i]==0)
            prime[++lg]=i;
}

long long Lgput(long long a,int x)
{
    long long p=1;

    while(x)
    {
        if(x%2)
            p=p*a;
        x/=2;
        a=a*a;
    }
    return p;
}

void Desc()
{
    int d=2,cnt;

    for(int i=1;P>1 && 1LL*d*d<=P;i++)
    {
        if(P%d==0)
        {
            cnt=0;
            while(P%d==0)
            {
                cnt++;
                P/=d;
            }
            sol=sol*Lgput(d,cnt/n);
        }
        d=prime[i+1];
    }

    if(P>1)
        sol=sol*Lgput(P,1/n);
}



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

    sol=1;
    Ciur();
    Desc();

    cout<<sol;
    return 0;
}


Measured memory_bytes: 640
if __name__ == "__main__":
    while True:
        n, m, a = map(int, raw_input().split())
        if n == 0 and m == 0 and a == 0:
            break

        now = a
        amida = [[] for i in range(1001)]

        for i in range(m):
            h, p, q = map(int, raw_input().split())
            amida[h].append((p, q))
        
        for height in range(1000 - 1, 0, -1):
            lines = amida[height]
            for l in lines:
                if l[0] == now:
                    now = l[1]
                elif l[1] == now:
                    now = l[0]

        print now

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

int main(){
    int N;
    cin >> N;
    priority_queue<int> que;
    int val;

    for(int i=0; i<N; i++){
        cin >> val;
        que.push(val);
    }

    int ans = 0;
    bool isAlice = true;
    while (que.size() > 0){
        int tmp_val = que.top();que.pop();
        if (isAlice){
            ans += tmp_val;
        }else{
            ans -= tmp_val;
        }
        isAlice = !isAlice;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3588
#include<stdio.h>
int main(void)
{
	long long a,b,c,d,e,f,g,h,max;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	e=a*c;
	f=a*d;
	g=b*c;
	h=b*d;
	max=e;
	if(f>max) max=f;
	if(g>max) max=g;
	if(h>max) max=h;
	printf("%lld\n",max);
	return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

class DisjointSet
{
public:
    DisjointSet() {}
    DisjointSet(int n)
    : p(vs32(n, -1)), w(vs32(n, 0))
    {}
    ~DisjointSet() {}

    bool same(int x, int y)
    {
        x = parent(x);
        y = parent(y);
        return x == y;
    }

    int diff(int x, int y)
    {
        parent(x); parent(y);
        return w[y] - w[x];
    }

    void unite(int x, int y, int d)
    {
        int rx = parent(x);
        int ry = parent(y);

        if (rx == ry) return;

        if (p[rx] > p[ry])
        {
            swap(rx, ry);
            swap(x, y);
            d = -d;
        }
        p[rx] += p[ry];
        p[ry] = rx;
        w[ry] = w[x] + d - w[y];
    }

    int parent(int x)
    {
        int ret;
        if (p[x] < 0)
        {
            ret = x;
        }
        else
        {
            ret = parent(p[x]);
            w[x] += w[p[x]];
            p[x] = ret;
        }
        return ret;
    }

    vs32 p;
    vs32 w;
};

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

    int n, m;
    cin >> n >> m;

    DisjointSet ds(n);
    rep (i, m)
    {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (ds.same(l, r) && ds.diff(l, r) != d)
        {
            cout << "No\n";
            return 0;
        }
        else
        {
            ds.unite(l, r, d);
        }
    }

    cout << "Yes\n";
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n, k;
    cin >> n >> k;
    long double prob=0;

    for(int i=1; i<=n; i++){
        long double iprob = 1;
        //サイコロを振った時点でk以上である場合
        if(i >= k){
            prob += 1;
            continue;
        }
        //k以上になるには何回表が出る必要があるか数える
        int count=0;

        while(true){
            if(pow(2,count)*i >= k) break;
            count ++;
        }
        for(int j=0; j<count; j++){
            iprob /= 2;
        }
        prob += iprob;
    }
    prob /= n;

    cout << setprecision(12) << prob << endl;
}

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

int n,x[105],mi=10000000,z;

int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>x[i];
    for(int i=0;i<=100;i++){
        z=0;
        for(int j=0;j<n;j++){
            z+=(x[j]-i)*(x[j]-i);
        }
        mi=min(mi,z);
    }
    cout<<mi<<endl;
    
    return 0;
}


Measured memory_bytes: 256