akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define WHOLE(v) v.begin(), v.end()
using namespace std;
const int INF = 1e8;
set<int> s[4];
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> ans(N, INF);
    vector<vector<int>> edge(N, vector<int>());
    for(int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edge[u].push_back(v);
    }
    if(M == 0) {
        cout << -1 << endl;
        return 0;
    }
    int S, T;
    cin >> S >> T;
    S--, T--;
    set<int> o[2];
    o[0].insert(S);
    int t = 0;
    while(o[t % 2].size()) {
        for(auto i = o[t % 2].begin(); i != o[t % 2].end(); i++) {
            int c = *i;
            if(c == T) {
                cout << t << endl;
                return 0;
            }
            s[0].insert(c);
        }
        for(int j = 0; j < 3; j++) {
            for (auto i = s[j].begin(); i != s[j].end(); i++) {
                int p;
                p = *i;
                for(auto i2 = edge[p].begin(); i2 != edge[p].end(); i2++) {
                    s[j + 1].insert(*i2);
                }
            }
            s[j].clear();
        }
        for (auto i = s[3].begin(); i != s[3].end(); i++) {
            int p = *i;
            if (ans[p] < t) continue;
            ans[p] = t;
            o[(t + 1) % 2].insert(p);
        }
        s[3].clear();
        o[t % 2].clear();
        t++;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 8060
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
main() { ios::sync_with_stdio(false);
  vector<int> xs(3);
  for(auto& x:xs) cin>>x;
  sort(xs.begin(), xs.end());
  cout<< (xs[0]*xs[1])/2 <<endl;
}

Measured memory_bytes: 256
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int R;
  cin >> R;
  double pi = 3.14159265359;
  cout << 2*R*pi << endl;

  return 0;
}


Measured memory_bytes: 3784
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m, k = map(int, input().split())

class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        # union by rank
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)

        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def count_member(self, x):
        return -self.p[self.find(x)]


uf = UnionFind(n)
ab = []
cd = []

for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    ab.append((a, b))
    uf.union(a, b)

for _ in range(k):
    c, d = map(lambda x: int(x)-1, input().split())
    cd.append((c, d))

ans = [uf.count_member(i)-1 for i in range(n)]

for a, b in ab:
    if uf.same(a, b):
        ans[a] -= 1
        ans[b] -= 1

for c, d in cd:
    if uf.same(c, d):
        ans[c] -= 1
        ans[d] -= 1

print(*ans)


Measured memory_bytes: 37944
import itertools
seq=[int(i) for i in input().split()]
#print(len(a))
x=100000
listseq=list(itertools.permutations(seq))
#print(listseq)
for j in range(len(listseq)):
  y=abs(listseq[j][1]-listseq[j][0])+abs(listseq[j][2]-listseq[j][1])
  if y < x:
    x=y
print(x)

Measured memory_bytes: 3060
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //when you use, devide by 1e+9!!!!! auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

ll A,B,C;
ll X,Y;
ll m;

int main()
{
	cin>>A>>B>>C;
	cin>>X>>Y;
	m=min(X,Y);
	if(A+B<2*C){
		cout<<A*X+B*Y<<endl;
	}
	else{
		ll a=max(X,Y);
		X-=m;
		Y-=m;
		cout<<min(C*m*2+A*X+B*Y,a*2*C)<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
while(true){
int m=sc.nextInt();
int f=sc.nextInt();
int r=sc.nextInt();
if(m==-1&&f==-1&&r==-1){
    break;
}
if(m==-1||f==-1){
    System.out.println("F");
}else if(m+f>=80){
    System.out.println("A");
}else if(m+f>=65){
    System.out.println("B");
}else if(m+f>=50||r>=50){
    System.out.println("C");
}else if(m+f>=30){
        System.out.println("D");
}else {
    System.out.println("F");
}
}
sc.close();
    }
}


Measured memory_bytes: 26296
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
  int kazu = 0;
  int jyougenn = 0;
  cin >> kazu >> jyougenn;
  vector<long long> hp(kazu);
  for(int i = 0;i <= kazu - 1;i++){
    cin >> hp[i];
  }
  sort(hp.begin(),hp.end());
  long long kotae = 0;
  for(int i = 0;i <= kazu - 1 - jyougenn;i++){
    kotae += hp[i];
  }
  cout << kotae << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
 
// #define fisier 1
 
using namespace std;
 
typedef long long ll;
 
const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;
 
int main()
{
	#ifdef fisier
		ifstream cin("input.in");
		ofstream cout("output.out");
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n;
	cin >> n;
	ll pw = 26;
	int stp = 1;
	while(n > pw)
	{
		++stp;
		n -= pw;
		pw *= 26;
	}
	vector<char> v;
	--n;
	for(; stp; --stp)
	{
		ll rest = n%26;
		v.push_back('a' + rest);
		n /= 26;
	}
	reverse(v.begin(), v.end());
	for(auto x : v)
		cout << x;
	/*
	int t = 1;
	cin >> t;
	for(; t; --t)
	{
		
	}
	*/
	return 0;
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int n; cin >> n;
    pair<int, int> arr[n];
    int ans[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i].first;
        arr[i].second = i;
    }
    sort(arr, arr + n);
    for(int i = 0; i < n; i++){
        ans[i] = arr[i].second + 1;
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << " ";
    }
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N, A, B; cin >> N >> A >> B;
  int cnt1 = 0, cnt2 = 0, cnt3 = 0;
  for (int i = 0; i < N; i++){
    int P; cin >> P;
    if (P <= A) cnt1++;
    else if (P > B) cnt3++;
    else cnt2++;
  }

  cout << min(cnt1, min(cnt2, cnt3)) << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <iostream>


int main(void){
	int a, b, c, k, res = 0;
	std::cin >> a >> b >> c >> k;
	if(a >= k){
		res += k;
		k = 0;
	} else if(a < k){
	       	res += a;
		k -= a;
	}
	if(b >= k) k = 0;
	else if(b < k) k -= b;
	if(c >= k){
		res -= k;
		k = 0;
	} else if(c < k){
		res -= c;
		k -= c;
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int n,m,a,b,d[N];
vector<int> v[N];
int main(){
    cin>>n>>m;
    while(m--){
	cin>>a>>b;
	v[a].push_back(b);
    }
    for(int i=0;i<=n;i++)d[i]=0;
    for(int i=0;i<=n;i++){
	for(auto x:v[i])d[x]=max(d[x],d[i]+1);
	d[i+1]=max(d[i+1],d[i]);
    }
    cout<<d[n]<<endl;
    return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
   using namespace std;
   int main()
   {
       ios::sync_with_stdio(0);
       cin.tie(0);
       int x1,x2,x3,x4,x5;
       cin>>x1>>x2>>x3>>x4>>x5;
       if(x1==0)
       cout<<"1";
       else if(x2==0)
       cout<<"2";
       else if(x3==0)
       cout<<"3";
       else if(x4==0)
       cout<<"4";
       else
       cout<<"5";
   

   return 0;
   }

Measured memory_bytes: 3580
N,L=map(int,input().split())
taste = [0]*N
taste_minus = [0]*N
for i in range(N):
    taste[i]=L+i
for j in range(N):
    taste_minus[j]=abs(taste[j])
    minus = min(taste_minus)
    if taste[j]<0:
        minus = -1*minus
    

print(sum(taste)-minus)
    

Measured memory_bytes: 9108
#!/usr/bin/env python

def main():
    k = int(input())
    a, b = map(int, input().split())

    ret = "NG"
    for i in range(a, b+1):
        if i % k == 0:
            ret = "OK"
            break

    print(ret)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;


using Hash = __int128;

constexpr Hash MOD = 999999999999999829LL;
constexpr Hash A = 1e9-1;

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

    map<pair<Hash,char>,ll> mp;

    for(const auto& ss:s){
        Hash h = 0;
        for(int j=1;j<ss.size();j++){
            h = (h*A + ss[j])%MOD;
        }
        mp[make_pair(h,ss[0])]++;
    }

    ll ans = 0;
    for(const auto& ss:s) {
        vector<int> cnt(26);
        for(auto c:ss) cnt[c-'a']++;
        Hash h = 0;
        Hash a = 1;
        for(int i=ss.size()-1;i>=0;i--){
            for(int j=0;j<26;j++){
                auto key = make_pair(h,char(j+'a'));
                if(cnt[j] && mp.count(key)){
                    ans+=mp[key];
                }
            }
            cnt[ss[i]-'a']--;
            h=(h+ss[i]*a)%MOD;
            a = a*A%MOD;
        }
    }
    
    cout<<ans-n<<endl;
    return 0;
}

Measured memory_bytes: 28152
import java.util.*;

class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    long X = sc.nextLong();
    long ans = 0;
    ans += X / 11 * 2;
    
    if(X % 11 > 0){
      if(X % 11 <= 6) ans += 1;
      else ans += 2;
    }
    
    System.out.println(ans);
  }
}
    

Measured memory_bytes: 35800
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
 
int main(void)
{
   int n,sum=0;scanf("%d",&n);
   int a[n];
   int b[n]={0};
    for(int i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
   }
   for(int i=0;i<n-1;i++)
   {
       if(a[i]>=a[i+1])
          {
              sum++;
              b[i]=sum;
          }
         
         else
         { 
             sum=0;
             b[i]=sum;
         }
         
   }
   sort(b,b+n);
   printf("%d",b[n-1]);
   return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l;
    string st;
    cin>>st;
     l=st.size();
     if(st[l-1]=='s')
         st=st+"es";
    else
        st=st+'s';
    cout<<st;
   return 0;
}



Measured memory_bytes: 3632
import sys


def main() -> None:
    x, y = [int(next_str()) for _ in range(2)]

    cnt = 0
    if abs(x) < abs(y):
        cnt += x < 0
        cnt += y < 0
    elif abs(x) > abs(y):
        cnt += x > 0
        cnt += y > 0
    else:
        cnt += x != y

    print(abs(abs(x) - abs(y)) + cnt)


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
def solve():
  from itertools import groupby as gb 
  n=int(input())
  sl,vl=[list(a) for a in zip(*[(s,len(list(i))) for s,i in gb(sorted([input() for i in range(n)]))])]
  m=int(input())
  slm,vlm=[list(a) for a in zip(*[(s,-len(list(i))) for s,i in gb(sorted([input() for i in range(m)]))])]
  for i in set(sl)&set(slm):
    vl[sl.index(i)]+=vlm[slm.index(i)]
  print(max(0,max(vl)))
  
if __name__=="__main__":
  solve()

Measured memory_bytes: 3064
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    if S[-1]=="s":
        S+="es"
    else:
        S+="s"
        
    print(S)

main()


Measured memory_bytes: 61956
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


    int ans = 0;
    int n;
    cin >> n;


    for(int i = 1; i <= n; i++)
    {
    	for(int j = 1; i * j < n; j++)
    	{
    		ans++;
    	}
    }

    cout << ans;
 
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N, B[1001], C[1001], x1, x2, d, t, i, j;
    int *A;
    A=malloc(sizeof(int) * 1001001);
    scanf("%d", &N);
    for (i=1; i<=N; i++) {
        for (j=1; j<=N-1; j++) scanf("%d", &A[1000*i+j]);
        B[i]=1;
        C[i]=0;
    }
    x1=N*(N-1)/2;
    x2=x1;
    d=0;
    while (x1>0) {
        x2=x1;
        d++;
        for (i=1; i<=N; i++) {
            t=A[1000*i+B[i]];
            if (i==A[1000*t+B[t]] && C[i]==0 && C[t]==0) {
                B[i]++;
                B[t]++;
                C[i]++;
                C[t]++;
                x1--;
                // printf("[!], ");
            }
            // printf("(%d, %d, %d, %d), ", d, i, t, A[t][B[t]]);
        }
        // printf("\n");
        for (i=1; i<=N; i++) C[i]=0;
        if (x1==x2) {
            d=-1;
            break;
        }
    }
    printf("%d", d /*x*/);
    return 0;
}


Measured memory_bytes: 4096
/*
author : w2sc
  date : 2019/12/22
  time : 20:34:47
*/
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
const int M=1e5+10,INF=0x3f3f3f3f;
const double EPS=1e-10,PI=acos(-1.);
vector<int> G[M];
int n,s,t,d[2][M];
void dfs(int u,int dis,int ma,int fa)
{
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        if(v==fa)
            continue;
        d[ma][v]=dis+1;
        dfs(v,dis+1,ma,u);
    }
}
int main()
{
    scanf("%d%d%d",&n,&t,&s);
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(s,0,0,-1),dfs(t,0,1,-1);
    //for(int i=1;i<=n;i++)
    //    printf("%d %d\n",d[0][i],d[1][i]);
    int ans=d[0][t]-1;
    for(int i=1;i<=n;i++)
    {
        if(G[i].size()==1 && i!=s && i!=t)
        {
            //printf("%d\n",i);
            int u=G[i][0];
            if(d[0][u]>=d[1][u])
                ans=max(ans,d[0][u]);
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 12928
import sys
import math as mt
#input=sys.stdin.buffer.readline  
t=1
#t=int(input())
for _ in range(t):
    #n=int(input())
    #a,b,c=map(int,input().split())
    #l=list(map(int,input().split()))
    ans=0
    s1=input()
    s2=input()
    for i in range(len(s1)):
        if s1[i]!=s2[i]:
            ans+=1
    print(ans)

Measured memory_bytes: 68004
w = [i for i in range(int(input()))]
n = int(input())

for i in range(n):
  a, b = map(int, input().split(","))
  w[a-1], w[b-1] = w[b-1], w[a-1]

for i in range(len(w)):
  print(w[i]+1)


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define llrep(i,a,b) for(ll i=a;i<b;i++)
#define llrepd(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
int dx[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[8] = { 1, 0, -1, 0 ,1, -1, 1, -1 };
ll H, W;
vector<vector<int>> area;

void dfs(int i, int j) {
    area[i][j] = 0;
    rep(n, 0, 8) {
        int nx = i + dx[n], ny = j + dy[n];
        if (nx >= H || ny >= W || nx < 0 || ny < 0) continue;
        if (area[nx][ny] == 1) dfs(nx, ny);
    }
}


void resolve(ll W, ll H) {
    area = vector<vector<int>>(H, vector<int>(W));
    rep(i, 0, H) rep(j, 0, W) cin >> area[i][j];
    ll count = 0;
    rep(i, 0, H) {
        rep(j, 0, W) {
            if (area[i][j] == 1) {
                count++;
                dfs(i, j);
            }
        }
    }
    cout << count << endl;
}

void _main() {
    while(true) {
        cin >> W >> H;
        if (W == 0 && H == 0) break;
        resolve(W,H);
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

vector<vector<int>> cache;
int recursive(int cur, int prev, const vector<vector<int>>& cost) {
  if (cur == cost.size()) {  // all done
    return 0;
  }
  if (prev != -1 && cache[cur][prev] != -1) {
    return cache[cur][prev];
  }
  int points = 0;
  // consider only ones with different prev
  for (int j = 0; j < 3; ++j) {
    if (j != prev) {
      points =
          max(points, recursive(cur + 1, j, cost) + cost[cur][j]);  // prev = j
    }
  }
  if (prev == -1) {
    return points;
  }
  return cache[cur][prev] = points;
}

void solve() {
  // write your code here
  int n;
  cin >> n;
  vector<vector<int>> cost(n, vector<int>(3));  // n*3 cost matrix
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> cost[i][j];
    }
  }
  cache.assign(n, vector<int>(3, -1));
  int ans = recursive(0, -1, cost);
  cout << ans << endl;
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 17408
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		StringBuilder str = new StringBuilder(s.next()
				.replaceAll("eraser", "")
				.replaceAll("dream", "D")
				.replaceAll("er", "R")
				.replaceAll("as", "A"));
		String[] m = {"RAe","DR","D"};
		String b,st;
		boolean f;
		do {
			f=false;
			for(int i=0;i<m.length;i++) {
				b=m[i];
				st = str.toString();
				if(st.endsWith(b)) {
					str.delete(str.length()-b.length(),str.length());
					f=true;
					break;
				}
			}
		}while(f);
		System.out.println((str.toString().equals(""))?"YES":"NO");
	}
}

Measured memory_bytes: 204180
N = int(input())

dp = [10000] * (N+1)

dp[0] = 0

for n in range(N+1):
  count = 1
  while(True):
    if count > N:
      break

    if n - count < 0:
      break

    dp[n] = min(dp[n], dp[n-count]+1)
    count *= 6

  count = 1
  while(True):
    if count > N:
      break

    if n - count < 0:
      break

    dp[n] = min(dp[n], dp[n-count]+1)
    count *= 9

print(dp[N])

Measured memory_bytes: 41200
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807
 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
} 
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

bool islower(char x)
{
	int n=x-'a'+1;
	return (n>=1 && n<=26);
}

int solve()
{
	string x;
	cin>>x;
	if(x[0]=='A')
	{
		ll j;
		bool flag=false;
		forr(i,2,x.size()-1)
		{
			if(x[i]=='C')
			{
				j=i;
				flag=true;
				break;
			}
		}
		if(flag)
		{
			forr(i,1,x.size())
			{
				if(i==j) continue;
				if(!islower(x[i])) return printf("WA"),0;
			}
			printf("AC");
			return 0;
		}
		else printf("WA");
	}
	
	else printf("WA");
		
		
	
	return 0;
}
	
 
int main()
{   
 
//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
}

 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();

      long mp = dfs(arr, A, B, C, 0, 0, 0, 0);
      System.out.println(mp);
  }

  private static long dfs(int[] arr, int A, int B, int C, int curA, int curB, int curC, int curN) {
    if(curN == arr.length) {
      if(curA  == 0 || curB  == 0 || curC == 0)
        return Integer.MAX_VALUE;
      else
        return Math.abs(A - curA) + Math.abs(B - curB) + Math.abs(C - curC) - 30;
    }

    long rest0 = dfs(arr, A, B, C, curA, curB, curC, curN + 1);
    long rest1 = dfs(arr, A, B, C, curA + arr[curN], curB, curC, curN + 1) + 10;
    long rest2 = dfs(arr, A, B, C, curA, curB + arr[curN], curC, curN + 1) + 10;
    long rest3 = dfs(arr, A, B, C, curA, curB, curC + arr[curN], curN + 1) + 10;
    return Math.min(rest0, Math.min(rest1, Math.min(rest2, rest3)));
  }
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

ll dp[3001][3001][4];
ll pts[3001][3001];

int main(){
    ll r,c,k;
    cin >> r >> c >> k;
    

    rep(i,0,k){
        ll x,y;
        cin >> y >> x;
        cin >> pts[y-1][x-1];
    }

    rep(i,0,r+1){
        rep(j,0,c+1){
            rep(l,0,4){
                ll temp = 0;
                if(j > 0 && l > 0) temp = max(dp[i][j-1][l],dp[i][j-1][l-1] + pts[i][j-1]);
                else if(j != 0) temp = dp[i][j-1][l];

                if(i > 0){
                    rep(m,0,4){
                        if(m == 3) temp = max(temp,dp[i-1][j][m]);
                        else temp = max(temp,dp[i-1][j][m] + pts[i-1][j]);
                    }
                }

                dp[i][j][l] = temp;
            }
        }
    }

    cout << dp[r][c][3] << endl;
    return 0;
}


Measured memory_bytes: 355292
H, W, K = map(int, input().split())
C = [[elem for elem in input()] for _ in range(H)]
Count = 0

H = 2 ** H - 1
W = 2 ** W - 1

for I in range(H+1):
    for J in range(W+1):
        count = 0
        for i, row in enumerate(C):
            for j, elem in enumerate(row):
                if 2 ** i & I and 2 ** j & J and elem == '#':
                    count += 1
        if count == K:
            Count += 1

print(Count)

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

const int MAXN = 21;
const int MAXL = (1 << 21 ) + 2;
const int MOD = 1e9 + 7;

int dp[MAXN][MAXL],mascara[MAXN],N;

int solve(int pos,int bitmask)
{
	if(pos == N) return (__builtin_popcount(bitmask) == N);
	if(dp[pos][bitmask] != -1) return dp[pos][bitmask];
	int tot = 0;
	for(int i = 0;i<N;i++){
		if(!(bitmask & (1 << i)) && ((1 << i) & mascara[pos])){
			tot = (tot + solve(pos+1, bitmask | (1 << i) )) % MOD;
		}
	}
	return dp[pos][bitmask] = tot;
}

int main()
{
	memset(dp,-1,sizeof(dp));
	cin >> N;
	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++){
			int x;
			cin >> x;
			if(x) mascara[i] |= (1 << j);
		}
	}
	cout << solve(0,0) << endl;
}

Measured memory_bytes: 175676
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

 //最大公約数求める関数
auto my_gcd(auto n , auto m){
  if(n < m){
    auto tmp = n;
    n = m;
    m = tmp;
  }
  auto l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
string S; cin >> S;
vector<char> c(3);
int sum;
rep(s,1<<3)// 2^n 通り 
{
	sum = ctoi(S[0]);
rep(i,3){
	
	
    if(s >> i&1){// sのibit目が立っているとき実装される = true
		sum+=ctoi(S[i+1]);
		c[i] = '+';
	
}
	else{
		sum -= ctoi(S[i+1]);
		c[i] = '-';
	}
}
if(sum == 7) {
	cout << S[0] << c[0] << S[1] << c[1] << S[2] << c[2] <<S[3] << '=' << 7 << endl;
	break;
}

}

}

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

int main() {
	int N;
	cin >> N;
	if (N < 105) cout << 0;
	else if (N < 135) cout << 1;
	else if (N < 165) cout << 2;
	else if (N < 189) cout << 3;
	else if (N < 195) cout << 4;
	else cout << 5;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

条件を満たす数を数えてみよう
まず105=3*5*7は8個
後は？
そもそも、約数が8個=a^7、a*b^3、a*b*cのケースが考えられる
a^7は単純に3^7>200なのでどうでもいい
a*b^3は3^3*5=135、3^3*7=189が考えられる
a*b*cは3*5*7=105、3*5*11=165、3*5*13=195が考えられる
*/

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

using namespace std;

int simulate(vector<pair<char, char>> &qs, string &s, int pos) {
  for (int i = 0; i < qs.size(); ++i) {
    if (s[pos] != qs[i].first) {
      continue;
    }

    if (qs[i].second == 'L') {
      pos--;
    } else {
      pos++;
    }

    if (pos < 0) {
      return -1;
    } else if (pos >= s.size()) {
      return 1;
    }
  }

  return 0;
}

int main(int argc, const char *argv[]) {
  int n, q;
  string s;
  cin >> n >> q >> s;

  vector<pair<char, char>> qs(q);
  for (auto &p : qs) {
    cin >> p.first >> p.second;
  }

  // solve left
  int ans_l, ans_r;
  {
    int left = 0, right = s.size();
    while (left < right) {
      int mid = (left + right) / 2;
      int sim = simulate(qs, s, mid);
      if (sim == -1) {
        left = mid + 1;
      } else {
        right = mid;
      }
    }

    ans_l = right;
  }

  // solve right
  {
    int left = 0, right = s.size();
    while (left < right) {
      int mid = (left + right) / 2;
      int sim = simulate(qs, s, mid);
      if (sim == 1) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }

    ans_r = right;
  }

  int dropped = 0;
  dropped += ans_l;
  dropped += s.size() - ans_r;

  cout << s.size() - dropped << '\n';
}

Measured memory_bytes: 3932
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;



int main() {ll h, w; cin >> h >> w;
	vector<string> a(h);
	vector<vector<ll>> memo(h);
	rep(i, 0, h) memo[i].resize(w,-1);
	memo[0][0] = 0;
	rep(i, 0, h) cin >> a[i];
	queue<p> q;
	q.push(make_pair(0, 0));
	while (!q.empty()) {
		p s = q.front(); q.pop();
		int dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,1,-1 };
		rep(i, 0, 4) {
			ll x = s.first + dx[i], y = s.second + dy[i];
			if (x < 0 || x >= h || y < 0 || y >= w) continue;
			if (a[x][y] == '#' || memo[x][y] > 0) continue;
			q.push({ x, y });
			memo[x][y] = memo[s.first][s.second] + 1;
		}
	}
	ll white = 0;
	rep(i, 0, h)rep(j, 0, w) {
		if (a[i][j] == '.') white++;
	}
	if (memo[h - 1][w - 1] > 0)cout << white - memo[h - 1][w - 1] - 1 << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
input = STDIN.readlines.map{|line|line.strip.split()}
line = input.shift
n = line[0].to_i
sum = 0
input.each do |s|
    x = s[0].to_f
    if s[1] == 'BTC' then
        x *= 380000.0
    end
    sum += x
end
puts(sum)


Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        boolean isNG = true;
        for (int i = 1; i < 10; i++) {
            if (n % i == 0 && n / i < 10) {
                isNG = false;
                break;
            }
        }
        // write your code
        System.out.println(isNG ? "No" : "Yes");
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23764
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    md = 998244353
    n, s = MI()
    aa = LI()
    dp = [0] * (s + 1)
    ans = 0
    for a in aa:
        dp[0] += 1
        for i in range(s, a - 1, -1):dp[i] += dp[i - a]
        ans += dp[s]
    print(ans%md)

main()


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	double a,b,p,q,r;
	cin >> a >> b >> p >> q >> r;
	//p*b - r*(t-b) = q*(t-a);
	//(q+r)*t = p*b + q*a + r*b;
	//t = (p*b + q*a + r*b)/(q+r);
	cout << setprecision(10) << (p*b + q*a + r*b)/(q+r) << endl;
	return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<string> XA, BA, BX, XX;
  rep(i,N){
    string s;
    cin >> s;

    if(s[0] == 'B'){
      if(s[s.size()-1] == 'A') BA.push_back(s);
      else BX.push_back(s);
    }else if(s[s.size()-1] == 'A'){
      XA.push_back(s);
    }else{
      XX.push_back(s);
    }
  }

  if(XA.size() > 0){
    rep(i,BA.size()){
      XA[0] += BA[i];
    }
  }else{
    string tmp = "";
    rep(i,BA.size()){
      tmp += BA[i];
    }
    XA.push_back(tmp);
  }
  
  string ret = "";
  rep(i,max(XA.size(),BX.size())){
    if(i<XA.size() && i<BX.size()){
      ret += XA[i] + BX[i];
    }else{
      if(i<XA.size()) ret += XA[i];
      if(i<BX.size()) ret += BX[i];
    }
  }
  rep(i,XX.size()){
    ret += XX[i];
  }

  int cnt = 0;
  rep(i,ret.size()-1){
    if(ret[i] == 'A' && ret[i+1] == 'B') cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}



Measured memory_bytes: 1024
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    s = s_input()

    l = [0 for i in range(len(s))]
    cnt = 0
    flg = "R"

    for n,i in enumerate(s):
        if i == flg:
            cnt += 1
        else:
            if i == "L":
                f = math.ceil(cnt/2)
                b = cnt - f
                l[n-1] = l[n-1] + f
                l[n] = l[n] + b
                flg = "L"
            else:
                b = math.ceil(cnt/2)
                f = cnt - b
                l[n-cnt-1] = l[n-cnt-1] + f
                l[n-cnt] = l[n-cnt] + b
                flg = "R"
            cnt = 1
    b = math.ceil(cnt/2)
    f = cnt - b
    l[n-cnt] = l[n-cnt] + f
    l[n-cnt+1] = l[n-cnt+1] + b

    print(" ".join(map(str,l)))





if __name__=="__main__":
    main()


Measured memory_bytes: 82456
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp;
  auto f = true;
  if (!(s.length % 2)) {
    foreach (i; 0..s.length/2) {
      if (s[i*2..i*2+2] != "hi") {
        f = false;
        break;
      }
    }
  } else {
    f = false;
  }
  if (f) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,N) for (int (i) = 0; (i) < (N); (i)++)

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int a, b; std::cin >> a >> b;
	int num = std::stoi(std::to_string(a) + std::to_string(b));
	if ((int)sqrt(num) * (int)sqrt(num) == num)std::cout << "Yes";
	else std::cout << "No";
	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp::min;

fn solve(mut a: i64, mut b: i64, n: i64) -> i64 {
    if n == 1 {
        return min(a, b);
    }
    while a != b {
        if a > b {
            a = (a + n - 2) / n;
        } else {
            b = (b + n - 2) / n;
        }
    };
    a
}

fn main()
{
    input! {
    n:i64,
    q:usize,
    query:[(i64,i64);q],
    }

    for (a, b) in query {
        println!("{}", solve(a, b, n));
    }
}

Measured memory_bytes: 5528
// C.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	int ans = 1 << 30;
	for (int i = 0; i <= n; ++i) {
		int cnt = 0, r = i;
		for (int j = 6; r > 0; j *= 6) {
			cnt += (r % j) / (j / 6);
			r -= r % j;
		}
		r = n - i;
		for (int j = 9; r > 0; j *= 9) {
			cnt += (r % j) / (j / 9);
			r -= r % j;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
t=1
for i in range(n//2):
    if s[i]!=s[-1-i]:
        t=0
for i in range(n//4):
    if s[i]!=s[n//2-1-i]:
        t=0
if t==1:
    print("Yes")
else:
    print("No")

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

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

int main() {
  for (int n; cin >> n, n; ) {
      const string digit = "01235789";
      string ans;
      while (n) {
          ans = digit[n % 8] + ans;
          n /= 8;
      }
      cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int n;
  cin >> n;
  string s;
  int ac=0, wa=0, tle=0,re=0;
  rep(i, n) {
    cin >> s;
    if(s=="AC") ac++;
    else if(s=="WA") wa++;
    else if(s=="TLE") tle++;
    else re++;
  }
  
  //output
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int W,H,x,y,r;
    
    cin >> W >> H >> x >> y >> r;
    
    if(!((r <= x)&&(x <= W-r)&&(r <= y)&&(y <= H-r)))
    {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;
int n,m;
int adj[100][100] = {};

int dfs(int curr, vector<int> &nodes){
	int ret = 0;
	if(nodes.size() > 1){
		for(int i=0; i<(int)nodes.size(); i++){
			int sub = inf;
			for(int j=0; j<(int)nodes.size(); j++){
				if(i==j) continue;
				sub = min(sub, adj[nodes[i]][nodes[j]]);
			}
			ret += sub;
		}
	}
	for(int i=curr; i<n; i++){
		bool ok = true;
		for(int v: nodes){
			if(adj[i][v] == 0) ok = false;
			break;
		}
		if(ok){
			nodes.push_back(i);
			ret = max(ret, dfs(i+1, nodes));
			nodes.pop_back();
		}
	}
	return ret;
}

int main(){
	cin >> n >> m;
	for(int i=0; i<m; i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		adj[a][b] = adj[b][a] = c;
	}
	vector<int> nodes;
	cout << dfs(0, nodes) << endl;
	return 0;
}


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

using namespace std;

const int Nmax = 1e5+5;
long long a[Nmax], b[Nmax], cnt=0;
int i, n;

int main()
{
   // freopen("input", "r", stdin);
   // freopen("output", "w", stdout);

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

    for(i=n; i; --i)
    {
        a[i] += cnt;
        a[i] %= b[i];
        if(a[i]) cnt += b[i] - a[i];
    }

    printf("%lld\n", cnt);

    return 0;
}


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

int main() {
  long long N, M;
  cin >> N >> M;
  if (N == 1LL && M == 1LL) {
    printf("1");
  } else if (N == 1LL || M == 1LL) {
    printf("%lld", N * M - 2LL);    
  } else {
    printf("%lld", N * M - 2LL * (N + M - 2LL));
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<cmath>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    vector<vector<pair<int,int>>> V;
    for(int i=0;i<N;i++){
        cin >> A[i];
        vector<pair<int,int>> tmpV;
        for(int j=0;j<A[i];j++){
            int tmpx;
            cin >> tmpx;
            int tmpy;
            cin >> tmpy;
            //xijはゼロ始まりにする。
            tmpV.push_back(make_pair(tmpx-1,tmpy));
        }
        V.push_back(tmpV);
        tmpV.clear();
    }

    int max = 0;
    for(int bit=0;bit < (1<<N);bit++){
        bool flag = true;
        for(int i=0;i<N;i++){
            //i番目が不親切という周回なら何もしない
            //i番目が正直者という仮定ならば証言を採用する
            if(bit & (1<<i)){
                for(int j=0;j<V[i].size();j++){
                    if(
                        //正直者という仮定なのに不親切という証言があるか、
                        //不親切という仮定なのに正直者という仮定があればその仮定は無効
                        ((bit & (1<<V[i][j].first))>0 && V[i][j].second==0) ||
                        ((bit & (1<<V[i][j].first))==0 && V[i][j].second==1)
                    ){
                        flag = false;
                    }
                }
            }
        }
        if(flag){
            bitset<16> bits(bit);
            max = fmax(max,bits.count());
        }
    }
    cout << max << endl;
    return 0;
}

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

using namespace std;

string s , t;

int main()
{
	cin >> s >> t;
	sort(s.begin() , s.end());
	sort(t.begin() , t.end());
	reverse(t.begin() , t.end());
	if(s < t)
		cout << "Yes";
	else
	{
	//	if(t[t.size() - 1] == s[0] && t.size() > s.size())
		//	cout << "Yes";
		//else
			cout << "No";
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,ans=0;
	cin>>n;
	FORQ(i,0,n){
		int c=0,t=i;
		while(t!=0){
			t/=10;
			c++;
		}
		if(c%2)ans++;
	}
	cout<<ans<<endl;

	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++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector <int> v(n);
  rep(i, n) {
    int64_t a, tmp = 0;
    cin >> a;
    while (a%2 == 0) {
      tmp++;
      a /= 2;
    }
    v.at(i) = tmp;
  }
  int64_t ans = 0;
  rep(i, n) ans += v.at(i);
  cout << ans << endl;
}

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

int main()
{
	int n;
	vector<int> cars;
	while (cin >> n) {
		if (n==0)  {
			cout << cars.back() << endl;
			cars.pop_back();
		}
		else
			cars.push_back(n);
	}

	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==1) a=14;
  if(b==1) b=14;
  if(a==b) cout << "Draw" << endl;
  else if(a<b) cout << "Bob" << endl;
  else cout << "Alice" << endl;
}

Measured memory_bytes: 256