akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

const i64 mod = 1e9 + 7;

i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}
i64 inv(i64 x) {
  return ipow(x, mod - 2);
}

i64 n;
vector<vector<int>> g, h;
vector<i64> sub;

void dfs_h(int u, int p) {
    for (int v : g[u]) {
        if (v == p) continue;
        h[u].push_back(v);
        dfs_h(v, u);
    }
}

void dfs_sub(int u) {
    sub[u] = 1;
    for (int v : h[u]) {
        dfs_sub(v);
        sub[u] += sub[v];
    }
}

int main() {
    cin >> n;
    g.resize(n + 1);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    h.resize(n + 1);
    sub.resize(n + 1);
    dfs_h(1, 0);
    dfs_sub(1);
    i64 ans = 0;
    for (int u = 1; u <= n; ++u) {
        if (g[u].size() >= 2) {
            ans += (mod + 1) / 2 - inv(ipow(2, n));
            i64 par = n - 1;
            for (int v : h[u]) {
                ans += mod - (inv(ipow(2, n - sub[v])) - inv(ipow(2, n)));
                par -= sub[v];
            }
            ans += mod - (inv(ipow(2, n - par)) - inv(ipow(2, n)));
            ans %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32000
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<Character,Integer> map = new LinkedHashMap<>();

		for(char ch='a'; ch<='z'; ch++) {
			map.put(ch,0);
		}


		while(sc.hasNextLine()) {
			String str=sc.nextLine();
			String str2 = str.toLowerCase();
			for(int i=0; i<str2.length(); i++) {
				char ch = str2.charAt(i);

				if(map.get(ch)!=null) {
					map.put(ch,map.get(ch)+1);
				}
			}
		}

		for(Character ch : map.keySet()) {
			System.out.println(ch +" : "+map.get(ch));
		}

	}
}


Measured memory_bytes: 26208
#include <iostream>
#include <string>
using namespace std;
const static int N = 1000;
int dp[N + 1][N + 1];

int lcs(string X, string Y) {
	int max = 0;
	int m = X.size();
	int n  = Y.size();
	X = ' ' + X;
	Y = ' ' + Y;

	for (int i = 1; i <= m; i++)
		dp[i][0] = 0;
	for (int i = 1; i <= n; i++)
		dp[0][i] = 0;

	for (int i = 1; i <= m; i++) {
		for ( int j = 1; j <= n; j++) {
			if (X[i] == Y[j])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else {
				if (dp[i - 1][j] > dp[i][j - 1])
					dp[i][j] = dp[i - 1][j];
				else
					dp[i][j] = dp[i][j - 1];
			}

			max = (max < dp[i][j]) ? dp[i][j] : max;
		}
	}

	return max;
}

int main(int argc, char const *argv[]) {
	int n;
	cin >> n;


	for (int i = 0; i < n; i++) {
		string X, Y;
		cin >> X >> Y;

		cout << lcs(X, Y) << endl;
	}

	return 0;
}

Measured memory_bytes: 6972
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<< #x <<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

const int MAX_LEN = 100001;
int main(){
    string s;
    int n;
    int l,r;
    l = r = -1;
    cin >> s;
    n = s.length();
    REP(i,n-1){
        if( s[i] == s[i+1] ){
            l = i + 1;
            r = i+1 + 1;
            break;
        }
    }
    REP(i,n-2){
        if( s[i] == s[i+2] ){
            l = i + 1;
            r = i+2 + 1;
            break;
        }
    }

    printf("%d %d\n",l,r);
    return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define lll pair<ll,ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vi vector<int>
#define ff first
#define ss second
#define pb(a) push_back(a)
#define ppb() pop_back()
#define mkp(a,b) make_pair(a,b)
#define vs vector<string>
#define vc vector<char>
#define deb1(a) cout<<#a<<" "<<a<<"\n"
#define deb2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n"
#define mms0(a) memset(a,0,sizeof(a))
#define mms1(a) memset(a,-1,sizeof(a))
#define FOR(a,b,c) for(int i=(a);i<(b);i+=(c))
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define _ 0
using namespace std;




void solve(){
   int N,W;
   cin>>N>>W;
   vector<pair<ll,ll>> data;
   FOR(_,N,1){
      lll p;
      cin>>p.ff>>p.ss;
      data.pb(p);
   }

   vll dp(100000+1,INT_MAX);

   dp[0] = 0;
   for(int i=1;i<=N;i++){
      for(int j = 100000;j>=1;j--){
         if(j >= data[i-1].ss){
            dp[j] = min(dp[j],dp[j-data[i-1].ss] + data[i-1].ff);
         }
      }
      //for(int k=0;k<=9;k++) cout<<dp[k]<<" ";cout<<"\n";
   }

   ll ans = 0;
   for(int i=0;i<=100000;i++){
      if(dp[i]<=W) ans = i;
   }
   cout<<ans;
}




int main(){
   int t = 1;
  // cin>>t;
   while(t--){
      solve();
   }
   return 0;
}

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

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        String S = sc.next();
        char[] c = new char[N];
        for(int i = 0; i < S.length(); i++){
            c[i] = S.charAt(i);
        }
        c[A - 1] = 'A';
        c[B - 1] = 'B';
        // 遠くに行く方を先に動かす
        int bigTarget = C > D ? C - 1 : D - 1;
        int nowIndex = C > D ? A - 1 : B - 1;
        char player = C > D ? 'A' : 'B';
        char otherPlayer = C > D ? 'B' : 'A';
        int nowOtherIndex = C > D ? B - 1 : A - 1;
        int otherTarget = C > D ? D - 1 : C - 1;
        boolean result1 = true;
        while(nowIndex < bigTarget){
            if(c[nowIndex + 1] == '.'){
                c[nowIndex] = '.';
                c[nowIndex + 1] = player;
                nowIndex += 1;
            }else if(nowIndex + 2 <= bigTarget && c[nowIndex + 2] == '.'){
                c[nowIndex] = '.';
                c[nowIndex + 2] = player;
                nowIndex += 2;
            }else if(c[nowIndex + 1] == otherPlayer || c[nowIndex + 2] == otherPlayer){
                // 相手をずらす
                if(nowOtherIndex + 1 <= otherTarget && c[nowOtherIndex + 1] == '.'){
                    c[nowOtherIndex] = '.';
                    c[nowOtherIndex + 1] = otherPlayer;
                    nowOtherIndex += 1;
                }else if(nowOtherIndex + 2 <= otherTarget && c[nowOtherIndex + 2] == '.'){
                    c[nowOtherIndex] = '.';
                    c[nowOtherIndex + 2] = otherPlayer;
                    nowOtherIndex += 2;
                }else{
                    result1 = false;
                    break;
                }
            }else {
                result1 = false;
                break;
            }
        }
        boolean result2 = true;
        if(nowOtherIndex > otherTarget){
            result2 = false;
        }else{
            // 相手を動かす
            while(nowOtherIndex < otherTarget){
                if(c[nowOtherIndex + 1] == '.'){
                    nowOtherIndex += 1;
                }else if(nowOtherIndex + 2 <= otherTarget && c[nowOtherIndex + 2] == '.'){
                    nowOtherIndex += 2;
                }else{
                    result2 = false;
                    break;
                }
            }
        }
        if(result1 && result2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 25772
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+10,mod=1e9+7;
int siz,f[N][3][3];
string str;
char ch[N];
signed main(void)
{
	cin>>str;
	siz=str.size();
	for(int i=1;i<=siz;i++) ch[i]=str[i-1];
	f[0][0][0]=1;
	for(int i=0;i<siz;i++)
	{
		if(ch[i+1]!='0')
		{                                              //x y
			f[i+1][1][0]=(f[i+1][1][0]+f[i][0][0])%mod;//0 0
			f[i+1][0][0]=(f[i+1][0][0]+f[i][0][1])%mod;//0 1
			f[i+1][0][1]=(f[i+1][0][1]+f[i][0][2])%mod;//0 2
			f[i+1][2][0]=(f[i+1][2][0]+f[i][1][0])%mod;//1 0
			f[i+1][1][0]=(f[i+1][1][0]+f[i][1][1])%mod;//1 1
			f[i+1][1][1]=(f[i+1][1][1]+f[i][1][2])%mod;//1 2
			f[i+1][2][0]=(f[i+1][2][0]+f[i][2][0])%mod;//2 0
			f[i+1][2][0]=(f[i+1][2][0]+f[i][2][1])%mod;//2 1
			f[i+1][2][1]=(f[i+1][2][1]+f[i][2][2])%mod;//2 2
		}
		if(ch[i+1]!='1')
		{                                              //x y
			f[i+1][0][1]=(f[i+1][0][1]+f[i][0][0])%mod;//0 0
			f[i+1][0][2]=(f[i+1][0][2]+f[i][0][1])%mod;//0 1
			f[i+1][0][1]=(f[i+1][0][1]+f[i][0][2])%mod;//0 2
			f[i+1][1][1]=(f[i+1][1][1]+f[i][1][0])%mod;//1 0
			f[i+1][1][2]=(f[i+1][1][2]+f[i][1][1])%mod;//1 1
			f[i+1][1][1]=(f[i+1][1][1]+f[i][1][2])%mod;//1 2
			f[i+1][2][1]=(f[i+1][2][1]+f[i][2][0])%mod;//2 0
			f[i+1][2][2]=(f[i+1][2][2]+f[i][2][1])%mod;//2 1
			f[i+1][2][1]=(f[i+1][2][1]+f[i][2][2])%mod;//2 2
		}
	}
	int ans=0;
	for(int i=0;i<=2;i++)for(int j=i;j>=0;j--)ans=(ans+f[siz][i][j])%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 22020
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
dst = [{} for i in range(n+1)]
for i in range(m):
    u,v = inm()
    dst[u][v] = dst[v][u] = i
sm = 0
for i in range(m):
    q = [1]
    done = [False]*(n+1)
    done[0] = done[1] = True
    while len(q)>0:
        x = q.pop()
        for y in dst[x]:
            if done[y] or dst[x][y]==i:
                continue
            done[y] = True
            q.append(y)
    if len([x for x in done if not x])>0:
        sm += 1
print(sm)


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

struct FAU {
    VI p, r;

    FAU(int n): p(n,-1), r(n,0) {}

    int find(int x) {
        if (p[x] == -1) return x;
        return p[x] = find(p[x]);
    }

    void join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return ;

        if (r[x] > r[y]) p[y] = x;
        else p[x] = y;

        if (r[x] == r[y]) ++r[y];
    }
};

ll expo(ll a, ll n, ll mod) {
    ll ans = 1;

    while (n) {
        if (n & 1LL) ans = (ans * a) % mod;

        n >>= 1;
        a = (a * a) % mod;
    }

    return ans;
}

ll revMod(ll a, ll mod) {
    return expo(a, mod - 2, mod);
}

ll fact(int n) {
    ll res = 1;
    FOR(i,2,n) res = (res * i) % MOD;
    
    return res;
}

ll revFact(int n, VL &revs) {
    ll res = 1;
    FOR(i,2,n) res = (res * revs[i]) % MOD;
    
    return res;
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n, x, y;
    cin >> n >> x >> y;
    
    VI color(n), weight(n);
    FOR(i,0,n-1) {
        cin >> color[i] >> weight[i]; color[i]--;
    }
    
    VP minForColor(n, {INF, -1});
    FOR(i,0,n-1) {
        minForColor[color[i]] = min(minForColor[color[i]], mp(weight[i], i));
    }
    
    FAU fau(n);
    
    FOR(i,0,n-1) {
        if (weight[i] + minForColor[color[i]].st <= x) {
            fau.join(i, minForColor[color[i]].nd);
        }
    }
    
    sort(minForColor.begin(), minForColor.end());
    
    FOR(i,0,n-1) {
        auto it = minForColor.begin();
        while (it != minForColor.end() && color[it->nd] == color[i]) {
            it++;
        }
        
        if (it == minForColor.end()) continue;
        
        if (weight[i] + it->st <= y) {
            fau.join(i, it->nd);
        }
    }
    
    VL revs(n+1);
    FOR(i,1,n) {
        revs[i] = revMod(i, MOD);
    }
    
    ll ans = 1;
    
    map <int,int> cnt[n];
    FOR(i,0,n-1) cnt[fau.find(i)][color[i]]++;
    
    FOR(i,0,n-1) if (!cnt[i].empty()) {
        int total = 0;
        
        for (auto &e : cnt[i]) {
            total += e.nd;
        }
        
        ans = (ans * fact(total)) % MOD;
        
        for (auto &e : cnt[i]) {
            ans = (ans * revFact(e.nd, revs)) % MOD;
        }
    }
    
    cout << ans;
    
    return 0;
}

/*************************************************************************/


Measured memory_bytes: 25216
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  ll n;
  cin >> n ;
  VI a(n);
  rep(i,n)cin >> a.at(i);
   ll mon=1000;
   rep(i,n-1){
      if(a.at(i)<a.at(i+1)){
         ll st=mon/a.at(i);
         mon+=st*(a.at(i+1)-a.at(i));
      }
   }
      cout << mon << endl;
}



    
   

Measured memory_bytes: 3600
n = int(input())
a_list = list(input())
b_list = list(input())
c_list = list(input())
count = 0
for i in range(n):
    if a_list[i] == b_list[i] == c_list[i]:
        continue
    elif a_list[i] == b_list[i]:
        count += 1
        c_list[i] = a_list[i]
        continue
    elif b_list[i] == c_list[i]:
        a_list[i] =b_list[i]
        count += 1
        continue
    elif a_list[i] == c_list[i]:
        count += 1
        b_list[i] = a_list[i]
        continue
    else:
        count = count + 2
print(count)


Measured memory_bytes: 3064
n, k, q = gets.split.map(&:to_i)
count = Hash.new(0)
q.times { count[gets.to_i] += 1 }

answer = []

1.upto(n) do |i|
  minus_point = q - count[i]
  result = (k - minus_point > 0) ? 'Yes' : 'No'
  answer << result
end

puts answer


Measured memory_bytes: 13948
#include <iostream>
#include <string>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	string s;
	cin >> s;
	long long h = 0;
	long long max = h;
	for(int i = 0;i < s.size();i++)
	    {
	    	if(s[i] == 'I')h++;
	    	else if(s[i] == 'D')h--;
	    	
	    	if(h > max)max = h;
		}
	cout << max << endl;
	return 0;
 } 

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <utility>
#include <cstring>
using namespace std;
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2));
    sq=(sq*sq);
    if(k%2==1)
        sq=(sq*n);
    return sq;
}
ll nCr(ll n, ll r) {
    if(r > n - r) r = n - r;
    ll ans = 1;
    for(int i = 1; i <= r; i++)
        ans *= (n - r + i)/i;
    return ans;
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
// int dx[]={1,-1,0,0,1,-1,1,-1};
// int dy[]={0,0,1,-1,1,1,-1,-1};
// freopen("input.txt" ,"r",stdin );
// freopen("output.txt","w",stdout);
ll dp[100000+5][6];
ll arr[100000+5][5];
int n;
ll maxSum(int i,int last){
    if(dp[i][last]!=-1 ) return dp[i][last];
    if(i==n) return 0;
    if(last==0)
        return dp[i][last]=max(maxSum(i+1,1)+arr[i][1],maxSum(i+1,2)+arr[i][2]);
    if(last==1)
        return dp[i][last]=max(maxSum(i+1,0)+arr[i][0],maxSum(i+1,2)+arr[i][2]);
    if(last==2)
        return dp[i][last]=max(maxSum(i+1,0)+arr[i][0],maxSum(i+1,1)+arr[i][1]);
    return dp[i][last]=max(maxSum(i+1,2)+arr[i][2],(ll)max(maxSum(i+1,0)+arr[i][0],maxSum(i+1,1)+arr[i][1]));
}
int main(){
    fast();
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++) cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    cout<<maxSum(0,4);
    return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    const auto &pf = prime_factorize(N);
    long long res = N;
    for (auto p : pf) {
        res *= (p.first - 1);
        res /= p.first;
    }
    cout << res << endl;
}



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

using namespace std;

string str;
int k;
set<string> s;
string str2;

void hawawa()
{
	cin >> str;
	cin >> k;
	str2 = str;
	sort(begin(str2), end(str2));
	str2.erase(unique(str2.begin(), str2.end()), str2.end());
	for (auto&& i : str2) {

		s.insert(string(1, i));

		for (int j = 0; j < str.size() && str.substr(j, str.size() - j).find(i) != string::npos ; j++) {
			j = str.substr(j, str.size() - j).find(i) + j;
			for (int l = 2; l <= 5 && j + l <= str.size(); l++) {
				s.insert(str.substr(j, l));
			}
		}

		if (s.size() >= k) break;
	}
	for (auto i = s.begin(); i != s.end(); i++) {
		k--;
		if (!k) {
			cout << *i << "\n";
			return;
		}
	}
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,A,B;
  cin>>N>>A>>B;
  ll x=A,y=B;
  if(x>y){
    if((x-y)%2==0){cout<<(x-y)/2<<endl;return 0;}
  }
  else if(x<y){
    if((y-x)%2==0){cout<<(y-x)/2<<endl;return 0;}
  }
  A=min(x,y);
  B=max(x,y);
  ll wayto1=(A-1+B-1+1)/2;
  ll waytoN=(N-A+N-B+1)/2;
  cout<<min(wayto1,waytoN)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
#define rep(i, n) for(int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(){
    ll n; cin >> n;
    int a[57] = {11,31,41,61,71,101,131,151,211,241,251,271, //12
    281,311,331,401,421,431,461,491,521,541,571,601,631,641,//14
    661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,//14
    1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,//11  
    1361,1381,1451,1471,1481,1511}; // 6
    for(int i = 0; i < n; i++){
        cout << a[i] << " ";
    }
    cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,W,H,L;
vector<P> t;

bool check(P p,int a){
  if(p.first<p.second)
    return (p.first<=a&&a<=p.second);
  return (p.first<=a||a<=p.second);
}
int calcArg(int x,int y){
  if(x==0)return y;
  if(y==H)return H+x;
  if(x==W)return H+W+H-y;
  return H+W+H+W-x;
}

int calcLU(int x,int y){
  int d=min(x,H-y);
  return calcArg(x-d,y+d);
}
int calcLD(int x,int y){
  int d=min(x,y);
  return calcArg(x-d,y-d);
}
int calcRU(int x,int y){
  int d=min(W-x,H-y);
  return calcArg(x+d,y+d);
}
int calcRD(int x,int y){
  int d=min(W-x,y);
  return calcArg(x+d,y-d);
}

int solve(int si){
  int res=1,last=t[si].second;
  for(int i=si;i<si+N;i++){
    if(check(t[i],last)) continue;
    res++;
    last=t[i].second;
  }
  return res;
}

int main(){
  cin>>N>>W>>H;
  L=W+W+H+H;
  for(int i=0;i<N;i++){
    int x,y,s;
    char ch;
    P p;
    cin>>x>>y>>ch;
    if(ch=='N'){
      s=calcArg(x,H);
      p.first = (s-H+y+L)%L;
      p.second = (s-y+H)%L;
    }
    if(ch=='E'){
      s=calcArg(W,y);
      p.first = (s-W+x+L)%L;
      p.second = (s-x+W)%L;
    }
    if(ch=='S'){
      s=calcArg(x,0);
      p.first = (s-y+L)%L;
      p.second = (s+y)%L;
    }
    if(ch=='W'){
      s=calcArg(0,y);
      p.first = (s-x+L)%L;
      p.second = (s+x)%L;
    }
    
    t.push_back(p);
  }
  for(int i=0;i<N;i++) swap(t[i].first,t[i].second);
  sort(t.begin(),t.end());
  for(int i=0;i<N;i++) t.push_back(t[i]);
  for(int i=0;i<N+N;i++) swap(t[i].first,t[i].second);
  int ans = N;
  for(int i=0;i<N;i++)ans = min(ans,solve(i));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3124
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

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

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

  def size(self, x):
    return -self.parents[self.find(x)]

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

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

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

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

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
AB = []
for _ in range(M):
  A, B = map(int, input().split())
  AB.append((A-1, B-1))

uf = UnionFind(N)
unhappy = [N*(N-1)//2]

def conb(x):
  return x*(x-1)//2

for A, B in reversed(AB):
  old_ap, old_bp = uf.find(A), uf.find(B)
  if old_ap == old_bp:
    uf.union(A, B)
    unhappy.append(unhappy[-1])
  else:
    old_happy = conb(uf.size(old_ap)) + conb(uf.size(old_bp))
    uf.union(A, B)
    new_happy = conb(uf.size(A))
    happy = new_happy - old_happy
    unhappy.append(unhappy[-1] - happy)

print(*reversed(unhappy[:-1]), sep="\n")

Measured memory_bytes: 96776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iterator>
#include <cstdlib>

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

using namespace std;

vector<string> split(const string &str, char delim)
{
	vector<string> res;
	size_t current = 0, found;
	while((found = str.find_first_of(delim, current)) != string::npos)
	{
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main()
{
	string t;
	while(true)
	{
		getline(cin,t);
		if(t == "0") break;

		int n = atoi(t.c_str());
		
		vector<pair<int,string> > v;
		vector<string> temp;
		map<string,int> m;
		rep(i,n)
		{
			string s;
			getline(cin,s);
			temp.push_back(s);
		}

		string ret;
		getline(cin,ret);

		rep(i,temp.size())
		{
			vector<string> st = split(temp[i],' ');

			rep(j,st.size())
			{
				if(ret[0] == st[j][0]) m[st[j]]++;
			}
		}

		map<string,int>::iterator ite;
		for(ite = m.begin();ite != m.end();ite++)
		{
			v.push_back(make_pair(-ite->second,ite->first));
		}

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


		int cnt = 0;

		rep(i,v.size())
		{
			if(cnt == 0 && v[i].second[0] == ret[0])
			{
				cnt++;
				cout << v[i].second;
			}
			else if(0 < cnt && cnt < 5 && v[i].second[0] == ret[0])
			{
				cnt++;
				cout << " " << v[i].second;
			}
		}

		if(cnt == 0) cout << "NA" << endl;
		else cout << endl;
	}
}

Measured memory_bytes: 1224
n,k = list(map(int,input().split()))
a=[]
d=[]
c=0
for i in range(k):
    d+=[int(input())]
    a+=list(map(int,input().split()))
    
for i in range(1,n+1):
    if i in a:
        continue
    else:
        c+=1
print(c)

Measured memory_bytes: 9040
#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll modInverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

bool prime[100005];

void Sieve(int n)
{
    //bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    /*for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";*/
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 1e6 + 5;
ll mod = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x,n;
    cin >> x >> n;
    int arr[n];
    vector<int> v;
    int cnt[110];
    mem(cnt,0);
    for(int i=0;i<n;i++)
    {
        cin >> arr[i];
        cnt[arr[i]]++;
    }
    for(int i=0;i<110;i++)
    {
        if(cnt[i] == 0)
            v.push_back(i);
    }
    sort(v.begin(),v.end());
    int ans = x;
    int d = 100000000;
    for(auto y : v)
    {
        int p = abs(y-x);
        if(d > p)
        {
            d = p;
            ans = y;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3660
#include <stdio.h>
int main()
{
    long sum;
    int min, max, a[10000], n, i;
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &a[i]);// can do that!?
        if (i == 0) {
            max = a[i];
            min = a[i];
        }
        else if (a[i] > max) {
            max = a[i];
        }
        else if (a[i] < min) {
            min = a[i];
        }
        sum += a[i];
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}

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

#define ll long long
#define N 100005
#define mod 1000000007

ll ten[12],two[12];

void pre()
{
    ten[0]=1;two[0]=1;
    
    for(ll i=1;i<12;i++)
    {
        ten[i]=ten[i-1]*10;two[i]=two[i-1]*2;
    }
    
    
}
void f(string s,int n)
{
    ll i,ans=0,dig,j;
    
    for(i=0;i<n;i++)
    {
        dig=s[i]-'0';
        for(j=0;j<n-i;j++)
        {
            ans+=((dig*ten[j]*two[max(n-2-j-i,0ll)])*two[i]);   // two[i] at the last is for the '+'s that can occur at
        }                                                       // the left side of that position..                             
    }
    
    cout<<ans<<endl;
    
}
int main() 
{
  pre();
  int n ;
  string s;
  cin>>s;
  n=s.length();
  f(s,n);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
const int maxn=2e5+100;
const ll mod=1e9+7;
const int INF=1e7;

int a[5000];

int main()
{
    int x,y,n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int flag=0;
    for(int i=1;i<=n;i++){
        if(a[i]!=i){
            swap(a[i],a[a[i]]);
            flag++;
        }
    }
    if(flag<=1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 10005

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

int dp[ARRAY_MAX];//位置iに行くのに必要なジャンプの最小回数

int main() {

	int D, L;
	cin >> D >> L;
	
	for (int i = 0; i < ARRAY_MAX; i++)
	{
		dp[i] = INF;
	}

	dp[0] = 0;

	for (int i = 0; i <= D; i++)
	{
		if (i + 1 <= D)
		{
			dp[i + 1] = min(dp[i + 1], dp[i] + 1);
		}
	}
	for (int i = 0; i <= D; i++)
	{
		if (i + L <= D)
		{
			dp[i + L] = min(dp[i + L], dp[i] + 1);
		}
	}
	cout << dp[D] << endl;



	return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {
	
	public static void countABC(char[] arr) {
		int counter = 0;
		for (int count = 0; count < arr.length - 2; count++) {
			if(arr[count] == 'A' && arr[count + 1] == 'B' &&
				arr[count + 2] == 'C') counter++;
		}
		System.out.println(counter);
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		scan.nextInt();
		countABC(scan.next().toCharArray());
		scan.close();
	}

}


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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define d(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


#define MAX_N 1001
#define MAX_W 10001
LL N,W,dp[MAX_N][MAX_W],v[MAX_N],w[MAX_N],maxv=0;

int main(void){
    cin>>N>>W;
    REP(i,N){
        cin>>v[i]>>w[i];
    }
    REP(i,N)REP(j,W+1){
        if(j<w[i])dp[i+1][j]=dp[i][j];
        else dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
    }
    cout<<dp[N][W]<<endl;
    return 0;
}



Measured memory_bytes: 10924
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0560

"""
import sys
from sys import stdin
input = stdin.readline


def solve(M, N, K, field):
    dp_J = [[0] * (N+1) for _ in range(M+1)]
    dp_O = [[0] * (N+1) for _ in range(M+1)]
    dp_I = [[0] * (N+1) for _ in range(M+1)]
    for y in range(M):
        t_J = [0] * (N+1)
        t_O = [0] * (N+1)
        t_I = [0] * (N+1)
        for x in range(N):
            land = field[y][x]
            if land == 'J':
                t_J[x+1] = t_J[x] + 1
                t_O[x+1] = t_O[x]
                t_I[x+1] = t_I[x]
            elif land == 'O':
                t_J[x+1] = t_J[x]
                t_O[x+1] = t_O[x] + 1
                t_I[x+1] = t_I[x]
            else:
                t_J[x+1] = t_J[x]
                t_O[x+1] = t_O[x]
                t_I[x+1] = t_I[x] + 1

        for x in range(1, N+1):
            dp_J[y+1][x] = dp_J[y][x] + t_J[x]
            dp_O[y+1][x] = dp_O[y][x] + t_O[x]
            dp_I[y+1][x] = dp_I[y][x] + t_I[x]

    for _ in range(K):
        result = [0, 0, 0]
        y1, x1, y2, x2 = map(int, input().split())
        result[0] = dp_J[y2][x2] - dp_J[y1-1][x2] - dp_J[y2][x1-1] + dp_J[y1-1][x1-1]
        result[1] = dp_O[y2][x2] - dp_O[y1-1][x2] - dp_O[y2][x1-1] + dp_O[y1-1][x1-1]
        result[2] = dp_I[y2][x2] - dp_I[y1-1][x2] - dp_I[y2][x1-1] + dp_I[y1-1][x1-1]
        print(' '.join(map(str, result)))


def solve3(M, N, K, field):
    dp_J = [[0] * (N+1) for _ in range(M+1)]
    dp_O = [[0] * (N+1) for _ in range(M+1)]
    for y in range(1, M+1):
        for x in range(1, N+1):
            land = field[y-1][x-1]
            if land == 'J':
                dp_J[y][x] = dp_J[y-1][x] + dp_J[y][x-1] - dp_J[y-1][x-1] + 1
                dp_O[y][x] = dp_O[y-1][x] + dp_O[y][x-1] - dp_O[y-1][x-1]
            elif land == 'O':
                dp_J[y][x] = dp_J[y-1][x] + dp_J[y][x-1] - dp_J[y-1][x-1]
                dp_O[y][x] = dp_O[y-1][x] + dp_O[y][x-1] - dp_O[y-1][x-1] + 1
            else:
                dp_J[y][x] = dp_J[y-1][x] + dp_J[y][x-1] - dp_J[y-1][x-1]
                dp_O[y][x] = dp_O[y-1][x] + dp_O[y][x-1] - dp_O[y-1][x-1]

    for _ in range(K):
        result = [0, 0, 0]
        y1, x1, y2, x2 = map(int, input().split())
        result[0] = dp_J[y2][x2] - dp_J[y1-1][x2] - dp_J[y2][x1-1] + dp_J[y1-1][x1-1]
        result[1] = dp_O[y2][x2] - dp_O[y1-1][x2] - dp_O[y2][x1-1] + dp_O[y1-1][x1-1]
        result[2] = (x2 - x1 + 1) * (y2 - y1 + 1) - result[0] - result[1]
        print(' '.join(map(str, result)))


def main(args):
    M, N = map(int, input().split())
    K = int(input())
    field = [input().strip() for _ in range(M)]
    solve3(M, N, K, field)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 86960
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int h, w, k;
ll dp[110][10];

bool check(int bit) {
  REP(i, w - 2) {
    int a = (bit >> i) & 1;
    int b = (bit >> (i + 1)) & 1;
    if (a && b) return false;
  }

  return true;
}

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

  cin >> h >> w >> k;
  k--;

  dp[0][0] = 1;
  REP(i, h) REP(j, w) REP(bit, 1 << (w - 1)) {
    if(check(bit)) {
      if(bit & (1 << j)) dp[i + 1][j + 1] = dp[i + 1][j + 1] + dp[i][j] % mod;
      else if(j > 0 && bit & (1 << (j - 1))) dp[i + 1][j - 1] = dp[i + 1][j - 1] + dp[i][j] % mod;
      else dp[i + 1][j] = dp[i + 1][j] + dp[i][j] % mod;
    }
  }

  cout << dp[h][k] % mod << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, mult;
    cin >> a >> b;
    mult = a * b;
    if ((mult % 2 != 0) || ((mult * 2) % 2 != 0) || ((mult * 3) % 2 != 0))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
K = gets.to_i

def get_snuke_num(digit)
  res = []
  base = 10 ** (digit - 2)
  geta = ('9' * (digit - 2)).to_i

  min_s = Float::INFINITY

  999.downto(10) do |i|
    s = i * base + geta
    v = s / s.to_s.chars.map(&:to_i).inject(:+).to_f
    next if min_s < v
    min_s = v

    res << s
  end

  res.reverse
end

snuke_nums = [*1..9]

keta = 2
while snuke_nums.size <= K
  snuke_nums += get_snuke_num(keta)
  snuke_nums.uniq!
  keta += 1
end

puts snuke_nums.take(K)



Measured memory_bytes: 2044
n = int(input())
l = []
B = 0
for i in range(n):
    a,b = map(int,input().split())
    l.append((a,b))
l.sort(reverse=True,key=lambda x:x[0]+x[1])
ans = 0
for i in range(n):
    if i %2 ==0:
        ans += l[i][0]
    else:
        ans -= l[i][1]
print(ans)

Measured memory_bytes: 86252
#include<stdio.h>

int main()
{
	int StrLen, LinkNum;
	int EndNum[50] = {0};
	int link[50][2];
	scanf("%d %d", &StrLen, &LinkNum);
	for (int i = 0; i < LinkNum; i++)
		scanf("%d,%d", &link[i][0], &link[i][1]);
	for (int i = 1; i <= StrLen; i++)
	{
		int posi = i;
		for (int j = 0; j < LinkNum; j++)
		{			
			if (link[j][0] == posi)
				posi = link[j][1];
			else if (link[j][1] == posi)
				posi = link[j][0];				
		}
		EndNum[posi-1] = i;
	}
	for (int i = 0; i < StrLen; i++)
		printf("%d\n", EndNum[i]);
	return 0;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

vector<int> C;

int solve(vector<int>& A) {
    int n = A.size();
    vector<int> B;
    B.resize(n);
    for (int i = n - 1; i >= 0; i--) {
        if (i == n - 1) {
            B[i] = 0;
        } else {
            if (A[i] >= A[i+1]) {
                B[i] = B[i+1] + 1;
            } else {
                B[i] = 0;
            }
        }
    }
    /*
    cout << "A: " << A << endl;
    cout << "B: " << B << endl;
    */
    return *max_element(B.begin(), B.end());

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    vector<int> A;
    cin >> n;
    A.resize(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    cout << solve(A) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
 
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
 
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
 
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
ll a,b;
bool alice;
int main(){
 
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
	cin>>a>>b;
	if(abs(a-b)<=1) cout<<"Brown\n";
	else cout<<"Alice\n";
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I]*(N*2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


Measured memory_bytes: 81468
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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



int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256