akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int main() {
  int x,y;
  cin>>x>>y;
  vector<int>gro1={1,3,5,7,8,10,12};
  vector<int>gro2={4,6,9,11};
  int X=0;
  int Y=0;
  for(int i=0;i<7;i++) {
    if(gro1.at(i)==x) {
      X++;
    }
    else if(gro1.at(i)==y) {
      Y++;
    }
  }
  for(int i=0;i<4;i++) {
    if(gro2.at(i)==x) {
      X+=2;
    }
    else if(gro2.at(i)==y) {
      Y+=2;
    }
  }
  if(x==2) {
    X+=3;
  }
  else if(y==2) {
    Y+=3;
  }
  if(X==Y) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int dist[20];
vector<tuple<int,int,int>> E;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int L, m=20, c, a, b, w;
	cin>>L;
	for(int i=18;i>0;i--) {
		if(((1<<(18-i))|dist[i+1])>=L) break;
		dist[m=i]=(1<<(18-i))|dist[i+1];
		E.emplace_back(i+1,i+2,0);
		E.emplace_back(i+1,i+2,1<<(18-i));
	}
	E.emplace_back(1,m+1,0);
	c=dist[m]+1;
	for(int i=m;i<20;i++) if(dist[i]+c<L) {
		E.emplace_back(1,i+1,c);
		c+=dist[i--]+1;
	}
	cout<<20<<' '<<E.size()<<'\n';
	for(auto e: E) {
		tie(a,b,w)=e;
		cout<<a<<' '<<b<<' '<<w<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200010,mod=1000000007;
int n,a[N],f[N],s[N];

inline int pls(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline int upd(int &a,int b){return a=pls(a,b);}

int main()
{
	n=rd();fo(i,1,n)a[i]=rd();
	f[0]=1;
	fo(i,1,n){
		f[i]=f[i-1];
		if(i>1&&a[i-1]!=a[i])upd(f[i],s[a[i]]);
		s[a[i]]=f[i];
	}
	printf("%d\n",f[n]);
	return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a = 1;
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        a = min(a * 2, a + k);
    }
    cout << a;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

main()
{
    fast;
    ll n,m;
    cin>>n>>m;
    if (n==m/2)
        cout<<n<<endl;
    else if (n<m/2)
    {
        m-=2*n;
        cout<<n+m/4<<endl;
    }
    else
        cout<<m/2<<endl;
}

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

int main() {
	int group[13] = { 100, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	int x, y;
	cin >> x >> y;
	if (group[x] == group[y]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import fractions

N,X = map(int,input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
y = [0]*N
for i in range(N):
    y[i] = x[i+1]-x[i]

if len(y) == 1:
    print(y[0])
else:
    answer = fractions.gcd(y[0],y[1])
    for i in range(2,N):
        answer = fractions.gcd(answer,y[i])
    print(answer)


Measured memory_bytes: 16300
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   { 
     string s,t;
     cin>>s>>t;
     ll i,n=s.length(),ans=0;
     for(i=0;i<n;i++)
       if(s[i]!=t[i])
         ans++;
     cout<<ans; 
   }
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(i, n) for(int i = n-1; i >= 0; i--)
#define loop(i, a, b) for(int i = a; i <= b; i++)
#define rloop(i, a, b) for(int i = a; i >= b; i--)
#define mem(a, val) memset(a, val, sizeof a);
#define test int t; cin>> t; while(t--)
#define all(v) v.begin(),v.end()
#define ll long long
#define ld long double
#define mp_ make_pair
#define pb push_back
#define sz(s) (int)s.size()
const int MAX = 1e5 + 5;
const int inf = 1e9+1;
const ll OO = 1e18;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
int n, k, a[MAX], dp[MAX];
int solve(int i = 0){
    if(i == n - 1) return 0;

    if(dp[i] < 1e9) return dp[i];

    int mn = inf;

    loop(j, i+1, i+k)
        if(j < n)
            mn = min(mn, solve(j) + abs(a[j] - a[i]));

    return dp[i] = mn;
}
int main()
{
    cin>> n >> k;
    lp(i, n)
        cin>> a[i];

    mem(dp, 63);
    cout<< solve() <<"\n";

    return 0;
}


Measured memory_bytes: 9060
#/usr/bin/ruby
#encoding: utf-8

# input
n = gets.to_i
a = gets.split.map(&:to_i)

# compute
a.sort!.reverse!
alice = 0
bob = 0

(0..n-1).each do |i|
  if i.even?
    alice += a[i]
  else
    bob += a[i]
  end
end

puts alice-bob

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll N;
  cin>>N;
  ll yaku[1000];

  FOR(i,0,999){
    yaku[i]=1;
  }

  FOR(i,1,N){
    ll tmp=i;
    FOR(j,2,N){
      while(tmp%j==0){
        yaku[j]++;
        tmp=tmp/j;
      }
    }
  }
  ll ans=1;
  FOR(i,0,999){
    ans=ans*yaku[i]%MOD;
  }
  cout<<ans<<endl;

  return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 55;
int a[maxn];
double b[maxn];
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i = 1;i <= n; ++i)
	{
		scanf("%d",&a[i]);
		b[i] = a[i] + 0.0;
	}
	sort(b + 1,b + n + 1);
	for(int i = 2;i <= n; ++i)
	{
		b[i] = (b[i] + b[i - 1]) / 2;
	}
	printf("%.10lf\n",b[n]);
	return 0;
}

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

int main() {
  vector<int> V(3);
  for (int i = 0; i < 3; i++) cin >> V.at(i);
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
  cout << ((V.size() == 2) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int h,w;cin>>h>>w;
  REP(i,h){
    string s;cin>>s;
    REP(j,w){
      cout<<s[j];
    }
    cout<<"\n";
    REP(j,w){
      cout<<s[j];
    }
    cout<<"\n";
  }
  return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll H;
  scanf("%lld", &H);

  ll W;
  scanf("%lld", &W);

  ll N;
  scanf("%lld", &N);

  ll b = max(H, W);
  ll s = min(H, W);

  ll count = 0;
  ll ans = 0;
  for (ll i = 0; i < s; i++) {
    count += b;
    ans++;
    if (count >= N) {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def distance(x,y):
    wa=x**2+y**2
    d=wa**0.5
    return d

N,D=map(int,input().split())
ans=0
for i in range(N):
    x,y=map(int,input().split())
    if distance(x,y)<=D:
        ans+=1
print(ans)

Measured memory_bytes: 9644
/*
[arc096] E - Everything on It
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 3000;

int N, MOD;

class gf {
public:
    int n;
    static gf mod_inv(int a, int m) {
        int u = 0, v = 1;
        while (a != 0) {
            int t = m / a;
            m -= t * a;
            u -= t * v;
            swap(a, m);
            swap(u, v);
        }
        return gf(u);
    }
    gf() : n(0) {}
    gf(int n) : n(n < 0 ? n % MOD + MOD : n % MOD) {}
    gf operator+(gf x) { return gf((n + x.n) % MOD); }
    gf operator-(gf x) { return gf((n - x.n + MOD) % MOD); }
    gf operator*(gf x) { return gf((1LL * n * x.n) % MOD); }
    gf operator/(gf x) { return *this * x.inv(); }
    gf& operator+=(gf x) { return *this = (*this + x); }
    gf& operator-=(gf x) { return *this = (*this - x); }
    gf& operator*=(gf x) { return *this = (*this * x); }
    gf& operator/=(gf x) { return *this = (*this / x); }
    gf inv() { return mod_inv(n, MOD); }
};

gf p2[MAX_N * MAX_N + 1];
gf pp2[MAX_N + 1];
gf stir2[MAX_N + 1][MAX_N + 1];

gf f2(int i, int j) {
    return (stir2[i][j] + stir2[i][j + 1] * (j + 1)) * p2[(N - i) * j] *
           pp2[N - i];
}

gf f1(int i) {
    gf ret = 0;
    for (int j = 0; j <= i; j++) {
        ret += f2(i, j);
    }
    return ret;
}

ll solve() {
    p2[0] = 1;
    for (int i = 1; i <= N * N; i++) {
        p2[i] = p2[i - 1] * 2;
    }

    pp2[0] = 2;
    for (int i = 1; i <= N; i++) {
        pp2[i] = pp2[i - 1] * pp2[i - 1];
    }

    stir2[0][0] = 1;
    for (int n = 1; n <= N; n++) {
        for (int k = 1; k <= n; k++) {
            stir2[n][k] = stir2[n - 1][k - 1] + stir2[n - 1][k] * k;
        }
    }

    gf ans = 0;
    gf nci = 1;
    for (int i = 0; i <= N; i++) {
        ans += f1(i) * nci * ((i & 1) ? -1 : 1);
        nci = nci * (N - i) / (i + 1);
    }

    return ans.n;
}

int main() {
    cin >> N >> MOD;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 70780
#include <iostream>
#include <vector>
#include <complex>

using namespace std;
typedef complex<double> C;

void fft(vector<C> &f, int n, int dir) {
	if (n == 1) return;
	vector<C> f0, f1;
	for(int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			f0.push_back(f[i]);
		} else {
			f1.push_back(f[i]);
		}
	}
	fft(f0, n / 2, dir);
	fft(f1, n / 2, dir);
	C zeta = polar(1.0, 2 * M_PI * dir / n);
	C now = C(1.0);
	for(int i = 0; i < n; i++) {
		f[i] = f0[i % (n / 2)] + now * f1[i % (n / 2)];
		now *= zeta;
	}
}

inline int getMinimumPowerOf2(int size) {
	int n = 1;
	while(n < size) n <<= 1;
	return n;
}

void fft2d(vector<vector<C> > &A, int dir = 1) {
	for(int i = 0; i < A.size(); i++) {
		vector<C> f;
		for(int j = 0; j < A[i].size(); j++) {
			f.push_back(A[i][j]);
		}
		fft(f, f.size(), dir);
		for (int j = 0; j < f.size(); j++) {
			A[i][j] = f[j];
		}
	}
	for(int j = 0; j < A[0].size(); j++) {
		vector<C> f;
		for(int i = 0; i < A.size(); i++) {
			f.push_back(A[i][j]);
		}
		fft(f, f.size(), dir);
		for (int i = 0; i < f.size(); i++) {
			A[i][j] = f[i];
		}
	}
}

vector<vector<C> > comb2d(vector<vector<C> > A, vector<vector<C> > B) {
	int n = getMinimumPowerOf2(A.size() + B.size()), m = getMinimumPowerOf2(A[0].size() + B[0].size());
	A.resize(n);
	B.resize(n);
	for (int i = 0; i < A.size(); i++) {
		A[i].resize(m);
	}
	for (int i = 0; i < B.size(); i++) {
		B[i].resize(m);
	}
	fft2d(A);
	fft2d(B);
	vector<vector<C> > ret(n, vector<C>(m, 0));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			ret[i][j] = A[i][j] * B[i][j];
		}
	}
	fft2d(ret, -1);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			ret[i][j] /= n * m;
		}
	}
	return ret;
}



int main() {
	int N, M;
	char chars[] = {'#', '.'};
	int num_chars = sizeof(chars);

	cin >> N >> M;
	vector<string> A(N), B(M);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	int n = getMinimumPowerOf2(N + M);
	vector<vector<C> > score(n, vector<C>(n, C(0)));
	for (int c = 0; c < num_chars; c++) {
		vector<vector<C> > cA, cB;
		for (int i = 0; i < N; i++) {
			cA.push_back(vector<C>());
			for (int j = 0; j < N; j++) {
				cA[i].push_back(C(A[i][j] == chars[c]));
			}
		}
		for (int i = 0; i < M; i++) {
			cB.push_back(vector<C>());
			for (int j = 0; j < M; j++) {
				cB[i].push_back(C(B[i][j] == chars[c]));
			}
		}
		vector<vector<C> > ret = comb2d(cA, cB);
		for (int i = 0; i < score.size(); i++) {
			for (int j = 0; j < score[0].size(); j++) {
				score[i][j] += ret[i][j];
			}
		}
	}
	bool flag = false;
	for (int i = 0; i < score.size(); i++) {
		for (int j = 0; j < score[0].size(); j++) {
			if ((int)(real(score[i][j]) + 0.1) == M * M) {
				flag = true;
				break;
			}
		}
		if (flag) break;
	}

	if (flag) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}





Measured memory_bytes: 1416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod  1000000007
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ld long double
#define fi first
#define se second
#define setbits __builtin_popcount
//Please check edge cases
ll power(ll x,ll n)
{
    ll p;
    if(n==0)
    {
        return 1;
    }
    p=power(x,n/2);
    p=((p%mod)*(p%mod))%mod;
    if(n%2==1)
    {
        p=((p%mod)*(x%mod)%mod);
    }
    return p;
}
int main()
{
    fastIO;
    ll n;
    cin>>n;
    ll a[n],i;
    ll y,x,val,j,val1,count=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    val=n;
    vector<ll>v(61,0);
    for(i=0;i<n;i++)
    {
        x=a[i];
        j=0;
        while(x!=0)
        {
            v[j]+=x%2;
            x/=2;
            j++;
        }
    }
    ll ans=0;
    for(i=0;i<61;i++)
    {   
        x=v[i];
        if(x>0)
        {
            ans+=(power(2,i)*(((n-x)*x)%mod))%mod;
        }
        ans=ans%mod;
    }
    ans=ans%mod;
    cout<<ans<<'\n';
    return 0;
}

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

int N;
int k, g;

signed main() {
	cin >> N;
	rep(i,N)
	{
		int a;
		cin >> a;
		if (a % 2)
			k++;
		else
			g++;
	}
	g += k / 2;
	k = k % 2;
	if (k == 0) {
		cout << "YES" << endl;
		return 0;
	}
	if (k == 1 && g == 0) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 384
x, y, z, k = map(int, input().split())
a =list(map(int, input().split()))
b =list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
abc = []
for i in range(x):
    if (i+1) > k:
        break
    for j in range(y):
        if (i+1)*(j+1) > k:
            break
        for h in range(z):
            if (i+1)*(j+1)*(h+1) >k:
                break
            abc.append(a[i] +b[j] +c[h])
abc.sort(reverse = True)
for i in range(k):
    print(abc[i])

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


int main(){
	double a,b,x,i;
	double theta;
	cin>>a>>b>>x;
	if(a*a*b/2>=x){
		i = a-2*x/(a*b);
		theta = atan(b/(a-i));
	}
	else{
		i = 2*b-2*x/(a*a);
		theta = atan(i/a);
    }
	cout<<std::setprecision(11)<<theta/M_PI*180<<endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    String ans = "";
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == '1') {
        ans += "9";
      } else if (str.charAt(i) == '9') {
        ans += "1";
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21204
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> weights(N);
    for (int i = 0; i < N; ++i) cin >> weights[i];

    int left = 0;
    int right = accumulate(weights.begin(), weights.end(), 0);
    int minAbs = 100000000;
    for (int i = 0; i < N - 1; ++i)
    {
        left += weights[i];
        right -= weights[i];
        int absDiff = abs(left - right);
        if (absDiff < minAbs)
        {
            minAbs = absDiff;
        }
    }
    cout << minAbs << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    int alice = 0;
    int bob = 0;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    for (int i = 0; i < n-1; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            if (a[i] < a[j])
            {
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }
    cout << alice-bob << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N,Q=map(int,input().split())

T=[[]for _ in range(N)]
for i in range(N-1):
    a,b =map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

ans=[0]*N
for i in range(Q):
    p,x=map(int,input().split())
    ans[p-1] += x
    
q=deque([0])
visited=set()
while q:
    now =q.popleft()
    visited.add(now)
    for n in T[now]:
        if n not in visited:
            ans[n] += ans[now]
            q.append(n)
print(*ans)

Measured memory_bytes: 64304
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
//map<int,int> m;
int main(){
	ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x = a%d==0?a/d:a/d+1;
	int y = c%b==0?c/b:c/b+1;
	if(y<=x){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}



}


Measured memory_bytes: 3636
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter


import sys
def input():
	return sys.stdin.readline().strip()

N, M = list(map(int, input().split()))

graph = [[] for _ in range(N)]

for _ in range(M):
	s, t = list(map(int, input().split()))
	graph[s - 1].append(t - 1)

base_dist = [-1]*N
base_dist[-1] = 0


for i in range(N - 2, -1, -1):
	total = 0
	for node in graph[i]:
		total += base_dist[node]
	base_dist[i] = total/len(graph[i]) + 1


ans = base_dist[0]
for stop in range(0, N - 1):
	dist = copy.deepcopy(base_dist)
	total = 0
	if len(graph[stop]) == 1:
		continue
	max_d = 0
	for node in graph[stop]:
		max_d = max(max_d, dist[node])
		total += dist[node]
	total -= max_d
	total /= (len(graph[stop]) - 1)
	total += 1
	dist[stop] = total

	for i in range(stop - 1, -1, -1):
		total = 0
		for node in graph[i]:
			total += dist[node]
		dist[i] = total / len(graph[i]) + 1

	ans = min(ans, dist[0])
	#print(stop,dist)

print(ans)


Measured memory_bytes: 89560
from fractions import gcd
from math import ceil
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=len(bin(a[0]))-bin(a[0]).rfind("1")
for i in range(1,n):
  if c!=len(bin(a[i]))-bin(a[i]).rfind("1"):
    print(0)
    exit()
g=a[0]
for i in range(n-1):
   g=(g//gcd(g,a[i+1]))*(a[i+1]//gcd(g,a[i+1]))*gcd(g,a[i+1])
g//=2
print(ceil((m//g)/2))


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

int main () {

    int N, M;
    cin >> N >> M;

    vector<int> divisor;
    for (int i = 1; i * i <= M; i++) {
        if (M % i == 0) {
            divisor.push_back(i);
            divisor.push_back(M / i);
        }
    }

    sort(divisor.begin(), divisor.end(), greater<int>());

    for (int i = 0; i < divisor.size(); i++) {
        if (divisor[i] <= M/N) {
            cout << divisor[i] << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
int main() {
	string a;
	cin >> a;
	string b = "";
	for (int i = 0; i < a.length(); i++) {
		if (a[i] == 'A') {
			b += a[i];
		}
		else if (a[i] == 'Z') {
			b += a[i];
		}
	}
	int b2 = 0, c2 = 0;
	for (int i = 0; i < b.length(); i++) {
		if (b[i] == 'A') {
			break;
		}
		else {
			b2++;
		}
	}
	for (int i = b.length() - 1; i >= 0; i--) {
		if (b[i] == 'Z') break;
		else {
			c2++;
		}
	}
	string d = "";
	char e = 'A', f = 'Z';
	for (int i = b2; i < b.length() - c2; i++) {
		if (b[i] == e) {
			d += b[i];
			swap(e, f);
		}
	}
	if (d.length() == 0) cout << -1 << endl;
	else cout << d << endl;
}

Measured memory_bytes: 3224
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main
{
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n=ni();
		int[] a=na(n);
		int ans=0;
		while(ok(a)) {
			for(int i=0;i<n;i++) {
				a[i]=a[i]/2;
			}
			ans++;
		}
		
		out.println(ans);
	}
	
	boolean ok(int[] a) {
		for(int i=0;i<a.length;i++) {
			if(a[i]%2!=0) {
				return false;
			}
		}
		return true;
	}
	
	
	
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception 
	{ new Main().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf)
		{
			ptrbuf = 0;
			try 
			{ lenbuf = is.read(inbuf); } 
			catch (IOException e) 
			{ throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c)
	{ return !(c >= 33 && c <= 126); }
	private int skip() 
	{ int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() 
	{ return Double.parseDouble(ns()); }
	private char nc()
	{ return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b)))
		{ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b)))
		{
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}
		
		while(true)
		{
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) 
	{ System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 21204
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int K = stdin.nextInt();
	    if ( K == 0 ) {
		break;
	    }

	    int sum = 0;
	    final int lim = K * ( K - 1 ) / 2;
	    for ( int i = 0; i < lim; i++ ) {
		sum += stdin.nextInt();
	    }

	    System.out.println( sum / ( K - 1 ) );	    
	}	
    }    
}

Measured memory_bytes: 61964
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	static boolean[][] cg;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    int M=gi();
	    int[][] g=new int[N][N];
	    cg=new boolean[N][N];
	    boolean[] f=new boolean[M];

        for (int i=0; i< N;i++) {
        	for(int j=0; j<N;j++) {
        		if(i!=j) {
        		    g[i][j]=Integer.MAX_VALUE;
        		} else {
        			g[i][j]=0;
        		}
        	}
        }

        for (int i=0; i<M;i++) {
        	int a=gi();
        	int b=gi();
        	int c=gi();
        	g[a-1][b-1]=c;
        	g[b-1][a-1]=c;
		    cg[a-1][b-1]=true;
		    cg[b-1][a-1]=true;
        }

        for (int i=0; i<N;i++) {
            dikstra(g, i);
        }

        int ans=0;
        for (int i=0; i<N;i++) {
        	for (int j=0; j<N;j++) {
            	if(cg[i][j]==true)ans++;
            }
        }

        System.out.println(ans/2);
	}

	public static int[] dikstra(int[][] g, int s){
        int[] k=new int[g.length];
        int[] prev=new int[g.length];
        prev[s]=s;
        boolean[] f=new boolean[g.length];
        for (int i=0; i<g.length; i++) {
        	k[i]=Integer.MAX_VALUE;
        }
        k[s]=0;
        while(true) {
        	int v=-1;
        	for(int i=0; i<g.length;i++) {
        		if(!f[i] && (v==-1 || k[i]<k[v])) {
        			v=i;
        		}
        	}
        	if(v==-1)break;
        	f[v]=true;

        	for(int i=0; i<g.length; i++) {
        		if (k[i]>k[v]+g[v][i] && g[v][i]!=Integer.MAX_VALUE) {
        		   prev[i]=v;
        		   k[i]=k[v]+g[v][i];
        		}
        	}
        }

        for (int i=0; i<g.length;i++) {
        	cg[i][prev[i]]=false;
        	cg[prev[i]][i]=false;
        }

        return k;
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39512
def main():
    n, y = map(int, input().split())
    flag = False
    for i in range(n+1):
        for j in range(n+1):
            if i + j <= n and y == i * 10000 + j * 5000 + (n - i - j) * 1000:
                print(i, j, (n - i -j))
                flag = True
                if flag:
                    break
        else:
            continue
        break
    if not flag:
        print('-1 -1 -1')
if __name__ == '__main__':
    main()

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

int main() {
  int n;
  cin>>n;
  string s;
  int cnt = 0;
  map<string, int> mp;
  for(int i=0;i<n;i++) {
    cin>>s;
    if(mp[s] == 0) cnt++;
    mp[s] = 1;
  }
  cout<<cnt<<endl;
}
    

Measured memory_bytes: 19180
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var RGBN = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var R = RGBN[0];
            var G = RGBN[1];
            var B = RGBN[2];
            var N = RGBN[3];

            int ret = 0;
            for (double r = 0; r <= 3000; r++)
            {
                for (double g = 0; g <= 3000; g++)
                {
                    var b = (N - r * R - g * G) / B;
                    var tran = b - Math.Truncate(b);
                    if (b < 0)
                    {
                        break;
                    }
                    if (tran == 0)
                    {
                        ret++;
                    }
                } 
            }

            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 28124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	ll K;
	cin >> N >> K;
	V<int> a(N);
	rep(i,N) cin >> a[i];

	V<set<int>> val2is(200010);
	rep(i,N){
		val2is[a[i]].insert(i);
	}

	V<int> ps = {0};
	{
		int x = 0;
		do{
			auto it = val2is[a[x]].upper_bound(x);
			if(it == val2is[a[x]].end()){
				it = val2is[a[x]].begin();
				ps.pb(*it + 1);
			}
			x = *it + 1;
			if(x == N){
				x = 0;
			}
		}while(x != 0);
	}
	K = (K-1)%ps.size();
	show(ps);

	auto From = [&](int s){
		V<int> res;
		V<bool> is(200010);
		for(int i=s;i<N;i++){
			if(is[a[i]]){
				while(res.back() != a[i]){
					is[res.back()] = false;
					res.pop_back();
				}
				is[a[i]] = false;
				res.pop_back();
			}else{
				res.pb(a[i]);
				is[a[i]] = true;
			}
		}
		return res;
	};

	V<int> res = From(ps[K]);
	for(int v: res) cout << v << " ";
	cout << endl;
}


Measured memory_bytes: 22772
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(A: int, B: int, C: int):
    counter = 0
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        if A == B and B == C:
            print(-1)
            return
        A, B, C = (B+C)//2, (C+A)//2, (A+B)//2
        counter += 1
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5304
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#define N 100000
using namespace std;

int color[N];
vector<int> G[N];
queue<int> Q;
int n;

void bfs(int s,int c) {
	Q.push(s);
	color[s] = c;
	while (!Q.empty()) {
		for (unsigned int it = 0;it < G[Q.front()].size();it++)
			if (color[G[Q.front()][it]] == 0){
				Q.push(G[Q.front()][it]);
				color[G[Q.front()][it]] = c;
		    }
		Q.pop();
	 }
}

void Color() {
	int c = 1;
	for(int i=0;i<n;i++)
		if (color[i] == 0) { bfs(i, c); c++; }
}

int main() {
	int m, q;
	cin >> n >> m;
	for (int i = 0;i < m;i++) {
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	Color();

	cin >> q;
	for (int i = 0;i < q;i++) {
		int u, v;
		cin >> u >> v;
		if (color[u] == color[v] && color[u] != 0)
			cout << "yes" << endl;
		else
			cout << "no"<<endl;
	}
}

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

int main(){
	int n;
	int a[110];
	cin >> n;
	rep(i,n) cin >> a[i];
	sort(a,a+n,greater<int>());
	int Alice=0;
	int Bob =0;
	rep(i,n){
		if(i%2 ==0) Alice += a[i];
		else Bob += a[i];
	}
	cout << Alice - Bob << endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B = gets.split(" ").map!{|i| i.to_i}
x = 0
for i in 1..N do
  sum = 0
  a = i
  while a != 0
    n = a % 10
    sum = sum + n
    a = (a-n)/10
  end
  if (sum >= A)&&(sum <= B)
    x = x + i
  end
end
puts x 

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

int main() {
  int n; cin>>n;
  string s; cin>>s;
  int count=0;
  rep(i,n-2){
    string sb=s.substr(i,3);
    if(sb=="ABC")count++;
  }
  cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N, M;
    cin >> N >> M;
    vpii lst;

    int A, B;
    REP(i, N)
    {
        cin >> A >> B;
        lst.push_back(make_pair(A, B));
    }
    sort(ALL(lst));
    ll ans = 0;
    REP(i, N)
    {
        // cout << lst[i].first << " " << lst[i].second << endl;
        if (M > lst[i].second)
        {
            ans = ans + lst[i].second * lst[i].first;
            M = M - lst[i].second;
        }
        else
        {
            ans = ans + M * lst[i].first;
            M = M - M;
        }
        if (M == 0)
            break;
    }

    cout << ans;
    // system("pause");
}

Measured memory_bytes: 2420
n,a,b,c  = map(int, input().split())
Ss = [input() for i in range(n)]
ans = []
flg = True
for i,S in enumerate(Ss):
    if S == "AB":
        if a == b == 0:
            flg = False
        elif a == b == 1 and i < len(Ss)-1:
            if Ss[i+1] == "AC":
                a += 1
                b -= 1
                ans.append("A")
            else:
                a -= 1
                b += 1
                ans.append("B")
        elif a < b:
            a += 1
            b -= 1
            ans.append("A")
        else:
            a -= 1
            b += 1
            ans.append("B")
    elif S == "AC":
        if a == c == 0:
            flg = False
        elif a == c == 1 and i<len(Ss)-1:
            if Ss[i+1] == "BC":
                a -= 1
                c += 1
                ans.append("C")
            else:
                a += 1
                c -= 1
                ans.append("A")

        elif a < c:
            a += 1
            c -= 1
            ans.append("A")
        else:
            a -= 1
            c += 1
            ans.append("C")
    elif S == "BC":
        if b == c == 0:
            flg = False
        elif b == c == 1 and i < len(Ss)-1:
            if Ss[i+1] == "AC":
                c += 1
                b -= 1
                ans.append("C")
            else:
                c -= 1
                b += 1
                ans.append("B")
        elif b < c:
            b += 1
            c -= 1
            ans.append("B")
        else:
            b -= 1
            c += 1
            ans.append("C")
            
if flg: 
    print("Yes")
    print(*ans)
else:
    print("No")

Measured memory_bytes: 91644
from collections import deque
n = int(input())
a = list(map(int, input().split()))

b = deque()

for i in range(n):
    if i%2:
        b.appendleft(a[i])
    else:
        b.append(a[i])

o = b.pop if n%2 else b.popleft

for i in range(n):
    print(o(), end=' ')

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p;
string s, t;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n ;
	for(ll i=0;i<n;i++) {
		cin>>x;
		if(x&1) {
			cout<<"first\n";
			return;
		}
	}
	cout<<"second\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    vector<pair<int, int>> iApair(n);

    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        a--;
        iApair[i] = make_pair(i, a);
    }

    sort(iApair.begin(), iApair.end(), [](pair<int, int> lhs, pair<int, int> rhs) {
        return lhs.second < rhs.second;
    });

    for (auto &&ia : iApair)
    {
        cout << ia.first + 1 << " ";
    }
    cout << endl;

    return 0;
}

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

typedef long long ll;

using namespace std;

ll MAX = 1e9+1;
void solve() {
    string s, t;

    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    string ans;
    vector< vector<int> > dp(n+1, vector<int>(m+1, 0));
    // dp[i][j] ~ length of lcs between s[:i] and t[:j]
    // dp[0][0] = 0 
    // dp[i][j] = dp[i-1][j-1] + 1 if s[i] == t[j] otherwise the 
    //            longer of dp[i][j-1] and dp[i-1][j]

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i-1] == t[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int i = n-1;
    int j = m-1;
    while (i >= 0 && j >= 0) {
        if (s[i] == t[j]) {
            ans += s[i];
            i--;
            j--;
        } else {
            // at dp[i+1][j+1]
            if (dp[i][j+1] > dp[i+1][j])
                i--;
            else
                j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


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




Measured memory_bytes: 35584
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <fstream>

using namespace std;

struct node
{
    string name;
    int time;
};

int main()
{
    queue<node> Q;
    int n, q;
    int current_time = 0;
    int i;
    node a;

    cin >> n >> q;

    for ( i = 0; i < n; i++ )
    {
        cin >> a.name >> a.time;
        Q.push(a);
    }

    while(!(Q.empty()))
    {
        a = Q.front();
        int tmp = min(q, a.time);
        a.time -= tmp;
        current_time += tmp;
        Q.pop();
        if ( a.time )
            Q.push(a);
        else
            cout << a.name << " " << current_time << endl;
    }

    return 0;
}



Measured memory_bytes: 6328
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    int n;
    cin >> n;
    vector <int> v(n);
    for (int i = 0; i< n; i++) cin >> v[i];
    vector <int> s(n);
    s[0] = v[0];
    int ans = 1;
    for (int i = 1; i < n; i++){
        if (v[i] <= s[i-1]){
            s[i] = v[i];
            ans++;
        }
        else s[i] = s[i-1];
    }
    cout << ans;
    return 0;
}




Measured memory_bytes: 1792
import java.util.Scanner;
	public class Main {
	
		public static void main(String[] args) {
			solve();
		}
		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int array[] = new int[n];
			String res = "APPROVED";
			for(int i = 0;i<n;i++) {
				array[i] =sc.nextInt();
				if(array[i]%2==0&&!(array[i]%3==0||array[i]%5==0)) {
						res = "DENIED";
					}
				
			}
			System.out.println(res);
			sc.close();
		}	
	}
	


Measured memory_bytes: 21844
#include<iostream>
#include<string>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	string A,B;
	string result;
	cin >> A;
	cin >> B;
    if(A.size()>B.size()) result="GREATER";
    else if(A.size()<B.size()) result="LESS";
    else{
        if(A>B) result="GREATER";
        else if(A<B) result="LESS";
        else if(A==B) result="EQUAL";
    }
	cout << result << "\n";
}

Measured memory_bytes: 256
def getConverseCodes(S, n):
    converseCodes = ''
    for s in S:
        s = ord(s)
        if 65 <= s and s<= 90:
            s = s + n
            if s > 90:
                s = s - 26
        s = chr(s)
        converseCodes += s
    return converseCodes

N = int(input())
S = input()

print(getConverseCodes(S, N))

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
//void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void Yes() { cout << "Yes" << endl; } 
void No() { cout << "No" << endl; }

signed main()
{
	int N, A, B;
	cin >> N >> A >> B;

	int ans = 0;
	for (int i = 0; i <= N; i++)
	{
		int sum = 0;
		int n = i;
		while (n > 0)
		{
			int s = n % 10;
			sum += s;
			n /= 10;
		}
		if (A <= sum && sum <= B)
		{
			ans += i;
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 3572