akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;

const int N = 2e5 + 5;

vector<int> g[N], h[2*N];
int c[N], cind[N], sz[N], par[N];

void init(int u, int p=0){
	int cpar = cind[c[u]];	
	h[cpar].push_back(u);
	sz[u] = 1;
	par[u] = p;
	for(int v:g[u]){
		if(v == p)continue;
		cind[c[u]] = v;
		init(v,u);
		sz[u] += sz[v];
	}
	cind[c[u]] = cpar;
}

ll ans[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	rep(i,1,n+1){
		cin >> c[i];
		c[i]--;
	}
	rep(i,0,n-1){
		int x,y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	iota(cind,cind+N,N);
	init(1);
	rep(i,2,n+1){
		int ctar = c[par[i]];	
		ll cnt = sz[i];
		for(int v:h[i]){
			cnt -= sz[v];
		}
		ans[ctar] += cnt*(cnt-1)/2 + cnt;
	}
	rep(i,N,2*N){
		int ctar = i - N;
		ll cnt = sz[1];
		for(int v:h[i]){
			cnt -= sz[v];
		}
		ans[ctar] += cnt*(cnt-1)/2 + cnt;
	}
	rep(i,0,n)ans[i] = 1LL * n * (n-1)/2 + n - ans[i];
	rep(i,0,n)cout << ans[i] << '\n';
}


Measured memory_bytes: 50472
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            int ans = 0;
            int apos = 0;
            int zpos = 0;

            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) == 'A') {
                    apos = i;
                    break;
                }
            }

            for (int i = S.length() - 1; i > 1; i--) {
                if (S.charAt(i) == 'Z') {
                    zpos = i + 1;
                    break;
                }
            }

            ans = zpos - apos;

            // 出力
            out.println(ans);

        }

    }
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(2e6+5);

void pre() {

}

void solve() {
  int n;  cin>>n;
  vector<int> a(n);
  rep(i,n)  cin>>a[i];
  int ans = 0;
  rep(i,n) {
    repi(j,i+1,n-1) {
      ans += a[i]*a[j];
    }
  }
  cout<<ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  #endif
  int t = 1;
  pre();
//  cin>>t;
  rep(i,t)  {
    //cout<<"\nCase #"<<(i+1)<<"\n";
    solve();
    cout<<'\n';
  }
  return 0;
}


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

using namespace std;

int main()
{
    int a;

    cin >> a;

    if (a < 1200) {
        cout << "ABC" << endl;
    }
    else if (a < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
    return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 12
#define S 5005
#define M 1777771
using namespace std;
typedef unsigned long long ull;

bool dp[(1<<N)][S];
int n, m;
string s[N],t;

ull d1[N],d2[S],A[30];

int main(){

  while(1){
    
    cin>>n>>m;
    if(!n&&!m) break;
    
    for(int i=0;i<n;i++) cin>>s[i];

    t="";
    
    for(int i=0;i<m;i++){
      string tmp;
      cin>>tmp;
      t+=tmp;
    }

    for(int i=0;i<n;i++){
      ull hash=s[i][0];
      for(int j=1;j<s[i].size();j++)
	hash=hash*M+s[i][j];
      d1[i]=hash;
    }
    
    d2[0]=t[0];
    for(int i=1;i<t.size();i++)
      d2[i]=d2[i-1]*M+t[i];

    memset(dp,0,sizeof(dp));

    for(int i=0;i<t.size();i++) dp[0][i]=true;
    
    A[0]=1;
    for(int i=1;i<30;i++) A[i]=A[i-1]*M;

    for(int i=0;i<(1<<n);i++){

      for(int j=0;j<t.size();j++){

	if(!dp[i][j]) continue;
	
	for(int k=0;k<n;k++){

	  if(i&(1<<k)) continue;

	  int slen=s[k].size();
	  
	  if(t.size()<j+slen) continue;
	  
	  ull x=d2[j+slen-1];
	  if(j) x-=d2[j-1]*A[slen];
	  
	  if(d1[k]!=x) continue;
	  
	  dp[i|(1<<k)][j+slen]=true;
	  
	}
	
      }
      
    }

    int ans=0;
    
    for(int i=0;i<=t.size();i++)
      ans+=dp[(1<<n)-1][i];

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

Measured memory_bytes: 23220
#include<stdio.h>

int main(void) {
	int N, K, Q, a, i, flg;
	scanf("%d %d %d", &N, &K, &Q);

	int member[N];
	for (i = 0; i < N; i++) {
		member[i] = 0;
	}

	for (i = 0; i < Q; i++) {
		scanf("%d", &a);
		member[a - 1]+=1;
	}

	for (i = 0; i < N; i++) {
		flg = K - Q + member[i];
		if (flg > 0)printf("Yes\n");
		else printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
using namespace std;
const LL INF = (LL) 1e9 + 5;
const LL MOD = (LL) 1e9 + 7;
const int MAXN = 100005;

int n, a, b;
int d1[MAXN], d2[MAXN], pa[MAXN];
vector<int> G[MAXN];

void dfs(int v, int p, int d, int dist[MAXN]) {
	dist[v] = d;
	pa[v] = p;
	for (int to : G[v]) {
		if (to != p) {
			dfs(to, v, d + 1, dist);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> a >> b;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	dfs(a, a, 0, d1);
	dfs(b, b, 0, d2);
	
	if (n == 2) {
		cout << "0\n";
		return 0;
	}
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (d1[i] == d2[i] && d1[pa[i]] != d2[pa[i]]) {
			ans = max(ans, d2[i]);
		}
		if (d1[i] < d2[i] && G[i].size() != 1) {
			ans = max(ans, d2[i]);
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, m;
  while (cin >> n >> m) {
    vector<int> v;
    for (int i = 1; i * i < m; ++i) {
      if (m % i == 0) {
        v.push_back(i);
        v.push_back(m / i);
      }
    }

    // each (i, cnt) cout << i << endl;

    int x = 1;
    each (i, v) {
      int y = i * (m / i / n);
      if (y) {
        int z = y;
        if ((m / i) % n) z += i;
        // cout << i << ' ' << y <<  ' ' << z << ", " << n << endl;
        x = max(x, __gcd(y, z));
      }
    }
    cout << x << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

void main()
{
  int x, a, b; readV(x, a, b);
  writeln((x-a).abs < (x-b).abs ? "A" : "B");
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ans=0; cin>>n; 
    map <pii,int> cnt;
    vi a(n),b(n);
    for (int i=0;i<n;i++) cin >> a[i] >> b[i] ; 
    for (int i=0;i<n-1;i++){
        for (int j=i+1;j<n;j++){
            int x=a[i]-a[j]; 
            int y=b[i]-b[j]; 
            if (x<0) x=-x,y=-y; 
            if (x==0) y=abs(y);
            cnt[{x,y}]++;
            ans = max(ans,cnt[{x,y}]);
        }
    }
    cout << (n-ans) << endl ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}

/*
6
1 1
3 3
6 6
7 7
8 8
9 9

*/

Measured memory_bytes: 3648
import fractions, copy, collections

if __name__ == '__main__':
    n, ma, mb = map(int, input().split())
    rows = [map(int, input().split()) for _ in range(n)]

    ht = {(0, 0) : 0}
    for a, b, c in rows:
        temp = copy.deepcopy(ht)
        for x, y in ht:
            if not (x + a, y + b) in ht or ht[(x, y)] + c < ht[(x + a, y + b)]: temp[(x + a, y + b)] = ht[(x, y)] + c
        ht = temp
    
    ans = float('inf')
    for a, b in ht:
        if b != 0 and fractions.Fraction(ma, mb) == fractions.Fraction(a, b): ans = min(ans, ht[(a, b)])
    
    print(-1 if ans == float('inf') else ans)

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

int abs(int& a){
	if(a<0)a*=-1;
	return a;
}

int32_t main(){
	int n,h[MAXN];
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	int custo[MAXN];
	custo[0]=0;
	custo[1]=0;
	for(int i=2;i<=n;i++){
		custo[i]=custo[i-1]+abs(h[i]-h[i-1]);
		if(i>=3)custo[i]=min(custo[i],custo[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<custo[n]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;

    int64_t power = 1;
    int k = pow(10,9) + 7;

    for (int i = 0; i < N; i++)
    {
        power *= (i+1);
        power %= k;
    }
    cout << power << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#define ini ll_MAX
#define inl LLONG_MAX
#define MOD 1000000007
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define pbds tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
 
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
 
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
 
ll mod(ll a,ll b)
{
    return (b+a%b)%b;
}
 
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  
 
double sqdist(double a,double b,double c,double d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}
ll fact(ll n)
{
    if(n==0)return 1;
    ll ans = 1;
    FOR(i,1,n+1)ans*=i;
    return ans;
}
 
 
 
void solve()
{
    ll n,m,x;
    cin>>n>>m>>x;
    ll arr[n+1][m+1],c[n];
    for(ll i=0;i<n;i++)
    {
        cin>>c[i];
        for(ll j=0;j<m;j++)
            cin>>arr[i][j];
    }
    ll cost = LLONG_MAX;
    for(ll i=1;i<(1<<n);i++)
    {
        ll curcost = 0;
        vector<ll> vec(m,0);
        for(ll j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                curcost+=c[j];
                for(ll k=0;k<m;k++)
                    vec[k]+=arr[j][k];
            }
        }
        int f = 1;
        for(auto i:vec)
        {
            if(i<x)f=0;
        }
        if(f)
        cost = min(cost,curcost);
        
    }
    if(cost == LLONG_MAX)cout<<-1;
    else cout<<cost;
}   
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC160
{
    /// <summary>
    /// 
    /// </summary>
    static class C
    {
        static void Main(string[] args)
        {
            var k = NextInt();
            var n = NextInt();
            var aas = ReadIntArray();

            var zero = k - aas[n - 1] + aas[0];
            for (int i = n - 1; i >= 1; i--)
            {
                aas[i] -= aas[i - 1];
            }
            aas[0] = zero;

            Console.WriteLine(k - aas.Max());
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 34780
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int n,d1[N],d2[N];
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main()
{
	n=read();
	for(register int i=1;i<=n;i++)
	{
		int x=read(),y=read();
		d1[i]=x+y;
		d2[i]=x-y;
	}
	sort(d1+1,d1+1+n);
	sort(d2+1,d2+1+n);
	printf("%d\n",max(d1[n]-d1[1],d2[n]-d2[1]));
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  int a, b;
  cin >> a >> b;
  rep(i, 1010) {
    int aa = i * 8 / 100;
    int bb = i * 10 / 100;
    if (a == aa && b == bb) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


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

int a[4];

int main(void){
  string input;
  cin >> input;
  for(int i = 0; i < 4; i++) a[i] = input[i] - '0';
  
  for(int x = 0; x < (1 << 3); x++){
	int sum = a[0];
    string s;
    s += (char)(a[0] + '0');
    for(int i = 0; i < 3; i++){
	  if(x&(1<<i)){
        sum += a[i+1];
        s += '+';
        s += (char)(a[i+1] + '0');
      }else{
        sum -= a[i+1];
        s += '-';
        s += (char)(a[i+1] + '0');
      }
    }
    if(sum == 7){
      s += "=7";
	  cout << s << endl;
      return 0;
    }
  }    
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

char str[MAXN];

int main(){
	scanf("%s", str);
	int n = strlen(str);
	lint cnt = 0, dap = 0;
	for(int i=n-1; i>=0; i--){
		if(str[i] == 'W') cnt++;
		else dap += cnt;
	}
	cout <<dap << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>//atcoder.113.B
using namespace std;
int main(){
	int n,m=1,a,b,i;
	cin>>n>>a>>b;
	double j[n+1],k[n+1];
	for(i=1;i<=n;i++){
		cin>>j[i];
		j[i]*=1.0;
		k[i]=abs(b-(a-j[i]*0.006));
	}
	for(i=2;i<=n;i++)
		if(k[i]<k[m])
			m=i;
	cout<<m;
	return 0;
}

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

char abc[] = "abcdefghijklmnopqrstuvwxyz";

int abc_pos(char str){
    int i, ret;

    for(i = 0; i < 26; i++){
        if(str == abc[i]){
            ret = i;
        }
    }
    return ret;
}

int main(){
    int N, i, j, max = 0;
    char str[100];
    int flag_l[26] = {0}, flag_r[26] = {0};
    int same[100] = {0};

    scanf("%d%s", &N, str);

    for(i = 0; i < N - 1; i++){
        for(j = 0; j <= i; j++){
            flag_l[abc_pos(str[j])] = 1;
        }
        for(j = i + 1; j < N; j++){
            flag_r[abc_pos(str[j])] = 1;
        }
        for(j = 0; j < 26; j++){
            if(flag_l[j] == 1 && flag_r[j] == 1){
                same[i]++;
            }
        }
        //printf("%d: %d\n", i, same[i]);
        if(max <= same[i]){
            max = same[i];
        }
        for(j = 0; j < 26; j++){
            flag_l[j] = 0;
            flag_r[j] = 0;
        }
    }
    printf("%d\n", max);

    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
    int x,y;
  cin>>x>>y;
  if(y%2==0 && y/2-x>=0 && 2*x-y/2>=0) cout<<"Yes";
  else cout<<"No";
  nline;
  return 0;
}


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

int64_t fact(int64_t n){
  int64_t s = 1;
  for (int64_t i = 1; i < n+1; i++){
    s = s * i;
  }
  return s;
}

int64_t comb(int64_t n, int64_t k){
  int64_t s = 1;
  k = min(n-k, k);
  for (int64_t i = 0; i < k; i++){
    s = s * (n - i);
  }
    
  return s / fact(k);
}
  
int64_t pwr2(int n){
  int64_t s = 1;
  for (int i = 0; i < n; i++){
    s = s * 2;
  }
  return s;
}

int main() {
  int64_t N, P, o = 0, e = 0, a, c = 1, co = 0;
  
  cin >> N >> P;
  for (int i = 0; i < N; i++){
    cin >> a;
    if (a % 2 == 0){
      e += 1;
    }
    else{
      o += 1;
    }
  }
  
  for (int i = 0; i < e; i++){
    c = c * 2;
  }
  
  for (int i = 0; i < (o+1)/2; i++){
    co += comb(o, 2*i+1);
  }
  
  if (P == 1){
    cout << c * co << endl;
  }
  else{
    cout << c * (pwr2(o)-co) << endl;
  }
}

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

W, H, x, y = map(int, input().split())

count = 0
s = 0
if 2 * x == W and 2 * y == H:
    s = W * H / 2
    count = 4
else:

    if (x == 0 and y == 0) or (x == 0 and y == H) or (x == W and y == 0) or (x == W and y == H):
        s = W * H / 2
        count = 1
    elif (x == 0 and 2 * y == H) or (x == W and 2 * y == H) or (2 * x == W and y == 0) or (2 * x == W and y == H):
        s = W * H / 2
        count = 1
    else:
        if 2 * x == W:
            s = W * H / 2
            count = 1

        elif 2 * y == H:
            s = W * H / 2
            count = 1
        else:
            a = (H - 2 * y) / (2 * x - W)
            if a > 0:
                if ((H + a * x - y) / a) <= W and ((a * x - y) / a) >= 0:
                    s = (H**2 / 2 + H * (a * x - y)) / a
                    count += 1

                a *= -1
                if ((H + a * x - y) / a) >= 0 and ((a * x - y) / a) <= W:
                    s = (H**2 / 2 + H * (a * x - y)) / a
                    count += 1


            elif a < 0:
                s = a * (W**2) / 2 + (y - a * x) * W
                if (a * W + y - a * x) >= 0 and (y - a * x) <= H:
                    count += 1
                a *= -1
                if (a * W + y - a * x) <= H and (y - a * x) >= 0:
                    count += 1



if count == 1:
    print("{0:.6f}".format(abs(s)),0)
else:
    print("{0:.6f}".format(abs(s)),1)


Measured memory_bytes: 3188
#include<cmath>
#include<cstdio>
#include<vector>

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

using namespace std;

const double EPS=1e-8;
const double INF=1e77;

template<class T>
struct point{
	T x,y;
	point operator-(const point &a)const{ return (point){x-a.x,y-a.y}; }
};

template<class T>
struct segment{ point<T> a,b; };

template<class T>
struct polygon:vector< point<T> >{};

template<class T>
T dot(const point<T> &a,const point<T> &b){ return a.x*b.x+a.y*b.y; }

template<class T>
T cross(const point<T> &a,const point<T> &b){ return a.x*b.y-a.y*b.x; }

enum{CCW=1,CW=-1,ON=0};
int ccw(const point<double> &a,const point<double> &b,const point<double> &c){
	double rdir=cross(b-a,c-a);
	if(rdir> EPS) return CCW;
	if(rdir<-EPS) return CW;
	return ON;
}

bool intersect(const segment<double> &S1,const segment<double> &S2){
	if(max(S1.a.x,S1.b.x)+EPS<min(S2.a.x,S2.b.x)
	|| max(S1.a.y,S1.b.y)+EPS<min(S2.a.y,S2.b.y)
	|| max(S2.a.x,S2.b.x)+EPS<min(S1.a.x,S1.b.x)
	|| max(S2.a.y,S2.b.y)+EPS<min(S1.a.y,S1.b.y)) return false;
	return ccw(S1.a,S1.b,S2.a)*ccw(S1.a,S1.b,S2.b)<=0
		&& ccw(S2.a,S2.b,S1.a)*ccw(S2.a,S2.b,S1.b)<=0;
}

template<class T>
T dist2(const point<T> &a,const point<T> &b){
	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

template<class T>
double dist2(const segment<T> &S,const point<T> &p){
	if(dot(S.b-S.a,p-S.a)<=0) return dist2(p,S.a);
	if(dot(S.a-S.b,p-S.b)<=0) return dist2(p,S.b);
	return (double)cross(S.b-S.a,p-S.a)*cross(S.b-S.a,p-S.a)/dist2(S.a,S.b);
}

template<class T>
double dist(const segment<T> &S1,const segment<T> &S2){
	if(intersect(S1,S2)) return 0;
	return sqrt(min(min(dist2(S1,S2.a),dist2(S1,S2.b)),
					min(dist2(S2,S1.a),dist2(S2,S1.b))));
}

double dist(const polygon<double> &F1,const polygon<double> &F2){
	double res=INF;
	rep(i,F1.size()) rep(j,F2.size()) res=min(res,dist((segment<double>){F1[i],F1[(i+1)%F1.size()]},(segment<double>){F2[j],F2[(j+1)%F2.size()]}));
	return res;
}

int main(){
	for(int W,n;scanf("%d%d",&W,&n),W;){
		polygon<double> F[200];
		rep(i,n){
			int m; scanf("%d",&m);
			F[i].resize(m);
			rep(j,m) scanf("%lf%lf",&F[i][j].x,&F[i][j].y);
		}

		int s=n,t=n+1;
		double d[202][202];
		rep(u,n+2) rep(v,n+2) d[u][v]=(u==v?0:INF);
		// source -> sink
		d[s][t]=W;
		rep(u,n){
			// source -> node
			rep(i,F[u].size()) d[s][u]=min(d[s][u],F[u][i].x);
			// node -> node
			rep(v,n) d[u][v]=dist(F[u],F[v]);
			// node -> sink
			rep(i,F[u].size()) d[u][t]=min(d[u][t],W-F[u][i].x);
		}
		rep(w,n+2) rep(u,n+2) rep(v,n+2) d[u][v]=min(d[u][v],d[u][w]+d[w][v]);

		printf("%.9f\n",d[s][t]);
	}

	return 0;
}

Measured memory_bytes: 1432
n,a,b=map(int,input().split())
s=input()
os=int(0)
for i in range(n):
    if s[i]=='c':
        print("No")
    elif s[i]=='a' and a+b>0:
        print("Yes")
        a-=1
    elif s[i]=='b' and os<b and a+b>0:
        print("Yes")
        os+=1
        a-=1
    else:
        print("No")

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

int main() {
  long long n,a,b,c,d,e,f;
  cin>>n>>a>>b>>c>>d>>e;
  f=min({a,b,c,d,e});
  long long ans=ceil((double) n/f)+4;
  cout<<ans<<endl;
  
  
  
  
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b,k;
 cin >> k >> a >> b;
 for(int i = a ;i<=b ;i++){
     if(i%k==0){
         cout <<"OK"<< endl;return 0;
     }
 }
 cout << "NG" << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;

typedef vector<vector<pair<int, int> > > GRA;
int i,j,N,M;

bool dfs( int v, GRA &g, vector<int> &pos, vector<bool> &fix ) {
	fix[v] = true;
	
	for (int i = 0; i < g[v].size(); i++) {
		int next_pos = g[v][i].first;
		int d = g[v][i].second;
		if (fix[next_pos]) {
			if (pos[v] + d != pos[next_pos]) return false;
		} else {
			pos[next_pos] = pos[v] + d;
			if (!dfs(next_pos, g, pos, fix ))return false; 
		}
	}
	return true;
}

int main() {
	int L,R,D;
	bool ans = true;
	
	cin >> N >> M;
	GRA g(N);
	vector<int> pos(N,0);
	vector<bool> fix(N,false);
	
	REPI(0,M) {
		cin >> L >> R >> D;
		L--;R--;
		g[L].push_back(make_pair(R,D));
		g[R].push_back(make_pair(L,-D));
	}
	
	while(i<N) {
		if (!fix[i]) 
		if (!dfs(i,g,pos,fix)) {
			ans = false;
			break;
		}
		i++;
	}
	
	if (ans) cout << "Yes" << endl;
	else  cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 13824
//073 B - Write and Erase 2017/09/09
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int64 n; cin >> n;
    vector<int64> a(n);
    rep(i ,n) cin >> a[i];
    sort(a.begin(),a.end());
    int64 ans=0;
    for(int64 i=0;i<n;++i){
        int64 count=0; int64 f=a[i];
        while(i < n && f==a[i]){
            ++count; ++i;
        }
        --i;
        ans+=count%2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		long k=sc.nextLong();
		if(k%2==0) {
			System.out.println(""+(a-b));
		}else {
			System.out.println(""+(b-a));
		}
	}
}

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


struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> size;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        size = vector<int>(N, 1);
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        }
        else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }
    
    int getsize(int x) {
        return size[root(x)];
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    unionfind uf(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        uf.unite(a,b);
    }
    int ans = 1;
    for (int i = 0; i < N; i++) {
        ans = max(ans, uf.getsize(i));
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
multiset < pii > all[2],cur[2];
int n,dir,pos;
LL res=-linf;
void solve(){
	LL ret=0LL;
	int i,j,k;
	for(i=0;i<n;++i){
		pii crv;
		if(dir&1){
			crv=*cur[1].begin();
			swap(crv.first,crv.second);
		}
		else crv=*cur[0].rbegin();
		cur[0].erase(cur[0].lower_bound(crv));
		cur[1].erase(cur[1].lower_bound(mpr(crv.second,crv.first)));
		dir^=1;
		if(pos>=crv.first && pos<=crv.second) continue;
		if(ABS(pos-crv.first)<ABS(pos-crv.second)){
			ret+=(LL)ABS(pos-crv.first);
			pos=crv.first;
		}
		else{
			ret+=(LL)ABS(pos-crv.second);
			pos=crv.second;
		}
	}
	UMAX(res,ret+(LL)ABS(pos));
}
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		scanf("%d%d",&j,&k);
		all[0].insert(mpr(j,k));
		all[1].insert(mpr(k,j));
	}
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
    cur[0]=all[0];cur[1]=all[1];
	pos=0;
	dir=0;
	solve();
	cur[0]=all[0];cur[1]=all[1];
	pos=0;
	dir=1;
	solve();
	printf("%lld\n",res);
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 18944
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)

# def lcm(a,b): return a*b//gcd(a,b)

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(t, ans)
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 2e5 + 9;
// const ll m = 1e9 + 7;
const ll inf= 1ll<<62;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
const ll mod = 1e9+7;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll fk(ll n,ll k){
     ll a = (k*(k-1))/2;
     return a;
}
ll lk(ll n,ll k){
     ll a = (k*n) - fk(n,k);
     return a;
}
int main()
{   
     #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
     
     #endif                           
     ll T= 1;
     // cin>>T;
     ll ca = 1;
     while(T--){
          ll n,k;cin>>n>>k;
          ll ans= 0;
          for(int i = k;i<=n+1;i++){
               ans+=(lk(n,i) - fk(n,i) +1);
               ans%=mod;
          }
          cout<<ans<<'\n';
     }
    return 0;
}

Measured memory_bytes: 3624
export class Main {
  static main(input): string {
    const s: string = input.split("\n")[0];
    let count: number = 0;
    let result: number = 0;
    let boo: boolean = false;
    for (let i = 0, len = s.length; i < len; i++) {
      const t: string = s.charAt(i);
      if (t == "A" || t == "C" || t == "G" || t == "T") {
        if (boo) {
          count++;
        } else {
          boo = true;
          count = 1;
        }
      } else {
        if (boo) {
          boo = false;
          if (count > result) {
            result = count;
          }
        }
      }
    }
    if (boo) {
      boo = false;
      if (count > result) {
        result = count;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

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

using namespace std;

int main(int argc, char *argv[]) {
    int N, D;
    cin >> N >> D;

    int one = (D * 2) + 1;
    int ans = ceil(N / (one * 1.0));
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int N;
	int A;

	cin >> N;
	cin >> A;

	string ans = "No";

	for (int i = 0; i <= A; i++)
	{
		if ((N - i) % 500 == 0)
		{
			ans = "Yes";
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
int main(void){
    char c;
    
    while(fscanf(stdin,"%c",&c) != EOF){
        if('A' <= c && c <= 'Z'){
            c += 'a' - 'A';
            fprintf(stdout,"%c",c);
        }else if('a' <= c && c <= 'z'){
            c -= 'a' - 'A';
            fprintf(stdout,"%c",c);
        }else{
            fprintf(stdout,"%c",c);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}

void solve(){
	ll n;
	cin >> n;
	vll a(n);
	fi(n) cin >> a[i];
	ll x=0;
	fi(n) x=(x^a[i]);
	fi(n) cout << (x^a[i]) << " ";
	cout << endl;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 4780
#include<iostream>
using namespace std;
int main(){
    int A,B,h=100,w=100;
    char g[100][100];
    for(int i=0;i<h*w;i++)g[i/w][i%w]=(i<h*w/2?'#':'.');
    cin>>A>>B;
    cout<<"100 100"<<endl;
    for(int i=0;i<A-1;i++)g[2*(i/50)+1][2*(i%50)]='.';
    for(int i=0;i<B-1;i++)g[98-2*(i/50)][2*(i%50)]='#';
    for(int i=0;i<h*w;i++)cout<<g[i/w][i%w]<<(i%w+1==w?"\n":"");
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
len_F = sum(A)
min_F = 2020202021
sum_A = 0

for i in range(N):
    sum_A += A[i]
    len_F -= A[i]
    if(abs(sum_A - len_F) < min_F):
        min_F = abs(sum_A - len_F)
        
print(min_F)

Measured memory_bytes: 26224
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
	int a, b,c,d;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	int ans = min(a, b) + min(c,d);
	printf("%d\n",ans);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  ll d;
  ll sum = 0;
  ll sum2 = 0;
  REP(i,N){
    IN(d);
    sum += d;
    sum2 += d*d;
  }

  OUT((sum*sum-sum2)/2);

  return 0;
}

Measured memory_bytes: 256
N = int(input())
y = [0,1,2,3,4,5,6,7,8,9]
one = [1]
zero = [0]
p = [1,2,3,4,5,6,7,8,9]
q = [0,1,2]
a=N//1000
b=(N - (a * 1000))//100 
c=(N- (a*1000)-(b * 100))// 10
d=(N - (a*1000)-(b*100)-(c*10))

if ((a in one) and (b in q)or(a in zero) and (b in p))and((c in one) and (d in q)or(c in zero)and(d in p)):
  print('AMBIGUOUS')
elif (a in y )and(b in y)and((c in one) and (d in q) or (c in zero) and(d in p)):
  print('YYMM')
elif ((a in one )and(b in q))or((a in zero)and(b in p))and(c in y) and (d in y):
  print('MMYY')
else:
  print('NA')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

#define X first
#define Y second
#define N 210
#define M 11

typedef long long ll;
const int Mod=1000000007;
const int INF=1<<30;

char s[N];
int c[N],d[N];

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	for (int i='a';i<='z';i++) d[i]=1000;
	int n; scanf("%d",&n);
	while (n--)
	{
		scanf("%s",s);
		int len=strlen(s);
		memset(c,0,sizeof(c));
		for (int i=0;i<len;i++) c[s[i]]++;
		for (int i='a';i<='z';i++) d[i]=min(d[i],c[i]);
	}
	for (char c='a';c<='z';c++)
		for (int i=1;i<=d[c];i++)
			printf("%c",c);
	printf("\n");
	
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	
	int s=0,v=n;
	for(;v>0;){
		s+=v%10;
		v/=10;
	}
	
	if(n%s) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	return 0;
}


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

#define int long long

void solve() {
	int n;
	cin>>n;
	string str;
	cin>>str;
	for(auto &it:str) {
		if(it=='R') {
			it='1';
		} else if(it=='G') {
			it='2';
		} else if(it=='B') {
			it='3';
		}
	}
	int pre[n+1][4];
	memset(pre,0,sizeof(pre));
	for(int i=1;i<=n;i++) {
		pre[i][str[i-1]-'0']++;
		for(int j=1;j<=3;j++) {
			pre[i][j]+=pre[i-1][j];
		}
	}
	int ans=0;
	int mark[4];
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			if(str[i-1]==str[j-1]) {
				continue;
			}
			for(int k=1;k<=3;k++) mark[k]=0;
			mark[str[i-1]-'0']=mark[str[j-1]-'0']=1;
			int id;
			for(int k=1;k<=3;k++) {
				if(mark[k]==0) {
					id=k;	
				}
			}
			int midx=j+(j-i);
			if(midx>n) {
				int cnt=0;
				cnt+=pre[n][id]-pre[j][id];
				ans+=cnt;
			} else {
				int cnt=pre[midx-1][id]-pre[j][id];
				cnt+=pre[n][id]-pre[midx][id];
				ans+=cnt;
			}
		}
	}
	cout<<ans<<"\n";
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--) {
		solve();
	}
}

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

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

    int n = s.size();
    int ans = 0;
    int nextColor = abs((s[0] - '0') - 1);
    for (int i = 1; i < n; i++)
    {
        if (nextColor != (s[i] - '0'))
            ans++;
        nextColor = abs(nextColor - 1);
    }

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


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    ll n; cin >> n;
    ll ans = 0;
    ans = (n-1)*n/2;
    cout << ans<< '\n';
    return 0;
}

Measured memory_bytes: 256
N, P = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

dp = Array.new(N + 10) { Array.new(2, 0) }
dp[0][0] = 1
N.times do |i|
  a = A[i]
  dp[i + 1][0] = dp[i][0]
  dp[i + 1][1] = dp[i][1]
  if a.even?
    dp[i + 1][0] += dp[i][0]
    dp[i + 1][1] += dp[i][1]
  else
    dp[i + 1][1] += dp[i][0]
    dp[i + 1][0] += dp[i][1]
  end
end
puts dp[N][P]

Measured memory_bytes: 1788
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline

N, *A = map(int, read().split())
a = Counter(A)
s = sum(i * (i - 1) // 2 for i in a.values())

for i in A:
    v = a[i]
    answer = s - v * (v - 1) // 2 + (v - 1) * (v - 2) // 2
    print(answer)


Measured memory_bytes: 25932
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if ((a==1)&&(b==2))
        printf("3\n");
    else if ((a==2)&&(b==1))
        printf("3\n");
    else if ((a==3)&&(b==1))
        printf("2\n");
    else if ((a==1)&&(b==3))
        printf("2\n");
    else if ((a==2)&&(b==3))
        printf("1\n");
    else if ((a==3)&&(b==2))
        printf("1\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <functional>

int n;
int a, b, c;
int d[1001];

int main(){
	std::cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++)std::cin >> d[i];

	std::sort(d, d + n,std::greater<int>());

	int max = 0;
	for (int i = 0; i < n; i++){
		max = std::max(max, c / (a + b * i) );
		c += d[i];
	}

	std::cout << max << std::endl;

	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	set<char> st(all(s));
	if(st.size() == 26){
		int i = 25;
		while(i != 0 and s[i - 1] > s[i]){
			i--;
		}
		if(i == 0){
			cout << -1 << endl;
			return 0;
		}

		char c = 127;
		range(j,i,s.size()){
			if(s[i - 1] > s[j]) continue;
			c = min(c, s[j]);
		}
		cout << s.substr(0,i - 1) + c << endl;
	}else{
		char i = 'a';
		while(st.count(i)){
			i++;
		}
		cout << s + i << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int h1, h2, k1, k2, a, b, c, d, hp, kp;

	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;

	hp = (h1 / 10) * c + h1 * a + (h2 / 20) * d + h2 * b;
	kp = (k1 / 10) * c + k1 * a + (k2 / 20) * d + k2 * b;

	if (hp == kp)
	{
		cout << "even" << endl;
	}
	else
	{
		if (hp > kp)
		{
			cout << "hiroshi" << endl;
		}
		else
		{
			cout << "kenjiro" << endl;
		}
	}

    return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt(), c = scanner.nextInt(), total = 0;

		int[][] input = new int[r][c];
		int[] outputR = new int[r];
		int[] outputC = new int[c];

		for (int i = 0; i < r; i++)
			for (int i2 = 0; i2 < c; i2++)
				input[i][i2] = scanner.nextInt();

		for (int i = 0; i < r; i++) {
			for (int i2 = 0; i2 < c; i2++) {
				outputR[i] += input[i][i2];
				System.out.print(input[i][i2] + " ");
			}

			System.out.println(outputR[i]);
		}

		for (int i = 0; i < c; i++) {
			for (int i2 = 0; i2 < r; i2++)
				outputC[i] += input[i2][i];

			total += outputC[i];
			System.out.print(outputC[i] + " ");
		}

		System.out.println(total);
	}
}

Measured memory_bytes: 42048
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <map>
using namespace std;
#define LL long long
#define f(i,x,y) for (LL i=x;i<=y;i++)
#define ff(i,x,y) for (int i=x;i<y;i++)
#define fi first
#define se second 

const int N = 2e5+10;
LL x[5],y[5],mi,s;

int main(){
	cin>>s;
	if (s==(LL)1e18){
		cout<<"0 0 0 1000000000 1000000000 0"<<endl;
		return 0;
	}
	LL tmp = s/(LL)1e9;
	LL x2y1 = (tmp+1)*(LL)1e9-s;
	x[1] = 1e9;
	y[2] = tmp+1;
	x[2] = x2y1;
	y[1] = 1;
	cout<<"0 0 "<<x[1]<<" "<<y[1]<<" "<<x[2]<<" "<<y[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

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

  scanf("%d %d %d",&a,&b,&c);

  if (a==b+c || b==c+a || c==a+b) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

int main(){
    int N;cin>>N;
    int K[50];
    long long k;cin>>k;
    for(int i=0;i<50;i++){
        K[i]=k%2;
        k/=2;
    }
    vector<vector<long long>>A(100010,vector<long long>(50));
    vector<long long> S(50,0);
    for(int i=0;i<N;i++){
        long long a;cin>>a;
        for(int j=0;j<50;j++){
            A[i][j]=a%2;
            S[j]+=A[i][j];
            a/=2;
        }
    }
    bool same=true;
    long long ans[50];
    int i=49;
    long long sum=0;
    while(i>=0){
        if(same){
            if(K[i]==0){
                ans[i]=0;
                sum+=S[i]*(long long)pow(2,i);
            }
            else{
                if(S[i]>=N-S[i]){
                    ans[i]=0;
                    same=false;
                    sum+=S[i]*(long long)pow(2,i);
                }
                else{
                    ans[i]=1;
                    sum+=(N-S[i])*(long long)pow(2,i);
                }
            }
        }
        else{
            if(S[i]>=N-S[i]){
                ans[i]=0;
                sum+=S[i]*(long long)pow(2,i);
            }
            else{
                ans[i]=1;
                sum+=(N-S[i])*(long long)pow(2,i);
            }
        }
        i--;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j;
	string ret;
	vector<char> v;
	
	cin >> n;
	
	for ( i = 0; n > 0; i++ ) {
	    n--;
		v.push_back(n % 26 + 97);
	    n /= 26;
	}
	for ( i = v.size() - 1; i >= 0; i-- ) {
		cout << v[i];
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3652