akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int K;
char S[52];
int main(){
  rd(N);
  rd(K);
  rd(S);
  S[K-1] += 'a' - 'A';
  wt_L(S);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190526-1

// --- original code ---
// int N, K;
// char S[52];
// {
//   rd(N,K,S);
//   S[K-1] += 'a' - 'A';
//   wt(S);
// }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> vec(n+2);
    rep(i,n+1){
        reps(j,i+1,n){
            int tmp = min(abs(j-i),abs(x-i)+1+abs(j-y));
            tmp = min(tmp,abs(y-i)+1+abs(j-x));
            vec[tmp]++; 
        }
    }

    rep(i,n-1){
        cout << vec[i+1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B;
    cin >> A >> B;
    if(A + B >= 10) {
        cout << "error" << endl;
        return 0;
    }
    cout << A + B << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int[] v1 = { 0, 1, 0, -1 };
	static int[] v2 = { 1, 0, -1, 0 };
	static int[][] field;
	static int count = 0;

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while (true) {
			int w = cin.nextInt();
			int h = cin.nextInt();
			if(w+h==0){break;}
			
			int startx = 0, starty = 0;
			count=0;
			field = new int[h + 2][w + 2];
			for (int i = 1; i <= h; i++) {
				String str = cin.next();
				for (int j = 1; j <= w; j++) {
					if (str.charAt(j-1) == '.') {
						field[i][j] = 1;
					} else if (str.charAt(j-1) == '#') {
						field[i][j] = 2;
					} else if (str.charAt(j-1) == '@') {
						field[i][j] = 1;
						startx = i;
						starty = j;
					}
				}
			}
			bfs(startx, starty);
			System.out.println(count);
		}
	}

	static void bfs(int x, int y) {
		field[x][y] = 2;
		count++;
		for (int i = 0; i < 4; i++) {
			int xx = x + v1[i];
			int yy = y + v2[i];
			if (field[xx][yy] == 1) {
				

				bfs(xx, yy);
			}
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
const int N=666*666;
int n,d1,d2,vis[N],ans[N];
vector<int>e[N],qwq[4];
int hx(int a,int b){return a*n+b;}
void add(int a,int b){e[a].push_back(b),e[b].push_back(a);}
void dfs(int v,int f,int x){
	if(vis[v])return;vis[v]=1;if(x)ans[v]|=f;
	for(int i=0;i<(int)e[v].size();i++)dfs(e[v][i],f,x^1);
}
void solve(int d,int f){
	memset(vis,0,sizeof(vis));
	for(int i=0;i<n*n;i++)e[i].clear();
	for(int i=0;i*i<=d;i++){
		int j=sqrt(d-i*i);
		if(i*i+j*j==d){
			for(int x=0;x<n;x++)for(int y=0;y<n;y++){
				int X=x+i,Y=y+j;
				if(0<=X&&X<n&&0<=Y&&Y<n)add(hx(x,y),hx(X,Y));
				Y=y-j;
				if(0<=X&&X<n&&0<=Y&&Y<n)add(hx(x,y),hx(X,Y));
			}
		}
	}
	for(int i=0;i<n*n;i++)if(!vis[i])dfs(i,f,0);
}
int main(){
    scanf("%d%d%d",&n,&d1,&d2);n<<=1;
	solve(d1,1);
	solve(d2,2);
	//for(int i=0;i<n;i++){for(int j=0;j<n;j++)printf("%d ",ans[hx(i,j)]);printf("\n");}
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)qwq[ans[hx(i,j)]].push_back(hx(i,j));
	for(int i=0;i<4;i++)if((int)qwq[i].size()>=n*n/4){
		for(int j=0;j<n*n/4;j++)printf("%d %d\n",qwq[i][j]/n,qwq[i][j]%n);
		return 0;
	}
    return 0;
}

Measured memory_bytes: 86836
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;
 
struct edge {
    ll dst, cost;
    edge() {}
    edge(ll b, ll c) : dst(b), cost(c) {}
};

vector<edge> tree[100005];
int ans[100005];

// 頂点 0 を 0(白) と決める.
// 頂点 0 から dfs
// v: 今いる頂点, p: v の親
// f: 親の色
// cost: 直前のコスト
void dfs(ll v, ll p, ll f, ll cost) {
    if ( (f == 0 && (cost & 1) ) || (f == 1 && (cost % 2) == 0) ) {
        ans[v] = 1;
    } else {
        ans[v] = 0;
    }
    for (ll i = 0; i < tree[v].size(); i++) {
        edge e = tree[v][i];
        // 戻らないようにする処理
        if (e.dst == p) { continue; }
        dfs(e.dst, v, ans[v], e.cost);
    }
    return;
}

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

    for (int i = 0; i < n-1; i++) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        tree[u].push_back( edge(v, w) );
        tree[v].push_back( edge(u, w) );
    }

    dfs(0, -1, 0, 0);

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

    return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int a,b,c,k,count=0;
	cin>>a>>b>>c>>k;
	while(a>=b){
      b*=2;
      count++;
    }
	while(b>=c){
      c*=2;
      count++;
    }
  if(count<=k)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3636
s = input()[::-1]
counts = [0] * 2019
counts[0] = 1
digit = 1
sum = 0
for c in s:
  sum = (sum + int(c) * digit) % 2019
  digit = digit * 10 % 2019
  counts[sum] += 1
 
result = 0
for c in counts:
  result += c * (c - 1) // 2
 
print(result)

Measured memory_bytes: 9384
#include <iostream>

using namespace std;

int main() {
    int N;
    int num[100001];
    char check[100001] = { 0 };
    int start;

    cin >> N;
    for (int i=1; i<=N; i++) {
        cin >> num[i];
    }

    int p = 1, cont = 0;
    while (1) {
        if (p == 2) {
            cout << cont << endl;;
            break;
        }
        if (check[p] == 1) {
            cout << "-1" << endl;
            break;
        }
        
        check[p] = 1;
        p = num[p];
        cont++;
    }

    return 0;
}

Measured memory_bytes: 768
import bisect

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

bl = [bisect.bisect_left(A, b) for b in B]
for i in range(1, N):
    bl[i] += bl[i-1]
cl = [bisect.bisect_left(B, c) for c in C]

ans = 0
for c in cl:
    if c < 1:
        continue
    ans += bl[c-1]
print(ans)


Measured memory_bytes: 24500
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int cmp(const void *a,const void* b){
  return strcmp((char *)a,(char *)b);
}

int main(void){

char s[4];
int i;

scanf("%s",s);

qsort(s,4,sizeof(char),cmp);
if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
printf("Yes");
else
printf("No");




return 0;
}


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

int main() {
  int64_t P,x,y,Q=1000000007,Z=0;
  cin>>P>>x>>y;
  int64_t N=P; //ここから
       int64_t a=1,b=0,c=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=2;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      } //ここまで
  Z+=c;
  int64_t A=P,B=x,C=1;//A、Bを入れる
      for(int j=1;j<=B;j++){
        C=(C*(A+1-j))%Q;
        int64_t N=Q-2;
       int64_t a=1,b=0,c=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=j;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      }
        C=(C*c)%Q;
      }//ここまで
  Z=(Z+Q-C)%Q;
   A=P,B=y,C=1;//A、Bを入れる
      for(int j=1;j<=B;j++){
        C=(C*(A+1-j))%Q;
        int64_t N=Q-2;
       int64_t a=1,b=0,c=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=j;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      }
        C=(C*c)%Q;
      }//ここまで
  Z=(Z+Q-C-1)%Q;
  cout<<Z<<endl;
}

Measured memory_bytes: 384
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i, N) {
        cin >> A[i];
        cin >> B[i];
    }
    ll sum = 0;
    for(ll i = N-1; i >= 0; --i) {
        if ((A[i] + sum) % B[i] != 0 ) sum += B[i] - (A[i] + sum) % B[i];
    }
    print(sum);
    return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

def main():
    X, Y = map(int, input().split())
    tmp = X * 4 - Y
    if tmp%2 != 0:
        print("No")
        return
    turu = tmp // 2
    kame = X - turu
    if turu >= 0 and kame >= 0:
        print("Yes")
        return
    print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

void display(vector<int> ary) {
  for (int i = 0; i < ary.size(); i++) {
    if (i > 0) cout << " ";
    cout << ary[i];
  }

  cout << endl;
}

void bubble_sort_and_display(vector<int> ary) {
  int count = 0;
  bool flag = true;

  for (int i = 0; flag; i++) {
    flag = false;
    for (int j = ary.size() - 1; j > i; j--) {
      if (ary[j] < ary[j - 1]) {
        swap(ary[j], ary[j - 1]);
        flag = true;
        count++;
      }
    }
  }

  display(ary);
  cout << count << endl;
}

int main(void) {
  int len;
  vector<int> ary;
  char s[200];

  cin >> len;

  for (int i = 0; i < len; i++) {
    cin >> s;
    ary.push_back(atoi(s));
  }

  bubble_sort_and_display(ary);

  return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;
int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
	//ll n, m, h, w;
	//cin >> x;
	//string s, t;
	ll x[100005];
	ll y[100005];
	cin >> a;
	for (ll i = 0; i < a; i++)
	{
		cin >> x[i];
	}
	ll g = 0;
	y[0] = 1;
	c = -1;
	for (ll i = 1; i < a-1; i++)
	{
		y[i] = c * 2;
		c *= -1;
	}
	y[a - 1] = c;
	sort(x, x + a);
	sort(y, y + a);
	for (ll i = 0; i < a; i++)
	{
		b += x[i] * y[i];
	}
	
	y[0] = -1;
	c = 1;
	for (ll i = 1; i < a - 1; i++)
	{
		y[i] = c * 2;
		c *= -1;
	}
	y[a - 1] = c;
//	sort(x, x + a);
	sort(y, y + a);
	for (ll i = 0; i < a; i++)
	{
		d += x[i] * y[i];
	}

	//cout << abs(x[0] - x[a / 2]) << endl;
	cout <<max(b,d) << endl;


	//cout << sum << endl;
	//cout <<  endl;
	return 0;
}

//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}




//
//ll insuusyurui[1000] = {};
//ll insuukazu[1000] = {};
//ll memo[4000] = {};
//ll memo2[4000] = {};
//cin >> n;
//cin >> m;
//a = 2;
//// √n ≧ a ( n ≧ a * a ) の間ループ処理
//while (n >= a * a) {
//	// a で割り切れたら、a は素因数
//	// そして、割られる数を a で割る
//	// a で割り切れなかったら、 a を 1 増加させる
//	if (n % a == 0) {
//		printf("%lld * ", a);
//		insuukazu[c]++;
//		n /= a;
//	}
//	else {
//		a++;
//		//if (insuukazu[c] != 0)
//		{
//			c++;
//			//cout << c << endl;
//
//		}
//	}
//}
//printf("%lld\n", n);
//for (int i = 0; i < c; i++)
//{
//	//cout << insuukazu[i] << endl;
//}
//
//cout << "Yes" << endl;












//ll n, m;
//cin >> n;
//cin >> m;
//cin >> s;
//cin >> t;
//ll i;
//c = n;
//d = m;
//if (c<d)
//{
//	swap(c, d);
//}
//i = c % d;
//while (i != 0) {
//	c = d;
//	d = i;
//	i = c % d;
//}
//i = n*m / d;

//a = min(n, m);
//b = -1;
//for (ll z = 0; z < i; z++)
//{
//	if (z%m == 0&&z%n==0)
//	{
//		if (s[z / n] != t[z / m])
//		{
//			cout << -1 << endl;
//			return 0;
//		}
//	}


//	z += a;
//	z--;
//	/*
//	if (z % (i / n) == 0)
//	{
//	a++;
//	}
//	if (z % (i / m) == 0)
//	{
//	b++;
//	}
//	if (z % (i / n) == z % (i / m))
//	{
//	if (s[a] != t[b])
//	{
//	cout << -1 << endl;
//	return 0;
//	}
//	}
//	*/
//}


Measured memory_bytes: 1792
import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


def main():
	a=input()
	ans="No"
	
	for i in range(3):
		if a[i]==str(7):
			ans="Yes"
	
	print(ans)
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 9136
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end
N, a_list = gets_n_and_i_list

a_list.sort!

def xxx(arr)
  loop do
    return arr[0] if arr.length == 1
    arr = arr.each_slice(2).map { |a, b| b ? a * b : a }
  end
end

total = xxx(a_list)

if total > 10**18
  puts -1
else
  puts total
end

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

int main(){

    long long a, b, c, d; cin >> a >> b >> c>> d;
    long long M;

    M = b*d;

    if(a*c > M){
        M = a*c;
    }
    if(a*d > M){
        M = a*d;
    }
    if(b*c > M){
        M = b*c;
    }

    cout << M << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

struct edge { long long to, cost;};
typedef pair<long long, long long> P_dij;

/* params
 * @s -> start, n -> 要素数, G -> グラフ, d -> 結果(参照渡し)
*/
void dijkstra(const long long s, const long long n,
  vector< vector<edge> > const &G, vector<long long> & d){
  d.resize(n);
  for(int i=0; i<n; i++) d[i] = INF; 
  priority_queue<P_dij, vector<P_dij>, greater<P_dij>> que;
  d[s] = 0;
  que.push(P_dij(0, s));
  while (!que.empty()) {
    P_dij p = que.top();
    que.pop();
    long long v = p.second;
    if(d[v] < p.first)continue;
    for(int i=0;i<G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P_dij(d[e.to], e.to));
      }
    }
  }
}

/* END END END */
int main() {
  int n;
  cin >> n;
  vector<vector<edge>> G(n+1);
  
  int a,b;
  rep(i, n-1) {
    cin >> a >> b;
    G[a].push_back({b, 1});
    G[b].push_back({a, 1});
  }

  vector<ll> d1, d2;
  dijkstra(1, n+1, G, d1);
  dijkstra(n, n+1, G, d2);

  int cntf = 0, cnts = 0;
  for (int i = 1; i <= n; ++i) {
    if (d1[i] < d2[i]) cntf += 1;
    else if (d1[i] == d2[i]) cntf += 1;
    else cnts += 1;
  }

  if (cnts > cntf or cnts == cntf) {
    cout << "Snuke" << endl;
  } else {
    cout << "Fennec" << endl;
  }
}


Measured memory_bytes: 9744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    string s;
    cin >> s;
	
  	int ans = 0;
  	for(int i=0; i<4; i++){
		if(s[i] == '+'){
			ans++;
        }
      	else{
			ans--;
        }
    }
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, a, b, c = map(int, input().split())
S = []
T = []
r = 0
for i in range(n):
    S.append(input())
for i in range(n):
    if S[i] == "AB":
        if a < b:
            a += 1
            b -= 1
            T.append("A")
        elif a > b:
            a -= 1
            b += 1
            T.append("B")
        else:
            if i < n-1:
                if S[i+1] == "AC":
                    a += 1
                    b -= 1
                    T.append("A")
                else:
                    a -= 1
                    b += 1
                    T.append("B")
            else:
                a += 1
                b -= 1
                T.append("A")
    elif S[i] == "AC":
        if a < c:
            a += 1
            c -= 1
            T.append("A")
        elif a > c:
            a -= 1
            c += 1
            T.append("C")
        else:
            if i < n-1:
                if S[i+1] == "AB":
                    a += 1
                    c -= 1
                    T.append("A")
                else:
                    a -= 1
                    c += 1
                    T.append("C")
            else:
                a += 1
                c -= 1
                T.append("A")
    else:
        if b < c:
            b += 1
            c -= 1
            T.append("B")
        elif b > c:
            b -= 1
            c += 1
            T.append("C")
        else:
            if i < n-1:
                if S[i+1] == "AB":
                    b += 1
                    c -= 1
                    T.append("B")
                else:
                    b -= 1
                    c += 1
                    T.append("C")
            else:
                b += 1
                c -= 1
                T.append("B")
    if a < 0 or b < 0 or c < 0:
        r = 1
        break;
if r == 0:
    print("Yes")
    for i in range(n):
        print(T[i])
else:
    print("No")

Measured memory_bytes: 17112
#include <bits/stdc++.h>
#define y second
#define x first
#define lsb(x) (x&-x)
#define pb push_back
#define y second
const int NMAX=2666; //LOL
const int MOD=1000000007; //LOL
const int SQRT=350;
using namespace std;
const int INF=1000000007;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const int dx[]={-1, 0, 0, 1};
const int dy[]={0, 1, -1, 0};

bool A[505][505], blue[505][505], red[505][505];

int main()
{
	//freopen("input.in", "rt", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
		{
			char c;
			cin>>c;
			if(c=='#')
				A[i][j]=1;
		}
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m-1; ++j)
			if(i&1)
				red[i][j]=1;
	for(int i=1; i<=n; ++i)
		red[i][1]=1;
	for(int i=1; i<=n; ++i)
		for(int j=2; j<=m; ++j)
			if((i&1)==0)
				blue[i][j]=1;
	for(int i=1; i<=n; ++i)
		blue[i][m]=1;
	
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
		{
			if(A[i][j])
			{
				if(i&1)
					blue[i][j]=1;
				else
					red[i][j]=1;
			}
		}
	for(int i=1; i<=n; ++i,cout<<"\n")
		for(int j=1; j<=m; ++j)
			if(red[i][j])
				cout<<"#";
			else
				cout<<".";
	cout<<"\n";
	for(int i=1; i<=n; ++i,cout<<"\n")
		for(int j=1; j<=m; ++j)
			if(blue[i][j])
				cout<<"#";
			else
				cout<<".";
	
	return 0;
} 









Measured memory_bytes: 1536
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,M=pin()
    A=sorted([lispin() for _ in range(N)])
    #print(A)
    ans=0
    for a in A:
        if a[1]>M:
            ans+=a[0]*M
            break
        else:
            ans+=a[0]*a[1]
            M-=a[1]
        #print(M)
    print(ans)
#%%submit!
resolve()


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

double res = 0;
double P;

double E(int64 x){
	double num = 1/P;
	return num*x/2;
}

int main(void){
	int64 x;
	cin >> x >> P;
	P /= 100;
	if(x%2){
		res = 1;
		res += E(x-1)*P;
		res += E(x+1)*(1-P);
	}else{
		res += E(x);
	}
	cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000000
# define mm 1000000007
# define pi acos(-1)
# define fi first
# define se second

using namespace std;

signed main()
{
    gok

       int r;
       cin>>r;
       cout<<fixed<<setprecision(10)<<2*pi*r;



















      return 0;
    }


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

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

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <string>
#include <set>
#include <functional>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <queue>
#define INF 10000
typedef pair<int,int> p;
typedef pair<p,p> pp;
int dp[51][51][51][51],stx,sty,skx,sky,X,Y;
int dx[]={-1,0,0,1};
int dy[]={0,-1,1,0};
bool map[51][51];
class state{
public:
	int tx,ty,kx,ky;
	state(){}
	void inp(int tx_,int ty_,int kx_,int ky_){
		tx=tx_;
		ty=ty_;
		kx=kx_;
		ky=ky_;
		return;
	}
	void fix(int X,int Y){
		if(tx<1)tx=1;
		else if(X<tx)tx=X;
		if(ty<1)ty=1;
		else if(Y<ty)ty=Y;
		if(kx<1)kx=1;
		else if(X<kx)kx=X;
		if(ky<1)ky=1;
		else if(Y<ky)ky=Y;
		return;
	}
	void show(){
		//printf("dp[%d][%d][%d][%d]:%d\n",tx,ty,kx,ky,dp[tx][ty][kx][ky]);
		return;
	}
};
queue<state> task;
int bfs();
int main()
{
	while(cin>>X>>Y&&(X||Y)){
		fill(dp[0][0][0],dp[51][0][0],INF);
		cin>>stx>>sty>>skx>>sky;
		for(int y=1;y<=Y;y++)
			for(int x=1;x<=X;x++)cin>>map[x][y];
		int ans=bfs();
		if(ans==-1)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
    return 0;
}
int bfs(){
	while(!task.empty())task.pop();
	state s;s.inp(stx,sty,skx,sky);task.push(s);
	dp[stx][sty][skx][sky]=0;
	while(!task.empty()){
		state t=task.front();task.pop();
		t.show();
		if(t.tx==t.kx&&t.ty==t.ky)return dp[t.tx][t.ty][t.kx][t.ky];
		if(dp[t.tx][t.ty][t.kx][t.ky]>=100)return -1;
		for(int i=0;i<4;i++){
			int ttx=t.tx+dx[i];
			int tty=t.ty+dy[i];
			int tkx=t.kx-dx[i];
			int tky=t.ky-dy[i];
			state a;a.inp(ttx,tty,tkx,tky);
			a.fix(X,Y);
			if(map[a.tx][a.ty]){a.tx=t.tx;a.ty=t.ty;}
			if(map[a.kx][a.ky]){a.kx=t.kx;a.ky=t.ky;}
			if(dp[a.tx][a.ty][a.kx][a.ky]==INF){
				dp[a.tx][a.ty][a.kx][a.ky]=dp[t.tx][t.ty][t.kx][t.ky]+1;
				task.push(a);
				a.show();
			}
		}
	}
	return -1;
}

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

char buf[100];
int main() {
	int q; cin >> q;
	rep(i, q) {
		ll s; scanf("%llx", &s);
		string t = bitset<32>(s).to_string();
		string a = t.substr(1, 24);
		int b = 0, p = 1;
		for (int i = a.size() - 1; i >= 0; i--) {
			b += p*(a[i] - '0'); p *= 2;
		}
		double d = 0, y = 0.5;
		string c = t.substr(25);
		rep(i, c.size()) {
			d += y*(c[i] - '0'); y /= 2;
		}
		double ans = b + d;
		if (t.front() == '1')ans = -ans;
		sprintf(buf, "%.10lf", ans);
		string u = buf;
		while (u.back() == '0')u.pop_back();
		if (u.back() == '.')u.pop_back();
		if ((int)u.find('.') == -1)u += ".0";
		cout << u << endl;
	}
}

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String input = null;

        try {
            while ((input = in.readLine()) != null) {

                System.out
                        .println(conbinationInteger(Integer.valueOf(input), 4));

            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static int conbinationInteger(int data, int stair) {

        // 合計が最大値以上ならば解なし
        if (data > stair * 9) {
            return 0;

            // 最後の1段目ならば解1パターン
        } else if (stair == 1) {
            return 1;
        }

        int result = 0;

        // 9or現在値分ループ
        for (int i = data < 9 ? data : 9; i >= 0; i--) {

            int answer = conbinationInteger(data - i, stair - 1);

            // 現在処理中の値が解なしならば以降全て解なしのため、打ち切り
            if (answer == 0) {
                break;
            }

            result += answer;
        }

        return result;
    }
}

Measured memory_bytes: 18656
n,m = map(int,input().split())

la = []

for i in range(n):
    a,b = map(int,input().split())
    la.append([a,b])

la.sort(key=lambda x:x[0])

ans = 0
ind = 0
#print(la)

while m > 0:
    if la[ind][1] == 0:
        ind += 1
    else:
        ans += la[ind][0]
        m -= 1
        la[ind][1]  -= 1
        #print(ans)

print(ans)


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for(auto &c : s)
    {
        if(c == '?') c = 'D';
    }
    cout << s << '\n';

    return 0;
}


Measured memory_bytes: 3728
# https://onlinejudge.u-aizu.ac.jp/beta/room.html#ACPC2018Day3/problems/C

import collections

n = int(input().rstrip())

g = [[] for i in range(n)]
deg = [0 for i in range(n)]


for i in range(n):
    u, v = map(lambda x: x-1, map(int, input().rstrip().split(' ')))
    g[u].append(v)
    g[v].append(u)
    deg[u] += 1
    deg[v] += 1

q = collections.deque()

for i in range(n):
    if deg[i] == 1:
        q.append(i)

isPushed = [False for i in range(n)]

while len(q) > 0:
    v = q.popleft()
    isPushed[v] = True
    for nv in g[v]:
        deg[nv] -= 1

        if deg[nv] == 1:
            q.append(nv)

q = int(input().rstrip())

for _ in range(q):
    a, b = map(lambda x: x-1, map(int, input().rstrip().split(' ')))
    if isPushed[a] or isPushed[b]:
        print(1)
    else:
        print(2)



Measured memory_bytes: 24256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
using namespace std;
int main(){
    int a,b,n;
    std::cin >> n;
    if(n==1)std::cout << "Hello World" << std::endl;
    else {std::cin >>a >>b;std::cout << a+b << std::endl;}
}



Measured memory_bytes: 256
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int m = nextInt();


    int ok = 0;
    int nok = 0;

    boolean[] memo = new boolean[n+1];
    int[] wa = new int[n+1];

    Arrays.fill(memo,false);

    int[] p = new int[m];
    String[] s = new String[m];

    for(int i=0;i<m;i++){
      p[i] = nextInt();
      s[i] = next();

      if(!memo[p[i]] && s[i].equals("WA")){ //まだ正解してない
        wa[p[i]] ++;
      }
      else if(!memo[p[i]] && s[i].equals("AC")){ //今正解した
        nok += wa[p[i]];
        memo[p[i]] = true;
        ok ++;
      }
    }



    System.out.println(ok+" "+nok);

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 65500
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b)
{
	ll res = 1;
	a %= mod;
	assert(b >= 0);
	for (; b; b >>= 1)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin>>n;
	bool fg = false;
	while(n) {
		if(n%10==7) {
			fg=true;
			break;
		}
		n/=10;
	}
	if(fg) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3652
program atcoder
  implicit none
  real K, A, B, X, Y
  read *, K
  read *, A, B
  X=int(B/K)
  Y=int(A/K)
   if (X-Y >= 1) then
    print *, 'OK'
   else if (Y-A/K >= 0) then
    print *, 'OK'
   else 
    print *, 'NG'
   end if
  end program atcoder

Measured memory_bytes: 2892
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const int INF = int(1e9);

int main()
{
    string t = "YAKI";
    char s[1000];
    cin>>s;
    int ti = 0;
    for(int i = 0;i<4;i++){
        if(s[i]==t[ti])
            ti++;
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

   return 0;
}


Measured memory_bytes: 256
import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    M = list(map(int, input().split()))

    num = set()
    for pattern in product([0, 1], repeat=n):
        total = 0
        for idx, p in enumerate(pattern):
            if p == 1:
                total += A[idx]
        num.add(total)

    for m in M:
        print("yes" if m in num else "no")


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 5704
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int r, D, x2000;
    cin >> r >> D >> x2000;

    int result { x2000 };
    for (int i { 0 }; i < 10; ++i) {
        result = result * r - D;
        cout << result << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 10000000000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
using itpl = tuple<ll,ll>;

int main(){
    ll N;
    cin >> N;
    vector<ll>A(N,0),B(N,0),C(N,0);
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) cin >> B[i];
    rep(i,0,N) cin >> C[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    
    vector<ll> BCcounts(N,0);
    for(ll i=N-1;i>=0;i--){
        auto itr = lower_bound(C.begin(),C.end(),B[i]+1);
        BCcounts[i] = distance(itr,C.end());
        if(i!=N-1) BCcounts[i] += BCcounts[i+1];
    }

    ll ans = 0;
    for(ll i=0;i<N;i++){
        auto itr = lower_bound(B.begin(),B.end(),A[i]+1);
        if(itr == B.end()) break;
        ans += BCcounts[distance(B.begin(),itr)];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
	unsigned long long n;
	cin>>n;
	long long sum=100;
	int ans=0;
	do{
		ans++;
		sum*=1.01;
		if(sum>=n){
			cout<<ans<<endl;
			return 0;
		}
	}while(1);
	return 0;
}

Measured memory_bytes: 3588
import java.util.*;


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();
      System.out.println((a+b==c||a+c==b||a==b+c)?"Yes":"No");
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
const int INF = (1 << 26);

int main(){
    int n;
    while(cin >>n && n){
        int ans = 1, T = 1, S = 2, E = 3;
        rep(i, n){
            string str; cin >>str;
            if(str == "North"){
                swap(T, S);
                S = 7 - S;
            } else if(str == "East"){
                swap(T, E);
                T = 7 - T;
            } else if(str == "West"){
                swap(T, E);
                E = 7 - E;
            } else if(str == "South"){
                swap(T, S);
                T = 7 - T;
            } else if(str == "Right"){
                swap(E, S);
                E = 7 - E;
            } else if(str == "Left"){
                swap(E, S);
                S = 7 - S;
            }
            ans += T;
        }
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
 
int main(){
int N;
int pro1 , pro2 , pro3;
  
  scanf("%d" , &N);
 
	pro3 = N % 10;
	pro2 = (N % 100 - pro3)/10;
	pro1 = (N - pro2)/100;
 
if ((pro1==7)||(pro2==7)||(pro3==7))	printf("Yes\n");
else printf("No\n");
 
return 0 ;
 
}

Measured memory_bytes: 1644
#include<stdio.h>
 
int main(void)
{
    int n, m, l;
    int i, j,k;
    int A[100][100] = { 0 }, B[100][100] = {0};
    long long C[100][100] = { 0 };
    scanf("%d %d %d", &n, &m,&l);
    for (i = 0;  i< n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", &A[i][j]);
        }
    }
    for (i = 0; i< m; i++)
    {
        for (j = 0; j < l; j++)
        {
            scanf("%d", &B[i][j]);
        }
    }
    for (i = 0; i< n; i++)
    {
        for (j = 0; j < l; j++)
        {
            for (k = 0; k < m; k++)
            {
                C[i][j] = C[i][j] + A[i][k] * B[k][j];
            }
            printf("%lld", C[i][j]);
            if (j != l - 1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,i,count[2];
  long a[100005];
  char str[1000005],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a[0]=atoi(p);
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
    a[i]=atoi(p);
  }
  for(i=0,count[0]=0,count[1]=0;i<N;i++){
    if(a[i]%4==0){
      count[0]++; 
    }
    if(a[i]%4!=0 && a[i]%2!=0){
      count[1]++; 
    }
  }
  
  if(N%2==1 && count[1]==N/2+1){
    if(count[0]>=N/2){
      printf("Yes\n"); 
      return 0;
    }else{
      printf("No\n"); 
      return 0;
    }
  }
  if(count[0]>=count[1]){
    printf("Yes\n");
    return 0;
  }else{
    printf("No\n");
    return 0;
  }
  
 return 0; 
}

Measured memory_bytes: 1920
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    xy = [tuple(map(int, input().split())) for _ in range(N)]
    def dist(xy1,xy2): return ((xy1[0]-xy2[0])**2 + (xy1[1]-xy2[1])**2)**0.5
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            ans += dist(xy[i],xy[j])
    print(ans*2/N)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    string a, b; cin >> a >> b;
    if (a.size() > b.size()) {
        cout << "GREATER" << endl;
    } else if (a.size() < b.size()) {
        cout << "LESS" << endl;
    } else {
        for (int i = 0; i < a.size(); i++) {
            if (a[i] > b[i]) {
                cout << "GREATER" << endl;
                return 0;
            } else if (a[i] < b[i]) {
                cout << "LESS" << endl;
                return 0;
            }
        }

        cout << "EQUAL" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
string a;
int w,e,n,s;
inline bool zdy(){
    if(w==1&&e==1&&n==1&&s==1)return 1;
    if(w==1&&e==1&&n==0&&s==0)return 1;
    if(w==0&&e==0&&n==1&&s==1)return 1;
    if(w==0&&e==0&&n==0&&s==0)return 1;
    return 0;
}
int main(void){
	cin>>a;
	int b=a.size();
	for(int i=0;i<b;++i){
		if(a[i]=='W') w=1;
		else if(a[i]=='E') e=1;
		else if(a[i]=='N') n=1;
		else if(a[i]=='S') s=1;
	}
	if(zdy()==1){
		cout<<"Yes"<<endl;
		return 0;
	}else{
		cout<<"No"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 384
n = int(input())

h = [int(i) for i in input().split()]

left = h[0]

for i in range(1, n):
    if left < h[i]:
        h[i] -= 1
    elif left == h[i]:
        pass
    else:
        print('No')
        exit()
    left = h[i]

print('Yes')


Measured memory_bytes: 14396
#include<cstdio>
#include<cstring>
#include<algorithm>
#define REP(i,a,n) for(int i = a;i < n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int field[4002][4002];
int main(void){
   char a[4002],b[4002];
   while(scanf("%s",a+1) != EOF){
      scanf("%s",b+1);
      int ma = 0;
      REP(i,1,4001) field[i][1] = field[1][i] = 0;
      a[0] = '0'; b[0] = '1';
      int as = strlen(a),bs = strlen(b);
      REP(i,1,as){
         REP(j,1,bs){
            if(a[i] == b[j]){
               field[i][j] = field[i-1][j-1]+1;
               ma = max(ma,field[i][j]);
            }
            else field[i][j] = 0;
         }
      }
      printf("%d\n",ma);
   }
   return 0;
}

Measured memory_bytes: 63508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    i64 n;
    cin >> n;
    i64 ans = 0;
    for (i64 i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
import collections
N = int(input())
A = [int(_) for _ in input().split()]
dp = collections.defaultdict(int)
dp[0] = 1
ans = 0
for a in A:
    dp_new = collections.defaultdict(int)
    dp_new[0] = 1
    for b in dp:
        if a & b == 0:
            dp_new[a + b] += dp[b]
            ans += dp[b]
    dp = dp_new
print(ans)


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

bool isConsistent(vector<int> &a, int N) {
  sort(a.begin(), a.end());
  if(a[N-1] - a[0] > 1) return false;
  if(a[0] == a[N-1]) {
    return a[0] == N - 1 || (1 <= a[0] && a[0] <= N/2);
  } else {
    int i = 0;
    while(a[i] == a[0]) i++;
    return i <= a[0] && a[0] <= i - 1 + (N-i)/2;
  }
}

int main () {
  int N;
  scanf("%d", &N);
  vector<int> a(N, 0);
  rep(i,N) scanf("%d", &a[i]);

  printf(isConsistent(a, N) ? "Yes\n" : "No\n");
  return 0;
}


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

int main(){
  double w,h,x,y;
  cin >> w >> h >> x >>y;
  double wd,hd,answer;
  wd = w;
  hd = h;
  answer = wd * hd / 2.0;
  cout << setprecision(9) << answer;
    if(x == w/2.0 && y == h / 2.0)
      cout << " 1" << endl;
      else
        cout << " 0" << endl;
    
    
    
}
             
            
          
      
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,sm=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        {
            sm+=i;
        }
    }

    cout<<sm<<endl;









    return 0;
}


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

int N, W, D, p, s, w, d;

struct cake {
	int S;
	int w;
	int d;
};

int main() {
	cin >> N >> W >> D;
	while (N + W + D) {
		vector<cake> A = {};
		vector<int> ans = {};
		cake c;
		c.w = W;
		c.d = D;
		c.S = W * D;
		
		A.push_back(c);
		
		for (int n = 0; n < N; n ++){
			cin >> p >> s;
			c = A[p - 1];
			d = c.d;
			w = c.w;
			cake c2, c3;
			while (s > d + w) s -= d + w;
			if (s < w) {
				c2.d = d;
				c3.d = d;
				c2.w = min(s, w - s);
				c3.w = max(s, w - s);
			} else  {
				s -= w;
				c2.d = min(s, d - s);
				c3.d = max(d - s, s);
				c2.w = w;
				c3.w = w;
			}
			A.erase(A.begin() + p - 1);
			c2.S = c2.d * c2.w;
			c3.S = c3.d * c3.w;
			//cout << "(" << c2.d << "," << c2.w << "," << c2.S << ")" << endl; 
			//cout << "(" << c3.d << "," << c3.w << "," << c3.S << ")" << endl;
			A.push_back(c2);
			A.push_back(c3);
		}
		
		for (auto a: A) {
			if (a.S > 0) {
				ans.push_back(a.S);
			}
		}
		sort(ans.begin(), ans.end());
		for (int i = 0; i < ans.size(); i++) {
			printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
		}
		
		cin >> N >> W >> D;
	}
}


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

struct restaurant
{
    string city;
    int point;
    int num;
};

int main(void){
    int N;
    cin >> N;
    vector<restaurant> rest;
    for (int i = 0; i < N; i++){
        restaurant foo;
        cin >> foo.city >> foo.point;
        foo.num = i + 1;
        rest.push_back(foo);
    }
    sort(rest.begin(), rest.end(),
    [](const restaurant& x, const restaurant& y) { return x.point > y.point;});
    stable_sort(rest.begin(), rest.end(),
    [](const restaurant& x, const restaurant& y) { return x.city < y.city;});
    for (auto itr : rest){
        cout << itr.num << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
long long a[n],cnt=0;
for (int i =0;i < n;i++){
     cin >> a[i];
    // cout << a[i] << endl;

}
for (int i = 0;i < n;i++){
        
        while(i+1 < n && a[i]==a[i+1]) ++i;

        if(i+1<n && a[i] < a[i + 1]){
            while(i+1 < n && a[i] <= a[i+1]) ++i;
        }

        else if(i+1 < n && a[i] > a[i+1]){
            while(i+1 < n && a[i] >= a[i+1]) ++i;
        }
        ++cnt; 
}
    cout << cnt << endl;
}


Measured memory_bytes: 1024