akhauriyash/Code-Regression huggingface dataset:
///**Bismillahir Rahmanir Rahim.**

#include <bits/stdc++.h>
#define clr(a, v)             memset(a, v, sizeof a)
#define all(v)                v.begin(), v.end()
#define ast(v)                sort(v.begin(),v.end())
#define dst(v)                sort(v.begin(),v.end(), greater <int> ())
#define fast ios_base::       sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ass(tmp, v)           tmp.assign(v.begin(), v.end())
#define mid(b, e)             (b+e)/2
#define left(node)            node*2
#define right(node)           node*2+1
#define rep(i, l, r)          for (int i = l; i < r; i++)
#define rep2(i, l, r)         for (int i = l-1; i >= r; i--)
#define sf(n)                 scanf("%d", &n)
#define sff(n, m)             scanf("%d %d",&n,&m)
#define sfl(n)                scanf("%lld", &n)
#define sffl(n, m)            scanf("%lld %lld",&n,&m)
#define sfff(n, m, o)         scanf("%d %d %d",&n,&m, &o)
#define pf(n)                 printf("%d", n)
#define sp                    printf(" ")
#define nl                    printf("\n")
#define prln(n)               printf("%d\n", n)
#define pfl(n)                printf("%lld", n)
#define pb                    push_back
#define pii                   pair<int,int>
#define mp                    make_pair
#define S                     second
#define F                     first
#define PI                    3.1415926

struct greaters
{
    bool operator()(const long& a, const long& b) const
    {
        return a > b;
    }
};

//-----------------------------------***********************----------------------------------------------//

typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int N = 200050;
const int mod = 1e9+7;

void reset(){

}

int main(){
    //freopen("test.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int tc = 1, cas = 0;
    while(tc--){
      //reset();
      ll n; cin >> n;
      ll a[n+5];
      rep(i, 0, n){
      	cin >> a[i];
	  }
	  
	  ll ans = 0, flag = 0;
	  rep(i, 0, n-1){
	  	ll xx = i+1, cnt = 0, curr = a[i];
	  	while(curr >= a[xx] and xx < n){
	  		cnt++; curr = a[xx]; xx++;
	  		if(xx == n) flag = 1;
	    }
        ans = max(ans, cnt);
        if(flag) break;
	  }
	  cout << ans << '\n';

      ///printf("Case %d: %lld\n", ++cas, ans);
    }
    return 0;

}

//-----------------------------------***********************----------------------------------------------//



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

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

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

int main(){
    int n;
    cin >> n;
    vi x(n);
    rep(i, n){
        cin >> x[i];
    }
    sort(x.begin(), x.end());

    int ans = 1000000;
    for(int i = 1; i <= x[n-1]; i++){
        int p = 0;
        for(int j = 0; j < n; j++){
            p += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans, p);
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	float ans=0;
	int temp;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>temp;
		ans+=(1.00000/temp);
	}
	cout<<(1.00000/ans)<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
 
signed main()
{
	
	int  a, b; cin>>a>>b;
if(a>=1 && a<=9  && b>=1  &&  b<=9) cout<<a*b<<"\n";
else cout<<"-1";
	
	
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int N,i,count=0;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  for(i=0;i<N;i++)
  {
    if((S[i]=='O'&&S[i+1]=='X')||(S[i]=='X'&&S[i+1]=='O'))
    {
      count++;
      i++;
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2100
def solve():
    a,b = map(int, input().split())
    s = input()

    for i in s[0:a]:
        if '0' > i or i > '9':
            print("No")
            return
    if s[a] != '-':
        print("No")
        return
    for i in s[a+1:a+b+1]:
        if '0' > i or i > '9':
            print("No")
            return
    print("Yes")
    return

solve()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
using namespace std;
typedef pair<ll, ll>P;

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true, fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct etree { ll from, to, cost; };
double pai = 3.141592653589793;
bool comp(const etree& e1, const etree& e2) {
	return e1.cost < e2.cost;
}
#define ALL(x) (x).begin(),(x).end()

int main() {
	ll n, count = 0, sum = 0, odd = 0;
	cin >> n;
	if (n == 3)cout << 2 << ' ' << 5 << ' ' << 63 << endl;
	else {
		for (int i = 2;i <= 30000;i++) {
			if (count == n - 2) {
				for (int j = i;j <= 30000;j++) {
					if (j % 2 != 0 && j % 3 != 0)continue;
					for (int k = j + 1;k <= 30000;k++) {
						if (k % 2 != 0 && k % 3 != 0)continue;
						if (odd % 2 == 1) {
							if (j % 2 == 1 && k % 2 == 0) {
								if ((sum + j + k) % 6 == 0) {
									cout << j << ' ' << k << endl;
									exit(0);
								}
							}
							else if (j % 2 == 0 && k % 2 == 1) {
								if ((sum + j + k) % 6 == 0) {
									cout << j << ' ' << k << endl;
									exit(0);
								}
							}
						}
						else {
							if (j % 2 == 0 && k % 2 == 0) {
								if ((sum + j + k) % 6 == 0) {
									cout << j << ' ' << k << endl;
									exit(0);
								}
							}
							else if (j % 2 == 1 && k % 2 == 1) {
								if ((sum + j + k) % 6 == 0) {
									cout << j << ' ' << k << endl;
									exit(0);
								}
							}
						}
					}
				}
			}
			if (i % 2 == 0 || i % 3 == 0) {
				cout << i << ' ';
				count++;
				sum += i;
				if (i % 2 == 1)odd++;
			}
		}
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
 
using namespace std;
 
int main() {
	int h, w; cin >> h >> w;
	vector<vector<pair<int, int> > > lcnt(h + 2, vector<pair<int, int> >(w + 2, make_pair(0, 0)));
	vector<vector<pair<int, int> > > rcnt(h + 2, vector<pair<int, int> >(w + 2, make_pair(0, 0)));
	vector<string> s(h);
	for (int i = 0; i < h; ++i) cin >> s[i];
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			if (s[i - 1][j - 1] == '.') {
				lcnt[i][j].first += lcnt[i][j - 1].first + 1;
				lcnt[i][j].second += lcnt[i - 1][j].second + 1;
			}
		}
	}
	for (int i = h; i > 0; --i) {
		for (int j = w; j > 0; --j) {
			if (s[i - 1][j - 1] == '.') {
				rcnt[i][j].first += rcnt[i][j + 1].first + 1;
				rcnt[i][j].second += rcnt[i + 1][j].second + 1;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			ans = max(ans, lcnt[i][j].first + lcnt[i][j].second + rcnt[i][j].first + rcnt[i][j].second - 3);
		}
	}
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 67200
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a[100100], x, res;
bool k[33];

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,n) {
		x ^= a[i];
		int t = a[i]^(a[i]-1);
		k[__builtin_popcount(t)] = 1;
	}
	for (int i=30; i>=0; i--) if (x>>i&1){
		if (k[i+1]) x ^= (1<<(i+1)) - 1, res++;
		else return cout << -1 << endl, 0;
	}
	cout << res << endl;
}

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

using namespace std;

typedef long long llint;
typedef tuple<llint, llint, llint> TP;

int main() {
  int n, q;
  cin >> n >> q;
  vector<TP> v;
  for (int i = 0; i < n; i++) {
    llint s, t, x;
    cin >> s >> t >> x;
    v.emplace_back(s - x, 0, x);
    v.emplace_back(t - x, 1, x);
  }

  for (int i = 0; i < q; i++) {
    llint d;
    cin >> d;
    v.emplace_back(d, 2, i);
  }
  sort(v.begin(), v.end());

  vector<llint> ans(q);
  multiset<llint> se;
  for (auto &w : v) {
    llint s, k, x;
    tie(s, k, x) = w;
    if (k == 0) {
      se.insert(x);
    } else if (k == 1) {
      se.erase(se.lower_bound(x));
    } else {
      ans[x] = (se.empty() ? -1 : *se.begin());
    }
  }

  for (auto &w : ans) {
    cout << w << endl;
  }

  return 0;
}

Measured memory_bytes: 27364
#include <stdio.h>
#include <stdbool.h>

bool
check(int n, int *d, int k)
{
  while (n > 0) {
    int x = n % 10;
    for (int i = 0; i < k; i++) {
      if (d[i] == x) return false;
    }
    n /= 10;
  }
  return true;
}

int
main(int argc, char *argv[])
{
  int n, k, d[10];
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) scanf("%d", &d[i]);

  while(!check(n, d, k)) n++;

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

  return 0;
}


Measured memory_bytes: 128
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: Jalpaiguri Govt Enggineering College
*/
#include <bits/stdc++.h>
#include<algorithm>
#include<string>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class type1>
// using ordered_multiset = tree <type1, null_type, less_equal <type1>, rb_tree_tag, tree_order_statistics_node_update>;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 

#define ll int
#define int long long
#define ld long double
#define ff first
#define ss string 
#define se second
#define endl "\n"
#define alt(v) v.begin(),v.end()
#define ralt(v) v.rbegin(),v.rend()
#define pb emplace_back
#define mp make_pair
#define fab(i,a,b) for(int i=(a);i<(b);i++)
#define fba(i,a,b) for(int i=(b);i>=(a);i--)
int mod=1000000007;
// int mod=998244353;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};

bool test  = 0;
const int inf = 1e18;
const int N = 1e5+5;




void findDivisors(int n) 
{ 
  
    int div[n + 1]; 
    memset(div, 0, sizeof div); 
  
    // For every number from 1 to n 
    for (int i = 1; i <= n; i++) { 
  
        // Increase divisors count for 
        // every number divisible by i 
        for (int j = 1; j * i <= n; j++) 
            div[i * j]++; 
    } 
  
    int ans = 0;
    for (int i = 1; i <= n; i++) 
        ans += div[i];
    cout<<ans<<"\n";
} 





void solve()
{
  int n;
    cin >> n;
    findDivisors(n-1);
}
 
 
 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // precompute();
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
} 

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


int main()
{ 
  ll n;
  cin>>n;
int arr[32]={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<<arr[n-1];
return 0;
}


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000

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

    ll n, m, res = 0, k, a;
	cin >> n >> m;
	map<ll, ll> mapa;

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

	for(auto&p : mapa){
		if(p.ss == n){
			res++;
		}
	}

	cout << res << endl;
	
	return 0;
}


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

using namespace std;

// 最大公約数
long long gcd(long long a, long long b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (b == 0) return a;
    else return gcd(b, a % b);
}

// 最小公倍数
long long lcm(long long a, long long b) {
    long long g = gcd(a, b);
    return a / g * b;
}

int main() {
    long int a,b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
    return 0;
}

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

int main() {
  string S;
  cin>>S;
  vector<int>a(4);
  int ans=1,got=1;
  for(int i=0;i<S.size();i++){
    if(S[i]=='E'){
      a[0]++;
    }
    else  if(S[i]=='W'){
      a[1]++;
    }
        else  if(S[i]=='S'){
      a[2]++;
    }
        else {
      a[3]++;
    }
  }
 if(a[0]==0){
   if(a[1]>0){
     cout<<"No"<<endl;
     return 0;
   }
 }
   if(a[0]>0){
   if(a[1]==0){
     cout<<"No"<<endl;
     return 0;
   }
 }
   if(a[2]==0){
   if(a[3]>0){
     cout<<"No"<<endl;
     return 0;
   }
 }
   if(a[2]>0){
   if(a[3]==0){
     cout<<"No"<<endl;
     return 0;
   }
 }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}
//union_find(親par,深さrnk)
const int MXV=100000;
int par[MXV],rnk[MXV],siz[MXV];
void union_init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        rnk[i]=0;
        siz[i]=1;
    }
}
//根を探す
int find(int x){
    if(par[x]==x){
        return x;
    }
    else{
        return par[x]=find(par[x]);
    }
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y){
        return;
    }
    if(rnk[x]<rnk[y]){
        par[x]=y;
        siz[y]+=siz[x];
        siz[x]=0;
    }
    else{
        par[y]=x;
        siz[x]+=siz[y];
        siz[y]=0;
        if(rnk[x]==rnk[y]){
            rnk[x]++;
        }
    }
}
//集合が同じか
bool same(int x,int y){
    return find(x)==find(y);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,M;
    cin >> N >> M;
    union_init(N);
    vl A(M),B(M);
    rep(i,M){
        cin >> A[i] >> B[i];
    }
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    vl ans;
    ll now=N*(N-1)/2;
    rep(i,M){
        ans.pb(now);
        if(same(A[i],B[i])){
            continue;
        }
        else{
            ll sa=siz[find(A[i])],sb=siz[find(B[i])];
            now+=(sa*(sa-1)/2+sb*(sb-1)/2);
            unite(A[i],B[i]);
            ll sn=siz[find(A[i])];
            now-=sn*(sn-1)/2;
        }
    }
    reverse(ans.begin(),ans.end());
    rep(i,M){
        cout << ans[i] << endl;
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Measured memory_bytes: 6996
k = gets.to_i
ans = 0
def gcd(i,j,k)
    x = i
    y = j
    z = k
    while y != 0
        x,y = y,x%y
    end
    while z != 0
        x,z = z,x%z
    end
    return x
end

if k>=3
    k.times do |a|
        (a+1).upto(k-2) do |b|
            (b+1).upto(k-1) do |c|
                ans += 6*gcd(a+1,b+1,c+1)
            end
        end
    end
end

if k>=2
    k.times do |a|
        k.times do |b|
            if a != b
                ans += 3*gcd(a+1,a+1,b+1)
            end
        end
    end
end
k.times do |a|
    ans += gcd(a+1,a+1,a+1)
end
puts ans

Measured memory_bytes: 14308
import math
N = int(input())
x = []
y = []
total = 0
for i in range(N):
  a,b = map(int,input().split())
  x.append(a)
  y.append(b)
for i in range(N):
  for j in range(N-(i+1)):
    d = math.sqrt( (x[i]-x[i+j+1])**2 + (y[i]-y[i+j+1])**2 )
    total += d
ans = total * 2 / N
print(ans)

Measured memory_bytes: 3064
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 2000000007
#define infll 1e18
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define PI acos(-1)
#define sz(a) (int) (a).size()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;
typedef long double ld;

const int N = 1000002;
int n,dp[N];


int solve(int n) {
    if(n < 0) return infi;
    if(!n) return 0;
    if(~dp[n]) return dp[n];
    dp[n] = 1+solve(n-1);
    int j = 1;
    while (j <= n) dp[n] = min(dp[n], 1+solve(n-j)), j*=6;
    j = 1;
    while (j <= n) dp[n] = min(dp[n], 1+solve(n-j)), j*=9;
    
    return dp[n];
}


int main(int argc, const char * argv[]) {
    scanf("%d",&n);
    clr(dp, -1);
    lp(i, 1, n) solve(i);
    printf("%d\n",solve(n));
//    printf("%d\n",n);
    
    return 0;
}

/*
 6
 2 2 2 2 2 2
 1 6
 6 3
 3 4
 4 2
 6 5
 */





Measured memory_bytes: 4096
#include <stdio.h>

int main(){

   int a,b,c,n1,n2;
   n1=0;
   n2=0;
   while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
      if(c*c==a*a+b*b)
         n1++;
      if(a==b)
         n2++;
   }
   printf("%d\n%d\n",n1,n2);
   return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const lb PI=3.14159265359;

int main(){

  ll a,b,c;cin>>a>>b>>c;
  ll x,y;cin>>x>>y;

  ll mi=INF;
  rep(i,0,max(x,y)+1){
    chmin(mi,i*2*c+max((ll)0,x-i)*a+max((ll)0,y-i)*b);
  }
  out(mi);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a[20]="CODEFESTIVAL2016";
  char s[20];
  int b=0;
  cin>>s;
  for(int i=0;i<16;i++)
    if(a[i]!=s[i])
      b++;
  cout<<b<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int MN = 100005;

int N, L, T, X[MN], W[MN], Y[MN], Id[MN];
int X1[MN], X2[MN], C1, C2;
int Ans[MN];

inline LL Q1(LL v) {
	LL w = (v % L + L) % L, k = (v - w) / L;
	return std::upper_bound(X1, X1 + C1, w) - X1 + k * C1;
}
inline LL Q2(LL v) {
	LL w = (v % L + L) % L, k = (v - w) / L;
	return std::upper_bound(X2, X2 + C2, w) - X2 + k * C2;
}

int main() {
	scanf("%d%d%d", &N, &L, &T);
	for (int i = 0; i < N; ++i) {
		scanf("%d%d", &X[i], &W[i]);
		if (W[i] == 1) X1[C1++] = X[i];
		if (W[i] == 2) X2[C2++] = X[i];
	}
	for (int i = 0; i < N; ++i) {
		Y[i] = X[i];
		if (W[i] == 1) {
			Y[i] = (Y[i] + T) % L;
			Id[i] = (i + Q2(X[i] + 2ll * T) - Q2(X[i])) % N;
		}
		if (W[i] == 2) {
			Y[i] = (Y[i] - T % L + L) % L;
			Id[i] = ((i - Q1(X[i] - 1) + Q1(X[i] - 2ll * T - 1)) % N + N) % N;
		}
		Ans[Id[i]] = Y[i];
	}
	for (int i = 0; i < N; ++i) printf("%d\n", Ans[i]);
	return 0;
}

Measured memory_bytes: 4056
AIR_PORTS = ['A', 'B', 'C']


def get_input():
    PandQandR = input().split(" ")
    P = int(PandQandR[0])
    Q = int(PandQandR[1])
    R = int(PandQandR[2])
    return P, Q, R


def calc_flight_time(flight_time_list):
    min = 500
    for i, time_1 in enumerate(flight_time_list):
        for j, time_2 in enumerate(flight_time_list):
            if i == j:
                continue
            result_time = time_1 + time_2
            if min > result_time:
                min = result_time
    return min


def main():
    P, Q, R = get_input()
    flight_time_list = [P, Q, R]
    result_time = calc_flight_time(flight_time_list)
    print(result_time)


if __name__ == '__main__':
    main()


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

string S;

int main(){
	cin >> S;

	long long ans = S.size();
	for(long long i = 0; i < S.size() - 1; i++){
		if(S[i] != S[i+1]){
			long long tmp = max(i + 1, (long long)S.size() - i - 1);
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
    long n, k;
    cin >> n >> k;

    vector<long> a(n);
    for(auto &x: a) cin >> x;

    long sum = accumulate(a.begin(), a.end(), 0LL);

    long res = 1;
    vector<long> b(n);

    for(long qq=1; qq*qq<sum; qq++) {
        if(sum % qq != 0) continue;

        for(long q : {qq, sum/qq}) {
            copy(a.begin(), a.end(), b.begin());

            for(auto &x: b) x %= q;
            sort(b.begin(), b.end());

            long s = accumulate(b.begin(), b.end(), 0LL,
                    [=](long acc, long x) {return acc + (q-x);});

            long t = 0, r = 1e9;
            for(int i=0; i<n; i++) {
                r = min(max(t, s), r);
                t += b[i];
                s -= q - b[i];
            }
            r = min(max(t, s), r);

            if(r <= k)
                res = max(res, q);

        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        if(n%2==0)
            printf("%d\n",n);
        else
            printf("%d\n",2*n);
    }
    return 0;
}


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

int main(void)
{
    char w[16];
    
    scanf("%s", w);
    
    if (strcmp(w, "Sunny") == 0) {
        printf("Cloudy\n");
    } else if (strcmp(w, "Cloudy") == 0) {
        printf("Rainy\n");
    } else if (strcmp(w, "Rainy") == 0) {
        printf("Sunny\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair

int main(){
	int t,n,s=1000;
	vvi field(s*2+3,vi(s*2+3,0));
	while(cin>>t>>n,t){
		auto v=field;
	    int x,y;
		rep(i,n+1){
		    cin>>x>>y;
		    x+=s+1,y+=s+1;
        	v[y][x]=1;
		}
		queue<pair<int,pii>> que;
		que.emplace(0,mp(y,x));
		vi f={0,1,1,0,-1,-1,0};
		int ans=1;
		while(que.front().fs<t && !que.empty()){
		    auto c=que.front().sc;
		    rep(i,6){
		        if(v[c.fs+f[i]][c.sc+f[i+1]]==0){
		            ans++;
		            que.emplace(que.front().fs+1, mp(c.fs+f[i], c.sc+f[i+1]));
		            v[c.fs+f[i]][c.sc+f[i+1]]=2;
		        }
		    }
		    que.pop();
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 34424
#include<iostream>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>
#include"boost/algorithm/string.hpp"

using namespace std;


int main(){


	/*Q1*/

	int a, b, c;
	cin >> a >> b >> c;

	if (a < b){
		if (a < c && c < b){
			cout << "Yes" << endl;
			return 0;
		}
	}

	else{
		if (b < c && c < a){
			cout << "Yes" << endl;
			return 0;
		}


	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
const ll MOD = 1e9 + 7;

ll N, K;
vector<vector<ll>> imos;

int main(){
    cin >> N >> K;
    imos = decltype(imos)(1010, vector<ll>(2010));
    for(ll HOPE = 0; HOPE < N; HOPE++){
#if 0
        imos = decltype(imos)(1010, vector<ll>(2010));
#endif
        ll x, y;
        char c;
        cin >> x >> y >> c;
        x %= 2 * K;
        y %= 2 * K;
        if(c == 'W') y += K;
        if(x >= K){
            x -= K;
            y += K;
        }
        y %= 2 * K;
        imos[x][y]++;
        imos[K][y]--;
        imos[x][min(2 * K, y + K)]--;
        imos[K][min(2 * K, y + K)]++;
        if(2 * K < y + K){
            ll dic = y - K;
            imos[x][0]++;
            imos[K][0]--;
            imos[x][dic]--;
            imos[K][dic]++;
        }
        if(x){
            y += K;
            y %= 2 * K;
            imos[0][y]++;
            imos[x][y]--;
            imos[0][min(2 * K, y + K)]--;
            imos[x][min(2 * K, y + K)]++;
            if(2 * K < y + K){
                ll dic = y - K;
                imos[0][0]++;
                imos[x][0]--;
                imos[0][dic]--;
                imos[x][dic]++;
            }
        }
#if 0
        for(ll x = 0; x <= K; x++) for(ll y = 0; y <= 2 * K; y++) imos[x + 1][y] += imos[x][y];
        for(ll y = 0; y <= 2 * K; y++) for(ll x = 0; x <= K; x++) imos[x][y + 1] += imos[x][y];
        for(ll i = 2 * K; i >= 0; i--){
            for(ll j = 0; j <= K; j++) cout << imos[j][i] << ' ';
            cout << endl;
        }
        cout << "\n=====================\n";
#endif
    }
    for(ll x = 0; x <= K; x++) for(ll y = 0; y <= 2 * K; y++) imos[x + 1][y] += imos[x][y];
    for(ll y = 0; y <= 2 * K; y++) for(ll x = 0; x <= K; x++) imos[x][y + 1] += imos[x][y];
#if 0
    for(ll i = 2 * K; i >= 0; i--){
        for(ll j = 0; j <= K; j++) cout << imos[j][i] << ' ';
        cout << endl;
    }
#endif
    ll ans = 0;
    for(ll x = 0; x < K; x++) for(ll y = 0; y < 2 * K; y++) ans = max(ans, imos[x][y]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16128
import sys
input = sys.stdin.readline

def main():
    N,K = map(int,input().split())
    _a = list(map(int,input().split()))
    l = sum(_a).bit_length()
    cum = [0]
    for i in range(N):
        cum.append(cum[-1]+_a[i])

    a = []
    for i in range(1,N+1):
        for j in range(i):
            a.append(cum[i]-cum[j])

    bit = 2**(l-1)
    use = []
    ans = 0
    for _ in range(l):
        for num in a:
            if num&bit == bit:
                use.append(num)
        if len(use) >= K:
            ans += bit
            a = use
        use = []
        bit //= 2
        
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 23880
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    int res = -1;
    for (int st = 0; st < n; ++st) {
        vector<int> d(n, -1);
        queue<int> q;
        d[st] = 0;
        q.push(st);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int i = 0; i < n; ++i) {
                if (s[v][i] == '1') {
                    if (d[i] == -1) {
                        d[i] = d[v] + 1;
                        q.push(i);
                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (s[i][j] == '1') {
                    if (d[i] == d[j]) {
                        cout << -1 << endl;
                        return;
                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            res = max(res, d[i] + 1);
        }

    }
    cout << res << endl;


}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main()
{
	int N, Q, correct;
	long K;

	std::cin >> N >> K >> Q;

	std::vector<int>A(N, 0);

	for (int count = 0; count < Q; count++)
	{
		std::cin >> correct;
		A[correct - 1]++;
	}

	for (int i = 0; i < N; i++)
	{
		A[i] -= Q - K;
		int buffer = A[i];
		std::cout << (A[i] > 0 ? "Yes" : "No") << std::endl;
	}
}

Measured memory_bytes: 1024
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

arr = list(itertools.permutations(range(1,n+1),n))
arr = sorted(arr)
for i in range(len(arr)):
    if list(arr[i]) == p:
        a = i
    if list(arr[i]) == q:
        b = i
print(abs(b-a))

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

int main(int argc, char *argv[])
{
    int h,w;
    char line[256];

    while (1) {

        if (!fgets(line, sizeof(line), stdin)) {
            fprintf(stderr, "error input val\n");
            return -1;
        }

        if (sscanf(line, "%d %d", &h, &w) != 2) {
            fprintf(stderr, "error input format\n");
            return -1;
        }

        if (!h && !w) {
            return 0;
        }

        int i, j;

        for (i=0; i<h; i++){
            for (j=0; j<w; j++){
                if ((i != 0 && i != h-1) &&
                    (j != 0 && j != w-1)) {
                    printf(".");
                    continue;
                }
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("gold.in","r",stdin);
	freopen("gold.out","w",stdout);
#endif
}
int n,a[N];
void input()
{
	n=read<int>();
	For(i,1,n)a[i]=read<int>();
}
void work()
{
	int fir=1,even,odd,pos,gcd;
	while(true)
	{
		fir^=1;
		even=odd=0;
		For(i,1,n)
		{
			if(a[i]&1)odd++,pos=i;
			else even++;
		}
		if(even&1)
		{
			if(!fir)puts("First");
			else puts("Second");
			return;
		}
		else
		{
			if((odd==1&&a[pos]==1)||odd>=2)
			{
				
				if(!fir)puts("Second");
				else puts("First");
				return;
			}
			a[pos]--;
			gcd=a[1];
			For(i,2,n)gcd=__gcd(gcd,a[i]);
			For(i,1,n)a[i]/=gcd;
		}
	}
}
int main()
{
//	file();
	input();
	work();
	return 0;
}

Measured memory_bytes: 640
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    VI ans(n+1);
    for (int i = 2; i <= n; i++)
        cin >> a[i], ans[a[i]]++;

    for (int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
}



Measured memory_bytes: 4792
# -*- coding: utf-8 -*-
# 標準入力の取得
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A, B = [], []
for m in range(M):
    A_m, B_m = list(map(int, input().split()))
    A.append(A_m)
    B.append(B_m)


def main() -> None:
    """Entry point
    """
    # 求解処理
    # 道ごとに「良い展望台」ではない展望台を削除し、残りの展望台の数を計算する。
    observatory = [True for n in range(N)]  # 初期状態はすべて「良い展望台」
    for A_m, B_m in zip(A, B):
        A_m -= 1  # インデックス番号に変換
        B_m -= 1  # インデックス番号に変換
        if H[A_m] < H[B_m]:
            observatory[A_m] = False
        elif H[A_m] > H[B_m]:
            observatory[B_m] = False
        else:
            observatory[A_m] = False
            observatory[B_m] = False

    result = sum(observatory)

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22976
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;
using ll = long long;

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

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

  vector<vector<ll>> count(10, vector<ll>(10, 0));

  for(ll i = 1; i <= n; ++i){
    string nStr = to_string(i);
    ++count[ctoi(nStr[0])][ctoi(nStr.back())];
  }

  ll ans = 0;
  // 対角線 (a, a)の個数
  for(ll i = 1; i < 10; ++i){
    if(i <= n){
      ans += count[i][i];
    }

    if(count[i][i] >= 2){
      ans += count[i][i] * (count[i][i] - 1);
    }
  }

  for(ll i = 1; i < 10; ++i){
    for(ll j = i+1; j < 10; ++j){
      if(count[i][j] != 0 && count[j][i] != 0){
        ans += count[i][j]*count[j][i]*2;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  if (n >= 1000)
    outl("ABD");
  else
    outl("ABC");
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888
using System;
using System.Linq;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int M = int.Parse(input[1]);
    int X = int.Parse(input[2]);
    int Y = int.Parse(input[3]);
    
    input = Console.ReadLine().Split(' ');
    int[] xArr = new int[N];
    for (int i = 0; i < N; i++) {
      xArr[i] = int.Parse(input[i]);
    }
    
    input = Console.ReadLine().Split(' ');
    int[] yArr = new int[M];
    for (int i = 0; i < M; i++) {
      yArr[i] = int.Parse(input[i]);
    }
    
    bool result = false;
    for (int z = X + 1; z <= Y; z++) {
      if (xArr.Max() < z && z <= yArr.Min()) {
        result = true;
        break;
      }
    }
    Console.WriteLine(result ? "No War" : "War");
  }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	long double ax, ay, bx, by, cx, cy, dx, dy;
	int num;
	cin >> num;
	while (cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
		/**
		double inner = (by - ay)*(dy - cy) + (bx - ax)*(dx - cx);
		double length = sqrt((by - ay)*(by - ay) + (bx - ax)*(bx - ax))
			* sqrt((dy - cy)*(dy - cy) + (dx - cx)*(dx - cx));
		*/
		//if(max(inner - length, length - inner) < 1e-5) {
		if((bx - ax) * (dy - cy) - (by - ay) * (dx - cx) == 0){
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
		//cout << (bx - ax) * (dy - cy) - (by - ay) * (dx - cy) << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    t = input().rstrip()
    alphabet = 'abcdefghijklmnopqrstuvwxyz' #26

    for a in alphabet:
        l1, l2 = [], []
        for i in range(len(s)):
            if t[i] == a:
                l1.append(s[i])
            if s[i] == a:
                l2.append(t[i])
        if len(set(l1)) > 1 or len(set(l2)) > 1:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

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

const string dd = "ESWN";
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

class State
{
public:
  int x, y, d;
  State(int _x = 0, int _y = 0, int _d = 0)
    :x(_x), y(_y), d(_d) {}
};

int main()
{
  int H, W;
  long long int L;
  while (cin >> H >> W >> L) {
    if ((H|W|L) == 0)
      break;

    State s;
    vector<string> c(H);
    for (int i = 0; i < H; ++i) {
      cin >> c[i];
      if (c[i].find_first_of(dd) != string::npos) {
	s.y = i;
	s.x = c[i].find_first_of(dd);
	s.d = dd.find_first_of(c[s.y][s.x]);
	c[s.y][s.x] = '.';
      }
    }

    vector<vector<vector<long long int> > > visited(H, vector<vector<long long int> >(W, vector<long long int>(4, -1)));
    for (long long int i = 0; i < L; ++i) {
      if (visited[s.y][s.x][s.d] == -1) {
	visited[s.y][s.x][s.d] = i;
      } else {
	long long int diff = i - visited[s.y][s.x][s.d];
	i = L - ((L - i) % diff);
	if (i == L)
	  break;
      }
      
      while (s.x+dx[s.d] < 0 || W <= s.x+dx[s.d] ||
	     s.y+dy[s.d] < 0 || H <= s.y+dy[s.d] ||
	     c[s.y+dy[s.d]][s.x+dx[s.d]] == '#')
	s.d = (s.d+1) % 4;

      s.x += dx[s.d];
      s.y += dy[s.d];
    }

    cout << s.y+1 << " " << s.x+1 << " " << dd[s.d] << endl;
  }
  return 0;
}

Measured memory_bytes: 1464
import sys
input = sys.stdin.readline
import math

def Main(n):
    fl = math.floor(math.sqrt(n))
    a = b = 0
    for i in range(fl, 0, -1):
        if(n % i == 0):
            a = n // i
            break
    b = n // a
    return a + b - 2   

def main():
    N = int(input())
    print(Main(N))


if __name__ == '__main__':
    main()

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

int main(){

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

    sort(a.begin(), a.end());
    cout << (a[0] * a[1]) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
l = []
while True:
  a,op,b = input().split()
  if op == '?':
    break
  l.append((a,op,b))
for t in l:
  na = int(t[0])
  nb = int(t[2])
  op = t[1]
  if op == '+':
    print(na+nb)
  elif op == '-':
    print(na-nb)
  elif op == '*':
    print(na*nb)
  elif op == '/':
    print(na//nb)


Measured memory_bytes: 5600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int b[1000000+5],q,l,r;
bool check(int x){
	bool flag=true;
	if(x==1){return false;}
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0){
			flag=false;
			break;
		}
	}
	return flag;
}
int main(){
	for(int i=1;i<=100000;i++){
		b[i]=b[i-1];
		if(i%2==1&&check(i)&&check((i+1)/2)){
			b[i]++;
		}
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		scanf("%d%d",&l,&r);
		if(l>r){swap(l,r);}
		printf("%d\n",b[r]-b[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
light_rule = {n:int(input())-1 for n in range(N)}

light = ["1"]+["0"]*(N-1)

flag = 0
num = 0
bottun = 0
for _ in range(int(1e6)):
    if light[1] == "1":
        flag = 1
        break
    num += 1
    # print(bottun, light_rule[bottun])
    light[bottun] = "0"
    light[light_rule[bottun]] = "1"
    bottun = light_rule[bottun]
    # print(light)
    
if flag:
    print(num)
else:
    print(-1)

Measured memory_bytes: 57048
#include <stdio.h>

int main()
{
  int a[4] = {0}, b[4] = {0};
  int hit, blow;
  int i, j;

  while (scanf("%d", &a[0]) != EOF){

    for (i = 1; i < 4; i++)
      scanf("%d", &a[i]);

    for (i = 0; i < 4; i++)
      scanf("%d", &b[i]);

    hit = 0;
    blow = 0;

    for (i = 0; i < 4; i++){
      if (a[i] == b[i])
        hit++;
      for (j = 0; j < 4; j++){
        if (a[i] == b[j])
          blow++;
      }
    }

    blow -= hit;

    printf("%d %d\n", hit, blow);
  }

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define MP make_pair
#define mod 1000000007
#define int long long
signed main(){
    boost;
    char a;
  cin>>a;
  if(a<97)
    cout<<"A";
  else
    cout<<"a";
}


Measured memory_bytes: 3652
N = int(input())
A = []
for i in input().split():
    A.append(int(i))

sA = 0
for i in range(1, N, 2):
    sA += A[i]
x = sum(A) - 2 * sA
print(x, end=" ")
for i in range(N-1):
    x = 2*A[i]-x
    print(x, end=" ")
print()
    

Measured memory_bytes: 14024
N,X = list(map(int,input().split()))
a = [1]
p = [1]
def f(n,x):
    if x == 1:
        if n == 0:return 1
        else:return 0
    elif 1 < x and x < 2+a[n-1]:
        return f(n-1,x-1)
    elif 2+a[n-1] == x:
        return 1 + p[n-1]
    elif 2+a[n-1] < x and x < 3+2*a[n-1]:
        return p[n-1]+1+f(n-1,x-2-a[n-1])
    else:
        return 2*p[n-1]+1


for i in range(1,N+1):
    a.append(2*a[i-1]+3)
    p.append(2*p[i-1]+1)

print(f(N,X))

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(min(a, b) < c && c < max(a, b)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256