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

int main(){
	int n;
	cin >> n;
	int v[n], c[n], sum=0;
	
	for (int i=0; i<n; i++){
		cin >> v[i];
	}
	
	for (int i=0; i<n; i++){
		cin >> c[i];
	}
	
	for (int i=0; i<n; i++){
		if (v[i]-c[i]>0){
			sum += v[i]-c[i];
		}
	}
	
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long k, a, b;
	cin >> k >> a >> b;

	long long ans = k + 1;
	if (b - a >= 3) {
		long long x = 0;
		if (k >= a - 1) {
			k -= a - 1;
			x = a;
			x += k / 2 * (b - a) + k % 2;
		}
		ans = max(ans, x);
	}

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


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;




int main(){
    ll n;
    cin>>n;
    vector<ll> cnt(1e5,0);
    ll sum=0;
    rep(i,n){
        ll a;
        cin>>a;
        cnt[a]++;
        sum+=a;
    }
    ll q;cin>>q;
    rep(i,q){
        int b,c;
        cin>>b>>c;
        cnt[c]+=cnt[b];
        sum+=(c-b)*cnt[b];
        cnt[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}

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

int main() {
  vector<int> xs(3);
  for (auto& x : xs) cin >> x;
  sort(xs.begin(), xs.end());
  for (int i = 1; i < xs.size(); ++i) xs[i] += xs[i - 1];
  cout << xs[1] << endl;
}


Measured memory_bytes: 256
N,X=map(int,input().split())

from functools import lru_cache
import sys

sys.setrecursionlimit(10*20)

@lru_cache(maxsize=None)
def count(N):
    if N == 0:
        return 1
    else:
        return 3 + 2 * count(N-1)
    
@lru_cache(maxsize=None)
def calc(N,X):
    if N == 0:
        return 1
    center = count(N-1) + 1
    if X == 0 :
        return 0
    elif X < center:
        return calc(N-1,X-1)
    elif X == center:
        return calc(N-1,center-2) + 1
    elif X > center:
        return calc(N-1,X-center-1) + calc(N,center)
print(calc(N,X-1))

Measured memory_bytes: 4068
#include<iostream>
#include<algorithm>
int main() {
	int n[10];
	for (int i = 0; i < 10; i++) {
		int y;
		std::cin >> y;
		n[i] = y;
	}
	std::sort(n, n + 10);
	for (int i = 1; i < 4; i++) {
		std::cout << n[10 - i] << std::endl;
	}
}

Measured memory_bytes: 3124
var r,g,b,t:integer;
{procedure       mo;
begin
        assign(input,'RGB.inp');reset(input);
        assign(output,'RGB.out');rewrite(output);
end;
procedure       dong;
begin
        close(input);close(output);
end;}
procedure       nhap;
begin
        readln(r,g,b);
end;
procedure       xuli;
begin
        t:=r*100+g*10+b;
        if t mod 4=0 then writeln('YES') else writeln('NO');
end;
begin
        //mo;
        nhap;
        xuli;
        //dong;
end.




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

struct Edge { int to, cost; };
const int INF = 1'000'000'000;

int V, E;
vector<vector<Edge>> graph;
vector<int> dist;

bool BellmanFord(int s) {
	dist[s] = 0;
	for(int i=0; i<V; i++)
		for (int v = 0; v < V; v++)
			for (auto e : graph[v]) {
				if (dist[v] != INF && dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					if (i == V - 1)return true;
				}
			}
	return false;
}

int main() {
	int r;
	cin >> V >> E >> r;
	dist = vector<int>(V, INF);
	graph.resize(V);
	for (int i = 0; i < E; i++) {
		int s, t, d;
		cin >> s >> t >> d;
		graph[s].push_back({ t,d });
	}

	if (BellmanFord(r)) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (auto d : dist) {
			if (d == INF)cout << "INF" << endl;
			else cout << d << endl;
		}
	}
}


Measured memory_bytes: 3180
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  printf("%c%c%c",a[0],b[1],c[2]);
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
#include <iomanip>
using namespace std;
#define int long long
//#define double long double
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<int, pii > pip;
typedef pair<pii, pii > piipii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define all(vec) vec.begin(), vec.end()
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60)
#define mod 1000000007
#define se second
#define fi first

int N, A[100100];
int dp[100100], grp[3];

signed main(){
    cin >> N;
    dp[0] = 1;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        int a = A[i];
        int b = 0;
        int id = -1;
        for(int j = 0; j < 3; j++){
            if(a == grp[j]){
                b++;
                id = j;
            }
        }
        if(id < 0){
            cout << 0 << endl;
            return 0;
        }
        dp[i + 1] = dp[i] * b % mod;
        grp[id]++;
    }
    cout << dp[N] << endl;
    
    
    
    return 0;
}

/*

*/

Measured memory_bytes: 1792
# -*- codinf: utf-8 -*-
from collections import deque

N, M = map(int, input().split())
route = [[] for _ in range(N + 1)]

for _ in range(M):
  a, b = map(int, input().split())
  route[a].append(b)
  route[b].append(a)
  
q = deque([1]) # 頂点を設定して初期化
pre = [None] * (N+1) # 頂点までの最短に進む時の次の頂点のリスト
pre[1] = 0 # 頂点は0
depth = [None] * (N+1) # 頂点からの深さ(最短距離)のリスト
depth[1] = 0 # 頂点の距離は0
while len(q) > 0:
  x = q.popleft()
  for r in route[x]:
    if pre[r] is None:
      depth[r] = depth[x] + 1
      pre[r] = x
      q.append(r)

print("Yes")
for i in range(2, len(pre)):
  print(pre[i])

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  vector<int> a(n), b(n);
  rep (i, n) cin >> a[i] >> b[i];

  sort(rall(a));
  sort(rall(b));

  int ans = h / a[0] + (h % a[0] ? 1 : 0);
  ll bSum = 0;
  rep (i, sz(b)) {
    if (a[0] >= b[i]) break;
    bSum += b[i];
    int tmp = h - bSum;
    if (tmp <= 0) {
      ans = min(ans, i + 1);
      break;
    } else {
      ans = min(ans, tmp / a[0] + (tmp % a[0] ? 1 : 0) + i + 1);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
import math
import bisect
import heapq
import copy
sys.setrecursionlimit(1000000)
from collections import deque
from itertools import permutations

dy = [-1,0,1,0]
dx = [0,1,0,-1]

def main():
    m,n = 0,0
    grid = []
    inf = 1000000007

    def in_the_grid(h,w):
        return 0<=h and h<n  and 0<=w and w<m

    def bfs(i,j):
        dq = deque()
        res = [[inf]*m for _ in range(n)]
        dq.append([i,j,0])
        res[i][j] = 0
        while dq:
            h,w,c = dq.popleft()
            for k in range(4):
                n_h = h+dy[k]
                n_w = w+dx[k]
                if not in_the_grid(n_h,n_w):continue
                if grid[n_h][n_w] == 'x':continue
                if res[n_h][n_w]!=inf:continue
                res[n_h][n_w] = c+1
                dq.append([n_h,n_w,c+1])
        return res

    while True:
        m,n = map(int,input().split())
        if m == 0:break
        grid = []
        dis = []
        ver = []
        for _ in range(n):
            grid.append(input())
        for i in range(n):
            for j in range(m):
                if grid[i][j]=='o':
                    ver.append([i,j])
                    dis.append(bfs(i,j))
        for i in range(n):
            for j in range(m):
                if grid[i][j]=='*':
                    ver.append([i,j])
                    dis.append(bfs(i,j))

        v = len(dis)
        d = [[] for _ in range(v)]
        for i in range(v):
            for j,k in ver:
                d[i].append(dis[i][j][k])

        dp = [[inf]*v for _ in range(1<<v)]
        dp[1][0] = 0
        for bits in range(1<<v):
            for i in range(v):
                if dp[bits][i] == inf:continue
                for j in range(v):
                    if bits&(1<<j):continue
                    dp[bits|(1<<j)][j] = min(dp[bits|(1<<j)][j],
                                             dp[bits][i]+d[i][j])

        ans = inf
        for i in range(1,v):ans = min(ans,dp[(1<<v)-1][i])
        print (ans if ans!=inf else -1)


if __name__ == '__main__':
    main()




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

int main() {
	int n,sum=0;
	cin>> n;
	int S[10000];
	for (int i = 0;i < n;i++) cin >> S[i];
	int q;
	cin >> q;
	int T[500];
	for (int i = 0;i < q;i++) {
		cin >> T[i];
		for (int j = 0;j < n;j++)
			if (T[i] == S[j]) {
			    sum++;
			    break;
			}
	}

	cout << sum << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
#define print(a) cout<<a<<endl
typedef long long ll;
typedef string str;
typedef unsigned long long ul;
#define vint vector<int>

int main() {
	int a,b;
	cin >> a >> b;
	print(max(max(a+b,a-b),a*b));
	
	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++)

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i, m){
        cin >> a.at(i);
    }
    // 0 <- X
    int costA = 0;
    // X -> N
    int costB = 0;
    for (auto k: a){
        if (k < x) costA++;
        else if (x < k) costB++;
    }
    cout << min(costA, costB) << endl;
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;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 COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int K=in();
    ll temp;
    vector<ll> k;
    REP(i,N){
        cin>>temp;
        k.pb(temp);
    }
    sort(all(k));
    ll ans;
    ans=1e10;
    REP(i,N-K+1){
        ans=min(ans,k[i+K-1]-k[i]);
    }
    print(ans);
    return 0;
}

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

int main(){
	while(1){
		int n;	
		int a[12][12];
		
		scanf(" %d", &n);
		if(n==0) break;
		
		a[n][n]=0;
		for(int i=0; i<n; ++i){
			a[i][n]=0;
			for(int j=0; j<n; ++j){
				scanf(" %d", &a[i][j]);
				a[i][n]+=a[i][j];
			}
			a[n][n]+=a[i][n];
		}
		
		for(int i=0; i<n; ++i){
			a[n][i]=0;
			for(int j=0; j<n; ++j){
				a[n][i]+=a[j][i];
			}
		}
		
		for(int i=0; i<=n; ++i){ 
			for(int j=0; j<=n; ++j){
				printf("%5d", a[i][j]);
			}
			printf("\n");
		}
				
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N;
int main() {
	cin >> N;
	cout << "ABC" << N << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if(a<b || b>d){
            cout<<"No"<<endl;
            continue;
        }
        ll l=c+1,r=b-1;
        ll g=__gcd(b,d);
        a%=g;
        //l
        ll x=g-(l%g);
        if(x==g){
            x=l;
        }
        else x+=l;
        if(x-(g-a)>=l){
            l=x-(g-a);
        }
        else l=x+a;
        //l
        //r
        x=r-(r%g);
        if(x+a<=r){
            r=x+a;
        }
        else r=x-(g-a);
        //r
        if(l<=r){
            cout<<"No"<<endl;
        }
        else cout<<"Yes"<<endl;
    }
    return 0;
}


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

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

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

	ll ans=gcd(a[0],a[1]);
	for(ll i=2;i<n-1;i++){
		ans=gcd(ans,a[i]);
	}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n ;
	vector <pair<string,pair<int,int> > > v;
	for(int i=0;i<n;i++){
		string st;
		int x;
		cin >> st >> x;
		v.push_back({st,{(-1)*x,i+1}});
	}
	sort(v.begin(),v.end());
	for(auto i:v)
		cout << i.second.second << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  string s, t; cin >> s >> t;
  rep(i,N){
    if (s.substr(i)==t.substr(0,N-i)){
      cout << N+i << endl;
      return 0;
    }
  }
  cout << 2*N << endl;

  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			char[][] cnt=new char[n]['z'-'a'+1];
			for(int i=0;i<n;i++){
				String str=sc.next();
				for(int j=0;j<str.length();j++) cnt[i][str.charAt(j)-'a']++;
			}
			String ans="";
			for(int i=0;i<'z'-'a'+1;i++){
				int min=Integer.MAX_VALUE;
				for(int j=0;j<n;j++) min=Math.min(min, cnt[j][i]);
				char c=(char)('a'+i);
				for(int j=0;j<min;j++) ans+=Character.toString(c);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21716
s=input()
t=input()

ans = []
if len(s)>=len(t):    
    for i in range(len(s)-len(t)+1):
        cnt=0
        tmp=list(s)
        for j in range(len(t)):
            if s[i+j]!=t[j] and s[i+j]!='?':
                break
            else:
                cnt+=1
                tmp[i+j]=t[j]
        if cnt==len(t):
            tmp="".join(tmp)
            ans.append(tmp.replace('?','a'))
ans = sorted(ans)
if not ans:
    print('UNRESTORABLE')
else:
    print(ans[0])

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

int h[100000], dp[100000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    for (int i=0; i<n; i++)
        cin >> h[i];

    dp[0] = 0;
    for (int i=1; i<n; i++) {
        dp[i] = INT_MAX;
        for (int j=i-1; j>=max(i-k,0); j--)
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }

    cout << dp[n-1] << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;

  vl x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];

  ll m = INF, M = -INF;
  rep(i, n) {
      ll num = x[i] - y[i];
      chmin(m, num);
      chmax(M, num);
  }
  ll ans = M - m;

  m = INF, M = -INF;
  rep(i, n) {
      ll num = x[i] + y[i];
      chmin(m, num);
      chmax(M, num);
  }
  chmax(ans, M - m);

  cout << ans << newl;
  return 0;
}

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

int main()
{
    int N,D,X,c=0,a[100];
    cin>>N;
    cin>>D>>X;
    for(int i=1;i<=N;i++)
    {
        cin>>a[i];

    }
    for(int i=1;i<=N;i++)
    {for(int j=1;j<=D;j=j+a[i])
        {
            c++;

        }
    }
    cout<<(X+c)<<endl;
}

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

struct StExpr
{
  StExpr() : m_nPerson(0), m_nAttr(0) { }

  int m_nPerson;
  int m_nAttr;
};

void fnInput(vector<vector<StExpr>>& rvvoExpr)
{
  int nPersonSiz;
  cin >> nPersonSiz;
  rvvoExpr.resize(nPersonSiz + 1);

  for (int i = 1; i < rvvoExpr.size(); i++)
  {
    int nAttrSiz;
    cin >> nAttrSiz;
    rvvoExpr[i].resize(nAttrSiz);

    for (int j = 0; j < rvvoExpr[i].size(); j++)
      cin >> rvvoExpr[i][j].m_nPerson >> rvvoExpr[i][j].m_nAttr;
  }
}
  
int fnHonestCheck(const vector<vector<StExpr>>& cnrvvoExpr, 
                  const vector<int>& cnrvnHonest, int nMan)
{
  if (cnrvnHonest[nMan])               // Honest
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson ] )
        return 0;

    return 1;
  }
  else                                 // UnKind
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson ] )
        return 1;

    return 0;
  }
}
  
int fnMaxHonestGet(const vector<vector<StExpr>>& cnrvvoExpr)
{
  vector<int> vnHonest(cnrvvoExpr.size());
  int nMaxHonestCnt = 0;
  
  for (int n = 1; n < ( 1 << (cnrvvoExpr.size() - 1) ); n++)
  {
    int nHonestCnt = 0;

    for (int i = 0; i < cnrvvoExpr.size() - 1; i++)
      if (n & (1 << i))
      {
        vnHonest[i + 1] = 1;           // Honest
        nHonestCnt++;
      }
      else
        vnHonest[i + 1] = 0;           // UnKind

    bool bTrue = true;
    for (int nMan = 1; nMan < vnHonest.size(); nMan++)
      if (!fnHonestCheck(cnrvvoExpr, vnHonest, nMan))
      {
        bTrue = false;
        break;
      }

    if (bTrue) nMaxHonestCnt = max(nMaxHonestCnt, nHonestCnt);
  }
  return nMaxHonestCnt;
}
  
int main()
{
  vector<vector<StExpr>> vvoExpr;

  fnInput(vvoExpr);
  cout << fnMaxHonestGet(vvoExpr) << endl;

  return 0;
}

Measured memory_bytes: 256
// Try diverta 2019 Programming Contest 2
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut xy = vec![];
    for _ in 0 .. n {
        let x = get!();
        let y = get!();
        xy.push((x, y));
    }  
    
    let mut cost = n;
    
    for i in 0 .. xy.len() {
        for j in 0 .. xy.len() {
            if i == j {
                continue;
            }
            let p = xy[i].0 - xy[j].0;
            let q = xy[i].1 - xy[j].1;
            let mut cnt = 0;
            for u in 0 .. xy.len() {
                for v in u+1 .. xy.len() {
                	let dx = xy[u].0 - xy[v].0;
                    let dy = xy[u].1 - xy[v].1;
                    if dx == p && dy == q {
                        cnt += 1;
                    } else if -dx == p && -dy == q {
                        cnt += 1;
                    }
                }
            }
            cost = std::cmp::min(cost, n - cnt);
        }
    }
    
    println!("{}", cost);
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include "bits/stdc++.h" // define macro "/D__MAI"

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define repeat(l) for(auto cnt=0;cnt<(l);++cnt)
#define upto(l,r) for(auto cnt=l;cnt<=r;++cnt)
#define downto(r,l) for(auti cnt=r;cnt>=l;--cnt)
#define BIGINT 0x7FFFFFFF
#define MD 1000000007ll
#define PI 3.1415926535897932384626433832795
template<typename T1, typename T2>
ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << "(" << p.first << ":" << p.second << ")"; return o; }

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())
namespace {
    std::chrono::system_clock::time_point ttt;
    void tic() { ttt = TIME; }
    void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - ttt)); }
    std::chrono::system_clock::time_point tle = TIME;
#ifdef __MAI
    void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); }
#else
#define safe_tle(k) ;
#endif
}

#ifdef __MAI //_getchar_nolock
#define getchar_unlocked getchar
#endif
namespace {
    class MaiScanner {
    public:
        template<typename T>
        void input_integer(T& var) {
            var = 0;
            T sign = 1;
            int cc = getchar_unlocked();
            for (; cc<'0' || '9'<cc; cc = getchar_unlocked())
                if (cc == '-') sign = -1;
            for (; '0' <= cc&&cc <= '9'; cc = getchar_unlocked())
                var = (var << 3) + (var << 1) + cc - '0';
            var = var*sign;
        }
        inline int c() { return getchar_unlocked(); }
        inline MaiScanner& operator>>(int& var) {
            input_integer<int>(var);
            return *this;
        }
        inline MaiScanner& operator>>(long long& var) {
            input_integer<long long>(var);
            return *this;
        }
    };
}
MaiScanner scanner;


ll n, kei;

ll vv[101010];

int main() {
    scanner >> n >> kei;

    repeat(n) {
        int a, b;
        scanner >> a >> b;

        vv[a] += b;
    }

    int i;
    for (i = 1; 0 < kei; ++i) {
        kei -= vv[i];
    }

    cout << (i-1) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
const int mx = 27;
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
int mul(int a, int b){
  return (ll)a * b % mod;
}

vector<int> A(mx+7);
vector<int> B(mx+7);
vector<int> C(mx+7);
int main(){
  int n;
  scanf("%d", &n);
  for(int i=1;i<=n;i++){
    scanf("%d", &A[i]);
  }
  for(int i=1;i<=n;i++){
    scanf("%d", &B[i]);
  }
  for(int i=1;i<=n-1;i++){
    scanf("%d", &C[i]);
  }
  int sum = 0;
  int prev = 0;
  for(int i=1;i<=n;i++){
    int idx = A[i];
    if(prev==idx-1){
      sum+=B[idx]+C[idx-1];
      prev=idx;
    }
    else{
      sum+=B[idx];
      prev=idx;
    }
  }
  printf("%d", sum);
}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int S;cin>>S;
    int MOD = pow(10,9)+7;

    int DP[2000];
    DP[0]=0;
    DP[1]=0;
    DP[2]=0;
    DP[3]=1;
    DP[4]=1;
    DP[5]=1;
    for(int i=6;i<S+1;i++){
        DP[i] = 1;
        for(int j=3;j<i+1-3;j++){
            DP[i]=(DP[i]+DP[i-j])%MOD;
        }
    }
    cout<<DP[S]<<endl;











    return 0;
}

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

using namespace std;

#define long long long
//#define double __float128
#define INF (long) 1e18
#define MOD 1'000'000'007
#define mll map<long, long>
#define pll pair<long, long>
#define umap unordered_map
#define umll umap<long, long>
#define pb push_back
#define FOR(i, a, b) \
  for (long i = a; i < (long) b; i++)
#define SORT(v, atr) \
  stable_sort(v.begin(), v.end(), \
    [](auto &a, auto &b) { return a.atr < b.atr; });
#define UNSORT(v, atr) \
  sort(v.begin(), v.end(), \
    [](auto &a, auto &b) { return a.atr > b.atr; });
#define PRINTV(v) \
  FOR (_i, 0, v.size()) \
    cout << v[_i] << " "; \
  cout << "\n";

set<long> gera_primos(long n)
{
  set<long> primos;
  vector<bool> crivo(n+1);
  primos.insert(2);
  for (long i = 3; i <= n; i += 2) {
    if (crivo[i]) continue;
    primos.insert(i);
    for (long j = i; j <= n; j += i) {
      crivo[j] = true;
    }
  }
  return primos;
}

struct Link
{
  long from, to, t;
};

struct Node
{
  bool visitado = false;
  set<long> in, out;
};

umap<long, umap<long, umap<long, long>>> d;

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

  long x, y;
  cin >> x >> y;

  for (long k = x; k < 1e6 * x; k += x) {
    if (k % y != 0) {
      printf("%lld\n", k);
      return 0;
    }
  }
  puts("-1");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;

    if (n >= b) n = b - 1;

    cout << n % b * a / b << endl;

    //x%b*aの最大値をbで割る

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
    ll n,m,sum=0;cin>>n>>m;
    ll a[m];
    for(int i=0;i<m;++i)
    {
    	cin>>a[i];
    	sum+=a[i];
    }	
    ll num=-1;
    cout<<max(num,n-sum)<<"\n";


    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	int x;
	cin>>x;
	int a=0;
	for(int i=1;i<=x;i++){
		a+=i;
		if(a>=x){
			cout<<i<<endl;
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 3556
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
 
using namespace std;

int main(){
    FAST() ;
    string str ; cin >> str ;
    int ans = INT_MAX ;
    for( int i = 0 ; i < str.length() - 2 ; i++ ){
        int a = str[i] - '0' , b = str[i+1] - '0' , c = str[i+2] - '0' ;
        int num = a * 100 + b * 10 + c ;
        ans = min( ans , abs( num - 753) ) ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
    cin>>a[1]>>a[2]>>a[3];

    int ans = 0x3f3f3f3f;
    for(int i = 1;i<=3;i++)
        for(int j = 1;j<=3;j++)
            for(int k = 1;k<=3;k++)
            {
                if(i == k || i == j || j == k) continue;
                ans = min(ans,abs(a[j] - a[i]) + abs(a[k] - a[j]));
            }
    cout<<ans<<endl;
}


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

int main() {
    /*
	cin >> a >> b >> c;
	cout << a << " " << b << " " << c <<endl
	*/
	int a[4][3][10];
	int b,f,r,v,x;
	cin >> x;
	for(int bb=0;bb<4;bb++){
    	for(int ff=0;ff<3;ff++){
        	for(int rr=0;rr<10;rr++){
    	        a[bb][ff][rr]=0;
        	}
    	}
	}
	for(int i=0;i<x;i++){
	    cin >> b>> f>> r>> v;
	    a[b-1][f-1][r-1]+=v;
	}
	for(int bb=0;bb<4;bb++){
    	for(int ff=0;ff<3;ff++){
        	for(int rr=0;rr<10;rr++){
    	        cout << " "<< a[bb][ff][rr];
    	      //  if(rr!=9)cout << " ";
        	}
    	    cout << '\n';
    	}
        if(bb!=3)cout << "####################" << endl;
	}
}

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

int main() {
    int n,x,t;
    cin >> n >> x >> t;

    int a;
    a = n/x;

    if(a*x != n) a += 1;
    long long b = a*t; 
    cout << b << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
// cout<<fixed<<setprecision(10);
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;}


int main() {
    int n;
    cin >> n;
    string ans;
    if(n >= 1000) {
        ans = "ABD";
    } else {
        ans = "ABC";
    }
    cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    bool ret = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == N) {
                ret = true;
            }
        }
    }
    if (ret == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{	int n,q;
	cin>>n>>q;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];	
	}
	Query queries[q];
	
	for(int l,r,i=0;i<q;i++){
			cin>>l>>r;
			queries[i].idx=i;
			queries[i].l=l-1;
			queries[i].r=r-1;
	}
	 
	sort(queries, queries+q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 19300
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

class Dice{

public:
    Dice(){
        num = new int[7];
    }

    ~Dice(){
        delete[] num;
    }

    int setLabel(int i, int label){
        num[i] = label;
    }

    int top(){
        return num[1];
    }

    int roll(char dir){
        int tmp[7];
        memcpy(tmp, num, 7*sizeof(int));
        if(dir == 'W'){
            num[1] = tmp[3];
            num[3] = tmp[6];
            num[6] = tmp[4];
            num[4] = tmp[1];
        }
        else if (dir == 'E')
        {
            num[1] = tmp[4];
            num[3] = tmp[1];
            num[6] = tmp[3];
            num[4] = tmp[6];
        }
        else if(dir == 'S')
        {
            num[1] = tmp[5];
            num[2] = tmp[1];
            num[6] = tmp[2];
            num[5] = tmp[6];
        }
        else if(dir == 'N')
        {
            num[1] = tmp[2];
            num[2] = tmp[6];
            num[6] = tmp[5];
            num[5] = tmp[1];
        }
    }

private:
    int *num;

};

int main(){
    Dice dice;
    
    for(int i=0; i<6;i++){
        int label;
        cin >> label;
        dice.setLabel(i+1, label);
    }

    char dir;
    cin >> dir;
    do{
        dice.roll(dir);
        // cout << dice.top() << endl;
    } while((dir = getchar())!= '\n');

    cout << dice.top() << endl;
}


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

using namespace std;

int main()
{
	long int n,i;
	cin>>n;
          int a[n];
          for(i=0;i<n;i++)
             cin>>a[i];
           sort(a,a+n,greater <int >());
           long int sum=0;
           for(i=0;i<n;i++)
             {
                 if(i%2==0)
                   sum+=a[i];
                 else
                   sum-=a[i];
             }
	  cout<<sum<<"\n";
}

Measured memory_bytes: 256
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e10
#define MAX 100005
#define mod 998244353
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) printf("Case %lld:\n",i)
#define pf(a) printf("%lld ",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp,mp1;
vector<pair<ll,pair<ll,pair<ll,ll> > > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,ll>mpp;
///map<ll,bool>mb;
ll n,x,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,w;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
string s,t;
ll ans=0;
ll dep[MAX+10];
vector<ll>adj[MAX+10];
bool visited[MAX+10];
void reset()
{
    FOR(i,MAX) adj[i].clear();
    memset(visited,false,sizeof visited);
    memset(dep,0,sizeof dep);
}
void dfs(ll u)
{
    visited[u]=true;
    ll l=adj[u].size();
    ll source=u;
    FOR(i,l)
    {
        ll v=adj[u][i];
        if(!visited[v])
        {
            dfs(v);
        }
        dep[source]=max(dep[source],dep[v]+1);
    }
    ///dep[source]=max(1LL,dep[source]);
    ans=max(ans,dep[source]);
}
int main()
{
    ///reset();
    ///freopen("input.txt","r",stdin);
    fast;
    cin>>n>>m;
    reset();
    FOR(i,m)
    {
        ll u,v;
        cin>>u>>v;
        adj[u].p_b(v);
    }
    FOR1(i,n)
    {
        if(visited[i]==false)
        {
            dfs(i);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8704
chomp (my ($h, $w) = split / /, <STDIN>);
my @a;
for my $i (1..$h) {
  chomp (my $s = <STDIN>);
  if (scalar(grep {$_ eq '.'} (split '', $s)) != $w) {
    push @a, $s;
  }
}
for my $i (1..$w) {
  my $f = 1;
  for my $x (@a) {
    $f = 0 if substr($x, $w - $i, 1) ne '.';
  }
  if ($f) {
    for my $x (@a) {
      substr($x, $w - $i, 1) = '';
    }
  }
}
for my $x (@a) {
  print "$x\n";
}

Measured memory_bytes: 512
#define ll long long
#define R register
#include <bits/stdc++.h>

using namespace std;

ll n, p, a[55], f[55][2];
// 选到第i个，总和%2 = j的个数是f[i][j]。
int main()
{
	scanf("%lld%lld", &n, &p);
	for (R int i = 1; i <= n; ++i)
		scanf("%lld", &a[i]);
	f[0][0] = 1;
	for (R int i = 0; i <= n; ++i)
	{
		// 选 or 不选
		f[i + 1][a[i + 1] % 2] += f[i][0];
		f[i + 1][(1 + a[i + 1]) % 2] += f[i][1];
		f[i + 1][0] += f[i][0];
		f[i + 1][1] += f[i][1];
	}
	printf("%lld\n", f[n][p]);
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from heapq import heapify,heappop,heappush
def solve(H,W):
    grid = [input().split() for _ in range(H)]
    dist = [[[INF]*2 for _ in range(W)] for _ in range(H)]

    q = []
    #find start and goal
    g = []
    for i in range(H):
        for j in range(W):
            if grid[i][j] == 'S':
                heappush(q,(0,i,j,0))
                heappush(q,(0,i,j,1))
                dist[i][j][0] = 0
                dist[i][j][1] = 0
            elif grid[i][j] == 'T':
                grid[i][j] = '0'
                g.append((i,j))

    #Dijkstra
    t = ord('0')
    while q:
        d,ny,nx,leg = heappop(q)
        if d > dist[ny][nx][leg]:
            continue
        if leg == 0:
            for ly in range(max(ny - 2,0),min(ny + 3,H)):
                for lx in range(max(0,nx - 3),nx):
                    if abs(ly - ny) + abs(lx - nx) > 3:
                        continue
                    if grid[ly][lx] == 'X' or grid[ly][lx] == 'S':
                        continue
                    if dist[ly][lx][1] > dist[ny][nx][0] + ord(grid[ly][lx]) - t:
                        dist[ly][lx][1] = dist[ny][nx][0] + ord(grid[ly][lx]) - t
                        heappush(q,(dist[ly][lx][1],ly,lx,1))
        else:
            for ry in range(max(ny - 2,0),min(ny + 3,H)):
                for rx in range(nx + 1,min(nx + 4,W)):
                    if abs(ry - ny) + abs(rx - nx) > 3:
                        continue
                    if grid[ry][rx] == 'X' or grid[ry][rx] == 'S':
                        continue
                    if dist[ry][rx][0] > dist[ny][nx][1] + ord(grid[ry][rx]) - t:
                        dist[ry][rx][0] = dist[ny][nx][1] + ord(grid[ry][rx]) - t
                        heappush(q,(dist[ry][rx][0],ry,rx,0))

    ans = min(min(dist[gy][gx]) for gy,gx in g)
    print(-1 if ans == INF else ans)

def main():
    while True:
        W,H = map(int,input().split())
        if H == 0 and W == 0:
            return
        solve(H,W)
if __name__ == '__main__':
    main()


Measured memory_bytes: 5936
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const ll INF = 1000000007;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> m(h, vector<char>(w));
	rep(i, h) {
		rep(j, w) {
			cin >> m[i][j];
		}
	}

	vector<vector<int>> dp(h, vector<int>(w));
	dp[0][0] = 0;
	rep(i, h) {
		rep(j, w) {
			if (i > 0 && j > 0) {
				if (m[i][j] != m[i - 1][j]) dp[i][j] = dp[i - 1][j] + 1;
				else dp[i][j] = dp[i - 1][j];
				if (m[i][j] != m[i][j - 1]) dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
				else dp[i][j] = min(dp[i][j], dp[i][j - 1]);
			}
			else if (i > 0) {
				if (m[i][j] != m[i - 1][j]) dp[i][j] = dp[i - 1][j] + 1;
				else dp[i][j] = dp[i - 1][j];
			}
			else if(j>0) {
				if (m[i][j] != m[i][j - 1]) dp[i][j] = dp[i][j - 1] + 1;
				else dp[i][j] = dp[i][j - 1];
			}
		}
	}
	if (m[0][0] == '#') cout << dp[h - 1][w - 1]/2+1 << endl;
	else cout << (dp[h - 1][w - 1]+1)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll>h(N);
  ll ans=0;
  rep(i,N){
    cin>>h[i];
    if(h[i]>=K){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
I = list(input())
A = int(len(I)) -1

if I[A] == '2' or I[A] == '4' or I[A] == '5' or I[A] == '7' or I[A] == '9':
    print('hon')
elif I[A] == '0' or I[A] == '1' or I[A] == '6' or I[A] == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <math.h>
#include <utility>
using namespace std;
#define ll long long

int main () {
  ll n;
  cin >> n;
  vector<ll> divisor;
  for (ll i = 1; i <= (ll) sqrt(n); i++) {
    if (n % i == 0) {
      divisor.push_back(n/i);  
    }    
  }    
  ll ans = divisor[divisor.size() - 1];
  ll sub = 1;
  for (ll i = 1; i <= 10; i++) {
    sub = sub * 10;
    if (sub > ans) {
      cout <<  i << endl;
      break; 
    }    
  }
}

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

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

  int a, b1, b2;
  char c;
  cin >> a >> b1 >> c >> b2;

  int res = a * (b1*100 + b2);
  cout << res/100 << '\n';
  return 0;
}

Measured memory_bytes: 3664
S = gets.to_s.chomp.chars

R = S.dup.reverse

n = S.length
half = n /2

i = 0
cnt = 0

half.times do
  s = S[i]
  r = R[i]
  
  if s == r
    # equal
  else
    r = s
    cnt += 1
  end
  i += 1
end

p cnt

Measured memory_bytes: 1788
import math
N = int(input())

tax = 1.08
n = N // tax

if math.floor((n) * tax) == N:
    print(int(n))
else:
    while 1:
        if math.floor(n * tax) == N:
            print(int(n))
            break
        elif math.floor(n * tax) < N:
            n += 1
        elif math.floor(n * tax) > N:
            print(":(")
            break


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)


#define INF (1e9)
typedef long long unsigned int ll;


int main()
{

    int a,b,k;
    cin >> a>>b>>k;
    int count = 0;
    for(int i=100;i>0;i--){
        if(a%i==0&&b%i==0){
            count++;
        }
        if(k==count){
            cout << i;
            break;
        }
    }
    

    

    return 0;
}


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

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

c = 0
cur = 0
while True:
    if ab[cur][1] + c < k:
        c += ab[cur][1]
        cur += 1
    else:
        break
print(ab[cur][0])


Measured memory_bytes: 29912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 301;
string s;
ll k;
ll alf[26];

int main(){
	cin>>s>>k;
	FOR(i,0,26){
		alf[i]=26-i;
	}
	alf[0]=0;
	FOR(i,0,s.size()){
		ll j=s[i]-'a';
		if(alf[j]<=k){
			s[i]='a';
			k-=alf[j];
		}
	}
	if(k!=0){
		k%=26;
		while(k!=0){
			k--;
			if(s[s.size()-1]=='z')s[s.size()-1]='a';
			else s[s.size()-1]++;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INT(name) int name; scanf("%d",&name);
#define VINT(name,n) vector<int> name(n); for(int i = 0;i < n;i++) scanf("%d",&name[i]);

using namespace std;

int main(int argc, char const *argv[]){
	VINT(height,10)
	sort(height.begin(),height.end(),greater<int>());
	for(int i = 0;i < 3;i++){
		printf("%d\n",height[i]);
	}
	return 0;
}

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

int main() {
	map<int, int> ma;
	int tmp;
	for (int i = 0; i < 3; i++) {
		cin >> tmp;
		ma[tmp]++;
	}
	if (ma.size() == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#動的計画法
#C - Vacation
#aのところをdp[i][0]とするとなぜか事故る、そういう仕様なのか？、それどもdp = [[0,0,0]]*Nが影響しているのか
N = int(input())
H = [list(map(int,input().split())) for i in range(N)]
dp = [[0,0,0]]*N
dp[0] = H[0]
for i in range(1,N):
    a = max(dp[i-1][1],dp[i-1][2])+H[i][0]
    b = max(dp[i-1][0],dp[i-1][2])+H[i][1]
    c = max(dp[i-1][0],dp[i-1][1])+H[i][2]
    dp[i] = [a,b,c]
print(max(dp[N-1]))

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

#define BUF_SIZE 50

int get_int3(uint64_t *a1, uint64_t *a2, uint64_t *a3) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%llu %llu %llu", a1, a2, a3);
#else
#error
#endif
  return 0;
}

int main(void) {
    uint64_t a, b, k;
    get_int3(&a, &b, &k);
    if(k <= a) {
        a -= k;
    } else if (k > a && k <= a+b) {
        k -= a;
        a = 0;
        b -= k;
    } else {
        a = 0; b = 0;
    }
    printf("%llu %llu\n", a, b);
    return 0;
}

Measured memory_bytes: 128