akhauriyash/Code-Regression huggingface dataset:
// AtCoder template
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<map>
using namespace std;
int main() {
	int A;
	int B;
	cin >> A >> B;
	if (A <= B * 2)
		cout << 0 << endl;
	else
		cout << A - B * 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline().rstrip())

ans = 0
cnt_start_b = 0
cnt_end_a = 0
cnt_start_b_end_a = 0

for _ in range(N):
    s = sys.stdin.readline().rstrip()
    ans += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        cnt_start_b_end_a += 1
    elif s[0] == "B":
        cnt_start_b += 1
    elif s[-1] == "A":
        cnt_end_a += 1

if cnt_start_b_end_a > 0:
    if cnt_end_a == cnt_start_b == 0:
        ans += cnt_start_b_end_a - 1
    elif cnt_end_a == 0:
        ans += cnt_start_b_end_a
    elif cnt_start_b == 0:
        ans += cnt_start_b_end_a
    else:
        ans += cnt_start_b_end_a + 1 + min(cnt_end_a - 1, cnt_start_b - 1)
else:
    ans += min(cnt_end_a, cnt_start_b)
print(ans)

Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200010


int main() {
	char a[N][20];
	long long b[N];
	long long c[N];
	long long d[70][70];
	f(i, N) {
		f(j, 20)a[i][j] = 0;
	}
	f(i, 70) {
		f(j, 70)d[i][j] = 0;
	}
	int n, k, p;
	long long x, y, z;
	long long s, ans;
	ans = 0;
	scanf("%lld", &n);
	f(i, n) {
		scanf("%s", a[i]);
		k = strlen(a[i]);
		p = k;
		f(j, k) {
			if (a[i][j] == '.')p = j;
		}
		if (p == k)a[i][p] = '.';
		f(j, 9) {
			if (a[i][p + j + 1] == 0)a[i][p + j + 1] = '0';
		}
		k = strlen(a[i]);
		x = 0;
		f(j, k) {
			if ((a[i][j] >= '0') && (a[i][j] <= '9')) {
				x = x * 10;
				x += (a[i][j] - '0');
			}
		}
		y = 0;
		z = 0;
		while (x % 2 == 0) {
			y++;
			x /= 2;
		}
		while (x % 5 == 0) {
			z++;
			x /= 5;
		}
		d[y][z]++;
	}
	f(i, 70) {
		f(j, 70) {
			f(ii, 70) {
				f(jj, 70) {
					x = 100 * i + j;
					y = 100 * ii + jj;
					if (x <= y) {
						if ((i + ii) >= 18) {
							if ((j + jj) >= 18) {
								if ((i == ii) && (j == jj)) {
									s = d[i][j] - 1;
									s *= d[i][j];
									s /= 2;
									ans += s;
								}
								else {
									s = d[i][j] * d[ii][jj];
									ans += s;
								}
							}
						}
					}
				}
			}
		}
	}
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

const int MAX = 5100000;
long long fac[MAX], finv[MAX], inv[MAX];

/* 前処理 O(n) */
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

/* 計算 O(1) */
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  ll x = 2 * X - Y, y = 2 * Y - X;
  if (x % 3 != 0 || x < 0 || y % 3 != 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  }

  x /= 3, y /= 3;
  mint ans = 1;
  COMinit();
  ans *= COM(x + y, x);
  cout << ans.x << endl;
}

Measured memory_bytes: 119808
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    vector<int>W(N);
    rep(i,N)cin>>W.at(i);
    int sum1=0,sum2=0;
    int ans=10000000;
    rep(i,N-1){
        for(int j=0;j<=i;j++){
            sum1+=W.at(j);
        }
        for(int j=i+1;j<N;j++){
            sum2+=W.at(j);
        }
        if(abs(sum2-sum1)<ans){
            ans=abs(sum2-sum1);
        }
        sum1=0;
        sum2=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <queue>
#include <vector>
#include <string>
using namespace std;


int main(){
  vector<int> pop_num;
  string str;
  priority_queue<int> que;
  int num;
  int pop;
  int i;
  
  while(true){
    cin >>str;
    if(str == "insert"){
      cin >>num; 
      que.push(num);
    }else if(str == "extract"){

      pop_num.push_back(que.top());
      que.pop();
    }else if(str == "end"){
      break;
    }
  }

  for(int i = 0;i < pop_num.size();i++){
    cout << pop_num[i]<<endl;
  }

  
  /* while(!que.empty()){
    cout <<que.top()<<endl;
    que.pop();
  }
  */
  return 0;
}



Measured memory_bytes: 10744
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

struct modint
{
    ll a;
    modint():a(0){}
    modint(ll t){
        a=t%MOD;
        if(a<0) a+=MOD;
    }
    //operator long long() const{return a;}
    bool operator==(const modint & x)const{return a==x.a;}
    bool operator!=(const modint & x)const{return a!=x.a;}
    modint operator-() const {return modint(a?(MOD-a):0);}
    modint operator~() const {return modint(MOD -2);}
    modint operator+(const modint &x) const{return modint(*this)+=x;}
    modint operator-(const modint &x) const{return modint(*this)-=x;}
    modint operator*(const modint &x) const{return modint(*this)*=x;}
    modint operator/(const modint &x) const{return modint(*this)/=x;}
    modint &operator+=(const modint &x){
        a+= x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-= x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    
    modint &operator*=(const modint &x){
        a=a*x.a %MOD;
        return *this;
    }
    modint &operator/=(const modint &x){
        a=a*(~x).a %MOD;
        return *this;
    }

    friend ostream &operator<<(ostream &os,const modint &x){
        return os << x.a;
    }

    friend istream &operator>>(istream &is,modint &x){
        ll t;
        x=modint(t);
        return is;
    }

    modint pow(ll x)const{
        modint ret = 1,tmp=a;
        for(;x;tmp*=tmp,x>>=1){
            if(x&1) ret*=tmp;
        }
        return ret;
    }

};

modint nCr(int n,int r){
    modint ans=1;
    for(int i=1;i<=r;i++) ans*=modint(n-i+1)/modint(i);
    return ans;
}


void a(){
    ll n; cin >> n;
    cout << (n-1)/2 + 1;
}

void b(){

}

int main(){
    auto a = vv<>(3,v<>(3,0));
    rep(i,3)rep(j,3){
        cin >> a[i][j];
    }

    ll n; cin >> n;
    auto b=v<>(n,0);
    rep(i,n) cin >> b[i];

    rep(i,3)
        rep(j,3){
            rep(k,n){
                if(a[i][j]==b[k]) a[i][j]=-1;
            }
        }
    
    rep(i,3){
        bool col=true;
        bool row=true;
        bool dyl=true;
        bool dyu=true;
        rep(j,3){
            if(a[i][j]>=0)col=false;
            if(a[j][i]>=0)row=false;
            if(a[j][j]>=0)dyl=false;
            if(a[2-j][j]>=0)dyu=false;
        }
        if(col||row||dyl||dyu){
            cout << "Yes"<<endl;
            return 0;
        }
    }

    cout << "No"<<endl;
    return 0;
    

}

Measured memory_bytes: 256
import numpy as np

num, weight_limit = map(int, input().split())
wv_list = [list(map(int, input().split())) for _ in range(num)]

dp = np.zeros(weight_limit + 1)

for n in range(num):
    w = wv_list[n][0]
    v = wv_list[n][1]
    dp[w:] = np.maximum(dp[:-w] + v, dp[w:])

print(int(dp[-1]))

Measured memory_bytes: 15520
/*                                  /   \                                 */      
/*                                 /*****\                               */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K             */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x%MOD;else return (x*n)%MOD;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}  
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;


//	   cin>>t;
	      while(t--)
{

/*
5
1 1
2 2
3 4
5 5
6 6*/
ll n,m,j,l,k,i;
cin>>n;
ll a[n],b[n];
fo(i,n)
cin>>a[i]>>b[i];
ll f=-1;
for(i=0;i<n-2;i++)
{
	if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2])
	{
		f=1;
	break;
	}
}
if(f==1)
cout<<"Yes";
else
cout<<"No";
ee;



}
return 0;
}




Measured memory_bytes: 3656
from sys import stdin
import sys

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

a, b, k = list(map(int, stdin.readline().rstrip().split()))
g = gcd(a,b)

cnt = 0
l = []
for i in range(g // 2):
	if g % (i+1) == 0:
		l.append(i+1)

l.append(g)
print(l[len(l)-k])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long s;
    cin>>s;
    
    vector<bool> flag(1000001,false);
    long count=1;
    while(!flag.at(s)){
        flag.at(s)=true;
        if(s%2==0) s/=2;
        else s=3*s+1;
        count++;
    }
    cout<<count<<endl;
}


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


int main()
{
	long long int N,A,B,x,y,s;
	cin>>N>>A>>B;
	if(A+B==0)
	cout<<0<<"\n";
	else
	{
	x=N%(A+B);
	y=N/(A+B);
	if(x<A)
	s=x+y*A;
	else
	s=A+y*A;
	cout<<s<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from collections import defaultdict

def main():
  h, w, d = map(int, input().split())
  mat_a = numpy.array([list(map(int, input().split())) for _ in range(h)])
  q = int(input())
  x_to_pos = dict()
  
  for i in range(h):
    for j in range(w):
      x_to_pos[mat_a[i, j]] = (i, j)
      
  def calc_score(p1, p2):
    return sum([abs(x-y) for x, y in zip(p1, p2)])
  
  visited = numpy.zeros((h, w))
  costs = defaultdict(dict)
  for c in range(1, d+1):
    cost = 0
    costs[c%d][c] = 0
    while True:
      cp = x_to_pos[c]
      c += d
      if c > (h*w):
        break
      np = x_to_pos[c]
      cost += calc_score(cp, np)
      costs[c%d][c] = cost
  
  for _ in range(q):
    l, r = map(int, input().split())
    print(abs(costs[l%d][l] - costs[l%d][r]))

if __name__=='__main__':
  main()



Measured memory_bytes: 66164
import numpy as np

def main():
    N,M = map(int,input().split())
    A = np.array(list(map(int,input().split())))
    ans = 'No'

    if sum( A >= sum(A)/4/M ) >= M: ans = 'Yes'
    
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 12504
N, K = [int(x) for x in input().split()]
r, s, p = [int(x) for x in input().split()]

win_point = {
    'r': r,
    's': s,
    'p': p,
}

next_hands = {
    'r': ['s', 'p'],
    's': ['r', 'p'],
    'p': ['r', 's'],
}

enemy_hands = input()


def can_win(enemy_hand, my_hands):
    # 勝てる場合にはTrueと勝てる手を教えてくれる
    if enemy_hand == 'r' and 'p' in my_hands:
        return True, 'p'
    if enemy_hand == 's' and 'r' in my_hands:
        return True, 'r'
    if enemy_hand == 'p' and 's' in my_hands:
        return True, 's'

    # 勝てる手がない場合
    return False, None


point = 0

for index in range(K):
    now_hands = ['r', 'p', 's']
    for i in range(index, N, K):
        win, hand = can_win(enemy_hands[i], now_hands)

        if win:
            point += win_point[hand]
            now_hands = next_hands[hand]
        else:
            # 勝てない場合次似邪魔しない手を選ぶ
            # 勝てない回の次は必ず勝てるため全手出せる前提とする
            now_hands = ['r', 'p', 's']

print(point)


Measured memory_bytes: 9396
#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 rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    string S; cin >> S;
    bool n = false, s = false, e = false, w = false;
    for(char c : S) {
        switch(c) {
        case 'N':
            n = true;
            break;
        case 'W':
            w = true;
            break;
        case 'S':
            s = true;
            break;
        case 'E':
            e = true;
            break;
        }
    }
    bool f1 = !n && !s && e && w, f2 = n && s && !e && !w, f3 = n && s && e && w;
    if(f1 | f2 | f3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

map<int, int> mp;
map<int, int> ::iterator it = mp.begin();
int N;
int main () {
    cin >> N;
    for(int i=0; i<N; i++) {
        int a;
        cin >> a;
        if( mp[a] ) mp[a]--;
        else mp[a]++;
    }
    int cnt = 0;
    for(it = mp.begin(); it != mp.end(); it++) if( (*it).second) cnt++;
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 4992
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Mmmmmm......
#include<bits/stdc++.h>
using namespace std;

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
#define re return 
#define vi vector<int>
#define vii vector<pair<int ,int > >
#define F first
#define S second
#define pussy push_back
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 , mod = 1e9 + 7;



signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int n; cin >> n;
	map<int,int>mm;
	int curr=0;
	for(int i=0;i<n;i++){
		int x; cin >> x;
		curr += x;
		mm[x]++;
	}
	int q; cin >> q;
	while(q--){
		int a , b;cin >> a >> b;
		int rem = mm[a]*a;
		int add = b*mm[a];
		curr += add - rem;
		mm[b] += mm[a];
		mm[a] = 0;
		cout << curr << e;
	}
}


Measured memory_bytes: 9516
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]

def solve(N, A, B):
    xs = [a - b for a, b in zip(A, B)]
    if sum(xs) < 0:
        return -1
    xs.sort()
    rxs = xs[:]
    # print(xs)
    i = 0
    j = len(xs) - 1
    while xs[i] < 0:
        l = -xs[i]
        while l > 0:
            d = min(l, xs[j])
            l -= d
            xs[j] -= d
            if xs[j] == 0:
                j -= 1
        xs[i] = 0
        i += 1
    # print(xs)
    return sum(a != b for a, b in zip(rxs, xs))

print(solve(N, A, B))


Measured memory_bytes: 18424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N 55
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
typedef pair<int,int> pii;
int n,ans;
struct data{int x,y;
}a[N];
map<pii,int> f;
signed main()
{
	n=read();
	for (int i=1;i<=n;i++) a[i].x=read(),a[i].y=read();
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
		if (i!=j)
		{
			ans=max(ans,++f[make_pair(a[i].x-a[j].x,a[i].y-a[j].y)]);
		}
	cout<<n-ans;
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 3772
def main
  loop do
    n,m,p = gets.chomp.split.map(&:to_i)
    break if (n|m|p) == 0

    player = []
    sum = 0
    n.times do
      x = gets.chomp.to_i
      sum += x * 100
      player << x
    end
    prize = sum * (100 - p) / 100

    puts player[m-1] == 0 ? 0 : prize / player[m-1]
  end
end

main

Measured memory_bytes: 6112
//ehhhhh...... i hate you......

/* optimizations and other useless stuff*/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e14
#define ull unsigned long long int
using namespace std;
/* TYPE DEFINITIONS */
typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     pair<ll,ll>     pi;


/* Basic  Math!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll ncr(int n, int k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 

/* MACROS */
#define  all(A)         (A).begin() , (A).end()
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).sbegin()) it = (a).begin(); it != (a).end(); it++)  
vi v[100005];
ll dp[100005];
ll bruteFoce(int s)
{
    if(dp[s]!=-1)return dp[s];
    ll res=0;
    for(auto i:v[s])
    {
        res=max(res,bruteFoce(i)+1);
    }
    dp[s]=res;
    return dp[s];
}
void solve()
{
    int n,m;
    cin>>n>>m;
    forn(i,m)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    fora(i,1,n)dp[i]=-1;
    ll res=0;
    for(int i=1;i<=n;i++)
    {
        res=max(res,bruteFoce(i));
    }
    cout<<res<<endl;
}

int main()
{
    FastIO;
    ll c=0;
    ll t=1;
   // cin>>t;
    while(t--)
    {
        //cout<<"Case "<<++c<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 8192
n = gets.chomp.to_i
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i

min = [a,b,c,d,e].min
count = (n/(min*1.0)).ceil

puts count + 4





Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5,MAXM=1e6+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}int n;
//struct Edge{int to,next,w;}edges[MAXM];
//int cnt=1,head[MAXN],cur[MAXN],d[MAXN],S,T;
//inline void add(int x,int y,int w){
//	edges[++cnt]=(Edge){y,head[x],w},head[x]=cnt;
//	edges[++cnt]=(Edge){x,head[y],0},head[y]=cnt;
//}inline bool BFS(){
//	memset(d,0,sizeof(d)),d[S]=1;queue<int>q;q.push(S);
//	for(int x;!q.empty();){
//		x=q.front(),q.pop();
//		for(int i=head[x],y;i;i=edges[i].next)
//			if(!d[y=edges[i].to]&&edges[i].w)d[y]=d[x]+1,q.push(y);
//	}return d[T];
//}int DFS(int x,int dist){
//	if(x==T||!dist)return dist;int z=0;
//	for(int&i=cur[x],y,k;i;i=edges[i].next)if(d[y=edges[i].to]==d[x]+1&&edges[i].w){
//		k=DFS(y,min(dist,edges[i].w)),edges[i].w-=k,edges[i^1].w+=k,z+=k,dist-=k;
//		if(!dist)break;
//	}return z;
//}inline int Dinic(){int ans=0;while(BFS())memcpy(cur,head,sizeof(head)),ans+=DFS(S,1e9);return ans;}
struct Edge{int to,next,w;}edges[MAXM];
int head[MAXN],cur[MAXN],cnt=1,d[MAXN],S,T;
inline void add(int x,int y,int w){
	edges[++cnt]=(Edge){y,head[x],w},head[x]=cnt;
	edges[++cnt]=(Edge){x,head[y],0},head[y]=cnt;
}inline bool bfs(){
	queue<int>q;q.push(S);memset(d,0,sizeof(d)),memcpy(cur,head,sizeof(head)),d[S]=1;
	for(int x;!q.empty();q.pop())
		for(int i=head[x=q.front()],y;i;i=edges[i].next)
			if(edges[i].w&&!d[y=edges[i].to])d[y]=d[x]+1,q.push(y);
	return d[T];
}int dfs(int x,int dist){
	if(x==T||!dist)return dist;int z=0;
	for(int&i=cur[x],y,k;i;i=edges[i].next)if(edges[i].w&&d[y=edges[i].to]==d[x]+1){
		k=dfs(y,min(dist,edges[i].w)),z+=k,dist-=k,edges[i].w-=k,edges[i^1].w+=k;
		if(!dist)break;
	}return z;
}inline int Dinic(){int ans=0;while(bfs())ans+=dfs(S,1e9);return ans;}
int vis[MAXN],vis2[MAXN],id[MAXN],nxt[MAXN];vector<int>bel[MAXN];
inline bool Solve(){
	queue<int>q;
	for(int i=1;i<n;i++)for(int j=head[n+i];j;j=edges[j].next)if(edges[j].to&&!edges[j].w)id[i]=edges[j].to,vis[edges[j].to]=1;
	Rep(i,1,n)if(!vis[i])q.push(i);
	int cnt=0;
	for(int x;!q.empty();q.pop()){
		x=q.front(),cnt++;
		for(int i=0,len=bel[x].size(),y;i<len;i++)
			if(!vis2[y=bel[x][i]])vis2[y]=1,nxt[y]=x,q.push(id[y]);
	}return cnt==n;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),S=0,T=2*n;
	Rep(i,1,n-1){
		add(S,i+n,1);
		for(int t=read(),x;t--;)x=read(),add(i+n,x,1),bel[x].push_back(i);
	}Rep(i,1,n)add(i,T,1);
	if(Dinic()!=n-1){puts("-1");return 0;}
	if(!Solve()){puts("-1");return 0;}
	Rep(i,1,n-1)cout<<id[i]<<' '<<nxt[i]<<'\n';
	return 0;
}




Measured memory_bytes: 25896
N=int(input())
A=[]
for n in range(N):
    A.append(int(input()))

A.sort()

cnt=1
ans=0
for n in range(1,N):
    if A[n]==A[n-1]:
        cnt+=1
    else:
        if cnt%2==1:
            ans+=1
        cnt=1
    if n==N-1 and cnt%2==1:
        ans+=1
print(ans)

Measured memory_bytes: 13276
import java.util.*;

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 >= 13){
            System.out.println(b);
        } else if(a >= 6){
            System.out.println(b/2);
        } else {
            System.out.println(0);
        }

        return;
    }


}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>

std::vector<int64_t> p;
std::vector<int64_t> c;

auto main() -> int
{
    int64_t n, k;
    std::cin >> n >> k;
    p.reserve(n);
    c.reserve(n);

    for(int64_t i = 0; i < n; ++i)
    {
        int64_t t;
        std::cin >> t;
        p.emplace_back(t - 1);
    }

    for (int64_t i = 0; i < n; ++i)
    {
        int64_t t;
        std::cin >> t;
        c.emplace_back(t);
    }

    int64_t bestScore = INT64_MIN;

    for(int64_t i = 0; i < n; ++i)
    {
        int64_t idx = i;
        int64_t totalScore = 0;
        std::vector<int64_t> scores;

        do
        {
            idx = p[idx];
            scores.push_back(c[idx]);
            totalScore += c[idx];
        } while (idx != i);

        int64_t tmp = 0;
        uint64_t size = scores.size();
        for (uint64_t j = 0; (j < size) && ((j + 1) <= k); ++j)
        {
            tmp += scores[j];

            int64_t current = tmp;
            if(totalScore > 0)
            {
                int64_t e = (k - j - 1) / size;
                current += totalScore * e;
            }

            if(bestScore < current) bestScore = current;
        }
    }

    std::cout << bestScore << std::flush;
    
    return 0;
}

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

int main(){
    ll R,G,B,N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    ll r = N/R;
    for(ll i = r; i >= 0; i--){
        ll n = N-i*R;
        if(n == 0){
            ans++;
            continue;
        }
        else{
            ll g = n/G;
            for(ll j = g; j >= 0; j--){
                ll m = n - j*G;
                if(m == 0){
                    ans++;
                    continue;
                }
                else if(m%B == 0){
                    ans++;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
} 


Measured memory_bytes: 256
MAX = 1000000
prime = [1] * MAX
prime[0], prime[1] = 0, 0
i = 2
while i * i < MAX:
    j = 2
    while i * j < MAX:
        prime[i * j] = 0
        j += 1
    i += 1
for k in range(1, len(prime)):
    prime[k] += prime[k-1]

while True:
    try:
        n = int(raw_input())
        print prime[n]
    except EOFError:
        break

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  string s;
  cin >> n >> s;

  rep(i, 1<<2) {
    string t = "";
    if((i>>0)&1) t += "W";
    else t += "S";
    if((i>>1)&1) t += "W";
    else t += "S";
    reps(j, 1, s.size()) {
      if(s[j] == 'o') {
	if(t[j] == 'W') t += (t[j-1] == 'S' ? "W" : "S");
	else t += (t[j-1] == 'S' ? "S" : "W");
      } else {
	if(t[j] == 'W') t += (t[j-1] == 'S' ? "S" : "W");
	else t += (t[j-1] == 'S' ? "W" : "S");
      }
    }
    bool flag = true;
    if(s[n-1] == 'o') {
      if(t[n-1] == 'W' && t[n-2] == t[0] ||
	 t[n-1] == 'S' && t[n-2] != t[0]) {
	flag = false;
      }
    } else {
      if(t[n-1] == 'W' && t[n-2] != t[0] ||
	 t[n-1] == 'S' && t[n-2] == t[0]) {
	flag = false;
      }
    }
    if(s[0] == 'o') {
      if(t[0] == 'W' && t[n-1] == t[1] ||
	 t[0] == 'S' && t[n-1] != t[1]) {
	flag = false;
      }
    } else {
      if(t[0] == 'W' && t[n-1] != t[1] ||
	 t[0] == 'S' && t[n-1] == t[1]) {
	flag = false;
      }
    }
    if(flag) {
      cout << t.substr(0, s.size()) << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define ii pair <int, int>
#define dl pair <ll, ll>
#define vi vector <int>
#define vl vector <ll>
#define vii vector <ii>
#define REP(a, b) for (int i = a; i < b; i++)
#define REP2(a, b) for (int j = a; j < b; j++)
#define REPS(a, b, c) for (int i = a; iQ < b; i += c)
#define tam 1000001

using namespace std;

int n;
int arr[tam];
bitset <tam> primo;
int e[tam];

bool sieve() {
    primo.set();
    primo[0] = primo[1] = 0;
    int cont;
    for (int i = 2; i < tam; i++) {
        if (primo[i]) {
            cont = 0;
            cont += e[i];
            for (int j = i * 2; j < tam; j += i) {
                primo[j] = 0;
                cont += e[j];
            }
            if (cont > 1) return false;
        }
    }
    return true;
}

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

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

    cin >> n;
    REP(0, n) {
        cin >> arr[i];
        e[arr[i]]++;
    }
    if (sieve()) cout << "pairwise ";
    else {
        int ac = arr[0];
        REP(1, n) {
            ac = gcd(ac, arr[i]);
        }
        if (ac == 1) cout << "setwise ";
        else cout << "not ";
    }
    cout << "coprime\n";
    return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int64_t n, m, d;
    cin >> n >> m >> d;
    if(d == 0) cout << 1.0*(n-d)*(m-1.0)/(n*n) << endl;
    else cout << 2.0*(n-d)*(m-1.0)/(n*n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) {
    return cout << "(" << p.first << ", " << p.second << ")";
}
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
    cout << "{"; for (int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "}";
}
const ll INF = 1e12;
template<class T, int SZ> struct lazy_seg {
    T mn[2 * SZ], lazy[2 * SZ];
    lazy_seg() {
        for (int i = 0; i < 2 * SZ; i++) {
            lazy[i] = 0;
            mn[i] = 0;
        }
    }
    void push(int ind, int L, int R) {
        mn[ind] += lazy[ind];
        if (L != R) {
            lazy[2 * ind] += lazy[ind];
            lazy[2 * ind + 1] += lazy[ind];
        }
        lazy[ind] = 0;
    }
    void pull(int ind) {
        mn[ind] = min(mn[2 * ind], mn[2 * ind + 1]);
    }
    void build() {
        for (int i = SZ - 1; i >= 1; i--) {
            pull(i);
        }
    }
    void upd(int lo, int hi, T inc, int ind = 1, int L = 0, int R = SZ - 1) {
        push(ind, L, R);
        if (hi < L || R < lo) return;
        if (lo <= L && R <= hi) {
            lazy[ind] = inc;
            push(ind, L, R);
            return;
        }
        int M = (L + R) / 2;
        upd(lo, hi, inc, 2 * ind, L, M);
        upd(lo, hi, inc, 2 * ind + 1, M + 1, R);
        pull(ind);
    }
    T qmin(int lo, int hi, int ind = 1, int L = 0, int R = SZ - 1) {
        push(ind , L, R);
        if (lo > R || L > hi) return INF * 10;
        if (lo <= L && R <= hi) return mn[ind];
        int M = (L + R) / 2;
        return min(qmin(lo, hi, 2 * ind, L, M), qmin(lo, hi, 2 * ind + 1, M + 1, R));
    }
    void set(int idx, T val) {
        upd(idx, idx, val - qmin(idx, idx));
    }
    void set_min(int idx, T val) {
        ll old_val = qmin(idx, idx);
        if (val > old_val) return;
        upd(idx, idx, val - old_val);
    }
};
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, q, a, b;
    cin >> n >> q >> a >> b;
    a--, b--;
    lazy_seg<ll, (1 << 18)> add;
    lazy_seg<ll, (1 << 18)> sub;
    vector<int> x(n);
    for (int i = 0; i < q; i++) cin >> x[i], x[i]--;
    for (int i = 0; i < n; i++) {
        add.upd(i, i, INF);
        sub.upd(i, i, INF);
    }
    for (int i = 0; i < q; i++) {        if (i == 0) {
            add.set_min(b, abs(a - x[0]) + b);
            add.set_min(a, abs(b - x[0]) + a);
            sub.set_min(b, abs(a - x[0]) - b);
            sub.set_min(a, abs(b - x[0]) - a);

        } else {
            ll case_one = min(x[i] + sub.qmin(0, x[i]), add.qmin(x[i], n - 1) - x[i]);
            add.upd(0, n - 1, abs(x[i] - x[i - 1]));
            sub.upd(0, n - 1, abs(x[i] - x[i - 1]));
            add.set_min(x[i - 1], x[i - 1] + case_one);
            sub.set_min(x[i - 1], -x[i - 1] + case_one);
        }
    }
    ll ans = INF;
    for (int i = 0; i < n; i++) {
        ans = min(ans, add.qmin(i, i) - i);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 20332
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n,i,count=0;
    cin>>n;
    long int arr[n];
    for (i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    for (i=0;i<n-1;i++)
    {
        if (arr[i]==arr[i+1])
        {
            count++;
            cout<<"NO"<<endl;
            break;
        }
        
    }
    if (count==0)
        cout<<"YES"<<endl;
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll A , B , C;

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

    cin >> A >> B >> C;
    swap(A , B);
    swap(A , C);
    cout << A << sep << B << sep << C << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}
#ifndef BOOST_TEST_MAIN

int main(int const argc, char const** argv){
  ll N;
  cin >> N;
  ll res = imax;
  rep(i, N + 1){
    ll r = 0;
    ll t = i;
    while(t){
      r += t % 6;
      t /= 6;
    }
    t = N - i;
    while(t){
      r += t % 9;
      t /= 9;
    }

    res = min(r, res);
  }
  cout << res;
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    cout << b * (t / a) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] srgs) {
        Scanner sc = new Scanner(System.in);
        int i = 0;
        while(i++ < 1000){
            int H = sc.nextInt();
            if(H == 0) break;
            int W = sc.nextInt();
            for(int j=0; j<H; j++) {
                for(int k=0; k<W; k++) {
                    System.out.printf("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 59644
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

# include <stdio.h>
# include <bits/stdc++.h>


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace __gnu_pbds;
using namespace std;
 
typedef
tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, a[2], b[2];
string s;
int u[N];

bool can (int a, int b) {
	for (int i = a; i <= b - 1; i ++) {
		if (s[i] == '#' && s[i + 1] == '#') {
			return 0;
		}
	}
	return 1;
}

int main () {
	SpeedForce;
	cin >> n >> a[0] >> b[0] >> a[1] >> b[1];
	cin >> s;
	s = '#' + s;
	bool has = 0;
	for (int c = b[0] - 1; c <= b[1] - 1; c ++) {
		if (s[c] == '.' && s[c] == s[c + 1] && s[c] == s[c + 2]) has = 1;
	}
	if (!can(a[0], a[1])) {
		cout << "No\n";
		exit(0);
	}
	if (a[1] > b[1] && !has) {
		cout << "No\n";
		exit(0);
	}
	if (!can(b[0], b[1])) {
		cout << "No\n";
		exit(0);
	}

	cout << "Yes\n";

	return Accepted;
}

// B...a

Measured memory_bytes: 720
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

L = [[0]*2 for _ in range(N)]

for i in range(N):
    L[i][i%2] = A[i]
    L[i][(i+1)%2] = B[i]

P = [int(i) for i in range(N)]

ans = 10**10
import itertools
for C in itertools.combinations(P, (N+1)//2):
    C = list(C)
    used = [0]*N
    for i in C:
        used[i] = 1
    B_temp = []
    for i in range(N):
        if used[i] == 0:
            B_temp.append((L[i][1], i))

    temp = [0]*N
    check = [0]*N
    B_temp.sort()
    for i in range(len(C)):
        C[i] = (L[C[i]][0], C[i])
    C.sort()
    j = 0
    k = 0
    for i in range(N):
        if i%2 == 0:
            temp[i] = C[j][1]
            check[i] = C[j][0]
            j += 1
        else:
            temp[i] = B_temp[k][1]
            check[i] = B_temp[k][0]
            k += 1
    if check != sorted(check):
        continue

    cnt = 0
    for i in reversed(range(N)):
        for j in range(i):
            if temp[j] > temp[j + 1]:
                temp[j], temp[j + 1] = temp[j + 1], temp[j]
                cnt += 1

    ans = min(ans, cnt)

if ans == 10**10:
    ans = -1
print(ans)

Measured memory_bytes: 48744
"use strict";
    
const main = arg => {
    const times = arg.trim().split("\n").map(n=>parseInt(n));
    let min = 10;
    
    let sum = 0;
    
    for(let i=0; i<times.length; i++) {
        let digitOne   = String(times[i]).split("");
        digitOne = parseInt(digitOne[digitOne.length - 1]);
        
        let digitMinus = 10 - digitOne;
        sum += parseInt(times[i]);
        
        if(digitMinus !== 10) {
            sum += digitMinus;
        }
        
        if(digitMinus !== 10 && digitOne < min) {
            min = digitOne;
        }
    }

    console.log(parseInt(sum - (10 - min)));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9420
lim, mod = 3*10**5, 998244353
n, m, k = map(int, input().split())
ifac, fac = [1], [1]
for i in range(1, lim):
    fac.append((fac[-1]*i)%mod)
    ifac.append(1)
ifac[-1] = pow(fac[-1], mod-2, mod)
for i in range(1, lim-1):
    ifac[lim-1-i] = (ifac[lim-i] * (lim-i))%mod
pw = [1]
for i in range(1, lim):
    pw.append((pw[-1]*(m-1))%mod)
def C(n, k):
    r = fac[n] * ifac[k]
    r %= mod
    r *= ifac[n-k]
    return r%mod

ans = 0
for i in range(k+1):
    #i adjacent pairs are equal
    N = n - i
    add = C(n-1, i) * m
    add %= mod
    add *= pw[N-1]
    add %= mod
    ans += add
    ans %= mod
print(ans)

Measured memory_bytes: 44656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define req(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define qer(i,a,n) for (int i=n;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())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=998244353;
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;}
// head

int H[300000],V[300000],n,q;
void addH(int x, int k){while(x<=n)H[x]=min(H[x],k),x+=x&(-x);}
int minH(int x){int ans=mod;while(x)ans=min(ans,H[x]),x-=x&(-x);return ans;}
void addV(int x, int k){while(x<=n)V[x]=min(V[x],k),x+=x&(-x);}
int minV(int x){int ans=mod;while(x)ans=min(ans,V[x]),x-=x&(-x);return ans;}
int main(){
    cin>>n>>q;ll ans=(ll)(n-2)*(n-2);req(i,1,n)H[i]=V[i]=mod;
    req(i,1,q){
        int x,y;cin>>x>>y;
        if(x==1){
            int num=minV(n+1-y);if(num>=n)num=n-1;ans-=num-1;
            addH(n+1-num,y-1);
        }
        else{
            int num=minH(n+1-y);if(num>=n)num=n-1;ans-=num-1;
            addV(n+1-num,y-1);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,m;
    cin>>n;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    cin>>m;
    vector<int> vec2(m);
    for(i=0;i<m;i++){
        cin>>vec2[i];
    }
    int ans=0;
    for(i=0;i<m;i++){
        for(j=0;j<vec.size();j++){
            if(vec2[i]==vec[j]){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3108
a = int(input())
num_list = list(map(int,input().split()))

#考えられるすべての組み合わせを計算
total = 3**a

#奇数になるパターンを計算
cul_list = [j for j in range(a)]
for i in range(a):
  if num_list[i] % 2 == 0:
    cul_list[i] = 2
  else:
    cul_list[i] = 1
#print(cul_list)
ans = 1
for k in cul_list:
  ans *= k
print(total - ans)

Measured memory_bytes: 3064
using System.Collections.Generic;
using static System.Console;

class Atcoder
{
    public static void Main()
    {
        var d = new Dictionary<string, string>()
          { ["A"] = "T", ["T"] = "A", ["C"] = "G", ["G"] = "C" };
        WriteLine(d[ReadLine()]);
    }
}


Measured memory_bytes: 11104
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e2 + 5;
const int MAXW = 1e5 + 5;

int n,capacidade;
int p[MAXW],v[MAXW];
int memo[MAXW][MAXN];

int solve(int i,int peso){
    if(memo[peso][i]!=-1) return memo[peso][i];

    if(i>n || peso==0) return 0;

    int pegar=0,nao_pegar=0;
    
    if(p[i]<=peso){
        pegar = v[i] + solve(i+1,peso-p[i]);
    }
    nao_pegar = solve(i+1,peso);

    return memo[peso][i] = max(pegar,nao_pegar);
}

int32_t main(){
    cin>>n>>capacidade;

    for(int i=1;i<=n;i++){
        cin>>p[i]>>v[i];
    }
    
    memset(memo,-1,sizeof(memo));
    
    cout << solve(1,capacidade);
}

Measured memory_bytes: 85672
N = int(input())
D,X = map(int, input().split())
A = []
for i in range(N):
    A.append(int(input()))

ans = X
for i in range(N):
    for j in range(1,D+1):
        if (j-1)%A[i] == 0:
            ans += 1
print(ans)

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

int main() {
	int n;
	double rate = 380000;
	double sum = 0;

	cin >> n;

	vector<double> x(n);
	vector<string> u(n);

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

	for (int i = 0; i < n; i++) {
		if (u[i] == "JPY") sum += x[i];
		if (u[i] == "BTC") sum += x[i] * rate;
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))


#処理内容
def main():
	A, B = getlist()
	ans = [["."] * 100 for i in range(50)] + [["#"] * 100 for i in range(50)]
	for i in range(B - 1):
		ans[1 + 2 * ((2 * i) // 100)][(1 + 2 * i) % 100] = "#"
	for i in range(A - 1):
		ans[51 + 2 * ((2 * i) // 100)][(1 + 2 * i) % 100] = "."

	print(100, 100)
	for i in range(100):
		print("".join(ans[i]))


if __name__ == '__main__':
	main()

Measured memory_bytes: 3436
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if(a*b%2==1){
    cout << "Odd" << endl;
  }else{
    cout << "Even" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define SIZE 8
#define DIA_SIZE 15 //2*SIZE-1
#define NIL -1
#define FREE 1
#define NOT_FREE 0

/*
 * 
 */

int col[SIZE], row[SIZE], dpos[DIA_SIZE], dneg[DIA_SIZE];

void printBoard();
void putQueen(int i);

int main(int argc, char** argv) {
    int k, r, c, i;
    
    for (int i = 0; i < SIZE; ++i)
    {
        row[i] = NIL;
        col[i] = FREE;
//        for (int ix = 0; ix < SIZE; ++ix) 
    }
    for (int j = 0; j < DIA_SIZE; ++j)
    {
        dpos[j] = FREE;
        dneg[j] = FREE;
    }
    
    scanf("%d", &k);
    for (int jx = 0; jx < k; ++jx)
    {
        scanf("%d %d", &r, &c);
        row[r] = c;
        col[c] = dpos[r+c] = dneg[r-c+SIZE-1] = NOT_FREE;
    }
    
    for (i = 0; i < SIZE; ++i)
        if (row[i] == NIL) break;
    putQueen(i);
    
    return (EXIT_SUCCESS);
}

void printBoard()
{
    for (int i = 0; i < SIZE; ++i)
    {
        for (int j = 0; j < SIZE; ++j) printf("%c", (row[i] == j) ? 'Q' : '.');
        printf("\n");
    }
}

void putQueen(int i)
{
    int ix;
    if (i == SIZE) 
    {
        printBoard();
        return;
    }
    
    for (int j = 0; j < SIZE; ++j)
    {
        if (col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+SIZE-1] == NOT_FREE)
            continue;
        row[i] = j;
        col[j] = dpos[i+j] = dneg[i-j+SIZE-1] = NOT_FREE;
        for (ix = i+1; ix < SIZE; ++ix)
            if (row[ix] == NIL) break;
        putQueen(ix);
        row[ix] = NIL;
        col[j] = dpos[i+j] = dneg[i-j+SIZE-1] = FREE;
    }
}



Measured memory_bytes: 2088