akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    for(int i=1; i<=3000; i++){
        cin>>a>>b;
        if(a==0 && b==0){
            break;
        }
        else if(a>b){
            swap(a,b);
        }
        cout<<a<<" "<<b<<endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
template<class T> using vv=vector< vector<T> >;
typedef deque<int> di;
typedef deque< deque<int> > ddi;


int main() {
    vi V;
    FOR(i,2,10008) {
        V.pb(i);
    }
    rep(i,V.size()) {
        int v = V.at(i);
        for(int j = V.size() -1;j > i; j--) {
            if(V.at(j) % v == 0) V.erase(V.begin()+j);
        }
    }
    while(1) {
        int count = 0;
        int i=0;
        queue<int> Q; 
        int sum = 0;
        int A;
        cin >> A;
        if(A == 0) {
            break;
        }
        while(1) {
            if(sum == A) {
                count += 1;
                sum += V[i];
                Q.push(V[i++]);
            } else if(sum > A) {
                if(Q.size() == 1){
                    break;
                } else {
                    sum -= Q.front();
                    Q.pop();
                }
            } else {
                sum += V[i];
                Q.push(V[i++]);
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >>a;
  for(int i=0 ;i<3;i++){
    if(a.at(i) =='1'){
      a.at(i)='9';
    }
    else{
      a.at(i)='1';
    }
  }
  cout <<a <<endl;
}

Measured memory_bytes: 256
using System;

class InsertionSort
{
	static void Main()
	{
		int amount = int.Parse(Console.ReadLine().Replace("\n", ""));
		string[] itemString = Console.ReadLine().Replace("\n", "").Split(' ');
		int[] items = new int[amount];
		for (int i=0; i<amount; i++)
		{
			items[i] = int.Parse(itemString[i]);
		}
		Output(amount, items);
		for (int i=0; i<amount-1; i++)
		{
			if (items[i]>items[i+1])
			{
				for (int num=i; num>=0; num--)
				{
					if (items[num] > items[num+1])
					{
						int temp = items[num];
						items[num] = items[num+1];
						items[num+1] = temp;
					}
				}
			}
			Output(amount, items);
		}
	}

	static void Output(int amount, int[] items)
	{
		string output = "";
		for (int r=0; r<amount; r++)
		{
			if (r<amount-1)
			{
				output += items[r].ToString()+" ";
			}
			else
			{
				output += items[r].ToString();
			}
		}
		Console.WriteLine(output);
	}
}

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

int main(){
  int n,k;cin>>n>>k;
  int x,d=0;
  for(int i=0;i<n;i++){
    cin>>x;
    d+=(x<=k-x?2*x:2*(k-x));
  }
  cout<<d<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define pii pair<int,int>
#define fr(j,n) for(int j=0;j<n;j++)
#define f(n) for(int i=0;i<n;i++)
#define rt return 0;
#define sc second
#define fi first
#define i(n) int n;cin>>n;
#define pb(i) push_back(i);
#define rt return 0;
#define sz(a) a.size()
#define all(v) v.begin(),v.end()
#define ff(i,in,fi) for(int i=in;i<fi;i++)
//#define df int n;cin>>n;int a[n];fr(n){cin>>a[i];}5 8 7 14 55 19 9 2
using namespace std;
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define invect(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define ll long long int
#define p(s) cout<<#s<<":"<<s<<'\n';
#define here(n) cout<<"here"<<n<<endl;
#define ios         ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
map<int,int> ma;
std::vector<int> v;

void solve()
{
	int n;
	cin>>n;
	cout<<n*n*n;


}
signed main(){
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


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

int main() {
  ll a,b,c; cin >> a >> b >> c;
  if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a)) cout << "Yes" << endl;
  else cout << "No" << endl;
    
    
  
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

struct UnionFind {
  vector<int> par; // 親
  vector<int> siz; // サイズ
 
  UnionFind(int n) {
    par = vector<int>(n);
    siz = vector<int>(n, 1);
    rep(i, n) {
      par[i] = i;
    }
  }
 
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
  }
 
  int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  ll n,m;
  cin>>n>>m;
  vector<pair<int, int>> v(m);
  rep(i, m) {
    int a,b;
    cin>>a>>b;
    a--; b--;
    v[i] = {a, b};
  }
  UnionFind uf(n);
  vector<ll> ans;
  // 橋が存在しないときの不便さ
  ll cur = n * (n - 1) / 2;
  // 逆順に橋を架けていく
  for(int i = m - 1; i >= 0; i--) {
    ans.push_back(cur);
    if (uf.same(v[i].first, v[i].second)) {
      // 既に繋がっているなら不便さは変わらない
    } else {
      cur -= uf.size(v[i].first) * uf.size(v[i].second);
      uf.unite(v[i].first, v[i].second);
    }
  }
  reverse(ans.begin(), ans.end());
  for(ll x : ans) {
    cout << x << endl;
  }
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; ++ i)
#define FOR(i,a,b) for (int i = a; i <= b; ++ i)
#define FORD(i,b,a) for (int i = b; i >= a; -- i)
#define task ""
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef vector<int> vi;

const int N = 1e5 + 5;
int lab[N], f[N], g[N];
int n, m, idx, res;
vector<int> adj[N];
void dfs(int u) {
    f[u] = idx; g[lab[u]] = idx;
    REP(j, (int) adj[u].size()) {
        int v = adj[u][j];
        if (!f[v]) dfs(v);
    }
}
int main() {
    //freopen(task".inp", "r", stdin);
    //freopen(task".out", "w", stdout);
    scanf("%d%d", &n, &m);
    FOR(i, 1, n) scanf("%d", &lab[i]);
    FOR(i, 1, m) {
        int u, v;
        scanf("%d%d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    FOR(i, 1, n) if (!f[i]) {
        idx ++;
        dfs(i);
    }
    FOR(i, 1, n) res += (f[i] == g[i]);
    printf("%d", res);
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N, H;
    cin >> N >> H;

    vector<Pll> A(N), B(N);
    for (ll i = 0; i < N; i++) {
        ll ai, bi;
        cin >> ai >> bi;
        A[i] = make_pair(ai, i);
        B[i] = make_pair(bi, i);
    }

    sort(A.begin(), A.end(), greater<Pll>());
    sort(B.begin(), B.end(), greater<Pll>());

    ll ans = (H + A[0].first - 1) / A[0].first;

    ll b_sum = 0;
    for (ll i = 0; i < N; i++) {
        ll bi, b_idx;
        tie(bi, b_idx) = B[i];

        b_sum += bi;

        ll t = (H - b_sum + A[0].first - 1) / A[0].first;
        t = max(t, 0LL);

        ans = min(ans, t + i + 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
char s[100010];
int len;
vector<int> v;


int main()
{
	int i,j;
	
	scanf("%s",s);
	len = strlen(s);
	for(i=0;i<len;i++)
	{
		v.push_back(s[i]-'a');
	}
	
	int idx=0,turn=1;
	while(1)
	{
	//	printf("a");
		if(idx!=0 && idx!=len-1)
		{
			if(v[idx-1] != v[idx+1])
			{
				v.erase(v.begin()+idx);
		//		printf("remove idx = %d\n",idx);
				len--;
		//		for(i=0;i<len;i++)
		//		{
		//			printf("%c",v[i]+'a');				
		//		}
		//		printf("\n");
				turn *= -1;
				idx -= 2;
				if(idx<0) idx = 0;
			}
		}
		else if(idx==len-1)
		{
			break;
			idx=0;
		}
		else
		{
			if(len<=2)
			{
				break;
			}
		}
		idx++;
	}
	
	if(turn==-1) printf("First\n");
	else if(turn == 1) printf("Second\n");
}

Measured memory_bytes: 3988
#include <iostream>
    using namespace std;
     
    int main() {
    	int a,b,c;
      	cin >> a >> b >> c;
    	if ((10*b+c)%4 == 0) {
    		cout << "YES" << endl;
    	} else {
    		cout << "NO" << endl;
    	}
    }

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N, C; cin >> N >> C;
    vector<pair<int, int>> prog[C+1];
    rep(i, N){
        int s, t; int c; cin >> s >> t >> c;
        pair<int, int> temp = make_pair(s, t);
        prog[c].push_back(temp);
    }
    rep(i, C+1) sort(prog[i].begin(), prog[i].end());
    vector<pair<int, int>> kakutei_prog;
    rep(i, C+1){
        //prog[i]の中身を連結する
        int s = 0;
        int t = 0;
        while(t < prog[i].size()){
            while(t < prog[i].size()-1 && prog[i][t].second == prog[i][t+1].first) t++;
            //sからtの番組までは連結
            kakutei_prog.push_back(make_pair(prog[i][s].first, prog[i][t].second));
            t++; s = t;
        }
    }
    sort(kakutei_prog.begin(), kakutei_prog.end());
    /*rep(i, kakutei_prog.size()){
        cout << kakutei_prog[i].first << " " << kakutei_prog[i].second << endl;
    }*/

    priority_queue<int, vector<int>, greater<int>> stp; //録画機の中で最も終わる時間が早いものを常に取り出せるように
    stp.push(kakutei_prog[0].second);
    for(int i = 1; i < kakutei_prog.size(); i++){
        int eval = stp.top();
        if(eval < kakutei_prog[i].first){
            stp.pop();
        }
        stp.push(kakutei_prog[i].second);
    }

    cout << stp.size() << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 2552
from collections import deque

N, M = map(int, input().split())
g = [[] for _ in range(N+1)] #1-index
for i in range(M):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(N+1): #リストの要素を昇順に並び替え
    g[i].sort() 
    
#部屋１までの最短距離となる次の部屋の番号をguideにそれぞれ格納
guide = [float('inf')]*(N+1) #1-index
guide[0], guide[1] = 0, 0

seen = [-1]*(N+1)
q = deque()
q.append(1)

while q:
    q_no = q.popleft()
    for next_v in g[q_no]:
            if seen[next_v] == 1: continue
            
            seen[next_v] = 1
            guide[next_v] = q_no
            q.append(next_v)

if sum(guide) == float('inf'):
    print('No')
else:
    print('Yes')
    for i in range(2,N+1):
        print(guide[i])

Measured memory_bytes: 34812
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int len = sc.nextInt();
      int[] syutugen = new int[100005];
      Arrays.fill(syutugen,0);
      for(int i = 0; i < len; i++){
        int tmp = sc.nextInt() + 1;
        syutugen[tmp]++;
        syutugen[tmp - 1]++;
        syutugen[tmp + 1]++;
      }
      Arrays.sort(syutugen);
      System.out.println(syutugen[syutugen.length - 1]);
	}
}


Measured memory_bytes: 50296
#include <bits/stdc++.h>
using namespace std;
 
//#define kk
#define int long long
#define FOR(a, b) for(int i=a; i<=b; i++)
#define REP(i, a, b) for(int i=a; i<=b; i++)
#define ff first
#define ss second
#define ll long long
#define inf 1000000000
#define pb push_back
#define mod 1000000007
 
const ll INF=1e18+5;
const int maxN=1e5+5;
typedef pair<int, int> pi;

const int nax1=1e4+5;
const int nax2=1e2+5;

vector<int> num;
int dp[nax1][2][nax2];

int d;

int call(int pos, int flag, int sum){
	
	if(pos==(int)num.size()) return sum==0;
	
	if(dp[pos][flag][sum]!=-1) return dp[pos][flag][sum];
	
	int limit;
	if(flag==0) limit=num[pos];
	else limit=9;
	
	int res=0;
	
	for(int i=0; i<=limit; i++){
		int f=flag;
		if(i<limit) f=1;
		res=(res+call(pos+1, f, (sum+i)%d))%mod;
	}
	
	return dp[pos][flag][sum]=res%mod;
}

void solve(){
	string k;
	cin>>k>>d;
	
	num.clear();
	
	FOR(0, (int)k.size()-1){
		num.pb(k[i]-'0');
	}
	
	memset(dp, -1, sizeof(dp));
	
	int res=call(0,0,0);
	
	cout<<(res-1+mod)%mod<<endl;
}
 
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cout<<fixed<<setprecision(6);
	
	#ifdef kk
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int T=1;
	//cin>>T;
	
	while(T--){		
		solve();
	}
}


Measured memory_bytes: 20932
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;
     
     
int main()
{
    string s;
    cin >> s;
    cout << s.size() / 2 - count(all(s), 'p');
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p, a, b) for (ll p = a; p < b; p++)
#define F first
#define S second
using namespace std;

typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<ld> vld;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;

int main()
{
    ll t, i, j, k, ans, n, m, sum = 0, x;

    //cin>>t;
    t = 1;
    while (t--)
    {
        cin >> n >> k;
        
        if(n==k)cout<<"Yes";
        else cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const double INF=1000000000;
const int MAX=100001;
int main(){
    ll w,h;
    cin>>w>>h;
    vector<P> v;
    for(int i=0;i<w;i++){
        ll p;cin>>p;
        v.push_back(P(p,0));
    }
    for(int i=0;i<h;i++){
        ll q;cin>>q;
        v.push_back(P(q,1));
    }
    sort(all(v));
    ll ans=0;
    ll a=w+1;ll b=h+1;
    for(auto& e:v){
        if(e.second){
            b--;
            ans+=e.first*a;
        }else{
            a--;
            ans+=e.first*b;
        }
    }
    cout<<ans<<endl;
    return 0;
}

                           


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcount __builtin_popcount
#define mp make_pair
#define eb emplace_back
#define emp emplace
#define ss second
#define ff first
#define endl "\n"
#define PI 3.14159265359
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)

void reads(string& x){
    char kk[N];
    scanf("%s",kk);
    x = kk;
}
ll n,pode,a,b;
ll e(ll x){
    return x*x*x*x*x;
}

void solve(){
    pode=0;
    scanf("%lld", &n);
    for(a=0;a<=3000;a++){
        for(b=0;b<=3000;b++){
            if(e(a)-e(b)==n){
                pode=1;
            }
            else if(e(a)+e(b)==n){
                b=-b;
                pode=1;
            }
            if(pode)break;
        }
        if(pode)break;
    }
    printf("%lld %lld\n",a,b);
}
int main(){_
    int t=1;// scanf("%d",&t);
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 100005
int a[N],b[N];
signed main()
{
	int n=read();
	for(int i=1;i<=n+1;i++)
	{
		a[i]=read();
	}
	for(int i=1;i<=n;i++)
	{
		b[i]=read();
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=min(a[i]+a[i+1],b[i]);
		if(b[i]>a[i])
		{
			b[i]-=a[i];
			a[i]=0;
			a[i+1]=max(0LL,a[i+1]-b[i]);
		}
		else
		{
			a[i]-=b[i];
			b[i]=0;
		}
	}
	cout<<ans<<endl;
#ifndef ONLINE_JUDGE
//	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



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

using namespace std;

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

	long long ans = x / 11 * 2;

	if(x % 11 > 6) {
		ans += 2;
	} else if(x % 11 > 0) {
		ans += 1;
	}
	cout << ans << '\n';
		
	return 0;

}


Measured memory_bytes: 256
import numpy as np
n, k = map(int, input().split())
x = np.array(list(map(int, input().split())))

result = []
for i in range(n-k+1):
    l, r = x[i], x[i+k-1]
    if l*r >= 0:
        result.append(max(abs(l), abs(r)))
    else:
        result.append(abs(2*l-r))
        result.append(abs(2*r-l))
print(min(result))

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

int main() {
  int a,b, c;
  cin>>a>>b>>c;
  
  cout<<min(min(a+b,b+c),a+c)<<endl;
  
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int t, d, l;
    while(cin >> t >> d >> l, t){
        vector<int> v(t);
        int ans = 0, p = -1;
        for (auto &&i : v) scanf("%d", &i);
        for (int i = 0; i < t; ++i) {
            if(i && v[i-1] >= l) p = d;
            else p--;
            if(p > 0) ans++;
        }
        cout << ans << "\n";
    }
    return 0;
}


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

int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;


int gcd(int a, int b) {
	a = abs(a);
	b = abs(b);
	return b != 0 ? gcd(b, a % b) : a;
}

int main() {
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	string ans = S;
	ans[K - 1] = ans[K - 1] - ('A' - 'a');
	cout << ans << endl;
	return 0;
}


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


int main(){
  int K, N;
  cin >> K >> N;
  vector<int> v;

  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  int ret = K;
  rep(i,N){
    int a = v[i];
    int b = v[(i+1)%N];
    if(i+1 >= N) b += K;
    int d = abs(a-b);
    ret = min(ret, K - d);
  }
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
  int n; cin >> n;
  bool flg = false;
  rep(i, n){
    int a; cin >> a;
    if(a % 2 == 1) flg = true;
  }
  if(flg) cout << "first" << endl;
  else cout << "second" << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;

const int inf=1e9,mod=1e9+7,N=2e5+5;

void solve(){
	int c[3][3];
	rep(i,3)rep(j,3)cin>>c[i][j];
	for(int a1=0;a1<=100;a1++){
		set<int>b[3];
		rep(i,3){
			b[i].insert(c[0][i]-a1);
		}
		for(int a2=0;a2<=100;a2++){
			bool ok=0;
			rep(j,3){
				if(!b[j].count(c[1][j]-a2)){
					ok=1;
					break;
				}
			}
			if(ok)continue;
			for(int a3=0;a3<=100;a3++){
				ok=0;
				rep(k,3){
					if(!b[k].count(c[2][k]-a3)){
						ok=1;
					}
				}
				if(ok)continue;
				cout<<"Yes";
				return;
			}
		}
	}
	cout<<"No";
}

int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

Measured memory_bytes: 3596
# Input Part
N,K = map(int,input().split())
A = [int(input()) for _ in range(N)]

Amax = 3*10**5

# N: 処理する区間の長さ
N0 = 2**(Amax-1).bit_length()
INF = 0
data = [INF]*(2*N0)
# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])
# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

def main():
    for i in range(N):
        tmin = max(0,A[i]-K)
        tmax = min(Amax,A[i]+K)+1
        update(A[i],query(tmin,tmax)+1)
        #print(data)
    print(data[0])
main()


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

using namespace std;

int main(void){

  int n, m;
  cin >> n >> m;
  vector<int> A(n);
  for (int i=0; i<n; i++) {
    cin >> A[i];
  }

  int total = 0;
  for (int i=0; i<n; i++) {
    total += A[i];
  }

  int canSelect = 0;
  for (int i=0; i<n; i++) {
    if (A[i]*4*m >= total) {
      canSelect++;
     }
  }

  if (canSelect >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0; 
}


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

int main() {
  int N, X;
  cin >> N;
  
  int p;
  p = N;
  for(int i; i < N;i++){
    X += p % 10;
    p = p / 10;
  }
  if(N % X == 0){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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


int main()
{
    string S;
    ll N,flag=0;
    cin >> N;
    cin >> S;

    if(N%2==1){
        cout << "No" <<endl;
    }
    else{
        for(ll i=0;i<N/2;i++){
            if(S[i]!=S[i+N/2]){
                flag=1;
            }
        }
        if(flag==1){
            cout << "No" <<endl;
        }else{
            cout << "Yes" <<endl;
        }
    }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 
  string s;
  cin>>s;
  string output="";

  if(s.length() == 1)
	if(s.at(0) == '?')
		cout<<"D";
	else
		cout<<s.at(0);
  else{
	for(int i=0;i<s.length();i++){
		if(s.at(i) == '?'){
			if( i == 0 && s.at(i+1) == 'D')
				output+='P';
			else
				output+='D';
			continue;
		}
		output+=s.at(i);
	  }
	  cout<<output;
	}  
  return 0;
}

Measured memory_bytes: 3920
def judge(A,B,n,m):
    C = []
    for i in range(n-m+1):
        for j in range(n-m+1):
            C = [A[i+k][j:m+j] for k in range(m)]
            if B == C:
                return True
    return False

def main():
    N,M = map(int,input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]

    if judge(A,B,N,M):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


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

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

class P{
public:
	int x,y;
	P(int _x,int _y){
		x = _x;
		y = _y;
	}

	bool operator<(const P &p)const{
		return x < p.x;
	}
};

bool isFlash(vector<P> v){
	rep(i,v.size()-1) if(v[i].y != v[i+1].y) return false;
	return true;
}

bool isSame(vector<P> v,int n,int m){
	REP(i,n,m-1) if(v[i].x != v[i+1].x) return false;
	return true;
}

bool isStraight(vector<P> v){
	int n = 0;
	int m = v.size();
	if(v[0].x==0 && v[1].x==9) n = 1;

	REP(i,n,m-1) if(v[i].x + 1 != v[i+1].x) return false;
	return true;
}

int main(void){
	int n;
	bool firstFlg = true;

	while(cin>>n){
		if(firstFlg) firstFlg = false;
		else cout<<endl;

		int t[4][13];
		rep(i,4) rep(j,13) cin>>t[i][j];

		int s[9];
		rep(i,9) cin>>s[i];

		while(n--){
			int score = 0;
			vector<P> v;

			rep(i,5){
				string s;
				cin>>s;

				int x = ('2'<=s[0] && s[0]<='9' ? s[0]-'1' :
								 s[0]=='A' ? 0 :
								 s[0]=='T' ? 9 :
								 s[0]=='J' ? 10 :
								 s[0] == 'Q' ? 11 : 12);
				int y = (s[1]=='S' ? 0 :
								 s[1] == 'C' ? 1 :
								 s[1] == 'H' ? 2 : 3);

				score += t[y][x];
				v.push_back(P(x,y));
			}

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

			//CXg[gtbV
			if(v[0].x==0 && v[1].x==9 && isStraight(v) && isFlash(v))
				score *= s[8];
			//Xg[gtbV
			else if(isStraight(v) && isFlash(v))
				score *= s[7];
			//tH[J[h
			else if(isSame(v,0,4) || isSame(v,1,5))
				score *= s[6];
			//tnEX
			else if( isSame(v,0,2) && isSame(v,2,5) ||
							 isSame(v,0,3) && isSame(v,3,5) )
				score *= s[5];
			//tbV
			else if(isFlash(v))
				score *= s[4];
			//Xg[g
			else if(isStraight(v))
				score *= s[3];
			//X[J[h
			else if(isSame(v,0,3) || isSame(v,1,4) || isSame(v,2,5))
				score *= s[2];
			//c[yA
			else if( isSame(v,0,2) && (isSame(v,2,4) || isSame(v,3,5)) ||
							 isSame(v,1,3) && isSame(v,3,5) )
				score *= s[1];
			//yA
			else if( isSame(v,0,2) || isSame(v,1,3) ||
							 isSame(v,2,4) || isSame(v,3,5) )
				score *= s[0];
			//ðÈµ
			else
				score = 0;

			cout<<score<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 936
#include<bits/stdc++.h>
#define uLL unsigned long long
using namespace std;
#define LL long long
#define N 100005
LL a[N];
int k[7] = {-1,1};
int main() {
	int n;
	cin >> n;
	for(int i=1; i<=n; i++) scanf("%lld",&a[i]);
	LL L = 0,s = 1,R = a[1];
	for(int i=2; i<n; i++) {
		L += k[s]*a[i];
		s ^= 1;
	}
	L += k[s]*a[n];
	LL x1 = (R-L)/2;
	cout<<x1*2<<" ";
	for(int i=1; i<n; i++) {
		a[i] -= x1;
		printf("%lld ",a[i]*2);
		x1 = a[i];
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	ll n,a;
	cin >> n;
	bool bb=1;
	ll count=0;
	while(bb){
		count++;
		a=pow(count,2)+0.5;
		if(a>n) bb=0;
	}
	count--;
	cout << fixed << setprecision(0) << pow(count,2) << endl;
/////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
	int a;
	vector<int> in;
	while(scanf("%d",&a)!=EOF){
		if(a==0)	break;
		in.push_back(a);
	}
	map<int,int> dic;
	for(int it:in)	dic[it]++;
	int num=0;
	for(auto it:dic)	num=max(num,it.second);
	for(auto it:dic){
		if(num==it.second)	cout<<it.first<<endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

void LoopUtZeroIn() {
  int luziHoge = 10;
  while (cin >> luziHoge && luziHoge != 0)
    ;
}

int main() {
  int N, T, A, input;
  double hoge;
  cin >> N >> T >> A;
  double nearPointDiff = 100000;
  int nearPointNum = 10000;
  double idealHight = (T - A) / 0.006;
  for (int i = 0; i < N; i++) {
    cin >> input;
    hoge = fabs(input - idealHight);
    if (hoge < nearPointDiff) {
      nearPointNum = i;
      nearPointDiff = hoge;
    }
  }
  cout << nearPointNum + 1 << endl;

  // LoopUtZeroIn();
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int qq;
	double q,x1,x2,xx;
	while(1)	{
		scanf("%d",&qq);
		if(qq==-1)	break;
		q=double(qq);
		x1=q/2.0;
		while(1)	{
			xx=x1*x1*x1-q;
			if(xx<0)	xx=-xx;
			if(xx<0.00001*q)	break;
			x1=x1-(x1*x1*x1-q)/(3.0*x1*x1);
		}
		printf("%lf\n",x1);
	}
	return 0;
}


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

int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  
  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k; j++){
      if(s - i - j >= 0 && s - i - j <= k) ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, k, temp, N, M;
    scanf("%d %d", &N, &M);
    int n[N][2];
    int m[M][2];
    int answer[N][2];
    for(i = 0; i < N; i++) {
        scanf("%d %d", &n[i][0], &n[i][1]);
    }
    for(i = 0; i < M; i++) {
        scanf("%d %d", &m[i][0], &m[i][1]);
    }
    
    for(i = 0; i < N; i++) {
        answer[i][1] = 1e9;
    }
    for(i = 0; i < N; i++) {
        for(k = 0; k < M; k++) {
            if(n[i][0] > m[k][0]) {
               temp = n[i][0] - m[k][0];
            }
            else {
               temp = m[k][0] - n[i][0];
            }
            if(n[i][1] > m[k][1]) {
               temp += n[i][1] - m[k][1];
            }
            else {
               temp += m[k][1] - n[i][1];
            }
            if (answer[i][1] > temp) {
                answer[i][0] = k + 1;
                answer[i][1] = temp;
            }
        }
    }
    for(i = 0; i < N; i++) {
        printf("%d\n", answer[i][0]);
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;


signed main(){
	
	int a;
	cin>>a;
	int ans=(a/11)*2;
	if(a%11==0)ans+=0;
	else if(a%11<=6)ans++;
	else ans+=2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
文字列の配列の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt(),m=sc.nextInt();
        int[] c=new int[m+1];
        int ans=0;
        for (int i = 0; i < n; i++) {
            int k=sc.nextInt();
            for (int j = 0; j < k; j++) {
                int a=sc.nextInt();
                c[a]++;
            }
        }
        for (int i = 1; i <= m; i++) {
            if(c[i]==n)ans++;
        }
        out.println(ans);
    }
}

Measured memory_bytes: 24020
#include<iostream>
#include<vector>

int main(){
    int x;
    std::cin>>x;
    for(int i=0;i<x;++i){
        std::vector<int> vec(10);
        for(int l=0;l<10;++l){
            std::cin>>vec[l];
        }
        std::vector<std::vector<int> > vec2(2);
        vec2[0].push_back(vec[0]);
        for(int l=1;l<vec.size();++l){
            if(l==1){
                if(vec2[0][0]<vec[1]){
                    vec2[0].push_back(vec[1]);
                }else vec2[1].push_back(vec[1]);
            }else{
                if(vec[l]>vec2[0][vec2[0].size()-1]){
                    if(vec2[1].size()!=0&&vec2[1][vec2[1].size()-1]>vec[l]){
                        if(vec2[0][vec2[0].size()-1]>vec2[1][vec2[1].size()-1])vec2[0].push_back(vec[l]);
                        else vec2[1].push_back(vec[l]);
                    }else{
                        vec2[0].push_back(vec[l]);
                    }
                }else{
                    if(vec2[1].size()!=0?vec[l]>vec2[1][vec2[1].size()-1]:true){
                        vec2[1].push_back(vec[l]);
                    }else{
                        std::cout<<"NO"<<std::endl;
                        goto cont;
                    }
                }
            }
        }
        std::cout<<"YES"<<std::endl;
    cont:;
    }
    return 0;
}

Measured memory_bytes: 1208
dic={}
for i in range(int(input())):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
for i in range(int(input())):
    s=input()
    if s in dic:
        dic[s]-=1
    else:
        dic[s]=-1
print(max(sorted(dic.values())[-1],0))


Measured memory_bytes: 3060
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let mut s: Vec<_> = sc
        .read::<String>()
        .chars()
        .map(|c| c as usize - '0' as usize)
        .collect();
    s.insert(0, 0);
    let mut dp = [0, 1];
    for digit in s.into_iter() {
        let mut next = [1 << 50, 1 << 50];
        next[0] = cmp::min(next[0], dp[1] + 10 - digit);
        next[0] = cmp::min(next[0], dp[0] + digit);
        next[1] = cmp::min(next[1], dp[0] + digit + 1);
        next[1] = cmp::min(next[1], dp[1] + 9 - digit);
        dp = next;
    }
    println!("{}", dp[0]);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 15608
#include<iostream>
#include<string.h>
#include<cstdio>
using namespace std;
int main()
{
long long n,ans=0;
bool jump=true;
char buff[30];
cin>>buff;
for(int i=1;i<strlen(buff);i++)
if(buff[i]!='9')jump=false;
if(jump)goto j;
buff[0]--;
for(int i=1;i<strlen(buff);i++)
buff[i]='9';
j:for(int i=0;i<strlen(buff);i++)
ans+=buff[i]-48;
cout<<ans;
return 0;
}

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


int main(){
  long long N,a;
  cin >> N;
  vector<int> A(N);
  map<int,int> num_balls;
  map<int,long long> num_comb;
  
  for(int i=0;i<N;++i){
    cin >> a;
    A[i]=a;
    ++num_balls[a];
  }
  long long total=0;
  for(auto itr=num_balls.begin();itr!=num_balls.end();++itr){
    long long n=itr->second;
    int m=itr->first;
    num_comb[m]=n*(n-1)/2;
    total+=num_comb[m];
  }
  for(auto itr=A.begin();itr<A.end();++itr){
    cout << total-num_comb[*itr]*2/num_balls[*itr] << endl;
  }
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int n, i = 0,cnt = 0;
      int sum[4];
      cin >> n;
      while(n > 0){
        sum[i] = n % 10;
        n = n / 10;
        i++;
      }
      for (i = 0; i<=2; i++){
        if(sum[1] != sum[2]){
        } else if (sum[i] == sum[i+1]){
            cnt++;
        }
      }
      if (cnt >= 2){
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }

Measured memory_bytes: 384
#include<iostream>
using namespace std ;
int main()
{

    string s ;
    cin >> s ;
    int len = s.size(),f=0;
    if(len%2==1)
    {
        f=1;
    }
    else
    {
        for(int i=0;i<len;i+=2)
        {
            if(s[i]!='h' || s[i+1]!='i'){f=1;}
        }
    }
    if(f==0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0 ;
}


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

S = [0] * (N + 1)
S[0] = abs(A[0])
for i, a in enumerate(A[1:]):
    S[i + 1] += abs(a - A[i])
S[-1] = abs(A[-1])

s = sum(S)

print(abs(A[1]) + s - S[0] - S[1])
for i in range(1, N - 1):
    print(s - S[i] - S[i + 1] + abs(A[i - 1] - A[i + 1]))
print(s - S[-2] - S[-1] + abs(A[-2] - 0))


Measured memory_bytes: 57580
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

int main(){
	ll ans[256]={0};
	char hoge;
	while(cin >> hoge){
		if(hoge>64&&hoge<91){
			hoge += 32;
			//cout << hoge;
		}
		ans[hoge]++;
	}
	FOR(i,97,123){
		cout << (char)i <<" : "<<  ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int n;
int dp[31][51];

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

    while (cin >> n, n) {
        vector<int> f(n), aiteru(30);
        vector<vector<int>> ds(n);
        REP (i, n) {
            cin >> f[i];
            ds[i].resize(f[i]);
            REP (j, f[i]) {
                cin >> ds[i][j];
                ds[i][j]--;
                aiteru[ds[i][j]] |= (1LL << i);
            }
        }
        REP (i, n) dp[0][i] = (1LL << i);
        int ans = -1;
        REP (i, 30) {
            int mask = 0;
            REP (j, n) if (aiteru[i] >> j & 1) {
                mask |= dp[i][j];
            }
            REP (j, n) {
                if (!(aiteru[i] >> j & 1)) {
                    dp[i + 1][j] = dp[i][j];
                } else {
                    dp[i + 1][j] = dp[i][j] | mask;
                }
                if (dp[i + 1][j] == (1LL << n) - 1) {
                    ans = i + 1;
                    break;
                }
            }
            if (ans >= 0) break;
        }
        cout << ans << endl;
    }
}


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

const int mx = 3001;
int lookup[mx][mx];

string LCS(string a, string b, int m, int n){
	if(m == 0 || n == 0)
		return string("");
	if(a[m-1] == b[n-1])
		return LCS(a, b, m-1, n-1) + a[m-1];
	if(lookup[m-1][n] > lookup[m][n-1])
		return LCS(a, b, m-1, n);
	else
		return LCS(a, b, m, n-1);
}

void LCSLength(string a, string b, int m, int n){
	for(int i=1; i<=m; i++){
		for(int j=1; j<=n; j++){
			if(a[i-1] == b[j-1])
				lookup[i][j] = lookup[i-1][j-1] + 1;
			else
				lookup[i][j] = max(lookup[i-1][j], lookup[i][j-1]);
 		}
	}
}

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	string s, t; cin >> s >> t;
	LCSLength(s, t, s.size(), t.size());
	string ans = LCS(s, t, s.size(), t.size());
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 68776
unittest
{
	assert( [ "4 1 3" ].parse.expand.solve == 7 );
	assert( [ "1000000000 141421 173205" ].parse.expand.solve == 34076506 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nab = input.front.split.to!( long[] );
	return tuple( nab[ 0 ], nab[ 1 ], nab[ 2 ] );
}

auto solve( long n, long a, long b )
{
	auto ans = ModWorld!()( 2 ) ^^ n - 1;
	auto ac = n.combination( a );
	auto bc = n.combination( b );
	ans -= ac + bc;
	return ans;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M = 10L ^^ 9 + 7 )
{
	long n;
	
	// 演算子オーバーロード
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = this.n * a % M;
			a = a ^^ 2 % M;
		}
	}
	auto opBinary( string OP )( ModWorld r )
	{
		auto t = this;
		t.opOpAssign!OP( r );
		return t;
	}
	
	// long型対応
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	// format用出力
	string toString()
	{
		return this.n.to!string;
	}
}

// 組み合わせ数
auto combination( long M = 10L ^^ 9 + 7 )( long x, long y )
{
	if( x < y ) return ModWorld!M( 0L );
	auto z = ModWorld!M( 1L );
	foreach( i; 0L .. y )
	{
		z = z * ( x - i ) / ( i + 1 );
	}
	return z;
}


Measured memory_bytes: 256
use std::io::*;
use std::cmp::*;

struct Sp {
    i: usize,
    s: String,
    p: i32,
}

fn main() {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let n: usize = n.trim().split_whitespace().collect::<Vec<&str>>()[0].parse().unwrap(); 

    let mut v: Vec<Sp> = Vec::new();

    for i in  1..n + 1 {
        let mut sp = String::new();
        stdin().read_line(&mut sp).unwrap();
        let s: String = sp.trim().split_whitespace().collect::<Vec<&str>>()[0].parse().unwrap();
        let p: i32 = sp.trim().split_whitespace().collect::<Vec<&str>>()[1].parse().unwrap();

        v.push(Sp{i: i,s: s, p: p});
    }

    v.sort_by(|a, b| {
        match a.s.cmp(&b.s) {
            Ordering::Equal => {
                b.p.cmp(&a.p)
            }
            e => {
                e
            }
        }
    });

    for c in v {
        println!("{}",c.i);
    }

}


Measured memory_bytes: 4352
using System;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var N = new int[26];

        foreach (var s in S)
        {
            N[s - 'a'] += 1;
        }

        for (int i = 0; i < 26; i++)
        {
            if (N[i] == 0)
            {
                Console.WriteLine((char)('a' + i));
                return;
            }
        }
        
        Console.WriteLine("None");
    }
}


Measured memory_bytes: 25952
#include<stdio.h>
int d,t,s;
int main () {
  scanf("%d %d %d" , &d , &t , &s);
  d = d+s-1 ;
  if(t >= (d/s))
  {
    printf("Yes");
  }
  else 
  {
    printf("No");
  }
}


Measured memory_bytes: 1704
#include<stdio.h>
int main(){
  int a, b;
  char op;
  
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+') printf("%d\n",a+b);
    else if(op=='-') printf("%d\n",a-b);
    else if(op=='*') printf("%d\n",a*b);
    else if(op=='/') printf("%d\n",a/b);
    else break;
  }
  return 0;
}



Measured memory_bytes: 2148
import java.util.*;

public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int[] a=new int[N];
        int[] b=new int[N];
        int[] c=new int[M];
        int[] d=new int[M];
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
        }
        for(int i=0;i<M;i++){
            c[i]=sc.nextInt();
            d[i]=sc.nextInt();
        }
        for(int i=0;i<N;i++){
            int minDis=1000000000;
            int minPoint=0;
            for(int j=0;j<M;j++){
                int mdis=Math.abs(a[i]-c[j])+Math.abs(b[i]-d[j]);
                if(mdis<minDis){
                    minPoint=j;
                    minDis=mdis;
                }
            }
            System.out.println(minPoint+1);
        }
        return;
    }
}

Measured memory_bytes: 23764
#include<stdio.h>

int main(void){
	int W, H ,x ,y ,r;
	scanf("%d %d %d %d %d",&W ,&H ,&x ,&y ,&r);
	if((x-r) >= 0 && (x+r) <= W && (y-r) >= 0 && (y+r) <= H){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
def BubbleSort(C, N):
    for i in xrange(0,N):
        for j in xrange(N-1,i,-1):
            if int(C[j][1]) < int(C[j-1][1]):
                tmp = C[j]
                C[j] = C[j-1]
                C[j-1] = tmp
    return C

def SelectionSort(C, N):
    for i in xrange(0,N):
        minj = i
        for j in xrange(i,N):
            if int(C[j][1]) < int(C[minj][1]):
                minj = j
        if minj != i:
            tmp = C[i]
            C[i] = C[minj]
            C[minj] = tmp
    return C

def isStable(in_, out_, N):
    for i in xrange(N):
        for j in xrange(i + 1, N):
            for a in xrange(N):
                for b in xrange(a + 1, N):
                    if in_[i][1] == in_[j][1] and in_[i] == out_[b] and in_[j] == out_[a]:
                        return False
    return True

def main():
    N = int(raw_input())
    A = raw_input().split()
    BA = BubbleSort(A[:], N)
    SA = SelectionSort(A[:], N)
    print ' '.join(BA)
    if isStable(A, BA,N):
        print "Stable"
    else:
        print "Not stable"
    print ' '.join(SA)
    if isStable(A, SA,N):
        print "Stable"
    else:
        print "Not stable"

    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 6476