akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef __int128 _int ;
const int maxn=2e5+6;
const int mod=1e9+7;
const double pi=acos(-1.0);
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}        
void write(int x){        
    if(x < 0) {        
        putchar('-');        
        x = -x;        
    }        
    if(x > 9)        
        write(x/10);        
    putchar(x % 10 + '0');        
    return;        
}   
signed main(){
	string s;
	cin>>s;
	if(s=="ABC")  cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
} 

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull; 
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string ans;

void solve(string s){
  if(s.find("mmewe")!=-1){
    s.replace(s.find("mmewe"),5,"me");
    solve(s);
  }else if(s.find("emeww")!=-1){
    s.replace(s.find("emeww"),5,"ew");
    solve(s);
  }else{
    if(s==""||s=="mew")ans="Cat";
    else ans="Rabbit";
  }
}

int main(){
  string s;
  cin>>s;
  solve(s);
  cout<<ans<<endl;
  return 0;
  
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,T,c[100000],t[100000],j,i,tle=1;
    scanf("%d %d",&n,&T);
    for(i=0;i<n;i++)
	{
		 scanf("%d %d",&c[i],&j);
		 t[c[i]]=j;
	}
    sort(c, c+n);
    for(i=0;i<n;i++)
    {
        if(t[c[i]]<=T)
        {
            printf("%d\n",c[i]);
			tle=0;
            break;
        }
    }
	if(tle) printf("TLE\n");
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,m,t,p;
    while(cin >> n >> m >> t >> p,n){
        vector<vector<int>> masu(2000,vector<int>(2000));
        pii ll = {1000,1000};
        pii ur = {1000+m-1,1000+n-1};
        for(int i = ll.first; i <= ur.first;i++){
            for(int j = ll.second; j <= ur.second;j++){
                masu[i][j] = 1;
            }
        }
        
        auto show = [&]{
//            cout << endl;
//            for(int y = 1000; y <= 1010;y++){
//                for(int x = 1000;x<=1010;x++){
//                    cout << masu[y][x] << " ";
//                }
//                cout << endl;
//            }
//            cout << "===" << endl;
        };
        for(int _ = 0; _ < t; _++){
            show();
            int d,c; cin >> d >> c;
            if(d == 1){
                for(int i = ll.first; i <= ur.first ;i++){
                    for(int j = ll.second; j < ll.second+c ;j++){
                        masu[i][(c-(j-ll.second)-1) + ll.second+c] += masu[i][j];
                    }
                }
                ur.second = max(ur.second,ll.second+2*c-1);
                ll.second += c;
            }else{
                for(int i = ll.first; i < ll.first+c ;i++){
                    for(int j = ll.second; j <= ur.second ;j++){
                        masu[c-(i-ll.first)-1+ll.first+c][j] += masu[i][j];
                    }
                }
                ur.first= max(ur.first,ll.first+2*c-1);
                ll.first += c;
            }
        }
        show();
        
        for(int _ = 0; _ < p; _++){
            int x,y; cin >> x >> y;
            cout << masu[ll.first+y][ll.second+x] << endl;
        }
    }
    return 0;
}



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

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

    vector<int> l(n);
    int sum = 0;
    for(int i=0; i<n; i++){
        cin >> l[i];
        sum += l[i];
    }
    sort(l.begin(),l.end());

    if(sum - l[n-1] > l[n-1]) cout << "Yes" << endl;
    if(sum - l[n-1] <= l[n-1]) cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#define F first
#define S second
using namespace std;
int n;
long long m;
int d;
int p;
pair<int,int> a[11111];

int main(void){
  while(cin >> n >> m){
    if(!n) break;
    for(int i = 0; i < n; i++){
      cin >> d >> p;
      a[i] = make_pair(p,d);
    }
    sort(a,a+n,greater<pair<int,int> >());
    long long res = 0;
    for(int i = 0; i < n; i++){
      if(!m){
	res += a[i].F * a[i].S;
      }else if(a[i].S < m){
	m -= a[i].S;
      }else{
	res += a[i].F * (a[i].S-m);
	m = 0;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 10000;
modint fact[max_n], factinv[max_n];
ll pas[3002][3002];
void init_f() {
	rep(i, 3002)rep(j, 3002) {
		if (i == 0 || j == 0)pas[i][j] = 1;
		else pas[i][j] = pas[i - 1][j] + pas[i][j - 1];
	}
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
ll comb(int a, int b) {
	return pas[a - b][b];
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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

void solve() {
	string a, s, c; cin >> a >> s >> c;
	string ans;
	ans.push_back('A');
	ans.push_back(s[0]);
	ans.push_back('C');
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 384
#include <cstdio>

int main() {
	int te[5];
	while (scanf("%d", &te[0])!=EOF) {
		if (te[0] == 0) break;
		for (int i=1; i<5; i++) scanf("%d", &te[i]);
		int num[3];
		for (int i=0; i<3; i++) num[i] = 0;
		for (int i=0; i<5; i++) num[te[i]-1]++;
		if (num[0]!=0&&num[1]!=0&&num[2]!=0) {
			for (int i=0; i<5; i++) printf("3\n");
			continue;
		} else if ((num[0]==0&&num[1]==0)||
			(num[1]==0&&num[2]==0)||(num[0]==0&&num[2]==0)) {
			for (int i=0; i<5; i++) printf("3\n");
			continue;
		}
		if (num[0] == 0) {
			for (int i=0; i<5; i++) {
				if (te[i] == 2) {
					printf("1\n");
				} else if (te[i] == 3) {
					printf("2\n");
				}
			}
		} else if (num[1] == 0) {
			for (int i=0; i<5; i++) {
				if (te[i] == 3) {
					printf("1\n");
				} else if (te[i] == 1) {
					printf("2\n");
				}
			}
		} else if (num[2] == 0) {
			for (int i=0; i<5; i++) {
				if (te[i] == 1) {
					printf("1\n");
				} else if (te[i] == 2) {
					printf("2\n");
				}
			}
		}
	}
}

Measured memory_bytes: 0
import java.io.InputStream
import java.io.BufferedReader

fun main(args: Array<String>) {
  val inputStream = System.`in`
  val allText = inputStream.bufferedReader()
                           .use(BufferedReader::readText)
  allText.trim().split('\n')
         .map { s->
            s.split(' ').map{ Integer.parseInt(it) }.sum().toString().length
         }
  .forEach{ println(it) }
}


Measured memory_bytes: 32236
#include<stdio.h>
#include<string.h>
int MAX(int a,int b){return a<b?b:a;}
//int P[1010],L[1010],R[1010],H[1010],C=1;
int P[4][1010],C=1,H[1010];
//int hyouka(int i,int x){return N[i]<=x?N[i]<x?-1:0:1;}
char N[1010][110];
int hyouka(int i,char *s){return strcmp(N[i],s);}
int h(int a){return H[P[2][a]]-H[P[1][a]];}
void rot(int a,int t){
  int b=P[t][a],r=P[0][a];
  P[t][r]==a?(P[1][r]=b):(P[2][r]=b);
  if(P[3-t][b])P[0][P[3-t][b]]=a;
  P[t][a]=P[3-t][b];
  P[3-t][b]=P[0][b];
  P[0][b]=P[0][a];
  P[0][a]=b;
  H[a]=MAX(H[P[1][a]],H[P[2][a]])+1;
  H[b]=MAX(H[P[1][b]],H[P[2][b]])+1;
}
int mfind(char *x){
  int i,j,r,n,t;
  if(C==1){
    P[1][0]=C;
    //N[C]=x;
    strcpy(N[C],x);
    P[0][C++]=0;
    return 1;
  }
  for(i=1;r=hyouka(i,x);i=n){
    if(r<0)t=1;
    else   t=2;
    if(P[t][i]==0){
      P[t][i]=C;
      P[0][C]=i;
      H[i]=MAX(1,H[i]);
      //N[C]=x;
      strcpy(N[C],x);
      C++;
    }
    n=P[t][i];
  }//printf("%d\n",i);
  j=P[0][i];
  while(1){
    if(h(j)<-1){
      if(h(P[1][j])>0)rot(P[1][j],1);
      rot(j,2);
      break;
    }
    if(h(j)>1){
      if(h(P[2][j])<0)rot(P[2][j],2);
      rot(j,1);
      break;
    }
    if(h(j)==0)break;
    j=P[0][j];
    if(j==0)break;
  }//printf("%d\n",i);
  return i;
}      
int main(){
  int i,l,max=0,mj=1,r,a[1010]={};
  char *c,*mi,s[1020];
  fgets(s,1010,stdin);
  mi=strtok(s," \n");
  a[mj=mfind(mi)]++;
  max=strlen(mi);
  // printf("%s\n",mi);
  while(c=strtok(NULL," \n")){
    //printf("%s\n",c);
    a[r=mfind(c)]++;
    //printf("%d\n",r);
    l=strlen(c);//printf("%s %d\n",mi,l);
    if(max<l){
      max=l;
      strcpy(mi,c);
    }//printf("a\n");
    if(a[r]>a[mj])mj=r;//printf("a\n");
  }
  //printf("%s %d\n",mi,mj);
  printf("%s %s\n",N[mj],mi);
  return 0;
}

Measured memory_bytes: 564
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 1000483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int a[M],b[M],c[M][N],now[M] = {};
    int dp[5000];
    REP(i,5000) dp[i] = INF;
    dp[0] = 0;
    REP(i,M){
        cin >> a[i] >> b[i];
        REP(j,b[i]){
            cin >> c[i][j];
            now[i] |= (1 << (c[i][j] - 1));
        }
        dp[now[i]] = min(dp[now[i]],a[i]);
    }
    REP(i,(1 << N)-1){
        REP(j,(1 << N) - 1){
            dp[i|j] = min(dp[i|j],dp[i] + dp[j]);
        }
    }
    if(dp[(1 << N)-1] != INF) cout << dp[(1 << N)-1] << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 384
import math

n = int(input())

for _ in range(n):
    xa,ya,ra,xb,yb,rb = map(float, input().split())
    len=math.sqrt((xa-xb)**2+(ya-yb)**2)

    if len + rb < ra:
        print("2")
    elif len + ra < rb:
        print("-2")
    elif len <= ra + rb:
        print("1")
    else:
        print("0")

Measured memory_bytes: 6836
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;
    vint s(m), c(m);
    rep(i, m) cin >> s[i] >> c[i];

    int ans = 1000;
    rep(i, 1000) {
        bool check = true;
        int digit = to_string(i).length();
        if (digit != n) continue;
        rep(j, m) {
            int num = i;
            rep(k, n-s[j]) num /= 10;
            if (num%10 != c[j]) check = false;
        }
        if (check) {
            cout << i << endl;
            return 0;
        }
    }

    puts("-1");
    return 0;
}

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

int main() {
    int h,w;
    
    while (cin >> h >> w && h!=0 && w!=0){
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3136
n = int(input())
a = list(map(int,input().split()))

ans = 1
left = 0

now = a[0]
for right in range(1,n):
    while True:
        if now & a[right] == 0:
            now = now | a[right]
            ans += right - left +1
            break
        else:
            now = now^a[left]
            left += 1
print(ans)

Measured memory_bytes: 23560
using System;
using System.Text.RegularExpressions;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine(); //標準入力
            string[] str2 = str.Split(' ');
            int a = int.Parse(str2[0]);
            int b = int.Parse(str2[1]);
            int c = int.Parse(str2[2]);
            int d = int.Parse(str2[3]);
            int e = int.Parse(str2[4]);
            List<int> values = new List<int>();
                        
            int value;

            c = c * 2;
            //ABピザ優先
            if (d <= e)//Bピザのほうが多い
            {
                value = d * c;
                values.Add(value + (e - d) * b);
                values.Add(e * c);
            }
            else
            {
                value = e * c;    
                values.Add(value + (d - e) * a);
                values.Add(d * c);
            }

            
            values.Add(a * d + b * e);

            
            if (d <= e)
            {
                value = a * d;
                values.Add(value += e * b);
            }
            else
            {
                value = b * e;
                values.Add(value += d * a);
            }

            value = values.Min();
            Console.WriteLine(value);
        }
    }
}


Measured memory_bytes: 13268
/* ex2_3
   moka223711 */

#include <stdio.h>

int main(void){
  // N * N はマス目の数を表す
  // マス目のAマスを白く塗り、残りを黒く塗る
  int N, A;
  scanf("%d%d", &N, &A);
  
  // N * N - A は黒く塗るマスの数
  printf("%d\n", N * N - A);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <map>
#include <vector>
using namespace std;

int N, M, v;
map<int, int> num;

int main(){
    cin >> N >> M;
    
    num[0]++;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &v);
        v %= M;
        sum = (sum+v)%M;
        num[sum]++;
    }
    
    long long ans = 0;
    for (map<int, int>::iterator it=num.begin(); it!=num.end(); ++it) {
      int val = it->second;
      ans += 1ll*val*(val-1)/2;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3200
import math
x = int(input())
finished = False
# b >= 0 check
a = max(0,int(math.pow(x,0.2)) - 1)
while a**5 - (a-1)**5 <= x:
    tmp = a**5 - x
    if tmp < 0:
        a += 1
        continue
    b = int(math.pow(tmp,0.2))
    if a**5 - b**5 == x:
        finished = True
        print(a,b)
        break
    a += 1
if not finished:
    a = 1
    while a**5 < x:
        tmp = x - a**5
        b = int(math.pow(tmp,0.2))
        if a**5 + b**5 == x:
            finished = True
            print(a,-b)
            break
        a += 1
        

Measured memory_bytes: 9476
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

class point:
    def __init__(self, x ,y):
        self.x = x
        self.y = y

n = int(input())
names = []

for i in range(n):
    names += [input()]

march = 'MARCH'
count = []
for i in range(5):
    count += [0]

for i in range(n):
    for j in range(5):
        if(names[i][0] == march[j]):
            count[j] += 1

ans = 0
for i in range(5):
    for j in range(5):
        for k in range(5):
            if(i < j and j < k):
                ans += (count[i] * count[j] * count[k])

print(ans)

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct ArticulationPoints{
  int n,timer;
  vector<vector<int> > G;
  vector<int> used,pre,par,low;
  set<int> ap;
  ArticulationPoints(){}
  ArticulationPoints(int sz):
    n(sz),G(sz),used(sz),pre(sz),par(sz),low(sz){}
  
  void add_edge(int from,int to){
    G[from].push_back(to);
    G[to].push_back(from);
  }
  
  void dfs(int v,int p){
    pre[v]=low[v]=timer;
    timer++;
    used[v]=1;
    for(int u:G[v]){
      if(!used[u]){
	par[u]=v;
	dfs(u,v);
	low[v]=min(low[v],low[u]);
      }else if(u!=p){
	low[v]=min(low[v],pre[u]);
      }
    }
  }
  
  void build(){
    fill(used.begin(),used.end(),0);
    timer=1;
    dfs(0,-1);
    ap.clear();
    int np=0;
    for(int i=1;i<n;i++){
      int p=par[i];
      if(p==0) np++;
      else if(pre[p]<=low[i]) ap.insert(p);
    }
    if(np>1) ap.insert(0);
  }
};
//END CUT HERE

signed main(){
  int v,e;
  cin>>v>>e;
  ArticulationPoints ap(v);
  for(int i=0;i<e;i++){
    int s,t;
    cin>>s>>t;
    ap.add_edge(s,t);
  }
  ap.build();
  for(int i:ap.ap) cout<<i<<endl;
  return 0;
}

/*
  verified on 2017/07/13
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A&lang=jp
*/

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
int main(){
	int h,w,k;
	cin >> h >> w >> k;
	ll l[w+1]={},c[w+1]={},r[w+1]={};
	if(w==1){cout << 1 << endl;return 0;}
	for(int i=0;i<(1<<(w-1));i++){
		bool flag=true;
		for(int j=0;j<w-2;j++){
			if((i>>j)&(i>>(j+1))&1) flag=false;
		}
		if(!flag) continue;

		for(int j=0;j<w-1;j++){
			if((i>>j)&1){
				l[j+2]++;
				r[j+1]++;
			}else if(j==0){
				c[j+1]++;
			}else{
				if(((i>>(j-1))&1)==0) c[j+1]++;
				if(j==w-2) c[j+2]++;
			}
		}
	}
	ll dp[h+1][w+2]={};
	dp[0][1]=1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			dp[i][j]=dp[i-1][j-1]*r[j-1]%mod+dp[i-1][j]*c[j]%mod+dp[i-1][j+1]*l[j+1]%mod;
			dp[i][j]%=mod;
		}
	}
	cout << dp[h][k] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli inf = 1e18;

int main(){
	lli h,w;
	cin >> h >> w;
	lli ans = inf;
	for(int i=0; i<2; i++){
		vector<lli> a(3);
		for(int i=1; i<h; i++){
			a[0] = i*w;
			lli rh = h-i;
			if(rh%2==0 || w%2==0){
				a[1] = a[2] = rh*w/2;
			}else{
				a[1] = max(rh,w)/2 *min(rh,w);
				a[2] = a[1] +min(rh,w);
			}
			sort(a.begin(), a.end());
			ans = min(ans, a[2]-a[0]);
		}
		swap(h,w);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;
	vector<ll> a(n + 1), b(n);
	for (ll i = 0; i < n + 1; i++)
	{
		cin >> a[i];
	}
	for (ll i = 0; i < n; i++)
	{
		cin >> b[i];
	}

	ll ans = 0;

	ll temp = 0;
	temp = min(a[0], b[0]);
	ans += temp;
	a[0] -= temp;
	b[0] -= temp;

	for (ll i = 1; i < n; i++)
	{
		temp = min(a[i], b[i - 1]);
		ans += temp;
		a[i] -= temp;
		b[i - 1] -= temp;

		temp = min(a[i], b[i]);
		ans += temp;
		a[i] -= temp;
		b[i] -= temp;
	}
	temp = min(a[n], b[n - 1]);
	ans += temp;

	cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	private long[] K = new long[] { 2, 3, 5 };

	public void Solve()
	{
		long T = GetLong();
		WriteLine(string.Join("\n", Range(0, T).Select(_ => solve())));
	}

	private long solve()
	{
		long N = GetLong();
		var ABC = GetLongs(3);
		var D = GetLong();
		return rec(ABC, D, N, new Dictionary<long, long>());
	}

	private long rec(long[] ABC, long D, long x, Dictionary<long, long> dp)
	{
		if(dp.ContainsKey(x))
			return dp[x];

		long min = long.MaxValue / 2;
		try
		{
			chmin(ref min, checked(D * x));
		}
		catch
		{
		}

		for(long i = 0; i < 3; i++)
		{
			long floor = x / K[i];
			if(floor > 0)
			{
				long dpFloor = rec(ABC, D, floor, dp);
				chmin(ref min, dpFloor + ABC[i] + D * Abs(x - K[i] * floor));
			}

			long ceil = (x + K[i] - 1) / K[i];
			if(ceil > 1)
			{
				long dpCeil = rec(ABC, D, ceil, dp);
				chmin(ref min, dpCeil + ABC[i] + D * Abs(x - K[i] * ceil));
			}
		}
		return (dp[x] = min);		
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

int main() {
	while(true) {
		int sum;
		cin >> sum;
		if(sum == 0) break;
		for(int i = 0; i < 9; i++) {
			int el;
			cin >> el;
			sum -= el;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
/*C - Unification*/

#include <iostream>
#include <vector>

using namespace std;

int main(){
	
	char letra;
	vector <char> cadena;
	int tot = 0;
	int i = 0;

	while(cin>>letra){
		cadena.push_back(letra);

		if(i != 0){
			if(cadena[i] == '0' and cadena[i-1] == '1'){
				cadena.pop_back();
				cadena.pop_back();
				tot+=2;
				i-= 2;
			}
			else if(cadena[i] == '1' and cadena[i-1] == '0'){
				cadena.pop_back();
				cadena.pop_back();
				tot+=2;
				i-= 2;
			}

		}

		i++;
	}

	cout<<tot<<'\n';

	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  cout << (N+2 - 1)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define forr(i,k,n) for(int i=k; i<n; i++)
#define iforr(i,k,n) for(int i=n-1; i>=k; i--)
#define rep(i,n) forr(i,0,n)
#define irep(i,n) iforr(i,0,n)
#define aut(i,arr) for(auto& i:arr)
#define all(arr) arr.begin(), arr.end()
#define pb push_back
#define pii pair<int,int>
#define vpii vector<pii>
#define f first
#define db double
#define s second
#define ll long long 
#define ull unsigned long long
#define E '\n'
#define lmax 9223372036854775807;
#define MOD 1000000007
using namespace std;
vi v;
vvi ed;
void dfs(int i)
{
	v[i]=1;
	aut(j,ed[i])
		if(!v[j])
			dfs(j);
}
void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("code.in","r",stdin);
    freopen("code.out","w",stdout);
    #endif
}

int main()
{
	//Fast_IO();
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
		int n;
		cin>>n;
		int k;
		cin>>k;
		vi arr(n);
		vi val(n);
		rep(i,n){
			cin>>arr[i];
			cin>>val[i];
		}
		int tmp=0;
		rep(i,n)
			tmp+=val[i];
		vector<vector<ll>> dp(2,vector<ll>(tmp+1,-1));
		dp[0][0]=0;
		int flg=1;
		forr(i,1,n+1){
			dp[flg][0]=0;
			forr(j,1,tmp+1)
			{
				dp[flg][j]=dp[flg^1][j];
				if(j-val[i-1]>=0)
					if(dp[flg^1][j-val[i-1]]>=0)
						if(dp[flg][j]!=-1)
							dp[flg][j]=min(dp[flg][j],arr[i-1]+dp[flg^1][j-val[i-1]]);
						else
							dp[flg][j]=dp[flg^1][j-val[i-1]]+arr[i-1];

			}
			flg^=1;
		}
		ll ans=-1;
		rep(i,tmp+1){
			if(dp[flg^1][i]!=-1)
				if(dp[flg^1][i]<=k)
					ans=max(ans,(ll)i);
		}
		cout<<ans;
		cout<<E;
	}
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,count;
 count = 0;
 cin >> N; 
vector<int> pre(N);
for (int h = 0; h < N ;h++){
  cin >> pre.at(h);
//  cout << pre.at(h) ;
}
//  cout << endl;
  
vector<vector<int>> data(N, vector<int>(N));
   for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) { 
  data.at(i).at(j) = pre.at(i) + pre.at(j);
//   cout << data.at(i).at(j) << ",";
}
//   cout << endl;
}

for(int h = 0; h < N ;h++){  
  for(int i = 0; i < N ;i++){
    for(int j = 0; j < N ;j++){
 if(pre.at(h) < data.at(i).at(j) &&pre.at(i) < data.at(h).at(j)&&pre.at(j) < data.at(h).at(i)&& pre.at(i) != pre.at(j)&& pre.at(h) != pre.at(i)&& pre.at(h) != pre.at(j)) {
  count++; 
 } 

}  
  }
}
cout << count/6 << endl;  
}

Measured memory_bytes: 3648
from collections import defaultdict


class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]
        self.node = node

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

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

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

    def get_size(self, x):
        return -self.parent[self.find(x)]

    def get_root(self):
        return [i for i, root in enumerate(self.parent) if root < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.node) if self.find(i) == root]

    def all_group_members(self):
        return {r: self.members(r) for r in self.get_root()}


def main():
    h, w = map(int, input().split())
    grid = [["*" for _ in range(w + 2)]]
    for _ in range(h):
        grid.append(["*"] + list(input()) + ["*"])
    grid.append(grid[0])
    uf = UnionFind(h * w)
    all_black = []

    def grid_num(i, j):
        return w * (i - 1) + j - 1

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            for di, dj in [[0, 1], [1, 0], [0, -1], [-1, 0]]:
                ni = i + di
                nj = j + dj
                if grid[ni][nj] == "*":
                    continue
                elif grid[i][j] != grid[ni][nj]:
                    uf.union(grid_num(i, j), grid_num(ni, nj))
            if grid[i][j] == "#":
                all_black.append([i, j])
    ans = 0

    black = defaultdict(int)
    for i, j in all_black:
        black[uf.find(grid_num(i, j))] += 1
    for i, r in enumerate(uf.parent):
        if r < 0:
            ans += black[i] * (-r - black[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 35148
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  rep2(i, 1, 3501){
    rep2(j, i, 3501){
      double nij = n*i*j;
      double bo = 4*i*j - n*i - n*j;
      if(bo == 0) continue;
      double k = nij/bo;
      if(floor(k) == k && k > 0){
        cout << i << " " << j << " " << (ll)k << endl;
        return 0;
      }
    }
  }
  return 1;
}

Measured memory_bytes: 256
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(A[K-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 1001000;
bool prime[N];

const ll mod = 1e9+7;

int main(){
    fill(prime,prime+N,true);
    prime[0] = prime[1] = false;
    for(int i=2; i<N; ++i){
        if(prime[i]) for(int j=2*i; j<N; j+=i) prime[j] = false;
    }

    int n;
    cin >>n;
    vector<int> q(n);
    rep(i,n) cin >>q[i];
    q.pb(1000999);

    vector<ll> dp(n+1);
    dp[0] = 1;
    rep(i,n)if(prime[q[i]]){
        // 1個
        if(i+1<=n && prime[q[i+1]] && q[i]<q[i+1]) (dp[i+1] += dp[i]) %= mod;

        // 2個
        if(i+2<=n && prime[q[i+2]] && q[i]<q[i+2]) (dp[i+2] += dp[i]) %= mod;
    }
    cout << dp[n] << endl;

    return 0;
}



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

int main() {
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    int n, ans = 0;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        int t;
        std::cin >> t;
        while(1){
            if(t % 2){
                break;
            }
            ans++;
            t /= 2;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int power(int x)
{
	int power = 1;
	for (int i = 0; i < x; i++) {
		power *= 2;
	}
	return power;
}
int main(void)
{
	int N;
	scanf("%d", &N);
	if (N == 1) {
		printf("1");
	}
	for (int i = 10; i > 0; i--) {
		if (power(i)<=N&&power(i+1)>N){
			printf("%d",power(i));
		}
	}
	return 0;
}

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


int main()
{
	int m, f, r;

	while (true)
	{
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1) {
			break;
		}

		if (m == -1 || f == -1 || m + f < 30) {
			cout << 'F' << endl;
		}
		else if (m + f >= 80) {
			cout << 'A' << endl;
		}
		else if (65 <= m + f && m + f < 80) {
			cout << 'B' << endl;
		}
		else if (50 <= m + f && m + f < 65) {
			cout << 'C' << endl;
		}
		else {
			if (50 <= r) {
				cout << 'C' << endl;
			}
			else {
				cout << 'D' << endl;
			}
		}
	}

    return 0;
}



Measured memory_bytes: 3088
import java.io.*
import java.util.*

fun solve(N: Long){
    println((N/2 + N % 2).toDouble() / N.toDouble())
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    solve(N)
}



Measured memory_bytes: 29728
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = list(map(int, input().split()))

ans = 0
while True:
    taken = [0] * N
    for i, a in enumerate(As):
        taken[i] = a // N
        As[i] -= taken[i] * N
    # print("===")
    # print(As)
    # print(taken)

    taken_sum = sum(taken)
    if taken_sum == 0:
        break
    ans += taken_sum
    for i in range(N):
        As[i] += (taken_sum - taken[i])
print(ans)    


Measured memory_bytes: 5584
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t=1;
	while(t--)
	{
		string s,t;
		cin >> s >> t;
		int mn=INT_MAX;
		for(int i=0;i<=s.size()-t.size();i++)
		{
			int cnt=t.size();
			for(int j=0;j<t.size();j++)
			{
				if(s[i+j]==t[j])
				cnt--;
			}
			mn=min(mn,cnt);
		}
		cout << mn;
	}
}




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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n; cin >> n;
    int ans = inf;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        ans = min(ans, __builtin_ffs(a) - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(string& s) {
        int n = s.length();
        vector<int> cnts(3, 0);
        string A = "RGB";

        long long res = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                if (s[i] != s[j]) {
                    for (int k = 0; k < 3; ++k) {
                        if (A[k] != s[i] && A[k] != s[j]) {
                            res += cnts[k];
                            int l = 2 * i - j;
                            if (l >= 0 && s[l] == A[k]) {
                                --res;
                            }
                        }
                    }
                }
            }
            int id = A.find_first_of(s[i]);
            cnts[id] += 1;
        }

        return res;
        
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    string s;
    cin >> s;

    Solution sol;
    cout << sol.solve(s) << "\n";

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <time.h> //for clock
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    vector<ll> v;

    ll a;
    ll count = 0;
    ll i;

    int flag = 1;
    ll tmp = 1000000001;
    ll sum = 0;

    for(i = 0; i < n; i++){
        cin >> a;
        sum += abs(a);  
        v.push_back(a);
        if(a < 0){
            count++;
        }   

        if(tmp > abs(a)){
            tmp = abs(a);
            if(a < 0){
                flag = 0;
            }else{
                flag = 1;
            }
        }
    }

    if(flag){
        if(count%2 == 1){
            sum -= 2*tmp;
        }
    }else{
        if(count%2 == 1){
            sum -= 2*tmp;   
        }
    }

    cout << sum << endl;



}

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


int compute(int k, int n, vector<int>&dp, int arr[])
{
    if(k==0)
    return 0;
    
    int ans=0;
    // cout<<k<<" ";
    
    if(dp[k]!=-1)
        return dp[k];
        
    for(int i=0;i<n;i++)
    {
        if(arr[i]<=k)
        {
            if(compute(k-arr[i],n,dp,arr)==0)
            {ans=1;
            break;}
        }
    }
    // cout<<ans<<endl;
    return dp[k]=ans;
    
}

int main() {
// 	cout<<"GfG!";

    int N,K;
    cin>>N>>K;
    int arr[N];
    
    for(int i=0;i<N;i++)
        cin>>arr[i];
    
    vector<int>dp(K+1,-1);
    
    if(compute(K,N,dp,arr)==1)
        cout<<"First";
    else
        cout<<"Second";
    
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static int Mod = 1000000007;
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int X = l[0], Y = l[1];

            if ((X + Y) % 3 != 0 || 2 * Y < X || 2 * X < Y)
            {
                Console.WriteLine(0);
                return;
            }

            var n = (X + Y) / 3;
            var m = X - n;

            Console.WriteLine(ModNcr(n, m));
        }

        static long ModPow(long b, int i)
        {
            for (var r = 1L; ; b = b * b % Mod)
            {
                if (i % 2 > 0) r = r * b % Mod;
                if ((i /= 2) < 1) return r;
            }
        }

        static long ModInv(int x)
        {
            return ModPow(x, Mod - 2);
        }

        static long ModFactorial(int n)
        {
            for (long x = 1, i = 1; ; x = x * ++i % Mod)
                if (i >= n) return x;
        }

        static long ModNpr(int n, int r)
        {
            if (n < r) return 0;
            for (long x = 1, i = n - r; ; x = x * ++i % Mod) if (i >= n) return x;
        }

        static long ModNcr(int n, int r)
        {
            if (n < r)
                return 0;
            else if (n - r < r)
                return ModNcr(n, n - r);
            else
                return ModNpr(n, r) * ModInv((int)ModFactorial(r)) % Mod;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int cnt[100000];

int main()
{
	int N, Q, l, r;
	string S;

	cin >> N >> Q >> S;

	rep(i, N) {
		if (i == 0) cnt[i] = 0;
		else {
			string sub = S.substr(i - 1, 2);
			if (sub == "AC") cnt[i] = cnt[i - 1] + 1;
			else cnt[i] = cnt[i - 1];
		}
	}

	rep(i, Q) {
		cin >> l >> r;
		cout << cnt[r - 1] - cnt[l - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

ll n, k;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> k;
	// pair<score, type> 
	vector<pair<ll, ll> > food;
	rep(i,0,n) {
		ll t, d;
		cin >> t >> d;
		food.pb(mp(d, t));
	}
	sort(food.rbegin(), food.rend());

	set<ll> have;
	priority_queue<ll> Q;
	ll locret = 0;
	ll ret = 0;
	rep(i,0,k) {
		ll d = food[i].F;
		ll t = food[i].S;

		if(have.count(t)) {
			Q.push(-d);
		} else {
			have.insert(t);
		}

		locret += d;
	}

	ret = locret + (ll)have.size() * have.size();

	rep(i,k,n) {
		ll d = food[i].F;
		ll t = food[i].S;

		if(Q.empty()) break;
		ll minD = -Q.top();
		Q.pop();

		if(have.count(t)) {
			Q.push(-d);
		} else {
			have.insert(t);
		}

		ll x = have.size();
		locret = locret + d - minD;
		ret = max(ret, locret + x * x);
	}

	cout << ret << '\n';
	return 0;
}


Measured memory_bytes: 5232
n = int(input())
p = list(map(int,input().split()))
ans = 0
# print(p)

for i in range(n-2):
	if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]):
		ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U)
    A--;
  else
    B--;
  printf("%d %d\n", A, B);
}

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )

template < typename T >
inline T read( )
{
	register T x = 0;
	register char ch = gc( );
	register bool f = 0;
	while( !std::isdigit( ch ) )
	{
		f = ( ch == '-' );
		ch = gc( );
	}
	while( std::isdigit( ch ) )
	{
		x = x * 10 + ( ch - '0' );
		ch = gc( );
	}
	return f ? -x : x;
}

template < typename T >
void print( T x )
{
	if( x < 0 )
	{
		x = -x;
		pc( '-' );
	}
	if( x < 10 )
	{
		pc( x + 48 );
		return;
	}
	print < T > ( x / 10 );
	pc( x % 10 + 48 );
	return ;
}

namespace Solution
{
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( ' ' )
#define ptl( i ) print < long long > ( i ), putchar( ' ' )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
	int n, v, u;
	long long ans;
	void fakemain( )
	{
		n = rdi( );
		For( i, 1, n )
			ans += 1LL * i * ( n - i + 1 );
		For( i, 1, n - 1 )
		{
			u = rdi( );
			v = rdi( );
			if( u > v )
				std::swap( u, v );
			ans -= 1LL * u * ( n - v + 1 );
		}
		ptl( ans );
		return;
	}

} // namespace Solution

int main( int argc, char* argv[] )
{
	Solution::fakemain( );
	return 0;
}

Measured memory_bytes: 3632