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

int main() {
    int n;
    cin >> n;
    vector<int> P(n), Q(n);
    for (int i = 0; i < n; ++i) cin >> P[i];
    for (int i = 0; i < n; ++i) cin >> Q[i];
    vector<int> A(n);
    for (int i = 0; i < n; ++i) A[i] = i+1;
    map<vector<int>, int> mp;
    do {
        mp[A] = mp.size();
    } while (next_permutation(A.begin(), A.end()));
    int ans = abs(mp[P]-mp[Q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    int k, n;
    cin >> n >> k;

    VLD e(n+1, 0.0);
    REP(i,n) {
        LD temp;
        cin >> temp;
        e[i+1] = e[i] + temp*(temp+1.0)/2.0/temp;
    }

    LD ans = 0.0;
    for (int i=k; i<=n; i++) {
        ans = max(ans, e[i]-e[i-k]);
    }

    cout << fixed << setprecision(15) << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6352
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    cout << (N - 2) * 180 << endl;
    return 0;
}

Measured memory_bytes: 256
mod = 10**9+7

def kaizyou(x):
    y = 1
    for i in range(2, x+1):
        y = (y*i)%mod
    return y


N , M = map(int, input().split())
if abs(N-M) >= 2:
    ans = 0
elif N == M:
    ans = 2 * kaizyou(N) ** 2
elif N > M:
    ans = N * kaizyou(M) ** 2
else:
    ans = M * kaizyou(N) ** 2
print(ans%mod)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, A, B;
  cin >> N >> A >> B;
  vector<int> lenlist;
  lenlist.push_back(A);
  if(B > 1) {
    lint x = (N-A) / (B-1);
    lint d = (N-A) % (B-1);
    if(x <= 0 || x > A || (x == A && d != 0)) {
      cout << -1 << endl;
      return 0;
    }
    REP(i, B-1) lenlist.push_back(i<d ? x+1 : x);
  } else if(N != A) {
    cout << -1 << endl;
    return 0;
  }
  
  vector<int> ans;
  REP(i, B) {
    REP(j, lenlist[i]) {
      ans.push_back(N-lenlist[i]+1+j);
    }
    N -= lenlist[i];
  }
  REP(i, ans.size()) cout << ans[i] << (i!=N-1 ? " " : "");
  cout << "\n";
  

}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll l,r;
  cin>>l>>r;
  ll fmin=2020,smin=2020;
  ll ans=0;
  ll a=0;
  if(r-l>2019){
    co(0);
  }
  else{
/*    FOR(i,l,r+1){
      a=i%2019;
      if(a<fmin&&a<smin){
        smin=fmin;
        fmin=a;
      }
      else if(a>fmin&&a<smin){
        smin=a;
      }
   //   co(fmin);
   //   co(smin);
    }
    ans=fmin*smin%2019;*/
    FOR(i,l,r){
      FOR(j,i+1,r+1){
        a=i*j%2019;
        if(a<fmin){
          fmin=a;
        }
    //    co(fmin);
      }
    }
    co(fmin);
  }
}


Measured memory_bytes: 256
def main():
  result = 0
  k, s = map(int, input().split())
  for x in range(k + 1):
    for y in range(k + 1):
      z = s - x - y
      if 0 <= z <= k:
        result += 1
  print(result)
if __name__ == "__main__":
  main()

Measured memory_bytes: 9064
from collections import deque

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

adj = [[] for _ in range(n+1)]
visited = [False] * (n+1)

for a, b in ab:
    adj[a].append(b)
    adj[b].append(a)

c = 0

for i in range(1, n+1):
    if not visited[i]:
        visited[i] = True
        q = deque([i])
        
        while len(q) > 0:
            v = q.pop()
            for w in adj[v]:
                if not visited[w]:
                    visited[w] = True
                    q.append(w)
        
        c += 1

print(c - 1)

Measured memory_bytes: 98128
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 1000


int main(void) {
  vll a;

  FOR(i, 0, 3) {
	cin >> temp;
	a.push_back(temp);
  }

  sort(ALL(a));

  while (a[1] != a[2]) {
	ans++;
	a[0]++;
	a[1]++;
  }

  if (a[0] % 2 != a[1] % 2) {
	a[1]++;
	ans++;
  }

  ans += (a[1] - a[0]) / 2;

  cout << ans << endl;

  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//s.find(w[i])==string::npos
//findの使い方

long long int n,cnt=0,ans=0,a[100000],b[100000],c,cmp,data,m,h,x,y,txa,txb,tya,tyb,xcmp=0,ycmp=0;

string s,w;

vector<int> z;

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

     cin >> n;
     rep(i,n){
         cin >> a[i];
     }
     rep(i,n){
         cin >> b[i];
     }
     rep(i,n){
         cnt=0;
         rep(j,i+1){
             cnt+=a[j];
         }
         rrep(j,i,n){
             cnt+=b[j];
         }
         //cout << cnt << endl;
         ans = max(ans,cnt);
     }
     cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int main(){
    int a[3],b[3];
    for(int i=0;i<3;i++)scanf("%d",&a[i]);
    for(int i=0;i<3;i++)b[i]=std::abs(a[i]-a[(i+1)%3]);
    std::sort(b,b+3);
    printf("%d",b[0]+b[1]);
    return 0;
}

Measured memory_bytes: 128
<?php

$n = (int)trim(fgets(STDIN));
$max = floor(sqrt($n));
$max_len=strlen((string)$n);
$min = $max_len;

for ($i=1; $i <= $max; $i++) { 
	if ($n % $i===0) {
		$c1=$i;
		$c2=floor($n/$i);
		$tmp=max(strlen((string)$c1),strlen((string)$c2));
		$min = min($min, $tmp);
	}
}
echo $min;

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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<3;i++) {
        if(s.at(i) == '1') {
            s.at(i) = '9';
        }else if(s.at(i) == '9'){
            s.at(i) = '1';
        }
    }
    
    cout << s << endl;
}

Measured memory_bytes: 256
import math

# def comboSum(n, chooseMin, chooseMax):
# 	print(n, chooseMin, chooseMax)
# 	ways = 0
# 	for i in range(chooseMin, chooseMax + 1):
# 		localWays = math.factorial(n) // math.factorial(i) // math.factorial(n - i)
# 		ways += localWays
# 	return ways


def avg(L, atLeast, atMost):
	if (L.count(max(L)) >= atLeast):
		print(max(L))
		ways = 0
		for i in range(atLeast, min(atMost, L.count(max(L))) + 1):
			localWays = math.factorial(L.count(max(L))) // math.factorial(i) // math.factorial(L.count(max(L)) - i)
			ways += localWays
		print(ways)
		return
	L.sort(reverse=True)
	last = L[atLeast - 1]
	print(sum(L[:atLeast]) / atLeast)
	firstIndex = L.index(last)
	# lastIndex = len(L) - (sorted(L).index(last)) - 1
	n = L.count(last)
	i = atLeast - firstIndex
	print(math.factorial(n) // math.factorial(i) // math.factorial(n - i))

[N, atLeast, atMost] = list(map(lambda x: int(x), input().split()))
L = list(map(lambda x: int(x), input().split()))
avg(L, atLeast, atMost)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main()
{
	
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<b)
	printf("0\n");
	else
	printf("10\n"); 
}

Measured memory_bytes: 256
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n, m = map(int,input().split())
    a = [input().split() for i in range(m)]
    st = 0
    en = 10
    flg = 0
    if n == 2:
        st = 10
        en = 100
    elif n == 3:
        st = 100
        en = 1000
    for i in range(st,en):
        for j in range(m):
            tmp = list(str(i))
            if tmp[int(a[j][0])-1] != a[j][1]:
                flg = 1
                break
        if flg == 0:
            print(i)
            return
        flg = 0
    print(-1)
    return 
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <stack>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;


int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int sum = 0;
	if (2*c < a + b) {
		int  z = min(x, y);
		sum += z * c * 2;
		if (x - z != 0)sum += (x - z) * a;
		else sum += (y - z) * b;
		if (sum > 2 * c*max(x,y))sum = 2 * c*max(x, y);
	}
	else sum = (x*a) + (y*b);
	cout << sum;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool exist[9][9];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        exist[s][t] = true;
        exist[t][s] = true;
    }
    int order[10];
    rep(i, N) order[i] = i;
    int cnt = 0;
    do{
        bool ok = true;
        rep(i, N - 1) {
            int k1 = order[i];
            int k2 = order[i + 1];
            if (!exist[k1][k2]) ok = false;
        }
        cnt += ok;
    }while(next_permutation(order + 1, order + N));
    cout << cnt << endl;

    return 0;
}


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

ll solve() {
    int N, a;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < N-1; j++ ) {
            cin >> a;
            a--;
            A[i][j] = a;
        }
    }
    vector<int> ix(N), ixn(N);
    unordered_set<int> chg, nx, fn;
    for ( int i = 0; i < N; i++ ) {
        chg.insert(i);
        fn.insert(i);
    }
    int d = 0;
    while ( true ) {
        d++;
        for ( int i = 0; i < N; i++ ) {
            ix[i] = ixn[i];
        }
        for ( int p : chg ) {
            if ( nx.find(p) != nx.end() ) continue;
            if ( ix[p] >= N-1 ) continue;
            int a = A[p][ix[p]];
            if ( A[a][ix[a]] == p ) {
                nx.insert(p);
                nx.insert(a);
                ixn[p]++;
                ixn[a]++;
                if ( ixn[p] == N-1 ) fn.erase(p);
                if ( ixn[a] == N-1 ) fn.erase(a);
                if ( fn.empty() ) return d;
            }
        }
        if ( nx.empty() ) return -1;
        chg.swap(nx);
        nx.clear();
    }
   
    ll ans = d;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    
    ll x, y;    cin >> x >> y;
    string res="No";
    FOR(i, 0, x+1){
        ll tmp = 2*i+4*(x-i);
        if(tmp==y) res = "Yes";
    }
    cout << res << endl;
    
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////


int main() {

	ll s;
	cin >> s;

	ll vis[2000000] = {};

	vis[s] = 1;

	ll n = 1;

	while (1 == 1) {
		n++;

		if (s % 2 == 0) { s /= 2; }
		else { s = s * 3 + 1; }

		if (vis[s] == 0) { vis[s] = 1; }
		else { break; }
		
	}

	cout << n;
	


	system("PAUSE");
}

Measured memory_bytes: 16120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000003
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//AGC034
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n,x; cin>>n>>x;
    vector<int> b(n),l(n),u(n),val(n);
    rep(i,n){
        cin>>b[i]>>l[i]>>u[i];
        val[i]=b[i]*l[i]+(x-b[i])*u[i];
    }

    vector<int> num(n);
    iota(all(num),0);
    sort(all(num),[&](int s, int t){
        return val[s]>val[t];
    });

    vector<int> sums(n+1); sums[0]=0;
    rep(i,n){
        int j=num[i];
        sums[i+1]=sums[i]+val[j];
    }

    int score=0;
    rep(i,n)score+=b[i]*l[i];

    int left=-1,right=n*x+1;
    while(right-left>1){
        int mid=(right+left)/2;
        int take_all=mid/x;
        int incmp=mid-take_all*x;
        int final_sum=0;

        rep(i,n){
            int j=num[i];
            int tmp_sum;
            if(i<take_all and take_all<n)tmp_sum=sums[take_all+1]-val[j];
            else tmp_sum=sums[take_all];
            tmp_sum+=max<int>(0,incmp-b[j])*u[j]+min<int>(incmp,b[j])*l[j];
            chmax(final_sum,tmp_sum);
        }

        if(final_sum>=score)right=mid;
        else left=mid;
    }

    cout<<right<<endl;
    return 0;

}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x, y, l,r, h, w;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> ar;
    vector<string> sr;
    vector<vector<char>> arr;

    cin >> s;

    if(s[0]=='A')sans ='T';
    else if(s[0]=='T')sans ='A';
    else if(s[0]=='G')sans ='C';
    else if(s[0]=='C')sans ='G';



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

    std::cout << sans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::{input, marker::Chars, fastout};


#[fastout]
fn main() {
    input! {
        mut s: Chars,
    }

    let mut one = vec!['s'];
    let mut two = vec!['e', 's'];

    if s[s.len()-1] == 's' {
        s.append(&mut two);
    }else{
        s.append(&mut one);
    }

    let ans:String = s.iter().collect();

    println!("{}", ans);
    
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main() {
    int k; cin >> k;
    vector<int> a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			String t = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			String u = sc.next();

			if (s.equals(u)) {
				a--;
			} else {
				b--;
			}
			System.out.println(String.format("%d %d", a, b));
		}
	}

}


Measured memory_bytes: 23764
#include <stdio.h>

int main(void)
{
	int mt[10];
	int top;
	int topmt[3];
	int i, j;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &mt[i]);
	}
	top = 0;
	for (i = 0; i < 3; i++){
		for (j = 0; j < 10; j++){
			if (mt[j] > mt[top]){
				top = j;
			}
		}
		topmt[i] = mt[top];
		mt[top] = 0;
	}
	for (i = 0; i < 3; i++){
		printf("%d\n", topmt[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
 
//****************************************************                
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define vvll vector<vector<ll>>
#define mtp make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions
void solve();

int binary(int a[],int l,int r,int find)
{
    if(l>r)
    {
        return -1; 
    }else
    {
        int mid=(l+r)/2;
        if(a[mid]==find)
        {
            return mid+1;
        }else if(a[mid]>find)
        {
            binary(a,l,mid-1,find);
        }else
        {
            binary(a,mid+1,r,find);
        }   
    }   
}

int main()
{
    FAST_IO;
    ll testcases = 1;
    // cin >> testcases; //comment for 1 test case
    while(testcases--)
    {
        solve();
    }
}

void solve()
{
	ll n;
	cin>>n;
	vll a(n);
	ll ts=0;
	f(x,0,n)
	{
		cin>>a[x];
		ts=ts^a[x];
	}
	f(x,0,n)
	{
		cout<<(a[x]^ts)<<" ";
	}
	nl;
}

Measured memory_bytes: 4768
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		string A = GetString();
		long N = A.Length;
		long[] num = new long[26];
		for(int i = 0; i < N; i++)
			num[(int)(A[i] - 'a')]++;

		long total = (N * (N - 1)) / 2 + 1;
		long conflict = 0;
		for(int i = 0; i < 26; i++)
			conflict += (num[i] * (num[i] - 1)) / 2;
		
		Console.WriteLine(total - conflict);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int p1, p2;
  for(int i = 0; i < N; i++){
    cin >> p1 >> p2;
    sum += (p2-p1+1);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF=2e18;
ll N;
map<string,ll> mp;
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0;
    for(auto o:mp){
        ll n=o.second;
        ans+=n*(n-1)/2;
    }
   cout<<ans;
    return 0;
}

Measured memory_bytes: 11136
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstring;
typedef pair<int, int> pint;
typedef pair<pint, int> ppint;
typedef pair<int, pint> pintp;
typedef unsigned int uint;
typedef long long llint;
typedef unsigned long long int ullint;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find((v).begin(), (v).end(), i) != (v).end())
#define ERASE(v,i) (v).erase(remove((v).begin(),(v).end(),i),(v).end())
#define me (*this)

//repetition
//------------------------------------------
#define rep(i,s) for(int i=0; i<(int)(s); i++)

//constant
//--------------------------------------------
const int INF = 100000000;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLEAR(a) memset((a), 0 ,sizeof(a))

//debug
#define debug(x)  cerr << #x << " = " << (x) << endl

int main() {
	while(1) {
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0)
			break;
		n = m - n;
		int c = n / 1000;
		int b = n % 1000 / 500;
		int a = n % 500 / 100;
		printf("%d %d %d\n", a, b, c);
	}
	return 0;
}

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int main() {
  int N, l[100001] = {}, r[100001] = {};
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> l[i] >> r[i];
  }
  ++N;
  sort(l, l + N);
  sort(r, r + N);
  int64 ret = 0, cost = 0;
  for(int i = 0; i < N; i++) {
    cost += l[N - i - 1] - r[i];
    ret = max(ret, cost * 2);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1152
// 4/29
// 過去問攻略

#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;

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

    double l = (double)L / 3.0;

    // cout << 333 * 333 * 333 << endl;
    cout << fixed << setprecision(10) << l * l * l << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;
vector<int> v[220000];
long long c[220000];
void dfs(int a,int fa){
	if(fa){
		c[a]+=c[fa];
	}
	for(int i=0;i<v[a].size();i++){
		if(v[a][i]!=fa)dfs(v[a][i],a);
	}
}
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=2;i<=n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=1;i<=q;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		c[a]+=b;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		printf("%lld ",c[i]);
	}
}

Measured memory_bytes: 24704
import java.io.PrintWriter
import java.util.*


@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

@JvmField val _reader = INPUT.bufferedReader()
fun readLine(): String? = _reader.readLine()
fun readLn() = _reader.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = Array(n) { read() }
fun readLines(n: Int) = Array(n) { readLn() }
fun readInts(n: Int) = Array(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = Array(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = Array(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)
inline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }

class Store(val a: Int, val b: Int) : Comparable<Store> {
    override fun compareTo(o: Store): Int {
        if (a == 0 && o.a == 0)
            return b.compareTo(o.b)
        return ((a.toLong() * (o.b + 1)).compareTo(o.a.toLong() * (b + 1)))
    }
}

val mem = Array(30) { Array(200010) { -1 } }
fun dp(j: Int, id: Int, stores: Array<Store>): Int {
    if (stores.size == id) {
        return (if (j == 0) 0 else 1.shl(30))
    }
    if (mem[j][id] != -1) return mem[j][id]
    var w = 1.shl(30)
    if (j > 0) {
        val t = dp(j - 1, id + 1, stores) + 1
        w = Math.min(w.toLong(), t + t.toLong() * stores[id].a + stores[id].b).toInt()
    }
    w = Math.min(w, dp(j, id + 1, stores))
    mem[j][id] = w
    return w
}

fun main(args: Array<String>) {
    val (N, T) = readInts(2)
    val stores = (0 until N).map {
        val (a, b) = readInts(2)
        Store(a, b)
    }.sorted().toTypedArray()

    val (firstNonZero) = listOf(stores.indexOfFirst { it.a != 0 }).map { if (it == -1) N else it }

    var mx = 0
    for (i in 0..N) {

        for (id in (firstNonZero..N).reversed()) {
            if (stores.size == id) {
                mem[i][id] = (if (i == 0) 0 else 1.shl(30))
            } else {
                var w = 1.shl(30)
                if (i > 0) {
                    val t = mem[i - 1][id + 1] + 1
                    w = Math.min(w.toLong(), t + t.toLong() * stores[id].a + stores[id].b).toInt()
                }
                w = Math.min(w, mem[i][id + 1])
                mem[i][id] = w
            }
        }
        var t = mem[i][firstNonZero]

        if (t > T) break
        var cnt = i
        for (s in 0 until firstNonZero) {
            if (t + stores[s].b + 1 <= T) {
                t += stores[s].b + 1
                cnt += 1
            }
        }
        mx = Math.max(mx, cnt)
    }
    println(mx)
}

/*
1 1 5 -> 3
1 5 1 -> 2
5 1 1 -> 1
 */


Measured memory_bytes: 178544
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	vector<int> peaks;
	for (int i = 1; i < n; ++i) {
		peaks.push_back(value[i] - value[i - 1]);
	}

	long long money = 1000, stocks = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (peaks[i] > 0) {
			long long curr_gains = money, curr_stocks = stocks;
			curr_stocks = curr_gains / value[i];
			curr_gains %= value[i];
			curr_gains += value[i + 1] * curr_stocks;
			if (curr_gains > money || (curr_gains == money && curr_stocks > stocks)) {
				money = curr_gains;
				stocks = curr_stocks;
			}
		}
	}

	cout << money << "\n";

	return 0;

}

Measured memory_bytes: 3648
let (n,m) = cin.pair
let h = cin.array
var ok = Array(1...n).map { _ in 1 }
Array(1...m).forEach { _ in 
    var (a,b) = cin.pair
    a -= 1
    b -= 1
    if h[a] > h[b] {
        ok[b] = 0
    } else if h[a] < h[b] {
        ok[a] = 0
    } else {
        ok[a] = 0
        ok[b] = 0
    }
}

print(ok.sum)

// MARK: #### 以下、ライブラリ ####

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var int: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var str: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { str.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { str.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in int } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence }
infix operator ^^ : PowerPrecedence
func ^^ (radix: Int, power: Int) -> Int {
    return Int(pow(Double(radix), Double(power)))
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}


Measured memory_bytes: 17632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,ll> P;


int main(void){
    int n;
    string s,t;
    cin>>n>>s>>t;
    for(int i=0;i<n;i++){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


X, Y = LI()
print(int(X + Y/2))


Measured memory_bytes: 66924
import copy
import numpy as np

def det(p, q):
    return p[0]*q[1] - p[1]*q[0]
def sub(p, q):
    return (p[0]-q[0], p[1]-q[1])
def get_convex_hull(points):
    n = len(points)
    points.sort()
    size_convex_hull = 0
    ch = []
    for i in range(n):
        while size_convex_hull > 1:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    t = size_convex_hull
    for i in range(n-2, -1, -1):
        while size_convex_hull > t:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(points[i], ch[-2])
            if det(v_cur, v_new) > 0:
                break
            size_convex_hull -= 1
            ch.pop()
        ch.append(points[i])
        size_convex_hull += 1

    return ch[:-1]

N,*xyf = map(int, open(0).read().split())
xy = [(xyf[i*2],xyf[i*2+1]) for i in range(N)]
xyc = copy.deepcopy(xy)
ans = [0] * (N)
ch = get_convex_hull(xyc)
chs = set(ch)
l = len(ch)
for i in range(N):
    if xy[i] in chs:
        ind = ch.index(xy[i])
        a = (ch[ind-1],ch[ind])
        b = (ch[ind],ch[(ind+1)%l])
        u = np.array([a[0][0]-a[1][0],a[1][1]-a[0][1]])
        v = np.array([b[0][0]-b[1][0],b[1][1]-b[0][1]])
        inn = np.inner(u,v)
        nor = np.linalg.norm(u) * np.linalg.norm(v)
        cos = inn / nor
        ans[i] = (np.arccos(np.clip(cos, -1.0, 1.0))/(2*np.pi))
for x in ans:
    print(x)

Measured memory_bytes: 27056
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
import sys


MX = 10**9+1

N = int(sys.stdin.readline().rstrip())
An = list(map(int, sys.stdin.readline().rstrip().split()))
Bn = list(map(int, sys.stdin.readline().rstrip().split()))
Cn = list(map(int, sys.stdin.readline().rstrip().split()))

An = sorted(An)+[MX]
Bn = sorted(Bn)
Cn = sorted(Cn)+[MX]

ans,ia,ic = [0, 0, 0]
for b in Bn:
  while(An[ia] < b):
    ia += 1
  while(Cn[ic] <= b):
    ic += 1
  ans += ia * (N-ic)

print(ans)

Measured memory_bytes: 97048
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
    string s;
    cin >> s;
    if (s.back() == '1') {
        cout << -1 << endl;
        return 0;
    }
    s.pop_back();
    rep(i,0,s.size()/2) {
        if (s[i] != s[s.size()-1-i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    if (s[0] == '0') {
        cout << -1 << endl;
        return 0;
    }
    rep(i,s.size()/2+(s.size()%2),s.size()) {
        s[i] = '0';
    }
    ll last = 0;
    rep(i,0,s.size()) {
        ll a = last;
        ll b = i+1;
        cout << a+1 << " " << b+1 << endl;
        if (s[i] == '1') {
            last = b;
        }
    }
}

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

#define MOD 1000000007
#define MAX 100005
#define ll long long
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define ss(x) scanf("%s",x)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vpii vector<pii >
#define vll vector<ll>
#define clr(x) memset(x,0,sizeof(x))

#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll power(ll a,ll b,ll m){
	ll x=1%m; a%=m;
	while(b){
		if((1&b)) x = x * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return x;
}

int a[MAX];

int main(){
	int n;sd(n);
	a[0]=a[n+1]=0;
	for(int i=1;i<=n;i++) sd(a[i]);
	ll tot = 0;
	for(int i=1;i<=n+1;i++){
		tot+=abs(a[i]-a[i-1]);
	}
	for(int i=1;i<=n;i++){
		ll ans = tot - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]) + abs(a[i-1]-a[i+1]);
		// printf("%lld ",ans);
		plld(ans);
	}
}

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n;
    string s, t;
    cin >> n ;
    cin >> s;
    cin >> t;
    for (int i=0;i<n;i++)
    {
        bool flag = true;
        for (int j=i;j<n;j++)
        {
            if (s[j] == t[j-i]) continue;
            flag = false;
        }

        if (flag)
        {
            cout << n + i << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
    return 0;
}



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

typedef long long int ll;
typedef long long int llint;
#define ED return 0;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) ll(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<vector<bool>> shops (N,vector<bool> (N,false));
    for(ll i = 0;i < N;i++){
        for(ll j = 0;j < 10;j++){
            bool dummy;
            cin >> dummy;
            shops[i][j] = dummy;
        }
    }
    vector<vector<ll>> money (N,vector<ll> (11,0));
    for(ll i = 0;i < N;i++){
        for(ll j = 0;j < 11;j++){
            cin >> money[i][j];
        }
    }
    ll maxmoney = -999999999999;
    for(int a = 0;a < 2;a++){
        for(int b = 0;b < 2;b++){
            for(int c = 0;c < 2;c++){
                for(int d = 0;d < 2;d++){
                    for(int e = 0;e < 2;e++){
                        for(int f = 0;f < 2;f++){
                            for(int g = 0;g < 2;g++){
                                for(int h = 0;h < 2;h++){
                                    for(int i = 0;i < 2;i++){
                                        for(int j = 0;j < 2;j++){
                                            if(!a && !b && !c && !d && !e && !f && !g && !h && !i && !j){
                                                continue;
                                            }
                                            ll thistimemoney = 0;
                                            for(ll k = 0;k < N;k++){
                                                ll time = 0;
                                                if(shops[k][0] && a)time++;
                                                if(shops[k][1] && b)time++;
                                                if(shops[k][2] && c)time++;
                                                if(shops[k][3] && d)time++;
                                                if(shops[k][4] && e)time++;
                                                if(shops[k][5] && f)time++;
                                                if(shops[k][6] && g)time++;
                                                if(shops[k][7] && h)time++;
                                                if(shops[k][8] && i)time++;
                                                if(shops[k][9] && j)time++;
                                                thistimemoney += money[k][time];
                                            }
                                            maxmoney = max(maxmoney,thistimemoney);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << maxmoney << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typedef(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!(c >= 48); c = getchar()) if (c == 45) f ^= 1;
	for (; (c >= 48); c = getchar()) x = x * 10 + c - 48;
	return f ? x : -x;
}

int sol(int a, int b) {
	int lb = 0, rb = a - 1;
	while (lb < rb) {
		int md = (lb + rb + 1) >> 1;
		int mx = (b + md + 1) / 2;
		bool ok = 1LL * md * (b + 1) < 1LL * a * b;
		if (mx > b && mx < md) {
			ok &= 1LL * mx * (b + md + 1 - mx) < 1LL * a * b;
		}
		if (ok) lb = md;
		else rb = md - 1;
	}
	return lb;
}

int main() {
	int q = read();
	rep(tc, q) {
		int a, b;
		a = read(), b = read();
		printf("%d\n", sol(a, b) + sol(b, a));
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]
f=1
h[0]-=1
for i in range(1,n):
    if h[i]-h[i-1]>=1:h[i]+=-1
    elif h[i]-h[i-1]==0:h[i]+=0
    else:
        f=0
        print("No")
        break
if f==1:print("Yes")


Measured memory_bytes: 14224
#include<stdio.h>
int main(void){
	int a,b,c,temp;
	scanf("%d\n",&a);
	scanf("%d\n",&b);
	scanf("%d",&c);
	if(a>b){
		temp=a;
		a=b;
		b=temp;
	}
	if(a>c){
		temp=a;
		a=c;
		c=temp;
	}
	if(b>c){
		temp=b;
		b=c;
		c=temp;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  //input output template
  /*
  int N;
  cin >> N;
  cout << "Hello, world!" << endl;
  */
  /*
  int count_r=0;
  int count_g=0;
  int count_b=0;
  */
  
  int A,B;
  cin >> A >> B;
  
  int ans = 0;
  while(1){
    
    if( (ans*A - (ans - 1) ) >= B) break;
    ans++;
    
  }
  cout << ans << endl;  
  /*
  char str[4000];
  cin >> str;
  */
  
    

}

Measured memory_bytes: 256