akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 999999999;
int seg[16399];
void update(int i, int x) {
	i += 8192; seg[i] = x;
	while (i > 1) {
		i >>= 1;
		seg[i] = max(seg[i << 1], seg[i << 1 | 1]);
	}
}
int query(int a, int b, int k, int l, int r) {
	if (a <= l && r <= b) return seg[k];
	if (r <= a || b <= l) return -inf;
	int lc = query(a, b, k << 1, l, (l + r) >> 1);
	int rc = query(a, b, k << 1 | 1, (l + r) >> 1, r);
	return max(lc, rc);
}
int n, m, a[8009], inv[8009]; bool ok[8009];
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i], a[i]--, inv[a[i]] = i;
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (i > a[i]) continue;
		fill(seg + 1, seg + 16384, -inf);
		update(i, 1);
		for (int j = inv[i] + 1; j < n; j++) {
			if (inv[j] <= i || inv[j] > a[i]) continue;
			update(inv[j], query(i, inv[j], 1, 0, 8192) + 1);
		}
		ret = max(ret, seg[1]);
	}
	cout << min(ret + m, n / 2) << endl;
	return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main() {
	ll n;
	ll a, b;
	ll ans = 0;
	cin >> n;
	vi v,w;
	rep(i, n) {
		cin >> a >> b;
		v.pb(a);
		w.pb(b);
	}


	rep(i, n) {
		ans += (w[i] - v[i] + 1);
	}

	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int MAX_N = 1e5;

struct Node {
    int parent;
    int left;
    int right;
    int depth;
    Node(int parent=-1, int left=-1, int right=-1) :
        parent(parent), left(left), right(right) {}
};

Node tree[MAX_N];
int state[MAX_N]; // 0: not exists, 1: created, 2: mentioned

void add_node_to_tree(int id, int k, int c[]) {
    if (k > 0) {
        tree[id].left = c[0];
    }
    ++state[id];
    FOR(i,0,k) {
        int right = i==k-1 ? -1 : c[i+1];
        tree[c[i]].parent = id;
        tree[c[i]].right = right;
        ++state[c[i]];
    }
}

void set_depth(int n, int d) {
    tree[n].depth = d;
    if (tree[n].right != -1) {
        set_depth(tree[n].right, d);
    }
    if (tree[n].left != -1) {
        set_depth(tree[n].left, d+1);
    }
}

void print_tree(int n) {
    FOR(i,0,n) {
        cout << "node " << i << ": parent = " << tree[i].parent << ", depth = " << tree[i].depth << ", ";
        if (tree[i].depth == 0) {
            cout << "root, ";
        } else if (tree[i].left == -1) {
            cout << "leaf, ";
        } else {
            cout << "internal node, ";
        }
        int right = tree[i].left;
        cout << "[";
        while (true) {
            if (right == -1) { break; }
            cout << right;
            right = tree[right].right;
            if (right == -1) { break; }
            cout << ", ";
        }
        cout << "]" << endl;
    }
}

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

    int n;
    cin >> n;

    int id;
    int k;
    int c[MAX_N];
    FOR(i,0,n) {
        cin >> id >> k;
        FOR(j,0,k) {
            cin >> c[j];
        }
        add_node_to_tree(id, k, c);
    }
    int root = distance(state, find(state, state+n, 1));
    set_depth(root, 0);
    print_tree(n);

    return 0;
}

Measured memory_bytes: 8576
#include "bits/stdc++.h"
using namespace std;

vector<int>primes(1e6+1);
vector<int>sums(1e6 + 1);
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes[i] = true;
		}
	}
	flag = true;
}


int main() {
	hurui(999983);
	for (int i = 0; i <1e6; ++i) {
		sums[i + 1] = sums[i] + primes[i + 1];
	}
	while (1) {
		int N; cin >> N;
		if (!N)break;
		long long int prize = 0;
		while (N--) {
			long long int p, m; cin >> p >> m;
			int amax = min(999983ll, p + m);
			int amin = max(0ll, p - m-1);
			const int aprize = sums[amax] - sums[amin];
			prize += aprize - 1;
		}
		cout << max(0ll,prize )<< endl;
	}
	return 0;
}

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
 
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, ll> mill;
typedef map<int, vi> mivi;
typedef map<int, vpii> mivpii;

set<int> S;

int n, x;

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
}

int main() {
	fast_io();
//	freopen("input/ABC154C.txt", "r", stdin);
	
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> x;
		S.insert(x);
	}
	
	cout << (n == S.size() ? "YES" : "NO") << '\n';
	
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

Measured memory_bytes: 3624
/*
 *
 *   Author     : Amit Kumar
 *   Date 	: June 22, 2019
 * 
 */

#include <bits/stdc++.h>

//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define _ub upper_bound
#define _lb lower_bound
#define bint long long int
#define _in(x) scanf("%lld",&x)
#define _f first
#define _s second
#define _all(x) x.begin(),x.end()
#define _pb push_back
#define _eb emplace_back
#define _mp make_pair
#define _iv(v) for(auto &i:v){cin>>i;}
#define _ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define _ovn(v) for(auto i:v){cout<<i<<endl;}
#define _euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define _eovn(v) for(auto i:v){cerr<<i<<endl;}
#define _os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define _osn(s) for(auto itr:s){cout<<itr<<endl;}
#define _eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define _eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define _rep(x) for(auto i=0 ; i<(x); ++i)
#define _repe(x) for(auto i=0; i<=(x); ++i)
#define _irep(a,b) for(auto i=(a); i<(b); ++i)
#define _irepe(a,b) for(auto i=(a); i<=(b); ++i)
#define _crep(a,b,c) for(auto i=(a); i<(b); i+=(c))
#define _crepe(a,b,c) for(auto i=(a); i<=(b); i+=(c))
#define _min(x,y) ((y) ^ (((x) ^ (y)) & (-((x) < (y)))))
#define _max(x,y) ((x) ^ (((x) ^ (y)) & (-((x) < (y)))))
#define endl '\n'
using namespace std;

bint cal(bint x , bint c , bint d){
    bint temp = x;
    temp-=(x/c);
    temp-=(x/d);
    temp+=(x/((c*d)/__gcd(c,d)));
    return temp;
}


auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 


    bint a , b, c, d;
    cin>>a>>b>>c>>d;
    cout<<cal(b , c, d) - cal( a - 1, c, d)<<endl;
    return ;
}




int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        String sc = stdIn.next();
	if(sc.charAt(2)==sc.charAt(3)&&sc.charAt(4)==sc.charAt(5)){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int f[100100],a[100100],b[100100],n;
int main()
{
    scanf("%d",&n);
    int a1=(n+1)/2,b1=n-a1,i;
    int maxd=-1;
    for (i=1;i<=n;i++) {scanf("%d",&f[i]);maxd=max(maxd,f[i]);}
    bool same=1;
    for (i=1;i<n;i++) if (f[i]!=f[i+1]) {same=0;break;}
    if (same) {printf("%d\n",n/2);return 0;}
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for (i=1;i<=n;i+=2) a[f[i]]++;
    for (i=2;i<=n;i+=2) b[f[i]]++;
    int ans1=0,ans2=0,best1=0,best2=0;
    for (i=1;i<=maxd;i++) 
    {
        if (a[i]>ans1) {ans1=a[i];best1=i;}
        if (b[i]>ans2) {ans2=b[i];best2=i;}
    }
    if (best1!=best2) {printf("%d",n-ans1-ans2);return 0;}
    int ans3=0,ans4=0,best3=0,best4=0;
    a[best1]=0;b[best2]=0;
    for (i=1;i<=maxd;i++) 
    {
        if (a[i]>ans3) {ans3=a[i];best3=i;}
        if (b[i]>ans4) {ans4=b[i];best4=i;}
    }
    int tmp=max(ans1+ans4,ans2+ans3);
    printf("%d",n-tmp);
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#define LL long long
#include<stack>
using namespace std;
int const maxn=1e6+10;
LL const inf=(LL)1e18;
struct bkn{
    int next,to;
    LL w;
}e[maxn*2],e2[maxn*2];
stack<int> st;
int tot=1,head[maxn],vis[maxn],dfn[maxn],low[maxn],cnt,scc,h[maxn];
int col[maxn],q[maxn];
LL dp[maxn],sum[maxn];
int n,m;
void add(int hg[],bkn e[],int x,int y,LL w){
    e[tot].to=y,e[tot].next=hg[x],e[tot].w=w,hg[x]=tot++;
}
void tarjan(int x){
    low[x]=dfn[x]=++cnt;
    st.push(x);
    vis[x]=1;
    for (int i=head[x];i;i=e[i].next){
        int y=e[i].to;
        if (!dfn[y]) tarjan(y),low[x]=min(low[x],low[y]);
        else if (vis[y]) low[x]=min(low[x],low[y]);
    }
    if (low[x]==dfn[x]){
        scc++;
        while (1) {
            int y=st.top();
            st.pop();
            vis[y]=0;
            col[y]=scc;
            if (x==y) break;
        }
    }
}
void dfs(int x){
    vis[x]=1;
    for (int i=h[x];i;i=e2[i].next){
        int y=e2[i].to;
        if (!vis[y]) dfs(y);
    }
    q[++cnt]=x;
}
int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++){
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);
        add(head,e,y,x,w);
    }
    for (int i=1;i<=n;i++){
        if (!dfn[i]) tarjan(i);
    }
    tot=1;
    for (int x=1;x<=n;x++){
        for (int i=head[x];i;i=e[i].next){
            int y=e[i].to;
            if (col[y]==col[x]) {
                if (e[i].w!=0) {
                    cout<<"No"<<endl;
                    return 0;
                }
            }
            else add(h,e2,col[y],col[x],e[i].w);
        }
    }
    cnt=0;
    for (int i=1;i<=scc;i++){
        if (!vis[i]) dfs(i);
    }
    for (int i=cnt;i>=1;i--){
        int x=q[i];
        for (int j=h[x];j;j=e2[j].next){
            int y=e2[j].to;
            if (!dp[y]) dp[y]=dp[x]+e2[j].w;
            else if (dp[y]!=dp[x]+e2[j].w) {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}




Measured memory_bytes: 30464
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    (*A,) = map(int, read().split())

    ans = INF
    for i in range(5):
        res = A[i]
        for j in range(5):
            if j != i:
                res += (A[j] + 9) // 10 * 10
        if ans > res:
            ans = res

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <stdio.h>

int main(void){
  
  int n;
  scanf("%d",&n);
  
  int i;
  int a[30][n+1];
  for(i=0; i<n; i++)
    scanf("%d", &a[0][i]);
  
  i = 0;
  int j = 0;
  int c = 0;
  int f = 0;
  
  while(f != 1){
    for(j=0; j<n; j++){
      a[i+1][j] = a[i][j]/2;
      if(a[i][j]%2 == 1){
        f = 1;
        break;
      }
    }
    i++;
    c++;
  }
  
  printf("%d", c-1);
  
  return 0;
}

Measured memory_bytes: 128
//https://atcoder.jp/contests/abc178/tasks/abc178_b
#include <iostream>
#include<vector>
using namespace std;
#define ll long long int
int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll mx = a*c;
  if(a<=0 && c<=0)mx = max(mx,a*c);
  if(b>=0 && d>=0)mx = max(mx,b*d);
  mx = max(mx,a*d);
  mx = max(mx,b*c);
  
  cout<<mx<<"\n";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0&&b>0){
    c-=b;
    a-=d;
  }
  if(c<1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3624
n, y = (int(i) for i in input().split())


for i in range(n+1):
    if 10000*i + 5000*(n-i) < y:
        continue
    if 10000*i + 1000*(n-i) > y:
        break
    for j in range(n+1-i):
        x = 10000*i + 5000*j + 1000*(n-i-j)
        if x==y:
            print("{} {} {}".format(i, j, n-i-j))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <sstream>
#include <climits>
#include <fstream>
#include <cmath>

using namespace std;

/// ********* debug template by Bidhan Roy *********

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const unordered_set< T > &v ) {
    os << "[";
    typename unordered_set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const unordered_map< F, S > &v ) {
    os << "[";
    typename unordered_map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    } 
    return os << "]";
}

#define debug(x) cerr << #x << " = " << x << endl;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<bool> VB;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<LL> VLL;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<VB> VVB;
typedef vector<VI> VVI;
typedef vector<VC> VVC;
typedef vector<VLL> VVLL;
typedef vector<VD> VVD;
typedef vector<VS> VVS;
typedef vector<PII> VPII;

// TEMPLATE DEFINITIONS END

int n, x, tot = 0;
VI a;

void read_input(){
    cin >> n;
    a.resize(n);

    for(int i=0;i<n;i++){
        cin >> a[i];
        tot += a[i];
    }
}

void solve(){

    int P1 = tot / n;
    int P2 = tot / n + 1;
    LL sol1 = 0, sol2 = 0;
    for(int i=0;i<n;i++){
        sol1 += (a[i] - P1) * (a[i] - P1);
        sol2 += (a[i] - P2) * (a[i] - P2);
    }

    cout << min(sol1, sol2) << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    read_input();
    solve();
    return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextInt  
    val b = sc.nextInt
    val d = a-b
    println(if(d == 0) "a == b" else if(d>0) "a > b" else "a < b")
  }
}

Measured memory_bytes: 44896
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e=-0x7ffffff,f=0x7ffffff,g;
int main(){
	cin>>a>>b>>c>>d;
	for(int i=1;i<=a;i++)
		cin>>g,e=max(e,g);
	for(int i=1;i<=b;i++)
		cin>>g,f=min(f,g);
	if(e<f&&c<f&&d>=f)
		cout<<"No War";
	else cout<<"War";
}

Measured memory_bytes: 256
//code for love 
//love for code
//it does not matter how slow you go unless you don't stop

#include <bits/stdc++.h>

using namespace std;

int main()
{
   int n,m;cin>>n>>m;
   int a[m];long long int sum=0;
   for(int i=0;i<m;i++){
       cin>>a[i];
       sum+=a[i];
   }
   if(sum>n) cout<<"-1";
   else cout<<n-sum;
   
}


Measured memory_bytes: 3644
n = int(input())
anagrams = ["".join(sorted(input())) for i in range(n)]
from collections import defaultdict
d = defaultdict(list)
for i in range(n):
    d[anagrams[i]].append(i)
from scipy.misc import comb
cnt=0
for k, v in d.items():
    cnt+=comb(len(v), 2, exact=True)
print(cnt)

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

using namespace std;

int main() {
    string s;
    bool flag = false;
    cin >> s;
    rep(i, 3) {
        if (s[i] == s[i + 1])
            flag = true;
    }
    if (flag)
        printf("Bad\n");
    else
        printf("Good\n");
}


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

int main(){
    int x,y;
    cin >> x >> y;
    string ans ="No";
    for(int i =0; i<x;i++){
        if(2*i + 4*(x-i) == y)ans="Yes";
        else if(4*i + 2*(x-i) == y)ans="Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	cout << 48 - n << endl;
	return 0;
}


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

int gcd(int a, int b){
  if(b) return gcd(b, a%b);
  else return a;
}

int main() {
  int N, X;
  scanf("%d%d", &N, &X);
  int x[N];
  for (int i=0; i<N; i++) {
    cin >>x[i];
  }
  
  for (int i; i<N; i++){
  	x[i] -= X;
  }
  
  int D=x[0];
  
  for (int i;i<N; i++){
    D=gcd(D,x[i]);
  }
  
  printf("%d\n", abs(D));
}


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

int main()
{
    int n;
    cin >> n;
    int ans[n];
    for(int i=0; i<n; i++) {
        int s;
        cin >> s;
        ans[s-1] = i+1;
    }

    for(int i=0; i<n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 1152
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <string.h>
#include <ctype.h>
typedef long long ll;
const int INF = 1e9+7;

void stoupper(char *s) {
	char *p;
	for (p = s; *p != '\0'; p++) {
		*p = toupper(*p);
	}
}

int main(int argc, char **argv)
{
	int count;
	char W[16];
	char a[1024];

	count = 0;
	scanf("%s", W);
	stoupper(W);
	for (;;) {
		scanf("%s", a);
		if (strcmp(a, "END_OF_TEXT") == 0) break;
		stoupper(a);
		if (strcmp(a, W) == 0) count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <climits>
#include <functional>
#include <algorithm>

#define REP(i , begin , end) for( int i = begin; i < end ; ++i )
#define LOOP(n) for(int i = 0; i < n ; ++i)
#define FOREACH(v , fn) std::foreach(v.begin(), v.end(), fn)
#define FINDIF(v, fn) std::find_if( v.begin() , v.end() , fn)

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T>
using Graph = vector<vector<T>>;

int main(){
  string S{},T{},U{};
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if(S == U){
    --A;
  }
  else if(T == U){
    --B;
  }
  cout << A << " " << B ;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  ll n,m;
  cin >> n >> m;
  
  if(n*2 < m){
    ll diff = (m-n*2);
    while(diff%4!=0){
      diff--;
    }
    m -= diff/2;
    n += diff/4;
    //cout << diff << endl;
  }
  //cout << n << ":" << m << endl;

  while(n*2 < m){
    n += 1;
    m -= 2;
  }
  
  //cout << n << ":" << m << endl;

  
  cout << min(n,m/2) << endl;
  
  return 0;
}




Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  string s;
  cin >> s;
  
  s.erase(s.size()-1);
  for(int i = 0; i < 10e3; i++) {
    int c = 0;  
    if(s.size() % 2 == 1) {
      s.erase(s.size()-1);
      continue;
    } else if(s.size() % 2 == 0) {
      int t = 0;
      int b = s.size()/2; 
      for(int j = 0; j < s.size()/2; j++) {
        if(s.at(t) == s.at(b)) {
          t++;
          b++;
          continue;
        } else {
          s.erase(s.size()-1);
          c++;
          break;
        }
      }
      if(c == 0) {
        cout << s.size() << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: usize = read();
    let MOD = (1e9 + 7 as f64) as i64;
    let k: usize = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut pos: Vec<i64> = Vec::new();
    let mut neg: Vec<i64> = Vec::new();
    for i in 0..n {
        if a[i] < 0 {
            neg.push(a[i]);
        } else {
            pos.push(a[i]);
        }
    }
    let mut pos_size = pos.len();
    let mut neg_size = neg.len();
    let mut ok: bool = false;
    if pos_size > 0 {
        if n == k {
            if neg_size % 2 == 0 {
                ok = true;
            } else {
                ok = false;
            }
        } else {
            ok = true;
        }
    } else {
        if k % 2 == 0 {
            ok = true;
        } else {
            ok = false;
        }
    }
    let mut ans: i64 = 1;
    if ok == false {
        a.sort_by_key(|x| x.abs());
        for i in 0..k {
            ans = ((ans * ((a[i] % MOD + MOD) % MOD)) % MOD) % MOD;
            ans %= MOD;
        }
    } else {
        pos.sort();
        neg.sort();
        neg.reverse();
        if k % 2 == 1 {
            ans = (ans * (*pos.last().unwrap() % MOD) % MOD) % MOD;
            pos.pop();
        }
        let mut p: Vec<i64> = Vec::new();
        while (pos.len() >= 2) {
            let mut x: i64 = *pos.last().unwrap();

            pos.pop();
            x = x * (*pos.last().unwrap());
            pos.pop();
            p.push(x);
        }
        while (neg.len() >= 2) {
            let mut x: i64 = (*neg.last().unwrap());

            neg.pop();
            x = x * (*neg.last().unwrap());
            neg.pop();
            p.push(x);
        }
        p.sort();
        p.reverse();
        for i in 0..k / 2 {
            ans = (ans * (p[i] % MOD) % MOD) % MOD;
            ans %= MOD;
        }
    }
    if ans < 0 {
        ans = (ans + MOD) % MOD;
    }
    println!("{}", ans % MOD);
}


Measured memory_bytes: 6504
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    {
        printf("Possible\n");
    }
    else
    {
        printf("Impossible\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main() {
  ll i, j, k;
  
  ll N;
  cin >> N;
  string s;
  cin >> s;
  s="z"+s;
  
  ll a[4444];
  for(i=1; i<=N; i++) {
    if(s[i]=='R') a[i]=0;
    if(s[i]=='G') a[i]=1;
    if(s[i]=='B') a[i]=2;
  }
  
  ll sum[4444][3]={};
  for(i=1; i<=N; i++) {
    for(j=0; j<3; j++) {
      sum[i][j]=sum[i-1][j]+(a[i]==j);
    }
  }
  
  ll ans=0;
  for(i=2; i<=N-1; i++) {
    ll t=a[i];
    ll u=(t+1)%3;
    ll v=(t+2)%3;
    
    ans+=sum[i-1][u]*(sum[N][v]-sum[i][v]);
    ans+=sum[i-1][v]*(sum[N][u]-sum[i][u]);
  }
  
  for(i=2; i<=N-1; i++) {
    ll t=a[i];
    
    for(j=1; j<=min(i-1, N-i); j++)
      if(a[i-j]!=a[i+j] && a[i-j]!=t && a[i+j]!=t)
        ans--;
  }
  
  pt(ans);
}




Measured memory_bytes: 3720
#include<stdio.h>

int main()
{
	int x, y, i = 1;
	while (i <= 3000){
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)
			break;
		else if (0 <= x, y&&x, y <= 10000){
			if (x < y)
				printf("%d %d\n", x, y);
			else
				printf("%d %d\n", y, x);
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
 
using namespace std;
 
bool isLeap(int y)
{
    if(y%400==0)    return true;
    if(y%100==0)    return false;
    if(y%4==0)      return true;
    return false;
}
 
int NumberOfDays(int y,int m,int d)
{
    int num=0;
    int mon[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    if(isLeap(y))   mon[2]++;
 
    for(int i=1;i<y;i++) num+=isLeap(i)?366:365;
    for(int i=1;i<m;i++) num+=mon[i];
    num+=d-1;
 
    return num;
}
 
int main()
{
    int y1,m1,d1,y2,m2,d2;
    while(cin>>y1>>m1>>d1>>y2>>m2>>d2){
        if(!(~y1&&~m1&&~d1&&~y2&&~m2&&~d2)) break;
        cout<<NumberOfDays(y2,m2,d2)-NumberOfDays(y1,m1,d1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;

typedef pair<int, int> point;

map<point, bool> vis;
vector<point> cells;
set<long long> col;

long long w, h, n, ans[10];

int main() {
	cin >> h >> w >> n;
	for(int i = 0; i < n; i++) {
		int x, y;
		cin >> y >> x;
		col.insert(x*(h+1)+y);
		cells.push_back(make_pair(x, y));
	}
	
	for(point p : cells) {
		for(int dx = 0; dx < 3; dx++) {
			for(int dy = 0; dy < 3; dy++) {
				int ox = p.X - dx,
				    oy = p.Y - dy;
				    
				if(ox < 1 || oy < 1 || oy+2 > h || ox+2 > w) continue;
				if(vis[make_pair(ox, oy)]) continue;
				vis[make_pair(ox, oy)] = 1;
				
				int t = 0;
				for(int x = ox; x < ox+3; x++) {
					for(int y = oy; y < oy+3; y++) {
						if(col.find( x*(h+1)+y ) != col.end()) t++;
					}
				}
				ans[t]++;
			}
		}
	}
	
	ans[0] = (w-2)*(h-2);
	for(int j = 1; j < 10; j++) ans[0] -= ans[j];
	for(int j = 0; j < 10; j++) cout << ans[j] << '\n';
	
	cerr << (double)clock() / CLOCKS_PER_SEC << '\n';
	return 0;
}

Measured memory_bytes: 61940
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string a, b;
    cin >> a >> b;
    int na = stoi(a);
    int nb = stoi(b);

    string x = "", y = "";
    rep(i, na) x += b;
    rep(i, nb) y += a;
    if (x > y) cout << y << endl;
    else cout << x << endl;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
a = list(map(float, input().split()))
count = 0
for i in range(n):
    if a[i] >= (1.0/4)*(1.0/m)*sum(a):
        count += 1
if count >= m:
    print("Yes")
else: 
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main(){
	int k,x;
	cin >> k >> x;

	int ishi_max = 1000000;
	int ishi_min = -1000000;
	int sum = ishi_max - ishi_min +1;

	int nuri_min = max(ishi_min,x-k+1);
	int nuri_max = min(ishi_max,x+k-1);
	for(int i=ishi_min;i<=ishi_max;i++){
		if(i >= nuri_min && i <= nuri_max)
			cout << i << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var A int64
	fmt.Scan(&A)
	sc.Split(bufio.ScanWords)
	var ar int64 = int64(1)
	var res []int64
	for i := int64(0); i < A; i++ {
		tmp := nextInt()
		if tmp == 0 {
			fmt.Print(0)
			return
		}
		res = append(res, tmp)
	}
	for _, r := range res {
		if r > 1e18/ar {
			fmt.Print(-1)
			return
		}
		ar = ar * r
	}
	fmt.Print(ar)
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int cnt= 0;
    REP(i,n-2) if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<queue>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<sstream>
#include<map>


using namespace std;


#define clr(arr,val) memset(arr,val,sizeof(arr))
#define mp make_pair
#define pb push_back
#define fr first
#define sc second


typedef long long int ll;
typedef unsigned long long int ull;

typedef pair<int,int> pi;
vector<pi>vec;
int main()

{
    int n;
     cin>>n;
     string s="ACL";
    for(int i=0;i<n;i++)
    {
        cout<<s;
    }
  cout<<endl;
}


Measured memory_bytes: 3516
// AOJ 0172: Doctor's Research Rooms
// 2018.1.24 bal4u@uu

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

typedef struct { char rm; int light; } Q;
Q q[491520]; int top, end;
Q *used[15][32768];

int rm[15][15], s_rm[15];
int sw[15][15], s_sw[15];

char *msg[7] = {0,
"You can go home in %d steps.\n",
"You can not switch off all lights.",
"Help me!",
"Move to room %d.\n",
"Switch on room %d.\n",
"Switch off room %d.\n" };

typedef struct { char msg, rm; } T;
T res[10000]; int sz;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c < '0') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, m, i, j, s, t, ans;
	int room, light;

	while (n = in()) {
		m = in();
		memset(s_rm, 0, sizeof(s_rm));
		memset(s_sw, 0, sizeof(s_sw));

		for (i = 0; i < m; i++){
			s = in()-1, t = in()-1;
			rm[s][s_rm[s]++] = t;
			rm[t][s_rm[t]++] = s;
		}

		light = 0; for (i = 0; i < n; i++) if (in()) light |= 1 << i;

		for (i = 0; i < n; i++) {
			j = in(); while (j--) sw[i][s_sw[i]++] = in()-1;
			qsort(sw[i], s_sw[i], sizeof(int), cmp);
        }

		memset(used, 0, sizeof(used));
		q[0].rm = 0, q[0].light = light; top = 0, end = 1;
		used[0][light] = q;

		ans = 3;
		while (top < end) {
			s = q[top].rm, t = q[top].light;

			if (s == n-1) {
				if (t == 1<<(n-1)) { ans = 1; break; }
				ans = 2;
			}

			for (i = 0; i < s_sw[s]; i++) if (sw[s][i] != s) {
				light = t ^ (1<<sw[s][i]);
				if (used[s][light] == 0) {
					used[s][light] = q + top;
					q[end].rm = s, q[end++].light = light;
				}
			}

			for (i = 0; i < s_rm[s]; i++) {
				room = rm[s][i];
				if (t & (1<<room)) {
					if (used[room][t] == 0) {
						used[room][t] = q + top;
						q[end].rm = room, q[end++].light = t;
					}
				}
			}

			top++;
		}
 
		if (ans > 1) puts(msg[ans]);
		else {
			Q p = q[top];
			sz = 0;
			while (1) {
				Q nxt = *used[p.rm][p.light];
				if (nxt.rm == p.rm && nxt.light == p.light) break;
				if (p.rm != nxt.rm) res[sz].msg = 4, res[sz++].rm = p.rm;
				else for (i = 0; i < n; i++) if ((p.light & (1<<i)) ^ (nxt.light & (1<<i))) {
					if (p.light & (1<<i)) res[sz].msg = 5; else res[sz].msg = 6;
					res[sz++].rm = i;
					break;
				}
				p = nxt;
			}
			printf(msg[ans], sz);
			while (sz--) printf(msg[res[sz].msg], 1 + res[sz].rm);
		}
    }
    return 0;
}


Measured memory_bytes: 5932
function Main(input){
  inp = input.split('\n');
  N = parseInt(inp[0]);
  A = inp[1].split(' ').map((i) => { return parseInt(i); });
//  N = 3;
//  A = [3, 2, 1];

  result = true;
  count = 0;
  for (k = 0; result; k++) {
    
    // is All Even Number
    for (i = 0; i < N; i++) {
      if (A[i]%2 != 0) {
        count = k
        result = false;
        break;
      }
      A[i] = A[i]/2;
    }    
  }

  console.log(count);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include <stdio.h>
int main(){
  int N,i,j,temp,c=0;
  int a[100];

  scanf("%d",&N);
  
  for(i = 0;i < N;i++) scanf("%d",&a[i]);

  for(i = 0;i < N-1;i++){
    for(j = N-1; j != 0; j--){
      if(a[j]<a[j-1]){
	temp = a[j];
	a[j] = a[j-1];
	a[j-1] = temp;
	c++;
      }
    }
  }

  for(i = 0;i < N-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d",a[N-1]);
    

  printf("\n%d\n",c);

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rep2(i,a,b) for(ll i=a;i>=b;i--)

int main(int argc, char** argv) {
	string s;
	cin>>s;
	int fg=0,fg1=0;
	rep(i,0,s.length()-1){
	if(s[i]=='A')fg++;else if(s[i]=='B')fg1++;}
	if(fg&&fg1)
	cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys

def is_primes(n):
    n+=1
    primes = [1]*n
    primes[0] =0
    primes[1] =0
    for i in range(2,int(n**0.5)+1):
        if primes[i] ==1:
            for j in range(2*i,n,i):
                primes[j] = 0
    return primes
def iscomb(n):
    for p in primes:
        if p>n**0.5+1:
            return False
        if n%p==0:
            return True


n = ni()
nm=55555
isprimes = is_primes(nm)
primes = [p for p in range(nm) if isprimes[p]]
i=0
ans=[]
while len(ans)<n:
    if primes[i]%5==1:
        ans.append(primes[i])
    i+=1
print(*ans)


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

int main(void)
{
    int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<long long> p(a), q(b), r(c);
    for (int i = 0; i < a; i++) cin >> p[i]; sort(p.begin(), p.end()); reverse(p.begin(), p.end());
    for (int i = 0; i < b; i++) cin >> q[i]; sort(q.begin(), q.end()); reverse(q.begin(), q.end());
    for (int i = 0; i < c; i++) cin >> r[i]; sort(r.begin(), r.end()); reverse(r.begin(), r.end());

    vector<long long> s(x + y + c);
    for (int i = 0; i < x; i++) s[i] = p[i];
    for (int i = 0; i < y; i++) s[i + x] = q[i];
    for (int i = 0; i < c; i++) s[i + x + y] = r[i];
    sort(s.begin(), s.end()); reverse(s.begin(), s.end());

    long long ans = 0;
    for (int i = 0; i < x + y; i++) ans += s[i];
    cout << ans << endl;
}

Measured memory_bytes: 7696
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

void solve() {
	int n, ans = 0; cin >> n;
	vector<int>a(n);
	vector<vector<pair<int, int> > >xy(n, vector<pair<int, int> >());
	int alp = pow(2, n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < a[i]; j++) {
			int p, q;
			cin >> p >> q;
			xy[i].push_back(make_pair(p, q));
		}
	}
	for (int i = 0; i < alp; i++) {
		vector<int>patern(n);
		bool is_able = true;
		int p = alp / 2, q = i;
		for (int j = 0; j < n; j++) {
			patern[j] = (int)q / p;
			q %= p; p /= 2;
		}
		for (int j = 0; j < n; j++) {
			if (patern[j] == 1) {
				for (int k = 0; k < a[j]; k++) {
					if (xy[j][k].second != patern[xy[j][k].first - 1]) {
						is_able = false;
					}
				}
			}
		}
		if (is_able) {
			int sum = 0;
			for (int j = 0; j < n; j++) {sum += patern[j];}
			if (ans < sum)ans = sum;
		}
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 512
<?php
fscanf(STDIN, "%s", $S);
$arr = str_split($S);
$sum = [];
foreach ($arr as $c) {
    isset($sum[$c]) ? $sum[$c]++ : $sum[$c] = 1;
}
echo max($sum) === 2 && min($sum) === 2 ? "Yes" : "No";


Measured memory_bytes: 4856
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    p = list(map(int, input().split()))
    count = 0
    for p, q in zip(p, sorted(p)):
        if p != q:
            count += 1

    if count > 2:
        print('NO')
    else:
        print('YES')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */
 
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;
 
// std::cout << std::setprecision(20) << 1.1 << endl;
 

int64_t GreatestCommonDivisor(const int64_t a, const int64_t b) {
  // GCD. O(log(min(a, b))). 最大公約数.
  int64_t result = -1LL;
  if (a < 0) {
    std::cerr << "ERROR: GreatestCommonDivisor(): a is out of range: " << a << std::endl;
    throw 1;
  } else if (b < 0LL) {
    std::cerr << "ERROR: GreatestCommonDivisor(): b is out of range: " << b << std::endl;
    throw 1;
  } else if (a == 0LL) {
    result = b;
  } else if (b == 0LL) {
    result = a;
  } else {
    const int64_t new_a = std::min(a, b);
    const int64_t new_b = std::max(a, b) % new_a;  // Euclidean Algorithm
    result = GreatestCommonDivisor(new_a, new_b);
  }
  return result;
}

int64_t LeastCommonMultiple(const int64_t a, const int64_t b) {
  // LCM. O(log(min(a, b))). 最小公倍数.
  int64_t result;
  if (a == 0 || b == 0) {
    return 0;
  } else if (a == 1) {
    return b;
  } else if (b == 1) {
    return a;
  } else if (a < 0 || b < 0) {
    std::cerr << "ERROR: LeastCommonMultiple(): Invalid arg. a=" << a << ", b=" << b << std::endl;
    throw 1;
  }
  try {
    result = (a / GreatestCommonDivisor(a, b) * b);
  } catch (...) {
    std::cerr << "ERROR: LeastCommonMultiple()" << std::endl;
  }
  return result;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int64_t N;
  cin >> N;
  int64_t result = 1;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    result = LeastCommonMultiple(result, a);
  }
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main() {
	int N = 0;
	int K = 0;
	cin >> N >> K;
	int result = K;
	rep(i,N-1){
		result = result * (K - 1);
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256