akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, c = 0,i,t;
    string s;
    map <string, ll> mapp;    
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s>>t;
        mapp[s] = t+c;
        c += t;
    }
    cin>>s;
    cout<<c-mapp[s];
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    pi a[n + 1];
    FOR(i, 1, n) cin >> a[i].se >> a[i].fi;
    bool ok = 1;
    sort(a + 1, a + 1 + n);
    ll t = 0;
    FOR(i, 1, n)
    {
        if(t + a[i].se > a[i].fi)
        {
            ok = 0;
            break;
        }
        t += a[i].se;
    }
    if(ok) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int a, b;

int main() {
    cin >> a >> b;
    printf("%d %d %f\n", a / b, a % b, (double) a / b);
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const uint64_t max_len = 600;
const uint64_t max_loop_len = 40 * 6 + 1;
string invalid = "{";
using Node = pair<string, ll>;

struct Solver {
    ll N, S, G;
    VV<pair<ll, string>> edges;
    VV<string> dists;

    Solver(ll N, ll A, ll S, ll G) 
        : N(N), S(S), G(G), 
          edges(N), dists(N, V<string>(max_len, invalid))
    {
        for(ll i = 0; i < A; i++) {
            ll x, y;
            string lab;
            cin >> x >> y >> lab;
            edges[x].emplace_back(y, lab);
        }
        dists[S][0] = "";
    }

    string dijk() {
        priority_queue<Node, V<Node>, greater<Node>> pq;
        pq.emplace("", S);
        while(pq.size()) {
            string s_now;
            ll idx_now;
            tie(s_now, idx_now) = pq.top();
            pq.pop();
            if(dists[idx_now][s_now.size()] < s_now) continue;
            for(const auto &edge : edges[idx_now]) {
                ll idx_nxt;
                string lab;
                tie(idx_nxt, lab) = edge;
                string s_nxt = s_now + lab;
                if(max_len <= s_nxt.size()) continue;
                if(dists[idx_nxt][s_nxt.size()] <= s_nxt) continue;
                dists[idx_nxt][s_nxt.size()] = s_nxt;
                pq.emplace(s_nxt, idx_nxt);
            }
        }
        auto ite = min_element(dists[G].begin(), dists[G].end());
        auto idx = distance(dists[G].begin(), ite);
        if(max_len - max_loop_len <= idx && idx < max_len) return "NO";
        if(*ite == invalid) return "NO";
        return *ite;
    }

    void solve() {
        cout << dijk() << endl;
    }
};

int main() {
    while(true) {
        ll N, A, S, G;
        cin >> N >> A >> S >> G;
        if(!(N + A + S + G)) break;
        Solver(N, A, S, G).solve();
    }
    return 0;
}



Measured memory_bytes: 33264
# coding: utf-8
# Your code here!
n=int(input())
S=list(map(int,input().split()))
S1=set(S)


q=int(input())
T=list(map(int,input().split()))
count=0

for j in range(q):
    if T[j] in S1:
        count+=1
    
        
print(count)


Measured memory_bytes: 17136
import java.util.Scanner;
public class Main{
    
    public void solve(){
		Scanner sc = new Scanner(System.in);
		int a,b;
		a = sc.nextInt();
		b = sc.nextInt();
        
		System.out.println((a*b)+" "+(a*2+b*2));
		
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17160
#define rep(i,n)for(i=0;i<n;i++)
W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}

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


int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	vector<vector<int> > nmVec(N, vector<int>(M));
	vector<int> bVec(M);
	int ans = 0;
	rep(j, M)cin >> bVec.at(j);

	rep(i, N) {
		int count = 0;
		rep(j, M) {
			cin >> nmVec.at(i).at(j);
			count += nmVec.at(i).at(j) * bVec.at(j);
		}
		count += C;
		if (count>0)
		{
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <vector>

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    vector<int> elements;
    int max_element = numeric_limits<int>::min();
    for (size_t i = 0; i < n; ++i)
    {
        int temp;
        cin >> temp;
        elements.push_back(temp);
        if (temp > max_element)
            max_element = temp;
    }

    vector<int> counter(max_element+1, 0);

    for (size_t i = 0; i < n; ++i)
        ++counter[elements[i]];

    int totalcount = 0;
    for (size_t i = 0; i <= max_element; ++i) {
        if (counter[i] > 1)
            totalcount += counter[i] - 1;
    }
    if (totalcount % 2)
        ++totalcount;

    cout << (n - totalcount) << endl;

    return 0;
}


Measured memory_bytes: 1144
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var a = items[0];
            var b = items[1];
            var answer = a < b ? Enumerable.Repeat((char)('0' + a), b).ToArray() : Enumerable.Repeat((char)('0' + b), a).ToArray(); 

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        print("F")
    elif 80<=m+f:
        print("A")
    elif 65<=m+f<80:
        print("B")
    elif 50<=m+f<65:
        print("C")
    elif 30<=m+f<50:
        if r>=50:
            print("C")
        else:
            print("D")
    elif m+f<30:
        print("F")


Measured memory_bytes: 5596
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_int
  gets.chomp.to_i
end

N, M, X = get_ints
A = Array.new(N) { [] }
C = []
N.times do |i|
  values = get_ints
  C[i] = values[0]
  A[i] = values[1..]
end

min = 10 ** 5 * N + 1

(2 ** N).times do |i|
  stock = 0
  a_sum = Array.new(M, 0)

  N.times do |n|
    if i[n] == 1
      stock += C[n]

      M.times do |m|
        a_sum[m] += A[n][m]
      end
    end
  end

  if a_sum.all? { |a| a >= X }
    if min > stock
      min = stock
    end
  end
end

puts (min == 10 ** 5 * N + 1) ? -1 : min


Measured memory_bytes: 14496
#include<stdio.h>
int main (void)
{
  int n;
  scanf("%d",&n);
  char s[n+1],t[n+1];
  scanf("%s%s",s,t);
  for(int i=0;i<n;i++){
    printf("%c",s[i]);
    printf("%c",t[i]);
  }
  return 0;
}


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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
char arr[mxn];
int n, m, k, q;
string s, t;

void solve(){
    cin >> n;
    cout << (1000 - n % 1000) % 1000 << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec X(N), Y(N);
    REP(i,0,N) cin >> X[i] >> Y[i];

    map<pll,ll> C;
    REP(i,0,N) {
        REP(j,0,N) {
            if(i == j) continue;
            ++C[{X[i]-X[j], Y[i]-Y[j]}];
        }
    }

    ll m = 0;
    FORR(c,C) m = MAX(m,c.second);
    PR(N-m);

    return 0;
}

/*



*/

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

int main(){
    int x[5];
    for(int i = 0; i < 5; i++){
        cin >> x[i];
        if(x[i] == 0){
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 3160
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

from itertools import permutations, combinations,combinations_with_replacement,product
ls = [a,b,c,d,e]
comb = list(combinations(ls,2))

flag=0
for i in range(10):
    sa = abs(comb[i][1] - comb[i][0])
    if sa > k:
        flag=1

if flag==0:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 38768
#include<stdio.h>
int main()
{
	int n,i;
	double h,count=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		if(i % 2==1)
			count=count+1;
	h=count/n;
	printf("%.10f",h);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N; cin >> N;

    int m = -1;
    int ans = 0;

    for (int i = 0;i < N;i++){
        int H; cin >> H;
        if(H >= m){ans++; m = H;}
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
//not so imp
#define fill0(ar) fill((ar), 0)
#define fillinf(ar) fill((ar), inf)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;
ll n;

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n;
        ll cont, sum;
        if(n%2 == 0){
            cont = n*(n-2) / 2;
            sum = n+1;
        }
        else{
            sum = n;
            cont = (n*(n-2) + 1 ) /2;
        }
        cout<<cont<<endl;
        fr(i,1,n){
            fr(j,i+1,n){
                if(i+j != sum){
                    cout<<i<<" "<<j<<endl;
                }
            }
        }
    }
    end_routine();
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n, q = map(int, input().split())
g = [list() for i in range(n)]
node = [0] * n

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    node[p-1] += x

def dfs(v, p=-1):
    for u in g[v]:
        if u == p: continue
        node[u] += node[v]
        dfs(u, v)

dfs(0)
print(*node)


Measured memory_bytes: 268464
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


int main(){
    int K; string str;
    cin >> K >> str;
    if(str.length() <= K)cout << str << endl;
    else{
        for(int i = 0; i < K; i++){
            cout << str[i];
        }
        cout << "..." << endl;
    }
}

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

int main()
{
	int n;
	scanf("%d", &n);
	char str[10005];
	scanf("%s", str);
	int len = strlen(str);
	for(int i=0; i<len; i++)
	{
		str[i] = str[i] + n;
		if(str[i]>'Z')
			str[i]-=26;
	}
	printf("%s\n", str);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

struct edge{ll from,to;};
vector<vector<edge>> g;
vector<ll> d1,d2;

void dfs(ll s, vector<ll> &d){
    for(edge e:g[s]){
        if(d[e.to]==-1){
            d[e.to]=d[s]+1;
            dfs(e.to,d);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    d1=vector<ll>(n,-1);
    d2=vector<ll>(n,-1);
    g=vector<vector<edge>>(n);
    rep(i,n-1){
        ll a,b;cin>>a>>b;
        g[a-1].push_back({a-1,b-1});
        g[b-1].push_back({b-1,a-1});
    }
    d1[0]=0;
    dfs(0,d1);
    d2[n-1]=0;
    dfs(n-1,d2);
    ll c = 0;
    for(int i=0; i<n; i++){
        if(d1[i]<=d2[i])c++;
    }
    if(c>n-c)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 13568
import java.util.*;

class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		String[] s=new String[h];
		for(int i=0;i<h;i++)
			s[i]=sc.next();
		int al=0;
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(s[i].charAt(j)=='#')
				al++;
		int[][] m=new int[h][w];
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			m[i][j]=0;
		m[h-1][w-1]=1;
		boolean[][] done=new boolean[h][w];
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			done[i][j]=false;
		done[h-1][w-1]=true;
		int[] dx={-1,0,1,0};
		int[] dy={0,-1,0,1};
		Queue<Integer> que1 = new ArrayDeque<Integer>();
		Queue<Integer> que2 = new ArrayDeque<Integer>();
		que1.add(h-1);
		que2.add(w-1);
		while(que1.size()>0)
		{
			int x=que1.poll();
			int y=que2.poll();
			for(int k=0;k<4;k++)
			{
				int nx=x+dx[k];
				int ny=y+dy[k];
				if(nx<0 || ny<0 || nx>=h || ny>=w)
					continue;
				if(s[nx].charAt(ny)=='#')
					continue;
				if(done[nx][ny])
					continue;
				done[nx][ny]=true;
				m[nx][ny]=m[x][y]+1;
				que1.add(nx);
				que2.add(ny);
			}
		}
		if(m[0][0]==0)
			System.out.println(-1);
		else
			System.out.println(h*w-m[0][0]-al);

	}
}

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

using namespace std;

string f(int a, int b, int c, int d) {

    if (a + b > c + d) {
        return "Left";
    } else if (a + b < c + d) {
        return "Right";
    }

    return "Balanced";
}

int main() {

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

    string result = f(a, b, c, d);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	K := sc.nextInt()
	A := sc.nextInt()
	B := sc.nextInt()

	for i := 1; i*K <= B; i++ {
		if A <= i*K && i*K <= B {
			fmt.Println("OK")
			return 0
		}
	}

	fmt.Println("NG")

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


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

using namespace std;

//typedef
//------------------------------------------
template<class T> using V = vector<T>;
using VI = V<int>;
using VVI = V<VI>;
using VS = V<string>;
using LL = long long;
using ULL = unsigned long long;
using VLL = V<LL>;
using VVLL = V<VLL>;
template<class T, class U> using P = pair<T, U>;
using PII = P<int, int>;
using PLL = P<LL, LL>;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

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

template<class T> inline T updmax(T &a, T b){return a = max(a,b);}
template<class T> inline T updmin(T &a, T b){return a = min(a,b);}

const int MOD = 1000000007;

int d[100005];

int main(){
    int n;
    scanf("%d", &n);
    REP(i,n)scanf("%d", &d[i]);
    sort(d, d+n);
    printf("%d\n", d[n/2] - d[n/2 - 1]);
    return 0;
}

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

int main(){
  int n,k,x,y;
  
  cin >> n >> k >> x >> y;
  
  if(n <= k){
    cout << x*n << endl;
  }else{
  	cout << x*k + (n-k)*y << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
//Date : 04 - 03 - 18
//Author : Rishabh Paul

#include<bits/stdc++.h>
using namespace std;
#define MAX 90001
#define pb push_back
pair<int ,int>p[MAX];
int vis[MAX];
int n ,m ,d ,a[301][301];
vector<int> dis[MAX] ,path[MAX];
void printArray(int n){
	for(int i = 1 ; i <= n ; i++){
		for(int j = 0 ; j < dis[i].size() ; j++)	printf("%d " ,dis[i][j]);	printf("\n");
	}
	printf("-----------------\n");
	for(int i = 1 ; i <= n ; i++){
		for(int j = 0 ; j < dis[i].size() ; j++)	printf("%d " ,path[i][j]);	printf("\n");
	}
}
int main(){
	int lb = 0;
	scanf("%d %d %d" ,&n ,&m ,&d);
	for(int i = 1 ; i <= n ; i++)
		for(int j = 1 ; j <= m ; j++){
			scanf("%d" ,&a[i][j]);
			p[a[i][j]] = make_pair(i ,j);
		}
	for(int i = 1 ; i <= n*m ; i++)	
		if(!vis[i]){
			lb++;
			int prev = -1;
			for(int j = i ; j <= n * m ; j+=d){
				vis[j] = lb;
				path[lb].push_back(j);
				if(prev == -1){	dis[lb].push_back(0);	prev = j;	}
				else{
					pair<int,int> pp = p[j] ,qq = p[prev];
					int dist = abs(qq.first - pp.first) + abs(qq.second - pp.second);
					//printf("%d " ,dist) ;
					dis[lb].push_back(dis[lb].back() + dist);
					prev = j;
				}
			}
		}
		//printArray(lb);
	int Q;
	scanf("%d" ,&Q);
	while(Q--){
		int l ,r;
		scanf("%d %d" ,&l ,&r);
		int lb = vis[l];
		vector<int>::iterator it1 = lower_bound(path[lb].begin() ,path[lb].end() ,l);
		vector<int>::iterator it2 = upper_bound(path[lb].begin() ,path[lb].end() ,r);
		--it2;
		int x1 = (int)(it1 - path[lb].begin());
		int y1 = (int)(it2 - path[lb].begin());
		if(y1 >= x1){
				printf("%d\n" ,dis[lb][y1] - dis[lb][x1]);
		}else puts("0");
	}
	return 0;
}

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

int main(){
int N,A,B;
  cin>>N>>A>>B;
  
  int ans=0;
  for(int i=1; i<=N; i++){
    int C=0, t=i;
    for(int j=0; j<5; j++){
     C+=t%10;
     t/=10;
    }
    if(A<=C && C<=B){ans+=i;}
  }
  
  cout<<ans;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int main(void){
	int n=nextint();
	long ans=1;
	bool f=false;
	for(int i=0; i<n; i++){
		long a=nextlong();
		if(a==0){
			f=false;
			ans=0;
			break;
		}
		if(!f){
			if(__builtin_smull_overflow(ans, a, &ans)){
				f=true;
			}else if(ans>1000000000000000000L){
				f=true;
			}
		}
	}
	printf("%ld\n", f?-1:ans);
}


Measured memory_bytes: 1600
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    
    sort(a,a+3);
    
    cout<<a[2]-a[0]<<endl;
    
    
        
        
        
    
   
    return 0;
}








Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())

edges = [[] for _ in range(N)]

for _ in range(M):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)

for start in range(N):
    st = deque([(start, True)])
    L = deque()
    V = set()

    while st:
        now, isFirst = st.pop()
        if isFirst:
            L.append(now)

            if now in V:
                break

            V.add(now)

            st.append((now, False))

            for to in edges[now]:
                st.append((to, True))
        else:
            L.pop()
            V.remove(now)
    else:
        continue

    print(0)
    print()
    exit()

    loopStart = L[-1]
    while L[0] != loopStart:
        L.popleft()

    print(len(L) - 1)
    ans = [v + 1 for v in L]
    print(*ans[: -1], sep='\n')
    exit()

print(-1)

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

int main() {
    int D, N;
    cin >> D >> N;
    int num = 0;
    if (D == 0) {
        if (N == 100) {
            cout << 101 << endl;
        } else {
            cout << N << endl;
        }
    } else if (D == 1) {
        for (int i = 0; i < N; i++) {
            num += 100;
        }
        if (num == 10000) {
            cout << 10100 << endl;
        } else {
            cout << num << endl;
        }
    } else {
        for (int i = 0; i < N; i++) {
            num += 10000;
        }
        if (num == 1000000) {
            cout << 1010000 << endl;
        } else {
            cout << num << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//cin >> h;
    while(h--){
        ll n;
        cin >> n;
        string s;
        cin >> s;
        ll out = 0;
        for(int i = 1; i <= n - 2; i++){
            if(s[i - 1] == 'A' && s[i] == 'B' && s[i + 1] == 'C'){
                out ++;
            }
        }
        cout << out << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  int m;
  cin >> n;
  cin >> m;
  int arr[n];
  for(int i = 0; i < n;i++)
    cin >> arr[i];
  long double sum = accumulate(arr, arr+m,0);
  long double max = sum;
  for(int i = 0; i < n-m;++i) {
    sum -= arr[i];
    sum += arr[i+m];
    if(sum>max)max=sum;
  }
  cout << fixed << (max+m)/2;
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[200200];
typedef long long ll;
struct node{
	int b,c;
	bool operator < (const node& x){
		return c>x.c;
	}
};
node t[100100];
int bs(int n,int l,int r){
	int ans=-1;
	while(l<=r){
		int md=(l+r)>>1;
		if(a[md]<n){
			ans=n;
			l=md+1;
		}
		else{
			r=md-1;
		}
	}
	return ans;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&t[i].b,&t[i].c);
	}
	sort(t+1,t+m+1);
	int pt=1;
	int ppt=n;
	for(int i=n+1;i<=2*n;i++){
		if(t[pt].b){
			t[pt].b--;
			a[i]=t[pt].c;
			ppt=i;
		}
		else{
			pt++;
			if(pt>m) break;
			a[i]=t[pt].c;
			t[pt].b--;
			ppt=i;
		}
	}
	sort(a+1,a+1+ppt);
	ll ans=0;
	int cou=0;
	for(int i=ppt;cou<n;i--){
		ans+=1ll*a[i];
		cou++;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << x << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;

typedef long long ll;
using namespace std;
static const int MOD = 998244353;
static const int MAX_N = 300000;
vector<ll> fac(MAX_N+1);
vector<ll> facinv(MAX_N+1);

ll power(ll x, ll n){ //e^x % MOD
    if (n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1){ res = res * x % MOD; }
    return res;
}

ll ncr(ll n, ll k){
    if (k == 0 || n ==k){ return 1;}
    return (((fac[n] * facinv[k]) % MOD) * facinv[n-k]) % MOD; 
}


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

    ll N,A,B,K;
    cin >> N >> A >> B >> K;

    ll ans = 0;
    vector<ll> num_b(N+1);
    rep(i,0,N+1){
        if((K - A*i)%B == 0 && K - A*i >= 0){
            num_b[i] = (K-A*i)/B;
        }else{
            num_b[i] = -1;
        }
    }

    fac[0] = 0;
    fac[1] = 1;
    rep(i,2,N+1){
        fac[i] = (fac[i-1] * i) % MOD;
    }
    rep(i,0,N+1){
        facinv[i] = power(fac[i], MOD-2);
    }
    //rep(i,0,N){
    //    print(fac[i]);
    //}
    //print("");
    //rep(i,0,N){
    //    print(facinv[i]);
    //}


    
    rep(i,0,N+1){
        if(i <= N && num_b[i] <= N && num_b[i] >= 0){
            ans += (ncr(N,i) * ncr(N, num_b[i]))%MOD;
            ans %= MOD;
        }

    }
    ll result = ans % MOD;

    print(result);

}


Measured memory_bytes: 7296
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    ll c = 0, k = 0;
    cin >> c >> k;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    ll not_first = 0;
    ll cnt = 0, ans = 0;
    for (int i=0; i<n; i++) {
        if (not_first == 0) {
            not_first = a.at(i);
            cnt++;
        }
        else if (not_first+k < a.at(i)) {
            ans++;
            not_first = a.at(i);
            cnt = 1;
        }
        else {
            cnt++;
        }
        if (cnt == c) {
            cnt = 0;
            ans++;
            not_first = 0;
        }
    }
    cout << ((not_first == 0) ? ans : ans + 1) << endl;
    return 0;
}


Measured memory_bytes: 1024
N, M = map(int,input().split())
if N == 1:
    alpha = list(map(int,input().split()))
    print(len(alpha)-1)
    exit()
li = [list(map(int,input().split())) for i in range(N)]
for i in range(0,N,1):
    del li[i][0]
for i in range(1,N,1):
    if i == 1:
        ans = set(li[i-1]) & set(li[i])
    else:
        ans = set(ans) & set(li[i])
print(len(ans))


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

template <typename T>
struct Edge
{
    int to;
    T cost;
};

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

int main()
{
    int n;
    cin >> n;
    int x[1002];
    Graph g(n);
    for(int i = 1; i < n; i++){
        int p;
        cin >> p;
        p--;
        g.add_edge(p, i);
    }
    for(int i = 0; i < n; i++) cin >> x[i];
    int l[1002], h[1002];
    for(int i = 0; i < n; i++) l[i] = h[i] = -1;
    for(int i = n - 1; i >= 0; i--){
        int k = 0;
        for(int c : g.g[i]) k += l[c] + h[c];
        bool dp[50003]{0};
        dp[0] = true;
        for(int c : g.g[i]){
            for(int j = 50000; j >= 0; j--){
                if(!dp[j]) continue;
                if(j + l[c] <= 50000) dp[j + l[c]] = true;
                if(j + h[c] <= 50000) dp[j + h[c]] = true;
            }
        }
        for(int j = 0; j <= 50000; j++){
            if(dp[j] && k - j <= x[i]){
                if(j <= x[i]) l[i] = j, h[i] = x[i];
                else l[i] = x[i], h[i] = j;
                break;
            }
        }
        if(l[i] == -1){
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
    }
    cout << "POSSIBLE" << endl;
}

Measured memory_bytes: 384
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int n, k, cnt;
int main(){
	cin >> n >> k;
	cnt = 0;
	cnt = (n - 2)/ 11*5;
	lp((n-2) % 11) {
		lop(5, j) {
			if (((i + 1) * 7 + j + 2) * 9 % 11 == k) {
//				cout << ((i + 1) * 7 + j + 2) << endl;
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

const ll MOD = 1e9+7;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)


ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}


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


    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    ll N, M, K;
    cin >> N >> M >> K;

    ll ans_v = 0;
    ll ans_h = 0;
    
    ll A = N * M;

    for(ll i = 0; i < N; i++){
        ans_v = (ans_v + (((i * (N-i))%MOD) * ((M * M)%MOD)) % MOD ) %MOD;
    }

    for(ll i = 0; i < M; i++){
        ans_h = (ans_h + (((i * (M-i))%MOD) * ((N * N)%MOD)) % MOD ) %MOD;
    }

    ll ans = 0;
    ans = (ans_v + ans_h) % MOD;
    ans = (ans * comb(A-2, K-2))% MOD;

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
const int N = 710;
bool f[N], g[N];
int a[N][N], col[N], cnt[2];
int n, m;

void dfs(int u, int w) {
  col[u] = w, cnt[w]++;
  for(int i = 1; i <= n; ++i) {
    if(u == i || a[u][i]) continue;
    if(col[i] == -1) dfs(i, w ^ 1);
    else if(col[i] == w) {
      puts("-1");
      exit(0);
    }
  }
}

int main() {
  memset(col, -1, sizeof col);
  scanf("%d%d", &n, &m);
  for(int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    a[x][y] = a[y][x] = 1;
  }
  f[0] = 1;
  for(int i = 1; i <= n; ++i) {
    if(col[i] == -1) {
      memset(g, 0, sizeof g);
      memset(cnt, 0, sizeof cnt);
      dfs(i, 0);
//      printf("cnt1 = %d cnt2 = %d\n", cnt[0], cnt[1]);      
      for(int j = 0; j <= n; ++j) {
        g[j + cnt[0]] |= f[j];
        g[j + cnt[1]] |= f[j];
      }
      for(int j = 0; j <= n; ++j)
        f[j] = g[j];
    }
  }
  int ans = 1e9;
  for(int i = 0; i <= n; ++i)
    if(f[i]) {
//      printf("qwq%d\n", i);
      ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
    }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<list>
#include<math.h>

using namespace std;
using vec = vector<int>;
using lst = list<int>;

bool check(int x, const lst & sosu)
{
	for (const auto & s : sosu)
	{
		if (sqrt(x) < s)return true;
		if (x%s == 0) return false;
	}
	return true;
}

int main()
{
	lst sosu;
	sosu.emplace_back(2);

	for (int i = 3; i < 1000000; i += 2)
	{
		if (check(i, sosu))
		{
			sosu.emplace_back(i);
		}
	}

	while (true)
	{
		int a, d, n;
		cin >> a >> d >> n;

		if (a == 0)return 0;

		for (const auto & s : sosu)
		{
			if (s < a) continue;

			if ((s - a) % d == 0)
			{
				if (--n == 0)
				{
					cout << s << endl;
					break;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 5528
#include "bits/stdc++.h"
using namespace std;
 
int main() {
        int n;
        scanf("%d", &n);
        string s, t;
        cin >> s >> t;
        if (s == t) return !puts("0");
        if (s[0] != t[0]) return !puts("-1");
        vector<int> a, b;
        b.push_back(0);
        for (int i = 1; i < n; i ++) if (t[i] != t[i - 1]) b.push_back(i);
        int k = b.size();
        int p = n - 1;
        int bp = k - 1;
        while (p > 0) {
                while (t[b[bp]] != s[p]) p --;
                if (p == 0) break;
                a.push_back(p);
                bp --;
                p = min(p, b[bp]);
        }
        a.push_back(0);
        reverse(a.begin(), a.end());
        if (a.size() != k) return !puts("-1");
        int lb = -1, ub = k;
        while (ub - lb > 1) {
                int s = (lb + ub) / 2;
                bool ok = true;
                for (int i = 0; i < k; i ++) {
                        if (i + s < k) ok &= a[i + s] - s >= b[i];
                }
                if (ok) ub = s;
                else lb = s;
        }
        printf("%d\n", ub + 1);
        return 0;
}


Measured memory_bytes: 14332
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func next(s []byte, acc []byte, used [26]bool) ([]byte, bool) {
	if len(s) == 0 {
		for i := 0; i < 26; i++ {
			if !used[i] {
				return append(acc, byte(i)+'a'), true
			}
		}
		return nil, false
	}
	c := s[0]
	ci := int(s[0] - 'a')
	used[ci] = true
	res, ok := next(s[1:], append(acc, c), used)
	used[ci] = false
	if ok {
		return res, true
	}
	for i := ci + 1; i < 26; i++ {
		if used[i] {
			continue
		}
		return append(acc, byte(i)+'a'), true
	}
	return nil, false
}

func main() {
	defer stdout.Flush()
	s := []byte(readString())
	t, ok := next(s, []byte{}, [26]bool{})
	if ok {
		println(string(t))
	} else {
		println(-1)
	}
}

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


Measured memory_bytes: 640
n = int(input())
s = input()

ans = 10**6
e_list, w_list = [0], [0]
for i in range(n):
    if s[i] == 'E':
        e_list.append(e_list[i]+1)
        w_list.append(w_list[i])
    elif s[i] == 'W':
        w_list.append(w_list[i]+1)
        e_list.append(e_list[i])
e_list.append(e_list[n])
w_list.append((w_list[n]))

for leader in range(1, n+1):
    num = w_list[leader-1] + e_list[n+1]-e_list[leader]
    if num < ans:
        ans = num

print(ans)


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

int main(){
    int a, b;
    cin >> a >> b;
    
    if ( a > 8 || b > 8 ) {
        cout << ":(\n";
    } else {
        cout << "Yay!\n";
    }
    return (0);
}


Measured memory_bytes: 3588
package main

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

func main() {
	s := IOInitialize()
	s.Buffer([]byte{}, math.MaxInt64)
	n := String(s)
	strs := strings.Split(n, "")
	res := []string{}
	for _, str := range strs {
		if str == "1" {
			res = append(res, "9")
		} else {
			res = append(res, "1")
		}
	}
	ans := strings.Join(res, "")
	fmt.Println(ans)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import time
import math

def main():

    N = int(input())

    max_sum = 55555 * 5
    primes = [True] * (max_sum)
    primes[0] = False
    primes[1] = False
    max_i = int(math.sqrt(max_sum))
    for i in range(2, max_i):
        if primes[i]:
            for j in range(i * i, max_sum, i):
                primes[j] = False

    a = []
    for i in range(5):
        a.append([])

    a[2].append(2)
    for i in range(3, 55555, 2):
        if primes[i]:
            a[i % 5].append(i)

    for i in range(1, 5):
        if N <= len(a[i]):
            print(' '.join(map(str, a[i][:N])))
            break


if __name__ == '__main__':
    main()



Measured memory_bytes: 5360
#include <iostream>
#include <vector>
#include <algorithm>

#define MAX_N 100

typedef std::pair<int, int> P;

int N;

std::vector<P> blue, red;

bool my_ord(const P &x, const P &y) {
    return x.second > y.second;
}

int main() {
    std::cin >> N;

    for (int i=0; i<N; i++) {
        P p;
        std::cin >> p.first >> p.second;
        red.push_back( p );
    }
    std::sort(red.begin(), red.end(), my_ord);

    for (int i=0; i<N; i++) {
        P p;
        std::cin >> p.first >> p.second;
        blue.push_back( p );
    }
    std::sort(blue.begin(), blue.end());

    std::vector<P>::iterator b=blue.begin();

    int res=0;
    while (b != blue.end()) {
        std::vector<P>::iterator r=red.begin();
        while (r != red.end()) {
            if (r->first < b->first && r->second < b->second) {
                ++res;
                red.erase( r );
                break;
            }
            ++r;
        }
        ++b;
    }
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
using  v = vector<ll>;
auto x = vector<int>({-1,-1,-1,0,0,1,1,1});
auto y = vector<int>({1,0,-1,1,-1,1,0,-1});

int main(){
  ll h,w;
  cin >> h >> w;
  auto s = vector<string>(h);
  for(int i=0;i<h;i++){
  	cin >> s[i];
  }
  
  for (int i = 0; i < h; i++)
  {
     for (int j = 0; j < w; j++)
     {
        if(s[i][j]=='#') {
           cout << '#';
           continue;
         }
        int c = 0;
        for (int k = 0; k < 8; k++)
        {
           if(0<=i+x[k]&&i+x[k]<h&&0<=j+y[k]&&j+y[k]<w&&s[i+x[k]][j+y[k]]=='#') c++;
        }
        cout << c;       
     }
     cout <<endl;
  }
  

}
  
  

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


double kuri2(double x,int a)
{
	double ret=1;
	double tmp=x;
	while(a!=0)
	{
		if(a&1)
			ret*=tmp;
		tmp=tmp*tmp;
		a>>=1;
	}
	return ret;
}
int saikoro[2][1000001];
int main()
{
	int n,m,k;
	while(1)
	{
		cin>>n>>m>>k;
		if(n==0)
			break;
		fill(saikoro[0],saikoro[2],0);
		saikoro[0][0]=1;
		//cerr<<"start"<<endl;
		for(int i=0;i<n;i++)
		{
			for(int l=0;l<i*m+1;l++)
			{
				if(saikoro[i&1][l]>0)
				{
					saikoro[(i+1)&1][l+1]+=saikoro[i&1][l];
					saikoro[(i+1)&1][l+m+1]-=saikoro[i&1][l];
				}
			}
			saikoro[i&1][0]=0;
			for(int j=1;j<1000001;j++)
			{
				saikoro[i&1][j]=0;
				saikoro[(i+1)&1][j]+=saikoro[(i+1)&1][j-1];
			}
		}
		double haha=kuri2(m,n);
		double ans=0;
		int cnt=0;;
		for(int i=0;i<1000001;i++)
		{
			if(saikoro[n&1][i]>0)
				ans+=(double)(max(i-k,1)*saikoro[n&1][i])/haha;
		}
		cout<<setprecision(12)<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 10984
a, b = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(b)] 
tmin = e[0][0]
tmax = e[0][1]
for i, l in enumerate(e):
  if (tmin < l[0]):
    tmin = l[0]
  if (tmax > l[1]):
    tmax = l[1]
  if (tmax - tmin) < 0:
    break
if (tmax-tmin < 0):
  print(0)
else:
  print(tmax-tmin+1)

Measured memory_bytes: 21156