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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

signed main(){
	int n,k;
	cin>>n>>k;
	cout<<(int)(log2(n)/log2(k))+1<<endl;
}

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

int main() {
  int n, m, p, x;
  cin >> n;
  n++;
  vector<int> t(n);
  rep(i, 1, n) { cin >> t[i]; }

  int sum;
  cin >> m;
  rep(i, 0, m) {
    cin >> p >> x;
    sum = 0;
    rep(i, 1, n) {
      if (p == i) {
        sum += x;
      } else {
        sum += t[i];
      }
    }
    cout << sum << endl;
  }

  getchar();
}

Measured memory_bytes: 3580
#include <cstdio>
using namespace std;

int n;
int score[100], rank[100];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n * (n - 1) / 2; i++){
		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		a--;
		b--;
		if(c > d){
			score[a] += 3;
		}else if(c < d){
			score[b] += 3;
		}else{
			score[a]++; score[b]++;
		}
	}
	for(int i = 0; i < n; i++) rank[i] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(score[i] < score[j]) rank[i]++;
		}
	}
	for(int i = 0; i < n; i++) printf("%d\n", rank[i]);
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    string s; cin >> s;
    long long k; cin >> k;

    //5000chou
    //5,000,000,000,000,000
    // 5 * 10^15
    // 2^10 = 1000
    // 1 igaino saisyo?
    // (2^10)^14 = 1000
    int upper = (k < s.size()) ? k : s.size();
    for(int i = 0; i< upper; i++){
        if(s[i] == '1')
            continue;
        else{
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n,y;
    cin>>n>>y;
    for(int i=0;i<2001;i++){
        for(int j=0;j<2001;j++){
            if(i+j<=n){
            if(1000*i+(n-i-j)*5000+10000*j>y){
                break;
            }else if(1000*i+(n-i-j)*5000+10000*j==y){
                cout<<j<<" "<<n-i-j<<" "<<i;
                return 0;
            }
            }else{
                break;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int LL;
typedef long double dd; 
#define endl "\n"
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
LL dp[2000001];
LL mod=1e9+7;
using namespace std;
bool isPrime(LL n) {
  LL j; 
  for( j=2;j<=sqrt(n);j++){
    if(n%j==0){
      break;  
    } 
  }
  if(j>sqrt(n)){
    return 1; 
  }
  else{
    return 0; }
}
void solve(LL k){
string a; 
cin>>a; 
LL c; 
for(LL i=0;i<a.size();i++){
  c+=(a[i]-'0');
}
//cout<<c; 
if(c%9==0){
  cout<<"Yes"<<endl; 
}
else{
  cout<<"No"<<endl; 
  }
 }
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 LL t=1;
//cin>>t;
 LL k=1;
while(k<=t){
   solve(k);
  k++;
  }
   return 0;
   }

Measured memory_bytes: 3728
#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG
/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#else
#define print(...)
#endif

void solve() {
    ll N;
    cin >> N;
    Graph graph(N);
    rep(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<ll> C(N);
    rep(i, N) cin >> C[i];
    sort(C.rbegin(), C.rend());
    ll m = 0;
    ll idx = -1;
    rep(i, N) {
        ll s = graph[i].size();
        if (s > m) {
            m = s;
            idx = i;
        }
    }
    priority_queue<ll> que;
    que.push(idx);
    vector<ll> ans(N, 0);
    ll i = 0;
    while (!que.empty()) {
        ll q = que.top();
        que.pop();
        if (ans[q] == 0) {
            ans[q] = C[i];
            i++;
        }
        for (ll u : graph[q]) {
            if (ans[u] == 0) {
                ans[u] = C[i];
                i++;
                que.push(u);
            }
        }
    }
    ll a = 0;
    rep(u, N) {
        for (ll v : graph[u]) {
            a += min(ans[u], ans[v]);
        }
    }
    cout << a / 2 << '\n';
    rep(j, N) {
        cout << ans[j] << ' ';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 4336
function Main(input) {
  const N = input.split(' ')[0]
  const X = input.split(' ')[1]
  const T = input.split(' ')[2]

  const result = Math.ceil(N / X) * T
  console.log(result)
  }

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
    }
    int cnt = 0;
    rep(i, n){
        if(p[i]%2 == 0){
            if(p[i]%3 == 0 || p[i]%5 == 0){
            }
            else{
                cnt++;
            }}
    }
    if(cnt){
        cout << "DENIED";
    }
    else{cout << "APPROVED";}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n];
	int sum=0;
	for(int i=0;i<n;i++)
	   {
	   	  cin>>arr[i];
	   	  sum+=arr[i];
       }
	   int v1=sum/n;
	   int v2=ceil(sum/float(n));
	   int count1=0,count2=0;
	   for(int i=0;i<n;i++)
	   {
	   	   count1+=(v1-arr[i])*(v1-arr[i]);
	   	   count2+=(v2-arr[i])*(v2-arr[i]);
	   }
	   cout<<min(count1,count2)<<endl;
	   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int A,B;
int main (){
    cin >> A >> B;
    if( A == B ) cout << "Draw" << endl;
    else if ( (B != 1) & (A == 1 || A > B) ) cout << "Alice" << endl;
    else  cout << "Bob" << endl;
    return 0;
}


Measured memory_bytes: 256
while True:

    W,H=list(map(int,input().split()))
    if W==0 and H==0:
        break

    for i in range(W):
        for j in range(H):
            if (i+j)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
const int maxN = int(1e5+10);
int e[maxN]={},o[maxN]={};
int num[maxN]={};

const int limc = 1000+10;
int main(){
    int n,t;
    int minc = limc;
    cin >> n >> t;
    rep(i,n){
        int tc,tt;
        cin >> tc >> tt;
        if (tt <= t){
            if(tc < minc)minc=tc;
        }
    }
    if (minc == limc)cout << "TLE" << endl;
    else cout << minc << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n')[0].split(' ')
	const x = parseInt(args[0], 10)
	const y = parseInt(args[1], 10)
	const z = parseInt(args[2], 10)
	let n = 0

	while (true) {
		const t1 = y * (n + 1) + z * (n + 2)
		if (t1 > x) break 
		else n++
	}

	console.log(n)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int p[N];
  REP(i, N) { cin >> p[i]; }
  int cnt = 0;
  FOR(i, 1, N - 1) {
    if (p[i - 1] < p[i] && p[i] < p[i + 1] ||
        p[i - 1] > p[i] && p[i] > p[i + 1]) {
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int a;
	cin >> a;
	int ans =0;
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			if (i * 4 + j * 7==a)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 384
use v5.18;
use warnings;
use List::Util;
use Data::Dumper;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }
sub unique { my %u; $u{$_} = $_ for @_; values %u; }

my ($a, $b, $c) = splited_read_line;
say $a * $b / 2;


Measured memory_bytes: 1920
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


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

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



int main(void){

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

	cout << min(min(a+b, a+c),b+c) << endl;


	return 0;

}


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

using namespace std;

int main(void) {
    int N, K;
    string S;
    cin >> N >> K >> S;

    int cnt = 0;
    for(int i=1; i<N; i++) {
        if(S[i-1] != S[i]) ++cnt;
    }

    if(cnt <= 2*K) {
        cout << N-1 << endl;
    } else {
        cout << N-1 - cnt + 2*K << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
N = int(input().strip())
S = [input().strip() for _ in range(N)]

poll = dict()

for key in S:
    poll[key] = poll.get(key, 0) + 1

max_num = max(poll.values())
results = [key for key in poll if poll[key] == max_num]
results.sort()

for s in results:
    print(s)

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

using namespace std;
int main()
{
  int n;
cin >> n;
ll t;
ld ans = 1;
for (int i = 0; i < n; i++)
{
    cin >> t;
    if (ans != -1)
       ans *= t;
    if (ans > 1000000000000000000 || ans < 0)
       ans = -1;
    if (t == 0)
       ans = 0;
}
cout<<(ll)ans;
return 0;
}



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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;

    if (a == 0 || b == 0 || (a < 0 && 0 < b)){
        cout << "Zero" << endl;
    }else if(a > 0 || (b < 0 && (b - a + 1) % 2 == 0)){
        cout << "Positive" << endl;
    }else{
        cout << "Negative" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int count = 0;
	
	/* ----- input ----- */
	scanf("%d %d %d", &a, &b, &c);
	
	/* ----- to do ----- */
	while( (a%2 == 0) && (b%2 == 0) && (c%2 == 0) ){
		if(a == b && b == c){
			count = -1;
			break;
		}
		else{
			int x = a;
			int y = b;
			int z = c;
			a = y/2 + z/2;
			b = x/2 + z/2;
			c = x/2 + y/2;
			
			count++;
		}
	}
	
	/* ----- output ----- */
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 128
# -*- coding:utf-8 -*-

def solve():
    import sys
    import numpy as np

    N, M, X = list(map(int, sys.stdin.readline().split()))
    Cs = []
    AAs = []
    for _ in range(N):
        _in = list(map(int, sys.stdin.readline().split()))
        c, As = _in[0], _in[1:]
        Cs.append(c)
        AAs.append(np.array(As))

    ans = float("inf")
    for bit in range(2**N):
        total = 0
        masters = np.array([0]*M)

        for i in range(N):
            if bit>>i&1:
                total += Cs[i]
                masters += AAs[i]

            if sum(masters>=X) == M:
                ans = min(ans, total)

    if ans == float("inf"):
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 27300
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main(){

	map<char,string> table;
	table[' ']="101";
	table[(char)39]="000000";
	table[',']="000011";
	table['-']="10010001";
	table['.']="010001";
	table['?']="000001";
	table['A']="100101";
	table['B']="10011010";
	table['C']="0101";
	table['D']="0001";
	table['E']="110";
	table['F']="01001";
	table['G']="10011011";
	table['H']="010000";
	table['I']="0111";
	table['J']="10011000";
	table['K']="0110";
	table['L']="00100";
	table['M']="10011001";
	table['N']="10011110";
	table['O']="00101";
	table['P']="111";
	table['Q']="10011111";
	table['R']="1000";
	table['S']="00110";
	table['T']="00111";
	table['U']="10011100";
	table['V']="10011101";
	table['W']="000010";
	table['X']="10010010";
	table['Y']="10010011";
	table['Z']="10010000";


	map<string,char> table2;
	for(int i = 0; i < 26; i++){
		string ms;
		for(int j = 0; j < 5; j++){
			if((i>>j)&1){
				ms+='1';
			}
			else
				ms+='0';
		}
		reverse(ms.begin(),ms.end());
		table2[ms]='A'+i;
	}
	table2["11010"]=' ';
	table2["11011"]='.';
	table2["11100"]=',';
	table2["11101"]='-';
	table2["11110"]=(char)39;
	table2["11111"]='?';

	string str;
	while(getline(cin,str)){
		string nstr="";
		for(int i = 0; i < str.size(); i++){
			nstr+=table[str[i]];
		}
		int t=nstr.size();
		if(nstr.size()%5!=0){
			int add=(((nstr.size()/5)+1)*5)-nstr.size();
			for(int i = 0; i < add; i++){
				nstr+='0';
			}
		}
		string fstr="";
		for(int i = 0; i < nstr.size()/5; i++){
			string s=nstr.substr(5*(i),5);
			fstr+=table2[s];
		}
		cout<<fstr<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-

import sys
import os

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

if A > B:
    print(0)
elif A == B:
    print(1)
elif N == 1:
    print(0)
elif N == 2:
    print(1)
else:
    # N > 2
    rest = N - 2
    min_sum = A * rest
    max_sum = B * rest
    pattern = max_sum - min_sum + 1
    print(pattern)

Measured memory_bytes: 3064
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

template <typename T>
std::vector<T> dijkstra(std::vector<std::vector<std::pair<int,T> > > & G, int s) {
	const T INF = std::numeric_limits<T>::max();
	int n = G.size();
	using n_node = std::pair<T,int>;
	std::vector<T> dist(n,INF);
	std::priority_queue<n_node,std::vector<n_node>,std::greater<n_node> > next;
	next.emplace(0,s);
	while(!next.empty()) {
		n_node t = next.top(); next.pop();
		int i = t.second; T cost = t.first;
		if(dist[i]!=INF) continue;
		dist[i] = cost;
		for(auto e:G[i]) {
			next.emplace(cost+e.second,e.first);
		}
	}
	return dist;
}


signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<std::pair<int,int> > > G(n,std::vector<std::pair<int,int> >());
	rep(i,n-1) {
		G[i+1].emplace_back(i,0);
	}
	rep(i,m) {
		int l,r,c;
		std::cin >> l >> r >> c;
		l--;r--;
		G[l].emplace_back(r,c);
	}
	const int INF = std::numeric_limits<int>::max();
	auto x = dijkstra(G,0);
	if(x[n-1]==INF) {
		print(-1);
	}
	else {
		print(x[n-1]);
	}

	return 0;
}


Measured memory_bytes: 10872
# coding: utf-8

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
#		print(x1)
#		print(x2)
#		print(x3)
#		print(y1)
#		print(y2)
#		print(y3)

		xg = 1./3 * (x1 + x2 + x3)
		yg = 1./3 * (y1 + y2 + y3)
#		print("xg = {:}, yg = {:}".format(xg, yg))
		
		def line(xi, yi, xj, yj, x, y):
			return (yi-yj)*x/(xi-xj) + (xi*yj-xj*yi)/(xi-xj)
		
		if x1 != x2:
			def line12(x, y):
				if y < line(x1, y1, x2, y2, x, y):
#					print("2")
					return 2
				elif y > line(x1, y1, x2, y2, x, y):
#					print("3")
					return 3
				else:
#					print("0")
					return 0
		else:
			def line12(x, y):
				if x1 < x:
#					print("2")
					return 2
				elif x1 > x:
#					print("3")
					return 3
				else:
#					print("0")
					return 0

		if x2 != x3:
			def line23(x, y):
				if y < line(x2, y2, x3, y3, x, y):
#					print("5")
					return 5
				elif y > line(x2, y2, x3, y3, x, y):
#					print("7")
					return 7
				else:
#					print("0")
					return 0
		else:
			def line23(x, y):
				if x2 < x:
#					print("5")
					return 5
				elif x2 > x:
#					print("7")
					return 7
				else:
#					print("0")
					return 0

		if x1 != x3:
			def line13(x, y):
				if y < line(x1, y1, x3, y3, x, y):
#					print("11")
					return 11
				elif y > line(x1, y1, x3, y3, x, y):
#					print("13")
					return 13
				else:
#					print("0")
					return 0
		else:
			def line13(x, y):
				if x1 < x:
#					print("11")
					return 11
				elif x1 > x:
#					print("13")
					return 13
				else:
#					print("0")
					return 0

		if line12(xp, yp)*line23(xp, yp)*line13(xp, yp) == line12(xg, yg)*line23(xg, yg)*line13(xg, yg):
			print("YES")
		else:
			print("NO")

	except EOFError:
		break


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(void){
    // input
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> numa(100000);

    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        numa[a[i]-1]++;
    }
    int q;
    cin >> q;
    vector<int> b(q), c(q);
    for(int i = 0; i < q; i++){
        cin >> b[i] >> c[i];
    }
    // input end

   for(int i = 0 ; i < q; i++){
       int numB = numa[b[i]-1];
       numa[b[i]-1] = 0;
       numa[c[i]-1] += numB;
       sum = sum + numB * (c[i] - b[i]);
       cout << sum << "\n";
   }
    return 0;
}


Measured memory_bytes: 4648
n=int(input())
dic={}
maxx=1
for i in range(n):
  s=input()
  if s in dic:
    dic[s]+=1
  else:
    dic[s]=1
  if dic[s]>maxx:
    maxx=dic[s]
lis=[]
for i in range(len(dic)):
  kk=dic.popitem()
  if kk[1]==maxx:
    lis.append(kk[0])
lis.sort()
for i in range(0,len(lis)):
  print(lis[i])
    

Measured memory_bytes: 32096
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  s << "]";
  return s;
}

vector<int> frac;
void init_frac(int N) {
  frac.push_back(1);
  for (int i = 1; i <= N; i++) {
    frac.push_back(mod(frac[i-1] * i));
  }
}

int powM(int x, int n) {
  int res = 1;
  while (n > 0) {
    if ((n & 1) == 1) {
      res = mod(res * x);
    }
    x = mod(x * x);
    n >>= 1;
  }
  return res;
}

int inverse(int x) {
  return powM(x, MOD-2);
}

int comb(int n, int r) {
  if (n < 0 || n-r < 0 || r < 0) {
    return 0;
  }
  return mod(frac[n] * inverse(mod(frac[n-r]*frac[r])));
}


signed main()
{
  int n; cin >> n;
  vec<int> a(n+1);
  rep(i, 0, n+1) {
    cin >> a[i];
  }

  vec<bool> used(n, false);
  int m;
  rep(i, 0, n+1) {
    if (used[a[i]]) {
      m = a[i];
      break;
    }
    used[a[i]] = true;
  }

  vec<int> idx;
  rep(i, 0, n+1) {
    if (a[i] == m) {
      idx.push_back(i);
    }
  }

  init_frac(1e5+1);
  rep(k, 1, n+2) {
    cout << mod(comb(n+1,k) - comb(idx[0] + n-idx[1], k-1)) << endl;
  }

  return 0;
}


Measured memory_bytes: 2936
<?php
fscanf(STDIN,"%d %d %d",$r,$d,$x);

$atai=$r*$x-$d;
echo	$atai."\r\n";
for($i=1;$i<=9;$i++){
	$k=$r*$atai-$d;
	echo $k."\r\n";
	$atai=$k;
}

?>

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX 100001
using namespace std;

int main(){
  int N,tmp;
  cin >> N;
  vector<int> A;
  for(int i = 0;i < N;i++){
    cin >> tmp;
    A.push_back(tmp);
  }
  while(A.size() > 1){
    sort(A.begin(),A.end());
    for(int i = 0;i < A.size();i++){
      if(i == 0 && A[i] != 0) break;
      else if(i != 0 && A[i] != 0){
         A.erase(A.begin(),A.begin()+i);
         break;
       }
    }
    for(int i = 1;i < A.size();i++){
      A[i] %= A[0];
    }
  }
  cout << A[0] << endl;
}


Measured memory_bytes: 892
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N,0);
  int i,j;
  int d,a;
  for(i=0;i<K;i++) {
    cin >> d;
    for(j=0;j<d;j++) {
      cin >> a;
      A[a-1]++;
    }
  }
  int ans = 0;
  for(i=0;i<N;i++)if(A[i]==0)ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3628
n, m, x = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 7

for bit in range(2**n):
    tmp = [0] * m
    cost = 0
    for i in range(n):
        if (bit >> i) & 1:
            cost += arr[i][0]
            for j in range(m):
                tmp[j] += arr[i][j+1]
    if all(tmp_ >= x for tmp_ in tmp):
        ans = min(ans, cost)

print(ans if ans < 10**7 else -1)


Measured memory_bytes: 9144
import java.util.*;



public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int k = scanner.nextInt();
    int n = 0;
    for(int i =1 ; i <=k; i++){
      n = ((n  *10) % k + 7) % k;
      if(n == 0){
      System.out.println(i);
      scanner.close();
    return;
    }
      
    }
    
    System.out.println("-1");
    scanner.close();
    return;
  }
  
}


Measured memory_bytes: 35624
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main() {
    int N; cin >> N;
    ll a[N]; REP(i, N) cin >> a[i];
    ll sum[N][N];
    ll S;
    REP(l, N){
        S = 0;
        FOR(r, l, N){
            S += a[r];
            sum[l][r] = S;
        }
    }
    ll dp[N+1][N];
    REP(i, N) dp[1][i] = 0;
    FOR(l, 2, N+1){
        REP(i, N-l+1){
            ll tmp = dp[1][i] + dp[l-1][i+1];
            FOR(nl, 1, l){
                tmp = min(dp[nl][i] + dp[l-nl][i+nl], tmp);
            }
            dp[l][i] = tmp + sum[i][i+l-1];
        }
    }
    /*
    REP(l, N+1){
        REP(i, N){
            cout << dp[l][i] << ' ';
        }
        cout << endl;
    }
    */
    cout << dp[N][0] << endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int co[10000] = { 0 };
int main(){
	int n, x, y;
	cin >> n >> x >> y;		
	for (int j = 1; j < n; j++) {
			for (int k = j + 1; k <= n; k++) {
				int ans = k - j;
				int ans1 = abs(j - x) + abs(y - k) + 1;
				if (ans < ans1) {
					co[ans]++;
				}
				else {
					co[ans1]++;
				}
				
			}
		}
	for (int l = 1; l < n; l++) {
		cout << co[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static boolean is_prime(int n) {
	    if (n <= 3) {
	        return n > 1;
	    }
	    if (n % 6 != 1 && n % 6 != 5) {
	        return false;
	    }
	    int sqrt = (int) Math.sqrt(n);
	    for (int i = 5; i <= sqrt; i += 6) {
	        if (n % i == 0 || n % (i + 2) == 0) {
	            return false;
	        }
	    }
	    return true;
	    }
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count=0;
		int x[] = new int[n];
		while(n-1>=0) {
			x[count] = sc.nextInt();
			count++;
			n--;

		}
		count = 0;
		for(int i=0;i<x.length;i++) {
			if(is_prime(x[i])) {
				count++;
				}
			}
		System.out.println(count);
		sc.close();
		}

	}




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

int main() {
  ll X;
  cin >> X;
  ll now = 100;
  for (int i = 1;; i++) {
    now += now / 100;
    if (now >= X) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

vector<vector<int>> graph(100010, vector<int>());
vector<int> dis(100010);

void dfs(int n, int p, int d, vector<int> &vec) {
	vec[n] = d;
	for (int i : graph[n]) {
		if (i != p) dfs(i, n, d + 1, vec);
	}
}

vector<int> solve(int n, int g) {
	vector<int> res; res.pb(1);
	int v = n; int pre = -1;
	int num = 2;
	while (true) {
		for (int i : graph[v]) {
			if (dis[i] < dis[v]) {
				pre = v; v = i;
			}
		}
		res.pb(num); num++;
		if (v == g) break;
		for (int i : graph[v]) {
			if (i == pre) continue;
			if (dis[i] > dis[v]) {
				int p = res[res.size() - 1];
				res.pop_back();
				res.pb(num); num++;
				res.pb(p);
			}
		}
	}
	return res;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	rep(_, n - 1) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	dfs(0, -1, 0, dis);
	int idx = 0; int m = 0;
	rep(i, n) if (chmax(m, dis[i])) idx = i;
	dfs(idx, -1, 0, dis); int fidx = 0; m = 0;
	rep(i, n) if (chmax(m, dis[i])) fidx = i;
	vector<int> x = solve(fidx, idx);
	dfs(fidx, -1, 0, dis);
	vector<int> y = solve(idx, fidx);
	vector<int> ans = min(x, y);
	if (ans.size() != n) cout << -1 << '\n';
	else {
		rep(i, n) cout << ans[i] << ' ';
		cout << '\n';
	}
}

Measured memory_bytes: 11128
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int A, B;
	cin >> A >> B;


	if (A == B) co("Yes");
	else co("No");




	Would you please return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    int A, B;
    cin >> A >> B;

    cout << (A+B)%24 << endl;

    return 0;
}

Measured memory_bytes: 256
# agc002_a.py
A, B = map(int,input().split())
if A<=0 and B>=0:
    print('Zero')
elif A>0 and B>0:
    print("Positive")
elif A<0 and B<0:
    if (A-B)%2==0:
        print("Negative")
    else:
        print("Positive")


Measured memory_bytes: 2940
import sys
n=int(input())
l=[[int(i) for i in l.split()] for l in sys.stdin]
for i in range(n-1):
  if l[i]==l[i+1]:
    continue
  x=max((l[i][0]+l[i+1][0]-1)//l[i+1][0],(l[i][1]+l[i+1][1]-1)//l[i+1][1])
  l[i+1][0]*=x
  l[i+1][1]*=x
print(sum(l[-1]))

Measured memory_bytes: 3188
using System;
namespace std
{
    class Program
    {
        static void Main(string[] args) {
            int tmp;
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var c = int.Parse(input[2]);
       
            if (a > b) {
               tmp = b;
               b = a;
               a = tmp;
            }
            if (b > c) {
               tmp = c;
               c = b;
               b = tmp;
            }
            if(a > b) {
                tmp = b;
                b = a;
                a = tmp;
            }
            Console.WriteLine(a + " " + b + " " + c);
        }
    }
}


Measured memory_bytes: 19936
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

    vector<int> a(n + 1);
    rep(i, n){
        a[i+1] = a[i];
        if(s[i] == '#'){
            a[i+1]++;
        }
    }

    int ans = INF;
    for(int i = 0; i <= n; i++){
        int tmp = a[i] + (n - i) - (a[n] - a[i]);
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2676
def lcs(x, y)
  m = x.length
  n = y.length
  # maxl = 0
  c = Array.new(m+1) { Array.new(n+1, 0) }
  for i in 1..m
    for j in 1..n
      if x[i-1] == y[j-1]
        c[i][j] = c[i - 1][j - 1] + 1
      elsif c[i - 1][j] >= c[i][j - 1]
        c[i][j] = c[i - 1][j]
      else
        c[i][j] = c[i][j - 1]
      end
      # maxl = [maxl, c[i][j]].max
      # puts c.join(' ')
      # puts "c[1][3] : #{c[1][3]}"
      # puts "x: #{x[i]}, `y: #{y[j]}, i: #{i}, j: #{j}, c[i][j]: #{c[i][j]}, c[i-1][j-1]: #{c[i-1][j-1]}, maxl: #{maxl}"
    end
  end
  c[m][n]
end

gets.to_i.times do
  x = gets.chomp.chars
  y = gets.chomp.chars
  puts lcs(x, y)
end


Measured memory_bytes: 53948
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


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





n = I()
s = S()

fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod


ans = 1
l = 0
for i in s:
    if (i == 'B' and l % 2 == 0) or (i == 'W' and l % 2):
        l += 1
    else:
        if l == 0:
            print(0)
            exit()
        ans = ans * l % mod
        l -= 1


if l:
    print(0)
else:
    print(ans * fac[n] % mod)

Measured memory_bytes: 44232
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),M=in();
	if(N>M) swap(N,M);
	if(N==1 && M==2) out(3);
	else if(N==2 && M==3) out(1);
	else if(N==1 && M==3) out(2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>

using namespace std;

int main() {
    int n;

    cin >> n;

    vector<tuple<int, string, int>> ss;

    for(int i = 1; i <= n; i++){
        string s;
        int p;
        cin >> s >> p;
        tuple<int, string, int> e(i, s, p);
        ss.push_back(e);
    }

    std::sort(ss.begin(), ss.end(), [](tuple<int, string, int> l, tuple<int, string, int> r){
        if (std::get<1>(l) == std::get<1>(r)) {
            return std::get<2>(l) > std::get<2>(r);
        }
        return std::get<1>(l) < std::get<1>(r);
    });

    for(auto &e : ss){
        cout << get<0>(e) << endl;
    }

    return 0;
}

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

typedef long long ll;

int main()
{
   string s;
   cin >> s;
   
   int res = 0;
   int i = 1;
   while (s.size() > 2 && i < s.size()-1) {
      if (s[i-1] != s[i+1]) {
         s.erase(i, 1);
         i = (i-1 > 0) ? i-1 : i;
         ++res;
      }
      else ++i;
   }

   if (res % 2 == 0) cout << "Second" << endl;
   else cout << "First" << endl;
   return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    abc066c()
}

// 奇数の場合は奇数indexが右、そうでない場合は逆
fun abc066c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toLong() }

    val (evens, odds) = aList.mapIndexed { index, l -> Pair(index, l) }.partition { it.first % 2 == 0 }

    val aListSizeIsEven = aList.size % 2 == 0
    val left = if (aListSizeIsEven) odds.reversed() else evens.reversed()
    val right = if (aListSizeIsEven) evens else odds

    val answer = (left + right).map { it.second }

    println(answer.joinToString(separator = " "))
}


Measured memory_bytes: 109084
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
   int n;
   cin>>n;
   string s1;
   string s2;
   cin>>s1;
   cin>>s2;
   vector<bool> v;
   rep(i,n){
       if(s1[i]==s2[i]){
             v.push_back(1);
       }else{
            v.push_back(0);   
            i++;
       }
   }
    lint res=0;
    rep(i,v.size()){
        if(i==0){
            if(v[i]==1){
                res+=3;
            }else{
                res+=6;
            }
        }else{
            if(v[i-1]==1 && v[i]==1){
                res*=2;
                res%=MOD;
            }else if(v[i-1]==1 && v[i]==0){
                res*=2;
                res%=MOD;
            }else if(v[i-1]==0 && v[i]==0){
                res*=3;
                res%=MOD;
            }else{
                res*=1;
                res%=MOD;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 165
//A - We Love Golf
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

using ll = long long;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
    int k, a, b;

    cin >> k >> a >> b;

    bool flag = false;

    int kk = k;

    while (b >= kk) {
        if ((a <= kk) && (kk <= b)){
            flag = true;
            break;
        }
        kk += k;
    }

    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}


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

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  
  cout << n * 800 - int(n/15) * 200 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
int main()
{
long A,B,C;
std::cin >> A >> B >> C;
long num=0;
if(A+B>=C-1){
    num=B+C;
}else{
    num=1+(A+B)+B;
}
std::cout << num << std::endl;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{

			int[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			if (arr[0] > 0 && arr[0] < 10 && arr[1] > 0 && arr[1] < 10)
			{
				Console.WriteLine(arr[0] * arr[1]);
			}
			else
			{
				Console.WriteLine(-1);
			}


		}
	}

}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std; 
    using ll = long long;
    using P = pair<int,int>; 
    
    int main() {
     ll n;
     int m;
     cin >> n >> m;
     ll a[m];
     rep(i,m) cin >> a[i];
     
     int sum = 0;
     rep(i,m) sum +=a[i]; 
     
     if(n<sum) cout << -1 << '\n';
     else cout << n-sum << '\n';
     
     return 0;
    }
    

Measured memory_bytes: 3660
#include <iostream>
#define MAX 100

using namespace std;

void bubblesort(int a[], int n){
	/*int i,j;
	int flag;
	int temp;
	int count = 0;
	while(flag){
		flag = 0;
		for(i = 0 ; i < n-1 ; i++){
			if(a[i] > a[i+1]){
				temp = a[i];
				a[i] = a[i+1];
				a[i+1] = temp;
				flag = 1;
				count++;
	for(i = 0 ; i < n - 1 ; i++){
		cout << a[i] << " ";
	}
	cout << a[n-1] << endl;
			}
		}
	}
	for(i = 0 ; i < n - 1 ; i++){
		cout << a[i] << " ";
	}
	cout << a[n-1] << endl;

	cout << count <<  endl;*/
	int sw = 0;
	bool flag = 1;

	for(int i = 0 ; flag ; i++){
		flag = 0;
		for(int j = n - 1 ; j  >= i + 1 ; j--){
			if(a[j] < a[j-1]){
				swap(a[j],a[j-1]);
				flag = 1;
				sw++;
			}
		}
	}

	for(int i = 0 ; i < n - 1 ; i++){
		cout << a[i] << " ";
	}
	cout << a[n-1] << endl;

	cout << sw <<  endl;

}

int main(){
	int i;
	int n;
	int a[MAX];

	cin >> n;

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

	bubblesort(a,n);
}

Measured memory_bytes: 1160
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

d = abs(a-b)
s = v - w

if s <= 0:
  print('NO')
  exit(0)

if (t * s) >= d:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 61608
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int size = in.nextInt();
		int n = in.nextInt();
		int[] lines = new int[size];
		int a, b;
		for (int i = 0; i < lines.length; i++) {
			lines[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String input = in.next();
			a = Integer.parseInt(input.split(",")[0]);
			b = Integer.parseInt(input.split(",")[1]);
			lines = swap(a, b, lines);
		}
		for (int i = 0; i < lines.length; i++) {
			System.out.println(lines[i]);
		}
		in.close();
	}

	public static int[] swap(int a, int b, int[] lines) {
		int temp = lines[a - 1];
		lines[a - 1] = lines[b - 1];
		lines[b - 1] = temp;
		return lines;
	}
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;
typedef pair< int, P > PP;

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


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

	int n, a, b, c, d[100] = {};
	cin >> n >> a >> b >> c;
	REP(i, n) cin >> d[i];
	sort(d, d + n, greater<int>());
	int ans = c / a, sum = 0;
	REP(i, n) {
		sum += d[i];
		ans = max(ans, (c + sum) / (a + b * (i + 1)));
	}
	cout << ans << endl;

	return 0;
}




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

int main()
{
  int A, B, T, ans = 0;
  cin >> A >> B >> T;
  int temp = A;

  for (int i = 0; i < T + 1; i++) {
    if (i == temp) {
      ans += B;
      temp += A;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc137/tasks/abc137_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll K,X; cin>>K>>X;
    ll minp=max<ll>(X-K+1,-1000000);
    ll maxp=min<ll>(X+K-1,1000000);
    for(ll i=minp;i<=maxp;++i){
        cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
typedef pair<int,int> pii;
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=1005;
int s[N][N],q[N*N];//c1[N];c2[N];
pii p[N];
inline bool solve(int n,int m,int a,int b,int x,int y){
//	printf("solve n=%d m=%d a=%d b=%d x=%d y=%d\n",n,m,a,b,x,y);
	memset(s,0,sizeof(s));
	int i,j,u,c,t=0;
	rep(i,  1,b)rep(j,1,m)q[++t]=j;
	u=n-(b<<1);
	rep(i,  1,u)rep(j,1,y)q[++t]=j;
//	rep(i,  1,t)printf("%d ",q[i]);printf("Q\n");
//	rep(i,  1,y)c2[i]=n-b;
//	rep(i,y+1,m)c2[i]=  b;
//	rep(i,1,n)printf("%d ",c1[i]);printf("\n");
//	rep(i,1,m)printf("%d ",c2[i]);printf("\n");
/*
	rep(i,  1,n){
		rep(j,1,m)p[j]=mp(-c2[j],j);
		sort(p+1,p+m+1);
		if(!p[c=c1[i]].fi)return false;
		rep(j,1,c){
			s[i][u=p[j].se]=1;
			--c2[u];
		}
	}*/
	t=0;
	rep(i,1,n){
		c=(i<=x)?m-a:a;
//		printf("%d %d\n",i,c);
		rep(j,1,c){
			if(s[i][q[++t]])return false;
			s[i][q[t]]=1;
		}
	}
	rep(i,  1,n){rep(j,1,m)putchar(48^s[i][j]);putchar('\n');}
	return true;
}
int main(){
	int n,m,a,b,i,j,b1,b2,k1,k2;
	scanf("%d%d%d%d",&n,&m,&a,&b);
	b1=a*n;k1=m-(a<<1);
	b2=b*m;k2=n-(b<<1);
//	printf("%d %d %d %d\n",b1,k1,b2,k2);
	rep(i,0,n)rep(j,0,m)if(b1+i*k1==b2+j*k2&&solve(n,m,a,b,i,j))return 0;
	putchar('-');
	putchar('1');
	return 0;
}

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

int main() {
        string S;
        int K;
        
        cin >> S >> K;
        for (int i = 0; i < S.size() - 1; i++) {
                if (S[i] > 'a' && 'z' - S[i] + 1 <= K) {
                        K -= 'z' - S[i] + 1;
                        S[i] = 'a';
                }
        }

        int last = S.size() - 1;
        if (K > 0) {
                S[last] -= 'a';
                S[last] = ((int)S[last] + K) % 26;
                S[last] += 'a';
        }

        cout << S << endl;      

        return (0);
}

Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];

  string ans = "APPROVED";
  rep(i, n){
    if (a[i] %2 == 0){
      if (a[i] % 3 != 0 and a[i] % 5 != 0) ans = "DENIED";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256