akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
x,y=map(int,input().split())
a=list(map(int,input().split()))
lol=[]
for i in a:
    b=bin(i)[2:]
    lol.append("0"*(40-len(b))+b)
d=defaultdict(int)
for i in lol:
    for j in range(1,41):
        if i[-j]=="1":
            d[j]+=1
        else:
            d[j]-=1
            
s=""      
p=0
for i in range(1,41):
    if d[41-i]<0 and p+2**(40-i)<=y:
        s+="1"
        p+=2**(40-i)
    else:
        s+="0"
s=int(s,2)
k=0
for i in a:
    k+=i^s
print(k)    

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

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

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n, q;
VI s(100010), t(50010);

signed main()
{
    cin >> n;
    REP(i, n){
        cin >> s[i];
    }
    cin >> q;
    REP(i, q){
        cin >> t[i];
    }

    s.resize(n);
    VI::iterator ite = unique(ALL(s));
    s.resize(distance(s.begin(), ite));
    t.resize(q);

    int res = 0;
    REP(i, q){
        if (lower_bound(ALL(s), t[i]) != s.end()){
            res += (upper_bound(ALL(s), t[i]) - lower_bound(ALL(s), t[i]));
        } else if (lower_bound(ALL(s), t[i]) == s.end() && upper_bound(ALL(s), t[i]) == s.begin()) {
            res += 1;
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3744
using System;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            char[] input1 = Console.ReadLine().ToArray();
            char[] input2 = Console.ReadLine().ToArray();

            bool flag = true;

            if (input1.Length + 1 == input2.Length)
            {
                for (int i=0;i<input1.Length;i++)
                {
                    if (input1[i].Equals(input2[i])==false)
                    {
                        flag = false;
                    }
                }
            }
            else
            {
                flag = false;
            }

            if (flag)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }


Measured memory_bytes: 26244
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pb push_back
#define mk make_pair
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define mod 1000000007
int main()
{
    ll n;
    cin>>n;
    if(n%1000)
    {
        cout<<1000-n%1000;
    }
    else cout<<0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
string a[100005];
bool flag[100005];
int main()
{
	int n;
	cin>>n;
	map<vector<int>,vector<int> >mp;
	long long sum=0;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		vector<int>cnt(26);
		for(int j=0;j<a[i].size();j++)
			cnt[a[i][j]-'a']++;
		mp[cnt].push_back(i);
	}
	for(int i=0;i<n;i++)
	{
		vector<int>cnt(26);
		for(int j=0;j<a[i].size();j++)
			cnt[a[i][j]-'a']++;
		if(!flag[i]&&mp[cnt].size()!=1)
		{
			for(int j=0;j<mp[cnt].size();j++)
				flag[mp[cnt][j]]=true;
			sum+=mp[cnt].size()*(mp[cnt].size()-1)/2;
		}
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 30848
#include <stdio.h>

int main(void)	{

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


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



int main(int argc, char *argv[]){
  int N;
  cin>>N;
  vector<int> x(N),y(N);
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i];
  }
  pair<int,int> dis[50][50];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      dis[i][j].first=x[i]-x[j];
      dis[i][j].second=y[i]-y[j];
    }
  }

  vector<pair<int,int>> exsist;
  int same[2501]={0};

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j) continue;
      bool unique=true;
      for(int k=0;k<exsist.size();k++){
        if(dis[i][j]==exsist[k]){
          same[k]++;
          unique=false;
        }
      }
      if(unique){
        same[exsist.size()]++;
        exsist.push_back(dis[i][j]);
      }
    }
  }
  int saidai=0;
  for(int i=0;i<2501;i++){
    saidai=max(saidai,same[i]);
  }
  cout<<N-saidai<<endl;
  return 0;
}



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

using namespace std;

const int M=105;
int a[10];
bool vis[4][4];
int b;
int	num[M];
bool check()
{
	for(int i=1;i<=3;i++)
	{
		if(vis[i][1]&&vis[i][2]&&vis[i][3])return 1;
	}
	for(int i=1;i<=3;i++)
	{
		if(vis[1][i]&&vis[2][i]&&vis[3][i])return 1;
	}
	if(vis[1][1]&&vis[2][2]&&vis[3][3])return 1;
	if(vis[1][3]&&vis[2][2]&&vis[3][1])return 1;
	return 0;
}
int main()
{
	for(int i=1;i<=9;i++)
	{
		scanf("%d",&a[i]);
	}
	memset(vis,0,sizeof(vis));
	scanf("%d",&b);
	int tmp;
	for(int i=1;i<=b;i++)
	{
		scanf("%d",&tmp);
		for(int j=1;j<=9;j++)
		{
			if(a[j]==tmp)
			{
				if(j==3)
				{
					vis[1][3]=1;
				}
				if(j==6)
				{
					vis[2][3]=1;
				}
				if(j==9)
				{
					vis[3][3]=1;
				}
				else
				{
					int x=j/3+1;
					int y=j%3;
					vis[x][y]=1;
				}
				break;
			}
		}
	}
	if(check())
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  int b = a.size();
  vector<int> c(b+1);
  vector<int> d(b+1);
  for(int i = 0;i < b;++i){
    if(a.at(i) == '<'){c.at(i+1) = c.at(i)+1;}
  }
  for(int i = 0;i < b;++i){
    if(a.at(b-i-1) == '>'){d.at(b-i-1) = d.at(b-i)+1;}}
    long long ans = 0;
     for(int i = 0;i < b+1;++i){
       ans += max(c.at(i),d.at(i));}
    cout << ans << endl;
    
       
  }

Measured memory_bytes: 4740
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char const* argv[])
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    int result = 0;
    if(a < c)
    {
        if(b < c)
        {
            result = 0;
        }
        else
        {
            if(b < d)
            {
                result = b - c;
            }
            else
            {
                result = d - c;
            }
        }
    }
    else
    {
        if(d < a)
        {
            result = 0;
        }
        else
        {
            if(d < b)
            {
                result = d - a;
            }
            else
            {
                result = b - a;
            }
        }
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N, X;
  cin >> N >> X;
  vector<long> S = vector<long>(N, 0);
  rep(i, N) cin >> S[i];

  sort(S.rbegin(), S.rend());

  unordered_map<long, long> mp;
  mp[X] = 1;

  rep(i, N) {
    unordered_map<long, long> next_mp;
    long foo = N - i - 1;
    long bar = 1;
    for (auto it: mp) {
      next_mp[it.first] = (next_mp[it.first] + mp[it.first] * foo) % MOD;
      next_mp[it.first % S[i]] = (next_mp[it.first % S[i]] + mp[it.first] * bar) % MOD;
    }
    mp = next_mp;
  }

  long ret = 0;
  for (auto it: mp) {
    ret = (ret + it.first * it.second) % MOD;
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 1364
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, K, S;
    cin >> N >> K >> S;
    ll A[100000];
    if(S==1000000000) {
        int i;
        for(i = 0; i < K; i++) {
            A[i] = S;
        }
        for(int j = i; j < N; j++) {
            A[j] = S-1;
        }        
    }
    else {
        int i;
        for(i = 0; i < K; i++) {
            A[i] = S;
        }
        for(int j = i; j < N; j++) {
            A[j] = S+1;
        }
    }
    rep(i,N){
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>

int main(void){
	int n;
	int i;
	int sum = 100000;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		sum = sum * 1.05;
                if(sum%1000>0){
                   sum = sum - (sum%1000) + 1000;
                }
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;


struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1){}
    void init(int n) {par.assign(n, -1);}

    //再帰的に辿ることで親を調べる
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    //親が同じならば同じ集合に属する
    bool same(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        //新しい要素を加えた時に、rootに対して辺を張る(merge technique)
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    //新しいノードを集合に加えた時に、-1をrootに加算するため、
    //rootには、集合に属するノードの数に負符号を付加したものが保存されている。
    int size(int x){
        return -par[root(x)];
    }
};


int main(){
    int n;
    cin >> n;
    using P = pair<ll, int>;
    vector<P> x(n), y(n);
    rep(i, n){
        cin >> x[i].first;
        x[i].second = i;
        cin >> y[i].first;
        y[i].second = i;
    }

    sort(all(x));
    sort(all(y));

    UnionFind uf(n);
    using edge = tuple<ll, ll, ll>;
    priority_queue<edge, vector<edge>, greater<edge>> que;
    rep(i, n-1){
        que.push(edge(x[i+1].first-x[i].first, x[i+1].second, x[i].second));
        que.push(edge(y[i+1].first-y[i].first, y[i+1].second, y[i].second));
    }

    ll ans = 0;
    while(que.size() != 0){
        ll cost, a, b;
        tie(cost, a, b) = que.top();
        que.pop();
        if(!uf.same(a, b)){
            uf.merge(a, b);
            ans += cost;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 12016
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int dp[1010][1010];
/*dp[i][j]:=a1...aiとb1...bjの編集距離*/
inline int edit_distance(string a,string b){
   for(int i =0;i <=a.size();i++) dp[i][0] = i;

   for(int j =0;j <=b.size();j++) dp[0][j] = j;

      for(int i =1;i <=a.size();i++){
         for(int j =1;j <=b.size();j++){
            int cost =(a[i-1]==b[j-1]?0:1);
            /*d[ i1, i2 ] = minimum(
                               d[ i1 - 1, i2     ] + 1,     // 文字の挿入
                                    d[ i1    , i2 - 1 ] + 1,     // 文字の削除
                                    d[ i1 - 1, i2 - 1 ] + cost   // 文字の置換
                                     )
 */
            dp[i][j] =min(dp[i-1][j-1]+cost,min(dp[i][j-1]+1,dp[i-1][j]+1));
         }
      }
      return dp[a.size()][b.size()];
   }
int main(){
   string str1,str2;
   cin>>str1>>str2;
   cout <<edit_distance(str1, str2)<<endl;
   return 0;
}

Measured memory_bytes: 5140
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (s, _t) = parse_line!(String, String);
    let (a, b) = parse_line!(usize, usize);
    let u = read_line!();

    let (a, b) = if s == u { (a - 1, b) } else { (a, b - 1) };

    println!("{} {}", a, b);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<int> L(2*N); REP(i, 2*N) cin >> L[i];

  sort(ALL(L));

  int ans = 0;
  for (int i = 0; i < 2*N; i+=2) {
    ans += min(L[i], L[i+1]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
using namespace std;

char S[55][55];

int main() {
  int N, M, i, j, k, c, cnt, row;
  scanf("%d%d", &N, &M);
  for (i = 0; i < N; i++) {
    scanf("%s", S[i]);//Inputed russian flag color.
  }
  int ans = 999999;//Variable of maxinum.
  //白色に塗りつぶす行数
  for (i = 1; i <= N-2; i++) {//白の段数
	//青色に塗りつぶす行数
    for (j = 1; i+j <= N-1; j++) {//Blue's row
      cnt = 0;
      row = 0;
	  
      for (k = 0; k < i; k++) {
        for (c = 0; c < M; c++) {
          if(S[row][c] != 'W'){
			  cnt++;
		  }
        }
        row++;
      }
	 // cout<<"cnt(!W)="<<cnt<<" "<<"row="<<row<<endl;
      for (k = 0; k < j; k++) {
        for (c = 0; c < M; c++) {
          if(S[row][c] != 'B'){
			  cnt++;
		  }
        }
        row++;
      }
	  //cout<<"cnt(B)="<<cnt<<" "<<"row="<<row<<endl;
      for (k = 0; k < N-i-j; k++) {
        for (c = 0; c < M; c++) {
          if(S[row][c] != 'R'){
			 cnt++;
		  }
        }
        row++;
      }
	 // cout<<"cnt(R)="<<cnt<<" "<<"row="<<row<<endl;
      if (cnt < ans) ans = cnt;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = i + a[i];
    }
    map<lint, lint> cnt;
    lint ret  = 0;
    cnt[b[0]] = 1;
    for (int i = 1; i < n; ++i) {
        ret += cnt[i - a[i]];
        cnt[b[i]]++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 28912
/* By : rupesh282
 * link : https://atcoder.jp/contests/dp/tasks/dp_d  
 * */

#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;

const ll mod = 1e9+7;
const ll INF = 1e12;
int n , s;
vector<pair<int,int>>arr;
ll dp[100005][102];

ll recur(int ind , int w){
    if(w < 0)return -INF;
    else if(ind==0 && w>=0)return 0;

    if(dp[ind][w]!=-1)return dp[ind][w];

    ll first = arr[ind].second + recur(ind-1 , w-arr[ind].first);
    ll second = recur(ind - 1, w);
    return dp[ind][w] = max(first , second);
}

void solve(){
   cin>>n>>s; 
   arr.resize(n+1);
   for(int i=1;i<=n;i++)cin>>arr[i].first>>arr[i].second;


   for(int i=0;i<=s;i++){
       for(int j=1;j<=n;j++){
           if(arr[j].first <= i)
               dp[i][j] = max(arr[j].second + dp[i-arr[j].first][j-1] , dp[i][j-1]);
           else dp[i][j] = dp[i][j-1];
       }
   }

   cout<<(dp[s][n])<<endl;
   return;

}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 80000
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

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

    if(a <= x && x <= a+b){
        cout << "YES" << endl;
    }else
    {
        cout << "NO" << endl;
    }
    

    return 0;
}



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

int main() {
  int N, K;
  cin >> N >> K;
  
  int num = 1;
  
  for (int i = 0; i < N; i++) {
    int A, B;
    A = num * 2;
    B = num + K;
    if (A < B) {
      num = A;
    } else {
      num = B;
    }
  }
  cout << num << endl;
}


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

int main(){
    int n, a, b, h, maxh = 0;
    scanf("%d %d %d", &n, &a, &b);
    vector<int> vec;
    rep(_, n){
        scanf("%d", &h);
        vec.push_back(h);
      	maxh = max(maxh, h);
    }
    ll l = 0, r = maxh / b + 1;
    while(l + 1 < r){
        ll m = (l + r) / 2;
        ll rest = 0;
        rep(i, vec.size())
            if(vec[i] > b * m)
                rest += ceil((vec[i] - b * m) / (double)(a - b));
        if(rest > m) l = m;
        else r = m;
    }
    printf("%lld\n", r);
    return 0;
}

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

int main() {
	int N, M;

	cin >> N >> M;
	vector<int>L( M );
	vector<int>R( M );
	for( int i = 0; i < M; i++ ) {
		cin >> L[i] >> R[i];
		L[i]--;
		R[i]--;
	}

	vector<int> g( N + 1 );
	for( int i = 0; i < M; i++ ) {
		g[ L[i] ]++;
		g[ R[i] + 1 ]--;
	}
	for( int i = 0; i < N + 1; i++ ) {
		g[i + 1] += g[i];
	}
	int ans = 0;
	for( int i = 0; i < N + 1; i++ ) {
		if( g[i] >= M ) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
import collections as col
n, m = map(int, input().split())
t = [list(map(int,input().split())) for _ in range(n)]
t2 = []

for i in range(n):
    t[i].remove(t[i][0])
    t2 += t[i]

ans = col.Counter(t2)
ans = ans.values()
ans = list(ans)

print(ans.count(n))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
// get<0>(v[i])
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(40);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 40)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve(){
	string s;
	cin>>s;
	cout<<s.substr(0, 3)<<nl;
}
 
int main(){
    // boost;
    // cal(3);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<double,double>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;

void koch(vector<P>& a,int t){
    vector<P> b(t);
    REP(i,t){
        b[i].first = a[i].first;
        b[i].second = a[i].second;
        if(a[i].first == 100){
            b[i].first = a[i].first;
            b[i].second = a[i].second;
            break;
        }
    }
    REP(i,t){
        P ap = b[i];
        P bp = b[i+1];
        if(ap.first == 100){
            a[i*4] = ap;
            break;
        }
        P c,d,e;
        c.first = (2*ap.first+bp.first)/3;
        c.second = (2*ap.second+bp.second)/3;
        d.first = (ap.first+2*bp.first)/3;
        d.second = (ap.second+2*bp.second)/3;
        double xx = bp.second- ap.second;
        double yy = -(bp.first - ap.first);
        double distance = sqrt(xx*xx+yy*yy)/sqrt(3);
        //printD(xx);
        /*if(xx==0){
            double angle0=PI/6;
            e.first=ap.first+(distance*cos(angle0));
            e.second=ap.second+(distance*sin(angle0));
        }
        else */if(xx>=0){  //元になる直線が右上がりの場合
            double angle1=atan((double)yy/xx)+PI/6;
            e.first=ap.first-(distance*sin(angle1));
            e.second=ap.second+(distance*cos(angle1));
        }
        else{       //元になる直線が右下がりの場合
            double angle2=atan((double)yy/xx)-PI/6;
            e.first=bp.first-(distance*sin(angle2));
            e.second=bp.second+(distance*cos(angle2));
        }
        a[i*4] = b[i];
        a[i*4+1] = c;
        a[i*4+2] = e;
        a[i*4+3] = d;
    }
}

signed main(){
    cin >> n;
    int t = 2;
    REP(i,n){
        t = t*4-3;
    }
    vector<P> a(t);
    a[0] = P(0,0);
    a[1] = P(100,0);
    REP(i,n) koch(a,t);
    REP(i,t){
        cout << setprecision(15) << a[i].first << " " << a[i].second << endl;
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



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

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)

/*
 * Modint struct
 * library author : @snuke
 * */
const int mod = 998244353;
struct mint {
	long long x; // typedef long long ll;
	mint(long long x = 0): x((x % mod + mod) % mod) {}
	mint& operator+=(const mint a) { if ((x += a.x) >= mod)x -= mod; return *this;}
	mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod)x -= mod; return *this;}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { mint res(*this); return res += a;}
	mint operator-(const mint a) const { mint res(*this); return res -= a;}
	mint operator*(const mint a) const { mint res(*this); return res *= a;}
	mint pow(ll t) const {
		if (!t) return 1; mint a = pow(t >> 1); a *= a;
		if (t & 1) a *= *this; return a;
	}
	// for prime mod
	mint inv() const { return pow(mod - 2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct Combination {
	const int MAX = 2000050;
	vector<mint> fact;
	vector<mint> finv;
	Combination(): fact(MAX), finv(MAX) {
		for (int i = 0; i < MAX; i++) {
			if (i == 0)fact[i] = (mint)1;
			else fact[i] = fact[i - 1] * (mint)i;
		}
		finv[MAX - 1] = fact[MAX - 1].inv();
		for (int i = MAX - 2; i >= 0; i--) {
			finv[i] = finv[i + 1] * (mint)(i + 1);
		}
	}
	mint comb(int n, int r) {
		if (n < 0 || r < 0 || n < r)return 0;
		else return fact[n] * finv[r] * finv[n - r];
	}
} C;

ll n, m;

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

	cin >> n >> m;
	mint ans = 0;

	for (int k = 0; k <= m; k++) {
		if ((3 * m - k) % 2 != 0)continue;
		ans += C.comb(n, k) * (C.comb((3 * m - k) / 2 + n - 1, n - 1)
		       - (mint)k * C.comb((m - k) / 2 + n - 1, n - 1)
		       - (mint)(n - k) * C.comb((m - 2 - k) / 2 + n - 1, n - 1));
	}

	cout << ans << '\n';
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) a[i] = i+1;
  ll ans = 0;
  int res=0;
  bool lp = true;
  rep(i,n){
    ll cnt = 0;
    while(a[i]>0){
      if(a[i]%2!=0) break;
      a[i] /= 2;
      cnt++;
    }
    if(ans<cnt){
      res = i;
      ans = cnt;
    }
  }
  cout << res+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL read(){
    LL f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
#define MOD int(1e9+7)
LL Pow[MAXN+5]={1};
LL A[MAXN+5],C[MAXN+5],q1[MAXN+5],q2[MAXN+5];
char str[MAXN+5];
int main(){
    scanf("%s",str+1);
    int n=strlen(str+1);
    for(int i=1;i<=n;i++)//预处理出3^k
        Pow[i]=(Pow[i-1]*3)%MOD;
    for(int i=1;i<=n;i++){//处理出对于i位置之前的'A'和'?'
        A[i]=A[i-1],q1[i]=q1[i-1];
        if(str[i]=='A')//均包含第i个位置
            A[i]++;
        if(str[i]=='?')
            q1[i]++;
    }
    for(int i=n;i>=1;i--){//处理出对于i位置之后的'C'和'?'
        C[i]=C[i+1],q2[i]=q2[i+1];
        if(str[i]=='C')//均包含第i个位置
            C[i]++;
        if(str[i]=='?')
            q2[i]++;
    }
    LL ans=0,t1,t2,t3,t4;
    for(int i=1;i<=n;i++)
        if(str[i]=='B'||str[i]=='?'){//数学计数
            t1=((A[i-1]*C[i+1])%MOD*Pow[q1[i-1]+q2[i+1]])%MOD;
            t2=((A[i-1]*q2[i+1])%MOD*Pow[q1[i-1]+q2[i+1]-1])%MOD;
            t3=((C[i+1]*q1[i-1])%MOD*Pow[q1[i-1]+q2[i+1]-1])%MOD;
            t4=((q1[i-1]*q2[i+1])%MOD*Pow[q1[i-1]+q2[i+1]-2])%MOD;
            ans=(ans+((t1+t2)%MOD+(t3+t4)%MOD)%MOD)%MOD;//注意答案不要溢出
        }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int V, E;
vector<int>G[10010];//グラフの隣接リスト表現
vector<int>rG[10010];//辺の向きを逆にしたグラフ
vector<int>vs;//帰りがけ順の並び
bool used[10010];//すでに調べたか
int cmp[10010];//属する強連結成分のトポロジカル順序
void add_edge(int from, int to) {
	G[from].push_back(to);
	rG[to].push_back(from);
}
void dfs(int v) {
	used[v] = true;
	for (int i = 0; i < G[v].size(); ++i) {
		if (!used[G[v][i]])dfs(G[v][i]);
	}
	vs.push_back(v);
}
void rdfs(int v, int k) {
	used[v] = true;
	cmp[v] = k;
	for (int i = 0; i < rG[v].size(); ++i) {
		if (!used[rG[v][i]])rdfs(rG[v][i], k);
	}
}
int main() {
	cin >> V >> E;
	REP(i, E) {
		int s, t;
		cin >> s >> t;
		G[s].push_back(t);
		rG[t].push_back(s);
	}
	int Q;
	cin >> Q;
	int num = 0;
	memset(used, 0, sizeof(used));
	vs.clear();
	for (int v = 0; v < V; ++v) {
		if (!used[v])dfs(v);
	}
	memset(used, 0, sizeof(used));
	for (int i = vs.size() - 1; i >= 0; i--) {
		if (!used[vs[i]])rdfs(vs[i], num++);
	}
	REP(i, Q) {
		int u, v;
		cin >> u >> v;
		if (cmp[u] == cmp[v]) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 4716
#include<stdio.h>
#include<string.h>
long long arr[205][205];
long long min(long long a,long long b){
	return a>b?b:a;
}
int main() {
    int n,m;
    while(scanf("%d",&n)!=EOF){
    	long long x,y,c,d;
    	for(int i=0;i<205;i++){
    		for(int j=0;j<205;j++){
    		 arr[i][j]=10000000;	
			}
		}
    	for(int j=0;j<n;j++){
    	scanf("%lld %lld",&x,&y);
    	for(int h=0;h<y;h++){
    		scanf("%lld %lld",&c,&d);
    		arr[x][c]=min(arr[x][c],d);
		}
		}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				arr[i][j]=min(arr[i][j],arr[i][k]+arr[k][j]);
			}
		}
	}
	printf("0 0\n");
	for(int i=1;i<n;i++){
    printf("%d %lld\n",i,arr[0][i]);
   }
    }
	return 0;
}

































Measured memory_bytes: 3064
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    n = int(input())
    M = [list(map(int, input().split())) for _ in range(n)]

    # dp[i][j]: [i, j)の最小乗算数
    dp = [[0]*(n+1) for _ in range(n)]

    # 幅
    for i in range(2, n+1):
        # 開始位置
        for j in range(n-i+1):
            tmp = []
            # 切れ目
            for k in range(j+1, j+i):
                tmp.append(M[j][0]*M[k][0]*M[j+i-1][1]+dp[j][k]+dp[k][j+i])
            dp[j][j+i] = min(tmp)

    print(dp[0][n])

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 5772
// <--sbhmsh-- Shubham Jaiswal-->//

  #include <bits/stdc++.h>
  #define FASTIO std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  using namespace std;
  #define endl '\n'
  #define deb cout<<"sab_badhiya"<<endl;
  typedef long long int ll;
  // const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
  const long INF = 2000 * 1000 * 1000 + 7;
  map<int,int>mp;
  int a[300000];
  int main() {
    FASTIO
    int n, x, b;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mp[a[i]]++;
    }
    long long int ans = 0;
    for (auto it : mp) {
      ans += (1ll * it.second * (it.second - 1)) / 2;
    }
    for (int i = 0; i < n; i++) {
      b = mp[a[i]];
      ans -= (1ll * b * (b - 1)) / 2;
      b--;
      ans += (1ll * b * (b - 1)) / 2;
      cout << ans << endl;
      ans -= (1ll * b * (b - 1)) / 2;
      b++;
      ans += (1ll * b * (b - 1)) / 2;
    }
  }


Measured memory_bytes: 8320
#include <stdio.h>

#define MAX_N 104729

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };
int sum_p[ MAX_N / 2 ] = { 2 }, p = 1;

int main( void ) {
	int i, j, n, sum;

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	sum = 2;
	for ( i = 3; i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			sum_p[ p++ ] = sum += i;

	for ( ; scanf( "%d", &n ), n; printf( "%d\n", sum_p[ n - 1 ] ) ) ;

	return 0;
}

Measured memory_bytes: 1048
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
    int x;
    cin >> x;
    int beki;
    int ans = 1;


    for (int i = 1; i < 32; i++) {
        for (int j = 2; j < 10; j++) {
            beki = pow(i,j);
            if ((ans < beki) && (beki <= x))
                ans = beki;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

int main() {
	cin >> N >> R;
	if (N > 10) cout << R;
	else cout << R + 100 * (10 - N);
}



Measured memory_bytes: 256
#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;

ll solve(int n, VL a) {
    ll ans = 0;
    
    bool found;
    do {
        found = false;
    
        FOR(i,0,n-1) if (a[i] >= n) {
            found = true;
            
            ll here = a[i] / n;
                        
            ans += here;
            a[i] %= n;
        
            FOR(j,0,n-1) if (j != i) {
                a[j] += here;
            }
        }
    } while (found);
    
    return ans;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    
    ll k;
    cin >> k;
    
    ll initK = k;
    
    int n = 50;
    
    ll phases = k / n;
    ll init = phases + (n - 1);
    
    k %= n;
    
    VL a(n, init);
    
    while (k--) {
        int i = min_element(a.begin(), a.end()) - a.begin();
        
        a[i] += n;
        FOR(j,0,n-1) if (j != i) {
            a[j]--;
        }
    }
    
    cout << n << '\n';
    for (ll x : a) {
        assert(x >= 0);
        cout << x << ' ';
    }
    
    //assert(solve(n, a) == initK);
    
    return 0;
}

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


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

using namespace std;

int main(){
  int a, b, x;

  cin >> a >> b >> x;

  if (a <= x && a + b >= x){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = sorted(map(int, input().split()))
y = sorted(map(int, input().split()))
x = x[-1]
y = y[0]

ok = False

for Z in range(-1000, 1001):
    if X < Z <= Y and x < Z <= y:
        ok = True

if ok: print("No War")
else: print("War")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

def count(data):
    even = odd = 0
    for val in data:
        if val % 2 == 0:
            even += 1
        else:
            odd += 1

    return even,odd

A,B,C = map(int, input().split())

ans = 0
even,odd = count([A, B, C])
if even == 2:
    ans += 1
    if A % 2 == 0:
        A += 1
    if B % 2 == 0:
        B += 1
    if C % 2 == 0:
        C += 1
elif odd == 2:
    ans += 1
    if A % 2 != 0:
        A += 1
    if B % 2 != 0:
        B += 1
    if C % 2 != 0:
        C += 1

max_val = max(A,B,C)

ans += (max_val - A) / 2
ans += (max_val - B) / 2
ans += (max_val - C) / 2
print(int(ans))


Measured memory_bytes: 9012
#include <stdio.h>
#include <stdlib.h>
int solve(int,int,int,int*);
int main(){
  int i,n,q;
  int *A;
  int *m;

  scanf("%d",&n);
  if(n>20) exit(8);
  A = (int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
      if(A[i]<1 || A[i]>2000) exit(8);
    }
  scanf("%d",&q);
  if(q>200) exit(8);
  m = (int *)malloc(q*sizeof(int));
  for(i=0;i<q;i++)
    {
      scanf("%d",&m[i]);
      if(m[i]<1 || m[i]>2000) exit(8);
    }
  
  for(i=0;i<q;i++)
    {
      if(solve(0,m[i],n,A) == 1)
	{
	  printf("yes\n");
	  continue;
	}
      printf("no\n");
    }
  return 0;
}
int solve(int i,int m,int n,int *A){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  res = solve(i+1,m,n,A);
  if(res == 1) return res;
  res = solve(i+1,m-A[i],n,A);
  if(res == 1) return res;
  return res;
}
  
  



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

int main() {
	int A;
	int B;
	int C;
	string output;

	cin >> A;
	cin >> B;
	cin >> C;

	if (A == B || A == C || B == C) {
		if (A == B && B == C) {
			output = "No";
		}
		else {
		output = "Yes";
	}
	}
	
	else {
		output = "No";
	}

	cout << output;
}

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

int pow9by(int n){
    int ret=1;
    for(int i=0; i<n; i++){
        ret*=9;
    }
    return ret;
}

int nCk(int n,int k){
    if(n<k) return 0;
    int ret=1;
    for(int i=0; i<k; i++){
        ret*=n-i;
        ret/=i+1;
    }
    return ret;
}
int ctoi(const char c){
    return c-'0';
}
int main(){
    string N;
    int K;
    cin >> N >> K;
    vector<int> place;
    vector<int> num;
    for(int i=0; i<N.length(); i++){
        if(ctoi(N.at(i))){
            place.push_back(N.length()-i);
            num.push_back(ctoi(N.at(i)));
        }
        if(place.size()==K) break;
    }
    long long ans=0;
    if(N.length()<K || (N.length()==K&&N.at(0)=='1')){
        ans=0;
    }else{
        if(place.size()==K) ans++;
        for(int i=0; i<place.size(); i++){
            ans+=(long long)(num.at(i)-1)*nCk(place.at(i)-1,K-i-1)*pow9by(K-i-1);
            ans+=(long long)nCk(place.at(i)-1,K-i)*pow9by(K-i);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(3);
  rep(i, 3) cin >> a[i];
  vs s(n);
  rep(i, n) cin >> s[i];
  
  bool able = 1;
  string ans;
  rep(i, n) {
    ll &ch1=a[s[i][0]-'A'], &ch2=a[s[i][1]-'A'];
    if(ch1 == 0 && ch2 == 0) {able = 0; break;}
    else if(i<n-1 && a[s[i][0]-'A'] == 1 && a[s[i][1]-'A'] == 1) {
      if(s[i][0] == s[i+1][0] || s[i][0] == s[i+1][1]) {ch1++; ch2--; ans += s[i][0];}
      else {ch2++; ch1--; ans += s[i][1];}
    }else {
      if(ch1 < ch2) {ch1++; ch2--; ans += s[i][0];}
      else {ch2++; ch1--; ans += s[i][1];}
    }
  }
  
  if(able) {
    cout << "Yes" << newl;
    rep(i, n) cout << ans[i] << newl;
  }else cout << "No" << newl;
  return 0;
}

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

int main(){
    int n, m, x, y;
    cin >> n >> m >> x >> y;

    vector<int> x_list(n);
    vector<int> y_list(m);

    for(int i = 0; i < n; i++) cin >> x_list[i];
    for(int i = 0; i < m; i++) cin >> y_list[i];

    int max_x = *max_element(x_list.begin(), x_list.end());
    int min_y = *min_element(y_list.begin(), y_list.end());

   
    if(x < y && max_x < min_y && max_x < y && x < min_y ) cout << "No War";
    else cout << "War";
    
}

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

const int N = 1e5+10;
int a[N];
int main(){
    int a;
    cin >> a;
    for(int i=1;i<=9;++i){
        for(int j=1;j<=9;++j){
            if(i*j==a){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";


    return 0;
}

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

typedef struct process{
	char name[100];
	int time;
} P;

P Q[LEN];
int head, tail;

void enqueue(P x)
{
	Q[tail] = x;
	tail = (tail+1) % LEN;
}

P dequeue()
{
	P x = Q[head];
	head = (head+1) % LEN;
	return x;
}

int min(int a, int b)
{
	if(a <= b) return a;
	else return b;
}

int main()
{
	
	int i, n, q;
	int count = 0, m;
	P Temp;
	
	scanf("%d %d", &n, &q);
	
	for (i = 0; i < n; i++)
	{
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].time);
	}
	
	head = 0;
	tail = n;
	
	while(head != tail)
	{
		Temp = dequeue();
		m = min(q, Temp.time);
		Temp.time -= m;
		count += m;
		if(Temp.time > 0) enqueue(Temp);
		else printf("%s %d\n", Temp.name, count);
	}
	
	return 0;
}

Measured memory_bytes: 11824
<?php
fscanf(STDIN, "%d", $n);
$numbers = fgets(STDIN);
$exploded_numbers = explode(' ', trim($numbers));

$p = (int)round(array_sum($exploded_numbers) / $n);
$sum = 0;
foreach ($exploded_numbers as $num) {
  $sum += pow($num - $p, 2);
}

echo $sum;

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll k,n;
    cin>>k>>n;
    ll arr[n];
    for(ll i=0;i<n;++i){
    	cin>>arr[i];
	}
	ll minans = k;
	ll tempans = arr[n-1] - arr[0];
	minans = tempans;
	for(int i=1;i<n;++i){
		tempans =  k - arr[i] + arr[i-1];
		minans = min(minans, tempans);
	}
  cout<<minans<<endl;

return 0;
}



Measured memory_bytes: 5148
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

# inputa = [int(n) for n in inputa]
# inputa.sort()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

if a%2 == 0:
    print(a)
else:
    print(a*2)


Measured memory_bytes: 38256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
int g(int x,int y)
{
	if(x<y)
	{
		int t=x;
		x=y;
		y=t;
	}
	if(x%y==0)
	return y;
	else
	return g(y,x%y);
}
int main()
{
	int n,k,i,maxm,y,a[100005];
    while(scanf("%d%d",&n,&k)!=EOF)
	{
		maxm=-1;
		for(i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			maxm=max(a[i],maxm);
		}
		y=a[1];
		for(i=2;i<=n;i++)
		y=g(a[i],y);
		if(k<=maxm&&k%y==0)
		printf("POSSIBLE\n");
		else
		printf("IMPOSSIBLE\n");
	 } 
	 return 0;
}

Measured memory_bytes: 640
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next

  val map = s.foldLeft(Map.empty[Char, Int])((acc, v) => acc.get(v) match {
    case Some(vv) => acc.updated(v, acc(v) + 1)
    case _ => acc + (v -> 1)
  })

  val ans = if (map.size == 2 && map.head._2 == 2) "Yes" else "No"

  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)
}

Measured memory_bytes: 25900