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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N,K;
    cin >> N >> K;
    int R,S,P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    ll ans = 0;
    string U;
    rep(i,N) {
        if (i<K) {
            if (T[i]=='r') ans+=P, U.push_back('p');
            else if (T[i]=='s') ans+=R, U.push_back('r');
            else ans+=S, U.push_back('s');
        }
        else {
            if (T[i]=='r') {
                if (U[i-K]=='p') U.push_back('w');
                else ans+=P, U.push_back('p');
            }
            else if (T[i]=='s') {
                if (U[i-K]=='r') U.push_back('w');
                else ans+=R, U.push_back('r');
            }
            else {
                if (U[i-K]=='s') U.push_back('w');
                else ans+=S, U.push_back('s');
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3776
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)//n
mi=10**15
c=0
for i in a:
  c+=(i-ave)**2
mi=min(mi,c)
ave+=1
c=0
for i in a:
  c+=(i-ave)**2
mi=min(mi,c)
ave-=2
c=0
for i in a:
  c+=(i-ave)**2
mi=min(mi,c)
print(mi)


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

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

    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    REP(i, H) {
        cin >> A[i];
    }

    vector<vector<int>> d(H);
    REP(i, H) {
        d[i].assign(W, 1000 * 1000 + 100);
    }

    using tri = pair<int, pii>;
    queue<tri> q;
    REP(i, H) REP(j, W) {
        if (A[i][j] == '#') {
            d[i][j] = 0;
            q.push(tri(0, pii(i, j)));
        }
    }

    int result = 0;
    while (!q.empty()) {
        int dis;
        pii p;
        tie(dis, p) = q.front();
        q.pop();
        int x, y;
        tie(x, y) = p;
        if (d[x][y] < dis) {
            continue;
        }
        REP(k, 4) {
            int nx = x + dx[k];
            int ny = y + dy[k];
            if (0 <= nx && nx < H && 0 <= ny && ny < W && A[nx][ny] == '.') {
                A[nx][ny] = '#';
                d[nx][ny] = dis + 1;
                amax(result, dis + 1);
                q.push(tri(dis + 1, pii(nx, ny)));
            }
        }
    }

    /*
    REP(i, H) {
        REP(j, W) {
            printf("%d ", d[i][j]);
        }
        printf("\n");
    }
    */

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 17424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll n, u, v;
vector<vector<ll>> to;
vector<bool> seen, haji;
vector<ll> distFromV;
ll ans = 0;

void dfs(ll cv, ll d) {
  distFromV[cv] = d;
  FOREACH(nv, to[cv]) {
    if (seen[nv]) continue;
    seen[nv] = true;
    dfs(nv, d + 1);
  }
}

void calcDist(ll cv, ll d) {
  if (to[cv].size() == 1) {
    ans = max(ans, distFromV[cv] - 1);
  } else {
    ans = max(ans, distFromV[cv]);
  }
  FOREACH(nv, to[cv]) {
    if (seen[nv]) continue;
    if (distFromV[nv] <= d + 1) continue;
    seen[nv] = true;
    calcDist(nv, d + 1);
  }
}

int main() {
  cin >> n >> u >> v;
  u--;
  v--;
  to = vector<vector<ll>>(n);
  seen = vector<bool>(n, false);
  REP(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  // uから行ける端点
  distFromV = vector<ll>(n, -1);
  seen[v] = true;
  dfs(v, 0);
  seen = vector<bool>(n, false);
  seen[u] = true;
  calcDist(u, 0);
  cout << ans << endl;

  // REP(i, n) { DUMP(distFromV[i]); }
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define fto(i,a,b) for(int i=a; i<=b;++i)
#define fdto(i,a,b) for(int i=a; i>=b;--i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define maxn 5009
#define gb(i,j) ((i>>j)&1)
#define name "a"
#define endl '\n'

using namespace std;
int s[maxn],c[maxn],n;
ll f[maxn][maxn][2],g[maxn][2];
vector<int> a[maxn];
void dfs(int u, int p){
    s[u]=1;
    if(c[u]<0)f[u][0][1]=c[u];
    else f[u][0][0]=c[u];
    for(int v:a[u])
    if(v!=p){
        dfs(v,u);
        fto(i,0,s[u]+s[v]-1)g[i][1]=g[i][0]=1e18;
        for(int i=0; i<=s[v]-1; ++i){
            fdto(j,s[u]-1,0){
                /// cut
                //if(v==2 && i==0) cout <<','<<j<<' '<< f[v][i][1] <<' '<< f[v][i][0]<<endl;
                if(f[v][i][1]<0 || f[v][i][0]<1e18){
                    g[i+j+1][1]=min(g[i+j+1][1],f[u][j][1]);
                    g[i+j+1][0]=min(g[i+j+1][0],f[u][j][0]);
                }
                //if(v==2 && i==0)cout << g[1][1]<<endl;
                /// not cut
                if(f[v][i][0]<1e18){
                    if(f[u][j][0]<1e18)g[i+j][0]=min(g[i+j][0],f[u][j][0]+f[v][i][0]);
                    if(f[u][j][1]<1e18)g[j+i][1]=min(g[i+j][1],f[u][j][1]+f[v][i][0]);
                }
                if(f[v][i][1]<1e18 && min(f[u][j][1],f[u][j][0])<1e18){
                    g[i+j][1]=min(g[i+j][1],f[v][i][1]+min(f[u][j][1],f[u][j][0]));
                }
            }
        }
        s[u]+=s[v];
        //if(u==1)fto(j,0,s[u]-1)cout << g[j][0]<<' '<< g[j][1]<<endl;
        fto(j,0,s[u]-1)
            fto(t,0,1)f[u][j][t]=g[j][t];
        //if(u==4) cout << f[u][1][1]<<endl;
    }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i=1; i<=n; ++i)cin >> c[i];
    fto(i,2,n){
        int x,y;
        cin >> x >> y;
        a[x].pb(y);
        a[y].pb(x);
    }
    fto(i,1,n)
        fto(j,0,n)
            fto(t,0,1)f[i][j][t]=1e18;
    dfs(1,0);
    int res=n-1;
    //fto(j,1,n){cout << j <<endl;
    //fto(i,0,n-1)cout << f[j][i][0] <<' '<< f[j][i][1]<<endl;
    //}
    fto(i,0,n-1)if(f[1][i][0]<1e18)res=min(res,i);
    fto(i,0,n-1)if(f[1][i][1]<0)res=min(res,i);
    cout << res;
    return 0;
}


Measured memory_bytes: 392448
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,tmp,xsum=0,sum=0;
    vector<int> vec(0);
    cin >> n;
    rep(i,n){
        cin >> tmp;
        vec.push_back(tmp);
        xsum+=tmp;
        sum+=tmp*tmp;
    }
    if(!xsum%n){
        cout << sum << endl;
        return 0;
    }
    if(2*(xsum%n)<n)tmp=xsum/n;
  	else tmp=xsum/n+1;
  	cout << (sum+tmp*(n*tmp-2*xsum)) << endl;
}


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

struct BIT {
  long long n;
  vector<long long> dat;

  void init(long long n_input) {
    n = n_input + 1;
    dat.resize(n + 1);
    for (int i = 0; i <= n; i++) dat[i] = 0;
  }

  long long sum(long long i) {
    long long s = 0;
    while (i >= 0) {
      s += dat[i];
      i = (i & (i + 1)) - 1;
    }
    return s;
  }

  void add(long long i, long long x) {
    while (i <= n) {
      dat[i] += x;
      i |= i + 1;
    }
  }
};

int main() {
  int i;
  long long N;
  cin >> N;
  vector<int> A(N), sortedA(N);
  for (i = 0; i < N; i++) {
    cin >> A[i];
    sortedA[i] = A[i];
  }
  sort(sortedA.begin(), sortedA.end());
  int ub = N;
  int lb = 0;
  BIT bit;

  long long border = ((N * (N + 1) / 2) + 1) / 2;
  while (ub - lb > 1) {
    int mid = (ub + lb) / 2;
    int midn = sortedA[mid];
    bit.init(2 * N + 1);
    int sum = 0;
    bit.add(sum + N, 1);
    long long result = 0;
    for (i = 0; i < N; i++) {
      sum += A[i] >= midn ? 1 : -1;
      result += bit.sum(sum + N);
      bit.add(sum + N, 1);
    }
    if (result >= border) {
      lb = mid;
    } else {
      ub = mid;
    }
  }
  cout << sortedA[lb] << endl;
  return 0;
}


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

int main()
{
	int i, N, a[101], b[101], c[101], d[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(a[i]), &(b[i]));
	for (i = 1; i <= N; i++) scanf("%d %d", &(c[i]), &(d[i]));
	
	int j, adj[101][101] = {};
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			if (a[i] < c[j] && b[i] < d[j]) adj[i][j] = 1;
		}
	}
	
	int m, u, v, w, M[201] = {}, par[201], q[201], head, tail;
	for (m = 0; m <= N; m++) {
		for (i = 1; i <= N * 2; i++) par[i] = 0;
		for (i = 1; i <= N; i++) {
			if (par[i] != 0 || M[i] != 0) continue;
			par[i] = i;
			q[0] = i;
			for (head = 0, tail = 1; head < tail; head++) {
				u = q[head];
				if (u <= N) {
					for (w = N + 1; w <= N * 2; w++) {
						if (adj[u][w-N] == 1) {
							if (M[w] == 0) {
								for (v = w, par[w] = u; par[v] != v; v = par[v]) {
									if (v > N) {
										M[v] = par[v];
										M[par[v]] = v;
									}
								}
								break;
							} else if (par[w] == 0) {
								par[w] = u;
								q[tail++] = w;
							}
						}
					}
					if (w <= N * 2) break;
				} else {
					w = M[u];
					if (par[w] == 0) {
						par[w] = u;
						q[tail++] = w;
					}
				}
			}
			if (head < tail) break;
		}
		if (i > N) break;
	}
	
	printf("%d\n", m);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
mod = 10**9+7
nums = 5*(10**5) # 制約に合わせよう

g1, g2, inverse = [1, 1] , [1, 1], [0, 1]
 
for num in range(2, nums + 1):
    g1.append((g1[-1] * num) % mod)
    inverse.append((-inverse[mod % num] * (mod//num)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
    
def nPr(n, r):
    return g1[n] * g2[n-r] % mod

def nCr(n, r):
    return g1[n] * g2[r] * g2[n-r] % mod

ans = 0
for r in range(n+1):
    tmp = nCr(n, r)*nPr(m, r)*(nPr(m-r, n-r)**2)%mod
    ans = (ans+(-1)**r*tmp)%mod
print(ans)

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N;
    cin >> N;

    set<ll > st;
    st.insert(-INF);
    
    for(ll i = 0; i < N; i++){
        ll A; cin >> A;
        auto it = st.lower_bound(A);
        it--;
        if(*it != -INF){
            if(*it + 1 == A){
                st.erase(it);
            }
        }
        st.insert(A);
    }

    //set列挙 一番連続しているところを探す
    ll tmp = 0;
    ll mx = -1;
    for (auto itr = st.begin(); itr != st.end(); itr++) {
        if(*itr != -INF){
            mx = max(mx, *itr-tmp);
            tmp = *itr;
        }
    }

    cout << N - mx << endl;

}

Measured memory_bytes: 9600
#%% data
n = int(input())
a = list(map(int, input().split()))

#%%
counts = {}
for v in a:
    counts[v] = counts.get(v, 0) + 1

#%%
l = len([x for x in counts.values() if not x & 1])
print(len(counts) - 1 if l & 1 else len(counts))


Measured memory_bytes: 17396
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);

		int w=scanner.nextInt();
		int h=scanner.nextInt();
		int n=scanner.nextInt();

		Map<Integer,Integer> data=new TreeMap<Integer,Integer>();


			data.put(1,0);
			data.put(2,w);
			data.put(3,0);
			data.put(4,h);


		for(int i=0;i<n;i++) {
			int bufx=scanner.nextInt();
			int bufy=scanner.nextInt();
			int bufa=scanner.nextInt();

			if(bufa==1) {
					if(bufx>data.get(1)) {
						data.put(1,bufx);
					}
			}else if(bufa==2) {
					if(bufx<data.get(2)) {
						data.put(2,bufx);
					}
			}else if(bufa==3) {
				if(bufy>data.get(3)) {
					data.put(3,bufy);
				}
			}else {
					if(bufy<data.get(4)) {
						data.put(4,bufy);
					}
			}

		}

		int retwidth=data.get(2)-data.get(1);
		int retheight=data.get(4)-data.get(3);

		int result=retwidth*retheight;

		if(retwidth>0 && retheight>0) {
			System.out.println(result);
		}else {
			System.out.println("0");
		}

		scanner.close();

	}

	public static int getsumofkakuketa(int n) {

		int result=0;

		while(true) {

			result+=n%10;

			if(n/10!=0) {
				n/=10;
			}else {
				return result;
			}
		}



	}

	public static boolean isMacthed(int a,int b,int sum) {

		if(sum>=a && sum<=b) {
			return true;
		}else {
			return false;
		}

	}



}







Measured memory_bytes: 21844
from statistics import median_high
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(a[i]-i-1)
b.sort()
d=median_high(b)
ans=0
for i in range(n):
    ans+=abs(b[i]-d)
print(ans)

Measured memory_bytes: 33844
# -*- coding: utf-8 -*-
n=int(input())  #数値入力 「N」だけの入力のとき
a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
f = 0
if len(a) != len(set(a)):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 26804
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	ll h,w;
	cin>>h>>w;
	ll ans;
	if(w==1 || h==1)ans=1;
	else if(w%2==1 && h%2==1){
		ans=(h*w)/2+1;
	}else{
		if(h%2==0)ans=(h/2)*w;
		else if(w%2==0)ans=(w/2)*h;
	}
	cout<<ans<<endl;
}
 

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

using namespace std;

long long keta(long long i)
{
    long long keta = 0;
    while (i)
    {
        keta++;
        i /= 10;
    }

    return keta;
}

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

    long long ans = numeric_limits<long long>::max();

    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            long long current_min = max(keta(i), keta(n / i));
            ans = min(current_min, ans);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define ll long long
using namespace std;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return x*f;
}
int a[20],q[20];
int tot;
ll ans;

signed main(){
    ll b=read();
    while (b){
        q[++tot]=b%10;
        b/=10;
    }
    for (int i(1);i<=tot;++i) a[i]=q[tot-i+1];//可能这一步还有更优处理。
    for (int l(1);l<=tot;++l)
        for (int i(1);i+l-1<=tot;++i){
            ll num=0;
            for (int j(i);j<=i+l-1;++j) num*=10,num+=a[j];
            //printf("%lld ",num);
            if (i==1||i+l-1==tot){//靠在边界上
                for (int i(1);i<=tot-l-1;++i) num*=2;
                ans+=num;
            }
            else {//没靠在边界上
                for (int i(1);i<=tot-l-2;++i) num*=2;
                ans+=num;
            }
        }
    printf("%lld",ans);
    return 0; 
}

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

works = []

for _ in range(N):
    a,b = map(int,input().split())

    works.append([a,b])

sorted_works = sorted(works,key=lambda x: x[1])


flg = 0
for j in range(N):
    if j==0:
        if sorted_works[j][0]>sorted_works[j][1]:
            flg+=1
    else:
        sorted_works[j][0] += sorted_works[j-1][0]

        if sorted_works[j][0]>sorted_works[j][1]:
            flg+=1


if flg==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 39584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string s;
  cin >> s;
  REP(i, 0, 19) {
    if (s[i] == ',')s[i] = ' ';
  }
  cout << s << endl;
}


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

int main() {

  int t,p,r;

  while(1) {
  cin >> t >> p >> r;
  if(t ==0 && p == 0 && r ==0) break;
  //cout << t << p << r<<endl;
  
  int tid , pid,time;
  string mes,ans[2];
  ans[0] = "WRONG";
  ans[1] = "CORRECT";
  int tc[51]={0};
  int tw[51]={0};
  int tt[51]={0};
  int pw[51][51];
  int tj[51] = {0};
  for(int i=0;i<51;i++)
    for(int j=0;j<51;j++)
      pw[i][j] = 0;
  for(int i=1;i<=t;i++)
    tj[i] = i;
     
  for(int i=0;i<r;i++) {
    cin >> tid >> pid >> time >> mes;
    // cout << tid <<" " << pid << " " << time << " " << mes << endl; 
    if(mes == ans[0]) {
      pw[tid][pid]++;
    }
    else if(mes == ans[1]){
      tc[tid]++;
      tw[tid]++;
      tt[tid] += time;
      tt[tid] += pw[tid][pid] * 1200;     
    }
  }
  int a = t;
  int t;
  for(int i=1;i<=a;i++) {
    for(int j=i;j<=a;j++) {

      if(tc[i] < tc[j]) {
	t = tc[i];
	tc[i] = tc[j];
	tc[j] = t;

	t = tw[i];
	tw[i] = tw[j];
	tw[j] = t;

	t = tt[i];
	tt[i] = tt[j];
	tt[j] =t;

	t = tj[i];
	tj[i] = tj[j];
	tj[j] =t;
      }
      else if(tc[i] == tc[j]) {
	if(tt[i] > tt[j]) {
	  t = tc[i];
	  tc[i] = tc[j];
	  tc[j] = t;
	
	  t = tw[i];
	  tw[i] = tw[j];
	  tw[j] = t;
	  
	  t = tt[i];
	  tt[i] = tt[j];
	  tt[j] =t;
	  
	  t = tj[i];
	  tj[i] = tj[j];
	  tj[j] = t;
	}
	else if(tt[i] == tt[j]) {
	  if(tw[i] > tw[j]) {
	    t = tw[i];
	    tw[i] = tw[j];
	    tw[j] = t;
	    
	    t = tj[i];
	    tj[i] = tj[j];
	    tj[j] =t;
	  }
	  else if(tw[i] == tw[j] && tj[i] > tj[j]) {
	    t = tj[i];
	    tj[i] = tj[j];
	    tj[j] = t;
	  }
	}
      }
    } 
  }    
  
  for(int i=1;i<=a;i++) 
    cout <<tj[i]<<" " << tc[i] <<" "  << tt[i]<<endl;
  
  }

  return 0;

}

Measured memory_bytes: 1216
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
  int num_of_desks;
  int num_of_chairs;
  while(~scanf("%d %d",&num_of_desks,&num_of_chairs)){
    printf("%d\n",num_of_desks * num_of_chairs);
  }
}

Measured memory_bytes: 1188
n , k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
path = [0 for _ in range(k+1)]
# print(path)
for i in range(k+1):
    if path[i]==0:
        for v in a:
            if i+v<=k:
                path[i+v]=1
            else:
                break
print('First' if path[k]==1 else 'Second')



Measured memory_bytes: 44912
import sys
from heapq import heappush, heappushpop

t = int(sys.stdin.buffer.readline())
buf = []
for _ in range(t):
    n = int(sys.stdin.buffer.readline())
    lll = []
    rrr = []
    ans = 0
    for i in range(n):
        k, l, r = map(int, sys.stdin.buffer.readline().split())
        if l >= r:
            lll.append((k, l - r))
            ans += l
        else:
            rrr.append((n - k, r - l))
            ans += r
    lll.sort()
    rrr.sort()
    q = []
    for k, rl in lll:
        if len(q) < k:
            heappush(q, rl)
        else:
            nrl = heappushpop(q, rl)
            ans -= nrl
    q = []
    for k, lr in rrr:
        if len(q) < k:
            heappush(q, lr)
        else:
            nlr = heappushpop(q, lr)
            ans -= nlr

    buf.append(ans)

print('\n'.join(map(str, buf)))


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

struct BipartiteMatching{
    int n,time;
    vector<vector<int>> G;
    vector<int> match,used,dead;
    BipartiteMatching(int n):n(n),time(0),G(n),
        match(n,-1),used(n,-1),dead(n,0){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    int dfs(int v){
        used[v]=time;
        for (int u:G[v]){
            if (dead[u]) continue;
            int w=match[u];
            if (w<0||(used[w]<time&&dfs(w))){
                match[v]=u;
                match[u]=v;
                return 1;
            }
        }
        return 0;
    }
    int build(){
        int res=0;
        for (int v=0;v<n;++v){
            if (dead[v]) continue;
            if (match[v]<0){
                ++time;
                res+=dfs(v);
            }
        }
        return res;
    }
    int disable(int v){
        int u=match[v];
        if (u>=0) match[u]=-1;
        match[v]=-1; dead[v]=1;
        ++time;
        return u>=0?dfs(u)-1:0;
    }
    int enable(int v){
        dead[v]=0;
        ++time;
        return dfs(v);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<string> S(N);
    for (int i=0;i<N;++i) cin >> S[i];

    BipartiteMatching BM(N*M);
    auto id=[&](int x,int y){return x*M+y;};
    for (int i=0;i<N;++i){
        for (int j=0;j<M;++j){
            if (S[i][j]!='.') continue;
            for (int k=0;k<2;++k){
                int nx=i+k,ny=j+1-k;
                if (N<=nx||M<=ny) continue;
                if (S[nx][ny]!='.') continue;
                BM.add_edge(id(i,j),id(nx,ny));
            }
        }
    }

    cout << BM.build() << '\n';
    vector<vector<char>> ans(N,vector<char>(M,'.'));
    for (int i=0;i<N;++i){
        for (int j=0;j<M;++j){
            if (S[i][j]!='.'){ans[i][j]='#'; continue;}
            if (ans[i][j]!='.') continue;
            int match=BM.match[id(i,j)],x=match/M,y=match%M;
            if (match<0) continue;
            if (y==j) ans[i][j]='v',ans[x][y]='^';
            else ans[i][j]='>',ans[x][y]='<';
        }
    }

    for (int i=0;i<N;++i){
        for (int j=0;j<M;++j) cout << ans[i][j];
        cout << '\n';
    }
}

Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
int n;
vector<P>vec;
signed main(){
    cin>>n;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        P p=make_pair(a,b);
        vec.push_back(p);
    }
    sort(vec.begin(),vec.end());
    int ans=vec[n-1].first+vec[n-1].second;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	if (n >= 3200)
		cout << s << endl;
		else
		{
			cout << "red" << endl;
		}
		
}

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

v = [0] * N
w = [0] * N
for i in range(N):
    w[i],v[i] = map(int,input().split())

dp = [[0] * (W+1) for _ in range(N)]

for i in range(N):
    for j in range(1, W+1):
        if w[i] > j:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],v[i]+dp[i-1][j-w[i]])

print(max(dp[N-1]))

Measured memory_bytes: 120300
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main(void){
    int mv, N, A[25], tot=0, C[25];
    cin >>N;
    rep(i, N) cin >> A[i];
    rep(i, N){
        cin >> mv;
        //cout <<"<" << mv << endl;
        tot += mv;
    }
    rep(i, N-1) cin >> C[i];
    rep(i, N-1){
        if(A[i+1] == (A[i] +1)){
           // cout << ":" << A[i] << endl;
            tot+= C[A[i]-1];
        }
    }
    cout << tot<< endl;
    return 0;
}


Measured memory_bytes: 256
import collections

n=int(input())
v = input().split()

v1 = v[0::2]
v2 = v[1::2]

c1 = collections.Counter(v1)
c2 = collections.Counter(v2)
if(c1.most_common()[0][0] != c2.most_common()[0][0]):
	print(n - c1.most_common()[0][1] - c2.most_common()[0][1])
else:
	if(c1.most_common()[0][1] == n/2):
		count1 = c2.most_common()[0][1]
	else:
		count1 = c1.most_common()[1][1] + c2.most_common()[0][1]

	if(c2.most_common()[0][1] == n/2):
		count2 = c1.most_common()[0][1]
	else:
		count2 = c1.most_common()[0][1] + c2.most_common()[1][1]

	if(count1 < count2):
		print(n - count2)
	else:
		print(n - count1)


Measured memory_bytes: 22764
m,d = map(int,input().split())
k = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        x = j // 10
        if x < 2:
            continue
        y = j % 10
        if y < 2:
            continue
        if x * y == i:
            k += 1

print(k)

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

int main()
{
  int r, D, x;

  cin >> r >> D >> x;

  int ans = 0;

  for (int i = 0; i < 10; i++)
  {
    cout << (r * x - D) << endl;
    x = r * x - D;
  }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    H = list(map(int, input().split()))

    res = 0
    for i in range(n):
        if H[i] >= k:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 11916
import math


def main():
    num = int(input())
    k = int(input())
    data = list(map(int, input().split()))

    ans = 0
    for i in range(num):
        ans += min(abs(k - data[i]), abs(data[i])) * 2
    print(ans)





if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
//#include <atcoder/fenwicktree>

using namespace std;
//using namespace atcoder;

int N, K, A[300005];

const int M = 1 << 19;
int ST[M*2];

void CHANGE(int k, int v) {

	ST[M + k] = v;

	int p = (M + k) / 2;

	while (p >= 1) {
		ST[p] = max(ST[p * 2], ST[p * 2 + 1]);
		p /= 2;
	}
}

int Q(int a, int b, int l = 0, int r = M - 1, int k = 1) {

	if (b < l || r < a) { return 0; }

	if (a <= l && r <= b) { return ST[k]; }

	int tmp1 = Q(a, b, l, (l + r) / 2, k * 2);
	int tmp2 = Q(a, b, (l + r) / 2 + 1, r, k * 2 + 1);

	if (tmp1 >= tmp2) { return tmp1; }

	return tmp2;
}


int main(void) {
	cin >> N >> K;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}


	for (int i = 1; i <= N; i++) {
		int l = A[i] - K; int r = A[i] + K;
		int ret = Q(l, r);
		CHANGE(A[i], ret + 1);
	}

	cout << Q(1, M) << endl;

	return 0;
}

Measured memory_bytes: 7180
import copy
N = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a % b)

F = copy.copy(A)
B = copy.copy(A)

for i in range(1, N):
  F[i] = gcd(F[i], F[i-1])
for i in range(N - 2, -1, -1):
  B[i] = gcd(B[i+1], B[i])

mx = max(F[N-2], B[1])
for i in range(1, N - 1):
  mx = max(mx, gcd(F[i-1], B[i+1]))
print(mx)


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' or c =='i' or c == 'u' or c == 'e' or c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }

  // ここにプログラムを追記
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int a,b,c,ans = 0;
  cin >> a >> b >> c;
  ans = min(b/a,c);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from operator import itemgetter, attrgetter
N = int(input())
l_2d = [list(map(int, input().split())) for i in range(N)]
A, B = l_2d_t = [list(x) for x in zip(*l_2d)]

z = [[a, b] for a,b in zip(A,B)]
z.sort(key=itemgetter(1))
time = 0
possible = True
for i in range(N):
  time += z[i][0]
  if time > z[i][1]:
    possible = False

if possible:
  print('Yes')
else:
  print('No')

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

using namespace std;

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

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

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

int main(){
    int a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int sqrt(int num)
{
	int x = 1;
	while (x < num) {
		if (x * x == num) {
			return true;
		}
		x++;
	}
	return false;
}

int main()
{
	int a, b;
	int digit = 1;
	int num;
	cin >> a >> b;

	while (b / digit != 0) {
		digit *= 10;
	}
	num = b + digit * a;
	cout << ((sqrt(num) == true)? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
// Shuffle and Swap
// * frank_c1
// * 2017 / 12 / 27

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

LL pow_mod(LL b, LL p, LL k) {
	LL ret = 1;
	for (; p; p >>= 1) {
		if (p & 1) ret = ret * b % k;
		b = b * b % k;
	} return ret;
}

const int maxn = 10005;
const int mo = 998244353;
char a[maxn], b[maxn];
LL fac[maxn], ivf[maxn];
LL f[2][maxn];

inline LL C(int n, int m) {
	return fac[n] * ivf[m] % mo * ivf[n - m] % mo;
}

int main() {
	scanf("%s%s", a + 1, b + 1);
	int n = strlen(a + 1), p = 0, q = 0; 
	for (int i = 1; i <= n; ++i) {
		p += (a[i] == '1' && a[i] == b[i]); q += (a[i] != b[i]);
	} q >>= 1;
	fac[0] = ivf[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % mo;
	ivf[n] = pow_mod(fac[n], mo - 2, mo);
	for (int i = n - 1; i >= 1; --i) ivf[i] = ivf[i + 1] * (i + 1) % mo;
	int now = 0, lst = 0; LL ret = 0;
	for (int i = 0; i <= p; ++i) {
		now = lst ^ 1;
		memset(f[now], 0, sizeof(f[now]));
		if (!i) f[now][0] = 1;
		for (int j = 0; j <= q; ++j) {
			if (i) f[now][j] += f[lst][j] * i * j;
			if (j) f[now][j] += f[now][j - 1] * j * j;
			f[now][j] %= mo;
		}
		(ret += f[now][q] * C(p, i) % mo * C(p + q, i + q) % mo * fac[p - i] % mo * fac[p - i]) %= mo;
		lst = now;
	}
	return printf("%lld\n", ret), 0;
}

Measured memory_bytes: 640
def f(x,i,n):
    sadness = 0
    for j in range(n):
        sadness += abs(x[j]-i)
    return(sadness)
N = int(input())
H = [int(i) for i in input().split()]
for i in range(N):
    H[i] -= i+1
H = sorted(H)
k = N // 2
if N == 1 :
    print(0)
else:
    print(f(H,H[k],N))


Measured memory_bytes: 26184
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(0,n-2):
  if a[i]<a[i+1] and a[i+1]<a[i+2]:
    c+=1
  elif a[i]>a[i+1] and a[i+1]>a[i+2]:
    c+=1
print(c)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    V=list(map(int,input().split()))
    V.sort(reverse=1)

    ans=V.pop()
    while(V):
        v=V.pop()
        ans=(ans+v)/2

    print(ans)
resolve()

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	b=b+b;
	if(b.find(a)!=-1)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	int N;
	int[] h;
	public static void main(String[] args) {
        (new Main()).run();
    }
    
    void run(){
        input();
        int[] dp = new int[N+1];
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = Math.abs(h[1] - h[2]);
        
        for(int i=3; i<=N; i++){
            dp[i] = Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]), dp[i-2]+Math.abs(h[i]-h[i-2]));
        }
        System.out.println(dp[N]);
    }
	void input(){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        h = new int[N+1];
        for(int i=1; i<=N; i++){
            h[i] = sc.nextInt();
        }
	}
}

Measured memory_bytes: 50296
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> p(n);
	for (auto &t : p) cin >> t;
	int c = 0;
	for (int i = 1; i + 1 < n; i++) {
		c += (p[i] != min({p[i - 1], p[i], p[i + 1]}) && p[i] != max({p[i - 1], p[i], p[i + 1]}));
	}
	cout << c << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
MOD = 10**9+7
n = int(input())
A = list(map(int, input().split()))


def sieve(n):
    n += 1
    res = [i for i in range(n)]
    for i in range(2, int(n**.5)+1):
        if res[i] < i:
            continue
        for j in range(i**2, n, i):
            if res[j] == j:
                res[j] = i
    return res


U = max(A)+1
min_factor = sieve(U)


def prime_factor(n):
    res = defaultdict(lambda: 0)
    while 1 < n:
        res[min_factor[n]] += 1
        n //= min_factor[n]
    return res


pf = defaultdict(lambda: 0)

for a in A:
    for p, q in prime_factor(a).items():
        if pf[p] < q:
            pf[p] = q

x = 1
for p, q in pf.items():
    x *= pow(p, q, MOD)
x %= MOD

print(sum(x*pow(a, MOD-2, MOD) for a in A) % MOD)

Measured memory_bytes: 44148
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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

int r, c, d;
char arr[1005][1005], block[2][5][5];


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //http://codeforces.com/blog/entry/53502?#comment-387076

    cin>>r>>c>>d;
    string chars = "RGYB";

    for(int i=0;i<r;i++){
    	for(int j=0;j<c;j++){
    		int x = (i+j)%(2*d) / d;
    		int y = (i-j+500*d)%(2*d) / d;
    		cout<<chars[x*2+y];
    	}
    	cout<<endl;
    }

    return 0;
}







 




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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, a;
  cin >> h >> a;
  int ans = 0;
  while (h > 0) {
    h -= a;
    ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.size()<4){
    cout << "No" << endl;
    exit(0);
  }
  if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())

count = [0]*(n+1)

for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            ans = (x+y)**2+(y+z)**2+(z+x)**2
            if ans%2 == 0 and ans//2 <= n:
                count[ans//2] += 1
for i in count[1:]:
    print(i)

Measured memory_bytes: 69444
#include<iostream>
using namespace std;
int n,m,k;
int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(j*i+(n-j)*(m-i)==k)
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  long long n;
  long long a=1;
  cin >> n;
  for(long long i=1; i*i<=n; i++){
  	if(n%i==0){
      a= max(a,i);
    }
  }

  cout << a+n/a-2 << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
#define F first
#define S second
typedef long long ll;
using namespace std;

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


	p(b-a==c-b?"YES":"NO");
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(' ').map(String::toLong)
    val div = n / (a + b)
    val left = n - div * (a + b)
    if (left >= a) {
        println(div * a + a)
    } else {
        println(div * a + left)
    }
}


Measured memory_bytes: 38392
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=700,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d);



	cout<<endl;
} 


Measured memory_bytes: 256
a, b, c = [int(i) for i in input().split()]
# print(a, b, c)

gedoku = a + b

# cを余らせてしまうパターン（解毒が足りない）
if c > gedoku + 1:
    ans = (gedoku + 1) + b
# cを全て使うパターン（解毒が余る）
else:
    # # 必要な解毒
    # need_gedoku = c - 1
    #
    # # bが十分ある
    # if b >= c - 1:
    #     ans = c + (c - 1)
    # else:
    ans = b + c

print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char tmp = S.charAt(0);
        long count = 0;
        for (char c : S.toCharArray()) {
            if (c != tmp) {
                tmp = c;
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 39516
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;

int main(void){
    int n, m;
    cin >> n >> m;
    vi AC(n+1, 1), WA(n+1);
    int ac = 0, wa = 0;
    for(int i=0; i<m; i++){
        int p;
        string s;
        cin >> p >> s;
        if(AC[p] == 0) continue;
        if(s == "AC"){
            wa += WA[p]; ac++;
            AC[p] = 0;
        }
        if(s == "WA") WA[p]++;
    }
    cout << ac << ' ' << wa << '\n';
    return 0;
}

Measured memory_bytes: 4040
#include<iostream>
#define M std::cin>>
int s[200000],n,c,l,z,x,i,h=1e9+7;main(){M n>>z;c=l=s[z]=1;for(i=1;i<n;i++){M x;if(x!=z)c=(c+s[x])%h,s[x]=(s[x]+l)%h;l=c,z=x;}std::cout<<c;}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



long long solve(long long  a){
    if(a<0) a=0;
    if(a%2 == 1){
        if((a+1)%4 == 0) return 0;
        else return 1;
    }
    else{
        if(a%4 == 0) return a;
        else return (1^a);
    }
}

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

    
    
    cout << ((solve(b))^(solve(a-1))) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		char c[] = n.toCharArray();
		sc.close();

		for (int i = 0; i < 3; i++) {
			if (c[i] == '1') {
				c[i] = '9';
			} else if (c[i] == '9') {
				c[i] = '1';
			}
		}
		for (int i = 0; i < 3; i++) {
			System.out.print(c[i]);
		}
	}
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array=new int[n];
		int sum=0;

		for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);
		for(int i=0;i<n-1;i++) {
			sum+=array[i];
		}

		System.out.println(sum+array[n-1]/2);
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int a,b;
  cin>>a>>b;
  if(a<=b){
    cout<<a<<endl;
  }else{
    cout<<a-1<<endl;
  }


}

Measured memory_bytes: 256
program ABC165A
    implicit none
    integer(8)::K,A,B,i,flg=0
    read*,K,A,B

    do i=A,B
        if(mod(i,K)==0)then
            flg=1
            exit
        end if
    end do

    if(flg==0)print'(A)',"NG"
    if(flg==1)print'(A)',"OK"
end program ABC165A

Measured memory_bytes: 2860
#include<bits/stdc++.h>
#include<cmath>
#include<cstring>
#include<climits>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define asc(a,n) sort(a,a+n);
#define dsc(a,n) sort(a,a+n,comp);
#define fo(i,x,y) for(int i=x;i<y;i++)
#define inarr(x) int n; cin>>n; int x[n]; fo(i,0,n){cin>>x[i];}
#define test int t; cin>>t; while(t--)
using namespace std;

int basic(){freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);return 0;}
bool comp(int a,int b){return a>b;}



int32_t main()
{ //basic(); 
  fast; 
  int k,a,b; cin>>k>>a>>b;
  if(a+k-(a%k)<=b or a%k==0){cout<<"OK";}
  else{cout<<"NG";}
  	
   
return 0;
}







Measured memory_bytes: 3652
n = int(input())
s = "abcdefghij"

class Node:
    def __init__(self, string, index):
        self.children = []
        self.string = string
        self.index = index

    def get_children(self):
        parent = self.string
        for i, c in enumerate(s[:self.index+1]):
            self.children.append(Node(parent+c, max(self.index, i+1)))
        return self.children

root = Node("a", 1)
children = [root]
for _ in range(n-1):
    parents, children = children, []
    for parent in parents:
        children.extend(parent.get_children())
for child in children:
    print(child.string)

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

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

    int n, l;
    cin >> n >> l;

    int full = 0;
    for(int i = l; i < n+l; ++i) full += i;

    int res;
    int min_d = 1001001001;
    for(int i = l; i < n+l; ++i){
        int sub = full - i;
        if(abs(full - sub) < min_d){
            res = sub;
            min_d = abs(full - sub);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc162
{
    class Program
    {
        static void Main(string[] args)
        {
            var xyz = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            int temp = xyz[0];
            xyz[0] = xyz[1];
            xyz[1] = temp;
            int temp2 = xyz[2];
            xyz[2] = xyz[0];
            xyz[0] = temp2;
            foreach (var item in xyz)
            {
                Console.Write(item);
                Console.Write(" ");
            }
        }
    }
}


Measured memory_bytes: 13396
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>    
#include <cstring>
#include <array>
#include <cctype>
#include <string.h>
#include <vector>
#include <limits.h>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cassert>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <bitset>
using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int d,n;

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

	cin >> d >> n;

	int cc=1;

	FOR(i,0,d)	cc*=100;

	if(n<=99)	cout << cc*n << endl;
	else	cout << cc*101 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n" 
int32_t main() 
{ 
    int n;
    cin>>n;
    int a[n];
    f(i,0,n)
    cin>>a[i];
    sort(a,a+n);
    if(n==2)
    {
        cout<<a[1]-a[0]<<endl;
        cout<<a[1]<<" "<<a[0];
        return 0;
    }
    int fg=0,gg=0;
    f(i,0,n)
    {
        if(a[i]>=0)
        {
            fg=1;
        }
        if(a[i]<0)
            gg=1;
    }
    if(gg==0||fg==0)
    {
        if(gg==0)
        {
            int sm=a[0]-a[1],tt;
            tt=sm;
            sm=abs(sm);
            f(i,2,n)
            sm+=abs(a[i]);
            cout<<sm<<endl;
            cout<<a[0]<<" "<<a[1]<<endl;
            f(i,2,n-1)
            {
                cout<<tt<<" "<<a[i]<<endl;
                tt=tt-(a[i]);
            } 
            cout<<a[n-1]<<" "<<tt<<endl;
        }
        else
        {
            int sm=a[n-1]-a[n-2],tt;
            tt=sm;
            sm=abs(sm);
            for(int i=n-3;i>=0;i--)
            sm+=abs(a[i]);
            cout<<sm<<endl;
            cout<<a[n-1]<<" "<<a[n-2]<<endl;
            for(int i=n-3;i>=0;i--)
            {
                cout<<tt<<" "<<a[i]<<endl;
                tt=tt-(a[i]);
            } 
        }
    }
    else
    {
        int sm=0;
        f(i,0,n)
        {
            sm+=abs(a[i]);
        }
        cout<<sm<<endl;
        int ng=a[0],ps=a[n-1];
        f(i,1,n-1)
        {
            if(a[i]<0)
            {
                cout<<ps<<" "<<a[i]<<endl;
                ps=ps-a[i];
            }
            else
            {
               cout<<ng<<" "<<a[i]<<endl;
                ng=ng-a[i]; 
            }
        }
        cout<<ps<<" "<<ng<<endl;
    }
}


Measured memory_bytes: 2688