akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
using namespace std;

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}
int main() {

  int N;
  string S;
  cin >> N >> S;
  
  int stand_west[N];
  int stand_east[N];

  int preview;
  
  stand_east[0] = 0;
  stand_west[N-1] = 0;
  for(int i=0; i<N; i++) {
    if(i==0) {
      continue;
    }
    else {
      stand_east[i] = stand_east[i-1];
      stand_west[N-i-1] = stand_west[N-i];
      if(S[i-1] == 'W')
	stand_east[i]++;
      if(S[N-i] == 'E')
	stand_west[N-i-1]++;
    }
  }
  int min = N,temp;
  for(int i=0; i<N; i++) {
    temp = stand_east[i]+stand_west[i];
    min = min > temp ? temp : min;
  }
  cout << min << endl;
  return 0;
}

  


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

string S;
cin >> S;
int Q;
cin >> Q;

deque<char> deq;
rep(i,S.size()) {
    deq.push_back(S[i]);
}

// rev = 0のときデフォルト
// rev = 1のとき反転状態
int rev = 0;

while(Q--) {
    int T;
    cin >> T;
    //type1
    if(T == 1) {
        rev = 1 - rev;
    }

    // type2
    else {
        int F;
        char C;
        cin >> F >> C;
        F--;
        if (rev) F = 1 - F; // 反転状態だったら、フラグを反転
        if (F == 0) deq.push_front(C);
        else deq.push_back(C);

    }
}

if(rev) reverse(all(deq));
for(auto c:deq) cout << c ;
cout << endl;
return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{

   ll a,b,k,s,l;
   cin>>a>>b>>k;
   if(k<=a)
   {
       cout<<a-k<<" "<<b<<endl;
   }
   else
   {
       if((k-a)<=b)
       {
           cout<<"0"<<" "<<b-(k-a)<<endl;
       }
       else cout<<"0"<<" "<<"0"<<endl;
   }
   }




Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
 int N;
  cin >> N;
  int C[N];
  int V[N];
  for(int i=0;i<N;i++){
	cin >> C[i];
  }
  for(int i=0;i<N;i++){
	cin >> V[i];
  }  
  int sum=0;
  for(int i=0;i<N;i++){
	if(C[i]>V[i]){
		sum+=C[i]-V[i];
    }
  }
  cout << sum;
  
  return 0;
}


Measured memory_bytes: 256
/*enjoy karo yaar*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

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

int n,m;
vector<string> s;
vector<vector<int>> dist;
queue<pii> q;

bool valid(int x,int y)
{
    return (x>=0 && x<n && y>=0 && y<m && s[x][y]!='#' && dist[x][y]==inf);
}

int bfs(int sx,int sy)
{
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
            dist[i][j]=inf;
    }

    dist[sx][sy]=0;
    q.push({sx,sy});

    int res=0,x,y;
    pii p;

    while(!q.empty())
    {
        p=q.front();
        q.pop();

        res=max(res,dist[p.F][p.S]);

        for(int i=0;i<4;++i)
        {
            x=p.F+dx[i];
            y=p.S+dy[i];

            if(valid(x,y))
            {
                dist[x][y]=dist[p.F][p.S]+1;
                q.push({x,y});
            }
        }
    }

    return res;
}

void solve()
{
    cin>>n>>m;

    dist.resize(n,vector<int>(m));
    s.resize(n);
    for(int i=0;i<n;++i)
        cin>>s[i];

    int ans=0,tmp;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
        {
            if(s[i][j]=='.')
            {
                tmp=bfs(i,j);
                ans=max(ans,tmp);
            }
        }
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[7], b[7];
	int i;
	
	for (i=0; i<7; i++){
		scanf("%d %d", &a[i], &b[i]);
	}
	
	for (i=0; i<7; i++){
		printf("%d\n", a[i]-b[i]);
	}
						
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <float.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int n;
	long int i, j, k;
	long int sum = 0;
	
	scanf("%ld", &n);
	
	for(i = 2; i <= (int)sqrt(n); i++) {
		if(n % i == 0) {
			if( (n / (i - 1)) == (n % (i - 1)) ) {
				sum += (i - 1);
			}
			if( (n / (n / i - 1)) == (n % (n / i - 1)) ) {
				sum += (n / i - 1);
			}
		}
	}
	
	if(n != 2) {
		sum += n - 1;
	}
	
	if( (n % (int)sqrt(n) == 0) && (n > 3) ) {
		if( (n / ((int)sqrt(n) - 1)) == (n % ((int)sqrt(n) - 1)) ) {
			sum -= (int)sqrt(n);
		}
	}
	
	printf("%ld\n", sum);
	
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> t(n), a(n);

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

    long long x = t[0], y = a[0];

    for (int i = 1; i < n; ++i) {
        ll t0 = t[i], a0 = a[i];
        ll k0 = (x + t0 - 1) / t0, k1 = (y + a0 - 1) / a0;

        x = t0 * max(k0, k1);
        y = a0 * max(k0, k1);
    }

    cout << x + y << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
  const long double RATE = 380000; 
  
  int n;
  
  long double sum = 0;
  long double x;
  string u;
  int i;
  
  cin >> n;
  for(i=0; i<n; i++)
  {
    cin >> x >> u;
    if(u == "BTC")
    {
      sum = sum + RATE*x;
    }
    else
    {
      sum = sum + x;
    }
  }
  cout << sum;
  
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

struct e {
	int u,v,w;
	e(int u, int v, int w):u(u),v(v),w(w){}
};

int main() {
	int l;cin>>l;l--;
	vector<e> ans;
	int n=1,c=1,m=1;
	while(n<=18){
		l-=c;
		ans.push_back(e(n,n+1,0));
		ans.push_back(e(n,n+1,c));
		n++;
		if(l>=2*c) c*=2;
		else break;
	}
	if(l>0){
		ans.push_back(e(n,n+1,l));
		n++;
	}
	while(l>0){
		l--;
		int s=1;
		while(l>=pow(2,s-1)&&s<=18) {l-=pow(2,s-1);s++;}
		ans.push_back(e(s,n,l));
	}
	cout<<n<<' '<<ans.size()<<endl;
	for(auto i : ans) cout<<i.u<<' '<<i.v<<' '<<i.w<<endl;
}


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

int main() {
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) cin >> B.at(i);
  vector<vector<int>> A(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      int a;
      cin >> a;
      A[i].push_back(a);
    }
  }
  int ans = 0; 
  for (int i=0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < M; j++) {
      sum += A[i][j] * B[j];
    }
    sum += C;
    if (sum > 0) ans++;
  }
  cout << ans << endl;
}
  




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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> x(n);
  for (auto &e : x) {
    cin >> e;
  }
  ll r = 1e9;
  for (int i = 0; i < n - k + 1; i++) {
    ll a = abs(x[i]), b = abs(x[i + k - 1]);
    if (x[i] * x[i + k - 1] >= 0) {
      r = min(r, max(a, b));
    } else {
      r = min(r, min(a, b) + a + b);
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 1152
class State:
    d = {
        "E": lambda l: zip((0, 2, 3, 5), (l[3], l[0], l[5], l[2])),
        "N": lambda l: zip((0, 1, 4, 5), (l[1], l[5], l[0], l[4])),
        "S": lambda l: zip((0, 1, 4, 5), (l[4], l[0], l[5], l[1])),
        "W": lambda l: zip((0, 2, 3, 5), (l[2], l[5], l[0], l[3]))
        }

    def __init__(self, s, t):
        self.pos = list(range(1, 7))
        self.pip = s.split()
        self.log = t

    def __call__(self):
        for c in self.log:
            for i, v in self.d[c](self.pos):
                self.pos[i] = v

    def __str__(self):
        return self.pip[self.pos[0]-1]

state = State(input(), input())
state()
print(state)

Measured memory_bytes: 7644
# abc160_d.py
import sys
import time
import unittest
from io import StringIO
from collections import defaultdict


def resolve():
    N, X, Y = [int(i) for i in input().split()]
    dd = defaultdict(int)
    X -= 1
    Y -= 1
    for i in range(N):
        for j in range(i + 1, N):
            dd[min(j - i, abs(X - i) + 1 + abs(Y - j),
                   abs(Y - i) + 1 + abs(X - j))] += 1
    for i in range(1, N):
        print(dd[i])


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def checkTLE(self, input):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin

    def debugIO(self, input):
        stdin = sys.stdin
        sys.stdin = StringIO(input)
        resolve()
        sys.stdin = stdin

    def setUp(self):
        self.startTime = time.time()

    def tearDown(self):
        t = time.time() - self.startTime
        print('%s: %.3f' % (self.id(), t), flush=True)

    def test_入力例_1(self):
        input = """5 2 4"""
        output = """5
4
1
0"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 1 3"""
        output = """3
0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """7 3 7"""
        output = """7
8
4
2
0
0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """10 4 8"""
        output = """10
12
10
8
4
1
0
0
0"""
        self.assertIO(input, output)

    def test_入力例_TLE(self):  # TODO:
        input = """2000 2 4"""
        self.checkTLE(input)


if __name__ == "__main__":
    if "IS_LOCAL" in locals():
        suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
        unittest.TextTestRunner(verbosity=0).run(suite)
    else:
        resolve()


Measured memory_bytes: 6264
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<stack>
#define pii std::pair<int,int>
using namespace std;

long long a[2010]={0};
long long b[2010][2010]={0};

int main()
{   
	long long n,x,i,j,sum,minx,temp;
    scanf("%lld%lld",&n,&x);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(i=1;i<=n;i++){
        b[i][0]=a[i];
        for(j=1;j<n;j++){
            temp=i-j;
            if(temp<=0)
                temp=n+temp;
            b[i][j]=min(b[i][j-1],a[temp]);  
        }
    }
    minx=99999999999999;
    for(i=0;i<n;i++){
        sum=0;
        for(j=1;j<=n;j++)
            sum+=b[j][i];
        sum+=i*x;
        minx=min(sum,minx);
    }
    printf("%lld\n",minx);
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

char C[30];
bool U[30];

bool check(string S, string T) {
    ll N = S.length();
    REP(i, 27) {
        C[i] = (char) ('a' + i);
    }
    memset(U, 0, sizeof(U));
    REP(i, N) {
        char s = C[S[i] - 'a'];
        char t = T[i];
        if (s == t)
            continue;

        if (U[t - 'a'] || U[s - 'a'])
            return false;
        ll si = -1, ti = -1;
        REP(j, 27) {
            if (C[j] == s)
                si = j;
            if (C[j] == t)
                ti = j;
        }

        C[si] = t;
        C[ti] = s;
        U[t - 'a'] = true;
    }
    return true;
}

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

    string S, T;
    cin >> S >> T;
    if (check(S, T))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1112
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
S = []
for i in range(1,100):
    if N < 27:
        break
    N -= 1
    S.append(chr(ord('a')+N%26))
    N = N//26
S.append(chr(ord('a')+N-1))
print(''.join(S[::-1]))

Measured memory_bytes: 10064
#include <iostream>

using namespace std;
int main(void){
	int card[4][13]={0};
	char mark[4] = {'S','H','C','D'};
	int num;
	int a,b;
	char m;
	cin>>num;
	for(int i=0;i<num;i++){
		cin>>m>>b;
		for(int j=0;j<4;j++){
			if(m==mark[j]){
				a=j;
				break;
			}
		}
		card[a][b-1]++;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
			if(card[i][j]==0)
				cout<<mark[i]<<" "<<j+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC173C
{
    class Program
    {
        static int count = 0;
        static void Main(string[] args)
        {
            string[] HWK = Console.ReadLine().Split(' ');
            int H = int.Parse(HWK[0]);
            int W = int.Parse(HWK[1]);
            int K = int.Parse(HWK[2]);
            string[,] A = new string[H, W];
            int[] Hyn = new int[H];
            int[] Wyn = new int[W];
            string[] yn = new string[H + W];
            int black = 0;
            for(int i = 0; i < H; i++)
            {
                string ci = Console.ReadLine();
                for(int j = 0; j < W; j++)
                {
                    A[i, j] = ci[j].ToString();
                    if (ci[j].ToString() == "#")
                    {
                        black += 1;
                    }
                }
            }
            tansaku(H, W, yn, 0,A,K);
            Console.WriteLine(count);

        }
        static void tansaku(int H,int W, string[] yn, int num, string[,] A, int K)
        {
            if (num == H + W)
            {
                int B = 0;
                for(int i = 0; i < H; i++)
                {
                    for(int j = 0; j < W; j++)
                    {
                        if (yn[i] == "n" & yn[H + j] == "n")
                        {
                            if (A[i, j] == "#")
                            {
                                B += 1;
                            }
                        }
                    }
                }
                if (B == K)
                {
                    count += 1;
                }
                //Console.WriteLine(string.Join(" ", yn));
            }
            else
            {
                yn[num] = "y";
                tansaku(H, W, yn, num + 1,A,K);
                yn[num] = "n";
                tansaku(H, W, yn, num + 1,A,K);
            }
        }
    }
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  char c;
  cin >> c;

  if ('A' <= c && c <= 'Z') {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

// Low Linkを計算して橋と関節点を見つける
// ref : http://kagamiz.hatenablog.com/entry/2013/10/05/005213
struct low_link
{
    int n, m;
    vector<vector<int>> G;
    vector<pair<int, int>> bridge;
    vector<int> articulation;
    vector<int> ord, low;
    vector<bool> vis;

    low_link(vector<vector<int>> G, int n, int m) : G(G), n(n), m(m)
    {
        ord.resize(n);
        low.resize(n);
        vis.resize(n);

        int k = 0;
        REP(i, n){
            if(!vis[i]) dfs(i, -1, k);
        }

        SORT(bridge);
        SORT(articulation);
    }

    vector<pair<int, int>> get_bridge(){
        return bridge;
    }

    vector<int> get_articulation(){
        return articulation;
    }

private:
    void dfs(int v, int p, int &k)
    {
        vis[v] = true;
        
        ord[v] = k++;
        low[v] = ord[v];
        
        bool isArticulation = false;
        int ct = 0;
        
        // for (int i = 0; i < G[v].size(); i++){
        for (auto&& c : G[v]){
            if (!vis[c]){
                ct++;
                dfs(c, v, k);
                low[v] = min(low[v], low[c]);
                if (~p && ord[v] <= low[c]) isArticulation = true;
                if (ord[v] < low[c]) bridge.push_back(make_pair(min(v, c), max(v, c)));
            }
            else if (c != p){
                low[v] = min(low[v], ord[c]);
            }
        }
        
        if (p == -1 && ct > 1) isArticulation = true;
        if (isArticulation) articulation.push_back(v);
    }
};

int main(void)
{
    int v,e;
    cin >> v >> e;
    vector<vector<int>> G(v);
    REP(i, e){
        int s,t;
        cin >> s >> t;
        G[s].pb(t);
        G[t].pb(s);
    }

    low_link low(G, v, e);
    auto b = low.get_bridge();
    for(auto&& bi : b){
        pr(bi.fi, bi.se);
    }
}


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

 
int main() {
   string s,t;
   cin>>s>>t;
   
   int count=0,i;
   int l =s.size();
   for(i=0;i<l;i++)
	if(s[i]!=t[i]) count++;
	
	cout<<count<<endl;
    
    
	return 0;
}

Measured memory_bytes: 3892
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define MP make_pair
#define MEM(i,j) memset(i,j,sizeof i)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n,k,tmp,ans;
pll a[110000];
bitset<110000> b;

int main()
{Tie
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i].first>>a[i].second;
	for(int i=1<<30;1;i>>=1)
	{
		if(!i||(i&k))
		{
			tmp=0;
			for(int j=0;j<n;j++)
				if(!b[j]&&(i&a[j].first)==0)
					tmp+=a[j].second;
			ans=max(ans,tmp);
		}
		else
			for(int j=0;j<n;j++)
				if(a[j].first&i)
					b[j]=1;
		if(!i)break;
	}
	cout << ans<<'\n';
}


Measured memory_bytes: 1792
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

from itertools import accumulate
A = [0] + list(accumulate(a))
B = [0] + list(accumulate(b))

ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 135804
use std::io::Read;

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

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();
    let h: u64 = iter.next().unwrap().parse().unwrap();

    let ans = calc(h);

    return format!("{}", ans);
}

fn calc(i: u64) -> u64 {
    if i == 1 {
        return 1;
    }
    return 1 + 2 * calc(i / 2);
}

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

int main(){
    int array[3];
    for(int k = 0;k < 3;k++)

    scanf("%d",&array[k]);
        for(int k = 2;k > 0;k--)
        {
            for(int l = 0;l < k;l++){
            if(array[l] > array[l + 1])
            swap(array[l],array[l + 1]);
        }
        }
        printf("%d %d %d\n",array[0],array[1],array[2]);
           }


Measured memory_bytes: 3192
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 11, 2020 3:22 PM
 *    Problem Name  : C - Poll
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc155/tasks/abc155_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    set<string>se;
    map<string , int> mp;

    for(int i=0; i<n; i++) {
        string s;
        cin >> s;

        if(se.count(s)){
            mp[s]++;
        }
        else{
            se.insert(s);
            mp[s] = 1;
        }
    }

    int ans = 0;
    set<string>res;

    for(auto x: mp){
       ans = max(ans,x.second);  
    }

    for(auto x: mp){
        if(ans == x.second){
            cout << x.first << endl;
        }
    }
    return 0 ;
}


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

using namespace std;

int main(void)
{
	int a,b,c,k;

	cin >> a >> b >> c;
	cin >> k;

	int sum = a+b+c-max(a,max(b,c));
	int x = max(a,max(b,c));

	for(int i=0;i<k;i++)
	{
		x*=2;
	}

	sum+=x;

	cout << sum << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  ll n, k;
  cin >> n >> k;
  n %= k;
  cout << min(n, k - n) << endl;
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    
    bool judge = true;
    if (S[0] != 'A') judge = false;
    int cnt = 0;
    for (int i = 2; i < S.size() - 1; ++i) {
        if (S[i] == 'C') ++cnt;
    }
    if (cnt != 1) judge = false;
    for (int i = 1; i < S.size(); ++i) {
        bool B = false;
        for (int j = 0; j < 26; ++j) {
            if (S[i] == 'A' + j && S[i] != 'C') B = true;
        }
        if (B) judge = false;
    }
    
    if (judge) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}
    


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

int main(void){
    int a, b, N, s, f, flag=0;
    cin >> a >> b >> N;
    
    for (int i=0; i<N; i++){
        cin >> s >> f;
        if (f <= a || b <= s){}
        else {flag=1;}
    }
   
   cout << flag << endl;
   
    return 0;
}


Measured memory_bytes: 3068
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    long long x = 0;
    while(--q >= 0){
        int p, n;
        char c;
        cin >> p >> c >> n;
        if(c == '(')
            x += n;
        else
            x -= n;

        if(x == 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 856
W, H, N = gets.split.map(&:to_i)
ary = Array.new(W).map{Array.new(H, 0)}
1.upto(N) do |n|
    x, y, a = gets.split.map(&:to_i)
    case a
    when 1 then
        if x > 0
            x.downto(1) do |i|
                H.downto(1) do |j|
                    ary[i-1][j-1] = 1
                end
            end
        end
    when 2 then
        if x < W
            (x+1).upto(W) do |i|
                H.downto(1) do |j|
                    ary[i-1][j-1] = 1
                end
            end
        end
    when 3 then
        if y > 0
            y.downto(1) do |j|
                W.downto(1) do |i|
                    ary[i-1][j-1] = 1
                end
            end
        end
    when 4 then
        if y < H
            (y+1).upto(H) do |j|
                W.downto(1) do |i|
                    ary[i-1][j-1] = 1
                end
            end
        end
    end
end
puts ary.flatten.count(0)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll mp[1111111];

int main(){
	
	ll a,b;cin >> a >> b;
	
	if(a == 1){
		cout << b << endl;
		return 0;
	}
	
	for(int i = 2;i < 1111111;i++){
		while(b % i == 0){
			mp[i]++;
			b /= i;
		}
	}
	
	ll ans = 1;
	REP(i,1111111){
		while(mp[i] >= a){
			ans *= i;
			mp[i] -= a;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2304
n = int(input())
al = [list(map(lambda s: int(s) - 1, input().split()))[2:] for _ in range(n)]
begin = [-1] * n
end = [-1] * n
not_visited = list(range(n))
t = 1
def dfs(u):
    global begin, end, t, not_visited
    begin[u] = t
    t += 1
    not_visited.remove(u)
    for v in al[u]:
        if begin[v] == -1:
            dfs(v)
    end[u] = t
    t += 1

while len(not_visited) > 0:
    dfs(not_visited[0])

for i in range(n):
    print('{} {} {}'.format(i + 1, begin[i], end[i]))



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

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

    map<string,int> prize;
    for(int i=0;i<N;i++){
        if(prize[s[i]]=1)continue;
        prize[s[i]]=1;
    }

    cout << prize.size() << endl;
}

Measured memory_bytes: 25104
#include<map>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll const MAX = 1000;
ll cnt = 0;
ll ans[MAX];
int main() {
	ll n; cin >> n;
	if (n == 0) {
		cout << 0 << endl;	return 0;
	}
	while (n != 0) {
		ll m = abs(n);
		if ((m&(1 << cnt))>0) {
			ans[cnt] = 1;
		}
		else {
			ans[cnt] = 0;
		}
		if (cnt % 2 == 0) {
			n -= (ll(1) << cnt)*ans[cnt];
		}
		else {
			n += (ll(1) << cnt)*ans[cnt];
		}
		cnt++;
	}
	for (ll i = cnt - 1; i >= 0; i--) {
		cout << ans[i];
	}
	cout << endl;
}

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

int main(){

	int n, cnt, tmp, v[100];
	
	while(cin >> n){
		if(n == 0) break;
		cnt = 0;
		
		for(int i=0; i<n; i++){
			cin >> v[i];
		}
		
		for(int i=n-1; i>0; i--){
			for(int j=0; j<i; j++){
				if(v[j] > v[j+1]){
					tmp = v[j];
					v[j] = v[j+1];
					v[j+1] = tmp;
					cnt++;
				}
			}
		}
		
		cout << cnt << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
    int c[3][3];
    string ans="Yes";
    for(int i=0;i<3;i++) 
    for(int j=0;j<3;j++) 
    cin>>c[i][j];
    for(int i=1;i<3;i++) 
    for(int j=1;j<3;j++)
    if(c[i][0]-c[0][0]!=c[i][j]-c[0][j]) 
    ans="No"; 
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    vector<string>contest={
        "ABC",
        "ARC",
        "AGC",
    };
    int R;
    cin>>R;
    int idx;
    if(R<1200)idx=0;
    else if(R<2800)idx=1;
    else      idx=2;
    cout<<contest.at(idx)<<endl;

    return 0;
}


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

int main() {
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	for(int i=0;i<h;i++)
	{
		cin >> s.at(i);
	}
	string ans = "Yes";
	for(int i = 0;i<h;i++)
	{
		for(int j = 0;j<w;j++)
		{
			int z1=0,z2=0,z3=0,z4=0;
			char nw = s.at(i).at(j);
			if(nw == '.')
			{
				continue;
			}
			//ue
			if(i - 1 >= 0)
			{
				if(s.at(i-1).at(j) == '.')
				{
					z1 = 1;
				}
			}
			else
			{
				z1 = 1;
			}
			//migi
			if(j + 1 < w)
			{
				if(s.at(i).at(j+1) == '.')
				{
					z2 = 1;
				}
			}
			else
			{
				z2 = 1;
			}
			//hida
			if(j - 1 >= 0)
			{
				if(s.at(i).at(j-1) == '.')
				{
					z3 = 1;
				}
			}
			else
			{
				z3 = 1;
			}
			//sita
			if(i + 1 < h)
			{
				if(s.at(i+1).at(j) == '.')
				{
					z4 = 1;
				}
			}
			else
			{
				z4 = 1;
			}
			//kekka
			if(z1*z2*z3*z4 == 1)
			{
				ans = "No";
			}
		}
	}
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// 2020-07-05 20:59:43
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  REPC(i, 1, 12) {
    if(n <= i * 1000) {
      cout << i * 1000 - n << '\n';
      return;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pri 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
void run(){
	ll n,w;
	cin>>n>>w;
	ll z=1000*n;
	ll dp[1000*n+1];
	for(ll i=0;i<=z;i++){
		dp[i]=pri;
	}
	dp[0]=0;
	for(ll i=0;i<n;i++){
		ll wa,va;
		cin>>wa>>va;
		for(ll j=z;j>=0;j--){
		if(j-va>=0)	dp[j]=min(dp[j],dp[j-va]+wa);
		}
	}
	ll m=0;
	for(ll i=0;i<=z;i++){
		if(dp[i]<=w){m=i;}
	
	}
	cout<<m<<endl;
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N;
  cin >> N;
  char S[N];
  rep(i,N) cin >> S[i];
  int check=0;
  rep(i,N) if(S[i]=='Y') check=1;
  if(check==0) cout << "Three" << endl;
  else cout << "Four" << endl;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Goods = Tuple!(long, "w", long, "v");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    auto t = sread();
    long m = s.length, n = t.length;
    auto lcs = new long[][](m + 1, n + 1);
    foreach (i; iota(m))
    {
        foreach (j; iota(n))
        {
            if (s[i] == t[j])
                lcs[i + 1][j + 1] = lcs[i][j] + 1;
            else
                lcs[i + 1][j + 1] = max(lcs[i][j + 1], lcs[i + 1][j]);
        }
    }
    lcs.traceback(t, m, n).writeln();
}

auto traceback(T)(T lcs, string s, long m, long n)
{
    auto str = new char[](0);
    while (m > 0 && n > 0)
    {
        if(lcs[m][n] == lcs[m][n - 1])
            n--;
        else if(lcs[m][n] == lcs[m - 1][n])
            m--;
        else
        {
            m--, n--;
            str ~= s[n];
        }
    }
    str.reverse();
    return str;
}


Measured memory_bytes: 74108
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
    // Your code here!
    int a[200001];
    int n;
    
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    
    qsort(a, n, sizeof(int), compare_int);
    
    for(int i = 0; i < n-1; i++){
        if(a[i]==a[i+1]){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
}


Measured memory_bytes: 1788
N,M=map(int,input().split())
k=[]
for j in range(0,M):
    k.append([int(x) for x in input().split()])
    k[j]=k[j][1:]
p=[int(x) for x in input().split()]
condition=[0]*M
sum_=0
for u in range(0,2**N):
    switch=list(bin(u)[2:].zfill(N))
    for i in range(0,M):
        condition[i]=0
        for j in k[i]:
            condition[i] += int(switch[j-1])
        condition[i] = condition[i] % 2
    #print(switch,condition)
    sum_ += (condition==p)
print(sum_)

Measured memory_bytes: 3064
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab = sorted(ab, key=lambda x: x[0])

ans = 0
n_drinks = 0
for i in range(n):
    a, b = ab[i][0], ab[i][1]
    if n_drinks + b < m:
        ans += a * b
        n_drinks += b
    else:
        ans += (m - n_drinks) * a
        break

print(ans)

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, c;

	cin >> n >> c;

	vector<ll> a(n);

	REP(i, n) {
		cin >> a[i];
	}

	vector<ll> b(n);

	REP(i, n) {
		cin >> b[i];
	}

	vector<vector<ll>> p(401, vector<ll>(401, 0));

	REP(i, 400) {
		p[i + 1][0] = 1;
	}

	REP(i, 400) {
		REP(j, 400) {
			p[i + 1][j + 1] = p[i + 1][j] * (i + 1);
			p[i + 1][j + 1] %= MOD;
		}
	}

	vector<vector<ll>> sum(401, vector<ll>(401, 0));

	REP(i, 401) {
		REP(j, 400) {
			sum[i][j + 1] = sum[i][j] + p[j + 1][i];
			sum[i][j + 1] %= MOD;
		}
	}

	vector<vector<ll>> dp(n + 1, vector<ll>(c + 1, 0));
	dp[0][0] = 1;

	FOR(i, 1, n + 1) {
		REP(j, c + 1) {
			REP(k, j + 1) {
				dp[i][j] += dp[i - 1][j - k] * ((sum[k][b[i - 1]] - sum[k][a[i - 1] - 1] + MOD) % MOD);
				dp[i][j] %= MOD;
			}
		}
	}

	cout << dp[n][c] << endl;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int G[100005];
int pos[100005];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    memset(G, -1, sizeof(G));
    vector<VI> V(N + 1, VI(N - 1));
    FOR(i, 1, N) REP(j, N - 1) cin >> V[i][j];
    int days = 0;
    int total = (N * (N - 1)) / 2;
    while (total > 0) {
        days++;
        bool f = false;
        vector<bool> played(N+ 1, 0);
        FOR(i, 1, N) {
            if (pos[i] == N - 1) continue;
            if (played[i]) continue;
            int to = V[i][pos[i]];
            if (G[to] == i) {
                G[to] = -1;
                G[i] = - 1;
                f = true;
                total--;
                pos[i]++;
                pos[to]++;
                played[i] = true;
                played[to] = true;
            } else {
                G[i] = to;
            }
        }
        if (!f) {
            cout << "-1\n";
            return 0;
        }
    }
    cout << days << "\n";
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

string S;
ll K;

int main(void) {
    cin >> S >> K;
    // 1,000,000,000,000,000,000

    ll ans = 0;
    for (int i = 0; i < S.length(); ++i) {
        ll n = S[i] - '0';
        if (n == 1) {
            if (i + 1 == K) {
                ans = 1;
                break;
            }
        }
        else {
            ans = n;
            break;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean[] isp;
	static ArrayList<Integer> ps;
	static ArrayList<int[]> ms;

	static boolean[] eratosthenes(int m) {
		int n = m + 1;
		boolean[] isp = new boolean[n];
		if (n < 2) return isp;

		Arrays.fill(isp, true);

		for (int i=2; i*i<n; i++) {
			if (!isp[i]) continue;
			for (int j=i+i; j<n; j+=i) {
				isp[j] = false;
			}
		}

		return isp;
	}

	static void init() {
		isp = eratosthenes(10000);
		ps = new ArrayList<>();
		ms = new ArrayList<>();

		for (int i=0; i<10000; i++) {
			if (isp[i]) ps.add(i);
		}
		int size = ps.size();
		for (int i=0; i<size; i++) {
			for (int j=i; j<size; j++) {
				int a = ps.get(i);
				int b = ps.get(j);
				ms.add(new int[]{a*b, a, b});
			}
		}
		Collections.sort(ms, new Comparator<int[]>(){
			public int compare(int[] a, int[] b) {
				return a[0] - b[0];
			}
		});
	}

	static boolean solve() {
		int m = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		if (m + a + b == 0) return false;

		int n = ms.size();
		int pos = 0;
		while (pos < n && ms.get(pos)[0] <= m) pos++;

		for (int i=pos-1; i>=0; i--) {
			int[] t = ms.get(i);
			if (t[2]*a <= t[1]*b) {
				out.println(t[1]+" "+t[2]);
				return true;
			}
		}

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		init();
		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

int main() {
    int a, b, c;
    int cnt = 0;
    cin >> a >> b >> c;

    for(int i = a; i <= b; ++i) {
        if (c % i == 0) {
            ++cnt;
        }
    }

    cout << cnt << endl;

    return 0;
}



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

using namespace std;
using ll = long long;


int main()
{
	int n; cin >> n;
	vector<int> a(n);
	vector<ll>  sum(n + 1);
	for(int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	for(int i = 0; i < n; i++) sum[i + 1] += sum[i] + a[i];
	int cnt = 1;
	
	for(int i = n - 1; i >= 0; i--) {
		//cout << sum[i] << endl;
		if(sum[i] * 2 < a[i])break;
		cnt++;

	}
	cout << cnt << endl;
}

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

const int mod = 1e9 + 7;

void add_self(int &x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
}

void sub_self(int &x, int y) {
  x -= y;
  if (x < 0)
    x += mod;
}

int add(int x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
  return x;
}

int sub(int x, int y) {
  x -= y;
  if (x < 0)
    x += mod;
  return x;
}

int powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res % mod;
}

int mult(int x, int y) {
  return (1LL * x * y) % mod;
}

int divide(int x, int y) {
  return mult(x, powmod(y, mod - 2));
}

int ncr(int x, int y) {
  int fx = 1, fy = 1, fxy = 1;
  for (int i = 1; i <= x; ++i)
    fx = mult(fx, i);
  for (int i = 1; i <= y; ++i)
    fy = mult(fy, i);
  for (int i = 1; i <= x - y; ++i)
    fxy = mult(fxy, i);
  return divide(fx, mult(fy, fxy));
}

int main() {
  int x, y;
  scanf("%d %d", &x, &y);
  if (x > y)
    swap(x, y);
  if ((x + y) % 3 != 0)
    return 0 * puts("0");
  int stock = (x + y) / 3;
  for (int i = 0; i <= stock; ++i)
    if (i + (stock - i) * 2 == x)
      return 0 * printf("%d\n", ncr(stock, stock - i));
  printf("%d\n", 0);
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
s = [list(map(int, input().split()))for _ in range(M)]

for i in range(10 ** N):
    num = str(i)
    if len(num) == N and all(num[x - 1] == str(y) for x, y in s):
        print(num)
        exit()
print(-1)

Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
    long long int a, b;
    scanf("%lld%lld", &a, &b);
    if ((a==1&&b!=0)||(b==1&&a!=0))
    {
        printf("1");
    }
    else if (a % 2 == 0 || b % 2 == 0)
    {
        printf("%lld", a * b / 2);
    }
    else
    {
        printf("%lld", (a * b) / 2 +1);
    }
    return 0;
}

Measured memory_bytes: 128