akhauriyash/Code-Regression huggingface dataset:
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
to,xo,yo=0,0,0
for _ in range(n):
    t,x,y=map(int,input().split())
    dt=t-to
    dz=abs(xo-x)+abs(yo-y)
    if dz>dt or (dt-dz)&1:
        print('No')
        sys.exit()
    to,xo,yo=t,x,y
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    
    int n,k;
    cin>>n>>k;
    
    ll ans = 1LL*n*n;
    
    if(k==0){
        cout << ans << endl;
        return 0;
    }
    
    for(int b=1; b<=n; b++){
        if(b>k)ans -= n/b * k + min( k, n%b+1 ) - 1;
        else ans -= n;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;
int main(){
	cin >> s;
	int ans = 0;
	rep(i,s.size()){
		ans += (s[i] == '1');
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
ll mod = LLONG_MAX;
ll power(ll a, ll b)
{
	if(b == 0) return 1;
	ll ans = power(a, b/2);
	ans = (ans*ans)%mod;
	if(b%2) ans*=a;
	return ans%mod;
}
ll mul(ll a,ll n, ll mod)
{
	ll ret;
	if(n==0) return 0;
	ret = mul(a,n/2, mod);
	ret = (ret+ret)%mod;
	if(n%2)	ret=(ret+a)%mod;
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	ll a, b;
	cin >> a >> b;
	cout << a*b;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int cnt[11];
main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        for(int i=1;i<=10;i++)cnt[i]=0;
        cnt[a]=cnt[b]=cnt[c]=1;
        int s=0;
        for(int i=1;i<=10;i++)
        {
            if(!cnt[i]&&a+b+i<=20)s++;
        }
        cout<<(s>3?"YES":"NO")<<endl;
    }
}


Measured memory_bytes: 3044
def main():
    Input = [input() for i in range(1)]
    #N = int(Input[0])
    A,B = list(map(int,Input[0].split()))
    if A>9 or B>9:
        print(-1)
    else:
        print(A*B)
    


if __name__ == "__main__":
    main()
    


Measured memory_bytes: 2940
n = int(input())
d1 = [0] * n
d2 = [0] * n
for i in range(n):
  d1[i], d2[i] = (map(int, input().split()))
cnt = 0

for i in range(n):
  if d1[i] == d2[i]:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    break

if cnt >= 3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9188
import sys
sys.setrecursionlimit(10**7)

N = int(input())
src = [tuple(map(int, input().split())) for _ in range(N-1)]
es = [[] for _ in range(N)]
for a, b, c in src:
    es[a-1].append((b-1, c))
    es[b-1].append((a-1, c))

Q, K = map(int, input().split())
qs = [tuple(map(int, input().split())) for _ in range(Q)]
K -= 1

INF = 10 ** 12
dist = [INF] * N

def dfs(v, p=-1, d=0):
    dist[v] = d
    for nv, c in es[v]:
        if nv == p:
            continue
        dfs(nv, v, d+c)

dfs(K, -1, 0)
for x, y in qs:
    print(dist[x-1]+dist[y-1])

Measured memory_bytes: 221572
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <limits>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)
// For debug
#ifdef _DEBUG
#define DD(x) cerr << #x << ":" << x << endl;
#define DDA(ary) \
cerr << #ary << ":" << endl;\
for (auto v : ary) { cerr << v << ","; }\
cerr << endl;
#else
#define DD(x)
#define DDA(ary)
#endif

const int MAX_N = 100005;
int a[MAX_N];
int main() {
	int n, t;
	cin >> n >> t;
	REP(i, n) cin >> a[i];
	int maxV = 0;
	int cnt = 0;
	int low = a[0];
	int l, r;
	l = 0; r = 1;
	for (r = 1; r < n; r++) {
		int v = a[r] - a[l];
		if (v > maxV) {
			maxV = v;
			cnt = 1;
		}
		else if (v == maxV) {
			cnt++;
		}

		if (a[r] < low) {
			l = r;
			low = a[l];
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 640
n, x = map(int, input().split())
listA = list(map(int, input().split()))
listSum =0
for a in listA:
    listSum+=a

if listSum == x:
    print(n)
elif listSum < x:
    print(n-1)
else:
    listA.sort()
    index =0
    sum =0
    while sum < x+1:
        sum += listA[index]
        index+=1
    print(index-1)

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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int a;
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    ans += (D - 1) / a + 1;
  }
  ans += X;
  cout << ans << endl;

  return 0;
}

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

int main() {
    string s;
    cin>>s;
    int a=s[0]=='A',c=0,u=0;
    for (int i=1;i<s.size();i++) {
        if (2<=i&&i<=s.size()-2&&s[i]=='C')
            c++;
        else
            u+=isupper(s[i]);
    }
    if (a&&c==1&&u==0)
        puts("AC");
    else
        puts("WA");
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {

  static long n, m, k, ans;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Long.parseLong(in[0]);
    m = Long.parseLong(in[1]);
    k = Long.parseLong(in[2]);

    br.close();

    CombMod cm = new CombMod(300_010);
    MyMod mm = new MyMod(0L);

    for (int i = 0; i <= k; i++) {
      mm.add(
          MyMod.mul(MyMod.mul(m, cm.combMOD((int) n - 1, (int) i)), MyMod.pow(m - 1, n - 1 - i)));
    }

    out.println(mm.val);

    out.flush();
  }
}

class MyMod {

  static final long MOD = 998244353L;
  public long val;

  MyMod(long val) {
    this.val = val;
  }

  MyMod() {
    this(0L);
  }

  public static long add(long a, long b) {
    return (a % MOD + b % MOD) % MOD;
  }

  public static long sub(long a, long b) {
    return ((a % MOD - b % MOD) + MOD) % MOD;
  }

  public static long mul(long a, long b) {
    return (a % MOD * b % MOD) % MOD;
  }

  public static long div(long a, long b) {
    return (a % MOD * pow(b, MOD - 2) % MOD) % MOD;
  }

  // calc a^b
  // b <= 0 は1を返す
  public static long pow(long a, long b) {
    long result = 1L;
    a %= MOD;
    while (b > 0) {
      if (b % 2 == 1) result = (result * a) % MOD;
      a = (a * a) % MOD;
      b = (b >> 1);
    }
    return result;
  }

  // calc inverse element
  public static long invEle(long a) {
    return pow(a % MOD, MOD - 2) % MOD;
  }

  public void add(long a) {
    val = add(val, a);
  }

  public void sub(long a) {
    val = sub(val, a);
  }

  public void mul(long a) {
    val = mul(val, a);
  }

  public void div(long a) {
    val = div(val, a);
  }
}

/*
MODの値と計算はMyModクラスに依存
 */
class CombMod {

  // デフォルトのMAX値
  static final int MAX = 200_010;

  List<Long> fac;
  List<Long> finv;

  CombMod() {
    combIni(MAX);
  }

  CombMod(int m) {
    fac = new ArrayList<>();
    finv = new ArrayList<>();
    combIni(m);
  }

  void combIni(int max) {
    fac.add(1L);
    fac.add(1L);
    finv.add(1L);
    finv.add(1L);
    for (int i = 2; i <= max; i++) {
      fac.add(MyMod.mul(fac.get(i - 1), i));
      finv.add(MyMod.div(finv.get(i - 1), i));
    }
  }

  long combMOD(int n, int r) {
    if (n < r) return 0L;
    if (n < 0 || r < 0) return 0L;
    if (r == 0) return 1L;
    return MyMod.mul(fac.get(n), MyMod.mul(finv.get(r), finv.get(n - r)));
  }
}


Measured memory_bytes: 62684
import itertools

NMX = list(map(int, input().split()))
N = NMX[0]
M = NMX[1]
X = NMX[2]

CA = []
for i in range(N):
    CA.append(list(map(int, input().split())))

allbooks = [sum([j[i] for j in CA]) for i in range(M+1)]

#print(allbooks)
if min(allbooks[1:]) < X:
    print(-1)
else:
    kingaku = allbooks[0]
    yobun = [i-X for i in allbooks[1:]]

    maxkingaku = 0
    go = True
    for k in range(1, N):
        if go == False:
            break
        allicombi = itertools.combinations(CA, k)
        OKs = 0
        for combi in allicombi:
            goukei = [sum([j[i] for j in combi]) for i in range(M+1)]
            if min([y-x for x,y in zip(goukei[1:], yobun)])>=0:
                OKs +=1
                if goukei[0] > maxkingaku:
                    maxkingaku = goukei[0]

        if OKs == 0:
            go = False
    print(kingaku - maxkingaku)


Measured memory_bytes: 9236
#include <iostream>
#include <string>
#include <cstdio>
#include <cctype>
#include <cstring>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(cin>>n && n){
        static char g[2000][2000];
        memset(g,0,sizeof(g));
        rep(i,n){
            cin >> g[i];
            for(int j=0; g[i][j]=='.'; j++){
                if(g[i][j+1]=='.'){
                    g[i][j] = ' ';
                }else{
                    g[i][j] = '+';
                    break;
                }
            }
        }
        for(int i=1; i<n; i++){
            int j=0;
            for(;g[i][j]!='+'; j++);
            int ii=i+1;
            for(;g[ii][j]==' '; ii++);
            if(g[ii][j]!='+') continue;
            for(int y=i+1;y<ii; y++){
                g[y][j]='|';
            }
        }

        rep(i,n){
            cout << g[i]<<endl;
        }
    }
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n;
	string s,t;
	cin>>n>>s>>t;
	for(int i=0;i<int(s.size());++i){
		cout<<s[i]<<t[i];
	}
	cout<<endl;
	return 0;
}

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

int main(void)
{
  char s[10];
  scanf("%s",s);

  int i,slen,x,min=1000;
  slen=strlen(s);
  for(i=0;i<slen-2;i++){
    x = 100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0');
    x -= 753;
    if(x<0)
      x = -x;
    if(x<min)
      min = x;
  }
  
  printf("%d\n",min);
  return 0;
}

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

const long long MOD = 1e9+7;

long long ways[1000005];
long long invFact[1000005];
long long fact[1000005];
long long inv[1000005];
long long prefixSum[1000005];

long long ncr(int n, int r){
    return (fact[n]*invFact[n-r]%MOD)*invFact[r]%MOD;
}

int main(){
    int N;
    scanf("%d", &N);

    inv[1] = 1;
    for(int i = 2; i <= N; i ++){
        inv[i] = inv[MOD%i]*(MOD-MOD/i)%MOD;
    }

    fact[0] = 1;
    invFact[0] = 1;
    for(int i = 1; i <= N; i ++){
        fact[i] = i*fact[i-1]%MOD;
        invFact[i] = inv[i]*invFact[i-1]%MOD;
    }

    int n = N-1;
    for(int k = 1+n/2; k <= n; k ++){
        int l = n-k; // remaining to put at the back
        // (5 choose 3)*(6!)*(2!)

        // 2*x + 1*(k-1-x) = n-1
        // 2*x + k-1-x = n-1
        // 2*x + k-x = n
        // x + k = n
        // x = n-k
        prefixSum[k] = ((ncr(k-1, n-k)*fact[k]%MOD)*fact[l])%MOD; // have to exclude 1 and n, which is a must
        //printf("k=%d n=%d prefixSum[%d]=%lld\n", k, n, k, prefixSum[k]);
    }

    long long ans = 0;
    for(int i = n; i >= 1; i --){
        ans += i*(prefixSum[i]-prefixSum[i-1]+MOD)%MOD;
        //printf("%7d ", prefixSum[i]);
    }

    ans %= MOD;
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 31180
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,k,d=0;
  cin>>a>>b>>k;
  if(k>a)
    
    	cout<<"0 "<<max(b-k+a,d)<<endl;
  else
    cout<<a-k<<" "<<b<<endl;
  return 0;
}

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

int main(){
	vector<long> cnt(30, 0);
	cnt[0] = cnt[1] = cnt[2] = 1;
	for(int i = 0; i < 30; i++){
		for(int j = 1; j <= 3; j++){
			if(i+j < 30) cnt[i+j] += cnt[i];
		}
	}
	int n;
	while(cin >> n && n) cout << cnt[n-1] / 3650 + 1 << endl;
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

#define LL long long

LL sum;

int gcd(int a,int b){

	return b?gcd(b,a%b):a;

}

int main(){

	int n,a,b,c,d;

	scanf("%d",&n);

	for(a=1;a<=n;a++)

		for(b=1;b<=n;b++)

			for(c=1;c<=n;c++)

				d=gcd(a,b),d=gcd(c,d),sum+=d;

	printf("%lld\n",sum);

	return 0;

}


Measured memory_bytes: 1728
#include<stdio.h>
#include <string.h>
void BubbleSort(int a[], int N){
  int flag=1,i=0,j,tmp;
  while(flag==1){
    flag=0;
    for(j=N-1;j>i;j--){
      if(a[j]<a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	flag=1;
      }
    }
    i++;
  }
}
int main(){
  int N[3],s,t,i,M;
  scanf("%d %d %d",&N[0],&N[1],&N[2]);
  BubbleSort(N, 3);
  s=N[2]-N[1];
  t=N[2]-N[0];
  if(s%2==t%2){
    printf("%d",(s+t)/2);
  }else{
    printf("%d",(s+t+3)/2);
  }
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)	{rep(i,a.size())	cout<<a[i]<<" "; cout<<endl;}
#define mark(v)	cout<<"Here--"<<v<<endl;

const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision

   int n ; cin>>n;
   int dp[3] ={0} ;
   int c[3] = {0};
   rep(days,n){
      cin>>c[0]>>c[1]>>c[2];
      int new_dp[3] = {0};
      rep(i,3){
         rep(j,3){
            if(i!=j){
               new_dp[j] = max(new_dp[j],dp[i]+c[j]);
            }
         }
      }
      dp[0] = new_dp[0];
      dp[1] = new_dp[1];
      dp[2] = new_dp[2];
   }

   cout<<max(dp[0],max(dp[1],dp[2]));

    return 0;
}  

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int m = -1,ans;
    rep(i,1,n+1){
        int cnt = 0,a = i;
        while(a%2 == 0){
            a /= 2;
            cnt++;
        }
        if (chmax(m,cnt)) ans = i;
    }
    PRINT(ans);
}


Measured memory_bytes: 256
use std::io::Read;

#[allow(non_snake_case)]
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let H: i32 = iter.next().unwrap().parse().unwrap();
    let W: i32 = iter.next().unwrap().parse().unwrap();
    let h: i32 = iter.next().unwrap().parse().unwrap();
    let w: i32 = iter.next().unwrap().parse().unwrap();

    if H % h != 0 {
        println!("Yes");
        for i in 0..H {
            for j in 0..W {
                if j > 0 {
                    print!(" ");
                }
                if i % h == 0 {
                    print!("{}", H - 1);
                } else if (i + 1) % h == 0 {
                    print!("{}", -H);
                } else {
                    print!("0");
                }
            }
            println!();
        }
    } else if W % w != 0 {
        println!("Yes");
        for i in 0..H {
            for j in 0..W {
                if j > 0 {
                    print!(" ");
                }
                if j % w == 0 {
                    print!("{}", W - 1);
                } else if (j + 1) % w == 0 {
                    print!("{}", -W);
                } else {
                    print!("0");
                }
            }
            println!();
        }
    } else {
        println!("No");
    }
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int n ,m; cin>>n>>m;
vin h (n);
F (i,0,n,1) cin>>h[i];
mpin mp;
F (i,0,m,1) {
  int a , b; cin>>a>>b;
  --a , --b;
  mp[a]=max (mp[a] , h[b]);
  mp[b]=max (mp[b], h[a]);
}
int cnt=0;
F (i,0,n,1) {
  if (mp[i]<h[i]) ++cnt;
}
cout<<cnt;
return 0;
}


Measured memory_bytes: 8340
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int N;
    io.read(N);
    auto B = io.read_vec<int>(N - 1);
    int ans = B[0] + B[N - 2];
    for(int i = 0; i < N - 2; i++){
        ans += min(B[i], B[i + 1]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("-1"); exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


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

  bitset<4000000> dp;
  dp[0] = 1;

  int sum = 0;
  rep(i, n) {
    dp |= (dp<<a[i]);
    sum += a[i];
  }

  int ans = (sum+1)/2;
  while (!dp[ans]) ++ans;
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5152
#include <cstdio>
#include <cstdlib>
#include <cstring>

int h, w;
bool isRowHasBlack[110];
bool isColHasBlack[110];
char board[110][110];

int main()
{
	scanf("%d%d", &h, &w);
	
	for (int i = 0 ; i < h ; i++)
		scanf("%s", board[i]);
	
	memset(isRowHasBlack, false, sizeof(isRowHasBlack));
	memset(isColHasBlack, false, sizeof(isColHasBlack));
	
	for (int r = 0 ; r < h ; r++)
		for (int c = 0 ; c < w ; c++)
		{
			if (board[r][c] == '#')
			{
				isRowHasBlack[r] = true;
				isColHasBlack[c] = true;
			}
		}
		
	for (int r = 0 ; r < h ; r++)
	{
		if (isRowHasBlack[r] == false)
			continue;
		
		for (int c = 0 ; c < w ; c++)
			if (isColHasBlack[c] == true)
				printf("%c", board[r][c]);
				
		printf("\n");
	}
	
	return 0;
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector <vector <long long>> dp(n, vector <long long> (n, LLONG_MAX));
	for (int i = 0; i < n; i++) {
		dp[i][i] = 0;
	}
	for (int len = 0; len < n; len++) {
		for (int l = 0; l < n - len; l++) {
			long long r = l + len, cumSum = 0;
			assert(r < n);
			for (int i = l; i <= r; i++) {
				cumSum += a[i];
			}
			for (int k = l; k < r; k++) {
				dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + cumSum);
			}
		}
	}
	cout << dp[0][n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 4520
import heapq


def dijkstra(adj, start, goal=None):
    num = len(adj)          # グラフのノード数
    dist = [float('inf') for i in range(num)]  # 始点から各頂点までの最短距離を格納する
    prev = [float('inf') for i in range(num)]  # 最短経路における，その頂点の前の頂点のIDを格納する

    dist[start] = 0
    # プライオリティキュー．各要素は，(startからある頂点vまでの仮の距離, 頂点vのID)からなるタプル
    q = []
    heapq.heappush(q, (0, start))  # 始点をpush

    while q:
        prov_cost, src = heapq.heappop(q)  # pop

        # プライオリティキューに格納されている最短距離が，現在計算できている最短距離より大きければ，distの更新をする必要はない
        if dist[src] < prov_cost:
            continue

        # 他の頂点の探索
        for dest in range(num):
            cost = adj[src][dest]
            if cost != float('inf') and dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost  # distの更新
                # キューに新たな仮の距離の情報をpush
                heapq.heappush(q, (dist[dest], dest))
                prev[dest] = src                      # 前の頂点を記録

    return dist


n, m = map(int, input().split())
mat = [[float('inf')] * n for _ in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    mat[a - 1][b - 1] = c
    mat[b - 1][a - 1] = c
for i in range(n):
    mat[i][i] = 0
mat2 = []
for i in range(n):
    mat2.append(dijkstra(mat, i))
ans = 0
for i in range(n):
    for j in range(i, n):
        if mat[i][j] != float('inf') and mat[i][j] != mat2[i][j]:
            ans += 1
print(ans)


Measured memory_bytes: 3568
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
	std::cin >> N;
	std::vector<int64_t> h(N);
	for (auto& elem : h) {
		std::cin >> elem;
	}

	bool ans_fg = true;
	int64_t ans = 0;
	while(ans_fg) {
		bool water_fg = false;
		for (int64_t i = 0; i < N; i++) {
			if (h[i] != 0 && !water_fg) {
				water_fg = true;
			}
			if (h[i] == 0 && water_fg) {
				ans++;
				water_fg = false;
			}
			if (h[i] != 0) {
				h[i]--;
			}
		}
		if (water_fg) {
			ans++;
		}
		int64_t judge = 0;
		for (int i = 0; i < N; i++) {
			judge += h[i];
		}
		if (judge == 0) {
			ans_fg = false;
		}
	}

	std::cout << ans << std::endl;

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 256
w, h , x, y, r = map(int, input().split())
# x - r が0 より小さい、または、x + r がW より大きいならばNoと判定。

if x - r < 0 or x + r > w:
  print("No")
# x - r が0 以上、かつ、x + r がW 以下ならばYesと判定。
elif y - r < 0 or y + r >h:
  print("No")
elif x - r >= 0 and x + r <= w:
  print("Yes")
elif y - r >= 0 and y + r <= h:
  print("Yes")


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

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

  sort(d.begin(), d.end());

  cout << d[n/2] - d[(n-1) / 2] << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define N 
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
int n;
int l[20];
bool vis[20];
int main(){
	int maxn=0,sum=0;
	read(n);
	for(int i=1;i<=n;i++) read(l[i]);
	for(int i=1;i<=n;i++){
		if(l[i]>maxn){
			maxn=l[i];
		}
	}
	for(int i=1;i<=n;i++){
		if(l[i]==maxn){
			vis[i]=1;
			break;
		}
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]) sum+=l[i];
	}
	if(maxn<sum) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
import math
import fractions
A,B,C,D = map(int,input().split())
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)
def cal(n,x,y):
    return n-(n//x + n//y - n//lcm(x,y))
print(cal(B,C,D)-cal(A-1,C,D))

Measured memory_bytes: 5048
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        Int n;
        cin >> n;
        Int ans = n * n * n;
        cout << ans << endl;
        

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
from collections import deque
r, c = map(int, input().split())

MAX = (r+2) * (c + 2)

sy = 0
sx = 0
gx = c-1
gy = r-1

maze = [[val for val in list(input())] for _ in range(r)]
checked_maze = [[None for _ in range(c)] for _ in range(r)]
goal = [False]

def wfs(queue):
    while len(queue) > 0:
        a = queue.popleft()
        y = a[0]
        x = a[1]
        count = a[2]
        if x < 0 or x > c-1 or y < 0 or y > r-1:
            continue
        if checked_maze[y][x]:
            continue

        if a[0] == gy and a[1] == gx:
            goal[0] = count
            break

        checked_maze[y][x] = True
        if not maze[y][x] == "#":
            count += 1
            queue.append((a[0]+1, a[1], count))
            queue.append((a[0]-1, a[1], count))
            queue.append((a[0], a[1]+1, count))
            queue.append((a[0], a[1]-1, count))


if __name__ == "__main__":
    que = deque()
    checked_maze[sy][sx] = 0
    que.append((sy, sx, 0))
    wfs(que)
    if not goal[0]:
        print(-1)
    else:
        masu = r * c
        blocks = 0
        for r_index in range(r):
            for c_index in range(c):
                if maze[r_index][c_index] == "#":
                    blocks += 1
        print(masu-goal[0]-1 -blocks)

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

int main()
{
    int A, B;
    cin >> A >> B;
    for (int i = 13; i <= 1250; i++)
    {
        if ((floor(i * 0.08) == A) && (floor(i * 0.1) == B))
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

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

typedef long long ll;
#define pb push_back
#define mp make_pair


void solve()
{
	ll  a, b;
	cin >> a >> b;

	cout << a*b;
}


int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	// cin >> t;

	while (t--)
	{
		solve();
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 3652
while True:
    l = list(map(int,input().split()))
    a,b =l[0],l[1]
    if a == 0 and b == 0 :
        break
    for i in range(a):
        for j in range(b):
            k = i+j
            if k%2 ==0 :
                print("#",end = "")
            else:
                print(".",end = "")
        print()
    print()


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

int main() {

  long long a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k <= a) cout << k << endl;
  else if (k <= a + b) cout << a << endl;
  else cout << a-(k-a-b) << endl;

}

Measured memory_bytes: 3644
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	vector<int> AB,P;
	vector<int>::iterator it;
	int maxpoint = 0,n,m,in,key,c;

	cin >> n >> m;
	while(n != 0 && m != 0){

	for(int i = 0; i < n; i++){
		cin >> in;
		P.push_back(in);
	}

	P.push_back(0);
	sort( P.begin(),P.end() );

	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			AB.push_back(P[i]+P[j]);
		}
	}

	AB.push_back(m+1);
	sort( AB.begin(),AB.end() );

	for(int i = 0; i < AB.size() ; i++){
		key = m - AB[i];
		if(key < 0)	break;
		else	c = upper_bound(AB.begin(),AB.end(),key) - AB.begin() - 1;
		maxpoint = max(maxpoint,AB[i] + AB[c]);
	}

	cout << maxpoint << endl;
	
	maxpoint = 0;	
	AB.clear();
	P.clear();

	cin >> n >> m;
	}
	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

const double EPS = 1e-9;
const double PI = 3.1415926535;

struct Point {
	double x, y;
	Point(double _x, double _y) : x(_x), y(_y) {}
};

double sqr(double x) {
	return x*x;
}

double angle(double a, double b, double c) {
	return acos((sqr(b) + sqr(c) - sqr(a)) / (2.0*b*c));
}

double dist(Point a, Point b) {
	return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}

int n;
double r, T;
vector< Point > vp;

bool able[22][22][22];
double dst[22][22], dp[10010][22][22];

void update(double& a, double b) {
	a = min(a, b);
}

void solve() {	
	memset(able, 0, sizeof(able));
	for_(i,0,n) able[0][0][i] = 1;
	
	for_(i,0,n) for_(j,0,n) {
		dst[i][j] = dist(vp[i], vp[j]);
		
		if (i != j) {
			for_(k,0,n) {
				if (i != k && j != k) {
					double s = angle(dist(vp[i], vp[k]), dist(vp[i], vp[j]), dist(vp[j], vp[k]));
					double t = 180. - s * 180. / PI;
					able[i][j][k] = (t + EPS < T);
				}
			}
		}
	}
	
	for_(i,0,10010) for_(j,0,n) for_(k,0,n) dp[i][j][k] = 1e9;
	dp[0][0][0] = 0;
	
	int ans = 0;
	
	for_(i,0,10010) for_(j,0,n) for_(k,0,n) {
		if (dp[i][j][k] + EPS < r) {
			ans = i;
			
			for_(v,0,n) {
				if (k != v && able[j][k][v]) {
					update(dp[i+1][k][v], dp[i][j][k] + dst[k][v]);
				}
			}
		}
	}
	
	cout << ans << endl;
}

int main() {
	cin >> n;
	cin >> r >> T;
	
	for_(i,0,n) {
		double x, y; cin >> x >> y;
		vp.push_back(Point(x, y));
	}
	
	solve();
	
	return 0;
}

Measured memory_bytes: 39188
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
lli gcd(lli a, lli b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main() 
{
    
    lli n, k = 0,c, ans = 0, r = 1;
    cin >> n;
    if(n % 2)
    {
        cout << 0;
        return 0;
    }
    n/=2;
    for(lli i = 5; n/i>=1; i*=5)
    {
        ans+=n/i;
    }cout << ans;
    return 0;
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 1000000;
int cnt[3], b[3], c[3];
void get() {
	if( cnt[0] >= cnt[1] && cnt[1] >= cnt[2] )
		c[b[0] = 2] = 0, c[b[1] = 1] = 1, c[b[2] = 0] = 2;
	else if( cnt[0] >= cnt[2] && cnt[2] >= cnt[1] )
		c[b[0] = 2] = 0, c[b[2] = 1] = 2, c[b[1] = 0] = 1;
	else if( cnt[1] >= cnt[0] && cnt[0] >= cnt[2] )
		c[b[1] = 2] = 1, c[b[0] = 1] = 0, c[b[2] = 0] = 2;
	else if( cnt[1] >= cnt[2] && cnt[2] >= cnt[0] )
		c[b[1] = 2] = 1, c[b[2] = 1] = 2, c[b[0] = 0] = 0;
	else if( cnt[2] >= cnt[0] && cnt[0] >= cnt[1] )
		c[b[2] = 2] = 2, c[b[0] = 1] = 0, c[b[1] = 0] = 1;
	else if( cnt[2] >= cnt[1] && cnt[1] >= cnt[0] )
		c[b[2] = 2] = 2, c[b[1] = 1] = 1, c[b[0] = 0] = 0;
}
int lst[MAXN + 5], nxt[MAXN + 5];
int a[MAXN + 5], n;
void erase(int x) {
	lst[nxt[x]] = lst[x], nxt[lst[x]] = nxt[x];
	cnt[a[x]]--;
}
char s[MAXN + 5];
vector<int>v;
int main() {
	scanf("%s", s + 1), n = strlen(s + 1);
	for(int i=0;i<=n+1;i++)
		lst[i] = i - 1, nxt[i] = i + 1;
	a[0] = a[n + 1] = -1;
	for(int i=1;i<=n;i++) {
		cnt[a[i] = s[i] - 'A']++;
		if( a[i] == a[i-1] ) erase(i);
	}
	get();
	for(int i=nxt[0];i!=n+1;i=nxt[i])
		if( a[i] == c[2] && a[lst[i]] != a[nxt[i]] )
			v.push_back(i);
	for(int i=0;i<v.size()&&cnt[c[2]]!=cnt[c[1]];i++)
		erase(v[i]);
	v.clear();
	for(int i=nxt[0];i!=n+1;i=nxt[i])
		if( a[i] == c[2] && a[lst[i]] == c[0] && a[nxt[i]] == c[0] )
			v.push_back(i);
	for(int i=0;i<v.size()&&cnt[c[2]]!=cnt[c[1]];i++)
		erase(v[i]), erase(nxt[v[i]]);
	v.clear();
	for(int i=nxt[0];i!=n+1;i=nxt[i])
		if( a[i] == c[2] && a[nxt[i]] == c[1] )
			v.push_back(i);
	for(int i=0;i<v.size()&&cnt[c[0]]!=cnt[c[1]];i++)
		if( a[lst[v[i]]] != c[0] || a[nxt[nxt[v[i]]]] != c[0] )
			erase(v[i]), erase(nxt[v[i]]);
	v.clear();
	for(int i=nxt[0];i!=n+1;i=nxt[i])
		if( a[i] == c[2] && a[lst[i]] == c[1] )
			v.push_back(i);
	for(int i=0;i<v.size()&&cnt[c[0]]!=cnt[c[1]];i++)
		if( a[nxt[v[i]]] != c[0] || a[lst[lst[v[i]]]] != c[0] )
			erase(v[i]), erase(lst[v[i]]);
	v.clear();
	if( cnt[0] == cnt[1] && cnt[0] == cnt[2] ) {
		for(int i=nxt[0];i!=n+1;i=nxt[i])
			putchar(a[i] + 'A');
	}
}


Measured memory_bytes: 15344
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */
int main() {
    char b;
    cin >> b;
    char ans;
    if (b == 'A') ans = 'T';
    if (b == 'T') ans = 'A';
    if (b == 'C') ans = 'G';
    if (b == 'G') ans = 'C';

    cout << ans << endl;


}


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

int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a);
    vector<ll> q(b);
    vector<ll> r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    vector<ll> ans;
    for ( int i = a - 1; i >= a - x; --i ) {
        ans.push_back(p[i]);
    }
    for ( int i = b - 1; i >= b - y; --i ) {
        ans.push_back(q[i]);
    }
    sort(ans.begin(), ans.end());
    int check_idx = 0;
    for ( int i = c - 1; i >= max(0, c - y - x); --i ) {
        if ( ans[check_idx] < r[i] ) {
            ans[check_idx] = r[i];
            ++check_idx;
        }
    }
    cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;
    return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; ll m; cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    
    auto ok = [&](ll x) -> bool {
        ll count = 0;
        for (int i = 0; i < n; i++) {
            count += a.end() - upper_bound(a.begin(), a.end(), x - a[i]);
        }
        return count < m;
    };

    ll l = 0, r = 2 * 1e9 + 1;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (ok(mid)) r = mid;
        else l = mid;
    }

    vector<ll> sum(n + 1);
    for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[n - i - 1];

    ll ans = 0, tot = m;
    for (int i = 0; i < n; i++) {
        int num = a.end() - upper_bound(a.begin(), a.end(), r - a[i]);
        ans += a[i] * num + sum[num], tot -= num;
    }
    ans += r * tot;
    cout << ans << endl;
    return 0;
}


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



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    ll x;
//    x=1ll << 59;
//    ll y=(1ll << 59) - 1ll;
//    cout<<((double)(x)==(double)(x-1))<<endl;
    ll l1[4][4];
    for(int i=1;i<=3;i++){
        for(int j=1;j<=3;j++){
            cin>>l1[i][j];
        }
    }
    if((l1[1][1]-l1[1][2]==l1[2][1]-l1[2][2] && l1[1][1]-l1[1][2]==l1[3][1]-l1[3][2]) && (l1[1][2]-l1[1][3]==l1[2][2]-l1[2][3] && l1[1][2]-l1[1][3]==l1[3][2]-l1[3][3])){
        if((l1[1][1]-l1[2][1]==l1[1][2]-l1[2][2] && l1[1][1]-l1[2][1]==l1[1][3]-l1[2][3]) && (l1[2][1]-l1[3][1]==l1[2][2]-l1[3][2] && l1[2][1]-l1[3][1]==l1[2][3]-l1[3][3])){
            cout<<"Yes";return 0;
        }
    }
    cout<<"No";
}


Measured memory_bytes: 3580
// {{{ by WangYenJen
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll;
typedef pair<int,int> pii;
// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))
// input
inline bool SR(int &x) {
	return scanf("%d",&x) == 1;
}
inline bool SR(ll &x) {
	return scanf("%lld",&x) == 1;
}
inline bool SR(double &x) {
	return scanf("%lf",&x) == 1;
}
inline bool SR(char *s) {
	return scanf("%s",s) == 1;
}
inline bool RI() {
	return true;
}
template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
	return SR(x) && RI(tail...);
}
// output
inline void SP(const int x) {
	printf("%d",x);
}
inline void SP(const ll x) {
	printf("%lld",x);
}
inline void SP(const double x) {
	printf("%.16lf",x);
}
inline void SP(const char *s) {
	printf("%s",s);
}
inline void PL() {
	puts("");
}
template<typename I , typename... T> inline void PL(const I x , const T... tail) {
	SP(x);
	if(sizeof...(tail)) putchar(' ');
	PL(tail...);
}
// debug
#define WangYenJen
#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
    cerr << s << " = " << x << endl;
}
template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
    int c = 0;
    while(*s != ',' || c != 0) {
        if(*s == '(' || *s == '[' || *s == '{') c++;
        if(*s == ')' || *s == ']' || *s == '}') c--;
        cerr << *s++;
    }
    cerr << " = " << x << " , ";
    _DOING(s + 1 , tail...);
}
#define debug(...) \
do {\
    fprintf(stderr , "%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);
#else
#define debug(...)
#endif
// random function
inline int RAND() {
	static int x = 880301;
	return (x = x * 0xdefaced + 1) & 0x7fffffff;
}
// }}}

const int MAX_N = 100000 + 10;
int a[MAX_N];
int main() {
    int n;
    RI(n);
    ll ans = 0;
    REP(i , n) RI(a[i]);
    REP(i , n) {
        ans += a[i] / 2;
        a[i] %= 2;
        if(i + 1 < n) {
            int t = min(a[i] , a[i + 1]);
            a[i] -= t , a[i + 1] -= t , ans += t;
        }
    }
    PL(ans);
    return 0;
}


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

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

    int k,s;
    cin >> k >> s;
    int ans;
    rep(i,0,k+1) {
    	rep(j,0,k+1){
    	int l = s-i-j;
    	if(0<=l and l<=k) ans++;
        }
    }
     cout << ans << "\n";
    
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

c = sorted(a, reverse = True)

if c[0] == c[1]:
    for i in range(n):
        print(c[0])
else:
    for i in range(n):
        if a[i] == c[0]:
            print(c[1])
        else:
            print(c[0])






                                        




    




        


    







        



Measured memory_bytes: 14112
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int n, m;

struct DATA{
	int l, r;
};

inline bool cmp(DATA x, DATA y){
	return x.l < y.l;
}

DATA data[100010];

int main(){
	
	cin>>n>>m;
	
	for(register int i=0; i<m; i++){
		int tmpa, tmpb;
		
		cin>>tmpa;
		cin>>tmpb;
		
		data[i].l = min(tmpa, tmpb);
		data[i].r = max(tmpa, tmpb)-1;
	}
	
	sort(data, data+m, cmp);
		
	int pos = -999999999;
	int cnt = 0;
	
	for(register int i=0; i<m; i++){
		if(data[i].l > pos){
			cnt++;
			pos = data[i].r;
		}else{
			pos = min(pos, data[i].r);
		}
	}
			
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 1024