akhauriyash/Code-Regression huggingface dataset:
// code.begin();
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back 
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define my_time ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define endl "\n"
#define MOD 1000000007
const long long int INF=1e18;
#define mod 1000000007
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
//find_by_order(x)
//order_of_key(x)  


int power(int x,unsigned int y)
{
    int res=1;
    
    while(y>0)
    {
        // if y is odd multiply with result
        if(y&1)
        res=res*x;
        
        y=y>>1; // y=y/2;
        x=x*x;
        
    }
    return res;
}

int gcd(int a,int b)
{
    if(b==0)
    return a;
    
    return gcd(b,a%b);
}

ll  max3(ll  a, ll  b, ll c)
{
    return max(c, max(a, b));
}
int min3(int a, int  b, int  c)
{
    return min(a, min(b, c));
}

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int logg(int  a)
{
    int  x = 0;
    while (a > 1)
    {
        x++;
        a /= 2;
    }
    return x;
}


int modinv(int x)
{
    return powermod(x, mod - 2, mod);
}
map<int,int> m;int n;
double dp[305][305][305];
double solve(int a,int b,int c)
{
    if(a+b+c==0)
    return 0.0;
    
    if(dp[a][b][c]>-0.5)
    {
        return dp[a][b][c]; 
    }
    
    double k=(double)n/(a+b+c);
    
    double res=0;
    if(a)
    {
        res+=(k+solve(a-1,b,c))*a/(a+b+c);
    }
    if(b)
    {
         res+=(k+solve(a+1,b-1,c))*b/(a+b+c);
    }
    if(c)
    {
         res+=(k+solve(a,b+1,c-1))*c/(a+b+c);
    }
    
return dp[a][b][c]=res;
    
    
    
}




int  main(){
	my_time;

int t;
t=1;
//cin>>t;int test=0;
while(t--)
{

  cin>>n;
  int x=0;
  m[1]=m[2]=m[3]=0;
  for(int i=0;i<n;i++)
  {
      cin>>x;
      m[x]++;
  }
  
  for(int i=0;i<=n;i++)
  {
      for(int j=0;j<=n;j++)
      {
          for(int k=0;k<=n;k++)
          {
              dp[i][j][k]=-1;
          }
      }
  }
  
  double  res=solve(m[1],m[2],m[3]);
  printf("%.12f",res);
  
  
}
    return 0;
}


//code.end();





Measured memory_bytes: 220924
#include <stdio.h>
int main(){
	char c;
	char n;
	while(scanf("%c",&c)!=EOF){
		if(c!='@') printf("%c",c);
		else{
			scanf("%c",&n);
			n-=48;
			scanf("%c",&c);
			for(int i=0;i<n;i++) printf("%c",c);
		}
	}
	return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll maxv=0, n, count=0, h, h2;
  cin >> n;
  cin >> h;
  forll(i, 1, n){
	cin >> h2;
	if (h >= h2){
	  count += 1;
	}
	else{
	  if(maxv < count)
		maxv = count;
	  count = 0;
	}
	h = h2;
  }
  cout << max(maxv, count) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int x = abs(a-b);
  int y = abs(b-c);
  int z = abs(c-a);
  int maxi = max(max(x,y),z);
  cout << x+y+z-maxi << endl;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())

N -= 2

BIT = [[0 for i in range(N+1)] for _ in range(2)]
n = N
def BIT_query(idx,BIT):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

def BIT_update(idx,x,BIT):
    while idx <= n:
        BIT[idx] += x
        idx += idx&(-idx)
    return

now = N * N
max_x = [0, 0]
for _ in range(Q):
  s, x = map(int, input().split())
  s -= 1
  x -= 1
  x = N+1 - x
  #print()
  depth = N + BIT_query(x, BIT[s])
  now -= depth
  #print(x, s, depth, now, BIT_query(x, BIT[s]), max_x[s])
  
  if x > max_x[s]:
    BIT_update(N-depth+1, max_x[s] - x, BIT[1-s])
    max_x[s] = x
    
print(now)   
  
  
  
  

Measured memory_bytes: 94148
#!/usr/bin/python3

def genindex(N, S):
    index = [0] * len(S)
    c = 0
    i = 0
    while i < len(S)-1:
        if S[i] == 'A' and S[i+1] == 'C':
            c+=1
            index[i] = c
            i+=1
        else: # S[i] != 'A'
            index[i] = c
            i+=1
    return index


def main():
    N, Q = [int(x) for x in input().split()]
    S = "__" + input()
    #S = input()
    index = genindex(N, S)


    #print(index)
    for i in range(Q):
        l, r = [int(x) for x in input().split()]
        #print(index[r] - index[l], index[r], index[l])
        print(index[r] - index[l])
    #, index[r], index[l])

main()


Measured memory_bytes: 6140
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  int c=0;
  cin>>s;
  cin>>t;
  for(int i=0;i<(int)s.length();i++)
  {
    if(s[i]==t[i]) c+=1;
  }
  if((s.length()+1)==(t.length()) && (c==(int)s.length()))
  {
    cout<<"Yes";
  }
  else cout<<"No";
  return 0;
 
}

Measured memory_bytes: 3628
N,X,Y = map(int,input().split())

dp = [0]*N

for i in range(1,N+1):
    for j in range(i+1,N+1):
        m = min(j-i,abs(j-Y)+abs(X-i)+1)
        dp[m-1]+=1
        # print(i,j,m)
for i in dp[:-1]:
    print(i)



Measured memory_bytes: 46184
#include<iostream>
using namespace std;
int main()
{
	int n;
	long long sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0&&i%5==0) continue;
		else if(i%3==0) continue;
		else if(i%5==0) continue;
		else sum+=i;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

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

	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll temp=0;
	if(k>=a+b)
		temp=a-(k-a-b);
	else if(k>=a)
		temp=a;
	else
		temp=k;
	cout<<temp;

	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int q(const int *a,const int *b)
{
    return *a-*b;
}



int main(void)
{
    char s[101];
    long k;
    int i;
    scanf("%s%ld",s,&k);
    if(k==1){
        printf("%c",s[0]);
        return 0;
    }
    else{
        for(i=0;i<k;i++){
            if(s[i]!='1'){
                printf("%c",s[i]);
                return 0;
            }
        }
        puts("1");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main()
{
    int x,y;
    std::cin >> x;
    std::cin >> y;
    std::cout << gcd(x,y) <<"\n";
    return 0;
}



Measured memory_bytes: 3104
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
ll a,b,c,d,ans;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>a>>b>>c>>c>>d;
    ans=(a/2)*2+(c/2)*2+(d/2)*2;
    if(a && c && d)ans=max(ans,((a-1)/2)*2+((c-1)/2)*2+((d-1)/2)*2+3);
    cout<<ans+b<<endl;
	return 0;
}

Measured memory_bytes: 256
from string import digits

def main():
    N, M, Q = map(int, input().split())
    query = [tuple(map(int, input().split())) for _ in range(Q)]


    my_digits = list(range(1, M+1))
    r = my_digits.index(M)
    def dfs(S):
        if len(S) >= N:
            score = 0
            for a, b, c, d in query:
                if S[b-1] - S[a-1] == c:
                    score += d
            return score
        else:
            suffix = S[-1]
            l = my_digits.index(suffix)
            
            return  max([dfs(S+[num]) for num in my_digits[l:r+1]])

    ans = dfs([1])
    print(ans)

if __name__ == "__main__":
    main()

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

int H,W,A[200000],B[200000],C[200000];
set<pair<int,int>>st;
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;

int main(){
	cin>>H>>W;
	for(int i=0;i<H;i++){
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
	}
	for(int i=0;i<W;i++){
		C[i]=i;
		pq.push({0,i});
		st.insert({i,i});
	}
	for(int i=0;i<H;i++){
		auto it=st.lower_bound({A[i],-1});
		int t=-1;
		while(it!=st.end()&&it->first<=B[i]){
			t=it->second;
			C[it->second]=-1;
			auto it2=it;
			it++;
			st.erase(it2);
		}
		if(B[i]!=W-1&&t!=-1){
			C[t]=B[i]+1;
			st.insert({B[i]+1,t});
			pq.push({B[i]+1-t,t});
		}
		while(!pq.empty()&&pq.top().first+pq.top().second!=C[pq.top().second]){
			pq.pop();
		}
		if(pq.empty()){
			cout<<-1<<endl;
		}
		else{
			cout<<i+1+pq.top().first<<endl;
		}
	}
}


Measured memory_bytes: 16776
a,b,k = map(int, input().split())
if a<k:
  k-=a
  a=0
else:
  a-=k
  k=0
if b<k:
  k-=b
  b=0
else:
  b-=k
  k=0
print(str(a) + " " + str(b))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int n,m,s,t;cin>>n>>m>>s>>t;s--,t--;
    vector<vector<int>> g(n);
    rep(i,m){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vector<int> d(n,INF),rd(n,INF);
    {
        queue<int> que;
        que.push(s);d[s]=0;
        while(!que.empty()){
            int u=que.front();que.pop();
            for(auto to:g[u])if(chmin(d[to],d[u]+1))que.push(to);
        }
    }
    {
        queue<int> que;
        que.push(t);rd[t]=0;
        while(!que.empty()){
            int u=que.front();que.pop();
            for(auto to:g[u])if(chmin(rd[to],rd[u]+1))que.push(to);
        }
    }

    vector<ll> cnt(n,0);
    rep(i,n)if(rd[i]<n)cnt[rd[i]]++;
    ll res=0;
    rep(i,n){
        int op=d[t]-1-1-d[i];
        if(0<=op and op<n)res+=cnt[op];
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 11044
def can_you_solve_this(
        N: int, M: int, A: list, B: list, C: int)->int:
    AB = [0] * N
    for i in range(N):
        for j in range(M):
            AB[i] += A[i][j] * B[j]
        AB[i] += C
    return sum(1 for ab in AB if ab > 0)


if __name__ == "__main__":
    N = 0
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    A = [[int(s) for s in input().split()] for _ in range(N)]
    ans = can_you_solve_this(N, M, A, B, C)
    print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll mod=1e9+7;
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;}
const int N=1e5+10;
ll n,k;
ll dp[N];
void add(ll &x,ll y)
{
    x=(x+y)%mod;
}
int main()
{
 
    cin>>n>>k;
 
    ll ans=0;
    for(ll gc=k;gc;--gc)
    {
        ll di=k/gc;
        ll num=powmod(di,n)%mod;
        ll t=0;
        for(ll j=gc+gc;j<=k;j+=gc) add(t,dp[j]);
    
        dp[gc]=(num-t+mod)%mod;
    }
 
    for(int i=1;i<=k;++i){
        add(ans,dp[i]*i%mod);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef pair<int,int> P;
//#pragma GCC optimize("Ofast")

const int MAX_N = 205;

int N;
char G1[MAX_N][MAX_N];
vector<vector<int>> G;

int bfs(int s){
    int ans = -1;
    vector<bool> visited(N, false);
    vector<int> id(N, -10);

    queue<P> Q;
    Q.push({s,1});
    visited[s] = true;
    id[s] = 1;

    while(!Q.empty()){
        auto now = Q.front();
        Q.pop();
        int v = now.first;
        int ID = now.second;
        ans = max(ans, ID);
        //cout << v << endl;
        for(auto nv: G[v]){
            if(id[nv] == ID + 1 || id[nv] == ID - 1 || id[nv] == -10);
            else return -1;
            if(visited[nv]) continue;
            Q.push({nv, ID + 1});
            visited[nv] = true;
            id[nv] = ID + 1;
        }
        //cout << endl;
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    G.resize(N);
    rep(i,N){
        rep(j,N){
            cin >> G1[i][j];
            if(G1[i][j] == '1')G[i].push_back(j);
        }
    }
    int ans = -1;
    rep(i,N) ans = max(ans,bfs(i));
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
    string S,T; cin>>S>>T;
	int ans=T.size();
	for(int i=0; i+T.size()<=S.size(); i++) {
		int c=0;
		for (int j=0; j<T.size(); j++) c += S[i+j] != T[j];
		if (ans>c) ans=c;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number, H: number[] } => {
  const N = +lines[0]
  const H = lines[1].split(' ').map(line => +line)
  const obj = { N, H }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N, H } = parseLines(lines)
  let current = H[0]
  for (let i = 1; i < N - 1; i++) {
    if (current <= H[i] - 1) {
      current = H[i] - 1
    } else if (current <= H[i]) {
      current = H[i]
    } else {
      return 'No'
    }
  }

  if (current <= H[N-1] || current <= H[N-1] - 1) {
    return 'Yes'
  } else {
    return 'No'
  }

}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 27724
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

//a+b>=v 
int calc(int *a,int *b,int n,int v){
  int cnt=0;
  int j=n-1;
  int i;
  for(i=0;i<n;i++){
    while(j>=0 && a[i]+b[j]>=v) j--;
    cnt^=n-1-j;
  }
  return cnt&0x01;
}

void clearAndSort(int *a,int n,int bit,int *c){
  int m=0;
  while(m<n && a[m]<(1<<bit)) m++;
  for(int i=m;i<n;i++) a[i]^=1<<bit;
  int i=0;
  int j=m;
  int k=0;
  while(i<m && j<n){
    if(a[i]<=a[j]){
      c[k++]=a[i++];
    } else {
      c[k++]=a[j++];
    }
  }
  memcpy(c+k,a+i,sizeof(int)*(m-i));
  memcpy(a,c,sizeof(int)*(k+m-i));
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int *b=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  for(i=0;i<n;i++) scanf("%d",b+i);
  qsort(a,n,sizeof(int),cmp);
  qsort(b,n,sizeof(int),cmp);
  int *c=(int *)malloc(sizeof(int)*n);
  int ans=0;
  for(int bit=29;bit>=0;bit--){
    clearAndSort(a,n,bit+1,c);
    clearAndSort(b,n,bit+1,c);
    int cnt=calc(a,b,n,1<<bit)^calc(a,b,n,2*(1<<bit))^calc(a,b,n,3*(1<<bit));
    if(cnt) ans+=1<<bit;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2556
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long a = sc.nextLong();
			long b = sc.nextLong();
			long m = sc.nextLong();
			List<Long> aA = new ArrayList<>();
			long aMin = Long.MAX_VALUE;
			for (long i = 0; i < a; i++) {
				long ai = sc.nextLong();
				aA.add(ai);
				if (aMin > ai) {
					aMin = ai;
				}
			}
			List<Long> bB = new ArrayList<>();
			long bMin = Long.MAX_VALUE;
			for (long i = 0; i < b; i++) {
				long bi = sc.nextLong();
				bB.add(bi);
				if (bMin > bi) {
					bMin = bi;
				}
			}
			List<Integer> xM = new ArrayList<>();
			List<Integer> yM = new ArrayList<>();
			List<Integer> cM = new ArrayList<>();
			for (long i = 0; i < m; i++) {
				xM.add(sc.nextInt());
				yM.add(sc.nextInt());
				cM.add(sc.nextInt());
			}
			long min = aMin + bMin;
			// 整数配列ループ処理
			for (int i = 0; i < m; i++) {
				long cand = aA.get(xM.get(i) - 1) + bB.get(yM.get(i) - 1) - cM.get(i);
				if (min > cand) {
					min = cand;
				}
			}
			System.out.println(min);
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 159484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>
#include <sstream>
#include <iomanip>

using namespace std;

#define PI 3.14159265359

int main()
{
	double a , b ,x;

	cin >> a >> b >> x;

	double h, s;
	if (x / a < a * b / 2) {
		h = x / a * 2 / b;
		s = atan2(b, h) * 180 / PI;
	}
	else {
		h = (a * b - x / a) * 2 / a;
		s = atan2(h, a) * 180 / PI;
	}

	printf("%.15f", s);

	return 0;
}



Measured memory_bytes: 256
def main(argv)
  (a, b) = gets.chomp.split(' ').map(&:to_i)
  
  if b == 1 then
    puts 0.to_s
    return
  end
  
  k = 1
  while true do
    s = (k * a) - (k - 1)
    
    break if s >= b
    
    k += 1
  end  
  
  puts k.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

using namespace std;

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

int main(){
  uint64_t n;
  cin >> n;
  for(uint64_t p = 1000000; p > 0; --p) if(p * p <= n && n % p == 0){
    cout << (p + n / p - 2) << endl;
    break;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> l(n * 2);
    for (auto &r: l) cin >> r;

    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());

    int ans = 0;

    for (int i = 0; i + 1 < l.size(); i += 2) {
        ans += l[i + 1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
dic = {}

for i in range(n):
    tmp = input()
    if tmp in dic: dic[tmp] += 1
    else: dic[tmp] = 1

dic = sorted(dic.items())
dic = sorted(dic, key=lambda x:-x[1])

mx = dic[0][1]
for i in dic:
    if i[1]==mx: print(i[0])
    else: break

Measured memory_bytes: 42332
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        long ans = 0;
        int start = sc.nextInt();
        boolean up = false;
        boolean down = false;
        for (int i = 1; i < N; i++) {
        	int a = sc.nextInt();
        	if (start == a)
        		continue;
        	
        	if (start > a) {
        		if (up) {
        			ans++;
        			down = false;
        			up = false;
        		} else {
        			down = true;
        		}
        	} else {
        		if (down) {
        			ans++;
        			up = false;
        			down = false;
        		} else {
        			up = true;
        		}
        	}
        	
        	start = a;
        }
        
        System.out.println(ans+1);
    }
}



Measured memory_bytes: 48784
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    r = m//2
    s = 1
    e = 2*r+1
    for _ in range(r):
        print(s,e)
        s += 1
        e -=1
    
    s = n-2*(m-r)+1
    e = n
    for _ in range(m-r):
        print(s,e)
        s += 1
        e -=1


if __name__ == '__main__':
    main()

Measured memory_bytes: 9256
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b&&b==c)cout<< "No" << endl;
	else if (a == b || b == c || a == c)cout << "Yes" << endl;
	else cout << "No" << endl;
}
int main() {
	solve();
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut v = vec![0, 0]; // 0101..., 1010...
    for (i, &c) in s.iter().enumerate() {
        if c == '1' { v[(i % 2)] += 1; }
        if c == '0' { v[(i % 2) ^ 1] += 1; }
    }
    println!("{}", if v[0] < v[1] { v[0] } else { v[1] });
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
int *a, *MAXGROUP;
int findRoot(int x){
  if (a[x]<0) return x;
  else return a[x]=findRoot(a[x]);
}
void unite( int c, int b, int *p ){
  int q=findRoot(c);
  int w=findRoot(b);
  if (w!=q){
    if (a[q]>a[w]) {int temp=q;q=w;w=temp;}
    a[q]+=a[w];
    a[w]=q;
    if (*p>a[q]) *p=a[q];
  }
}
int main(){
  int m,n,k1,k2,max=-1;
  MAXGROUP=&max;
  scanf("%d%d",&n,&m);
  int i;
  a=(int*)malloc(n*sizeof(int));
  for (i=0;i<n;i++) a[i]=-1;
  for (i=0;i<m;i++){
    scanf("%d%d",&k1,&k2);
    k1--;k2--;
    unite(k1,k2,MAXGROUP);
  }
  free(a);
  printf("%d\n",-max);
}

Measured memory_bytes: 2244
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int e;
	while(cin >> e, e){
		int mini = e;
		for(int z = 0; e >= z*z*z; z++){
			for(int y = 0; e-z*z*z >= y*y; y++){
				int x = e - z*z*z - y*y;
				if(x < 0)continue;
				mini = min(mini, x+y+z);
			}
		}
		cout << mini << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
int H, W, t, d[507][507], s[507], l[507], r[507]; char c[507][507];
int main() {
	while (scanf("%d%d", &H, &W), H && W) {
		for (int i = 0; i < H; i++) scanf("%s", c[i]);
		for (int i = 0; i < W; i++) {
			for (int j = 0; j < H; j++) {
				if (c[j][i] == '*') d[j][i] = 0;
				else d[j][i] = j ? d[j - 1][i] + 1 : 1;
			}
		}
		int ret = 0;
		for (int i = 0; i < H; i++) {
			t = 0;
			for (int j = 0; j < W; j++) {
				while (t && d[i][s[t - 1]] >= d[i][j]) t--;
				l[j] = t ? (s[t - 1] + 1) : 0;
				s[t++] = j;
			}
			t = 0;
			for (int j = W - 1; j >= 0; j--) {
				while (t && d[i][s[t - 1]] >= d[i][j]) t--;
				r[j] = t ? s[t - 1] : W;
				s[t++] = j;
			}
			for (int j = 0; j < W; j++) ret = std::max(ret, d[i][j] * (r[j] - l[j]));
		}
		printf("%d\n", ret);
	}
}

Measured memory_bytes: 3836
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}


/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int n,k;
   cin>>n>>k;
   int cnt=1;
   cnt*=k;
   for(int i=1;i<n;++i)
    cnt*=(k-1);
  cout<<cnt<<endl;

}


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

int main() {
	long long int n;
	cin>>n;
	long long int sum=0;
	vector<int> res(n,0);

	for(int i=0;i<n;i++)
	{
	    cin>>res[i];
        sum^=res[i];
        
	}
	for(int i=0;i<n;i++)
	{
	    long long int temp=sum^res[i];
	    cout<<temp<<" ";
	}
	    
	
	
	return 0;
}

Measured memory_bytes: 3980
N = str(input())
n = int(N[-1])
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
    print("pon")
elif n == 3:
    print("bon")


Measured memory_bytes: 61860
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

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

	// for(int i = 0; i < 1001; i++) {
	// 	for(int j = -1000; j < i; j++) {
	// 		ll x1 = i * i * i * i * i;
	// 		ll x2 = j * j * j * j * j;
	// 		if ((x1 - x2) == X) {
	// 			cout << i << " " << j << endl;
	// 			return 0;
	// 		}
	// 	}
	// }
	for(int i=0;i<1001;i++){
        for(int j=-1000;j<i;j++){
            if(pow(i,5)-pow(j,5)==X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
  return 0;
}


Measured memory_bytes: 4064
#include<iostream>
#include<string>

using namespace std;
 
int main(void){
	string week[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,cnt,mc;
	
	while(cin>>m>>d){
		if(m==0){
			break;
		}
		mc=1;
		cnt=3;
		while(1){
			for(int i=1;i<=month[mc-1];i++,cnt++){
				if(m==mc && d==i){
					break;
				}
			}
			if(m==mc){
				break;
			}
			mc++;
		}
		cout<<week[cnt%7]<<endl;
	}
	return 0;
}

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

#define int long long



typedef long long ll;
typedef long double ld;






bool cmp(pair<int,int>& a,pair<int,int>& b){
	return a.first == b.first ? a.second < b.second : a.first < b.first;
}








signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
    cin>>t;
    cout<<t*t<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef double dl;
#define mp make_pair
#define pb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define dst distance
#define INF 1000000000
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define MAXN 2000110
ll MOD = 1e9+7;

ll ans[MAXN];
ll pref[MAXN];
ll N,T;

ll sum(ll a, ll b){
	return (MOD + pref[b] - pref[a-1])%MOD;
}

int main(){
	cin>>N;
	for (int i=1;i<=N;++i){
		ans[i] = 1;
		pref[i] = pref[i-1]+1;
	}
	ans[N+1] = T = N;
	pref[N+1] = pref[N] + ans[N+1];

	for (int i=N+2;i<=2*N;++i){
		ans[i] = (N-1)*(N-1)%MOD;
		ans[i] += (sum(i-N-1,i-1) + MOD - ans[i-2])%MOD;
		ans[i] %= MOD;
		pref[i] = (pref[i-1] + ans[i]) %MOD;
	}
	cout<<ans[N*2];
}

Measured memory_bytes: 31488
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

import itertools as iter
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

H,A = nums()
print(math.ceil(H/A))

Measured memory_bytes: 65772
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll n,s;
int main(){
	scanf("%lld%lld",&n,&s);
	
	if(n<s){
		puts("-1");
		return 0;
	}
	
	if(n==s){
		printf("%lld\n",n+1);
		return 0;
	}
	
	rep(b,2,400000){
		ll sum=0,temp=n;
		while(temp){
			sum+=temp%b;
			temp/=b;
		}
		if(sum==s){
			printf("%lld\n",b);
			return 0;
		}
	}
	
	//2桁
	for(ll p=sqrt(n-s);p>=1;p--)if((n-s)%p==0){
		ll b=(n-s)/p+1;
		ll q=s-p;
		if(0<=q&&q<b){
			printf("%lld\n",b);
			return 0;
		}
	}
	
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
<?php


[$N, $D] = fscanf(STDIN, "%d%d");
$ans = 0;
while($N--){
    [$X, $Y] = fscanf(STDIN, "%d%d");
    $dist = sqrt($X**2 + $Y**2);
    if($dist <= $D){
        $ans++;
    }

}
echo $ans;

Measured memory_bytes: 16220
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    int t[N], x[N], y[N];

    for(int i = 0; i < N; i++){
        scanf("%d%d%d", &t[i], &x[i], &y[i]);
    }

    int X = 0, Y = 0, T = 0;
    int d, f = 0;

    for(int i = 0; i < N; i++){
        d = abs(x[i] - X) + abs(y[i] - Y);
        if(d > (t[i] - T) || (d - t[i] + T) % 2 != 0){
            f = 1;
            break;
        }else{
            T = t[i];
            X = x[i], Y = y[i];
        }
    }

    if(f == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 2776
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, z, w = map(int, input().split())
    A = list(map(int, input().split()))
    """
    dpかと思ってずっとウンウン唸ってたのに、解説見て唖然。。。
    """
    if N == 1: print(abs(A[0] - w))
    else: print(max(abs(A[-1] - w), abs(A[-1] - A[-2])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 63992
#include <bits/stdc++.h>
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	double N; cin >> N;
	double ans = 0.0;
	ans = (double) ((N - (int)(N / 2)) / N);
	printf("%.10f", ans);
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
#define MN 500001
#define ll long long
using namespace std;

ll T,n,m,num,l[MN],r,id,N,d[MN],w[MN];
ll read_p,read_ca;
inline ll read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
struct na{int y,ne;}b[MN];
inline void in(int x,int y){b[++num].y=y;b[num].ne=l[x];l[x]=num;}
bool cmp(int x,int y){return x>y;}
int dfs(int p){
	d[p]=0;
	for (int i=l[p];i;i=b[i].ne) dfs(b[i].y);
	int num=0;
	for (int i=l[p];i;i=b[i].ne) w[num++]=d[b[i].y];
	sort(w,w+num,cmp);
	for (int i=0;i<num;i++)
	if (d[p]<w[i]+i+1) d[p]=w[i]+i+1;
}
int main(){
	register ll i;
	n=read();m=0;
	for (i=2;i<=n;i++) in(read(),i);dfs(1);
	printf("%d\n",d[1]);
}

Measured memory_bytes: 7168
#include <stdio.h>
#define MAX 200

char s[MAX];

int main(void){
    fgets(s,MAX,stdin);
    for(int i=0;s[i]!='\0';i++){
        if('a'<=s[i]&&s[i]<='z') s[i]-=32;
        printf("%c",s[i]);
    }
    return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
struct edge { int i, v, w; };

int main() {
	int N; cin >> N;
	vector<i_i> v;
	for (int t = 2; t >= 0; t--)
		rep(i, N) {
			int x; cin >> x;
			v.pb(i_i(x, t));
		}
	sort(v.begin(), v.end());
	vector<ll> dp(4);
	dp[0] = 1;
	rep(i, N * 3) {
		vector<ll> _dp = dp;
		int t = v[i].second;
		_dp[3 - t] += dp[3 - t - 1];
		dp = _dp;
	}
	cout << dp[3] << endl;
}


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

int main(){
  int x,y;
  cin >> x >> y;

  if (x == 2) x = 0;
  else if (x == 4 || x == 6 || x == 9 || x == 11) x = 1;
  else x = 2;

  if (y == 2) y = 0;
  else if (y == 4 || y == 6 || y == 9 || y == 11) y = 1;
  else y = 2;

  if(x == y)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
from operator import itemgetter

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

ab.sort(key=itemgetter(1), reverse=True)
ab.sort(key=itemgetter(0), reverse=True)
cd.sort(key=itemgetter(0), reverse=False)
cd.sort(key=itemgetter(1), reverse=False)

reserved = [0 for _ in range(N)]
for a, b in ab:
    for i, (c, d) in enumerate(cd):
        if reserved[i] :
            continue
        if a<c and b<d :
            reserved[i] = 1
            break
print(sum(reserved))

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

// @author: pashka

int mod = 998244353;

struct mint {
    int value;
    constexpr mint() : value() {}
    mint(const long &x) {
        value = normalize(x);
    }
    static long normalize(const long &x) {
        long v = x % mod;
        if (v < 0) v += mod;
        return v;
    }
    bool operator==(const mint &x) { return value == x.value; };
    mint operator+(const mint &x) { return value + x.value; };
    mint operator*(const mint &x) { return (long)value * x.value; };
    void operator+=(const mint &x) { value = normalize(value + x.value);};
};

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<vector<mint>> q(c + 1, vector<mint>(d + 1));
    vector<vector<mint>> w(c + 1, vector<mint>(d + 1));
    q[a][b] = 1;
    mint res = 0;
    for (int i = 1; i <= c; i++) {
        for (int j = 1; j <= d; j++) {
//            cout << i << " " << j << " " << q[i][j].value << "\n";
            if (j < d) {
                w[i][j + 1] += w[i][j] * i;
            }
            if (i < c) {
                q[i + 1][j] += q[i][j] * j;
                q[i + 1][j] += w[i][j];
                if (j < d)
                    w[i][j + 1] += q[i][j] * i;
            } else {
                if (j < d) {
                    q[i][j + 1] += q[i][j] * c;
                }
            }
        }
    }
    cout << q[c][d].value;


    return 0;
}

Measured memory_bytes: 73744
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (x, a, b) = readListOfLong()
    val absA = Math.abs(x - a)
    val absB = Math.abs(x - b)
    println(if(absA < absB) 'A' else 'B')
    
    
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37840
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define SZ(x) x.size()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

vector<int> G[N];
int dis[N], sz[N], pre[N];
int cnt[N], tot;

void dfs(int u, int fa) {
    sz[u] = 1;
    for(auto v : G[u]) {
        if(v == fa) continue;
        dis[v] = dis[u] + 1;
        pre[v] = u;
        dfs(v, u);
        sz[u] += sz[v];
    }
}

int main() {
    int n;
    scanf("%d", &n);
    rep(i, 1, n-1) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].pb(v), G[v].pb(u);
    }
    dfs(1, -1);
    int cur = n;
    tot = 0;
    while(pre[cur] != 1) {
        cnt[tot++] = sz[pre[cur]]-sz[cur];
        cur = pre[cur]; 
    }
    int x = n-sz[cur]-1, y = sz[n]-1;
    int l = 0, r = tot-1, tp = 0;
    while(l <= r) {
        if(!tp) {
            x += cnt[r];
            r--;
        } else {
            y += cnt[l];
            l++;
        }
        tp ^= 1;
    }
    if(x > y) puts("Fennec");
    else puts("Snuke");

    return 0;
}

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

int main() {
  int N,sum=0;
  cin >> N;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      for(int k=1;k<=N;k++){
        sum+=__gcd(i,__gcd(j,k));
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  list<int> lst;
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string query;
  int key;
  list<int>::iterator itr;
  while(n--){
    cin >> query;
    if(query == "insert"){
      cin >> key;
      lst.push_front(key);
    }
    else if(query == "delete"){
      cin >> key;
      for(itr = lst.begin();itr != lst.end();itr++)if(*itr == key){lst.erase(itr);break;}
    }
    else if(query == "deleteFirst")lst.pop_front();
    else if(query == "deleteLast")lst.pop_back();
  }
  for(itr = lst.begin();itr != --lst.end();itr++)cout << *itr << " ";
  cout << *itr << endl;
  return 0;
}

Measured memory_bytes: 32476
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int x,y;
    cin >> x >> y;

    vector<int> prizes = {0, 300000, 200000, 100000, 0};
    int ans = prizes[min(x,4)] + prizes[min(y,4)];
    if (x == 1 && y == 1)
        ans += 400000;
    cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A  = sc.nextInt();
		int B  = sc.nextInt();
		
		if(A == B) {
			System.out.println("Draw");
		} else {
			if(A == 1) {
				System.out.println("Alice");
			} else if(B == 1) {
				System.out.println("Bob");
			} else if(A > B) {
				System.out.println("Alice");
			} else if(A < B) {
				System.out.println("Bob");
			}
		}
	}
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

int main(){
#ifdef LOCAL
	freopen("H_input.txt", "r", stdin);
	//freopen("H_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	
	int n;
	cin >> n;

	for (int i = 1; i <= 360; ++i) {
		if ((n*i)%360 == 0) {
			cout << i;
			exit(0);
		}
	}



}


Measured memory_bytes: 3588