akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
#include <stack>
using namespace std;
int main(){
	int N, M; 
	cin >> N >> M; 
	int I[100010] = {}; 
	vector<int> E[100010] = {}; // 出ていく辺
	vector<int> F[100010] = {}; // 入ってくる辺
	for(int i = 1; i < M+N; i++){
		int a, b; 
		cin >> a >> b; 
		E[a].push_back(b); 
		F[b].push_back(a); 
		I[b] ++; 
	}
	stack<int> st;
	for(int i = 1; i <= N; i++){
		if(!I[i]) st.push(i); 
	}
	vector<int> S = {}; //トポロジカルソート後
	while(st.size()){
		int i = st.top(); st.pop(); 
		S.push_back(i); 
		for(int j = 0; j < E[i].size(); j++){
			I[E[i].at(j)] --; 
			if(!I[E[i].at(j)]) st.push(E[i].at(j)); 
		}
	}
	int top[100010] = {}; 
	for(int i = 0; i < N; i++){
		top[S.at(i)] = i; 
	}
	for(int i = 1; i <= N; i++){
		int mx = -1; 
		for(int j = 0; j < F[i].size(); j++){
			mx = max(mx, top[F[i].at(j)]);
		}
		cout << ((mx >= 0) ? S.at(mx) : 0) << endl; 
	}
}

Measured memory_bytes: 13052
#include <iostream>
#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 <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int Order[10000];
vector<int> G[10000];
long C[10000];
int A[10000];
void Calc(){
	int N = rei();
	for(int i=0;i<N-1;i++){
		int f = rei()-1;
		int t = rei()-1;
		G[f].push_back(t);
		G[t].push_back(f);
		Order[f]++;
		Order[t]++;
	}
	for(int i=0;i<N;i++){
		C[i] = rei();
	}
	sort(C,C+N);
	long ans = 0;
	for(int i=0;i<N-1;i++){
		ans += C[i];
	}
	cout << ans << endl;
	stack<int> sp;
	for(int i=0;i<N;i++){
		if(Order[i] == 1){
			sp.push(i);
		}
	}
	for(int i=0;i<N-1;i++){
		int v = sp.top();
		sp.pop();
		A[v] = C[i];
		for(int t:G[v]){
			Order[t]--;
			if(Order[t] == 1){
				sp.push(t);
			}
		}
	}
	A[sp.top()] = C[N-1];
	for(int i=0;i<N;i++){
		cout << A[i];
		if(i == N-1){
			cout << endl;
		}
		else{
			cout << " ";
		}
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

int main()
{
  IOS;
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  for (int i=0; i<n; i++)
    {
      if (s.substr(i,3)=="ABC")
	ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> sozai(n);
    vector<ll> to(n);
    for (int i = 0; i < n; i++) {
        cin >> sozai[i];
        to[i] = sozai[i];
    }
    sort(to.begin(), to.end());
    priority_queue<ll> q;
    priority_queue<ll> tq;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
            q.push(sozai[i]);
            tq.push(to[i]);
        }
    }
    ll ans = n / 2;
    while (!(q.empty()) && !(tq.empty())) {
        if (q.top() == tq.top()) {
            ans--;
            q.pop();
            tq.pop();
        }
        else if (q.top() > tq.top()) {
            q.pop();
        }
        else { tq.pop(); }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2812
N=int(input())
flag=0
E=[]
total=0
maxi=0
for i in range(N):
    E.append([0]*N)
for i in range(N):
    M=int(input())
    for j in range(M):
        C, D = map(int, input().split())
        if D==1:
            D=2
        else:
            D=1
        E[i][C-1]+=D

#print(E)

A=[]
for i in range((2**N)):
    s=format(i,'b')
    A.append(s.zfill(N))
#print(A)

for i in range(len(A)):
    flag=0
    total=0
    S=A[i]
    #print(S)
    for j in range(len(S)):
        if S[j]=='0':
            for k in range(N):
                #print(E[j][k],S[k])
                if (E[j][k]==1 and S[k]=='0')or (E[j][k] == 2 and S[k] == '1'):
                    #print('f')
                    flag=1
    if flag==0:
        for o in range(len(S)):
            if S[o]=='0':
                total+=1
        maxi=max(maxi,total)
print(maxi)

Measured memory_bytes: 50268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    ll n;cin>>n;
    ll ans = 1;
    for(int i=1;i<=n;i++){
        ans = i*ans%1000000007;
    }
    co(ans%1000000007);
}

Measured memory_bytes: 256
#include<stdio.h>
#define PMAX 1000000000
#define MAX 100000
int wmax=0;
int n,k,w[MAX];  
int check(int P){
    int i;
    int count=1,now=P;
    if(P<wmax) return 0;
    for(i=0;i<n;i++){
        if(now>=w[i]){
           now-=w[i];
        }else{
            count++;
            now=P-w[i];
        }
    }
    if(count>k) return 0;
    else return 1;
}
  
int main(void){
    int i;
    int left,right,mid;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
        if(w[i]>wmax) wmax=w[i];
    }
    left=0,right=PMAX;
    while(right-left>1){
        mid=(left+right)/2;
        if( check(mid) ) right=mid;
        else left=mid;
    }
    printf("%d\n",right);
    return 0;
}


Measured memory_bytes: 2240
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
 
using namespace std;
 
int main(){
  int C1,C2,C3,sum,cnt;
  bool card[11];
  while(cin >> C1 >> C2 >> C3){
    for(int i=0;i<=10;i++)card[i] = true;
    card[C1] = card[C2] = card[C3] = false;
    sum = C1+C2; cnt = 0;
    for(int i=1;i<=10;i++)if(card[i] && sum+i <= 20)cnt++;
    cnt*10 >= 35 ? cout << "YES":cout << "NO";
    cout << endl;    
 
  }
  return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;

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

    int n,m;
    cin>>n>>m;
    string s[n];
    int ar[n]={0};
    int br[m]={0};
    for(int i=0;i<n;++i)
    {
        cin>>s[i];
        int f=0;
        for(int j=0;j<m;++j)
        {
            if(s[i][j]=='#'){f=1;}
        }
        if(f==0){ar[i]=1;}
    }
    for(int j=0;j<m;++j)
    {
        int f=0;
        for(int i=0;i<n;++i)
        {
            if(s[i][j]=='#'){f=1;}
        }
        if(f==0){br[j]=1;}
    }
    for(int i=0;i<n;++i)
    {
        if(ar[i]==0)
        {
            for(int j=0;j<m;++j)
            {
                if(br[j]==0)
                {
                    cout<<s[i][j];
                }
            }
            cout<<endl;
        }
    }

return(0);
}

Measured memory_bytes: 256
times = [int(input()) for i in range(5)]
cost = 0
p_times = [time % 10 for time in times]

if (sum([i % 10 for i in p_times]) == 0) & (min(times) > 0):
    last_order = False
else:
    last_order = min([i for i in p_times if i > 0])
    last_order_idx = p_times.index(last_order)

if last_order:
    cost = times.pop(last_order_idx)

for time in times:
    if time % 10 == 0:
        cost += time
    else:
        cost += time + (10 - time % 10)

print(cost)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

const int BIT_SZ = 300005;
int bit[BIT_SZ];
void add(int idx) {
  idx += 100005;
  while(idx < BIT_SZ) {
    bit[idx]++;
    idx += idx & -idx;
  }
}
int qry(int idx) {
  idx += 100005;
  int ret = 0;
  while(idx) {
    ret += bit[idx];
    idx -= idx & -idx;
  }
  return ret;
}

int l[100005];
int n;

bool good(int thresh) {
  memset(bit, 0, sizeof(bit));
  int d = 0;
  add(d);
  ll amt = 0;
  for(int i = 0; i < n; i++) {
    d += (l[i] >= thresh) ? 1 : -1;
    amt += qry(d);
    add(d);
  }
  return amt >= ((n*(n+1LL)/2)+1)/2;
}

void solve() {
  cin >> n;
  for(int i = 0; i < n; i++) cin >> l[i];
  int lhs = 1;
  int rhs = 1e9;
  while(lhs != rhs) {
    int mid = (lhs+rhs+1)/2;
    if(good(mid)) lhs = mid;
    else rhs = mid-1;
  }
  cout << lhs << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    s.resize(3);

    cout << s << endl;

    return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll mazic(vector<ll> v,ll a){
  if(v.size()==1){
    return abs(a-v[0]);
  }
  ll m=inf;
  for(ll i=0;i<v.size();i++){
    m=min(m,abs(a-v[i]));
  }

  if(m==0)return 0;

  for(ll i=0;i<v.size()-1;i++){
    for(ll j=i+1;j<v.size();j++){
      vector<ll> u=v;
      u[i]+=u[j];
      swap(u[j],u[u.size()-1]);
      u.pop_back();
      m=min(m,mazic(u,a)+10);
    }
  }
  return m;

}

int main(){

  ll n,a,b,c;
  cin >> n >> a >> b >> c;

  ll l[n];
  for(ll i=0;i<n;i++)cin >> l[i];

  ll m=inf;
  for(ll i=1;i<(1<<n);i++){
    if(n-__builtin_popcountll(i)<=1)continue;
    vector<ll> v1;
    vector<ll> q;
    for(ll j=0;j<n;j++){
      if(i & (1<<j))v1.push_back(l[j]);
      else q.push_back(l[j]);
    }
    for(ll k=1;k<(1<<q.size());k++){
      if(__builtin_popcountll(k)==q.size())continue;
      vector<ll> v2,v3;
      for(ll t=0;t<q.size();t++){
        if(k & (1<<t))v2.push_back(q[t]);
        else v3.push_back(q[t]);
      }
      m=min(m,mazic(v1,a)+mazic(v2,b)+mazic(v3,c));
      //if(mazic(v1,a)+mazic(v2,b)+mazic(v3,c)==165)cout << i << " " << k << endl;
    }
  }

  // vector<ll> u;
  // u.push_back(100);
  // u.push_back(90);
  // u.push_back(80);
  // cout << mazic(u,253) << endl;

  cout << m << endl;


}

Measured memory_bytes: 3612
a, b, c, x, y = map(int, input().split())
ans = 0

if 2*c-a-b > 0:
  ans += a*x + b*y
else:
  s = min(x, y)
  ans += min(c*s*2 + a*(x-s) + b*(y-s), c*max(x, y)*2)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define F(N,S,E) for(int N=(int)(S);N<=(int)(E);N++)
#define D(N,E) for(int N=0;N<(int)(E);N++)
typedef vector<int> V;

template<class T=int>
T read(){
	T x=0;
	char ch=0;
	bool f=false;
	while(!isdigit(ch))f|=(ch=getchar())=='-';
	for(;isdigit(ch);ch=getchar())x=x*10+(ch^'0');
	return x;
}

const int MOD=1e9+7;
int add(int a,int b){return (a+b)%MOD;}
int sub(int a,int b){return (a-b+MOD)%MOD;}
int mul(int a,int b){return (LL)a*b%MOD;}
int sqr(int a){return mul(a,a);}
int ksm(int a,int b){return b?mul(sqr(ksm(a,b>>1)),b&1?a:1):1;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}

int solve(int h,int w){
	int g=gcd(h,w);
	return sub(add(add(ksm(2,h),ksm(2,w)),ksm(2,g)),3);
}

int main(){
	int h=read(),w=read(),t=read();
	int hg=gcd(h,t);
	int wg=gcd(w,t);
	int ans=ksm(solve(h/hg,w/wg),(LL)hg*wg%(MOD-1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  int diff = abs(A - B);

  int ans;
  if (diff % 2 == 0) {
    ans = diff / 2;
  } else {
    int X = (A + B - 1) / 2, Y = (N - A + N - B + 1) / 2;
    ans = min(X, Y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<int> edges[110000];
vector<int> val[110000];

int ans[110000];

struct UF{
	int n;
	vector<int> par;
	UF(int n) : n(n) {
		for(int i = 0; i < n; i++) par.push_back(i);
	}
	int find(int a){
		if(a != par[a]) par[a] = find(par[a]);
		return par[a];
	}
	void join(int a, int b){
		par[find(a)] = find(b);
	}
};


void dfs(int i, int v){
	if(ans[i] == v) return;
	if(ans[i] == 0) return;
	if(ans[i] == -1){
		ans[i] = v;
	} else {
		ans[i] = 0;
	}
	for(int j = 0; j < edges[i].size(); j++){
		dfs(edges[i][j], (ans[i] * val[i][j]) % 7);
	}
}
LL num[7][110000];
LL trash[110000];
int main(){
	int n, m;
	cin >> n >> m;
	vector<int> c, d;

	UF g(n);

	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		c.push_back(a);
		d.push_back(b);
		edges[a].push_back(b);
		edges[b].push_back(a);
		val[a].push_back(2);
		val[b].push_back(4);
		g.join(a,b);
	}
	for(int i = 0; i < n; i++){
		ans[i] = -1;
	}
	for(int i = 0; i < n; i++){
		if(ans[i] == -1) dfs(i,1);
	}
	for(int i = 0; i < n; i++){
		num[ans[i]][g.find(i)]++;
	}
	LL fans = 0;
	for(int i = 0; i < n; i++){
		trash[i] = 1;
		fans += num[0][i] * num[0][i];
		if(num[0][i]) trash[i] = 0;
		if(num[1][i] == 0) continue;
		if(num[2][i] == 0) continue;
		if(num[4][i] == 0) continue;
		trash[i] = 0;

		fans += num[1][i] * num[2][i];
		fans += num[2][i] * num[4][i];
		fans += num[4][i] * num[1][i];
	}
	for(int i = 0; i < m; i++){
		if(trash[g.find(c[i])]){
			fans++;
		}
	}
	cout << fans << endl;
}


Measured memory_bytes: 27256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
using namespace std;
int main() {
    long long int n;
    cin >> n;
    long long int fib[n];
    fib[0] = 2;
    fib[1] = 1;
    for(int i=2;i<n+1;i++){
        fib[i] = fib[i-1] + fib[i-2];
    }

    cout << fib[n] << endl;
}


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

A,B,C,X,Y = map(int, input().split())

# AB only
yen1 = max(X,Y) * 2 * C

# A + AB
yen2 = (max(X-Y, 0) * A) + (Y * 2 * C)

# AB + B
yen3 = (X * 2 * C) + (max(Y-X, 0) * B)

# A + B
yen4 = X * A + Y * B

ans = min(yen1, yen2, yen3, yen4)
print(ans)


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

int main(){

  int n;
  string s;
  int k = 1;
  int ans;

  cin >> ans;
  cin >> s;
  while(true){
    if(k % 2 == 0){
      cin >> s;
      if(s == "=") break;
    }

    if(k % 2 == 1){
      cin >> n;

      if(s == "+") ans = ans + n;
      if(s == "-") ans = ans - n;
      if(s == "*") ans = ans * n;
      if(s == "/") ans = ans / n;

    }

    k++;
  }

  cout << ans << endl;

}

Measured memory_bytes: 1204
#include <stdio.h>
#define N 10000
#define NIL -1

typedef struct {
  int p;
  int r;
  int l;
} Node;

Node T[N];

void preParse(int u){
  if(u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){

  int i, n, id, l, r, root=0;
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].p = NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d%d%d", &id, &l, &r);
    T[id].l = l;
    T[id].r = r;
    if(l != NIL) T[l].p = id;
    if(r != NIL) T[r].p = id;
  }

  for(i=0; i<n; i++){
    if(T[i].p == NIL) root = i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  
  return 0;
}

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

int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) {
        cout << S << endl;
    }
    else {
        for(int i = 0; i < K; i++) {
            cout << S[i];
        }
        cout <<"..."<< endl;
    }
}

Measured memory_bytes: 3628
a = input().split() 
n = int(a[0])
m = int(a[1])
x = int(a[2])
y = int(a[3])
a = input().split()
a = [int(s) for s in a]
x_max = max(a)
a = input().split()
a = [int(s) for s in a]
y_min = min(a)
if x_max >= y:
    print("War")
elif y_min <= x:
    print("War")
else:
    if x_max < y_min:print("No War")
    else:print("War")

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

using namespace std;
#define lint long long
#define P pair<int, int>


int main() {
    int N;
    cin >> N;
    int n = N / 2;
    int U[N / 2], V[N / 2];
    
    for(int i = 0; i < n; ++i){
        cin >> U[i] >> V[i];
    }
    
    map<int, int> CU, CV;
    
    for(int i = 0; i < n; ++i){
        CU[U[i]]++; CV[V[i]]++;
    }
    
    vector<P> LU, LV;
    
    for(auto e : CU){
        LU.push_back(make_pair(e.second, e.first));
    }
    for(auto e : CV){
        LV.push_back(make_pair(e.second, e.first));
    }
    
    sort(LU.begin(), LU.end(), greater<P>());
    if(LU.size() == 1){
        LU.push_back(make_pair(0, N + 1));
    }
    sort(LV.begin(), LV.end(), greater<P>());
    if(LV.size() == 1){
        LV.push_back(make_pair(0, N + 1));
    }
    
    if(LU[0].second != LV[0].second){
        cout << N - (LU[0].first + LV[0].first) << endl;
    } else {
        
        int num1 = N - (LU[1].first + LV[0].first);
        int num2 = N - (LU[0].first + LV[1].first);
        if(num1 >= num2){
            cout << num2 << endl;
        } else {
            cout << num1 << endl;
        }
    }
}


Measured memory_bytes: 6520
#include<iostream>
#include<string>
#include<algorithm>
#include<string.h>
int main(void) {
	std::string ss,tt;
	std::cin >> ss >> tt;
	std::sort(ss.begin(),ss.end());
	std::sort(tt.begin(), tt.end());
	char tem;
	for (int l1 = 0; l1 < tt.size()/2; l1++) {
		tem = tt.at(l1);
		tt.at(l1) = tt.at(tt.size() - l1-1);
		tt.at(tt.size() - l1-1) = tem;
	}
	if (strcmp(&ss.at(0), &tt.at(0)) >=0)
		std::cout << "No" << std::endl;
	else
		std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 256
def main():
  import bisect
  A, B, Q = map(int,input().split())
  S = [int(input()) for _ in range(A)]
  T = [int(input()) for _ in range(B)]
  X = [int(input()) for _ in range(Q)]
  S.insert(0,-float("inf"))
  S.append(float("inf"))
  T.insert(0,-float("inf"))
  T.append(float("inf"))
  for i in range(Q):
    ans = float("inf")
    #shrine start
    plc_id = bisect.bisect_left(S,X[i])
    right = bisect.bisect_left(T,S[plc_id])
    left = bisect.bisect_left(T,S[plc_id-1])
    left_d = abs(X[i] - S[plc_id-1])
    right_d = abs(X[i] - S[plc_id])
    ans = min(ans,left_d + min(abs(S[plc_id-1] - T[left-1]),abs(S[plc_id-1]-T[left])))
    ans = min(ans,right_d + min(abs(S[plc_id] - T[right-1]),abs(S[plc_id]-T[right])))
    #temple start
    plc_id = bisect.bisect_left(T,X[i])
    right = bisect.bisect_left(S,T[plc_id])
    left = bisect.bisect_left(S,T[plc_id-1])
    left_d = abs(X[i] - T[plc_id-1])
    right_d = abs(X[i] - T[plc_id])
    ans = min(ans,left_d + min(abs(T[plc_id-1] - S[left-1]),abs(T[plc_id-1]-S[left])))
    ans = min(ans,right_d + min(abs(T[plc_id] - S[right-1]),abs(T[plc_id]-S[right])))
    print(ans)
main()

Measured memory_bytes: 16176
<?php
$a[] = trim(fgets(STDIN));
$a[] = trim(fgets(STDIN));
$a[] = trim(fgets(STDIN));
$a[] = trim(fgets(STDIN));
$a[] = trim(fgets(STDIN));
$d = fgets(STDIN);

echo $a[4] - $a[0] <= $d ? "Yay!" : ":(";


Measured memory_bytes: 4856
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  cout << N * N * N << endl;
  return 0;
}


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (z < 0 || z > k) continue;
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)

i32 M = 998244353;
i32 dp[90310];
i32 dq[90310];

signed main() {
  i32 n;
  scanf("%d", &n);
  vector<i32> A(n);
  i32 sum = 0;
  REP(i, n) {
    scanf("%d", &A[i]);
    sum += A[i];
  }
  i32 lim = (sum - 1) / 2;
  dp[0] = 1;
  dq[0] = 1;
  REP(i, n) {
    RREP(t, 90000) {
      (dp[t + A[i]] += dp[t]) %= M;
      (dp[t] *= 2) %= M;
      (dq[t + A[i]] += dq[t]) %= M;
    }
  }
  i32 ans = 1;
  REP(i, n) {
    ans = (ans * 3) % M;
  }
  FOR(t, lim + 1, 90000) {
    ans = (ans - dp[t] * 3) % M;
  }
  if (sum % 2 == 0) {
    ans = (ans + dq[sum / 2] * 3) % M;
  }
  ans = (ans + M) % M;
  printf("%d\n", ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    double cnt = 0;
    FOR(i,1,n+1) if(i % 2 == 1) cnt += 1;
    double ans = cnt / n;
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main()
{
	int N, M;
	scanf("%d %d", &N, &M);
	int* k = new int[M];
	int** s = new int*[M];
	for (int i = 0; i < M; i++) {
		scanf("%d", &k[i]);
		s[i] = new int[k[i]];
		for (int j = 0; j < k[i]; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	int* p = new int[M];
	for (int i = 0; i < M; i++) {
		scanf("%d", &p[i]);
	}
	int res = 0;
	int l = 0;
	for (int i = 0; i < 1 << N; i++) {
		bool ok = true;
		for (int j = 0; j < M; j++) {
			int cnt = 0;
			for (int a = 0; a < k[j]; a++) {
				if (i & 1 << (s[j][a] - 1)) {
					cnt++;
				}
			}
			if (cnt % 2 != p[j]) {
				ok=false;
				break;
			}
		}
		if (ok) {
			res++;
		}
	}
	printf("%d", res);
}

Measured memory_bytes: 256
//$ darklife_12
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
int even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
void printvector(vector<int> v){
    int i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve()              
{
    int n,m,i,j,k;
    int a[200005],b[200005];
    int ans=0,res;
    bool flag=true;
    vector<int> v;
    string s1,s2;
    set<int> s;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    for0(i,n){
        cin>>s1;
        if(s1=="WA")wa++;
        else if(s1=="AC")ac++;
        else if(s1=="RE")re++;
        else tle++;
    }
        cout<<"AC x "<<ac<<endl;
        cout<<"WA x "<<wa<<endl;
        cout<<"TLE x "<<tle<<endl;
        cout<<"RE x "<<re<<endl;
}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
       cout<<"\n";
    }
}

Measured memory_bytes: 3580
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char c = s.charAt(0);
    if(c=='S') s = "Cloudy";
    if(c=='C') s = "Rainy";
    if(c=='R') s = "Sunny";
    System.out.println(s);
  }
}

Measured memory_bytes: 21972
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            var R = 0L; var G = 0L; var B = 0L;
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'R') R++;
                if (S[i] == 'G') G++;
                if (S[i] == 'B') B++;
            }
            var result = R * G * B;
            for (int i = 0; i < N; i++)
            {
                for (int d = 1; i + 2 * d < N; d++)
                {
                    if (S[i] != S[i + d] && S[i + d] != S[i + 2 * d] && S[i] != S[i + 2 * d]) result--;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27548
def main():
	# a,b,k = map(int,input().split())
	# n,k = map(int,input().split())
	n = str(input())
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(5)]
	# s = list(s)
	l = ['Sunny', 'Cloudy', 'Rainy']

	if n == l[0]:
		print(l[1])
	if n == l[1]:
		print(l[2])
	if n == l[2]:
		print(l[0])

 
if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
   int n;
   //vector<int> vec;
   int j[1000];

   cin >> n;

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

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

   for(int i = n - 1; i > 0; i--){
    cout << j[i] << " ";
   }

   cout << j[0] << endl;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e6 + 5;
const int mod = 1e9 + 7; 
using namespace std;

int n, m, k, fac[N], inv[N], ans, pw[N], f[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

int C(int n, int m)
{
	if(n < m || m < 0 || n < 0) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> (), m = read <int> (), k = read <int> ();
	for(int i = (fac[0] = 1); i <= n + m + k; i++) fac[i] = 1ll * fac[i - 1] * i % mod; 
	inv[n + m + k] = fpow(fac[n + m + k], mod - 2);
	for(int i = n + m + k - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod; 
	for(int i = (pw[0] = 1); i <= n + m + k; i++) pw[i] = 1ll * pw[i - 1] * 3 % mod; 
	for(int t = 0; t <= m + k; t++)
	{
		if(!t) f[t] = 1;
		else f[t] = 2ll * f[t - 1], f[t] = (1ll * f[t] - C(t - 1, t - 1 - k) - C(t - 1, m) + 2ll * mod) % mod;
		ans = (1ll * pw[m + k - t] * C(n + t - 1, n - 1) % mod * f[t] + ans) % mod; 
	}
	printf("%d\n", ans); 
	return 0; 
}


Measured memory_bytes: 15928
#include <iostream>

using namespace std;

int map[101][101];
int xg, yg;
int w, h;
int col;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
bool flag;

void dfs(int x, int y)
{
  map[y][x] = 0;
  
  if (x == xg && y == yg) {
    flag = true;
    return ;
  }
  
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    
    if (nx < 0 || ny < 0 || nx >= w || ny >= h)
      continue;
    else if (map[ny][nx] == col)
      dfs(nx, ny);
    }
}

void setblock(int c, int d, int bx, int by)
{
  int wlim = 4, hlim = 2;
  
  if (d == 1) {
    wlim = 2;
    hlim = 4;
  }
  
  for (int y = 0; y < hlim; y++)
    for (int x = 0; x < wlim; x++)
      map[by + y][bx + x] = c;
}

 
int main()
{
  while (cin >> w >> h, w || h) {
    int xs, ys;
    int n;
    
    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++)
                map[y][x] = 0;
    
    cin >> xs >> ys >> xg >> yg >> n;
    
    xs--, ys--, xg--, yg--;
    for (int i = 0; i < n; i++) {
      int c, d, x, y;
             
      cin >> c >> d >> x >> y;
      x--, y--;            
      setblock(c, d, x, y);
    }
    col = map[ys][xs];
    flag = false;
    if (col)
      dfs(xs, ys);
 
    if (flag)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main() {
    
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int cnt = 0;
    while(b <= a) {
        b*=2;
        cnt++;
    }
    while(c <= b) {
        c *= 2;
        cnt++;
    }

    if(cnt <= k) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	long long int a,b,c,x=0,da,db,dc;
	cin >> a >> b >> c;
	
	if(!(a == b && b == c && a % 2 == 0)){
		while(a % 2 != 1 && b % 2 != 1 && c % 2 != 1){
			da = a;
			db = b;
			dc = c;
			a = db/2 + dc/2;
			b = da/2 + dc/2;
			c = da/2 + db/2;
			x++;
		}
		cout << x << endl;
	}
	
	else{
		cout << "-1" << endl;
	}
	
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

constexpr int M = 1000000;
int dp[M + 5];
int cnt[M + 5];

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

    int N;
    cin >> N;
    int G = 0;
    dp[0] = dp[1] = 1;
    for(int i = 2; i <= M; ++i){
        if(dp[i])   continue;
        dp[i] = i;
        for(int j = i + i; j <= M; j += i){
            if(!dp[j])  dp[j] = i;
        }
    }
    bool pairwise = true;
    for(int i = 0; i < N; ++i){
        int A;
        cin >> A;
        G = gcd(G, A);
        vector<int> prime(1, 1);
        while(A != 1){
            if(dp[A] != prime.back())   prime.emplace_back(dp[A]);
            A /= dp[A];
        }
        for(int j = 1; j < (int)prime.size(); ++j){
            if(cnt[prime[j]])   pairwise = false;
            ++cnt[prime[j]];
        }
    }
    if(G > 1)   cout << "not coprime\n";
    else if(pairwise)   cout << "pairwise coprime\n";
    else    cout << "setwise coprime\n";
}

Measured memory_bytes: 11404
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int H, W, max_ = 0;

	scanf("%d", &H);
	scanf("%d", &W);

	vector<vector<int> > c(H, vector<int>(W));

	vector<vector<int> > dp(H, vector<int>(W, 0));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			scanf("%d", &c[i][j]);

			if (c[i][j] == 0)
			{
				if (i == 0 || j == 0)
				{
					dp[i][j] = 1;
				}

				max_ = 1;
			}
		}
	}

	for (int i = 1; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			if (c[i][j] == 0)
			{
				dp[i][j] = min({ dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1] }) + 1;

				max_ = max(dp[i][j], max_);
			}
		}
	}

	printf("%d\n", max_ * max_);

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vll h(n);
    rep(i,n) cin>>h[i];
    sort(all(h));
    ll ans=0;
    rep(i,n-k){
        ans+=h[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();

        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = sc.nextInt();
        }

        double min = Double.MAX_VALUE;
        int ret = -1;

        for (int i = 0; i < N; i++) {
            double t = T - H[i] * 0.006;

            double diff = Math.abs(t - A);
            if (diff < min) {
                ret = i;
                min = diff;
            }
        }

        System.out.println(ret+1);
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(){
	long long n, k, a, dummy;
	scanf("%lld %lld",&n,&k);
	a = n%k;
	dummy = a-k;
	if(dummy<0) dummy*=-1;
	if(dummy<a) printf("%lld",dummy);
	else printf("%lld",a);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(),a.end());
    if(n%2){
        if(a[0]!=0){
            cout<<"0"<<endl;
            return 0;
        }
        for(int i=1; i<n; i+=2){
            if(i+1!=a[i]){
                cout<<"0"<<endl;
                return 0;
            }
        }
    }else{
        for(int i=0; i<n; i+=2){
            if(i+1!=a[i]){
                cout<<"0"<<endl;
                return 0;
            }
        }
    }
    ll ans=1;
    ll mod=1e9+7;
    for(int i=0; i<n/2; i++){
        ans*=2;
        ans%=mod;
    }
    cout<<ans<<endl;
}

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

int main(int argc, char const *argv[])
{
    int l, r, m = 2019;
    cin >> l >> r;
    if (l +m < r)
    {
        cout << 0 << endl;
        return 0;
    }

    int n = l/m;
    r = r - m*n;
    l %= m;
    if(l >= r) r += m;
    int ans = m;
    for (int i = l; i < r; i++)
    {
        for (int j = i+1; j < r+1; j++)
        {
            ans = min(ans, i*j%m);
        }

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


Measured memory_bytes: 256
'''a,b = map(int,input().split())
d = a // b
r = a % b
f = a / b
print('{:.d} {:.d} {:.10f}',(d,r,f))'''
a,b = map(int,input().split())

print("%d %d %.10f"%(a/b,a%b,a/b))


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

int main() {
  string s; cin >> s;
  int sz = s.size();
  if (s[0] != 'A' || s[1] < 'a' || s[sz-1] < 'a') {
    cout << "WA\n";
    return 0;
  }
  int C = 0;
  for (int i=2; i<sz-1; ++i) {
    if (s[i] == 'C') ++C;
    else if (s[i] < 'a') {
      cout << "WA\n";
      return 0;
    }
  }
  cout << (C == 1 ? "AC\n" : "WA\n");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int ans = 100000;
		int temp;
		
		for(int i = 0; i < n; i++){
			ans *= 1.05;
			temp = ans / 1000 * 1000;
			if(ans != temp)ans = temp + 1000;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 26232
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int> C(N),S(N),F(N);
  for(int i=0;i<N-1;i++){
    cin>>C[i]>>S[i]>>F[i];
  }
  for(int i=0;i<N-1;i++){
    int tmp=0;
    for(int j=i;j<N-1;j++){
      if(tmp<S[j]){
        tmp=S[j];
      }else{
        tmp=(tmp+F[j]-1)/F[j]*F[j];
      }
      tmp+=C[j];
    }
    cout<<tmp<<endl;
  }
  cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string print[]={"Three" , "Four"};
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    set<char> st;
    for(ll i=0;i<n;i++){
        char ch;cin>>ch;
        st.insert(ch);
    }
    cout<<print[st.size()-3];
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let a = scan.chars();
    let n = a.len();
    let mut ret = n as i64*(n as i64-1) / 2;
    let mut cnt = vec![0i64;26];
    for k in a {
        cnt[k as usize - 'a' as usize] += 1;
    }
    for i in 0..26 {
        ret -= cnt[i] * (cnt[i] - 1) / 2;
    }
    println!("{}", ret+1);
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif

const int MOD = 1000000007;

int main(){
    IOS;

    int n;
    cin >> n;
    string s = "";
    for (int i = 1; i <= n; i++){
        s += to_string(i);
    }
    string p = "";
    string q = "";
    for (int i = 1; i <= n; i++){
        string x;
        cin >> x;
        p += x;
    }

    for (int i = 1; i <= n; i++){
        string x;
        cin >> x;
        q += x;
    }

    int a = 0;
    int b = 0;

    int i = 0;
    do {
        i++;
        if (s == p){
            a = i;
        }
        if (s == q){
            b = i;
        }
    }while(next_permutation(s.begin(), s.end()));

    cout << abs(a - b) << endl;

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18 + 1
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int dp[10005][101][2];

int compute(string &k, int& D, int pos, int d, bool tight){
    
    if(dp[pos][d][tight] != -1) 
        return dp[pos][d][tight];

    int ub = (tight) ? (k[pos] - '0') : 9;
    
    if(pos == k.length()-1){
        int ans=0;
        forI(x, 0, ub)
            if(x%D == d)    ans++;
        return ans;
    }
    int ans=0;
    forI(x, 0, ub)
        ans = (ans + compute(k, D, pos+1, (D+d-x%D)%D, tight && (x == ub)))%mod;
    
    return dp[pos][d][tight] = ans;
}

void solve(){
    string k; int d;   cin>>k>>d;
    memset(dp, -1, sizeof dp);
    cout<<(mod+compute(k, d, 0, 0, 1)-1)%mod;
}   

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 20400
#include <iostream>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;

int main()
{
    int a[10],b[10],i,j;
    long long int k=0;
    for(i=0;i<10;i++){
        a[i]=0;
    }
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        a[i]=0;
    }
    for(i=0;i<s.size();i++){
        stringstream ss;
        ss<<s[i];
        ss>>b[i];
    }
    for(i=0;i<s.size();i++){
        for(j=0;j<i;j++){
            a[j]=a[j]*10+pow(2,i-1);
        }
        a[j]=a[j]*10+pow(2,i);
    }
    for(i=0;i<s.size();i++){
        k=k+(long long int)a[i]*b[i];
    }
    cout<<k;
    return 0;
}

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

#define int long long 

using ll=long long;
using P=pair<int,int>;

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

int n;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}


string s;
ll k;


void solve(){
    cin>>s;
    cin>>k;
    int idx=1;
    bool flag=true;
    if(s.size()!=1)
        for(int i=1; i<s.size(); i++){
            if(i==s.size()-1)idx=s.size();
            if(s[i]!=s[i-1]){
                idx=i;
                flag=false;
            }
        }
    if(flag){
        cout<<idx*k/2<<endl;
        return;
    }
    int cnt=1;
    int a0=0;
    int a1=0;
    int alast=s.size()-idx;
    for(int i=1; i<idx; i++){
        if(s[i]!=s[i-1]){
            a0+=cnt/2;
            cnt=1;
        }else{
            cnt++;
        }
    }
    a0+=cnt/2;
    //cout<<a0<<endl;
    string s1=s+s;
    cnt=1;
    for(int i=1; i<s.size()+idx; i++){
        if(s1[i]!=s1[i-1]){
            a1+=cnt/2;
            cnt=1;
        }else{
            cnt++;
        }
    }
    //cout<<cnt<<endl;
    a1+=cnt/2;
    //cout<<a1<<endl;
    //cout<<alast/2<<endl;
    cout<<a0+(a1-a0)*(k-1)+alast/2<<endl;
}

signed main(){
    //while(1)
    solve();
}


Measured memory_bytes: 256