akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    int n;
    std::cin >> n;
    std::cout << ceil(double(n)/2) << std::endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int n, x;

int main(void){
	while(true){
		cin >> n >> x;
		if(n == 0 and x == 0) break;

		int res = 0;
		for(int i = 1; i < n; i++){
			for(int j = i+1; j < n; j++){
				int y = x - i - j;
				if(j<y and y<=n and y!=i and y!=j) res++;
			}
		}

		cout << res << '\n';
	}

	return 0;
}


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

int main(){
  int N,M,X,Y;cin>>N>>M>>X>>Y;
  int a[N+10],b[M+10];
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<M;i++)cin>>b[i];
  sort(a,a+N);
  sort(b,b+M);
  int t=1;
  for(int Z=-100;Z<=100;Z++){
    if(X<Z&&Z<=Y&&a[N-1]<Z&&Z<=b[0]){
      t=0;
    }
  }
  if(t==1){
    cout<<"War"<<endl;
  }else{
    cout<<"No War"<<endl;
  }
}

Measured memory_bytes: 256
def include3(n):
    while n!=0:
        if n%10 == 3:
            return True
        n //= 10
    return False
n = int(input())
d = [x for x in range(1 ,n+1) if (x % 3 == 0)|(x % 10 == 3)|(include3(x))]
s = ''
for i in d:
    s += ' {}'.format(i)
print(s)

Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,w,x,sum=0;
	cin>>n>>m;
	bool a[n+1];
	for(int i=1;i<=n;i++)
		a[i]=true;
	for(int i=1;i<=m;i++)
	{
		cin>>x;
		for(int i=1;i<=x;i++)
		{
			cin>>w;
			a[w]=false;
		}
	}
	for(int i=1;i<=n;i++)
	if(a[i])
		sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(){

    int x[4];

    for(int i=0; i<5; i++){
        scanf("%d", &x[i]);
    }

    for(int j=0; j<5; j++){
        if(x[j] == 0){
            printf("%d\n", j+1);
        }
    }
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int an,bn,m;
	cin>>an>>bn>>m;
	
	vi a(an),b(bn);
	REP(i,an) cin>>a[i];
	REP(i,bn) cin>>b[i];
	
	int ans=INF;
	REP(i,m){
		int x,y;
		int c;
		cin>>x>>y>>c;
		chmin(ans,a[x-1]+b[y-1]-c);
	}
	
	sort(ALL(a));
	sort(ALL(b));
	chmin(ans,a[0]+b[0]);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
   string s;
   cin>>s;
   int count=0;
  for(int i=0;i<n;i++)
  {
     if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
     count++;
  }
 cout<<count<<endl;




    return 0;
}







Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(a*b/2);
		sc.close();
	}
}


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

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), m = sc.nextInt();
        long[][] d = new long[n][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                d[i][j] = sc.nextLong();
            }
        }
        long[][] sum = new long[8][n];
        for (int i = 0; i < n; i++) {
            sum[0][i] = d[i][0] + d[i][1] + d[i][2];
            sum[1][i] = d[i][0] + d[i][1] - d[i][2];
            sum[2][i] = d[i][0] - d[i][1] + d[i][2];
            sum[3][i] = d[i][0] - d[i][1] - d[i][2];
            sum[4][i] = -d[i][0] + d[i][1] + d[i][2];
            sum[5][i] = -d[i][0] + d[i][1] - d[i][2];
            sum[6][i] = -d[i][0] - d[i][1] + d[i][2];
            sum[7][i] = -d[i][0] - d[i][1] - d[i][2];
        }
        long ans = Long.MIN_VALUE;
        for (int i = 0; i < 8; i++) {
            Arrays.sort(sum[i]);
            long sumsum = 0;
            for (int j = n - 1; j >= n - m; j--) {
                sumsum += sum[i][j];
            }
            ans = Math.max(ans, sumsum);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 30060
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
//vector <pair <long long int,int>> p[8];
long long int n,m;
string s;
int main(void)
{
  cin >> n;    
  int binary = 0;
  int base = 1;
  if(n==0){
      cout << '0';
      return 0;
  }
  while(n!=0){
    if(n > 0){
        if(n % (-2) == 0){
            //s.std::insert(0, '0');
            s.push_back('0');
        }else{
//            s.std::insert(0, '1');
            s.push_back('1');

        }
       // cout << n << (n % (-2)) <<endl;
        n = n / (-2);
        base = base * 10;
    }else{
        n = -n;
            if(n % (-2) == 0){
            //s.std::insert(0, '0');
            s.push_back('0');
        }else{
//            s.std::insert(0, '1');
            s.push_back('1');

        }
        //cout << n << (n % (-2)) <<endl;
        //n = n / (-2);
        n = ceil((double)n / (double)(2));
        base = base * 10;
    }
  } 

  std::reverse(s.begin(), s.end());
  std::cout << s << std::endl;
 return 0;
}


Measured memory_bytes: 256
// 解説見た
#include <bits/stdc++.h>
using namespace std;
int main() {
	double n,m,d; cin >> n >> m >> d;
	if (d==0) {
		cout << std::fixed << std::setprecision(15) << (m-1) / n << endl;
	}
	else {
		cout << std::fixed << std::setprecision(15) << 2 * (n-d) * (m-1) / pow(n,2) << endl;
	}
}

Measured memory_bytes: 3704
#include<cstdio>
using namespace std;

int ans, n, a[105];

bool dfs(int dep, int sum)
{
    if (dep > ans || sum<<(ans-dep) < n || sum <= 0) return false;
    a[dep] = sum;
    if (sum == n || sum<<(ans-dep) == n) return true;
    for (int i = 0; i <= dep; ++i)
        if (dfs(dep+1, sum+a[i]) || dfs(dep+1, sum-a[i])) return true;
    return false;
}

int main()
{
    while (~scanf("%d", &n) && n)
        for (ans = 0; ; ++ans)
            if (dfs(0,1)) {printf("%d\n", ans); break;}
    return 0;
}


Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;



static int dp[5005][5005];


int main(void){
    int N;
    string S;
    MEMSET(dp, 0);
    cin >> N >> S;
    S = " " + S;
    int Maximum = 0;
    for(int i = N; i > 0; i--){
        for(int j = N; j > 0; j--){
            if(S[i] == S[j]){
                /*cout << i << " Passed " <<j << endl;
                for(int i = N; i > 0; i--){
                    for(int j = N; j > 0; j--){
                        cout << dp[i][j] << " ";
                    }
                    cout << endl;
                }
                cout << dp[i+1][j+1] << endl;*/
                dp[i][j] = (dp[i+1][j+1]+1);
            }
        }
    }
    for(int i = N; i > 0; i--){
        for(int j = N; j > 0; j--){
            /*cout << dp[i][j] << " ";*/
            if(i >= j) continue;
            Maximum = max(Maximum, min(dp[i][j], j-i));
        }
        //cout << endl;
    }
    cout << Maximum << endl;
    return 0;
}


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

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();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#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())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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(void){
    int N,M; cin >> N >> M;
    vector<ll> x(N), y(N), z(N); REP(i,N) cin >> x[i] >> y[i] >> z[i];
    
    ll ans = 0;
    REP(i,1<<3){
        vector<ll> xx(N), yy(N), zz(N);
        if(i & 1<<0) REP(j,N) xx[j] = x[j];
        else REP(j,N) xx[j] = -x[j];
        if(i & 1<<1) REP(j,N) yy[j] = y[j];
        else REP(j,N) yy[j] = -y[j];
        if(i & 1<<2) REP(j,N) zz[j] = z[j];
        else REP(j,N) zz[j] = -z[j];

        vector<ll> val(N); REP(j,N) val[j] = xx[j]+yy[j]+zz[j];
        SORT(val); REVERSE(val);
        ll tmp = 0; REP(j,M) tmp += val[j];
        chmax(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

#define LAST '{'
#define MOD 1000000007

using namespace std;

int comb,len,syurui=0;
vector<int> table(100, 0);
long long dp[30][30][30];
long solve(int now,int nokori,int used) {

    if(dp[now][nokori][used]!=-1) return dp[now][nokori][used];
	if (!used) {
		return 1;
	}
	if ( nokori<comb-used || table[now] == 0) {
		return 0;
	}
    return dp[now][nokori][used]=(solve(now + 1, nokori-1, used) +solve(now + 1, nokori-1, used-1)*table[now])%MOD;
}

int main()
{
	string S;
	int N;
	int i,tmp;
	long ans;

	cin >> N;
	cin >> S;
	len = S.length();
	for (i = 0; i < len; i++) {
		tmp = S[i]-'a';
		if ( table[tmp]== 0) {
			syurui++;
		}
		table[tmp]++;
	}
	ans = len;

	sort(table.rbegin(),table.rend());
    memset( dp,-1,sizeof dp);
	for (i = 2; i <= 26; i++) {
		comb = i;
		ans = (ans + solve(0, syurui, i))%MOD;
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		String s = input.next();
		int n = s.length();
		String s1 = s.substring(0,(n-1)/2);
		String s2 = s.substring((n+1)/2,n);
		if(isPalin(s)&&isPalin(s1)&&isPalin(s2))
		    System.out.println("Yes");
		else
		    System.out.println("No");
		
	}
	static boolean isPalin(String s)
	{
	    if(s.length()==1)
	        return true;
	    int i=0,j=s.length()-1;
	    boolean flag = false;
	    while(i<j)
	    {
	        if(s.charAt(i)==s.charAt(j))
	            flag = true;
	        else{
	            flag = false;
	            break;
	        }
	        i++;
	        j--;
	    }
	    return flag;
	}
}

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

int main() {
	int N, A, B, cnta, cntb, cntc;
	cnta = cntb = cntc = 0;
	scanf("%d%d%d", &N, &A, &B);
	for (int i = 0, Pi; i < N; i++) {
		scanf("%d", &Pi);
		if (Pi <= A) ++cnta;
		else if (Pi <= B) ++cntb;
		else ++cntc;
	}

	printf("%d\n", std::min(cnta, std::min(cntb, cntc)));
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    if(n>=30)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3644
### main

while true
  n = gets.strip.to_i
  break if n == 0

  ns = n.times.map{gets.strip.to_i}

  count = 0

  (n - 1).step(1, -1).each do |i|
    for j in (0...i)
      if ns[j] > ns[j + 1]
        tmp = ns[j]
        ns[j] = ns[j + 1]
        ns[j + 1] = tmp
        count += 1
      end
    end
  end

  puts count
end

Measured memory_bytes: 6116
use proconio::marker::Usize1;
use proconio::{fastout, input};
use std::collections::{BTreeSet, HashSet};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        m: usize,
        bomb: [(Usize1, Usize1); m],
    }

    let mut h_cnt = vec![0u32; h];
    let mut w_cnt = vec![0u32; w];
    let mut bset = HashSet::new();
    for (b1, b2) in bomb.iter().copied() {
        h_cnt[b1] += 1;
        w_cnt[b2] += 1;
        bset.insert((b1, b2));
    }

    let h_max = h_cnt.iter().max().copied().unwrap();
    let w_max = w_cnt.iter().max().copied().unwrap();

    let mut h_i_v = vec![];
    let mut w_i_v = vec![];
    for i in 0..h {
        if h_cnt[i] == h_max {
            h_i_v.push(i);
        }
    }
    for i in 0..w {
        if w_cnt[i] == w_max {
            w_i_v.push(i);
        }
    }

    let mut ok = false;
    'outer: for h_i in h_i_v.iter().copied() {
        for w_i in w_i_v.iter().copied() {
            // contains判定されるのは最大でもm回まで
            if !bset.contains(&(h_i, w_i)) {
                ok = true;
                break 'outer;
            }
        }
    }

    let ans = h_max + w_max;
    let ans = if ok { ans } else { ans - 1 };
    println!("{}", ans);
}


Measured memory_bytes: 26460
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};
#[proconio::fastout]
fn main() {
    proconio::input!{
        s: String,
        t: String,
    }
    if &s[..] == &t[..(s.len())] { println!("Yes"); }
    else { println!("No"); }
}


Measured memory_bytes: 2164
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
    queue<int> ans;
    int n, k;
    cin >> n; cin >> k;
    for(int i=0;i < k;++i) {
        int ai, bi; cin >> ai >> bi;
        ans.push( (min(ai-1, min(n-ai, min(bi-1, n-bi)))) % 3);
    }

    while (!ans.empty()) {
        cout << ans.front()+1 << endl;
        ans.pop();
    }

    return 0;
}

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

int main()
{
	int64_t a,b,n;
	cin >> a >> b >> n;

	int64_t nmod=b-1;
	int64_t target=min(nmod,n);
	//fprintf(stderr,"nmod %lld, target %lld\n",nmod,target);
	cout << a*target/b - a*(target/b) << endl;
}








Measured memory_bytes: 3536
#include <iostream>

using namespace std;
int main()
{
    int k, x;
    cin >> k >> x;

    int min, max;
    min = x - (k - 1);
    max = x + (k - 1);
    
    if(min < -1000000) min = -1000000;
    if(max > 1000000) max = 1000000;
    
    // 出力
    for(int i=min; i<max+1; i++){
        cout << i << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A_list = [[int(i) for i in input().split()] for n in range(N)] 

A_list[0].pop(0)
a = A_list[0]
for i in range(1, N):
  A_list[i].pop(0)
  a = set(a) & set(A_list[i])

if len(a)==0:
  print(0)
else:
  print(len(a))

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum = 0;
    int[] ar = new int[n];
    for(int i=0;i<n;i++){
      ar[i] = sc.nextInt();
    }
    int max = ar[0];
    for(int j=1;j<n;j++){
      if(max < ar[j]){
        max = ar[j];
      }
    }
    for(int k=0;k<n;k++){
      sum += ar[k];
    }
    if(max < sum - max){
      System.out.println("Yes");
    } else if (max >= sum - max){
      System.out.println("No");
  }
}
}

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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, res = 0;
    cin >> n;
    if(!(n&1)) {
        n /= 2;
        while(n > 0) {
            res += n/5;
            n /= 5;
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define M 1000211 /* your task*/
#define L 14
 
char H[M][L]; /* Hash Table */

int getChar(char);
long long getKey(char *);
int Hash1(int);
int Hash2(int);
void find(char *);
void IN(char *);

int main()
{
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ )
    {
      scanf("%s %s", com, str);
      
      if ( com[0] == 'i' )
	{
	  IN(str);
	}
      else
	{
	  find(str);
	}
    }
  
  return 0;
}

int getChar(char ch)
{
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[])
{
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ )
    {
      sum += p*(getChar(str[i]));
      p *= 5;
    }
  return sum;
}

int Hash1(int K)
{
  return K%M;
}

int Hash2(int K)
{
  return 1+(K%(M-1));
}

void find(char str[])
{
  long long K;
  int hash,i=0;
  K=getKey(str);
  
  while(1)
    {
      hash=( (Hash1(K)) + i*(Hash2(K)) )%M;
      if(strcmp(H[hash],str)==0)
	{
	  printf("yes\n");
	  break;
	}
      else if(strlen(H[hash])==0)
	{
	  printf("no\n");
	  break;
	}
      i++;
    }
}

void IN(char str[])
{
  long long K;
  int hash,i=0;
  K=getKey(str);
  
  while(1)
    {
      hash=( (Hash1(K)) + i*(Hash2(K)) )%M;
      if(H[hash][0]=='\0')break;
      i++;
    }
  
  strcpy(H[hash],str);
}



Measured memory_bytes: 15384
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n,m;
    cin>>n>>m;
    int sum = 0;

    rep(i,m){
        int a;
        cin>>a;
        sum+=a;
    }
    cout<<(n-sum<0?-1:n-sum)<<endl;

return 0;
}


Measured memory_bytes: 3636
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<list>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//for(int i=0;i<n;i++){cout<<que[i]<<(i+1<n?" ":"\n");}
void solve(int n,double x,double y,int rad,double nga){
	nga/=3;
	if(n>0){
		solve(n-1,x,y,rad,nga);
		solve(n-1,x+nga*cos(rad*pai/6),y+nga*sin(rad*pai/6),rad+2,nga);
		solve(n-1,x+nga*sqrt(3)*cos((rad+1)*pai/6),y+nga*sqrt(3)*sin((rad+1)*pai/6),rad-2,nga);
		solve(n-1,x+nga*2*cos(rad*pai/6),y+nga*2*sin(rad*pai/6),rad,nga);
	}else{cout<<x<<" "<<y<<endl;}
}
int main(void){
	//cin.tie(0);
	cout<<setprecision(20);
	ios::sync_with_stdio(false);
	int n;cin>>n;
	solve(n,0,0,0,100.0);
	cout<<"100.0 0.0"<<endl;
	return 0;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 

int main(){
  int n ,i;
  cin>>n;
  int arr[n];
  for(i=0;i<n;++i) cin>>arr[i];
  sort(arr,arr+n);
  int s=0;
  for(i=0;i<n-1;++i) s+=arr[i];
    if(arr[n-1]<s) cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse.csgraph import shortest_path

N,X,Y = map(int,input().split())

l = [[0 for _ in range(N)] for _ in range(N)]

for i in range(1,N):
    l[i-1][i] = 1
    l[i][i-1] = 1
l[X-1][Y-1] = 1
l[Y-1][X-1] = 1

a = np.array(l)

cnt = 1
ans = [0]*(N+1)
for i in shortest_path(a):
    for j in range(cnt,N):
        ans[int(i[j])] += 1
    cnt += 1

for i in range(1,N):
    print(ans[i])

Measured memory_bytes: 134344
a, b, c = [int(i) for i in input().split()]


if a%2 == 1 or b%2 == 1 or c%2 == 1:
    print(0)
elif a == b and b == c:
    print(-1)
else:
    x = a
    y = b
    z = c
    cnt = 0
    while True:
        if x%2 == 1 or y%2 == 1 or z%2 == 1:
            break
        else:
            x, y, z = y//2 + z//2, x//2 + z//2, x//2 + y//2
            cnt += 1

    print(cnt)

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

int main()
{
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int k[15],s[15][15];
int p[15];
int n,m;
int ans;
int check(int x){
	for(int i=0;i<m;i++){
			int l=0;
		for(int j=0;j<k[i];j++){
			l^=((x>>s[i][j])&1);
		}
		if(l!=p[i])
			return 0;
	}
	return 1;
}
int main(){
	
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&k[i]);
		for(int j=0;j<k[i];j++){
			scanf("%d",&s[i][j]);
			s[i][j]--;
		}
	}
	for(int i=0;i<m;i++)
		scanf("%d",&p[i]);
	ans=0;
	for(int i=0;i<(1<<n);i++){
		if(check(i))
			ans++;
	}
	cout<<ans<<"\n";
}

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

int main() {
    
    int n;
    cin>>n;
    vll a(n);
    ll asum=0,a2=0;
    rep(i,n) {
        cin>>a[i];
        asum+=a[i];
        a2+=a[i]*a[i];
        asum%=1000000007;
        a2%=1000000007;
    }
    asum=(asum*asum)%1000000007;
    ll ans=asum-a2;
    if(ans<0){
        ans+=1000000007;
    }
    if(ans%2==1){
        ans+=1000000007;
    }
    ans/=2;
    cout<<ans<<endl;

}


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

int main(){
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  
  ll need=x/d;
  if(need>=k){
    cout<<x-d*k<<endl;
    return 0;
  }
  ll nokori=k-x/d;
  if(nokori%2==0){
    cout<<x%d<<endl;
  }
  else{
    cout<<d-x%d<<endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;

const LL mo=1e9+7;
LL n,m,a,b;
LL jc[maxn];
LL inv[maxn];
LL f[maxn];
LL sum;
LL ans;

LL ksm(LL a,LL k){
	if(!k)return 1ll;
	return (k&1)?a*ksm(a*a%mo,k>>1)%mo:ksm(a*a%mo,k>>1);
}

LL C(int x,int y){
	return (jc[y]*inv[x]%mo)*inv[y-x]%mo;
}

LL calc(int x,int y,int xx,int yy){
	return C(xx-x,xx+yy-x-y);
}

int main(){
	cin>>n>>m>>a>>b;
	jc[0]=1;
	for(LL i=1;i<maxn;i++)jc[i]=jc[i-1]*i%mo;
	inv[200000]=ksm(jc[200000],mo-2);
	for(LL i=199999;i>=0;i--)inv[i]=inv[i+1]*(i+1ll)%mo;
	ans=calc(1,1,n,m);
	for(int i=1;i<=b;i++){
		f[i]=calc(1,1,n-a+1,i);	
	}
	for(int i=1;i<=b;i++){
		f[i]-=sum;
		f[i]=(f[i]+mo)%mo;
		sum+=f[i];
		if(sum>=mo)sum-=mo;
		ans-=(f[i]*calc(n-a+1,i,n,m))%mo;
		ans=(ans+mo)%mo;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
from sys import stdin

A, B, K = [int(i) for i in stdin.readline().rstrip().split()]

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1
        B += A // 2
        A //= 2

    else:
        if B % 2 == 1:
            B -= 1
        A += B // 2
        B //= 2

print(A, B)


Measured memory_bytes: 3060
n=int(input())
arr=list(map(int,input().split()))
def f(arr):
  if len(arr)==0:
    return 0
  if 0 in arr:
    idx=arr.index(0)
    return f(arr[:idx])+f(arr[idx+1:])
  else:
    return 1+f([i-1 for i in arr])
print(f(arr))

Measured memory_bytes: 3188
S = list(input())
def dfs(s, i):
  if i == len(S) - 1:
    return sum(map(int, s.split("+")))
  return dfs(s + S[i + 1], i + 1) + dfs(s + "+" + S[i + 1], i + 1)

print(dfs(S[0], 0))

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9+7

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

    int n,a,mor = 0,ans = 0;
    vector<bool> c(8);

    cin >> n;

    for(int i = 0;i < n;i++)
    {
        cin >> a;
        if(a>=3200) mor++;
        else if(a>=2800) c[7] = true;
        else if(a>=2400) c[6] = true;
        else if(a>=2000) c[5] = true;
        else if(a>=1600) c[4] = true;
        else if(a>=1200) c[3] = true;
        else if(a>=800) c[2] = true;
        else if(a>=400) c[1] = true;
        else c[0] = true;
    }

    for(int i = 0;i < 8;i++)
        if(c[i]) ans++;

    cout << max(ans,1) << ' ' << ans+mor;
}


Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

void main()
{
    auto cin = new Scanner;
    char[] s;
    cin.scan(s);
    long sum;
    foreach (i; 0 .. (1 << s.length - 1))
    {
        long res = s[0] - '0';
        foreach (j; 0 .. s.length - 1)
        {
            if ((i >> j) & 1) {
                sum += res;
                res = s[j + 1] - '0';
            }
            else
            {
                res *= 10;
                res += s[j + 1] - '0';
            }
        }
        sum += res;
    }
    writeln(sum);
}


Measured memory_bytes: 364
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>

#define MOD 1000000007

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int x;
	cin >> x;
  if(x>=30){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}

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

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

    vector<int> A(3);
    REP(i, 3) cin >> A[i];
    int k;
    cin >> k;
    sort(A.begin(), A.end(), greater<int>());
    REP(i, k) A[0] *= 2;
    long long ans = 0;
    REP(i, 3) ans += A[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int r, D, x;
    cin >> r >> D >> x;

    REP(i, 10) {
        std::cout << r * x - D << '\n';
        x = r * x - D;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    map<int, int> count;

    for (int i = 0; i < 3; i++) {
        int ai;
        cin >> ai;
        count[ai]++;
    }

    for (auto i: count) {
        if (i.second == 1) {
            cout << i.first << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

def cul(x):
    ans = (1 + x)*x/(2*x)
    return ans

p = list(map(cul, list(map(int, input().split()))))
cnt = sum(p[0:k])
ans = cnt
for i in range(k, n):
    cnt += p[i] - p[i - k]
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 100384
package main

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

func main() {
	scanInit()

	H = nextInt()
	W = nextInt()
	s := nextGrid(H, W)
	x, y := 0, 0
	for {
		s[y][x] = "a"
		if x == W-1 && y == H-1 {
			break
		}
		nextx := 0
		nexty := 0
		// 12時から時計回り ２方向
		dx := []int{+1, +0}
		dy := []int{+0, +1}

		dnum := len(dx)
		cnt := 0
		for d := 0; d < dnum; d++ {
			ni := y + dy[d]
			nj := x + dx[d]

			// 領域外なら探索せずにスルー
			if ni < 0 || H <= ni || nj < 0 || W <= nj {
				continue
			}
			if s[ni][nj] == "#" {
				// Bomb HIT
				cnt++
				nextx = nj
				nexty = ni
			}
		}
		if cnt == 0 {
			fmt.Println("Impossible")
			return
		}

		x = nextx
		y = nexty
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if s[i][j] == "#" {
				fmt.Println("Impossible")
				return
			}
		}
	}

	fmt.Println("Possible")
	return
}

// DBGprintGrid print the grid
//! DBG
func DBGprintGrid(g [][]string) {
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Printf("%s", g[i][j])
		}
		fmt.Printf("\n")
	}
}

// 周りからtargetを探す
func getBombnum(i, j int, target string, s [][]string) int {
	cnt := 0

	//* 検索方向設定
	// 12時から時計回り ８方向
	//dx := []int{+0, +1, +1, +1, +0, -1, -1, -1}
	//dy := []int{-1, -1, +0, +1, +1, +1, +0, -1}
	// 12時から時計回り ４方向
	dx := []int{+0, +1, +0, -1}
	dy := []int{-1, +0, +1, +0}

	dnum := len(dx)
	for d := 0; d < dnum; d++ {
		ni := i + dy[d]
		nj := j + dx[d]

		// 領域外なら探索せずにスルー
		if ni < 0 || H <= ni || nj < 0 || W <= nj {
			continue
		}
		if s[ni][nj] == target {
			// Bomb HIT
			//fmt.Println("DBG HIT") //! DBG
			cnt++
		}
	}

	return cnt
	//return "" + string(cnt+'0') // 文字列で返したいとき
}

// read func
func nextGrid(a int, b int) [][]string {
	mat := make([][]string, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]string, b)
		tmp := nextStr()
		mat[i] = strings.Split(tmp, "")
	}
	return mat
}

// H =height
var H int

// W =witdh
var W int

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1796
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    string S; cin >> S;
    int ans = 1;
    repr(i,1,N){
        if(S[i] != S[i-1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200010;
int n, a[maxn];
ll ans;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		if ((i == 1 && a[i]) || (i != 1 && a[i] > a[i - 1] + 1)) {
			printf("-1"); return 0;
		}
	}
	for (int i = 1; i <= n; ++i)
		if (i == n || a[i] + 1 != a[i + 1]) ans += a[i];
	printf("%lld", ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <string>
#include <algorithm>
//
//void a(std::istream& in)
//{
//    std::vector<int> xList(5, 0);
//    for (auto& x : xList)
//    {
//        in >> x;
//    }
//
//    std::sort(xList.begin(), xList.end());
//    for (int i = 1; i < 5; ++i)
//    {
//        if (xList[i] == i)
//            continue;
//
//        std::cout << i;
//        return;
//    }
//    std::cout << 5;
//}

void a(std::istream& in)
{
    for (int i = 1; i <= 5; ++i)
    {
        int x;
        in >> x;
        if (x == 0)
        {
            std::cout << i;
            return;
        }
    }
}

int main(int, char* [])
{
    a(std::cin);
    return 0;
}


Measured memory_bytes: 3160
from collections import deque
N = int(input())

edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)

c = list(map(int,input().split()))
c.sort()
c = c[::-1]
max = c[0]
ans = [0 for i in range(N)]

d = [-1 for i in range(N)]
d[0] = 0
ans[0] = c.pop(0)
q = deque([0 * (N - 1)])
while len(q) > 0:
    u = q.popleft()
    for v in edge[u]:
        if d[v] > -1:
            continue
        d[v] = d[u] + 1
        ans[v] = c.pop(0)
        q.append(v)

print(sum(ans) - max)
print(*ans, sep=" ")


Measured memory_bytes: 6404
#include<stdio.h>

int main(){

	int n;
	scanf("%d",&n);
	int S[n];
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);	
	}
	
	int q;
	scanf("%d",&q);
	int T[q];
	for(i=0;i<q;i++){
		scanf("%d",&T[i]);	
	}
	
	int C=0;
	int key=0;
	int k;
	for(i=0;i<q;i++){
		key=T[i];
		for(k=0;k<n;k++){
			if(key==S[k]){
			C++;
			break;
			}
		}
	}
	
	
	printf("%d\n",C);
	return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	ll int t = 1;
	int n;
	cin >> n;
	ll int cnt = 0;
	while(n>t){
		t*=3;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <atcoder/all>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>
using namespace atcoder;
using namespace std;

using Pair = pair<int, int>;
using lint = long long;

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

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main() {
    int n, m;
    cin >> n >> m;
    dsu d(n);
    int ret = n - 1;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (!d.same(a, b)) ret--;
        d.merge(a, b);
    }
    cout << ret << endl;
}


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

using namespace std;
int main() {
  int n;
  cin >> n;
  string blue[n];
  for (int i = 0; i < n; i++) {
    cin >> blue[i];
  }
  int m;
  cin >> m;
  string red[m];
  for (int i = 0; i < m; i++) {
    cin >> red[i];
  }

  int result = 0;
  for (int i = 0; i < n; i++) {
    string s = blue[i];
    int point = 0;
    for (int j = 0; j < n; j++) {
      if (s == blue[j]) point++;
    }
    for (int k = 0; k < m; k++) {
      if (s == red[k]) point--;
    }
    result = max(result , point);
  }

  cout << (result <0 ? 0 : result) <<endl;

  return 0;
}

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

#define int ll

//get vector of prime numbers which is lower than or equal n
vector<int> get_primes(int n)
{
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i])
        {
            res.push_back(i);
            for (int j = 2 * i; j < is_prime.size(); j = j + i)
            {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

vector<pair<int, int>> factorize(int n)
{
    vector<pair<int, int>> res;
    for (int i = 2; i * i <= n; i++)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        res.push_back(make_pair(i, tmp));
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int mpow(int x, int n)
{
    int res = 1;
    while (n != 0)
    {
        if (n & 1)
            res = res * x % INF;
        x = x * x % INF;
        n = n >> 1;
    }
    return res;
}

//mod frac
vector<int> mfrac;
void set_mfrac(int n)
{
    if (mfrac.size() == 0)
    {
        mfrac.push_back(1);
    }
    for (int i = mfrac.size(); i <= n; i++)
    {
        mfrac.push_back((i * mfrac[i - 1]) % INF);
    }
}

//get nCm mod INF
int mcomb(int n, int m)
{
    if (mfrac.size() <= n)
    {
        set_mfrac(n);
    }
    int res = mfrac[n];
    res = res * mpow(mfrac[m], INF - 2) % INF;
    res = res * mpow(mfrac[n - m], INF - 2) % INF;
    return res;
}

vector<int> get_gcd(int n)
{
    vector<int> res;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (i * i == n)
            {
                res.push_back(i);
            }
            else
            {
                res.push_back(i);
                res.push_back(n / i);
            }
        }
    }
    return res;
}

struct cG
{
    int t;
    int A;
    int F;
};

signed main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> F(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> F[i];
    }

    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    int l = -1, r = 1e12;
    while (l + 1 < r)
    {
        ll c = (l + r) / 2;
        // sum(max(0, A[i] - X/F[i])) <= K
        bool ok = [&] {
            ll s = 0;
            for (int i = 0; i < N; i++)
            {
                s += max(0ll, A[i] - c / F[i]);
            }
            return s <= K;
        }();
        if (ok)
            r = c;
        else
            l = c;
    }

    cout << r << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
int main(){
  char s[100010],c[27] = "abcdefghijklmnopqrstuvwxyz";
  scanf("%s",&s);
  for(int i = 0;i < 26;i++){
    int check = 1;
    for(int j = 0;j < strlen(s);j++){
      if(c[i] == s[j]){
        check--;
        break;
      }
    }
    if(check > 0){
      printf("%c\n",c[i]);
      return 0;
    }
  }
  printf("None\n");
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define rreps(i, n) for (int i = (n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

vector<vi32> children;
int dp[100010];

int rec(int v) {
  if (dp[v] != 0) return dp[v];
  int ret = 1, mx = 0;
  for (auto u: children[v]) {
    amax(mx, rec(u));
  }
  return dp[v] = ret + mx;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, m;
  cin >> n >> m;
  children = vector<vi32>(n + 1);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    children[y].push_back(x);
  }
  rep(i, n + 1) rec(i);
  int ans = 0;
  rep(i, n + 1) amax(ans, dp[i]);
  cout << ans - 1 << endl;
  return 0;
}


Measured memory_bytes: 10624
a, b = map(int, input().split())


def mod(n):
    return n % 4


def xor(num):
    if mod(num-1) == 0:
        return 0
    elif mod(num-1) == 1:
        return num
    elif mod(num-1) == 2:
        return 1
    elif mod(num-1) == 3:
        return num + 1


print(xor(a-1) ^ xor(b))


Measured memory_bytes: 3060