akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <random>
#include <fstream> //iostreamのファイル入出力をサポート
#include <vector>
#include <algorithm>
#include <string>
#include <math.h> 
#include <time.h>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define rep(i,n) for (int i=0;i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define vs vector<string>
#define VI vector<int>
#define vi vector<int>
using namespace std;

int main(){
	int N,K,i,a,cnt;
	cin>>N>>K;

	vi I;
	
	rep(i,N){
		cin>>a;
		I.pb(a);
	}

	sort(all(I));

	cnt=0;
	rep(i,K){
		cnt+=I[N-i-1];
	}
	cout<<cnt<<endl;
   	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Jan  1 10:30:05 2019
ABC115C
@author: maezawa
"""

n, k = list(map(int, input().split()))
h = [0]*n
for i in range(n):
    h[i] = int(input())
    
h.sort()
ans = h[k-1] - h[0]
for i in range(n-k+1) :
    dh = h[i+k-1] - h[i]
    if ans > dh:
        ans = dh
print(ans)

Measured memory_bytes: 7472
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        while(true){
            int hight = sc.nextInt();
            int width = sc.nextInt();
            if(hight==0 && width==0){
                break;
            }
            for(int i=0;i<hight;i++){
                String draw = "";
                for(int j=0;j<width;j++){
                    if((i==0 || i==hight-1) || (j==0 || j==width-1)){
                        draw += "#";
                    } else {
                        draw += ".";
                    }
                }
                System.out.println(draw);
            }
            System.out.println("");
        }
        sc.close();
    }
}


Measured memory_bytes: 50064
#include<bits/stdc++.h>
#define   ll            long long int
#define   endl          "\n"
#define   vi            vector<int>
#define   vll           vector<ll>
#define   pb            push_back
#define   all(p)        p.begin(),p.end()
#define   F             first
#define   S             second
#define   mp            make_pair
#define   MOD           1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    int t=1;
 //   cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n==0)cout<<1<<endl;
        else if(n==1)cout<<0<<endl;

    }



return 0;
}





Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,Y;
  cin >> N >>Y;
  Y/=1000;
  int A,B,C;
  int Z=Y-N;
  if(Z<0){
    cout<<"-1 -1 -1"<<endl;
  }else if(Z==0){
    cout<<"0 0 "<<N<<endl;
  }else{
    int m=(2*Z+8)/9;
    int M=min(Y/5,Z/4);
    if(M<m){
      cout<<"-1 -1 -1"<<endl;
    }else{
      A=-4*m+Z;
      B=-2*Z+9*m;
      C=Y-5*m;
      cout<<A<<" "<<B<<" "<<C<<endl;
    }
  }
}


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

using namespace std;

typedef pair<int,bool> P;
typedef vector<P> Closure;

bool isupper(char ch){
	return 'A'<=ch&&ch<='Z';
}
int getNum(char ch){
	if(isupper(ch)) return ch-'A';
	else return ch-'a';
}

Closure cs[8080];
int cnt;

bool cmp(const Closure &c1,const Closure &c2){
	if(c1.size()!=c2.size()) return c1.size()<c2.size();
	return c1<c2;
}

char ch[3][3030];
int M;

int which[26];//1:true,0:false,-1:unknown
bool suc;

void input(){
	scanf("%d",&M);
	if(M==0) exit(0);
	for(int i=0;i<3;i++) scanf("%s",ch[i]);
}

void init(){
	for(int i=0;i<26;i++){
		which[i]=-1;
	}
	suc=false;
	cnt=0;
}

void get(){
	for(int i=0;i<3*M;i+=3){
		for(int stat=0;stat<8;stat++){
			Closure c;
			for(int j=0;j<3;j++){
				int a=(stat>>j)&1;
				char ch=::ch[j][i+1+a];
				P p=P(getNum(ch),!isupper(ch));
				c.push_back(p);
			}
			sort(c.begin(),c.end());
			c.erase(unique(c.begin(),c.end()),c.end());
			bool flg=false;
			for(int i=0;i+1<c.size();i++){
				if(c[i].first==c[i+1].first){
					flg=true;
				}
			}
			if(flg) continue;
	//		if(c[0].first==c[1].first||c[1].first==c[2].first){
	//			continue;
	//		}else{
			cs[cnt++]=c;
	//		}
		}
	}
	sort(cs,cs+cnt,cmp);
	cnt=unique(cs,cs+cnt)-cs;
}

void dfs(int id){
	if(cnt==id){
		suc=true;
		return;
	}
	Closure c=cs[id];
	bool changed[3]={0,0,0};
	for(int i=0;i<c.size();i++){
		int x=c[i].first;
		bool t=c[i].second;
		int num=t?1:0;
		if(which[x]!=-1&&which[x]!=t){
			continue;
		}
		if(which[x]==t){
			dfs(id+1);
			if(suc) return;
			else{
				for(int j=0;j<3;j++){
					if(changed[j]){
						which[c[j].first]=-1;
					}
				}
				return;
			}
		}
		changed[i]=true;
		which[x]=t;
		dfs(id+1);
		if(suc) return;
		which[x]=t^1;
	}
	for(int i=0;i<c.size();i++){
		if(changed[i]){
			which[c[i].first]=-1;
		}
	}
}

void output(){
	if(suc==false){
		printf("-1\n");
	}else{
		int num=0;
		for(int i=0;i<26;i++){
			if(which[i]==1) num++;
		}
		printf("%d",num);
		for(int i=0;i<26;i++){
			if(which[i]==1) printf(" %c",'A'+i);
		}
		printf("\n");
	}
}

void solve(){
	dfs(0);
	output();
}

int main(){
	while(true){
		input();
		init();
		get();
		solve();
	/*	for(int i=0;i<cnt;i++){
			printf("(");
			for(int j=0;j<cs[i].size();j++){
				printf("%c %c",'a'+cs[i][j].first,cs[i][j].second?'t':'f');
				printf(" ");
			}
			printf(")");
			printf("\n");
		}
		printf("\n");*/
	}
	return 0;
}

Measured memory_bytes: 2184
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int L;
LL A[200111];

LL dp[200111][3];

void MAIN() {
    scanf("%d", &L);
    REP (i, L) scanf("%lld", A+i);

    LL sum = 0;
    REP (i, L) sum += A[i];

    memset(dp, 0xc0, sizeof dp);

    REP (i, L) {
	if (A[i] == 0) {
	    REP (a, 3) REP (b, a+1) {
		amax(dp[i+1][a], dp[i][b] - (a == 1 ? 1 : 2));
	    }
	} else if (A[i] % 2 == 0) {
	    REP (a, 3) REP (b, a+1) {
		amax(dp[i+1][a], dp[i][b] + A[i] - (a == 1 ? 1 : 0));
	    }
	    REP (a, 3) {
		amax(dp[i+1][a], A[i] - (a==1? 1: 0));
	    }
	} else {
	    REP (a, 3) REP (b, a+1) {
		amax(dp[i+1][a], dp[i][b] + A[i] - (a == 1 ? 0 : 1));
	    }
	    REP (a, 3) {
		amax(dp[i+1][a], A[i] - (a==1? 0: 1));
	    }
	}
    }

    LL ans = sum;
    REP (i, L+1) REP (a, 3) amin(ans, sum - dp[i][a]);
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;


// Union-Find

#define MAX_N 200001

long long par[MAX_N]; // 親
long long rankuf[MAX_N]; // 木の深さ
// n要素で初期化
void init(long long n) {
	for (long long i = 0; i < n; i++) {
		par[i] = i;
    rankuf[i] = 0;
	}
}
// 木の根を求める
long long find(long long x) {
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}
// xとyの属する集合を併合
void unite(long long x, long long y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (rankuf[x] < rankuf[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (rankuf[x] == rankuf[y]) rankuf[x]++;
	}
}
// xとyが同じ集合に属するか否か
bool same(long long x, long long y) {
	return find(x) == find(y);
}

int main(){	
	long long W;
	long long H;
	scanf("%lld",&H);
	vector<string> S(H-1+1);
	scanf("%lld",&W);
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> S[i];
	}
	init(H*W);
	rep(i, H) {
		rep(j, W) {
			if(i-1 >= 0 && S[i][j] != S[i-1][j]) unite(i*W+j, (i-1)*W+j);
			if(i+1 < H && S[i][j] != S[i+1][j]) unite(i*W+j, (i+1)*W+j);
			if(j-1 >= 0 && S[i][j] != S[i][j-1]) unite(i*W+j, i*W+j-1);
			if(j+1 < W && S[i][j] != S[i][j+1]) unite(i*W+j, i*W+j+1);
		}
	}

	vector<ll> b(H*W), w(H*W);
	rep(i, H) {
		rep(j, W) {
			if (S[i][j] == '#') b[find(i*W+j)]++; else w[find(i*W+j)]++;
		}
	}

	ll res = 0;
	rep(i, H*W) {
		res += b[i]*w[i];
	}

	cout << res << endl;

	return 0;
}



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

int main(){
    int n;
    cin >> n;
    int h[100001];
    rep(i, n){
        cin >> h[i];
    }
    int dp[100001];
    dp[0]=0;
    for(int i=1; i<n; i++){
        if(i==1){
            int cost = dp[0];
            dp[i] = cost + abs(h[i] - h[0]);
        }else{
            int c1 = dp[i-1];
            int c2 = dp[i-2];
            dp[i] = min(c1 + abs(h[i] - h[i-1]), c2 + abs(h[i] - h[i-2]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    int n;cin>>n;
    int colors[9];
    std::fill_n(colors,9,0);
    fore(i,0,n){
        int val;cin>>val;
        int ref = val/400>8?8:val/400;
        colors[ref]++;
    }
    int max = 0;
    int min = 0;

    fore(i,0,8){
        if(colors[i]>0){
            min++;
            max++;
        }
    }
    if(min==0 && colors[8]>0){
        min = 1;
    }
    max += colors[8];
    cout<<min<<" "<<max;    
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];

        for (int i=0;i<n;i++){
            a[i]=sc.nextLong();
        }
        int ans = 0;
        for (int i=0;i<n;i++){
            while (i+1<n&&a[i]==a[i+1])i++;
            if (i+1<n&&a[i]<a[i+1]){
                while (i+1<n&&a[i]<=a[i+1])i++;
            }else if (i+1<n&&a[i]>a[i+1]){
                while (i+1<n&&a[i]>=a[i+1])i++;
            }
            ans++;
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 60364
#include<bits/stdc++.h>
using namespace std;
int n, m, k, t, s[12], p[12], ans;

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++){
        scanf("%d", &k);
        for(int j = 0; j < k; j++){
            scanf("%d", &t);
            s[i] ^= 1<<(t-1);
        }
    }
    for(int i = 0; i < m; i++) scanf("%d", p+i);
    for(int i = 0; i < 1<<n; i++){
        int ok = true;
        for(int j = 0; j < m; j++){
            bool cnt = false;
            for(int k = 0; k < n; k++) if((i&s[j])>>k&1) cnt ^= true;
            if(cnt != p[j]) ok = false;
        }
        if(ok) ans++;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define ones(n) __builtin_popcount(n)
#define ONES(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 100005, M = 102, mod = 998244353, mxLog = 20;

vector<int> adj[N];
int memo[N];
int solve(int u) {
    if (memo[u])
        return memo[u];
    int ret = 0;
    for (int v : adj[u]) {
        ret = max(ret, solve(v));
    }
//    cout << u << ' ' << ret << endl;
    return memo[u] = ret + 1;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(7), cout << fixed;

    int n, m;
    cin >> n >> m;
    int u , v;
    for (int i = 0; i < m; ++i) {
        cin >> u >> v;
        adj[u].push_back(v);
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (!memo[i]) {
            ans = max(ans, solve(i));
        }
//        cout << ans << '\n';
    }

    cout << ans - 1 << '\n';

    return 0;
}

Measured memory_bytes: 8192
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

A, B, Q = mi()

S = [ii() for _ in range(A)]
T = [ii() for _ in range(B)]

S_ = [S[0]] + S + [S[A-1]]
T_ = [T[0]] + T + [T[B-1]]

for _ in range(Q):
    f = ii()
    to_s = bisect.bisect_left(S, f)
    to_t = bisect.bisect_left(T, f)
    #ans_1 = ans_2 = 0
    #print(to_s, to_t)

    #ans_1 += abs(S_[to_s+1] - f)
    #ans_2 += abs(f - S_[to_s])
    #print(ans_1, ans_2)

    #ans_1 = min(ans_1 + abs(S_[to_s+1] - T_[to_t+1]), ans_1 + abs(S_[to_s+1] - T_[to_t]))
    #ans_2 = min(ans_2 + abs(S_[to_s] - T_[to_t+1]), ans_2 + abs(S_[to_s] - T_[to_t]))

    ans = min(abs(S_[to_s+1] - f) + abs(S_[to_s+1] - T_[to_t+1]), float('inf'))
    ans = min(abs(S_[to_s+1] - T_[to_t+1]) + abs(f- T_[to_t+1]), ans)
    ans = min(abs(S_[to_s+1] - f) + abs(S_[to_s+1] - T_[to_t]), ans)
    ans = min(abs(S_[to_s+1] - T_[to_t]) + abs(f- T_[to_t]), ans)
    ans = min(abs(S_[to_s] - f) + abs(S_[to_s] - T_[to_t+1]), ans)
    ans = min(abs(S_[to_s] - T_[to_t+1]) + abs(f- T_[to_t+1]), ans)
    ans = min(abs(S_[to_s] - f) + abs(S_[to_s] - T_[to_t]), ans)
    ans = min(abs(S_[to_s] - T_[to_t]) + abs(f- T_[to_t]), ans)
    print(ans)


Measured memory_bytes: 16160
S, T = [input() for _ in range(2)]

answer = float("inf")

for i in range(len(S) - len(T) + 1):
	k = 0
	S_subset = S[i:i + len(T)]
	for t, s in zip(T, S_subset):
		if t != s:
			k += 1
	answer = min(answer, k)
print(answer)

Measured memory_bytes: 8992
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")



ll key(int i, int j) {
	return ((ll)(max(i, j)) << 32) | (ll)(min(i, j));
}
struct node {
	int state;
	int d;
	vector<ll> to;
};
unordered_map<ll, node> mp;
vector<ll> t;
int N;
bool dag = true;
void visit(ll k) {
	if (mp[k].state == 1) {
		dag = false;
		return;
	}
	else if (mp[k].state == 0) {
		mp[k].state = 1;
		for (ll& ck : mp[k].to) visit(ck);
		mp[k].state = 2;
		t.push_back(k);
	}
}
int main() {
	cin >> N;
	REP(i, 0, N - 1)REP(j, i + 1, N)mp.insert(pair<ll, node>(key(i, j), node{ 0 ,0 }));
	REP(i, 0, N) {
		vector<int> a(N - 1);
		REP(j, 0, N - 1) cin >> a[j];
		REP(j, 0, N - 2)mp[key(i, a[j]-1)].to.push_back(key(i, a[j + 1]-1));
	}
	for (auto p : mp) {
		if (p.second.state == 0) visit(p.first);
	}
	if (!dag) {
		PRI(-1);
		return 0;
	}
	int ans = 0;
	for (ll& k : t) {
		for (ll ck : mp[k].to) {
			mp[k].d = max(mp[k].d, mp[ck].d + 1);
			ans = max(ans, mp[k].d);
		}
	}
	PRI(ans+1);
	return 0;
}




Measured memory_bytes: 60340
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  int a[3][n];

  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
    sort(a[i], a[i] + n);
  }
  int i = 0, k = 0;  // A, B, Cはsortされているのでi, kはfor文内で初期化しなくてよい
  long long ans = 0;
  for(int j = 0; j < n; j++) {
    while(a[0][i] < a[1][j] && i < n) {
      i++;
    }
    while(a[1][j] >= a[2][k] && k < n) {
      k++;
    }
    ans += (long long) i * (n - k);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

int main(void){
 
  ll n;
  cin >> n;
  cout << 10 - (n/200) << endl;
  return 0;
}


Measured memory_bytes: 3628
while true
        input = STDIN.gets.split(' ')
        h = input[0].to_i
        w = input[1].to_i

        break if (h == 0 && w == 0)

        h.times {|i|
                w.times {|j|
                        if i.even? then
                                print "#" if j.even?
                                print "." if j.odd?
                        else
                                print "." if j.even?
                                print "#" if j.odd?
                        end
                }
                print "\n"
        }
        print "\n"

end

Measured memory_bytes: 6100
//参加気分でさ

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	ll A, B;
	cin >> A >> B;

	int Asq = sqrt(A);
	int Bsq = sqrt(B);
	int AL[1000001] = {};
	AL[1] = 1;
	int BL[1000001] = {};
	BL[1] = 1;
	for (int i = 2; i <= Asq; i++) {
		while (A % i == 0) {
			A /= i;
			AL[i] = 1;
		}
	}
	if (A <= 1000000) AL[A] = 1;
	for (int i = 2; i <= Bsq; i++) {
		while (B % i == 0) {
			B /= i;
			BL[i] = 1;
		}
	}
	if (B <= 1000000) BL[B] = 1;

	int kotae = 0;
	rep1(i, 1000000) {
		if (AL[i] && BL[i]) {
			kotae++;
		}
	}
	if (A > 1000000 && B > 1000000 && A == B) kotae++;

	cout << kotae << endl;

	Would you please return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
int main() {
	long long n,m;
	cin >> n >> m;
	cout << 3LL * (n-__gcd(n,m));
	return 0;
}


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

int main(void) {
    long long n;
    vector<long long> a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        long long tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    long long l[100010], r[100010];
    l[0] = r[n] = 0;
    for (int i = 1; i <= n; ++i) {
        l[i]     = __gcd(l[i - 1], a[i - 1]);
        r[n - i] = __gcd(r[n - i + 1], a[n - i]);
    }
    long long ans;
    ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, __gcd(l[i], r[i + 1]));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2676
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		
		for(int i=0; i<s.length(); i++){
		    if(s.equals(t)){
		        System.out.println("Yes");
		        return;
		    }else{
		        s = s.charAt(s.length()-1) + s.substring(0, s.length()-1);
		    }
		}
		
      	System.out.println("No");
    }
}

Measured memory_bytes: 38916
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, n) for (int i = 2; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
    Int N;
    cin >> N;
    vector<Int> A(N+1);
    rep2(i,N) cin >> A[i];

    vector<vector<int>> PS(N+1);

    rep2(i,N) {
        PS[A[i]].push_back(i);
    }

    rep1(i,N) {
        cout << PS[i].size() << endl;
    }



}


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

int main()
{
    string a;
    cin>>a;
    int d;
    d=a.length();
    if(a[d-1]=='2' || a[d-1]=='4' || a[d-1]=='5' ||a[d-1]=='7' ||a[d-1]=='9')
    {
        cout<<"hon\n";
    }
    else if(a[d-1]=='0' || a[d-1]=='1' ||a[d-1]=='6' ||a[d-1]=='8')
    {
        cout<<"pon\n";
    }
    else if(a[d-1]=='3')
    {
        cout<<"bon\n";
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int h,w;
    cin>>h>>w;
    char fi[h][w];
    rep(i,h) rep(j,w) cin>>fi[i][j];

    int cw[h][w];
    rep(i,h) rep(j,w) cw[i][j]=0;
    rep(i,h){
        int c=1;
        rep(j,w){
            if(fi[i][j]=='#') c=1;
            else{
                cw[i][j]=c;
                c++;
            }
        }
    }
    rep(i,h){
        for(int j=w-2;j>=0;j--){
            if(cw[i][j]==0) continue;
            if(cw[i][j+1]==0) continue;
            cw[i][j]=cw[i][j+1];
        }
    }
    int ch[h][w];
    rep(i,h) rep(j,w) ch[i][j]=0;
    rep(j,w){
        int c=1;
        rep(i,h){
            if(fi[i][j]=='#') c=1;
            else{
                ch[i][j]=c;
                c++;
            }
        }
    }
    rep(j,w){
        for(int i=h-2;i>=0;i--){
            if(ch[i][j]==0) continue;
            if(ch[i+1][j]==0) continue;
            ch[i][j]=ch[i+1][j];
        }
    }

    /*
    rep(i,h){
        rep(j,w){
            cout<<ch[i][j]<<" ";
        }
        cout<<endl;
    }*/

    int ans=0;
    rep(i,h){
        rep(j,w){
            ans=max(ans,ch[i][j]+cw[i][j]);         
        }
    }

    cout<<ans-1<<endl;
}


Measured memory_bytes: 38788
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < n; ++i)

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  if (x == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (n == 1) {
    cout << x << endl;
    return 0;
  }
  if (n == 2) {
    cout << x + x * x % m << endl;
    return 0;
  }

  ll y = x;
  vector<ll> used(m + 1);
  ll start = 0, end = 0;
  rep(i, 0, n) {
    used[x]++;
    end = x;
    x = x * x % m;
    if (used[x] == 1) {
      start = x;
      break;
    }
  }
  ll ans = 0;
  ll now = y;
  while (n > 0 && now != start) {
    ans += now;
    now = now * now % m;
    --n;
  }
  ll loop = 1;
  ll loop_sum = now;
  now = now * now % m;
  ll cnt = 1000000;
  while (cnt > 0 && now != start) {
    loop_sum += now;
    now = now * now % m;
    ++loop;
    --cnt;
  }

  if (n <= 0 || x == 0) {
    cout << ans << endl;
    return 0;
  }
  ans += n / loop * loop_sum;
  n %= loop;
  rep(i, 0, n) {
    ans += x;
    x = x * x % m;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
using namespace std;

int main(){
    int n, m, in;
    cin >> n >> m;

    rep(i, m){
        cin >> in;
        n -= in;
    }

    if(n<0) cout << "-1" << endl;
    else cout << n << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    string s;
    int a = 0;
    cin >> s;
    rep(i,3){
        if(s[i] == '1')a++;
    }
    cout << a << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;


int main()
{
    ll N, P;
    cin>>N>>P;

    ll ans = 1;

    if(N==1){
        cout<<P<<endl;
        return 0;

    }
    else if(P==1)
    {
        cout<<1<<endl;
        return 0;
    }

    for(ll i=2; i*i<=P; ++i)
    {
        ll count = 0;
        while(P%i==0)
        {
            count++;
            if(count==N)
            {
                ans*=i;
                count=0;
            }
            P/=i;

        }

    }

    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;

    int a,b,c,k;
    cin >> a >> b >> c >> k;

    int cur = k-a;
    if(cur <= 0){cout << k << endl; return 0;}
    int ans = 0;
    ans += a;

    cur = cur-b;
    if(cur <= 0){cout << ans << endl; return 0;}

    int cur2 = cur-c;
    if(cur2 <= c){cout << ans - cur << endl; return 0;}
    else cout << ans - c << endl;


    return 0;
}



Measured memory_bytes: 3496
N = gets.to_i

edges = Hash.new { |h, k| h[k] = [] }

list = []

(N - 1).times do
  a, b = gets.split.map(&:to_i) 

  list << [a, b]

  edges[a] << b
  edges[b] << a
end

root = 1

visited = Hash.new(false)
colors = Hash.new { |h, k| h[k] = {} }
cant_use = Hash.new { |h, k| h[k] = Hash.new(false) }

queue = [root]

until queue.empty?
  from = queue.shift

  next if visited[from]
  visited[from] = true

  c = 1

  edges[from].each do |to|
    next if visited[to]

    c += 1 while cant_use[from][c]

    colors[from][to] = c
    cant_use[to][c] = true
    c += 1
    queue << to
  end
end

ans = []
list.each do |a, b|
  ans << colors[a][b]
end

puts ans.max
puts ans


Measured memory_bytes: 84280
module ABC136

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_A
  
  contains
  
  subroutine task_A (volume_Container1_max, volume_Container1_contained, volume_Container2_contained)

    ! arguments for this <subroutine>
    integer(INT8), intent(in) :: volume_Container1_max
    integer(INT8), intent(in) :: volume_Container1_contained
    integer(INT8), intent(in) :: volume_Container2_contained

    ! variables for this <subroutine>
    integer(INT8) :: volume_Container1_receivable
    integer(INT8) :: volume_remained

    volume_Container1_receivable = volume_Container1_max - volume_Container1_contained

    if (volume_Container1_receivable .ge. volume_Container2_contained) then
      volume_remained = 0_INT8
    else
      volume_remained = volume_Container2_contained - volume_Container1_receivable
    end if

    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') volume_remained
    
    ! STEP.END
    return

  end subroutine task_A

end module ABC136

program main

  ! <module>s to import
  use,     intrinsic :: iso_fortran_env
  use, non_intrinsic :: ABC136

  ! variables for this <program>
  integer(INT8) :: A
  integer(INT8) :: B
  integer(INT8) :: C

  read(unit=INPUT_UNIT, fmt=*) A, B, C
  
  call task_A (A, B, C)

end program main

Measured memory_bytes: 256
n, m = map(int, input().split())
a = []
for i in range(n):
    a.append(list(input()))
b = []
for i in range(m):
    b.append(list(input()))
flag = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        flag2 = True
        for k in range(m):
            if b[k] != a[k + i][j:j + m]:
                flag2 = False
                break
        if flag2 == True:
            flag = True
            break
    if flag == True:
        break
if flag == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import math
x = 0
y = 0
degree = 0
while(True):
    a = map(int, raw_input().split(","))
    if(a[0] == 0 and a[1] == 0):
        break
    x += a[0] * math.sin(math.radians(degree))
    y += a[0] * math.cos(math.radians(degree))
    degree += a[1]
print(int(x))
print(int(y)) 

Measured memory_bytes: 4416
// Namori
// * frank_c1
// * 2017 / 12 / 18
 
#include <bits/stdc++.h>
using namespace std;

const int maxn = (int)(1e5) + 5;
vector<int> nxt[maxn];
int fa[maxn], dfn[maxn], siz[maxn], su[maxn];
int ci[maxn], cc[maxn], va[maxn];
int cnt, idx, S, T;

inline int iabs(int x) {
	return x >= 0 ? x : -x;
}

void dfs(int x, int f, int v) {
	fa[x] = f; dfn[x] = ++idx; 
	siz[x] = 1; su[x] = v; v ^= 1;
	for (int i = 0; i < (int)nxt[x].size(); ++i)
		if (nxt[x][i] != f) {
			if (!dfn[nxt[x][i]]) {
				dfs(nxt[x][i], x, v);
				su[x] += su[nxt[x][i]];
				siz[x] += siz[nxt[x][i]];
			} else if (dfn[nxt[x][i]] < dfn[x]) {
				int c = x, a = nxt[x][i]; 
				while (c != a) {
					ci[++cnt] = c; cc[c] = 1; c = fa[c];
				} ++cnt; S = x; T = a;
			}
		}
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		nxt[u].push_back(v); nxt[v].push_back(u);
	}
	dfs(1, 0, 0);
	if (!cnt || !(cnt & 1)) {
		if (2 * su[1] != siz[1]) {
			printf("-1\n"); return 0;
		}
	} else {
		if ((2 * su[1] - siz[1]) & 1) {
			printf("-1\n"); return 0;
		}
	}
	int dt = (2 * su[1] - siz[1]) / 2, ret = iabs(dt);
	if (cnt & 1) {
		while (S != T) {
			siz[S] += dt; cc[S] = 0; S = fa[S];
		}
		while (T) {
			siz[T] += dt * 2; T = fa[T];
		} 
	}
	for (int i = 1; i <= n; ++i) if (!cc[i]) ret += iabs(2 * su[i] - siz[i]);
	if (!(cnt & 1)) {
		for (int i = 1; i < cnt; ++i) va[i] = 2 * su[ci[i]] - siz[ci[i]];
		va[cnt] = 0; sort(va + 1, va + cnt + 1); ret += iabs(va[(cnt + 1) / 2]); 
		for (int i = 1; i < cnt; ++i) ret += iabs(va[(cnt + 1) / 2] - 2 * su[ci[i]] + siz[ci[i]]);
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;;
int main(){
  int N,Q;
  cin>>N>>Q;
  
  string S;
  vector<int>date(N);
  int sum=0;
  cin>>S;
  for(int i=0;i<N;i++){
   if(i==0){
     date[0]=0;
   }
    else{
      if(S[i-1]=='A'&&S[i]=='C'){
        sum++;
        date[i]=sum;
      }
      else{
        date[i]=sum;
      }
    }
  }
  
  vector<int>l(Q);
  vector<int>r(Q);
  
  for(int i=0;i<Q;i++){
    cin>>l[i]>>r[i];
  }
  
  for(int i=0;i<Q;i++){
      cout<<date[r[i]-1]-date[l[i]-1]<<endl;
 
 
  }

}


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


int main() {
  int N,Q;
  cin >> N >> Q;

  vector<vector<int>> G(N);

  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> add(N);
  for (int i = 0; i < Q; ++i) {
    int p, x;
    cin >> p >> x;
    add[--p] += x;
  }

  stack<int> st;
  st.push(0);
  
  vector<int> ans(N);
  vector<bool> vis(N);

  while (!st.empty()) {
    int now = st.top();
    vis[now] = true;
    st.pop();
    ans[now] += add[now];
    for ( int next : G[now] ) {
      if( vis[next] ) continue;
      ans[next] += ans[now];
      st.push(next);
    }
  }

  for (int i = 0; i < N; ++i) {
    cout << ans[i] << " ";
  }
} 


Measured memory_bytes: 16372
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<typename T> /*inline*/ bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> /*inline*/ bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
int MAX_N = 57;
int MAX_SUM = 8000;
int P = 5000;

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= K;
    }
    
    int dp[MAX_N][MAX_SUM] = {0};
    dp[0][P] = 1;
    for (int j = 0; j < N; j++) {
        for (int t = 0; t < MAX_SUM; t++) {
            if (0 <= t + A[j] && t + A[j] < MAX_SUM) {
                dp[j+1][t] = dp[j][t] + dp[j][t+A[j]];
            } else {
                dp[j+1][t] = dp[j][t];
            }
        }
    }
    cout << dp[N][P]-1 << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i;i<(int)n;i++)

using namespace std;

int main(){
  int n,m,ans;
  cin>>n>>m;
  if(n==0){
  ans=(int)m*(m-1)/2;
    cout<<ans<<endl;
    return 0;
  }
  if(m==0){
  ans=(int)n*(n-1)/2;
    cout<<ans<<endl;
    return 0;
  }
  ans=(int)(n+m)*(n+m-1)/2-n*m;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
   int a,b;
    cin>>a>>b;
    int ans=0;
    ans+=max(a,b);
    if(a>=b){
        a--;
    }else{
        b--;
    }
    ans+=max(a,b);
    cout<<ans<<endl;
    return 0;
}

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

void solve();

int main()
{
  solve();

  return 0;
}

void solve()
{

  long n;
  cin >> n;

  long ac = 0, wa = 0, tle = 0, re = 0;
  string s;

  for (long i = 0; i < n; i++)
  {
    cin >> s;
    if (s == "AC")
      ac++;
    if (s == "WA")
      wa++;
    if (s == "TLE")
      tle++;
    if (s == "RE")
      re++;
  }

  cout << "AC x " << ac << '\n';
  cout << "WA x " << wa << '\n';
  cout << "TLE x " << tle << '\n';
  cout << "RE x " << re << '\n';
}

Measured memory_bytes: 3632
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        for (int i = 0; i < s.length(); i++) {
            System.out.print(s.charAt(i));
            if(i < t.length()){
                System.out.print(t.charAt(i));
            }
        }
    }
}

class io{
    public static void br(){
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }

}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    string S;
    cin >> S;
    int B_count = 0;
    int W_count = 0;
    char next;
    rep(i, S.size()) {
        if (i == 0) {
            if (S[0] == 'B') {
                B_count++;
                next = 'B';
            }
            else {
                W_count++;
                next = 'W';
            }
            continue;
        }
        if (S[i] == next) {
            continue;
        }
        next = S[i];
        if (next == 'B') {
            B_count++;
        }
        else {
            W_count++;
        }
    }
    cout << B_count+W_count-1 << endl;
}

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

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

      Arrays.sort(arr);
      Deque<Long> deque = new LinkedList<>();
      for(long a : arr)
        deque.addLast(a);

      List<String> res = new ArrayList<>();
      while(deque.size() > 2) {
        long n1 = 0L;
        long n2 = 0L;
        String str = "";
        if(deque.peekFirst() >= 0) {
          n1 = deque.pollFirst();
          n2 = deque.pollFirst();
          deque.offerFirst(n1 - n2);
          str = n1 + " " + n2;
        } else if(deque.peekLast() <= 0) {
          n1 = deque.pollLast();
          n2 = deque.pollLast();
          deque.offerLast(n1 - n2);
          str = n1 + " " + n2;
        } else {
          n1 = deque.pollFirst();
          n2 = deque.pollLast();
          if(deque.peekFirst() < 0) {
            deque.offerLast(n2 - n1);
            str = n2 + " " + n1;
          } else {
            deque.offerFirst(n1 - n2);
            str = n1 + " " + n2;
          }
        }
        res.add(str);
      }
      long n1 = deque.pollFirst();
      long n2 = deque.pollLast();
      System.out.println(n2 - n1);
      res.add(n2 + " " + n1);
      for(String str : res)
        System.out.println(str);
  }
}

Measured memory_bytes: 67364
#include <bits/stdc++.h>
using namespace std;
int main(){
	int count=1;
	string S;
	cin>>S;
	vector<unordered_map<char,int>> mp((int)S.size());
	for(int i=0;i<(int)S.size();i++){
    	mp.at(i)[S.at(i)]=1;
    	if(i>0){
        	if(S.at(i-1)==S.at(i)){
            	count++;
            }
        }
    }
	if(count==(int)S.size()){
    	cout<<0<<endl;
    	return 0;
    }
	for(int i=1;i<(int)S.size();i++){
    	unordered_map<char,int> check;
    	for(int j=0;j<(int)S.size()-i;j++){
        	for(auto itr=mp.at(j+1).begin();itr!=mp.at(j+1).end();itr++){
            	mp.at(j)[itr->first]=1;
            }
        	for(auto itr=mp.at(j).begin();itr!=mp.at(j).end();itr++){
            	check[itr->first]++;
            }
        }
    	for(auto itr=check.begin();itr!=check.end();itr++){
        	if(itr->second==(int)S.size()-i){
            	cout<<i<<endl;
            	return 0;
            }
        }
    	check.clear();
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long sum=0;
	string a,b;
	double z;
	cin>>a>>b;
	a+=b;
	int len=a.size(),d; 

	for(int i=0;i<len;i++){
		sum+=(a[i]-'0')*pow(10,len-1-i);
	}
	d=sqrt(sum);
	z=sqrt(sum);
	if(d==z){
		cout<<"Yes";	
	}
	else{
		cout<<"No"<<endl;	
	}
	return 0;
  }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long N, X,sum;
    while(1){
    sum = 0;
     cin >> N >> X;
     if(N == 0 && X == 0)break;
     for (int i = 1; i < N+1; i++){
        for (int j = i+1; j < N+1; j++){
            for (int k = j+1; k < N+1; k++){
                if (i + j + k == X)sum++;
            }
        }
     }
     cout << sum << endl;
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1005
struct node{
    ll x,y;
    node(ll r_x=0,ll r_y=0) {x=r_x,y=r_y;}
}p[M];
int n,tp=-1;
ll s[M];
int cnt;
ll dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
char ss[4]={'L','U','R','D'};
void work() {
    for(int i=30;i>=0;i--) s[++cnt]=1ll<<i;
    if(tp==0) s[++cnt]=1;
    cout<<cnt<<'\n';
    for(int i=1;i<=cnt;i++) cout<<s[i]<<' ';
    cout<<'\n';
    for(int i=1;i<=n;i++)
	{
	    ll x=0,y=0;
	    for(int j=1;j<=cnt;j++)
		{
		    ll tx,ty,ax,ay,mn=1e18;
	        int cho;
		    for(int t=0;t<4;t++)
			{
			    tx=x+dx[t]*s[j],ty=y+dy[t]*s[j];
			    if(abs(tx-p[i].x)+abs(ty-p[i].y)<mn)
				{
				    mn=abs(tx-p[i].x)+abs(ty-p[i].y);
				    ax=tx,ay=ty;
				    cho=t;
				}
			}
		    cout<<ss[cho];
		    x=ax,y=ay;
		}
	    cout<<'\n';
	}
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
	{
	    cin>>p[i].x>>p[i].y;
	    if(tp==-1) tp=(abs(p[i].x)+abs(p[i].y))&1;
	    else if(tp!=((abs(p[i].x)+abs(p[i].y))&1)) {tp=2;break ;}
	}
    if(tp==2) cout<<-1<<'\n';
    else work();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

constexpr int MAX_N = 100003;
constexpr ll mod = 1e9 + 7;

ll powm(ll x, ll p) {
	if (p == 0) return 1;
	ll res = powm(x, p / 2);
	res *= res;
	res %= mod;
	if (p % 2LL == 1) {
		res *= x;
		res %= mod;
	}
	return res;
}



int main() {
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<ll> ac(n + 2);
	for (int i = 1; i <= n; i++) {
		ac[i] = (ac[i - 1] + powm(i, mod - 2)) % mod;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll coef = ac[i + 1] + ac[n - i] - ac[1];
		ans += coef*a[i] % mod;
		ans %= mod;
	}
	ll fact = 1;
	for (ll i = 2; i <= n; i++) fact = (fact*i) % mod;
	cout << fact*ans % mod << endl;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc147_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int count = 0;

            for (int i = 0; i < S.Length / 2; i++)
            {
                if (S[i] != S[S.Length -i -1]) 
                {
                    count++;
                }
            }

            Console.WriteLine(count);
            Console.Read();
        }

    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <math.h>
using namespace std;
int F(int a) {
	int cnt = 0;
	for (int i = 1;i <=a;i++) {
		if (a%i == 0) {
			cnt++;
		}
	}

	return cnt;
}

int main() {
	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 1;i <= N;i+=2) {
		if (F(i) == 8) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

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

#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

struct data{
    int vx,vy,x0,y0;
    data(int a,int b,int c,int d){
        int g=gcd(abs(a),abs(b));
        a/=g;b/=g;
        if(a<0)a*=-1,b*=-1;
        else if(a==0&&b<0)b*=-1;
        vx=a;vy=b;x0=c;y0=d;
    }
    bool operator==(const data &d){
        if(vx!=d.vx||vy!=d.vy)return false;
        int xx=x0-d.x0,yy=y0-d.y0;
        if(vx==0)return xx==0;
        if(vy==0)return yy==0;
        return xx%vx==0&&yy%vy==0&&xx/vx==yy/vy;
    }
};

int N;
int x[10],y[10];

int table[10][10];

int p[]={1,2,3,4,5,6,7,8};
vint lis;
bool f[100];
int ans=1145141919;

void dfs(int n,int c){
    if(n==N-1){
        chmin(ans,c);
        return;
    }

    int idx=p[n];
    rep(i,lis.size()){
        int tmp=table[lis[i]][idx];
        lis.pb(idx);
        if(f[tmp])dfs(n+1,c);
        else{
            f[tmp]=1;
            dfs(n+1,c+1);
            f[tmp]=0;
        }
        lis.pop_back();
    }
}

signed main(){
    cin>>N;
    rep(i,N)cin>>x[i]>>y[i],x[i]*=2,y[i]*=2;

    vector<data>vec;
    rep(i,N)rep(j,N)if(i!=j){
        data d(y[j]-y[i],x[i]-x[j],(x[i]+x[j])/2,(y[i]+y[j])/2);
        int t=-1;
        rep(k,vec.size())if(vec[k]==d)t=k;
        if(t==-1){
            table[i][j]=vec.size();
            vec.pb(d);
        }
        else{
            table[i][j]=t;
        }
    }

    do{
        lis.clear();
        lis.pb(0);
        dfs(0,0);
    }while(next_permutation(p,p+N-1));

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1220
# -*- coding: utf-8 -*-
n = int(input())
sp = []
for i in range(n):
    sp.append([str(i) for i in input().split()])

tmp = []
city = [''] * n
for i in range(n):
    tmp.append([sp[i][0], 100 - int(sp[i][1]), i+1])
    city[i] = sp[i][0]
#print(tmp)
tmp.sort()
#print(tmp)
for i in range(n):
    print(tmp[i][2])

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define SORT(V) sort((V).begin(),(V).end())
#define ll long long

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long K;
  scanf("%lld",&K);
  ll result = 0;
  if(A<=K) {
    if(B>=K-A) {
      result = A;
    } else {
      result = A - (K-A-B);
    }
  } else {
    result=K;
  }
  cout<<result<<endl;
  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector<int> a;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }

  sort(a.begin(), a.end());

  int mx = 0;
  for(int i = a[0]; i <= a[n - 1]; i++) {
    vector<int>::iterator ulim = upper_bound(a.begin(), a.end(), i + 1);
    vector<int>::iterator dlim = lower_bound(a.begin(), a.end(), i - 1);
    mx = max(mx, (int)(ulim - dlim));
  }

  cout << mx << endl;
}

Measured memory_bytes: 892
loop do
	n = gets.to_i
	break if n.zero?

	dataset = Hash.new
	dataset.default = 0
	
	n.times do
		id, selling_price, quantity = gets.chomp.split.map(&:to_i)
		dataset[id] += selling_price * quantity
	end
	
	satisfying_id = dataset.select{|id, sales| sales >= 1000000 }.keys
	
	puts (satisfying_id.empty? ? "NA" : satisfying_id)
end

Measured memory_bytes: 6108