akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    string s;
    cin >> s;

    for(int i = 0; i < 3; i++){
        if(s.at(i) == '1'){
            s.at(i) = '9';
        }else{
            s.at(i) = '1';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int build[4][3][10];
	REP(i, 4){
		REP(j, 3){
			REP(k, 10){
				build[i][j][k] = 0;
			}
		}
	}

	int n;
	cin >> n;
	while (n){
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		build[b-1][f-1][r-1] += v;
		n--;
	}

	REP(i, 4){
		REP(j, 3){
			REP(k, 10){
				cout << " " << build[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) cout << "####################" << endl;
	}
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long
#define N 55
using namespace std;
ll n,a[N][N],ans,dp[N][N][N];
ll getans(int l,int x,int r){
	if (l==x&&r==x) return 1;
	if (l==x||r==x) return 0;
	if (dp[l][x][r]==0){
		dp[l][x][r]=1;
		for (int i=l;i<x;i++){
			for (int j=i;j<x;j++){
				for (int k=x+1;k<=r;k++){
					for (int s=k;s<=r;s++){
						if (a[i][s])dp[l][x][r]+=getans(l,i,j)*getans(j+1,x,k-1)*getans(k,s,r);
					}
				}
			}
		}
	}
	return dp[l][x][r]-1;
}
int main(){
	cin>>n;
	for (int i=1;i<=n*2;i++){
		for (int j=1;j<=n*2;j++){
			char ch=getchar();
			while (ch!='0'&&ch!='1')ch=getchar();
			a[i][j]=ch-'0';
		}
	}
	for (int j=2;j<=n*2;j++)if (a[1][j]) ans+=getans(2,j,n*2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll a, b;
	string s="", t="";

	std::cin >> a >> b;
	rep(i, 0, b) {
		s += (char)(a + '0');
	}
	rep(i, 0, a) {
		t += (char)(b + '0');
	}
	if (s < t) {
		outn(s);
	}
	else {
		outn(t);
	}

	return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())

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

    for i in a:
        if i % 2 == 0:
            if i % 3 != 0:
                if i % 5 != 0:
                    print('DENIED')
                    break
    
    else:
        print('APPROVED')


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using  namespace std;
#define    ll  long long int
ll fre[11];
int main( )
{
    ll N, k, mx = -1,sum=0;
    ll a,b,c;
    cin>>a>>b>>c;
    ll mxn=max(a,max(b,c));
    ll x= mxn-a;
    ll y= mxn-b;
    ll z= mxn-c;
    if((x+y+z)%2==0)
    {
        mx=(x+y+z)/2;
    }
    else
    {
        mx=(x+y+z+3)/2;
    }
    cout << mx<< endl;

    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

#define MAX_N 2020

struct BIT2d{
  ll bit[MAX_N+1][MAX_N+1];

  void init(){
    memset(bit,0,sizeof(bit));
  }

  ll sum(int x, int y){
    ll s=0;
    for(int i=y;i>0;i-=i&-i){
      for(int j=x;j>0;j-=j&-j){
        s+=bit[i][j];
      }
    }
    return s;
  }
  void add(int x, int y,ll v){
    for(int i=y;i<=MAX_N;i+=i&-i){
      for(int j=x;j<=MAX_N;j+=j&-j){
        bit[i][j]+=v;
      }
    }
  }
};

struct query{
  ll t,c,h0,w0,h1,w1;
};

bool operator<(const query& a, const query& b){
  return a.t>b.t;
}

BIT2d bit[2];
ll H,W,T,Q;

ll calc_sum(ll b,ll i0,ll j0,ll i1,ll j1){
  return bit[b].sum(i1,j1)-bit[b].sum(i1,j0-1)-bit[b].sum(i0-1,j1)+bit[b].sum(i0-1,j0-1);
}

int main(){
	cin>>H>>W>>T>>Q;
  priority_queue<query> qs;
  rep(i,Q){
    ll t,c;
    cin>>t>>c;
    if(c==0||c==1){
      ll h,w;
      cin>>h>>w;
      qs.push((query){t,c,h,w,-1,-1});
    }else{
      ll h0,w0,h1,w1;
      cin>>h0>>w0>>h1>>w1;
      qs.push((query){t,c,h0,w0,h1,w1});
    }
  }

  bit[0].init(); bit[1].init();
  while(qs.size()){
    query q = qs.top();  qs.pop();
    if(q.c==0){
      bit[0].add(q.h0,q.w0,1);
      qs.push((query){q.t+T,3,q.h0,q.w0,-1,-1});
    }else if(q.c==1){
      if(calc_sum(1,q.h0,q.w0,q.h0,q.w0)>0){
        bit[1].add(q.h0,q.w0,-1);
      }
    }else if(q.c==2){
      cout<<calc_sum(1,q.h0,q.w0,q.h1,q.w1)<<" "<<calc_sum(0,q.h0,q.w0,q.h1,q.w1)<<endl;
    }else if(q.c==3){
      bit[0].add(q.h0,q.w0,-1);
      bit[1].add(q.h0,q.w0,1);
    }
  }

	return 0;
}

Measured memory_bytes: 71416
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

const NIL = -1

type Node struct {
	p, l, r int
}

type Nodes []Node

var out bytes.Buffer

func (n Nodes) preParse(u int) {
	if u == NIL {
		return
	}
	out.WriteString(fmt.Sprintf(" %d", u))
	n.preParse(n[u].l)
	n.preParse(n[u].r)
}

func (n Nodes) inParse(u int) {
	if u == NIL {
		return
	}
	n.inParse(n[u].l)
	out.WriteString(fmt.Sprintf(" %d", u))
	n.inParse(n[u].r)
}

func (n Nodes) postParse(u int) {
	if u == NIL {
		return
	}
	n.postParse(n[u].l)
	n.postParse(n[u].r)
	out.WriteString(fmt.Sprintf(" %d", u))
}

func answer(reader io.Reader) string {
	var v, l, r, root int
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	nodes := make(Nodes, n)
	for i := 0; i < n; i++ {
		nodes[i].p = NIL
	}

	for i := 0; i < n; i++ {
		sc.Scan()
		v, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		l, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ = strconv.Atoi(sc.Text())

		nodes[v].l, nodes[v].r = l, r
		if l != NIL {
			nodes[l].p = v
		}
		if r != NIL {
			nodes[r].p = v
		}
	}

	for i := 0; i < n; i++ {
		if nodes[i].p == NIL {
			root = i
		}
	}

	out.WriteString(fmt.Sprintln("Preorder"))
	nodes.preParse(root)
	out.WriteString("\n")
	out.WriteString(fmt.Sprintln("Inorder"))
	nodes.inParse(root)
	out.WriteString("\n")
	out.WriteString(fmt.Sprintln("Postorder"))
	nodes.postParse(root)

	return out.String()
}

func main() {
	fmt.Println(answer(os.Stdin))
}



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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

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

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

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

const int cys=998244353;
int n;
int du1[200005],du2[200005];
map<int,int> adj1[200005];
vector<int> adj2[200005];

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

int main(){
	n=readint();
	int x,y;
	for(int i=1;i<n;i++){
		x=readint(); y=readint();
		adj1[x][y]=adj1[y][x]=1;
		du1[x]++,du1[y]++;
	}
	for(int i=1;i<n;i++){
		x=readint(); y=readint();
		adj2[x].pb(y),adj2[y].pb(x);
		du2[x]++,du2[y]++;
	}
	ll inv2=qpow(2,cys-2),inv4=qpow(4,cys-2),ans=0;
	for(int i=1;i<=n;i++) ans=(ans+((n-1)*inv2%cys-(n-du1[i]-1)*inv4%cys)*inv2)%cys;
	for(int i=1;i<=n;i++){
		for(auto v:adj2[i]){
			if(i<v) continue;
			if(adj1[i].count(v)) ans=(ans-((n-2)*inv2%cys-(n-du1[i]-du1[v])*inv4%cys)*inv4)%cys;
			else ans=(ans-((n-2)*inv2%cys-(n-du1[i]-du1[v]-1)*inv4%cys)*inv4)%cys;
		}
	}
	printf("%lld\n",(ans+cys)%cys);
	return 0;
}


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

int main() {
	int A,B,K; cin >>A>>B>>K;
	for(int i = min(A,B) ; i > 0 ; i--){
		if(A%i == 0 && B%i == 0){
			K--;
			if(K == 0){
				cout << i << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n;
	string s;
	cin>>n;
	cin>>s;
	int total=0;
	rep(i,n-2){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')total++;
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	if(abs(x-n)>abs(y-n))cout<<"B"<<endl;
	else cout<<"A"<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
X = [[int(i) for i in input().split()] for i in range(n-1)]
ans = [0 for i in range(n)]

for j in range(n):
    for i in range(j, n-1, 1):
        if ans[j] >= X[i][1]:
            if ans[j] % X[i][2] == 0:
                ans[j] = ans[j] + X[i][0]
            else:
                ans[j] = ans[j] + X[i][0] + X[i][2] - ans[j] % X[i][2]

        else:
            ans[j] = X[i][1] + X[i][0]

for i in range(n):
    print(ans[i])

Measured memory_bytes: 3188
#include<iostream>
#include<list>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;

typedef long long ll;

int main(){
  int n;
  cin>>n;
  list<int>ans;
  string s;
  int x;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=="insert"){
      cin>>x;
      ans.push_front(x);
    }
    else if(s=="delete"){
      cin>>x;
      auto it=ans.begin();
      while(it!=ans.end()){
	if(*it==x){ans.erase(it);break;}
	it++;
      }
    }
    else if(s=="deleteFirst"){
      ans.pop_front();
    }else{
      ans.pop_back();
    }
  }
  auto it=ans.begin();
  for(int i=0;it!=ans.end();it++,i++){
    if(i)cout<<' ';
    cout<<(*it);
  }
  cout<<endl;
  return 0;
}




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

ll mod = 1e9+7;
ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}

int main(){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    vector<ll> fact(1001, 1), invfact(1001, 1);
    for (int i = 2; i <= 1000; i++) fact[i] = fact[i-1]*i%mod;
    invfact[1000] = modinv(fact[1000]);
    for (int i = 999; i >= 2; i--) invfact[i] = invfact[i+1]*(i+1)%mod;
    
    vector<vector<ll>> dp(B+1, vector<ll>(N+1, 0));
    dp[A-1][0] = 1;
    for (int i = A; i <= B; i++) {
        vector<ll> ik(D+1, 1);
        for (int k = 1; k <= D; k++) ik[k] = ik[k-1]*invfact[i]%mod;
        for (int j = 0; j <= N; j++) {
            dp[i][j] = dp[i-1][j];
            for (int k = C; k <= D; k++) {
                if (i*k > j) break;
                dp[i][j] += dp[i-1][j-i*k]*invfact[k]%mod*ik[k]%mod;
            }
            dp[i][j] %= mod;
        }
    }
    cout << dp[B][N]*fact[N]%mod << endl;
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(20)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e16)
#define inf 1e16
#define f first
#define se second
ll mod=1e9+7;
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
char move[]={'D','R','U','L'};
int X[]={2,1,-1,-2,-2,-1,1,2}; 
int Y[]={1,2,2,1,-1,-2,-2,-1}; 
struct comp{
	bool operator()(const pair<int,int>&a,const pair<int,int>&b) const {
		if(a.first>b.first) return true;
		if(a.first<b.first) return false; 
		if(a.second<b.second) return true;
		return false;
	}
};
void solve(){
	//ifstream fin("input.txt");
	//ofstream fout("output.txt");
	int x;
	cin>>x;
	cout<<(x>=30?"Yes":"No")<<endl;
	
	
	
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


Measured memory_bytes: 3672
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    val d = sc.nextLong()
    println(problem131c(a, b, c, d))
}

fun problem131c(a: Long, b: Long, c: Long, d: Long): Long {
    fun computeGreatestCommonDivisor(small: Long, big: Long): Long {
        val rest = small % big
        return if (rest == 0L) big else computeGreatestCommonDivisor(big, rest)
    }
    val bMultiple = b / c + b / d
    val aMultiple = (a - 1) / c + (a - 1) / d
    val greatestCommon = if (c > d) {
        computeGreatestCommonDivisor(c, d)
    } else {
        computeGreatestCommonDivisor(d, c)
    }
    val leastCommon = c * d / greatestCommon
    var bAns = b - bMultiple
    bAns += b / leastCommon
    var aAns = (a - 1) - aMultiple
    aAns += (a - 1) / leastCommon
    return bAns - aAns
}

Measured memory_bytes: 31516
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll K, A, B;
    cin >> K >> A >> B;

    if (K <= A) {
        cout << 1 << endl;
    } else if (A - B <= 0) {
        cout << -1 << endl;
    } else {
        ll t = K - A;
        cout << (t + (A - B) - 1) / (A - B) * 2 + 1 << endl;
    }
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  if ( N % 2 ) {
    cout << (double)((double)(N+1)/2)/N << endl;    
  } else {
    cout << (double)1/2 << endl;    
  }
  
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
#define grade(a) cout << a << endl
using namespace std;

int main(){
    int n, m, l;
    int i, j, k;
    cin >> n >> m >> l;
    int A[n][m];
    int B[m][l];
    rep(i,n){
        rep(j,m) cin >> A[i][j];
    }
    rep(i,m){
        rep(j,l) cin >> B[i][j];
    } 
    rep(i,n){
        rep(j,l){
            long s=0;
            rep(k,m) s += A[i][k] * B[k][j];
            cout << s;
            if(j!=l-1)cout << " ";
        }
        cout << endl;
    }
    return 0;
}


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

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

def foo(a,b,ans):
    z = d[a][b]
    for p in range(3):
        for q in range(3):
            if a-2+p<0 or a+p>=h or b-2+q<0 or b+q>=w:
                continue
            ok = True
            reachorig = False
            v = 0
            for i in range(3):
                for j in range(3):
                    if p+i==q+j==2:
                        reachorig = True
                    if z[p+i][q+j]==1:
                        if reachorig:
                            v += 1
                        else:
                            ok = False
                            break
            if ok:
                ans[v] += 1

h,w,n = inm()
d = {}
ab = []
for i in range(n):
    a,b = inm()
    a -= 1
    b -= 1
    ab.append((a,b))
    if a not in d:
        d[a] = {}
    d[a][b] = [[0]*5 for j in range(5)]
    d[a][b][2][2] = 1
for a,b in ab:
    for dx in range(-2,3):
        for dy in range(-2,3):
            if a+dx in d and b+dy in d[a+dx] and not (dx==dy==0):
                d[a+dx][b+dy][2-dx][2-dy] = 1

if False and DBG:
    for i in range(h):
        for j in range(w):
            if i in d and j in d[i]:
                #print(f"{i=} {j=}")
                for k in range(5):
                    print(d[i][j][k])
ans = [0]*10
for a,b in ab:
    foo(a,b,ans)
print((h-2)*(w-2)-sum(ans))
for i in range(1,10):
    print(ans[i])


Measured memory_bytes: 136708
import java.util.*
import java.math.*
import kotlin.math.*

fun readLn()=readLine()!!
fun readInt()=readLn().toInt()
fun readInts()=readLn().split(" ").map{it.toInt()}
fun readLong()=readLn().toLong()
fun readLongs()=readLn().split(" ").map{it.toLong()}

val out=mutableListOf<String>()
fun printLine(s:String){out.add(s)}
fun output(){println(out.joinToString("\n"))}

fun main(){
    var n=readInt()
    var A=readInts()
    var a=Array(n+1){if(it==0) 0 else A[it-1]}
    var ans=0L
    fun Solve(){
        var cnt=TreeMap<Int,Int>()
        for(i in 1..n){
            if(cnt.containsKey(a[i]-i))ans+=cnt[a[i]-i]!!
            if(!cnt.containsKey(-a[i]-i))cnt[-a[i]-i]=0
            cnt[-a[i]-i]=cnt[-a[i]-i]!!+1
        }
    }
    Solve()
    printLine("$ans")
    output()
}

Measured memory_bytes: 84612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct edge{int to,sum;};
int n,m,d[2][100010];
vector<edge>v[100010];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        v[a].pb({b,c});
        v[b].pb({a,c});
    }
    rep(i,2)rep(j,n)d[i][j]=INF;
    d[0][0]=0;
    queue<P>q;
    q.push({0,0});
    while(!q.empty()){
        P p=q.front();
        q.pop();
        for(edge e:v[p.se]){
            int to=e.to;
            if(d[1-p.fi][e.to]==INF){
                d[1-p.fi][e.to]=e.sum-d[p.fi][p.se];
                q.push({1-p.fi,e.to});
            }
            else{
                if(d[1-p.fi][e.to]!=e.sum-d[p.fi][p.se]){
                    puts("0");
                    return 0;
                }
            }
        }
    }
    int mi=INF,ma=INF;
    rep(i,n){
        chmin(mi,d[0][i]);
        chmin(ma,d[1][i]);
    }
    mi=-mi;
    if(d[1][0]==INF)cout<<max(0ll,ma-mi-1)<<endl;
    else{
        if(d[1][0]>0&&d[1][0]%2==0){
            int t=d[1][0]/2;
            if(mi<t&&t<ma)cout<<1<<endl;
            else cout<<0<<endl;
        }
        else cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 10480
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define pr(n) printf("%d",n)
#define sc(n) scanf("%d",&n)
#define forr(i,n) for(int i=0;i<n;i++)
#define fo(i,n) for(int i=1;i<=n;i++)
#define int long long
const int N=1*1e5+10;
int a[N],n,k,dp[N];
int fib(int i)
{
    if(i==n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int j,mi=INT_MAX;
    for(j=1; (i+j)<=min(n,(i+k)); j++)
    {
        mi=min(mi,(abs(a[i]-a[i+j])+fib(i+j)));
    }

    return dp[i]=mi;
}
signed main()
{
    int tc=1;
   // sc(tc);
    while(tc--)
    {
        sc(n);
        sc(k);
        int i;
        fo(i,n)sc(a[i]);
        memset(dp,-1,sizeof(dp));
        pr(fib(1));
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string s, t;
	cin >> s >> t;
	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

//Ctrl+Aを使わない


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define inf int(1e9)
#define half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;


const int max_n = half_inf;
ll n, a[max_n];

void solve() {
    bool has_odd = false;
    rep(i, n) {
        if (a[i] % 2 != 0) {
            has_odd = true;
            break;
        }
    }
    cout << (has_odd ? "first" : "second") << endl;
}

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    }
    else if (r < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
}

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

#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++)

using namespace std;

long long mod = 1000000000 + 7;

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	rep(i, N)cin >> A[i];
	
	long long ans = 0;
	long long twoPow = 1;
	rep(i, 60) {
		long long count0 = 0;
		long long count1 = 0;
		rep(j, N) {
			if (A[j] & (1LL << i))count1++;
			else count0++;
		}
		long long add = (count0 * count1) % mod * twoPow % mod;
		ans = (ans + add) % mod;
		twoPow = (twoPow * 2) % mod;
	}
	cout << ans;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
const int INF=99999;

bool check(int n)
{
    cout << n << endl;
    string s;
    cin >> s;
    if(s=="Male"){
        return 0;
    }else if(s=="Female"){
        return 1;
    }else{
        exit(0); 
    }
}

int main()
{
    int ng=0,ok,n;
    cin >> n;
    ok=n-1;
    bool f=check(ok),b=check(ng);
    while(true)
    {
        int mid=(ok+ng)/2+(ok+ng)%2;
        if(mid%2){
            if(check(mid)==f){
                ng=mid;
            }else{
                ok=mid;
            }
        }else{
            if(check(mid)==b){
                ng=mid;
            }else{
                ok=mid;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 852
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
string s;
int len,flag,ok; 
int main(){
    cin>>s;
    for(int i=0;s[i];i++){
    	if(s[i]=='C')flag=1;
    	if(s[i]=='F'&&flag){ok=1;break;} 
    }
    if(ok)puts("Yes");
    else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF=0x3f3f3f3f,maxn=1;
//vector<int>v[maxn];map<int,string>mp;
//queue<int>q;
//int a[maxn],n,m;
int main()
{
	int i,j,k,ans=0;
	double n;
	cin>>n;
	double x;
//	x=n/1.08;
//	x=x+0.5;
//	x=int(x);
x=n;
for(double i=0;i<=50000;i++)
{
	int y=i*1.08;
	if(y>=x)
	{
	//	cout<<y<<endl;
		if((y-x)<1)
		{
			cout<<i<<endl;return 0;
}
	else
	{
		cout<<":("<<endl;return 0;
	}
	}
}
	cout<<x;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define present(container, element) (container.find(element) != container.end())
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cpresent(container, element) (find(all(container),element) != container.end())
#define all(c) c.begin(), c.end()
#define mod 1000000007 
#define MOD 998244353
#define PI 3.141592654
typedef long long ll;
using namespace std;
int main(){
  ss
  ll a=0,b,c;
  string s1,s2;
  cin>>s1>>s2;
  for(int i=0;i<3;i++){
  	if(s1[i]==s2[i]) a++;
  }
  
  cout<<a;
return 0; 

}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 4000

int main(void){
	int i,dataset,snum[MAX],flag;
	long long total[MAX],unitcost,amount;
	while( 1 ){

		for(i=0;i<MAX;i++){
			total[i]=0;
			snum[i]=0;
		}

		scanf("%d",&dataset);
		if( dataset == 0 ){break;}

		else for(i=0;i<dataset;i++){
			scanf("%d %lld %lld",&snum[i],&unitcost,&amount);
			total[snum[i]]+=unitcost*amount;
		}
		

		flag=0;
		for(i=0;i<MAX;i++){
                        if( total[snum[i]] >= 1000000 ){
				flag=1;
				printf("%d\n",snum[i]);
				total[snum[i]]=0;
			}
		}
		if( dataset!=0 && flag==0 ){
			printf("NA\n");
		}
	}
}

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

int memo[101][10001],v[1001],w[1001];
int dp(int i,int j){
    if(i == 0)return 0;
    if(memo[i][j] >= 0)return memo[i][j];
    if(j - w[i - 1] < 0)return memo[i][j] = dp(i - 1,j);

    return memo[i][j] = max(dp(i - 1,j),dp(i,j - w[i - 1]) + v[i - 1]);
}

int main(){
    int N,W;
    scanf("%d %d",&N,&W);
    for(int i = 0; i < N; i++){
        scanf("%d %d",&v[i],&w[i]);
    }
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 10001; j++){
            memo[i][j] = -1;
        }
    }
    printf("%d\n",dp(N,W));
    return 0;
}


Measured memory_bytes: 7120
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a > b)
        ans += a--;
    else
        ans += b--;
    ans += max(a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
struct Node{
    Node(){
        left_child = right_child = parent = -1;
    };
    int left_child,right_child,parent;
};
 
void preORDER(Node order[],int id){
    printf(" %d",id);
    if(order[id].left_child != -1) preORDER(order,order[id].left_child );
    if(order[id].right_child != -1) preORDER(order,order[id].right_child );
}
 
void inORDER(Node order[],int id){
    if(order[id].left_child != -1) inORDER(order,order[id].left_child );
    printf(" %d",id);
    if(order[id].right_child != -1) inORDER(order,order[id].right_child );
}
 
void postORDER(Node order[],int id){
    if(order[id].left_child != -1) postORDER(order,order[id].left_child );
    if(order[id].right_child != -1) postORDER(order,order[id].right_child );
    printf(" %d",id);
}
 
int main(){
    int n,id,left,right,root_id;
    scanf("%d",&n);
    Node order[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d %d",&id,&left,&right);
        if(left != -1){
            order[id].left_child = left;
            order[left].parent = id;
        }
        if(right != -1){
            order[id].right_child = right;
            order[right].parent = id;
        }
    }
 
    for(root_id = 0; root_id < n; root_id++){
        if(order[root_id].parent == -1) break;
    }
 
    printf("Preorder\n");
    preORDER(order,root_id);
    printf("\n");
 
    printf("Inorder\n");
    inORDER(order,root_id);
    printf("\n");
 
    printf("Postorder\n");
    postORDER(order,root_id);
    printf("\n");
}


Measured memory_bytes: 2740
using System;

namespace AtCoderAbc160
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var sSplit = s.Split();
            var n = int.Parse(sSplit[0]);
            var x = int.Parse(sSplit[1]);
            var y = int.Parse(sSplit[2]);

            var p = new Problem4();
            var answer = p.GetAnswer(n, x, y);
            for (int i = 0; i < answer.Length; i++)
            {
                Console.WriteLine(answer[i]);
            }
        }
    }

    public class Problem4
    {
        public int[] GetAnswer(int n, int x, int y)
        {
            var answer = new int[n - 1];

            for (int i = 1; i <= n - 1; i++)
            {
                for (int j = i + 1; j <= n; j++)
                {
                    var a = j - i;
                    var b = Math.Abs(i - x) + Math.Abs(j - y) + 1;
                    var distance = Math.Min(a, b);
                    answer[distance - 1]++;
                }
            }

            return answer;
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define   ll   long long int
#define   sz   200010

using namespace std;


ll num[sz];

int main()
{


     double k,x,y,d,m,t;

     ll n,i,c=0;


     cin>>n>>m;

     for(i=1;i<=n;i++)
     {
         cin>>num[i];
         t+=num[i];
     }
      d=t*1.0/(4.0*m);

     for(i=1;i<=n;i++)
     {
        if(num[i]>=d)c++;

     }

     if(c>=m)cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;


   return 0;
}


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

public class Main
{
    public static void main(String[] argv)
    {
        try{
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        String msg1,msg2;
        msg1=bf.readLine();
        msg2=bf.readLine();
        Solver s = new Solver(msg1,msg2);
        s.solve();
        s.approach();
        }
        catch(IOException e )
        {
            System.exit(0);
        }
    }
}

class Solver
{
    String patten,target;
    boolean winFlag;
    public Solver(String s1,String s2)
    {
        patten=s1;
        target=s2;
        winFlag=false;
    }
    public void solve()
    {
        String tmp = target+target;
        for( int i=0;i<patten.length();i++)
        {
            winFlag=true;
            for(int j=0;j<patten.length();j++)
            {
                if(tmp.charAt(i+j)!=patten.charAt(j))
                    winFlag=false;
            }
            if(winFlag==true)
                break;
        }

    } 
    public void approach()
    {
        if(winFlag==true)
            System.out.println("Yes");
        else
            System.out.println("No");
            
    }
    
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rs64() {
	int64_t n;
	scanf("%" SCNd64, &n);
	return n;
}

int main() {
	ri();
	std::string s;
	std::cin >> s;
	int n = s.size();
	int cnt = 0;
	for (int i = 0; i + 2 < n; i++) {
		if (s.substr(i, 3) == "ABC") cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;


int main(){

	int M,N,maximum = 0,tmp,sum;
	scanf("%d %d",&M,&N);

	for(int i = 0; i < M; i++){
		sum = 0;
		for(int k = 0; k < N; k++){
			scanf("%d",&tmp);
			sum += tmp;
		}
		maximum = max(maximum,sum);
	}
	printf("%d\n",maximum);

	return 0;
}

Measured memory_bytes: 2768
import sys
r, D, x2000 = map(int, sys.stdin.readline().split())
x2001 = r * x2000 - D
x2002 = r * x2001 - D
x2003 = r * x2002 - D
x2004 = r * x2003 - D
x2005 = r * x2004 - D
x2006 = r * x2005 - D
x2007 = r * x2006 - D
x2008 = r * x2007 - D
x2009 = r * x2008 - D
x2010 = r * x2009 - D
print(x2001)
print(x2002)
print(x2003)
print(x2004)
print(x2005)
print(x2006)
print(x2007)
print(x2008)
print(x2009)
print(x2010)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
string s,p;
int main(){
	cin>>s;
	p=s;
	reverse(s.begin(),s.end());
	if(p!=s){
		printf("No\n");
		return 0;
	}
	s=s.substr(0,(s.length()-1)/2);
	p=s;
	reverse(s.begin(),s.end());
	if(p!=s){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    rep(i, n)
        cin >> a[i];
    rep(i, n)
        cin >> b[i];
    rep(i, n)
        cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());


    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        ll key = b[i];
        ll numc = c.end() - upper_bound(c.begin(), c.end(), key);
        ll numa = lower_bound(a.begin(), a.end(), key) - a.begin();
        ans += numa * numc;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll int64_t
using namespace std;

bool compare_by_b(pair<string,int> a,pair<string,int> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    rep(i,a) {
        if((b*i+c) % a == 0) {
        cout<<"YES"<<endl;
        return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

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

inline LL gl()
{
    LL f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 1000003, M = N << 1;

int n, m;
int a[N];

signed main()
{
    //File("");
    n = gi();
    int sum = 0;
    for (int i = 1; i <= n; i+=1) a[i] = gi(), sum ^= a[i];
    for (int i = 1; i <= n; i+=1) cout << (sum ^ a[i]) << ' ';
    return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = n / m;
    if (n % m != 0)
        ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
import collections

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

B = [0] * n
for i in range(n):
    if (format(A[i], 'b')[::-1].find('1') <= 2):
        B[i] = format(A[i], 'b')[::-1].find('1')
    else :
        B[i] = 2


C = collections.Counter(B)
if (1 in C):
    if (C[2] >= C[0]):
        print('Yes')
    else:
        print('No')
else:
    if (C[2]+1 >= C[0]):
            print('Yes')
    else:
        print('No')

Measured memory_bytes: 14636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
string s,t;
VI ced,gled;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  cin>>s>>t;
  in mx=0;
  in ns=n;
  in pns=n;
  for(in nt=n-1;nt>=0;--nt){
    while(ns>=0 && (ns==n || s[ns]!=t[nt] || ns>nt)){
      --ns;
    }
    if(ns<0){
      cout<<-1<<endl;
      return 0;
    }
    if(ns==pns)
      continue;
    pns=ns;
    ced.PB(ns);
    gled.PB(nt);
  }
  reverse(all(ced));
  reverse(all(gled));
  forv(i,ced){
    while(i+mx<sz(ced) && ced[i+mx]-mx<gled[i])
      ++mx;
  }
  cout<<mx<<endl;
  return 0;
}


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

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

    int ans = 0;
    if (n >= 2)
        ans += n * (n - 1) / 2;
    if (m >= 2)
        ans += m * (m - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int N,M,F[2][305][305];
char A[305][305];
long long Ans;
inline int LU(int x,int y,int k){
	if (k<1) return 0;
	k+=min(0,min(x-k,y-k));
	return F[0][x][y]-F[0][x-k][y-k];
}
inline int RU(int x,int y,int k){
	int cnt=0;
	for (int i=0;i<k;++i){
		if (x-i<1||y+i>M) break;
		cnt+=A[x-i][y+i]=='#';
	}
	return cnt;
//	if (k<1) return 0;
//	k+=max(0,min(x-k,y+k-M-1));
//	return F[1][x][y]-F[1][x-k][y+k];
}
inline int Calc(int x_1,int y_1,int x_2,int y_2){
	if (x_2<x_1) swap(x_1,x_2),swap(y_1,y_2);
	if (y_1<=y_2){
		int z=max(x_2-N,y_2-M);
		if (z>0) x_2-=z,y_2-=z;
		if (x_2<1||y_2<1) return 0;
		return LU(x_2,y_2,x_2-x_1+1);
	}
	if (y_1>=y_2){
		int z=max(x_2-N,1-y_2);
		if (z>0) x_2-=z,y_2+=z;
		if (x_2<1||y_2>M) return 0;
		return RU(x_2,y_2,x_2-x_1+1);
	}
}
int main(){
	scanf("%d%d",&N,&M);
	for (int i=1;i<=N;++i) scanf("%s",A[i]+1);
	for (int i=1;i<=N;++i)
		for (int j=1;j<=M;++j) F[0][i][j]=F[0][i-1][j-1]+(A[i][j]=='#'),F[1][i][j]=F[1][i-1][j+1]+(A[i][j]=='#');
	int KS=min(N,M);
	for (int i=1;i<=N;++i)
		for (int j=1;j<=M;++j)
			for (int k=KS;k;--k){
				if (i>k&&j>k&&A[i-k][j]=='#'&&A[i][j-k]=='#') Ans+=Calc(i-k,j-2*k,i-2*k+1,j-k-1);
				if (i+k<=N&&j+k<=M&&A[i+k][j]=='#'&&A[i][j+k]=='#') Ans+=Calc(i+k,j+2*k,i+2*k-1,j+k+1);
				if (i>k&&j+k<=M&&A[i-k][j]=='#'&&A[i][j+k]=='#') Ans+=Calc(i-2*k,j+k,i-k-1,j+2*k-1);
				if (i+k<=N&&j>k&&A[i+k][j]=='#'&&A[i][j-k]=='#') Ans+=Calc(i+2*k,j-k,i+k+1,j-2*k+1);
			}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> A;
int f(int p, long long q) {
	if (p == N) return q%2 == 0 ? 1 : 0;
	int r = 0;
	for (int x = A[p]-1; x <= A[p]+1; ++ x) {
		r += f(p+1, q*x);
	}
	return r;
}
int main() {
	cin >> N;
	A.resize(N);
	for (auto& x : A) cin >> x;

	cout << f(0, 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int N,K;
int dp[2005][2005][2];
int solve(string s){
  int INF=1e7;
  for(int i=0;i<2005;i++)
    for(int j=0;j<2005;j++)
      for(int k=0;k<2;k++)
        dp[i][j][k]=-INF;
   
 
  dp[0][0][0]=0;
 
  int maxm=0;
   
  for(int i=0;i<N;i++){
    for(int j=0;j<=K;j++){
      for(int k=0;k<2;k++){
         
        if(dp[i][j][k]==-INF)continue;
        int l=(j+2-k)%2;
        //cout<<i<<' '<<j<<' '<<k<<' '<<l<<' '<<dp[i][j][k]<<endl;
         
        if(j<K){
          dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
           
          dp[i][j+1][1-k]=max(dp[i][j+1][1-k],dp[i][j][k]);
        }
       
        int ncost=dp[i][j][k];
        if(k==1){
          if(s[i]=='L')ncost++;
          if(s[i]=='R')ncost--;
        }
        if(l==1){
          if(s[i]=='U')ncost--;
          if(s[i]=='D')ncost++;
        }
         
        dp[i+1][j][k]=max(dp[i+1][j][k], ncost);
        if(i+1==N)maxm=max(maxm,dp[i+1][j][k]);
      }
    }// j
  }// i
   
  int x=0,y=0;
  for(int i=0;i<N;i++){
    if(s[i]=='L')x--;
    if(s[i]=='R')x++;
    if(s[i]=='D')y--;
    if(s[i]=='U')y++;
  }
   
  return x+y+maxm+maxm;
}
 
int main(){
  string s,t;
  cin>>s>>K;
  N=s.size();
  t=s;
  int ans=0;
  ans=max(ans, solve(t) );
 
  t=s;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='L')t[i]='R';
    if(s[i]=='R')t[i]='L';
  }
  ans=max(ans, solve(t) );
 
 
  t=s;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='L')t[i]='R';
    if(s[i]=='R')t[i]='L';
    if(s[i]=='U')t[i]='D';
    if(s[i]=='D')t[i]='U';
  }
  ans=max(ans, solve(t) );
 
  t=s;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='U')t[i]='D';
    if(s[i]=='D')t[i]='U';
  }
  ans=max(ans, solve(t) );
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 34620
sequence = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(sequence[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25
/*
input case
output case
*/

string correct = "CODEFESTIVAL2016";
string s;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int cnt = 0;

    rep(i,correct.size()) {
        if (correct[i] != s[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384