akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using ll = long long;
using P = pair<long long, long long>;
using MATRIX = vector< vector<ll> >;

long long N;
vector<P> v;

int main() {
  cin >> N;
  rep(i, N) {
    long long a, b;
    cin >> a >> b;
    v.push_back(make_pair(b, a));
  }
  sort(v.begin(), v.end());
  long long sum = 0;
  rep(i, v.size()) {
    sum += v[i].second;
    if(sum > v[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 7316
/*
    author: kartik8800
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[22][(1<<22)];
int solve(vector<vector<int>>& compat, int i, int womenSubset, int N)
{
    if(i == N+1)
    {
        if(womenSubset == 0)
            return 1;
        return 0;
    }

    if(dp[i][womenSubset] != -1)
        return dp[i][womenSubset];
    ll ans = 0;
    for(int women = 0; women < N; women++)
    {
        bool available = (((1<<women)&(womenSubset)) == 0) ? 0 : 1;
        if(available && compat[i][women + 1])
        {
            ans = (ans + solve(compat, i+1, womenSubset ^ (1<<women), N)) % mod;
        }
    }
    return dp[i][womenSubset] = ans;
}

int main() {
   int n;
   cin >> n;
   vector<vector<int>> compat(n+1, vector<int>(n+1));
   memset(dp, -1, sizeof dp);
   for(int i = 1; i<=n; i++)
        for(int j = 1; j <= n; j++)
            cin >> compat[i][j];
   cout<<solve(compat, 1, ((1<<(n)) - 1), n);
   return 0;
}


Measured memory_bytes: 721152
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ff first
#define ss second
typedef long long int ll;
typedef pair<int,int> pii;
const int MAX=2e5+10;
vector<pii>g[MAX];
int n,col[MAX];
void dfs(int u,int p,int pc){
    int c=1;
    for(auto x:g[u]){
        int v = x.ff;
        int idx = x.ss;
        if(v==p)continue;
        while(c==pc)c++;
        col[idx] = c++;
        dfs(v,u,col[idx]);
    }
}
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    col[1] = 1;
    cin >> n;
    for(int i=1;i<=n-1;i++){
        int u,v;cin>>u>>v;
        g[u].push_back({v,i});
        g[v].push_back({u,i});
    }
    int maxS=0;
    for(int i=1;i<=n;i++){
        maxS = max(maxS,(int)g[i].size());
    }
    dfs(1 , 0 , 0);
    cout<<maxS<<endl;
    for(int i=1;i<n;i++)cout<<col[i]<<"\n";
    return 0;
}


Measured memory_bytes: 10752
import math

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

h = []
min_h = 10 ** 10
max_h = 0
for _ in range(N):
    hi = int(input())
    if hi < min_h:
        min_h = hi
    if hi > max_h:
        max_h = hi
    h.append(hi)
    
min_K = math.ceil(sum(h) / (A - B + B * N)) - 1
max_K = math.ceil(max(h) / A) * N
min_K = math.ceil(min_h / A)
max_K = math.ceil(max_h / B)
K = min_K
while(min_K != max_K):
    x = [math.ceil((n - K * B) / (A - B)) for n in h]
    sum_x = sum([xi for xi in x if xi > 0])
    if sum_x <= K:
        max_K = K
        K = math.floor((min_K + K) / 2)
    else:
        min_K = K + 1
        K = math.floor((K + max_K) / 2) + 1

print(K)

Measured memory_bytes: 15172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	for(int i = 0; i < n; ++i){ cin >> a[i] >> b[i]; }
	ll answer = 0;
	for(int i = n - 1; i >= 0; --i){
		const ll x = a[i] + answer, y = b[i];
		const ll t = (y - x % y) % y;
		answer += t;
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
constexpr ll mod = 1000000007;

ll N, K;
ll fact[4010], inv[4010];

ll powMod( ll x, ll y )
{
  ll ret = 1;
  
  while( y > 0 )
  {
    if( y&1 )
      ret = (ret*x) % mod;

    x = (x*x) % mod;
    y >>= 1;
  }

  return ret;
}

ll comb( ll n, ll r )
{ 
  if( n-r < 0 )
    return 0;
  if( n > N || n < 0 )
    return 0;
  if( r < 0 )
    return 0;

  return fact[n]*inv[n-r]%mod*inv[r]%mod;
}

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

  fact[0] = 1;
  rep( i, 4000 )
    fact[i+1] = (fact[i]*(i+1)) % mod;

  rep( i, 4001 )
    inv[i] = powMod( fact[i], mod-2 );

  repi( i, 1, K+1 )
    printf( "%lld\n", comb( K-1, i-1 )*comb( N-K+1, i )%mod );

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define pb                  push_back
#define arr                 vector<ll>
#define mem(x,val)          memset(x,val,sizeof(x))
#define vp                 vector<pair<ll,ll>>
#define matrix              vector<vector<ll> >
#define digit(x)            floor(log10(x))+1
#define debug(x)            cerr << #x << " is " << x << endl;
#define all(a)              a.begin(),a.end()
#define fixed               setprecision(15)
// ll dx[]={-1,1,0,0},dy[]={0,0,-1,1}; 4 Sides
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};    8 Sides
using namespace std;
arr read(ll n){
    arr a;
    for (ll i=0;i<n;i++){
        ll x;
        cin>>x;
        a.pb(x);
    }
    return a;
}
  int main(){
       ll x, k, d;
       cin >> x >> k >> d;
       x = abs(x);
       
       ll step = x/d;
       ll c = min(step, k);

       k = k - c;
       x = x - c*d;

       if (k&1){
           cout<<abs(x-d)<<endl;
       }else{
           cout<<x<<endl;
       }

        return 0;
}


Measured memory_bytes: 3616
//人正是因为度过了一段阴暗岁月，才会更渴求黎明的曙光
//青春不能回头。所以青春也没有终点。
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

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

const int MAXN = 0;

int main(void) {
	double N;
	cin >> N;
	printf("%.8lf\n", N/3*N/3*N/3);
	return 0;
}




Measured memory_bytes: 256
from collections import defaultdict

def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = defaultdict(lambda : 0)
    ans = 0
    for i, ai in enumerate(a):
        sa = i - ai
        ans += d[sa]
        wa = i + ai
        d[wa] += 1
    print(ans)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 149920
p = input()
a = int(p[0])
b = int(p[1])
c = int(p[2])
d = int(p[3])
if a + b + c + d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b + c - d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a + b - c + d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b + c + d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b - c - d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a - b - c + d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b + c - d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a - b - c - d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")


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

int main(){
  int a,b,c,d,e,f,i,j,k,l,s=0,w=100;
  cin>>a>>b>>c>>d>>e>>f;a*=100;b*=100;
  for(i=0;i<=f;i+=a)
  for(j=0;i+j<=f;j+=b)
  for(k=0;i+j+k<=f;k+=c)
  for(l=0;i+j+k+l<=f;l+=d)
  if(((k+l)*(100+e)<=e*(i+j+k+l)&&s*(i+j+k+l)<=(k+l)*(w+s))){
    w=i+j,s=k+l;
  }
  cout<<w+s<<" "<<s;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,i,k,max=0,min=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  max=a[1]-a[0];
  min=a[0];
  for(i=1;i<n;i++){
    int b=a[i]-min;
    if(b>max)max=b;
    if(a[i]<min)min=a[i];
  }
  printf("%d\n",max);
  return 0;
}


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

int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    cin>>n;
    if(n==1)
    {
        printf("0\n");
        return 0;
    }
    m=(1e9)+7;
    x=1;
    y=1;
    d=1;
    for(i=1;i<=n;i++)
    {
        x=(x*10)%m;
    }
    for(i=1;i<=n;i++)
    {
        y=(y*8)%m;
    }
    for(i=1;i<=n;i++)
    {
        d=(d*9)%m;
    }
    d=(d*2)%m;
    x=(x-d)%m;
    x=(x+m)%m;
    x=(x+y)%m;
    cout<<x<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

ll dp[303][303][303];
const ll INF=1e18;

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

  int N,K;
  cin>>N>>K;
  vector<ll> H(N);
  rep(i,N) cin>>H[i];

  rep(i,N+1) rep(j,K+1) rep(k,N+1) dp[i][j][k]=INF;
  dp[0][0][0]=0;
  for(int i=0;i<N;i++){
      for(int j=0;j<=K;j++){
          for(int k=0;k<=i;k++){
              if(dp[i][j][k]==INF) continue;
              ll preh=0;
              if(k>0) preh=H[k-1];
              {
                  ll neco=max(0ll,H[i]-preh);
                  chmin(dp[i+1][j][i+1],dp[i][j][k]+neco);
              }

              {
                  if(j+1<=K){
                      chmin(dp[i+1][j+1][k],dp[i][j][k]);
                  }
              }
          }
      }
  }

  ll ans=INF;
  rep(i,N+1) chmin(ans,dp[N][K][i]);
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  ll ret = 1e10;
  string s;
  cin >> s;
  for(int i = 0; i + 3 <= s.size(); i++) {
    ll curr = 0;
    for(int a = 0; a < s.size(); a++) {
      if(a >= i && a < i+3) {
        curr *= 10;
        curr += s[a] - '0';
      }
    }
    ret = min(ret, abs(curr - 753));
  }
  cout << ret << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,s=0,n;
    cin>>n>>a;
    int ara[a];
    for(int i=0;i<a;i++)
    {
        cin>> ara[i];
        s+=ara[i];
    }
    if(n>s) cout << n-s ;
    else if(n==s) cout << 0;
    else cout << -1;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
#define pii pair<lli,lli>
#define vi vector <lli>
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if(y==0) return 1%p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y);
lli modInverse(lli b, lli m)
{
    lli x, y;
    lli g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x%m + m) % m;
}
lli modDivide(lli a, lli b, lli m)
{
    a = a % m;
    lli inv = modInverse(b, m);
    return (inv * a) % m;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    lli x1, y1;
    lli gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
lli solve(lli cur){
	lli ans=0;
	while(cur>0){
		ans++;
		lli cnt=0;
		for(lli i=0;i<19;i++){
			if((cur&(1<<i))==(1<<i))
			cnt++;
		}
		//cout<<cur<<" "<<cnt<<"\n";
		cur=cur%cnt;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    string s;
    cin>>s;
    lli tot=0;
    rep(i,(lli)s.length()){
    	if(s[i]=='1')
    	tot++;
	}
	//cout<<tot<<" ";
	lli valm=0;
	lli modm=tot+1;
	//cout<<modm<<"\n";
	for(lli i=n-1;i>=0;i--){
		if(s[i]=='1'){
			valm=(valm+power(2,n-1-i,modm))%modm;	
		}
	}
	//cout<<valm<<"\n";
	lli vall=0;
	lli modl=tot-1;
	if(modl>0){
	for(lli i=n-1;i>=0;i--){
		if(s[i]=='1')
		vall=(vall+power(2,n-1-i,modl))%modl;
	}
	}
	//cout<<vall<<" "<<valm<<"\n";
	rep(i,n){
		lli cur;
		if(s[i]=='1'){
			cur=vall;
			if(modl>0){
			cur=((cur-power(2,n-i-1,modl))%modl+modl)%modl;
			}
			else{
			cout<<"0\n";
			continue;
			}
		}
		else{
			cur=valm;
			cur=(cur+power(2,n-i-1,modm))%modm;
		}
		//cout<<cur<<" ";
		lli ans=solve(cur);
		cout<<ans+1<<"\n";
		//cout<<cur<<" ";
	}
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> time_effort_vector(N);
    for(int i = 0;i < N;++i){
        cin >> time_effort_vector[i].second >> time_effort_vector[i].first; 
    }
    sort(time_effort_vector.begin(), time_effort_vector.end());
    int effort_sum = 0;
    int limit_time = 0;
    for(int i = 0; i < N; ++i){
        effort_sum += time_effort_vector[i].second;
        limit_time = time_effort_vector[i].first;
        if(limit_time < effort_sum){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  vector<char> vec(3);
  vec = {S[0],S[1],S[2]};
  sort(ALL(vec));
  if(vec[0]=='a'&&vec[1]=='b'&&vec[2]=='c')
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val (h, w) = readInts()
    val s = Array(h) { readLine()!!.toCharArray() }
    for (y in 0 until h) {
        for (x in 0 until w) {
            if (s[y][x] == '.') continue
            var p = false
            if (y != 0) {
                p = p || s[y - 1][x] == '#'
            }
            if (y != h - 1) {
                p = p || s[y + 1][x] == '#'
            }
            if (x != 0) {
                p = p || s[y][x - 1] == '#'
            }
            if (x != w - 1) {
                p = p || s[y][x + 1] == '#'
            }
            if (!p) {
                println("No")
                return
            }
        }
    }
    println("Yes")
}


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

int main()
{
  int n, m, p, s, g;
  int t[8], edge[30][30];
  double dp[1 << 8][30];
  const double INF = 1e8;

  while(cin >> n >> m >> p >> s >> g, n){
    fill_n( *edge, 30 * 30, -1);
    fill_n( *dp, (1 << 8) * 30, INF);
    s--, g--;

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

    for(int i = 0; i < p; i++){
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      edge[a][b] = c;
      edge[b][a] = c;
    }

    for(int i = 0; i < 1 << n; i++){
      dp[i][s] = 0.0;
    }

    double ret = INF;
    for(int i = (1 << n) - 1; i >= 0; i--){ //今のチケット
      ret = min( ret, dp[i][g]);
      for(int j = 0; j < m; j++){ //今の街
        if(dp[i][j] != INF){
          for(int k = 0; k < n; k++){ //使うチケット
            if(i >> k & 1){
              for(int l = 0; l < m; l++){ //次の街
                if(edge[j][l] != -1){
                  dp[i & ~(1 << k)][l] = min( dp[i & ~(1 << k)][l], dp[i][j] + (double)edge[j][l] / t[k]);
                }
              }
            }
          }
        }
      }
    }
    if(ret == INF) puts("Impossible");
    else cout << fixed << setprecision(8) << ret << endl;
  }
  return 0;
}

Measured memory_bytes: 1300
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = -1;

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    int n;
    cin >> n;
    cout << (n%1000 ? 1000-n%1000 : 0) << '\n';
}

Measured memory_bytes: 3632
# abc150_c.py
import sys
import time
import unittest
from io import StringIO
import itertools


def resolve():
    N = int(input())
    P = [int(i) for i in input().split()]
    Q = [int(i) for i in input().split()]
    a = 0
    b = 0
    i = 0
    for s in itertools.permutations(range(1, N + 1)):
        if a == 0 and tuple(s) == tuple(P):
            a = i + 1
        if b == 0 and tuple(s) == tuple(Q):
            b = i + 1
        i += 1
    print(abs(a - b))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def setUp(self):
        self.startTime = time.time()

    def tearDown(self):
        t = time.time() - self.startTime
        print('%s: %.3f' % (self.id(), t), flush=True)

    def test_入力例_1(self):
        input = """3
1 3 2
3 1 2"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1"""
        output = """17517"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3
1 2 3
1 2 3"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    if "IS_LOCAL" in locals():
        suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
        unittest.TextTestRunner(verbosity=0).run(suite)
    else:
        resolve()


Measured memory_bytes: 6216
#include<cstdio>
#include <algorithm>
#include <istream>
#include <stdio.h>
#include <iostream>
using namespace std;

int a, b;
string s, t, w;

int main()
{
	cin >> s;
	for ( int i = 0; i < s.size(); i++) {
        cout <<"x";
	}
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A = [list(map(int,rl().split())) for _ in range(3)]
    N = int(rl())
    b = [int(rl()) for _ in range(N)]
    
    bingo = [[False] * 3 for _ in range(3)]
    for bi in b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == bi:
                    bingo[i][j] = True
    
    for i in range(3):
        cnt = 0
        for j in range(3):
            cnt += bingo[i][j]
        if cnt == 3:
            print("Yes")
            exit()
    for i in range(3):
        cnt = 0
        for j in range(3):
            cnt += bingo[j][i]
        if cnt == 3:
            print("Yes")
            exit()
    cnt = 0
    for i in range(3):
        cnt += bingo[i][i]
    if cnt == 3:
        print("Yes")
        exit()
    cnt = 0
    for i, j in[[0, 2],[1,1],[2,0]]:
        cnt += bingo[i][j]
    if cnt == 3:
        print("Yes")
        exit()
    print("No")
    

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    long long int n,m;
    long long int tmp;

    scanf("%lld %lld",&n,&m);
    if (n < m){
	tmp=m;
	m=n;
	n=tmp;
    }

    if ((n == 1) && (m == 1)){
	printf("1\n");
	return 0;
    } else if (n == 2){
	printf("0\n");
	return 0;
    } else if (n >= 3){
	if (m == 1){
	    printf("%lld\n",n-2);
	    return 0;
	} else if (m == 2){
	    printf("0\n");
	    return 0;
	} else if (m >= 3){
	    printf("%lld\n",(n-2)*(m-2));
	    return 0;
	}
    }

    return 0;
}

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

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

using namespace std;

static int H, W;
static char A[16][16];

static bool solve1() {
	map<char, int> mm;
	for (int i = 0; i < H; i++)
		mm[A[i][0]]++;
	int c = 0;
	foreach (v, mm)
		if (v.second & 1)
			c++;
	if (c > 1)
		return false;
	if (c == 0)
		return true;
	return H & 1;
}

static bool matches(const char *x, const char *y) {
	for (int i = 0; i < W; i++)
		if (x[i] != y[W - i - 1])
			return false;
	return true;
}

static bool good(char B[16][16]) {
	int m = 0;
	int b = 0;
	for (int i = 0; i < H; i++) {
		if (m & (1 << i))
			continue;
		bool good = false;
		for (int j = i + 1; j < H; j++)
			if (matches(B[i], B[j])) {
				m |= (1 << j);
				good = true;
				break;
			}
		if (!good) {
			b++;
			if (b > 1 || H % 2 == 0 || !matches(B[i], B[i]))
				return false;
		}
	}
	return true;
}

static void fillcol(char B[16][16], int t, int f) {
	for (int i = 0; i < H; i++)
		B[i][t] = A[i][f];
}

static bool solve2() {
	char B[16][16];
	int m = W / 2;
	for (int mm = 0; mm < (1 << W); mm++) {
		if (__builtin_popcount(mm) != m)
			continue;
		int bc[16];
		int b = 0, c = 0;
		for (int i = 0; i < W; i++)
			if (mm & (1 << i)) {
				fillcol(B, b++, i);
			} else {
				bc[c++] = i;
			}
		do {
			for (int i = 0; i < H; i++)
				for (int j = 0; j < c; j++)
					B[i][m + j] = A[i][bc[j]];
			if (good(B))
				return true;
		} while(next_permutation(&bc[0], &bc[c]));

	}

	return false;
}

static
bool good() {
	if (W == 1)
		return solve1();
	return solve2();
	//if (solve10())
	//	return true;
	//return solve11();
}

int main(int argc, const char* argv[]) {
	scanf("%d%d\n", &H, &W);
	for (int i = 0; i < H; i++)
		scanf("%s\n", &A[i][0]);

	if (good())
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}


Measured memory_bytes: 256
n = int(input())
t_list = []
x_list = []
y_list = []
position = [0,0]
time = 0
count = 0
for i in range(n):
    t,x,y = map(int,input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)
for i in range(n):
    if abs(x_list[i]-position[0]) + abs(y_list[i]-position[1]) == t_list[i]-time:
        time = t_list[i]
        position = [x_list[i],y_list[i]]
        count += 1
    elif abs(x_list[i]-position[0]) + abs(y_list[i]-position[1]) < t_list[i]-time and ((t_list[i]-time)-(abs(x_list[i]-position[0])+abs(y_list[i]-position[1]))) % 2 == 0:
        time = t_list[i]
        position = [x_list[i],y_list[i]]
        count += 1
    else:
        print('No')
        break
if count == n:
    print('Yes')

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {
	
	int a;
	cin >> a;
	if (a % 2 == 0) {
		cout << "0.5000000000" << endl;
	}
	else {
		double b = a / 2 + 1;
		cout << setprecision(15) << b / (double)(a) << endl;
	}

}




Measured memory_bytes: 256
N = int(input())
numbers = [int(i) for i in input().split()]

new_numbers = []

cnt = 0
for i in range(1, len(numbers)-1):
    numberset = [numbers[i-1], numbers[i], numbers[i+1]]
    numberset.sort()
    if numberset.index(numbers[i]) == 1:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int ac=0,size=0,Ccnt=0;
  char s[11];
  cin >> s;
  for(int i=0;s[i]!='\0';i++)size++;
  for(int i=0;i<size;i++){
    if(i==0){
      if(s[i]!='A'){
        ac=1;
        break;
      }
    }else if(i>=2&&i<=size-2){
      if(s[i]=='C'){
        Ccnt++;
      }
    }else{
      if(!(s[i]>='a'&&s[i]<='z')){
        ac=1;
        break;
      }
    }
  }
  if(ac==0&&Ccnt==1)cout << "AC"<<endl;
  else cout << "WA"<<endl;
}


Measured memory_bytes: 256
import heapq
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def brute_force():
    N = int(input())
    L = list(map(int, input().split()))

    ans = -float('inf')
    for i in range(N, 2*N+1):
        tmp = sum(list(sorted(L[:i], reverse=True))[:N])\
            - sum(list(sorted(L[i:]))[:N])

        ans = max(ans, tmp)


def solve():
    N = int(input())
    L = list(map(int, input().split()))

    first = L[:N]
    heapq.heapify(first)
    first_sum = [0]*(N+1)
    tmp_first = sum(first)
    first_sum[0] = tmp_first
    for i in range(N, 2*N):
        first_ind = i-N+1
        if L[i] > first[0]:
            rem = heapq.heappop(first)
            heapq.heappush(first, L[i])
            tmp_first += L[i]-rem
        first_sum[first_ind] = tmp_first

    third = [-v for v in L[N*2:]]
    heapq.heapify(third)
    third_sum = [0]*(N+1)
    tmp_third = -sum(third)
    third_sum[-1] = tmp_third
    for i in reversed(range(N+1, 2*N+1)):
        third_ind = i-N-1
        if -L[i-1] > third[0]:
            rem = heapq.heappop(third)
            heapq.heappush(third, -L[i-1])
            tmp_third = tmp_third + rem+L[i-1]
        third_sum[third_ind] = tmp_third

    ans = max([f-l for f, l in zip(first_sum, third_sum)])
    print(ans)


# brute_force()
solve()


Measured memory_bytes: 39644
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	r := int(math.Floor(math.Sqrt(float64(n))))
	for i := r; i > 0; i-- {
		m := n / i
		d := n % i
		if d == 0 {
			sum := m + i - 2
			fmt.Println(sum)
			return
		}
	}
}


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

string a, s;

int main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> a >> s;
	int la = a.size(), ls = s.size(), mn = 1005;
	for (int i = 0; i <= la - ls; i ++ )
	{
		int k = 0;
		for (int j = 0; j < ls; j ++ )
			if (a[i + j] != s[j])
				k ++ ;
		mn = min(mn, k);
	}
	cout << mn << '\n';
	
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int l;cin>>l;
    vin two;
    int res=1,node=1;
    two.push_back(res);
    while(2*res<=l){
        res*=2;node++;
        two.push_back(res);
    }
    vin edge(node,inf);int m=2*(node-1);
    for(int i=node-1;i>0;i--){
        if(l-two[i-1]>=res){
            m++;
            edge[i]=l-two[i-1];
            l-=two[i-1];
        }
    }
    cout<<node<<" "<<m<<endl;
    rep2(i,1,node)cout<<i<<" "<<i+1<<" "<<0<<endl;
    rep2(i,1,node)cout<<i<<" "<<i+1<<" "<<two[i-1]<<endl;
    rep2(i,1,node)if(edge[i]!=inf)cout<<i<<" "<<node<<" "<<edge[i]<<endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;
//import java.util.Arrays;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(c >= a && c <= b ? "Yes" : "No");
	}
}


Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    bool can = false;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) can = true;
    }
    if(can) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main() {
	FASTIO;
	int d, t, s;
	cin >> d >> t >> s;
	cout << ((((double)d / (double)s) <= t) ? "Yes\n" : "No\n");
}

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

using namespace std;

int N, h[100000];
int dp[100000];

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

	dp[0] = 0; dp[1] = abs(h[0]-h[1]);
	for(int i = 2; i < N; ++i) dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]), dp[i-1]+abs(h[i-1]-h[i]));

	cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#define rep(i, n) for(int i = 0; i < n; i++)
#define ck(a, b) (0<=a && a<b)
using namespace std;
int dx[]={-1,0,1,-1,1,-1,0,1}, dy[]={-1,-1,-1,0,0,1,1,1};
int w, h; int il[50][50];

int main(){
	while(cin>>w>>h, w||h){
		int c = 0;
		rep(y, h)rep(x, w)cin>>il[y][x];
		rep(y, h)rep(x, w){
			if(il[y][x]){
				int cked[50][50] = {0};
				cked[y][x] = 1;
				bool finish = 0;
				while(!finish){
					finish = 1;
					rep(i, h)rep(j, w){
						if(cked[i][j]){
							rep(d, 8){
								if(ck(j+dx[d],w) && ck(i+dy[d],h) &&
									il[i+dy[d]][j+dx[d]] &&
									!cked[i+dy[d]][j+dx[d]]
								){
									cked[i+dy[d]][j+dx[d]] = 1; finish = 0;
								}
							}
						}
					}
				}
				c++;
				rep(i, h)rep(j, w)if(cked[i][j])il[i][j]=0;
			}
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 884
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)



INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, k = LI()
if k > (n - 1) * (n - 2) // 2:
    print(-1)
    exit(0)


ans = []
for i in range(2, n + 1):
    ans += [(1, i)]
ans += list(combinations(range(2, n + 1), 2))[:(n - 1) * (n - 2) // 2 - k]
print(len(ans))
for j in ans:
    print(*j)



Measured memory_bytes: 43760
#include <iostream>
#include <algorithm>
#include <string>

#define X first
#define Y second
#define int long long

using namespace std;

void pudge(){
    int a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);
}

signed main(){
#ifdef LOCAL
    freopen("pudge.in", "r", stdin);
    freopen("pudge.out", "w", stdout);
#endif
    ios_base::sync_with_stdio;
    cin.tie(0);
    cout.tie(0);

    pudge();

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	a, _ := strconv.Atoi(stringLineScan())
	b, _ := strconv.Atoi(stringLineScan())
	c, _ := strconv.Atoi(stringLineScan())
	if a == b && a != c {
		fmt.Println("Yes")
	} else if b == c && b != a {
		fmt.Println("Yes")
	} else if c == a && c != b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;


int n, m;
bool check(const string &s, int x){
	for(int i = x; i < x+n*2+1; i+=2) if(s[i] != 'I') return false;
	for(int i = x+1; i < x+n*2+1; i+=2) if(s[i] != 'O') return false;
	return true;
}

int main(){
	while(cin >> n, n){
		cin >> m;
		string s;
		cin >> s;
		int ans = 0;
		rep(i, m-n*2+1){
			ans += check(s, i);
		}
		cout << ans << endl;
	}

    return 0;
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    int p[a+10],q[b+10],r[c+10];
    std::priority_queue<int> que;
    
    rep(i,a){
        cin >> p[i];
    }
    rep(i,b){
        cin >> q[i];
    }
    rep(i,c){
        int x;
        cin >> x;
        que.push(x);
    }
    
    sort(p,p+a);
    sort(q,q+b);

    for(int i=0;i<x;i++){
        que.push(p[a-1-i]);
    }
    for(int i=0;i<y;i++){
        que.push(q[b-1-i]);
    }

    long long ans=0;
    rep(i,x+y){
        ans+=que.top();
        que.pop();
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> edge(N,vector<int>(N));
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--; b--;
        edge[a][b]=1;
        edge[b][a]=1;
    }
    vector<int> ary(N);
    rep(i,N){
        ary[i]=i;
    }
    int ans = 0;
    do{
        if(ary[0]!=0)break;
        bool ok = true;
        for(int ix=1;ix<N;ix++){
            if(edge[ary[ix-1]][ary[ix]]!=1){
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }while(next_permutation(ary.begin(),ary.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
import math
from functools import reduce
from collections import deque

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

r,d,x_2000 = get_nums_l()

now = x_2000
for i in range(10):
    new_a = now * r - d
    print(new_a)
    now = new_a

Measured memory_bytes: 38256
h,n=map(int,input().split())
a,b=[],[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)#ダメージ量
    b.append(B)#消費魔力

dp=[float('inf')]*(h+1)
dp[0]=0
for i in range(h):
    for j in range(n):

        next=i+a[j] if i+a[j]<=h else h
        dp[next]=min(dp[next],dp[i]+b[j])
print(dp[-1])


Measured memory_bytes: 73824
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for i in range(n)]

d=[[0]*3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      d[i][j]=1
      
if d[0][0]==1 and d[0][1]==1 and d[0][2]==1:
  print('Yes')
elif d[1][0]==1 and d[1][1]==1 and d[1][2]==1:
  print('Yes')
elif d[2][0]==1 and d[2][1]==1 and d[2][2]==1:
  print('Yes')
elif d[0][0]==1 and d[1][1]==1 and d[2][2]==1:
  print('Yes')
elif d[0][0]==1 and d[1][0]==1 and d[2][0]==1:
  print('Yes')
elif d[0][1]==1 and d[1][1]==1 and d[2][1]==1:
  print('Yes')
elif d[0][2]==1 and d[1][2]==1 and d[2][2]==1:
  print('Yes')
elif d[0][2]==1 and d[1][1]==1 and d[2][0]==1:
  print('Yes')
else:
  print('No')

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

int main(){
    char c;
    scanf("%c",&c);
    switch(c){
        case 'A': printf("T\n"); break;
        case 'T': printf("A\n"); break;
        case 'C': printf("G\n"); break;
        case 'G': printf("C\n"); break;
    }
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N;cin>>N;
    vec_int A(N);
    rep(i,N)cin>>A.at(i);

    int Q; cin>>Q;

    vec_int B(Q),C(Q);
    rep(i,Q)cin>>B.at(i)>>C.at(i);

    map<int, int> int_map;


    int init_val = 0;

    rep(i,N){
        if(int_map.count(A.at(i))==0){
            int_map[A.at(i)] = 1;
        }else{
            int_map[A.at(i)] ++ ;
        }
        init_val += A.at(i);
    }

    rep(i,Q){
        int temp = int_map[B.at(i)];
        int_map[B.at(i)] = 0;
        if(int_map.count(C.at(i))==0){
            int_map[C.at(i)] = temp;
        }else{
            int_map[C.at(i)] += temp ;
        }
        init_val -= temp*B.at(i);
        init_val += temp*C.at(i);
        cout<<init_val<<endl;

    }



    return 0;
}

Measured memory_bytes: 11324
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[50],b[50];
signed main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%d",&a[i]);
		b[i]=abs(a[i]);
	}
	int ma=max_element(b,b+n)-b;
	cout<<(n-1)*2<<endl;
	rep(i,n){
		if(i==ma)continue;
		cout<<ma+1<<' '<<i+1<<endl;
	}
	if(a[ma]>0){
		rep(i,n-1){
			cout<<i+1<<' '<<i+2<<endl;
		}
	}
	else{
		for(int i=n-2;i>=0;i--){
			cout<<i+2<<' '<<i+1<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;
const int maxn = 55;
char maze[maxn][maxn];
int h,w;

void solve(int i,int j)
{
    int num = 0;

    if(i-1 >= 0 && i-1 < h && j >= 0 && j < w && maze[i-1][j] == '#')
        num++;
    if(i-1 >= 0 && i-1 < h && j+1 >= 0 && j+1 < w && maze[i-1][j+1] == '#')
        num++;
    if(i >= 0 && i < h && j+1 >= 0 && j+1 < w && maze[i][j+1] == '#')
        num++;
    if(i+1 >= 0 && i+1 < h && j+1 >= 0 && j+1 < w && maze[i+1][j+1] == '#')
        num++;
    if(i+1 >= 0 && i+1 < h && j >= 0 && j < w && maze[i+1][j] == '#')
        num++;
    if(i+1 >= 0 && i+1 < h && j-1 >= 0 && j-1 < w && maze[i+1][j-1] == '#')
        num++;
    if(i >= 0 && i < h && j-1 >= 0 && j-1 < w && maze[i][j-1] == '#')
        num++;
    if(i-1 >= 0 && i-1 < h && j-1 >= 0 && j-1 < w && maze[i-1][j-1] == '#')
        num++;
    maze[i][j] = num+'0';
}

int main()
{
    int i,j;
    int num;

    while(scanf("%d%d",&h,&w) != EOF)
    {
        num = 0;
        for(i = 0;i < h;i++)
        {
            getchar();
            for(j = 0;j < w;j++)
            {
                scanf("%c",&maze[i][j]);
                if(maze[i][j] == '.')
                    num++;
            }
        }
        if(num > 0)
        {
            for(i = 0; i < h; i++)
            {
                for(j = 0; j < w; j++)
                {
                    if(maze[i][j] == '.')
                    {
                        solve(i,j);
                        num--;
                        if(num == 0) break;
                    }
                }
            }
        }
        for(i = 0;i < h;i++)
        {
            for(j = 0;j < w;j++)
            {
                printf("%c",maze[i][j]);
            }
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>

using namespace std;

void solve() {

}

int main() {
	long long n,a[5];
	cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] ;
	long long time = 0;
	long long min = a[0];
	for (long long i = 1; i < 5; i++) {
		if (min >= a[i]) {
			min = a[i];
		}
	}
	long long n_ = n % min;
	if (n_ != 0) {
		time = (n - n_ + min) / min;
	}
	else {
		time = n / min;
	}
	time += 4;
	cout << time;
	return 0;
}


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

int n;
string s;
int p[200010];

int main () {

	cin >> n >> s;
	for (int i = 0; i < n; i ++) {
		if (i > 0) p[i] = p[i-1];
		if (s[i] == '#') p[i] ++;
	}
	
	int mini = 1e9;
	int tren = 0;
	for (int i = n; i >= 0; i --) {
		if (i != n && s[i] == '.') tren ++;
		mini = min(mini, p[i-1]+tren);
	}
	
	cout << mini;

	return 0;
}


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

using namespace std;

ll num[1000000];

int main()
{
	ll n;
	cin>>n;
	ll minn = 1000000001;
	ll ans;
	cin>>ans;
	ll a;
	for(ll i=1; i<n; i++)
	{
		cin>>a;
		ans=__gcd(ans, a); 
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	int A, B; cin >> A >> B;
	int ans = max({A+B, A-B, A*B});

	cout << ans << endl;


	return 0;

}


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

int main(){
	int n;cin>>n;
	vector<int>a(n);
	for(auto&& w:a)cin>>w;
	int num=0,ans=0;
	for(int i=0;i<n;i++){
		if(a[i]==i+1){num++;}
		else{
			if(num!=0)ans+=(num/2)+num%2;
			num=0;
		} 
    //  cout<<num<<" "<<ans<<endl;
	}
	if(num!=0)ans+=(num/2)+num%2;
                    
	cout<<ans<<endl;	
}


Measured memory_bytes: 640
// Name: Joseph McCullough
// Program: tolower
// Description: Turns a string to lowercase.
// Visit www.mcculloughdesigns.com/blog for more c++ tutorials!
// Feel free to use this code for whatever: Work, fun, cheating on homework.

#include <string>
#include <iostream>

using namespace std;
void lowerCase(string&);

const string SENTINEL = "0"; //Used to terminate program.

int main()
{
	string userInput;        //What the user will enter to lowercase.


	getline(cin, userInput);

	//while (userInput != SENTINEL)
	//{

		lowerCase(userInput);
		cout <<userInput << "\n";

		//cout << "\nEnter the string you wish to lowercase or 0 to quit: ";
		//getline(cin, userInput);


	//}

	//cout << "\n\nProgram terminated by User.\n";

	return 0;

}

/****** function lowerCase *****
Description: makes all the characters of a string lowercase

PARAMETERS
	strToConvert: the string being manipulated

Precondition:
	strToConvert: undefined

	HEADERS
	#include <string>

Postcondition:
	Returns the string all lowercase */

void lowerCase(string& strToConvert)
{
   for(unsigned int i=0;i<strToConvert.length();i++)
   {
      strToConvert[i] = toupper(strToConvert[i]);
   }
}

Measured memory_bytes: 1184
N,M=map(int, input().split())
s=[]
c=[]
for i in range(M):
    n,a=input().split()
    s.append(int(n))
    c.append(int(a))
a=[1]
S=[1]+[0]*(N-1)

for i in range(M):
    for j in range(M):
        if s[i]==s[j] and c[i]!=c[j]:
            a.append(-1)

for i in range(M):
    if s[i]==1 and c[i]==0 and N!=1:
        a.append(-1)

for i in range(M):
    S[s[i]-1]=c[i]

if a[-1]==-1:
    print(-1)
elif N==1 and (M==0 or c[0]==0):
    print(0)
else:
    print(''.join(map(str, S)))
   

Measured memory_bytes: 3188