akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;
string S,T;
long long  i=0;
char counter;

int main(){
  cin >> S >> T;
  vector<long long> s(30);
  vector<long long> t(30);
  for(i=0;i<S.size();i++){
    for(counter='a';counter<='z';counter++){
      if(S.at(i)==counter){
        s.at(counter-97)++;
      }
      if(T.at(i)==counter){
        t.at(counter-97)++;
      }
    }
  }
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  
  for(i=0;i<30;i++){
    if(s.at(i)!=t.at(i)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
const int N=100001,M=400004;
const int INF=0x7f7f7f7f;
struct node {
        int i,value;
        friend bool operator < (node a,node b){
                return a.value > b.value;
        }
};
struct edge{
	int to,value;
	int next;
}mem[M];
priority_queue<node> minq;
int head[N],siz=0,dis[N],n,m,start,qian[N];
bool vis[N];
void  dijkstra(int start){
        dis[start]=0;
        node tmp={start,0};
        minq.push(tmp);
        while(!minq.empty()){
                tmp=minq.top();
                minq.pop();
                if(vis[tmp.i])continue;
                vis[tmp.i]=true;
                for(int j=head[tmp.i];j!=0;j=mem[j].next){
                		int to=mem[j].to;
                	    if(!vis[to]&&mem[j].value+dis[tmp.i]<dis[to]){
                            	dis[to]=mem[j].value+dis[tmp.i];
                                node tmp2={to,dis[to]};
                                minq.push(tmp2);
                                qian[to] = tmp.i;
                        }
                }
        }
}
int main(){
        memset(head,0,sizeof(head));
        memset(dis,0x7f,sizeof(dis));
        memset(vis,false,sizeof(vis));
        memset(qian,-1,sizeof(qian));
        scanf("%d %d",&n,&m);
        start=1;
        int u,v,w;
        for(int i=1;i<=m;i++){
                scanf("%d %d",&u,&v);w=1;
                siz++;mem[siz].to=v;mem[siz].value=w;mem[siz].next=head[u];head[u]=siz;
                siz++;mem[siz].to=u;mem[siz].value=w;mem[siz].next=head[v];head[v]=siz;
        }
        dijkstra(start);
        for(int i=1;i<=n;i++)
        {
        	if(dis[i]>=2139062143){
        		printf("No");return 0;
			}
		}
		printf("Yes\n");
		for(int i=2;i<=n;i++)
		{
			cout<<qian[i]<<endl;
		}
        return 0;
}

Measured memory_bytes: 10320
#include <stdio.h>
int main()
{
  int box[101][101],r,c,cour,couc,sumc,sumr=0,suma=0;
  scanf("%d %d",&r,&c);
  for(cour=1;cour<r+1;cour++){
    for(couc=1;couc<c+1;couc++){
      scanf("%d",&box[cour][couc]);
    }
  }
  for(cour=1;cour<r+1;cour++){
    sumc=0;
    for(couc=1;couc<c+2;couc++){
      if(couc<c+1){
	printf("%d ",box[cour][couc]);
	sumc=sumc+box[cour][couc];
      }
    }
    printf("%d\n",sumc);
  }
  for(couc=1;couc<c+1;couc++){
    sumr=0;
    for(cour=1;cour<r+1;cour++){
      sumr=sumr+box[cour][couc];
    }
    printf("%d ",sumr);
    suma=suma+sumr;
  }
  printf("%d\n",suma);
  return 0;
}

Measured memory_bytes: 1068
l, r = map(int, input().split())

aaa = []

if r - l >= 2019:
    ans = 0
else:
    r_mod = r % 2019
    l_mod = l % 2019
    if l_mod > r_mod:
        ans = 0
    else:
        for i in range(l_mod, r_mod+1):
            for j in range(i+1, r_mod+1):
                rl_mod = i * j % 2019 
                aaa.append(rl_mod)
        ans = min(aaa)

print(ans)



Measured memory_bytes: 75412
#include <bits/stdc++.h>
using namespace std;
int costmin(int n,int h[]){
	int *dp=new int[n+1];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
 	for(int i=2;i<n;i++){
    	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
 	}
   return dp[n-1];
}
int main(){
	int n;cin>>n;
	int a[n];
	for(int&x:a) cin>>x;
	int ans=costmin(n,a);
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        String s = sc.next();
        String t = sc.next();
        
        int n = s.length();
        int m = t.length();
        int ans = n;
        for(int i = 0; i <= n-m; i++){
            int count = 0;
            for(int j = 0; j < m; j++){
                if(s.charAt(i+j) != t.charAt(j)){
                    count++;
                }
            }
            ans = Math.min(count, ans);
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll a, b;
  cin >> a >> b;
  
  if (a <= 5) {
    cout << 0 << endl;
  } else if (a <= 12) {
    cout << b/2 << endl;
  } else {
    cout << b << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind
{
    vector<int> par, rank;
    UnionFind(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; ++i)
            par[i] = i;
    }
    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x), ry = root(y);
        if (rx == ry)
            return;
        if (rank[ry] > rank[rx])
            par[rx] = ry;
        else
            par[ry] = rx;
        if (rank[rx] == rank[ry])
            rank[rx]++;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
};

vector<ll> fac, inv, finv;

void initcom()
{
    fac = inv = finv = vector<ll>(1e6);
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (ll i = 2; i < 1e6; ++i)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll com(int n, int k)
{
    if (n < 0 || k < 0)
        return 0;
    if (n < k)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}
ll mopow(ll a, ll x, ll mod)
{
    ll res = 1;
    while (x > 0)
    {
        if (x & 1)
            res = res * a % mod;
        a = a * a % mod;
        x >>= 1;
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i)
        cin >> p[i];
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i)
    {
        a[i] = 1 + n * i;
        b[n - 1 - i] = a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        a[p[i]-1] += i;
    }
    for (int i = 0; i < n; ++i)
    {
        cout << a[i];
        if (i < n - 1)
            cout << ' ';
        else
            cout << endl;
    }
    for (int i = 0; i < n; ++i)
    {
        cout << b[i];
        if (i < n - 1)
            cout << ' ';
        else
            cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3864
#include <iostream>
using namespace std;
int main(){
  int n,a,b;
  while(cin >> n,n){
    int suma = 0,sumb = 0;
    for(int i = 0 ; i < n ; i++){
	cin >> a >> b;
	if(a > b)suma+=(a+b);
	else if(a < b)sumb+=(a+b);
	else {
	  suma += a;
	  sumb+=b;
	}
      }
      cout << suma << " " << sumb << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
        ll N; cin >> N;
        vl as(N);
        FOR(i, 0, N) cin >> as[i];

        vl prefix(N);
        prefix[0] = as[0];
        FOR(i, 1, N) {
                prefix[i] = prefix[i-1] + as[i];
        }

        ll min_dis = oo;
        FOR(snuke, 0, N-1) {
                ll x = prefix[snuke];
                ll y = prefix[N-1] - prefix[snuke];
                min_dis = min(abs(x-y), min_dis);
        }
        cout << min_dis << endl;
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while (true) {
        int x, y, s; cin >> x >> y >> s;
        if (!x && !y && !s) break;

        int ans = 0;
        FOR(i, 1, s) FOR(j, i, s)  {
            if (i*(100+x)/100 + j*(100+x)/100 != s) continue;
            ans = max(ans, i*(100+y)/100 + j*(100+y)/100);
        }

        cout << ans << endl;
    }
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;

    i64 d = 1;
    for (i64 i = 26; n > i; i *= 26) n -= i, d++;

    n--;
    string ans(d, 'a');
    for (i64 i = d - 1; n > 0; i--) {
        ans[i] += n % 26;
        n /= 26;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main() {
	string s;
	while(getline(cin, s)) {
		stack<char> st;
		bool f = true;
		if(s == ".") {
			break;
		}
		for(auto &c : s){
			if(c == '(' || c == '[') {
				st.push(c);
			}
			else if(c == ')' || c == ']') {
				if(st.size() == 0) {
					f = false;
					break;
				}
				char t = st.top();
				if((t == '(' && c == ')') || (t == '[' && c == ']')) {
					st.pop();
				}
				else {
					f = false;
					break;
				}
			}
		}
		f = f && (st.size() == 0);
		cout << (f ? "yes" : "no") << endl;
	}
	return 0;
}



Measured memory_bytes: 3200
# -*- coding: utf-8 -*-
length=int(input())
lst=list(map(int,input().split()))
lst2=[]
for i in range(length):
    s1=sum(lst[0:i+1])
    s2=sum(lst[i+1:])
    lst2.append(abs(s1-s2))
print(min(lst2))

Measured memory_bytes: 3060
#include <stdio.h>
int max(int a, int b) { return a > b ? a : b; }

int main(){
  long int a,b,k;
  scanf("%ld%ld%ld",&a,&b,&k);
  if(k<=a){
    printf("%ld %ld",a-k,b);
  }
  else if(k<=a+b){
    printf("%ld %ld",0,a+b-k);
  }
  else{
    printf("%ld %ld",0,0);
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  string s; cin>>s;
  if (s=="RRR") cout << 3;
  if (s=="SSR"||s=="RSS") cout << 1;
  if (s=="SRR"||s=="RRS") cout << 2;
  if (s=="SRS"||s=="RSR") cout << 1;
  if (s=="SSS") cout << 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
using P = pair<int, int>;
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

//二項係数を求める nCk mod.p (1≦k≦n≦10^7程度)
constexpr int MAX = 1e6 + 1;
constexpr int MOD = 1e9 + 7;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() //テーブルを作る前処理
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep(i, 2, MAX)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
int COM(int n, int k) //二項係数
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit(); //前処理をしておく

    int x, y;
    cin >> x >> y;
    if (x < y)
        swap(x, y);

    if ((2 * y - x) % 3 != 0)
    {
        cout << 0 << '\n';
    }
    else if (2 * y - x < 0)
    {
        cout << 0 << '\n';
    }
    else
    {
        cout << COM((x + y) / 3, (2 * y - x) / 3) << '\n';
    }
    return 0;
}

Measured memory_bytes: 23680
# coding: utf-8

# https://atcoder.jp/contests/abc103
# 11:25-


def main():
    A = list(map(int, input().split()))
    tasks = [[0, 1, 2], [0, 2, 1], [1, 2, 0], [1, 0, 2], [2, 0, 1], [2, 1, 0]]

    ans = 10000000
    for task in tasks:
        cand = abs(A[task[1]]-A[task[0]]) + abs(A[task[2]]-A[task[1]])
        if cand < ans:
            ans = cand
    
    return ans


print(main())


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

int main() {
  bool a[3] = {};
  for(int i=0; i<3; ++i) {
    char c;
    cin >> c;
    a[c - 'a'] = true;
  }
  if(a[0] && a[1] && a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}
    

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

int main(){
  string S;
  cin>>S;
  int N=S.size();
  string T="keyence";
  int count=0;
  for(int i=0;i<7;i++){
    if(S.at(i)==T.at(i)){
      count++;
    }else{
      break;
    }
  }
  for(int i=6;i>=0;i--){
    if(S.at(N-7+i)==T.at(i)){
      count++;
    }else{
      break;
    }
  }
  
  if(count>=7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
  

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

using namespace std;

int main() {
    int a = 0, b = 0, x = 0;
    cin >> x;
    cin >> a;
    cin >> b;

    x -= a;
    while (x >= b) {
        x -= b;
    }

    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int ketawa(int a){
	int sum = 0; 
	while(a > 0){
		sum += a % 2; 
		a /= 2; 
	}
	return sum; 
}
int main(){
	int N, A, B; 
	cin >> N >> A >> B; 
	string res = "YES"; 
	if(ketawa(A) % 2 == ketawa(B) % 2) res = "NO"; 
	if(N == 1){
		cout << "YES" << endl << A << " " << B << endl; 
	}
	int C[140000] = {}; 
	C[0] = 0; C[1] = 1; C[2] = 3; C[3] = 2; 
	C[4] = 6; C[5] = 7; C[6] = 5; C[7] = 4; 
	for(int i = 3; i < 17; i++){
		C[(1 << i)] = (1 << (i+1)) - C[(1 << i) - 1]; 
		for(int j = (1 << i) + 1; j < (1 << (i+1)); j++){
			C[j] = C[j-1] + C[(1 << (i+1)) - 1 - j] - C[(1 << (i+1)) - j]; 
		}
	}
	int P = 0;
	for(int i = 0; i < (1 << N); i++){
		if(C[i] == (A^B)){
			P = i; break; 
		}
	}
	vector<int> ans = {}; 
	if(P < (1 << (N-1))){
		for(int i = 0; i < P; i++){
			ans.push_back(C[i]); 
		}
		for(int i = P - 1; i >= 0; i--){
			ans.push_back(C[(1 << N) - 1 - i]); 
		}
		for(int i = ((1 << (N-1)) - 1); i >= P; i--){
			if(i % 2 == 1){
				ans.push_back(C[(1 << N) - 1 - i]); 
				ans.push_back(C[i]); 
			}
			else if(i % 2 == 0){
				ans.push_back(C[i]); 
				ans.push_back(C[(1 << N) - 1 - i]); 
			}
		}
	}
	else if(P < (1 << N) - 1){
		for(int i = 0; i < (1 << N) - 1 - P; i++){
			ans.push_back(C[i]); 
		}
		for(int i = P + 1; i < (1 << N); i++){
			ans.push_back(C[i]); 
		}
		for(int i = ((1 << (N-1)) - 1); i >= (1 << N) - 1 - P; i--){
			if(i % 2 == 1){
				ans.push_back(C[(1 << N) - 1 - i]); 
				ans.push_back(C[i]); 
			}
			else if(i % 2 == 0){
				ans.push_back(C[i]); 
				ans.push_back(C[(1 << N) - 1 - i]); 
			}
		}
	}
  	else if(P == (1 << N) - 1){
			ans.push_back(0); 
		for(int i = ((1 << (N-1)) - 1); i >= 1; i--){
			if(i % 2 == 0){
				ans.push_back(C[(1 << N) - 1 - i]); 
				ans.push_back(C[i]); 
			}
			else if(i % 2 == 1){
				ans.push_back(C[i]); 
				ans.push_back(C[(1 << N) - 1 - i]); 
			}
		}
           ans.push_back(1 << (N-1)); 
	}
  if(N != 1){
	cout << res << endl; 
	if(res == "YES"){
		for(int i = 0; i < ans.size(); i++){
			cout << ((ans.at(i)) ^ A) << " ";
		}
		cout << endl; 
	}
  }
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//std::uniform_int_distribution<long long> rg(1,1e18);
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
void dfs(int i, vector<si>& edges, vi& vis, int& r) {
    r++;
    vis[i] = 1;
    for(int j : edges[i]) {
        if(!vis[j]) dfs(j, edges, vis, r);
    }
}
void solve() {
    int n, m;
    cin >> n >> m;
    vector<si> edges(n);
    fori(i,0,m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].insert(b);
        edges[b].insert(a);
    }
    vi vis(n, 0);
    int ans = 1;
    fori(i,0,n) {
        if(!vis[i]) {
            int r = 0;
            dfs(i,edges, vis, r);
            ans = max(ans, r);
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
//	freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


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

int data[2][100];
int n;

void solve() {
  int ans = -1;
  for(int i = 0; i < 2; i++) {
    bool visited[2][100];
    int jump, nb, nf;
    jump = 0;
    nb = i;
    nf = 0;
    if(data[nb][nf] == 1) {
      while(nf < n && data[nb][nf] == 1) nf++;
      nf--;
    }

    fill_n(visited[0], 2*100, false);
    visited[i][0] = true;
    while(1) {
      if(nf == n-1) {
	if(ans == -1 || jump < ans) {
	  ans = jump;
	}
	break;
      }
      jump++;
      nb = 1 - nb;
      nf += 2;
      if(nf >= n) nf--;
      if(data[nb][nf] == 1) {
	while(nf < n && data[nb][nf] == 1) nf++;
	nf--;
      } else if(data[nb][nf] == 2) {
	while(data[nb][nf] == 2) nf--;
      }
      if(visited[nb][nf]) break;
      visited[nb][nf] = true;
    }
  }
  if(ans == -1) cout << "NA" << endl;
  else          cout << ans << endl;
}

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;

    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < n; j++) {
	cin >> data[i][j];
      }
    }
    solve();
  }
  return 0;
}

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

int solve(int l, int r,string s) {
	int cnt = 0;
	for (int i = l; i < r; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C')
			cnt++;
		if (s[i] != 'A' && s[i + 1] == 'C')
			i += 2;
	}
	return cnt;
}
const int oo = 1e6;
long int p[oo], q[oo];

vector<pair<int, int>>v;
int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> p[i] >> q[i];
		//state[i] = 1;
		v.push_back(make_pair(p[i], q[i]));
	}
	sort(v.begin(), v.end());
	int cnt = 0;
	long long cost = 0;
	for (int i = 0; i < n; i++) {
		while (true) {
			if (m > v[i].second) {
				cnt += v[i].second;
				cost += (long long)v[i].second * v[i].first;
				m -= v[i].second;
				break;
			}
			else {
				cnt += m;
				cost += (long long )m * v[i].first;
				cout << cost << endl;
				return 0;
			}
			
		}
	}
	cout << cost << endl;

	
	return 0;
}

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

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());

        long ans = Long.MAX_VALUE;

        for (int i = 0; i <= Math.max(x*2, y*2); i+=2) {
          long tmp = c*i + a*(Math.max(0,x-i/2)) + b*(Math.max(0,y-i/2));
          ans = Math.min(tmp, ans);   
        }

        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(){
  long long mi=1e18,a=0,b=0,s=0,mx=-1e18;
  int n,m,i,d[100010],c=0,max=0;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
    if(d[i]>0)s+=d[i];
    if(d[i]<0)a+=d[i];
    if(d[i]>0)b+=d[i];
    if(i>=m){
      if(d[i-m]<0)a-=d[i-m];
      if(d[i-m]>0)b-=d[i-m];
    }
    if(i>=m-1){
      if(mx<a)mx=a;
      if(mi>b)mi=b;
    }//printf("%2d %2lld %2lld\n",d[i],a,b);
  }//printf("\n%d %lld %lld %lld\n",max,s,mx,mi);
  if(-mx>mi)s-=mi;
  else      s+=mx;
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
	double a,b,f;
	long d, r;
	scanf("%lf %lf",&a,&b);
	d = (int) a / (int)b;
	r = (int)a % (int)b;
	f = a / b;
	printf("%ld %ld %.5lf\n", d, r, f);
	return 0;
}

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

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int m=scan.nextInt();
int[] p=new int[m];
String[] s=new String[m];

int i=0;
for(i=0;i<m;i++){
    p[i]=scan.nextInt();
    s[i]=scan.next();
}
  
int[] a=new int[n];
int[] b=new int[n];
for(i=0;i<n;i++){
    a[i]=0;
    b[i]=0;
}
  
for(i=0;i<m;i++){
    if(s[i].equals("WA")&&b[p[i]-1]==0){
        a[p[i]-1]=a[p[i]-1]+1;
    }
    if(s[i].equals("AC")&&b[p[i]-1]==0){
        b[p[i]-1]=b[p[i]-1]+1;
    }
}

int sum=0;
int summ=0;
for(i=0;i<n;i++){
  if(b[i]==1){
  sum=sum+a[i];
  }
  summ=summ+b[i];
}

System.out.println(summ+" "+sum);
}
}

Measured memory_bytes: 70052
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,l[5][5]; cin>>n;
	while(n--){
		int ans=0,f;
		rep(i,5)rep(j,5)cin>>l[i][j];
		rep(i,5)rep(j,5)if(l[i][j]){
			rep(a,6)rep(b,6){
				f=0;
				rep(p,a)rep(q,b)if(i+p>4||j+q>4||!l[i+p][j+q])f=1;
				if(!f&&ans<a*b)ans=a*b;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;


int main() {
  ll n, m;
  cin >> n >> m;
  ll x = 1;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if (a[i] % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    x = lcm(x, a[i] / 2);
  }

  rep(i, n) {
    if ((2 * x / a[i]) % 2 == 0) {   // 最小公倍数と a[i] で 2^q の q は同じでないといけない
      cout << 0 << endl;
      return 0;
    }
  }

  ll tmp = m / x;
  ll ans = (tmp + 1) / 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3768
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
dp = [0] * N
bc = 0

for _i in range(N):
    i = N-_i
    cur = i * 2
    sum_b = 0
    # print('i', i)

    if i == 0:
        break

    while cur <= N:
        # print(i-1, cur)
        sum_b += B[cur-1]
        cur += i

    b = (sum_b + A[i-1]) % 2

    # print(i, b)
    if b == 1:
        B[i-1] = b
        bc += 1

# print(B)
print(bc)
if bc > 0:
    print(' '.join([str(i+1) for i in range(N) if B[i] > 0]))


Measured memory_bytes: 72412
//int -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define REP(i,sss,eee) for(int i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<bool> dp,b;
std::vector<int> inp;
int main(){
	int n,k;cin>>n>>k;
	inp.resize(n);
	REP(i,0,n-1)
	{
		cin>>inp[i];
	}
	sort(inp.begin(),inp.end());
	dp.resize(k+1,0);
	REP(val,0,k)
	{
		for (int i = 0; (i < n) && (inp[i]<=val); ++i)
		{
			dp[val]=((!(dp[val-inp[i]]))|dp[val]);
		}
	}
	if(dp[k]){cout<<"First\n";}
	else{cout<<"Second\n";}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	M := N
	k := 0
	for M > 0 {
		k += M % 10
		M /= 10
	}
	if N%k == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        long long b = 1;
        sum += b*a;
        sum = sum % 10;
    }
    if(sum % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
 
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;
#define N 2 
int getMin(int x, int y) { return (x<y)? x: y; } 
int arr1[200010],arr2[200010];

signed main() {
 
	fastio();
//	#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	multiset<pair<int,int>,greater<pair<int,int>>> arr;
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++)
	{
		cin>>arr1[i];
		
	}
	for(int i=0;i<n;i++)
	{
		cin>>arr2[i];
		arr.insert(mp(arr2[i],i));	
	}
	//cout<<arr.size()<<endl;
	int ans=0;
	while(arr.size()!=0)
	{

		pair<int,int> tp=*arr.begin();
		
		arr.erase(arr.begin());
		
		
		if(arr1[tp.ss]==arr2[tp.ss])
		{
			continue;
		}
		int m=tp.ss;
		int l=tp.ss-1;
		if(l<0)
			l+=n;
		int r=tp.ss+1;
		if(r==n)
			r=0;
		int res=arr2[l]+arr2[r];
		if((arr2[m]-res)<arr1[m])
		{
			cout<<-1<<endl;
			return 0;
		}
		int ptr=(arr2[m]-arr1[m])/res;
		arr2[m]-=(res*ptr);

		ans+=ptr;
		if(arr1[m]!=arr2[m])
		{
			arr.insert({arr2[m],m});
		}
	}
	cout<<ans;
	return 0;

 }


Measured memory_bytes: 15872
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define ll long long

using namespace std;

int main() {
  int N; cin >> N;
  int M; cin >> M;
  vector<int> a(N);

  int sumVote = 0;
  for(int i=0;i<N;i++) {
    cin >> a[i];
    sumVote += a[i];
  }

  float thres = (float) sumVote / (float) (4 * M);
  int cnt = 0;

  for(int i=0;i<N;i++) {
    if ((float)a[i] >= thres) {
      cnt ++;
    }
  }
  if (cnt >= M) cout << "Yes" << endl;
  else cout << "No" <<endl;
  return 0;
}


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

const int maxn = 2e2 + 10;
const long long mod = 998244353;

int n;
long long x[maxn], y[maxn];
long long pot[maxn];

struct line {
	long long dx, dy;

	line(long long DY, long long DX) {
		long long GCD = __gcd(DX, DY);

		DY /= GCD;
		DX /= GCD;

		if(DY < 0)
			DX = -DX;

		dx = DX;
		dy = DY;
	}
};

bool operator < (line a, line b) {
	return (a.dx < b.dx) || (a.dx == b.dx && a.dy < b.dy);
}

long long solve() {
	pot[0] = 1LL;

	for(int i = 1; i <= n; ++i)
		pot[i] = (pot[i - 1] * 2LL) % mod;

	long long ans = (pot[n] - 1 + mod) % mod;

	for(int i = 1; i <= n; ++i) {
		map <line, int> angle;
		int hor = 0, ver = 0;

		for(int j = i + 1; j <= n; ++j) {
			long long dx = x[i] - x[j];
			long long dy = y[i] - y[j];

			if(!dx)
				++ver;
			else
				if(!dy)
					++hor;
				else
					++angle[line(dy, dx)];
		}

		long long add = 0;

		for(auto it: angle) 
			add = (add + pot[it.second] - 1 + mod) % mod;

		add = (add + 1) % mod;
		add = (add + pot[ver] - 1 + mod) % mod;
		add = (add + pot[hor] - 1 + mod) % mod;

		ans = (ans - add + mod) % mod;
	}

	return ans;
}

int main() {
	cin >> n;

	for(int i = 1; i <= n; ++i)
		cin >> x[i] >> y[i];

	cout << solve() << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i,H) cin >> a[i];

    vector<int> cnt(30,0);
    rep(i,H) rep(j,W) cnt[a[i][j]-'a']++;

    int one=0,two=0;
    if(H%2==1) two += W;
    if(W%2==1) two += H;

    if(H%2==1 and W%2==1){
        one = 1;
        two -= 2;
    }

    two /= 2;

    for(int i=0;i<30;i++) if(cnt[i]){
        if(cnt[i]%4==0) continue;
        else if(cnt[i]%2==0){
            two--;
        }
        else{
            one--;
        }
    }
    if(two<0 or one<0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;
typedef long long int lli;
#define repeat(i, n) for(int (i)=0; (i)<(n); (i)++)

int main(){
	int n;
	cin >> n;
	lli ans = 0;
	vector<int> t, s;
	bool rem = false;
	repeat(i, n){
		lli a,b;
		cin >> a >> b;
		if(a < b){
			ans += b;
			rem = true;
		}else if(a == b){
			s.push_back(b);
		}else{
			t.push_back(b);
		}
	}
	
	
	if(rem){
		repeat(i, (int)s.size()){
			ans += s[i];
		}
	}
	sort(t.begin(), t.end());
	if(!t.empty()){
		for(int i=1; i<(int)t.size(); i++){
			ans += t[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
from collections import deque
N,M = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
hist = [0 for _ in range(N+1)]
cnt = 1
for i in range(1,N+1):
    if hist[i]==0:
        que = deque([i])
        hist[i]=cnt
        while que:
            x = que.popleft()
            for y in G[x]:
                if hist[y]==0:
                    que.append(y)
                    hist[y] = cnt
        cnt += 1
C = {}
for i in range(1,N+1):
    c = hist[i]
    if c not in C:
        C[c] = 0
    C[c] += 1
cmax = 0
for c in C:
    cmax = max(cmax,C[c])
print(cmax)

Measured memory_bytes: 122444
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 510
using namespace std;
int read(){
	int nm=0,fh=1; int cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
char ch[M][M]; int n,m;
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++) scanf("%s",ch[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(ch[i][j]=='#') putchar('#');
			else if(i==1||(i<n&&(j&1))) putchar('#');
			else putchar('.');
		} putchar('\n');
	} putchar('\n');
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(ch[i][j]=='#') putchar('#');
			else if(i==n||(i>1&&!(j&1))) putchar('#');
			else putchar('.');
		} putchar('\n');
	}
	return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

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

void solve() {
    int N;
    cin >> N;
    vector<ll> T(N);
    REP(i, N) cin >> T[i];

    ll lcm = T[0];
    for (int i = 1; i < N; i++) {
        ll tmp = T[i] / gcd(T[i], lcm);
        lcm = tmp * lcm;
    }
    print(lcm);
}

signed main() {
    solve();
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#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 int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;

int main() {
	FAST;
	
	int n,k;
	cin >> n >> k;
	int res = (n-1)%(k-1)? (n-1)/(k-1)+1:(n-1)/(k-1);
	cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(l[j] == l[i]) continue;
            for(int k=j+1;k<n;k++){
                if(l[k] == l[i] || l[k] == l[j]) continue;
                if(l[k] < l[i]+l[j]) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll x, y;
  cin >> x >> y;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  //cout << n << "\n";
  
  cout << ( x%y==0 ?-1 :x) << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int mod=1e9+7;
int n,x,a,b,c;
ll ans=1;
int main(){
	cin>>n;
	a=b=c=0;
	for(int i=1;i<=n;i++){
		cin>>x;
		ll tmp=0;
		if(x==a)tmp++;
		if(x==b)tmp++;
		if(x==c)tmp++;
		ans*=tmp;ans%=mod; 
		if(x==a)a++;
		else if(x==b)b++;
		else if(x==c)c++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  string s; cin >> s;
  vector<vector<ll>> nxt(n+1, vector<ll>(10, n+1));
  rep(i, n) {
    nxt[i][s[i]-'0'] = i+1;
  }
  rrep(i, n) rep(j, 10) chmin(nxt[i][j], nxt[i+1][j]);
  ll ans = 0;
  rep(a, 10) rep(b, 10) rep(c, 10) {
    ll pos = 0;
    if (nxt[pos][a] == n+1) continue;
    pos = nxt[pos][a];
    if (nxt[pos][b] == n+1) continue;
    pos = nxt[pos][b];
    if (nxt[pos][c] == n+1) continue;
    pos = nxt[pos][c];
    ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3840
def solve(n, s):
    rlist, glist, blist = [0 for _ in range(n)], [0 for _ in range(n)], [0 for _ in range(n)]
    rcount, gcount, bcount = 0, 0, 0
    for i in range(n-1):
        if s[n-1-i] == 'R':
            rcount += 1
        if s[n-1-i] == 'G':
            gcount += 1
        if s[n-1-i] == 'B':
            bcount += 1
        rlist[n-2-i], glist[n-2-i], blist[n-2-i] = rcount, gcount, bcount
        
    ans = 0

    for i in range(n-2):
        for j in range(i+1,n-1):
            if s[i] != s[j]:
                if s[i] == 'R':
                    if s[j] == 'G':
                        ans += blist[j] - ( 1 if 2*j-i < n and s[2*j-i] == 'B' else 0)
                    else:
                        ans += glist[j] - (1 if 2*j-i < n and s[2*j-i] == 'G' else 0)
                elif s[i] == 'G':
                    if s[j] == 'R':
                        ans += blist[j] - (1 if 2*j-i < n and s[2*j-i] == 'B' else 0)
                    else:
                        ans += rlist[j] - (1 if 2*j-i < n and s[2*j-i] == 'R' else 0)
                else:
                    if s[j] == 'G':
                        ans += rlist[j] - (1 if 2*j-i < n and s[2*j-i] == 'R' else 0)
                    else:
                        ans += glist[j] - (1 if 2*j-i < n and s[2*j-i] == 'G' else 0)
    
    return ans

def main():
    n = int(input())
    s = input()
    print(solve(n, s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 69240
#include <iostream>
#include <cstdint>

using Int = std::int64_t;

int main() {
	int m;
	std::cin >> m;

	Int s = 0, w = 0;
	for (int i = 0; i < m; ++i) {
		Int d, c;
		std::cin >> d >> c;

		w += c;
		s += d * c;
	}

	std::cout << w - 1 + (s - 1) / 9 << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++) 
using namespace std;
typedef long long ll;

ll A,B;
string a,b;
int main() {
    ios::sync_with_stdio(false);
    cin >> A;
    int ju = 0;
    FOR(i,1,9) FOR(j,1,9) if (i*j == A) ju = 1;
    if (ju == 1) cout << "Yes"; else cout <<"No";
	return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
fl = True
s = [a,b,c,d,e]
for i in range(len(s)):
    for j in range(len(s)):
        if j <= i:
            continue
        if s[j]-s[i] > k:
            fl = False
if fl:
    print("Yay!")
else :
    print(":(")

Measured memory_bytes: 3064
while True:
    N = int(input())
    if not N:
        break
    D = [[] for _ in range(30)]
    for i in range(N):
        for x in map(int, input().split()[1:]):
            D[x - 1].append(i)
    C = [1 << i for i in range(N)]
    for d in range(30):
        for i in D[d]:
            for j in D[d]:
                C[i] = C[i] | C[j]
        if any(x == (1 << N) - 1 for x in C):
            print(d + 1)
            break
    else:
        print(-1)

Measured memory_bytes: 7556
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int A,B;
int x[6];
int num[1000005];
int judge(int m){
	int k=5;
	while(k){////
		x[k]=m%10;
	    m/=10;
	    --k;
	}
	if(x[1]==x[5]&&x[2]==x[4]) return 1;
	else return 0;	
}
int main(){
	int all=0;
	for(int i=10000;i<=99999;i++){
		if(judge(i)) ++all;
		num[i]=all;
	}
	scanf("%d%d",&A,&B);
	printf("%d",num[B]-num[A-1]);
	return 0;
	
}

Measured memory_bytes: 512
#include <iostream>
 
using namespace std;
 
int main(){
	int x=10000;
	int input[x];
	int temp=1;
	int count=0;

	while(temp!=0){
		cin >> temp;
		input[count] = temp;
		++count;
	}

	for(int i; i<count-1; ++i){
		cout << "Case " << i+1 << ": " << input[i] << endl;
	}

}

Measured memory_bytes: 3104