akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int D=365;
int csum;
int c[26];
int s[D][26];
int last[26];

int ans[D];

int score(){
	memset(last,-1,sizeof(last));
	int sum=0;
	int diff=0;
	rep(i,D){
		sum+=s[i][ans[i]];
		diff+=csum;
		diff-=(i-last[ans[i]])*c[ans[i]];
		sum-=diff;
		last[ans[i]]=i;
	}
	return sum;
}

int main(){
	scanf("%*d");
	rep(i,26)scanf("%d",&c[i]),csum+=c[i];
	rep(i,D)rep(j,26)scanf("%d",&s[i][j]);
	rep(i,D){
		ans[i]=max_element(s[i],s[i]+26)-s[i];
	}
	random_device rnd;
	mt19937 mt(rnd());
	int cur=score();
	rep(loop,1000000){
		int p=mt()%D,d=mt()%26;
		int old=ans[p];
		ans[p]=d;
		int nx=score();
		if(cur>nx){
			ans[p]=old;
		}
		else cur=nx;
	}
	rep(i,D){
		cout<<ans[i]+1<<endl;
	}
	cerr<<"score: "<<cur<<' '<<score()<<endl;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
        int list[2][1000];
        for(int i = 0; i < 2; i++){
                for(int j = 0; j < 1000; j++){
                        list[i][j] = 0;
                }   
        }   
        char s[100];
        int c = 0;
        while(cin.getline(s,100)){
                if(s[0] !=  '\0'){
                        int n = 0;
                        int i = 0;
                        while(s[i] != ','){
                                n = n*10+s[i++]-'0';
                        }   
                        list[c][n-1]++;
                }else c++;
        }   
        for(int i = 0 ; i < 1000; i++){
                if(list[0][i] && list[1][i]) cout << i+1 <<" "<< list[0][i]+list[1][i] << endl;
        }   
}

Measured memory_bytes: 0
#include<string>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>

using namespace std;

	

int main()
{
	int s;
	cin >> s;
	int a[50000];
	bool judge_i = 0;
	int m = 2;
	a[1] = s;
	for(int i=1;judge_i==0;i++)
	{
		if(a[i]%2==0)
		{
			a[i+1] = a[i]/2;
		}
		else if(a[i]%2==1)
		{
			a[i+1] = a[i]*3 + 1;
		}
		for(int j=1;j<i+1;j++)
		{
			if(a[i+1]==a[j])
			{
				judge_i = 1;
			}
		}
		m = i+1;
	}
	cout << m << endl;
} 




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string s, t;
    cin >> s >> t;

    int slen = s.size();
    vector<vector<int>> sindex(26, vector<int>(slen + 2));

    rep(i, slen) {
        sindex[s[i] - 'a'][i + 1] = i + 1;
    }

    rep(i, 26) {
        int ct = 0;
        for (int j = slen; j >= 1; j--) {
            if (sindex[i][j] != 0) {
                ct = sindex[i][j];
            }
            sindex[i][j] = ct;
        }
    }

    ll ans = 0;
    int before = 0;

    rep(i, t.size()) {
        int now = sindex[t[i] - 'a'][before + 1];
        if (now == 0) now = sindex[t[i] - 'a'][1];
        if (now == 0) {
            ans = -1;
            break;
        }
        if (before < now) {
            ans -= before;
            ans += now;
        }
        else {
            ans -= before;
            ans += now + slen;
        }
        before = now;
    }

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

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

using namespace std;

int main () {

    string S;
    string T;
    int correct = 0;

    cin >> S >> T;

    for (int i = 0; i < 3; i++) {

        if (S[i] == T[i]) correct++;
    }

    cout << correct << endl;
}

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


using namespace std;

int main(){
    int N;
    cin>>N;
    int x1=0,x2=0,x4=0;

    
    for(int i = 0; i < N; i++)
    {
        int res;
        cin>>res;

        if(res%4==0){
            x4++;
        }else if(res%2==0){
            x2++;
        }else{
            x1++;
        }
    }


    if(x2==0&&(x1==N/2||x4==N/2)){
        cout<<"Yes"<<endl;
    }else if(x1<=x4){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

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

int main() {
  int n;
  cin >> n;
  int a;
  while(n--) {
    cin >> a;
    if (a%2==0) {
      if (a%3 && a%5) {
        cout << "DENIED\n";
        return 0;
      }
    }
  }
  cout << "APPROVED\n";
  return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(i=0;i<(n);++i)
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<utility>
#include<string>
#include<algorithm>
#include<bitset>
#include<queue>
using ll = unsigned long long int;
using namespace std;



int src(){
    string str;
    cin >> str;
    ll N = str.length()+1;
    vector<ll> a(N,0);
    ll min;
    a[1]=0;
    min=0;
    if(N==2){cout<<1;return 0;}
    char start ,next;
    ll sid=0;
    start=str[0];
    ll count=1;
    for(ll i=1;i<=N-1;++i){
        if(start==str[i] and count<N-1){
            count++;
        }else{
            if(start=='<'){
                a[sid]=0;
                for(ll j=1;j<=count;j++){
                    a[sid+j]=a[sid+j-1]+1;
                }
            }else{
                a[sid]=count;
                for(ll j=1;j<=count;j++){
                    a[sid+j]=a[sid+j-1]-1;
                }
            }
            if(i+1<N){
                start=str[i];
                sid+=count;
                count=1;
            }
        }
    }
    ll sum=a[0];
    start=str[0];
    for(ll i=1;i<N-1;++i){
        next=str[i];
        if(start=='<' and next=='>'){
            a[i] = max(a[i-1],a[i+1])+1;
        }
        sum+=a[i];
        start=next;
    }
    sum+=a[N-1];

    cout<<sum;
    return 0;
}

int main(ll argc,char* argv[]){
    //ifstream in( argv[1] );
    //cin.rdbuf(in.rdbuf());
    src();    
    return 0;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
int n,m,s=1,t;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		t+=a;
		if(t<=m)s++;
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	input = input.split(" ");

	var N = input[0];
	var A = input[1];
	var B = input[2];

	var sum = 0;
	for (var i = 0 ; i <= N; i++) {
		var digitSum = getSumOfDigits(i);
		if(A <= digitSum && digitSum <= B) {
			sum += i;
		}
	}

	console.log(sum);
}

function getSumOfDigits(value) {
	var s = 0;
	while (value) {
	    s += value % 10;
	    value = Math.floor(value / 10);
	}
	return s;
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21320
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  priority_queue<long long int> q;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    q.push(a);
  }
  
  for (int i = 0; i < m; ++i) {
    int a = q.top();
    q.pop();
    a /= 2;
    q.push(a);
  }
  
  long long int ans = 0;
  
  while(!q.empty()) {
    ans += q.top();
    q.pop();
  }
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 1400
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    static int tc=1;
    static String[] s;

    public static long[] ila(String[] s){
        long[] array=new long[s.length];
        for(int i=0;i<array.length;i++)
            array[i]=Long.parseLong(s[i]);
        return array;
    }
    public static boolean isPalindrome(String s , int start,int end){
    	while(start<end){
    		if(s.charAt(start)!=s.charAt(end))
    			return false;
    		start++;
    		end--;
    	}
    	return true;
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        tc=1;
        t:
        for(int z=1;z<=tc;z++){
        	String s = br.readLine();
        	boolean result =true;
        	result = isPalindrome(s,0,s.length()-1);
        	if(!result){
        		System.out.println("No");
        		return;
        	}
        	result = isPalindrome(s,0,(s.length()-2)>>1);
        	if(!result){
        		System.out.println("No");
        		return;
        	}
        	result = isPalindrome(s,(s.length()+2)>>1,s.length()-1);
        	if(!result){
        		System.out.println("No");
        		return;
        	}
        	System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int64_t Z,W;
  cin>>Z>>W;
  vector<int64_t>A(N+1);
  A.at(0)=W;
  for(int i=1;i<=N;i++){
  int64_t a; cin>>a;
    A.at(i)=a;
  }for(int i=0;i<=N;i++)
    A.at(i)=abs(A.at(i)-A.at(N));
  cout<<max(A.at(0),A.at(N-1))<<endl;;
  
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}
*/

struct block{ll w, s, v, sum;};

bool comp(block a, block b){
  return a.sum < b.sum;
}

ll dp[1010][20010];

void solve(){
  ll N;
  cin >> N;
  vector<block> A;
  rep(i, N){
    ll w, s, v;
    cin >> w >> s >> v;
    A.pb({w, s, v, w + s});
  }
  sort(A.begin(), A.end(), comp);
  rep(i, 1010)rep(j, 20010) dp[i][j] = -INFL;
  dp[0][0] = 0;
  rep(i, N){
    rep(j, 20010){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if(A[i].s >= j){
        dp[i+1][j+A[i].w] = max(dp[i+1][j+A[i].w], dp[i][j] + A[i].v);
      }
    }
  }
  ll ans = 0;
  rep(j, 20010) ans = max(ans, dp[N][j]);
  cout << ans << endl;
}

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


Measured memory_bytes: 158208
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for (int i = 0; i <= n - 1; i++) cin >> v[i];
    sort(v.rbegin(), v.rend());
    ll tot = 0;
    for (int i = k; i <= n - 1; i++) {
        tot += v[i];
    }
    cout << tot << '\n';
}

Measured memory_bytes: 4828
#include<cstdio>
#include<functional>
#include<algorithm>
#define MM 2100000000
using namespace std;
int main(void)
{
	int v,e,r,s[2000],t[2000],d[2000],leng[1000],i,j,flg;
	scanf("%d %d %d",&v,&e,&r);
	for(i=0;i<e;i++)	scanf("%d %d %d",&s[i],&t[i],&d[i]);
	for(i=0;i<v;i++)	leng[i]=MM;
	leng[r]=0;
	for(i=0;i<=v;i++)	{
		flg=0;
		for(j=0;j<e;j++)	{
			if(leng[s[j]]!=MM && leng[s[j]]+d[j]<leng[t[j]])	{
				leng[t[j]]=leng[s[j]]+d[j];
				flg=1;
			}
		}
		if(flg==0)	break;
	}
	if(i>v && flg==1)	{
		printf("NEGATIVE CYCLE\n");
	}
	else {
		for(i=0;i<v;i++)	{
			if(leng[i]==MM)	printf("INF\n");
			else printf("%d\n",leng[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 2788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 main(int argc, char const *argv[]) {
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(c-(a-b),0) << endl;
  return 0;
}


Measured memory_bytes: 384
/*2019/10/02 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
//int asc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return -1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return 1;}
//int desc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return 1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return -1;}

int main(){
    int n,s[200],flg[200]={};
    int sum=0;
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
        sum+=s[i];
    }
    qsort(s,n,sizeof(int),asc);

    if(sum%10){
        printf("%d\n",sum);
    }else{
        for(int i=0;i<n;i++){
            if(s[i]%10){
                printf("%d\n",sum-s[i]);
                return 0;
            }
        }
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
  int num,A=0,B=0,AB=0,O=0;
  char tr;
  string bl;
  while(cin >> num >> tr >> bl){
	if(bl=="A") A++;
	else if(bl=="B") B++;
	else if(bl=="AB") AB++;
	else if(bl=="O") O++;
  }
  cout << A << endl 
	   << B << endl
	   << AB << endl
	   << O << endl;
  return 0;
}

Measured memory_bytes: 1200
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))
A = np.sort(A)[::-1]
F = np.sort(F)
# 二部探索法　Aの最大値をどこまで減らせるか
if A.sum() <= K:
    print(0)
    exit()
if K == 0:
    print((A * F).max())
up = (A * F).max() # 可能 mid は完食にかかる時間
low = 0 # 不可能
while up > low + 1:
    mid = (up + low) // 2
    if (A - np.minimum(A, (mid // F))).sum() <= K: #可能
        up = mid
    else:
        low = mid
print(up)

Measured memory_bytes: 37224
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

struct Matrix(size_t height, size_t width)
{
    long M;
    long[width][height] arr;

    this(long[width][height] arr, long M = 10L^^9+7) {
        this.arr = arr;
        this.M = M;
    }

    pure
    Matrix!(height, rhs_width) opBinary(string op, size_t rhs_width)(Matrix!(width, rhs_width) rhs) {
        static if (op == "*") {
            long[rhs_width][height] res;
            foreach (y; 0..height) {
                foreach (x; 0..rhs_width) {
                    foreach (i; 0..width) {
                        res[y][x] = (res[y][x] + (this.arr[y][i] * rhs.arr[i][x]) % M) % M;
                    }
                }
            }
            return Matrix!(height, rhs_width)(res, M);
        } else {
            static assert(0, "Operator "~op~" not implemented");
        }
    }

    pure
    Matrix!(height, width) opBinary(string op)(long n) {
        static if (op == "^^" && height == width) {
            long[width][height] rr;
            foreach (i; 0..width) rr[i][i] = 1;
            auto r = Matrix!(height, width)(rr, M);
            auto x = this;
            while (n) {
                if (n%2 == 1) r = r * x;
                x = x * x;
                n /= 2;
            }
            return r;
        } else {
            static assert(0, "Operator "~op~" not implemented");
        }
    }
}

Matrix!(h, w) matrix(size_t h, size_t w)(long[w][h] arr, long M = 10L^^9+7)
{
    return Matrix!(h, w)(arr, M);
}

void main()
{
    auto labm = readln.split.to!(long[]);
    auto L = labm[0];
    auto A = labm[1];
    auto B = labm[2];
    auto M = labm[3];

    long[18] CS;
    if (A < 10) CS[0] = (10-A-1)/B+1;
    foreach (i; 1..18) {
        auto dm = 10L^^(i+1)-1-A;
        if (dm < 0) continue;
        auto last = B*(L-1);
        CS[i] = ((dm > last) ? last : dm)/B+1;
        foreach (j; 0..i) CS[i] -= CS[j];
        if (dm >= last) break;
    }

    long[3][1] xss = [[0, A, 1]];
    auto xs = matrix(xss, M);

    foreach (i, d; CS) {
        long[3][3] cm = [
            [(10L^^(i+1)%M).to!long, 0, 0],
            [1L, 1, 0],
            [0L, B, 1]
        ];
        auto m = matrix(cm, M);
        m = m^^d;
        xs = xs * m;
    }
    writeln(xs.arr[0][0]);
}

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

struct Problem {

	void Solve() {
		UL N; cin >> N;
		UL L = N / 2;
		UL R = N - L;
		if (N == 19999) { L = 10000; R = 9999; }
		if (N == 19998) { L = 10000; R = 9998; }
		vector<UL> ans;
		if (N == 3) { cout << "2 5 63" << endl; return; }
		{
			UL p;
			if (R % 4 == 0) { p = 3; }
			if (R % 4 == 1) { ans.push_back(6); p = 9; }
			if (R % 4 == 2) { ans.push_back(3); ans.push_back(9); p = 12; }
			if (R % 4 == 3) { ans.push_back(3); ans.push_back(6); ans.push_back(9); p = 12; }
			R -= R % 4;
			rep(i, R) { ans.push_back(p); p += 3; }
		}
		{
			UL p = 2;
			if (L % 2 == 1) { ans.push_back(2); ans.push_back(8); ans.push_back(14); p = 20; L -= 3; }
			L /= 2;
			rep(i, L) { ans.push_back(p); ans.push_back(p + 2); p += 6; }
		}

		rep(i, ans.size()) { if (i) cout << " "; cout << ans[i]; }
		cout << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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



int main(){
    string in;
    cin >> in;



    if(in.at(3)==in.at(2) && in.at(5)==in.at(4)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, t int
	fmt.Scan(&n, &t)
	ts := make([]int, n)
	for i := range ts {
		fmt.Scan(&ts[i])
	}

	sum := t
	for i := 1; i < n; i++ {
		sum += min(t, ts[i]-ts[i-1])
	}
	fmt.Println(sum)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 6492
N = int(input())
T = {i: [] for i in range(N)}
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    T[a - 1].append((b - 1, c))
    T[b - 1].append((a - 1, c))

Q, K = map(int, input().split())
S, D = [(-1, K - 1)], [0] * N
while len(S) > 0:
    p, c = S.pop()
    for g, d in T[c]:
        if g != p:
            D[g] = D[c] + d
            S.append((c, g))

for _ in range(Q):
    x, y = map(int, input().split())
    print(D[x - 1] + D[y - 1])


Measured memory_bytes: 87908
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
ll max(ll a, ll b)
{
    return a > b ? a : b;
}
int main()
{
    ll t, a, k;
    cin >> t >> a >> k;
    cout << max(t - k, 0) << " " << max(a - (t - k > 0 ? 0 : k - t), 0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,m;
	cin>>n>>m;
	ll a[100010],b[100010];
	vector<ll>ch[100010];
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		a[i]=x;
		b[i]=y;
		ch[x].push_back(y);
	}
	for(ll i=0;i<100010;i++){
		sort(ch[i].begin(),ch[i].end());
	}
	for(ll i=0;i<m;i++){
		ll nowx=a[i];
		ll nowy=b[i];
		auto itr=lower_bound(ch[nowx].begin(),ch[nowx].end(),nowy);
		ll id=itr-ch[nowx].begin();
		id++;
		printf("%06d",nowx);printf("%06d",id);
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 8576
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: i64 = sc.get();
    let M: usize = sc.get();
    let A: Vec<i64> = sc.vec(M);
    let ans = N - A.into_iter().sum::<i64>();
    println!("{}", max(-1, ans));
}


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

int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll cnt=0;
    if(a!=0)
    {
    cnt+=(n/(a+b))*a;
    ll r=(n%(a+b));
    if(r>=a)    cnt+=a;
    else    cnt+=r;
    cout << cnt ;
    }
    else    cout << "0";
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string s,key_s;
  cin >> s;
  rep(i,s.size())FOR(j,i,s.size()){
    key_s = s.substr(0,i) + s.substr(j,s.size()-j);
    if("keyence" == s.substr(0,i) || "keyence" == s.substr(0,i)+s.substr(j,s.size()-j) || "keyence" == s.substr(0,i)+s.substr(j,s.size()-j)){
      cout << "YES" << endl;
      return 0;
    }

  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
N, M, C = map(int, raw_input().split())
B = map(int, raw_input().split())

ans = 0
for i in xrange(N):
	A = map(int, raw_input().split())
	A = [A[j] * B[j] for j in xrange(M)]
	if sum(A) + C > 0: ans += 1
print ans

Measured memory_bytes: 28524
#include<stdio.h>
 
int main(void){
    int w,n,bar[30],i,tem,a,b;

    scanf("%d\n%d",&w,&n);
    
    for(i=0;i < 30;i++){
        bar[i] = i+1;
    }

    for(i=0;i < n;i++){
        scanf("%d,%d",&a,&b);
        a--; b--;

        tem    = bar[a];
        bar[a] = bar[b];
        bar[b] = tem;
    }

    for(i=0;i < w;i++){
        printf("%d\n",bar[i]);
    }
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  vector<int> x(n);
  for(int i=0; i<n; i++) x[i] = i+1;
  for(int i=0; i<n; i++) cin >> p[i];
  for(int i=0; i<n; i++) cin >> q[i];

  int a = -1, b = -1;
  int i = 0;
  do {
    if (x == p) a = i;
    if (x == q) b = i;
    i++;
  } while(next_permutation(all(x)));

  cout << abs(a-b) << endl;

}

// EOF


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


int main(){

 int X,N,tmp,j;
  cin >> X >> N;
  if(N==0){
    cout << X << endl;
    return 0;
  }
  
  vector <int> p(N);
  rep(i,N){
    cin >> tmp;
    p.at(i)=tmp;
  }
  bool torf=false,torf2=false;
  
//vector <bool> torf (N);
  

 //cout << X-100 << endl;
  rep(i,100){
    
    for(j=0;j<N;j++){
      if(X-i==p.at(j)){
    torf=true;
      }
      if(X+i==p.at(j)){

        torf2=true;
      }
    }
    if(torf==false){
      cout << X-i << endl;
      return 0;
     
    }else if(torf2==false){
      cout << X+i << endl;
      return 0;
    }
    torf=false;
    torf2=false;
    //cout << torf << endl;
   /* if(torf==true){
      if(X-i!=p.at(j))
      cout << X-i << endl;
      else
        cout << X+i << endl;
      return 0;
    }
    

      torf=false;*/
  }
   
  
}

Measured memory_bytes: 3632
n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
li_a = [0 for i in range(n)]
li_b = [0 for i in range(n)]
a = 0
b = 0
for j in range(m):
  if li[j][1] == "WA":
    li_b[int(li[j][0])-1] += 1
  elif li[j][1] == "AC" and li_a[int(li[j][0])-1] == 0:
    a += 1
    b += li_b[int(li[j][0])-1]
    li_a[int(li[j][0])-1] += 1
print(a, b)

Measured memory_bytes: 27548
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int solve() {
  int N; cin>>N;
  vector<ll> A(N), B(N);
  ll Asum = 0, Bsum = 0;
  REP(i,N) {
    cin>>A[i]; Asum += A[i];
  }
  REP(i,N) {
    cin>>B[i]; Bsum += B[i];
  }
  if(Bsum > Asum) return -1;
  vector<ll> pos;
  ll negsum = 0;
  int ans = 0;
  REP(i,N) {
    if(A[i] < B[i]) {
      negsum += abs(B[i] - A[i]);
      ans ++;
    }
    else if(A[i] > B[i]) pos.push_back(abs(B[i] - A[i]));
  }
  sort(pos.begin(), pos.end());
  reverse(pos.begin(), pos.end());
  int idx = 0;
  while(negsum > 0) {
    negsum -= pos[idx];
    idx++;
  }
  return ans + idx;
}

int main() {
  int ans = solve();
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 2428
package main

import "fmt"

func add_action(ans string, add_ans string, add_number int) string {
	for i := 0; i < add_number; i++ {
		ans = ans + add_ans
	}
	return ans
}

func main() {
	var sx, sy, tx, ty int
	fmt.Scan(&sx, &sy, &tx, &ty)
	U_number := ty - sy
	D_number := ty - sy
	L_number := tx - sx
	R_number := tx - sx
	ans := ""
	ans = add_action(ans, "U", U_number)
	ans = add_action(ans, "R", R_number)
	ans = add_action(ans, "D", D_number)
	ans = add_action(ans, "L", L_number)
	ans = add_action(ans, "L", 1)
	ans = add_action(ans, "U", U_number + 1)
	ans = add_action(ans, "R", R_number + 1)
	ans = add_action(ans, "D", 1)
	ans = add_action(ans, "R", 1)
	ans = add_action(ans, "D", D_number + 1)
	ans = add_action(ans, "L", L_number + 1)
	ans = add_action(ans, "U", 1)
	fmt.Println(ans)
}

Measured memory_bytes: 6656
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;
typedef vector<int> vint;

int a, b, c;
int N;
int result[300];
vector<vint> dame;
stack<int> oklist;

int main() {
	while (cin >> a >> b >> c, a + b + c) {
		cin >> N;
		for (int i = 0; i < a + b + c; i++)result[i] = 2;
		for (int i = 0; i < N; i++) {
			int A, B, C, D;
			cin >> A >> B >> C >> D;
			A--, B--, C--;
			if (D == 1) {
				result[A] = 1;
				result[B] = 1;
				result[C] = 1;
				oklist.push(A), oklist.push(B), oklist.push(C);
			}
			else {
				dame.push_back({ A,B,C });
			}
		}
		while (oklist.size()) {
			int tmp = oklist.top(); oklist.pop();
			for (int i = 0; i < dame.size(); i++) {
				for (int j = 0; j < dame[i].size(); j++) {
					if (dame[i][j] == tmp) {
						dame[i].erase(dame[i].begin() + j);
						break;
					}
				}
				if (dame[i].size() == 1) {
					result[dame[i][0]] = 0;
					dame[i].clear();
				}
			}
		}
		for (int i = 0; i < a + b + c; i++)cout << result[i] << endl;
		dame.clear();
	}
	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n,d;
    cin >> n >> d;
    cout << (n+(2*d))/(2*d+1) << endl;
    return 0;
}

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

const int N = 50;
int a[N], b[N], c[N], d[N], A[N];
int n, m, q, ret = 0;
 
void search(int pos, int low) {
  if (pos == n) {
    int cur = 0;
    for (int i = 0; i < q; ++i) {
      if (A[b[i]] - A[a[i]] == c[i])
        cur += d[i];
    }
    ret = max(cur, ret);
    return;
  }
  for (int i = low; i <= m; ++i) {
    A[pos] = i;
    search(pos + 1, i);
  }
}
 
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i]; --b[i];
  }
  search(0, 1);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3576
fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(' ').map(String::toLong)
    val minute = h * 60 + m
    val hDeg = minute.toDouble() / 720.0 * 2 * Math.PI
    val mDeg = m / 60.0 * 2 * Math.PI

    val ax = a * Math.sin(hDeg)
    val ay = a * Math.cos(hDeg)
    val bx = b * Math.sin(mDeg)
    val by = b * Math.cos(mDeg)
    val xDiff = Math.abs(ax - bx)
    val yDiff = Math.abs(ay - by)
    val dist = Math.sqrt(xDiff * xDiff + yDiff * yDiff)

    println(dist)
}


Measured memory_bytes: 36592
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;





template< typename T >
vector<T> dijkstra(WG<T> &g,int s){
  const auto lim = numeric_limits<T>::max();
  vector<T> dist(g.size(),lim);
  using Pi = pair<T,int>;
  priority_queue<Pi,vector<Pi>,greater<Pi>> q;
  dist[s] = 0;
  q.emplace(dist[s],s);
  while(!q.empty()){
    T cost;
    int idx;
    tie(cost,idx) = q.top();
    q.pop();
    if(dist[idx] < cost) continue;
    for( auto &e : g[idx]){
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      q.emplace(dist[e.to],e.to);
    }
  }
  return dist;
}



void f(int n,int m,int l,int k,int a,int h){
  vector<bool> fr(n,false);
  WG<int> es(n*(m+1));

  fr[a]=true;
  fr[h]=true;
  rep(i,l){
    int t;
    cin>>t;
    fr[t]=true;
  }

  rep(i,k){
    int x,y,t;
    cin>>x>>y>>t;
    FOR(j,t,m+1){
      int xk=x*(m+1)+j-t;
      int yk=y*(m+1)+j-t;
      es[x*(m+1)+j].PB(edge<int>(yk,t));
      es[y*(m+1)+j].PB(edge<int>(xk,t));
    }
  }

  rep(i,n){
    rep(j,m){
      if(fr[i]){
        es[i*(m+1)+j].PB(edge<int>(i*(m+1)+j+1,1));
      }
    }
  }
  vector<int> dist = dijkstra(es,a*(m+1)+m);
  int res=INF;
  rep(i,m+1){
    res=min(res,dist[h*(m+1)+i]);
  }

  if(res==INF) cout<<"Help!"<<endl;
  else cout<<res<<endl;
}

main(){
  int n,m,l,k,a,h;

  while(true){
    cin>>n>>m>>l>>k>>a>>h;
    if(n==0) break;
    f(n,m,l,k,a,h);
  }
}



Measured memory_bytes: 7212
#include<iostream>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int solve(int n,int m,int *h,int *w){
  map<int,int> M;
  rep(i,m){//length
    int tmp=0;
    rep(j,i+1){
      tmp+=w[j];
    }
    M[tmp]++;
    REP(j,i+1,m){
      tmp=tmp-w[j-i-1]+w[j];
      //cout << "tmp"<<tmp << endl;
      M[tmp]++;
    }
  }

  int ret = 0;
  rep(i,n){
    int tmp=0;
    rep(j,i+1){
      tmp+=h[j];
    }
    ret+=M[tmp];
    REP(j,i+1,n){
      tmp=tmp-h[j-i-1]+h[j];
     ret+=M[tmp];
    }
  }
  return ret;
}

main(){
  int n,m;
  int h[1500],w[1500];
  while(cin>>n>>m && n){
    rep(i,n)cin>>h[i];
    rep(j,m)cin>>w[j];
    cout << solve(n,m,h,w) << endl;
  }
}

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

namespace ABC088 {
	class ABC088_A {
		static void Main(string[] args) {
			var N = int.Parse(Console.ReadLine());
			var A = int.Parse(Console.ReadLine());
			Console.WriteLine(N % 500 <= A ? "Yes" : "No");
		}
	}
}


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

long int Monster(long int A){
  if(A == 1) return 1 ;
  else return 2 * Monster(A/2) + 1 ;
}  

int main(){
  long int H ;
  cin >> H ;
  cout << Monster(H) << endl ;
  return 0 ;
}

Measured memory_bytes: 256
H, W = map(int, raw_input().split())

s = [raw_input() for _ in range(H)]

ans = "Yes"

for y in range(H):
  for x in range(W):
    if s[y][x]=="#":
      ok = False
      for dx,dy in [(-1,0), (1,0), (0,-1), (0,1)]:
        if 0<=x+dx<W and 0<=y+dy<H and s[y+dy][x+dx]=="#":
          ok = True
      if not ok:
        ans = "No"

                
print ans

Measured memory_bytes: 2568
#include <stdio.h>
int main()
{int n,i;
double k,sum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		if (i%2!=0)	
			sum=sum+1;
			k=sum/n;
	printf("%.10f",k);
return 0;	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>

ll ti[3001][3001];


int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s,t;
	cin>>s>>t;

	for(ll i=0;i<=s.size();i++)
    {
        for(ll j=0;j<=t.size();j++)
        {
            if(i==0 || j==0)
                ti[i][j]=0;

            else if(s[i-1]==t[j-1])
                ti[i][j]=ti[i-1][j-1]+1;

            else
                ti[i][j]=max(ti[i][j-1],ti[i-1][j]);
        }
    }
    string ans="";

    ll i=s.size(),j=t.size();

    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
           {
               ans+=string(1,s[i-1]);i--;j--;
           }
        else
        {
            if(ti[i][j-1]>ti[i-1][j])
                j--;
            else i--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;


	return 0;
}



Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n, a[N], dp[N];
int main() {
    scanf("%d", &n);
    for(int i=0; i<n; ++i)
        scanf("%d", a+i);
    for(int i=1; i<n; ++i)
        dp[i] = 1e9+1;
    for(int i=0; i<n; ++i){
        dp[i+1] = min(dp[i+1], dp[i] + abs(a[i] - a[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(a[i] - a[i+2]));
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

int a[3], b[3];
int c[5];

int main() {
  for (int i = 0; i < 3; ++ i) {
    scanf("%d%d", a + i, b + i);
    c[a[i]] ++;
    c[b[i]] ++;
  }
  for (int i = 1; i <= 4; ++ i)
    if (c[i] > 2)
      return puts("NO"), 0;
  puts("YES");
}


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

using namespace std;

bool has_odd(int k) {
    if (k == 0) return false;
    return !has_odd(k/10);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        sum += has_odd(i);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int tmp;
int main(){
    int g = 0;
    int c = 0;
    int p = 0;
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == 'g'){//g
            if(p + 1 > g){
                g++;
            }else{
                p++;
                ans += 1;
            }
        }else{//'p'
            if(p + 1 > g){
                g++;
                ans--;
            }else{
                p++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

vi adjList[100000];
int visited[100000],path[100000];
int doDFS(int u,int p) {
    int i;
    vi back,child;
    visited[u] = 1,path[u] = 1;
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (!visited[v]) {
            if (doDFS(v,u)) child.pb(v);
        }
        else if ((v != p) && path[v]) back.pb(v);
    }
    path[u] = 0;
    while (back.size() >= 2) {
        int x = back.back();
        back.pop_back();
        int y = back.back();
        back.pop_back();
        printf("%d %d\n%d %d\n",u+1,x+1,u+1,y+1);
    }
    while (child.size() >= 2) {
        int x = child.back();
        child.pop_back();
        int y = child.back();
        child.pop_back();
        printf("%d %d\n%d %d\n",u+1,x+1,u+1,y+1);
    }
    if (child.empty() && back.empty()) return 1;
    else if (child.empty()) {
        printf("%d %d\n%d %d\n",u+1,p+1,u+1,back[0]+1);
        return 0;
    }
    else if (back.empty()) {
        printf("%d %d\n%d %d\n",u+1,child[0]+1,u+1,p+1);
        return 0;
    }
    else {
        printf("%d %d\n%d %d\n",u+1,child[0]+1,u+1,back[0]+1);
        return 1;
    }
}
int main() {
    int i;
    int N,M;
    int u,v;
    scanf("%d %d",&N,&M);
    for (i = 0; i < M; i++) {
        scanf("%d %d",&u,&v);
        u--,v--;
        adjList[u].pb(v);
        adjList[v].pb(u);
    }
    if (M & 1) {
        printf("-1\n");
        return 0;
    }
    else doDFS(0,-1);

    return 0;
}



Measured memory_bytes: 21760
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n,x,p,ans;
    int flag[210];
    while (scanf("%d %d",&x,&n)!=EOF) {
        int l=x,r=x;
        ans = 0;
        for (int i=0;i<=200;i++) {
            flag[i] = 0;
        }
        for (int i=0;i<n;i++)
        {
            scanf("%d",&p);
            flag[p] = 1;
        }
        bool getans = false;
        while (!getans) {
            //printf("%d %d\n",l,r);
            if (!flag[l]||!flag[r]) {
                getans=true;
                if (!flag[l])
                    ans=l;
                else
                    ans=r;
            }
            l--;
            r++;
        }
        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 3248
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 1000007
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
bitset<maxx/2>vis;
vector<int>prime;
map<int,int>maps;
int arr[200005];
void sieve(){
    int x=maxx/2, y=sqrt(maxx)/2;
    for(int i=1;i<=y;i++){
        if(vis[i]==0){
            for(int j=(i*(i+1)*2);j<x;j+=(2*i)+1)
                vis[j]=1;
        }
    }
    prime.push_back(2);
    for(int i=3;i<maxx;i+=2)
        if(vis[i/2]==0)
        prime.push_back(i);
}
bool isprime(int a)
{
    if(a==2){
        return true;
    }
    if(a%2==0){
        return false;
    }
    if(a<=maxx){
        if(vis[a/2]==0)return true;
        else
            return false;
    }
    for(int i=0;i<prime.size() && prime[i]*prime[i]<=a;i++){
        if(a%prime[i]==0){
            return false;
        }
    }
    return true;
}
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}

void Dufaux()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&arr[i]);
        maps[arr[i]]++;
    }
    if(maps[1]==1){
        printf("1\n");
        return;
    }
    else if(maps[1]>1){
        printf("0\n");
        return;
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        bool found=true;
        if(maps[arr[i]]>1){
            continue;
        }
        if(isprime(arr[i])){
            cnt++;
            continue;
        }
        for(int j=2;j*j<=arr[i];j++){
            if(arr[i]%j==0){
                ll k=arr[i]/j;
                if(maps[j]>=1 || maps[k]>=1){
                    found=false;
                    break;
                }
            }
        }
        if(found==true){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return;
}
int main()
{
	sieve();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 33352
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
using namespace std;
typedef long long ll;
const int N=111111;
int a[N],b[N],n,m;
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)scanf("%d%d",&a[i],&b[i]);
	ll ans=0;
	rep(p,0,32){
		int msk=(((m>>p))<<p);
		if((m>>p)&1)msk--;else msk=m;
		assert(msk<=m);
		ll sum=0;
		rep(i,1,n)if((msk|a[i])==msk)sum+=b[i];
		if(sum>ans)ans=sum;
	}
	printf("%lld\n",ans);
	return 0;
}


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

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

    long long a, sumA = 0, sumB = 0, mA = 0, mB = 0;
    for(int i = 1; i <= n; i++){
        cin >> a;
        sumA += a;
        sumB += a;

        if(i % 2){
            if(sumA <= 0){
                mA += 1 - sumA; // required manipulation
                sumA = 1;       // - -> +
            }
            if(sumB >= 0){
                mB += 1 + sumB;
                sumB = -1;
            }
        }else{
            if(sumA >= 0){
                mA += 1 + sumA;
                sumA = -1;
            }
            if(sumB <= 0){
                mB += 1 - sumB;
                sumB = 1;
            }
        }
    }
    cout << min(mA, mB) << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>
#include<iomanip>


using namespace std;

void Solution()
{
    string str;
    int num[10];
    
    while (cin>>str)
    {
        for (int i = 0; i < 10; i++)
        {
          num[i] = str[i] - '0';
        }
        
        for(int i = 9; i >= 0; i--) // start from 9 and then 8 ,7 ,6...
        {
            for(int j = 0; j < i; j++)
            {
                num[j] = (num[j] + num[j + 1]) % 10;
            }
        }
        
        cout<<num[0]<<endl;

    }
    
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1184