akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;

typedef ll number;
const ll MOD = 1000000009;
typedef vector<number> marray;
typedef vector<marray> matrix;
matrix ident(ll n) {
	matrix A(n, marray(n));
	for (int i = 0; i < n; ++i) A[i][i] = 1;
	return A;
}
// O( n^2 )
marray mul(const matrix &A, const marray &x) {
	marray y(A.size());
	for (int i = 0; i < A.size(); ++i)
		for (int j = 0; j < A[0].size(); ++j) {
			y[i] += A[i][j] * x[j];
			y[i] %= MOD;
		}

	return y;
}
// O( n^3 )
matrix mul(const matrix &A, const matrix &B) {
	matrix C(A.size(), marray(B[0].size()));
	for (int i = 0; i < C.size(); ++i)
		for (int j = 0; j < C[i].size(); ++j)
			for (int k = 0; k < A[i].size(); ++k) {
				C[i][j] += A[i][k] * B[k][j];
				C[i][j] %= MOD;
			}
	return C;
}
// O( n^3 log e )
matrix pow(const matrix &A, ll e) {
	return e == 0 ? ident(A.size()) :
		e % 2 == 0 ? pow(mul(A, A), e / 2) : mul(A, pow(A, e - 1));
}


int main() {
	ll W, H, N;
	ll count = 0;
	while (cin >> W >> H >> N, W != 0) {
		count++;
		marray M(W);
		M[0] = 1;
		matrix Po(W, marray(W));
		for (int y = 0;y<W;y++)
			for (int x = 0;x<W;x++)
				Po[y][x] = abs(y - x) <= 1;

		vector<P> ob(N);
		for (int i = 0;i<N;i++) {
			ll x, y;
			cin >> x >> y;
			x--; y--;
			ob[i] = P(y, x);
		}
		sort(ob.begin(), ob.end());
		ll now = 0;
		for (int i = 0;i<ob.size();i++) {
			M = mul(pow(Po, ob[i].first - now), M);
			M[ob[i].second] = 0;
			now = ob[i].first;
		}
		M = mul(pow(Po, H - 1 - now), M);
		cout << "Case " << count << ": " << M[W - 1] << endl;
	}
	return 0;
}
/*
3 5 3
1 4
2 3
3 1

*/

Measured memory_bytes: 5868
/* Find the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b */
/* 1.Use the Euclidean algorithm to find GSD
   2.Use GSD to find LCM */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>



int GCD(int a , int b) /* Use the Euclidean algorithm to find GSD */
{
    int i=0; /*for iteration */
    int temp=0; /* a temporary place to hold variable */

    for(i=0 ; (b!=0) ; i++)
    {
        temp = a%b;
        a = b;
        b = temp;
    }
    return a;
}

int LCM(int a ,int b ) /* Use GSD to find LCM */
{
    int gcdvalue=0;
    int factorA=0; /* a divide by gcdvalue */
    int factorB=0; /* b divided by gcdvalue */

    gcdvalue = GCD(a,b);
    factorA = a / gcdvalue;
    factorB = b / gcdvalue;

    return ( gcdvalue * factorA * factorB );
}

int main()
{
    int a=0 , b=0;

    /* 1.Ask the user to enter two numbers , a and b */
    while(scanf("%d%d" ,&a,&b)!=EOF)
    {
     /* 2.Use the Euclidean algorithm to find GSD and print it */
     printf("%d " ,GCD(a,b));

     /* 3.Use GSD to find LCM */
     printf("%d\n" ,LCM(a,b));

    }

    return 0;
}



Measured memory_bytes: 1960
#include <stdio.h>

int main(void) 
{
	int n;
	int x[10000];
	while(scanf("%d", &x[n]) != EOF)
	{
		if (x[n] == 0)
		{
			break;
		}
		printf("Case %d: %d\n",n+1,x[n]);
		
		n ++;
	}
	
	return 0;
}



Measured memory_bytes: 2060
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val S = sc.next()
  println(if (N % 2 == 0 && {
    val (l, r) = S.splitAt(N / 2)
    l == r
  }) "Yes" else "No")
}


Measured memory_bytes: 55280
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
const int mod = 1e9 + 7;
using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
ll n,w[111],v[111],dp[105][100010],W;
int main(){
    ios::sync_with_stdio(0);
    cin >> n >> W;
    for(int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }
    for(int j = n;j>=1;j--){
        for(int i=W;i>=0;i--){
            dp[j][i] = max(dp[j+1][i],(i-w[j]>=0?dp[j+1][i-w[j]]+v[j]:0LL));
        }
    }
    cout << dp[1][W] << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  for(int i = 0; i < n/2; ++i){
    if(s[i] != s[n-1-i]) ++ans;
  }
  cout << ans << endl;
}


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




int main() {
  int N;
  string S;
  cin>>N>>S;
  vector<int> vec(N,0);
  int max=0;
  int count=0;
  for (int i=0;i<N;i++){
    if (S.at(i)=='I'){
      count+=1;
    }
    else {
      count-=1;
    }
    if (max<=count){
      max=count;
    }
  }
  cout<<max<<endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
ll rt[] = {1800,1600,1400,1200,1000,800,600,400};
ll gp[] = {1,2,3,4,5,6,7,8};


int32_t main(){
    IOS;
    ll i,j,k,n,m,x;
    cin >> x;
    fori(8){
        if(x>=rt[i]){
            cout << gp[i]<<"\n";
            return 0;
        }
    }
} 

Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    char a, b;
    cin >> a >> b;

    if (a == b)
    {
        cout << 'H' << endl;
    }
    else
    {
        cout << 'D' << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define loop(a, b, inc) for (int i = a; i <= b; i += inc)
typedef pair<int, int> pii;
typedef pair<int, string> ps;
typedef unsigned long long int llu;
typedef long long int ll;
typedef unsigned u;
const int MOD = 1e7+9, MAXN = 1e6;

vector<int> h;
int dp[MAXN], n;

int solve(int i, int k) 
{
	if (i == n-1) return 0;
	if (dp[i] == -1) {
		dp[i] = abs(h[i]-h[i+1])+solve(i+1, k);
		for (int j = 2; j <= k && i+j <= n-1; ++j) {
			dp[i] = min(dp[i], abs(h[i]-h[i+j])+solve(i+j, k));
		}
	}
	return dp[i];
} 

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k, aux;
	cin >> n >> k;
	loop(1, n, 1) {
		cin >> aux;
		h.pb(aux);
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0, k) << endl;
	
	return 0;
}


Measured memory_bytes: 12536
#include<iostream>
#include  <stdio.h>
using namespace std;
void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);


void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
    //ShowData(x, 10);               /* 途中経過を表示 */

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

  /* n 個のデータを表示する */
void ShowData(int x[ ], int n)
{
    int i;

    for (i = 0; i < n ; i++)
        printf("%d  ", x[i]);
    printf("\n");
}



int main(){

    int num_A;
    int num_B;
    cin >> num_A;
    cin >> num_B;
    int x[num_A+1];
    int y[num_B+1];

    cin >> x[0];
    cin >> y[0];

    for(int n = 1 ; n < num_A + 1 ; n++ ){
        cin >> x[n];
    }
    for(int n = 1 ; n < num_B + 1 ; n++ ){
        cin >> y[n];
    }


    QSort(x, 0, num_A + 1 - 1);
    QSort(y, 0, num_B + 1 - 1);

    if( x[num_A + 1 - 1] < y[0]  ){
        cout << "No War";
    }else{
        cout << "War";
    }

    return 0;
}

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

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

int main()
{   
    int n, q;

    cin >> n;
    vector<int> s(n);
    REP(i, n) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());

    cin >> q;
    vector<int> t(q);
    REP(i, q) {
        cin >> t[i];
    }

    int cnt = 0;
    REP(i, q) {

        int search = t[i];
        int left = 0, right = n;

        while (left < right) {
            int mid = (left+right)/2;

            if (s[mid] == search) {
                cnt++;
                break;
                
            }

            else if (search < s[mid]) {
                right = mid;
            }

            else if (search > s[mid]) {
                left = mid+1;
            }  
        }        
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3428
#include<stdio.h>
int main()
{
	int a,b,c;
	int i,j,k;
	int x=0;
	scanf("%d%d%d",&a,&b,&c);
	while(a%2==0&&b%2==0&&c%2==0)
	{
		x++;
		if(x==1000000) break;
		i=a/2;	j=b/2;	k=c/2;
		a=j+k;	b=i+k;	c=i+j;
	}
	if(x==1000000) printf("-1");
	else printf("%d",x);
	return 0;
}

Measured memory_bytes: 256
S = input()
L = [int(c) for c in S]
O = [1,-1]
sum = 0
N = 0

for i in O:
    for j in O:
        for k in O:
            if L[0] + i*L[1] + j*L[2] + k*L[3] == 7:
                print('{:}{:+}{:+}{:+}=7'.format(L[0],i*L[1],j*L[2],k*L[3]))
                exit()


Measured memory_bytes: 3060
#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() {
    double R;
    cin >> R;
    double PI = acos(-1);
    cout << 2 * R * PI << endl;
    return 0;
}


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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  
  for(int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  
  for(int i = 0; i < N - K; i++)
  {
    if(A.at(i) < A.at(i + K)){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
  }
}

Measured memory_bytes: 4056
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int n, a[10] = { 0 };
int f[100][10];
ll p[100][11];
ll ans = -1e10;

void dfs(int i) {
	if (i == 10) {
		int e = 0;
		ll d = 0;
		FOR(j, n) {
			int x = 0;
			FOR(k, 10) {
				if (a[k] && f[j][k]) {
					x++;
					e++;
				}
			}
			d += p[j][x];
		}
		if (!e)return;
		ans = max(ans, d);
		return;
	}
	a[i] = 0;
	dfs(i + 1);
	a[i] = 1;
	dfs(i + 1);
}

int main() {

	cin >> n;
	
	FOR(i, n) {
		FOR(j, 10)cin >> f[i][j];
	}
	FOR(i, n) {
		FOR(j, 11)cin >> p[i][j];
	}
	dfs(0);
	cout << ans << endl;

	return 0;
}


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

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1){
    for(int u : to[v]) if(u != p) {
            ans[u] += ans[v];
            dfs(u, v);
        }
}


int main() {
    int n, q; cin >> n >> q;
    rep(i, n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q){
        int p, x;
        cin >> p >> x;
        p--;
        ans[p]+=x;
    }
    dfs(0);
    rep(i, n){
        cout << ans[i] <<( i < n-1 ? ' ' : '\n') ;
    }
    return 0;
}


Measured memory_bytes: 24176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#define MOD 1000000007
using namespace std;
template<int mod=MOD> class modint {
private:
  int _num;
  modint set(int num){ _num = num % mod; return *this; }
public:
  modint(){ _num = 0; }
  modint(int num){ _num = num % mod; }

  modint operator= (int x){ return set(x % mod); }
  modint operator+ (int x){ return modint<mod>(_num + (x % mod)); }
  modint operator- (int x){ return modint<mod>(_num - (x % mod)); }
  modint operator* (int x){ return modint<mod>(_num * (x % mod)); }
  modint operator+=(int x){ return set(_num + (x % mod)); }
  modint operator-=(int x){ return set(_num - (x % mod)); }
  modint operator*=(int x){ return set(_num * (x % mod)); }

  explicit operator int() { return _num; }
  friend ostream& operator<<(ostream &os, const modint<mod> &x){ os << x._num; return os; }
};
#define INT_MAX 2147000000
#define LONG_MAX 9223372036854775806

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int H,W,A,B;
#define HMAX 1001
int main(){
    cin >> H >> W >> A >> B;
    bool check = true;
    if(W/2<A||H/2<B)check = false;
    if(check){
        for(int j=0;j<H;j++){
            for(int i=0;i<W;i++){
                if(i<A&&j<B)cout << '1';
                else if(i>A-1&&j>B-1) cout << '1';
                else cout << '0';
            }
            cout << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void)
{
	char s[101],t[101];
	scanf("%s%s",s,t);
	int lens=strlen(s),lent=strlen(t);
	int i,k,temp;
	for(i=0;i <= lens-2;i++)
		{
		for(k=0;k <= lens-2-i;k++)
			{
			if(s[k] > s[k+1])
				{
				temp = s[k];
				s[k] = s[k+1];
				s[k+1] = temp;
				}
			}
		}
	for(i=0;i <= lent-2;i++)
		{
		for(k=0;k <= lent-2-i;k++)
			{
			if(t[k] < t[k+1])
				{
				temp = t[k];
				t[k] = t[k+1];
				t[k+1] = temp;
				}
			}
		}
	s[lens]=0;
	int check=1;
	i=0;
	while(check==1 && i <= lent-1)
		{
		if(s[i] < t[i]){break;}
		else if(s[i] == t[i])
			{
			if(i == lent-1){check=0;}
			else{i++;}
			}
		else{check=0;}
		}
	if(check==0){printf("No\n");}
	else{printf("Yes\n");}
	return 0;
}


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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


int sum( int* v, int ini, int fim ) {
	int s = 0;
	for ( int i = ini; i <= fim; i++ ) {
		s += v[i];
	}
	return s;
}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    int w[100];
    int menor = 100;

    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> w[i];

    for ( int i = 0; i < n - 1; i++ ) {
    	int aux = abs(sum(w, 0, i) - sum(w, i + 1, n - 1));
    	if ( aux < menor ) {
    		menor = aux;
    	}
    }

    cout << menor << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * C - gacha
 * くじ引きを N 回行い、i 回目には種類が文字列 Si で表される景品を手に入れました。
 * 何種類の景品を手に入れましたか？
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // くじを引いた回数
        int n = sc.nextInt();
        // 入手した景品
        Set<String> s = new HashSet<>();

        for( int i = 0; i < n; i++ ) {
            s.add( sc.next() );
        }
        System.out.println( s.size() );

        sc.close();
    }
}

Measured memory_bytes: 77028
A, B = map(int, input().split())

def check(n):
    digits = [0] * 45
    for i in range(45):
        if i >= 1:
            am = n % (2 ** (i+1))
            if am > 2 ** i  and am % 2:
                am = 1
            else:
                am = 0
            sh = 0
        else:
            sh = n // 2
            am = 0
        digits[i] = (sh + am) % 2
    return digits
        
a = check(A)
b = check(B+1)
ans = 0
for i in range(45):
    ans += ((a[i] + b[i]) % 2) * (2 ** i)

if A == B:
    ans = A
print(ans)

Measured memory_bytes: 3064
/**
*    author:  Dooloper
*    created: 25.07.2020 21:05:19
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
    int x = 0;
    cin >> x;
    int shou, dai;
    shou = 200;
    dai = 399;
    int kyu = 8;

    for (int i = 1; i < 9; i++){
        if (shou + i*200 <= x && x <= dai + i*200){
            cout << kyu - i +1 << endl;
            break;
        }
    }
    

}

Measured memory_bytes: 3596
#include <stdio.h>
#define INF 100000000;

int main(){
  int n, r, c, x;
  int i, j, k, l;
  int m[100], p[100][100];

  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d",&m[i-1]);
    scanf("%d",&m[i]);
  }
  for(i=1; i<=n; i++)p[i][i] = 0;
  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j = i + l - 1;
      p[i][j] = INF;
      for(k=i; k<=j-1; k++){
	x = p[i][k] + p[k+1][j] + m[i-1] * m[k] * m[j];
	if(x < p[i][j])p[i][j] = x;
      }
    }
  }
  printf("%d\n",p[1][n]);
  return 0;
}



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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

int acc[100001];
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  s += "  ";
  repi(n + 1) acc[i + 1] = (s[i] == 'A' && s[i + 1] == 'C') + acc[i];
  repi(q) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    cout << acc[r + 1] - acc[l] - (s[r] == 'A' && s[r + 1] == 'C') << endl;
  }
}


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

int main(){
	int n,k,x,y; cin>>n>>k>>x>>y;
	if(n<=k) cout<<n*x<<endl;
	else cout<<k*x+(n-k)*y<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

int main()
{
	int num = 0;
	while (cin >> num && num != 0)
	{
		string dat;
		int l = 0, r = 0, h = 0, ans = 0;
		rep(i, num) 
		{ 
			cin >> dat; 
			switch (dat[0])
			{
			case 'r':
				if (dat[1] == 'u') { r++; h++; }
				else { r--; h--; }
				break;
			case 'l':
				if (dat[1] == 'u') { l++; h++; }
				else { l--; h--; }
				break;
			}
			if (r + l + h == 4) { ans++; r = 0; l = 0; h = 0; }
			else if (r + l + h == -4) {ans++; r = 0; l = 0; h = 0;}
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 3192
def modinv(a,m):
    b, u, v = m, 1, 0
    while b:
        t = a//b
        a -= t*b
        a,b = b,a
        u -= t * v
        u,v = v,u
    u %= m
    return u

s=input()
all_hatena = s.count('?')

a_cnt = 0
ab_cnt = 0
hatena_cnt = 0
ans = 0

MOD = 10**9+7
for si in s:
    if si == 'A':
        a_cnt += 1
    elif si == 'B':
        ab_cnt += a_cnt*pow(3,all_hatena,MOD)
        if all_hatena >= 1: ab_cnt += hatena_cnt*pow(3,all_hatena-1,MOD)
    elif si == 'C':
        ans += ab_cnt
    else:
        ans += ab_cnt*modinv(3,MOD)
        ab_cnt += a_cnt*pow(3,all_hatena-1,MOD)
        if all_hatena >= 2: ab_cnt += hatena_cnt*pow(3,all_hatena-2,MOD)
        hatena_cnt += 1
    ab_cnt%=MOD
    ans%=MOD
print(ans)

Measured memory_bytes: 74288
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N,M; cin >> N >> M;
    vector<vector<long long >> v(N,vector<long long>(2));
    for(int i=0;i<N;i++) cin >> v[i][0] >> v[i][1];
    sort(v.begin(), v.end());
    long long ans =0;
    for(int i=0;i<N;i++){
        if(M>=v[i][1]) {M-=v[i][1]; ans+=v[i][0]*v[i][1];}
        else {ans+=M*v[i][0]; M=0;}
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
def resolve():

    n,t=map(int,input().split())
    T=list(map(int,input().split()))
    T.append(T[-1]+10**10)
    ans=0
    for i in range(n):
        if T[i+1]-T[i]>t:
            ans+=t
        else:
            ans+=T[i+1]-T[i]
    print(ans)




resolve()

Measured memory_bytes: 25200
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    long N, K;
    cin >> N >> K;

    if (N >= K * 2 - 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b) {
    if (a < b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

    int r = a % b;    
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(void){
    int a, b;
    while(scanf("%d %d\n", &a, &b) != EOF) {
        printf("%d %d\n", gcd(a, b), a / gcd(a, b) * b);
    }

    return 0;
}


Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin >> n >> k;
    int ans = 0;
    rep(i,n)
    {
      int tmp;
      cin >> tmp;
      
      ans += min(abs(tmp-k), tmp) * 2;
    }
    cout << ans << endl;
}


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


using namespace std;

string s1,s2,odp = "";

int arr[5001][5001];


int main(){
    ios_base::sync_with_stdio(0);

    cin >> s1 >> s2;

    for (int i=1; i<=s2.size(); i++){   //tablica dla dwóch słów

        for (int j=1; j<=s1.size(); j++){

            if (s1[j-1] == s2[i-1]) arr[i][j] = arr[i-1][j-1]+1;
            else arr[i][j] = max(arr[i][j-1], arr[i-1][j]);
        }
    }


    int i = s2.size();
    int j = s1.size();

    while (i != 0 && j != 0){   //odzyskujemy słowo

        if (s1[j-1] == s2[i-1]){

            odp = s1[j-1] + odp;
            j--; i--;
        }

        else if (arr[i][j-1] > arr[i-1][j]) j--;
        else i--;
    }

   
    //cout << arr[s2.size()][s1.size()] << "\n";
    cout << odp;

}

Measured memory_bytes: 59264
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
ll a[100000];

void init()
{
}

void solve()
{
    int num[3] = {0, 0, 0};
    REP(i, N){
        if(a[i] % 4 == 0) num[0]++;
        else if(a[i] % 2 == 0) num[1]++;
        else num[2]++;
    }
    cout << ((num[1] == 0 && num[0]+1 >= num[2]) || (num[1] > 0 && num[0] >= num[2]) ?
            "Yes" : "No") << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, cnt = 0, continueflag = 114514;
  cin >> N;
  vector<ll> p(N + 1);
  for(ll i = 1; i <= N; i++) cin >> p.at(i);
  for(ll i = 1; i <= N; i++) {
    if((p.at(i) == i) && (continueflag != i - 1)) {
      cnt++;
      continueflag = i;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 4052
#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 RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
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 N;
    cin >> N;
    vector<int> A(N);
    for (auto &&i : A) {
        cin >> i;
    }

    vector<int> ans(N);
    ll sum = 0;
    REP(i, N) {
        if (i % 2 == 0) {
            sum += A[i];
        } else {
            sum -= A[i];
        }
    }
    ans[0]     = sum;
    ans[N - 1] = 2 * A[N - 1] - ans[0];
    FOR(i, 1, N - 1) { ans[i] = 2 * A[i - 1] - ans[i - 1]; }
    for (auto &&i : ans) {
        std::cout << i << " ";
    }
    std::cout << '\n';

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
struct Node {
    int index = -1;
    int depth = -1;
    int parent = -1;
    int *child;
    int ccnt = 0;
    int type = 0;
};
 
void depth(Node *node, int x, int d) {
    node[x].depth = d;
    for (int i = 0; i < node[x].ccnt; ++i) {
        depth(node, node[x].child[i], d+1);
    }
}
 
int Root(Node *node, int x) {
    if (node[x].parent > -1) {
        Root(node, node[x].parent);
    } else {
        return x;
    }
}
 
int main() {
    int n, x, root;
    string type[] = {"leaf", "internal node", "root"};
    cin >> n;
    Node a[n];
    for (int i = 0; i < n; ++i) {
        cin >> x;
        cin >> a[x].ccnt;
        a[x].index = x;
        a[x].child = new int[a[x].ccnt];
        for (int j = 0; j < a[x].ccnt; ++j) {
            a[x].type = 1;
            cin >> a[x].child[j];
            a[a[x].child[j]].parent = x;
        }
    }
     
    root = Root(a, 0);
    a[root].type = 2;
    depth(a, root, 0);
     
    for (auto& i : a) {
        cout << "node " << i.index << ": ";
        cout << "parent = " << i.parent << ", ";
        cout << "depth = " << i.depth << ", ";
        cout << type[i.type] << ", ";
        cout << "[";
        for (int j = 0; j < i.ccnt-1; ++j) {
            cout << i.child[j] << ", ";
        }
        if (i.ccnt) { 
            cout << i.child[i.ccnt-1] << "]\n";
        } else {
            cout << "]\n";
        }
    }
     
    return 0;
}

Measured memory_bytes: 9680
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template <class T> void out(const T &val) { cout << val << endl; }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int a[4] = {0,300000,200000,100000};
    int aa = read(), bb = read();
    int ans = 0;
    if (aa == 1 && bb == 1) {
        ans += 400000;
    }
    if (aa <= 3) {
        ans += a[aa];
    }
    if (bb <= 3) {
        ans += a[bb];
    }
    // ans += a[aa] + a[bb];
    out(ans);
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dp[2222][2222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vi S(n),T(m);
  for(auto &a:S)cin>>a;
  for(auto &a:T)cin>>a;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(S[i]==T[j]){
	dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]+1;
	dp[i+1][j+1]%=MOD;
      }else{
	dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j];
	dp[i+1][j+1]+=MOD;
	dp[i+1][j+1]%=MOD;
      }
    }
  }
  cout<<dp[n][m]+1<<endl;
  return 0;
}


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

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

using namespace std;

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

const int MAX_N=2e5;

int N,P[MAX_N];

int inx[MAX_N];

int main(){
	cin>>N;
	REP(i,N){
		cin>>P[i];
		P[i]--;
	}
	REP(i,N){
		inx[P[i]]=i;
	}
	int ans=0,f;
	REP(i,N-1){
		int j=N-2-i;
		if (ans==0){
			if (inx[j]>inx[j+1]){
				ans++;
				f=j+1;
			}
		}else{
			vector<PA> vec(3);
			vec[0]=PA(inx[j],j);
			vec[1]=PA(inx[j+1],j+1);
			vec[2]=PA(inx[f],f);
			sort(vec.begin(),vec.end());
			bool flg=false;
			REP(k,3){
				if (vec[k].second==j && vec[(k+1)%3].second==j+1){
					flg=true;
				}
			}
			if (!flg){
				ans++;
				f=j+1;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N,0);
  rep(i,N-1){
    int x;
    cin >> x;
    a.at(x-1)++;
  }
  rep(i,N){
    cout<<a.at(i)<<endl;
  }
}


Measured memory_bytes: 4052
import java.util.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		FastReader reader = new FastReader();
		PrintWriter writer = new PrintWriter(System.out);

		long sum = 0;
		int n = reader.nextInt();
		for (int i=0; i<n; i++)
			sum += reader.nextLong()-1;

		writer.println(sum);
		writer.close();
	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <stdlib.h>

int Partition(int *,int,int);
void swap(int *,int *); 

int main(){
  int n,i;
  int *A;
  int q;
  scanf("%d",&n);
  A = (int *)malloc(n * sizeof(int));
  for(i=0; i<n; i++) scanf("%d",&A[i]);

  q = Partition(A,0,n-1);

  for(i=0; i<n; i++){
    if(i != 0) printf(" ");
    if(i == q)printf("[");
    printf("%d",A[i]);
    if(i == q)printf("]");
    }

  printf("\n");

  return 0;
}



int Partition(int A[],int p,int r){
  int x,i,j,tmp;
  x = A[r];
  i = p-1;
  for(j=p; j<=r-1; j++){
    if(A[j] <= x){
      i++;
      swap(&A[i],&A[j]);
    }
    
  }

  swap(&A[i+1],&A[r]);
  return i+1;
}

void swap(int *a,int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}



Measured memory_bytes: 2128
h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            flg=True
            if i>0:
                if s[i-1][j]=='#':
                    flg=False
            if j>0:
                if s[i][j-1]=='#':
                    flg=False
            if i<h-1:
                if s[i+1][j]=='#':
                    flg=False
            if j<w-1:
                if s[i][j+1]=='#':
                    flg=False
            if flg:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))

if n == 1:
    print(1)
    exit(0)
if n == 2:
    if abs(a[0]-a[1]) <= 2:
        print(2)
    else:
        print(1)
    exit(0)

if n >= 3:
    d = [0 for _ in range(100001)]
    for i in range(n):
        d[a[i]] += 1
    ans = 0 
    for i in range(100001-2):
        tmp = d[i] + d[i+1] + d[i+2]
        if ans <= tmp:
            ans = tmp 

print(ans)


Measured memory_bytes: 20696
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n,ans=0,k;cin>>n>>k;
    while(n)n/=k,ans++;
    cout<<ans;
}




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

ll N, K;
vector<ll> A, F;

bool C(ll x) {
    // xが成立するか？
    ll k = K;

    rep(i, N) {
        if (A[i]*F[i] > x) {
            ll now = x / F[i];
            if (A[i] - now <= k) {
                k -= (A[i] - now);
                // if (k < 0) {
                //     return false;
                // }
            } else {
                return false;
            }
        }
    }
    return true;
}

bool C2(ll x) {
    ll s = 0;
    rep(i, N) {
        s += max(0ll, A[i]-x/F[i]);
    }
    return s <= K;
}

int main() {
    // ll N, K;
    cin >> N >> K;
    // vector<int> A(N), F(N);
    A.resize(N);
    F.resize(N);
    // rep(i, N) cin >> A[i] >> F[i];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];

    ll left = -1;
    ll right = 1000000000000;

    // 消化コストAは降順に
    sort(A.begin(), A.end());
    // 食べにくさFは昇順に
    // sort(F.begin(), F.end(), greater<ll>());
    sort(F.rbegin(), F.rend());

    while (right - left > 1) {
        ll mid = (left + right) / 2;

        if (C(mid)) right = mid;
        else left = mid;
    }

    cout << right << endl;
}

Measured memory_bytes: 6348
import java.util.*;
public class Main{
	static long GCM(long a, long b){
		long p = Math.max(a, b);
		long q = Math.min(a, b);
		long r = p % q;
		while(r!=0){
			p = q;
			q = r;
			r = p % q;
		}
		return q;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		String s = sc.next();
		String t = sc.next();
		long g = GCM(n, m);
		long l = m / g * n;
		long a = n / g;
		long b = m / g;
		boolean bl = false;
		for(int i=0; i<g; i++){
			int id1 = (int)(i*a);
			int id2 = (int)(i*b);
			if(s.charAt(id1)!=t.charAt(id2)){
				bl = true;
				break;
			}
		}
		System.out.println(bl==false ? l : -1);
	}
}

Measured memory_bytes: 28420
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

map<ll,bool> mp;
vector<ll> a[100];
int n,d;

ll make(ll x,ll y){
	int sum=0;
	for(int i=0;i<d;i++)
		sum+=(a[x][i]-a[y][i])*(a[x][i]-a[y][i]);
	return sum;
}

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	cin>>n>>d;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++){
			int x;
			cin>>x;
			a[i].pb(x);
		}
	for(int i=0;i<=10000;i++)
		mp[i*i]=true;
	int sum=0;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			if(mp[make(i,j)])
				sum++;
	cout<<sum;
	return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
            Console.WriteLine(input[1]<=input[0]*500?"Yes" :"No");
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<set>
#include<map>
#include<functional>
#include<queue>
#include<string.h>
#include <sstream>
#include<stdio.h>
#include<iomanip>
#include<stdlib.h>
#include<math.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<bitset>
#include<assert.h>
#include<fstream>
using namespace std;
//typedef long long LL;
//typedef vector<int>VI;
//typedef pair<int,int>PII;
//#define FOR(x,y,z)for(int x=y;x<=z;++x)
//#define FORD(x,y,z)for(int x=y;x>=z;--x)
//#define FOReach(x,Z)for(_typeof((Z).begin())x=(Z).begin();x!=(Z).end();++x)
//#define REP(x,y)for(int x=0;x<y;++x)
//#define PB push_back
//#define ALL(X)(X).begin(),(X).end()
//#define SZ(X)((int)(X).size())
//#define CLR(X,x)memset(X,x,sizeof(X))
//#define MP make_pair
//#define ST first
//#define ND second
//#define DBG
//#ifdef DBG
//#define debug printf
//#else
//#define debug(fmt,...)
//#endif
//const int MAX = 16;
//const int INF = 1000000001;

int main(){
vector<int> pf(1000);
int n;
cin>>n;
for(int i=1;i<=n;i++){
int t=i;
for(int j=2;j<=t;j++){
while(t%j==0){pf[j]++;
t/=j;
}}}
const int mod=1000000000+7;
long long ans=1;
for(int i=1;i<1000;i++)
{
ans*=pf[i]+1;
ans%=mod;}
cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
ans=1
arr=sorted(arr)
def solve(arr,ans):
    for i in arr:
        ans*=i
        if(ans>10**18):
            return(-1)
        if(ans==0):
            return(0)
    if(ans>10**18):
        return(-1)
    return(ans)
print(solve(arr,ans))

Measured memory_bytes: 21652
N, M = map(int, input().split())
E = []
for _ in range(M):
    a,b,c = map(int, input().split())
    E.append((a,b,c))
dist = [-N*10**9]*(N+1)
dist[1] = 0
flag = False
for i in range(N):
    for (a,b,c) in E:
        newlen = dist[a] + c
        if newlen > dist[b]:
            dist[b] = newlen
    if i == N-1 and dist[N] > predist:
        flag =True
    predist = dist[N]

if flag:
    print("inf")
else:
    print(dist[N])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >>n;
  int a[n];
  int k=1;
  multiset<int> s;
  rep(i,n){
    cin >> a[i];
    s.insert(a[i]);
    k=max(k,a[i]);
  }
  sort(a,a+n);
  bool ok=true;
  if(k%2==0){
    rep(i,n){
      if(a[i]==k/2){
	if(s.count(a[i])!=1) ok=false;	
      }
      else if(a[i]<=k && a[i]>=k/2+1){
	if(s.count(a[i])<2) ok = false;
      }
      else ok=false;
    }
    for(int i=k/2+1;i<=k;i++){
      if(s.count(i)<2) ok=false;
    }
    if(s.count(k/2)!=1) ok=false;
  }
  else{
    rep(i,n){
      if(a[i]==(k+1)/2){
	if(s.count(a[i])!=2) ok=false;
      }
      else if(a[i]<=k && a[i]>=(k+1)/2+1){
	if(s.count(a[i]<2)) ok=false;
      }
      else ok=false;
    }
    for(int i=(k+1)/2+1;i<=k;i++){
      if(s.count(i)<2) ok=false;
    }
    if(s.count((k+1)/2)!=2) ok=false;
  }
  if(k+1>n) ok=false;
  if(ok) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  
  


  
  return 0;
    

}


Measured memory_bytes: 256