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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    //データ
    int card[4][13] = {
        {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13},  //スペード
        {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13},  //ハート
        {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13},  //クラブ
        {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13},  //ダイヤ
    };

    //入力
    int n;
    cin >> n;
    char suit;
    int  num;
    int  x = -1;
    rep(i, n) {
        cin >> suit >> num;
        switch (suit) {
            case 'S':
                x = 0;
                break;
            case 'H':
                x = 1;
                break;
            case 'C':
                x = 2;
                break;
            case 'D':
                x = 3;
                break;
        }
        card[x][num - 1] = 0;
    }

    // 出力
    rep(u, 4) {
        rep(j, 13) {
            if (card[u][j]) {
                switch (u) {
                    case 0:
                        suit = 'S';
                        break;
                    case 1:
                        suit = 'H';
                        break;
                    case 2:
                        suit = 'C';
                        break;
                    case 3:
                        suit = 'D';
                        break;
                }
                cout << suit << " " << card[u][j] << "\n";
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
using namespace std;
int main(){
char a[2][3];
cin>>a[0]>>a[1];
if(a[0][0]==a[1][2]&&a[0][1]==a[1][1]&&a[0][2]==a[1][0])
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}

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

const int N = 1e5L + 11;
int a[N];

int main() {
	ios :: sync_with_stdio(0);
	int n, l; cin >> n >> l;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 1; i < n; i ++) if(a[i] + a[i + 1] >= l) {
		cout << "Possible\n";
		for(int j = 1; j < i; j ++)
			cout << j << '\n';
		for(int j = n - 1; j > i; j --)
			cout << j << '\n';
		cout << i << '\n';
		return 0;
	}
	cout << "Impossible\n";
}

Measured memory_bytes: 1280
from heapq import *

N = int(input())

result = 100000

ns = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]

h = []

xs = {}

heappush(h, (0, 0))

while 1:
    r, m = heappop(h)
    if m == N:
        result = r
        break
    for n in ns:
        s = r + 1
        x = m + n
        if x <= N and not x in xs:
            xs[x] = s
            heappush(h, (s, x))

print(result)



Measured memory_bytes: 16800
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<int>> a(h + 1, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    vector<vector<int>> b(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> b[i][j];
        }
    }

    int l = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            l = max(l, (h + w) * abs(a[i][j] - b[i][j]) + 1);
        }
    }

    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(l, false)));
    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < l; k++) {
                if (dp[i][j][k] && i + 1 < h && k + abs(a[i + 1][j] - b[i + 1][j]) < l) {
                    dp[i + 1][j][k + abs(a[i + 1][j] - b[i + 1][j])] = true;
                }
                if (dp[i][j][k] && i + 1 < h && abs(k - abs(a[i + 1][j] - b[i + 1][j])) < l) {
                    dp[i + 1][j][abs(k - abs(a[i + 1][j] - b[i + 1][j]))] = true;
                }
                if (dp[i][j][k] && j + 1 < w && k + abs(a[i][j + 1] - b[i][j + 1]) < l) {
                    dp[i][j + 1][k + abs(a[i][j + 1] - b[i][j + 1])] = true;
                }
                if (dp[i][j][k] && j + 1 < w && abs(k - abs(a[i][j + 1] - b[i][j + 1])) < l) {
                    dp[i][j + 1][abs(k - abs(a[i][j + 1] - b[i][j + 1]))] = true;
                }
            }
        }
    }

    for (int i = 0; i < l; i++) {
        if (dp[h - 1][w - 1][i]) {
            cout << i << endl;
            break;
        }
    }
}


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

############### TESTCASE ###############
test = ""
#test = \
"""
33
ABCCABCBABCCABACBCBBABCBCBCBCABCB
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
################# MAIN ################# 

n = int(input2())
s = input2()

ans = 0
for i in range(n-2):
    if s[i] + s[i+1] + s[i+2] == "ABC":
        ans += 1

print(ans)
    

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

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

int main()
{
    int w, h, c, a;

    cin >> w >> h >> c;

    a = GCD( w, h );

    cout << w / a * h / a * c << endl;
    return 0;
}


Measured memory_bytes: 3124
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

int q , w , e , z ;

int main()
{
	speed;

    int w , n1 , n2 ;
    cin >> w >> n1 >> n2 ;
    int k = min( n1 , n2 ) ;
    int u = max( n1 , n2 ) ;
    int j = k + w ;
    int i = u - j ;
    if( i < 0 ){
        cout << 0 ;
    }
    else{
        cout << i ;
    }

	time;
}


Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Wed Mar 11 16:31:16 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

S = ns()
T = ns()
N = len(S)
flag = False

for i in range(N + 1):
    q = S[:i]
    p = S[i:]
    if p + q == T:
        flag = True
    
print("Yes" if flag else "No")

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author bhavy seth
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, InputReader sc, PrintWriter out) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int x = (int) (a / 0.08);
            for (int i = 1; i < 50000; i++) {
                if (Math.floor(i * 0.08) == a && Math.floor(i * 0.1) == b) {
                    out.println(i);
                    break;
                }
                if (i == 49999)
                    out.println(-1);
            }
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

typedef long long int ll;

using namespace std;

int main(void){

    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;

    ans += (n/(a+b)) * a;
    ans += (n%(a+b) >= a ? a : n%(a+b));

    cout << ans << endl;


    return 0;
}

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

int main() {
    map<string, int> days = {
        {"SUN", 7},
        {"MON", 6},
        {"TUE", 5},
        {"WED", 4},
        {"THU", 3},
        {"FRI", 2},
        {"SAT", 1}
    };

    string S = "";

    cin >> S;

    cout << days.at(S);

    return 0;
}

Measured memory_bytes: 256
from collections import deque
N, X, Y = map(int, input().split())

X -= 1
Y -= 1

q = deque()

ans = [0] * N

def BFS(x, cnt):
    if dist[x] != (N + 1):
        return
    cnt += 1
        
    dist[x] = cnt
    if x + 1 < N:
        q.append((x + 1, cnt))
    if x - 1 >= 0:
        q.append((x - 1, cnt))
    if x == X:
        q.append((Y, cnt))
    if x == Y:
        q.append((X, cnt))


for x in range(N):
    dist = [N + 1] * N
    q.append((x, -1))
    while q:
        BFS(*q.popleft())

    for i in range(N):
        ans[dist[i]] += 1

for x in range(1, N):
    print(ans[x] // 2)






Measured memory_bytes: 120284
#include <cstdio>
#include <cstring>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std; 
typedef long long ll;
const int maxN=200+5;
int T;
int N;
ll A[maxN];
ll base[64];
char S[maxN];
void ins(ll x) {
	for(int i=62;~i;--i) if(x>>i&1) {
		if(base[i]) x^=base[i];
		else {
			for(int j=i+1;j<63;++j) if(base[j]>>i&1) {
				base[j]^=x;
			}
			for(int j=i-1;~j;--j) if(x>>j&1) {
				x^=base[j];
			}
			base[i]=x;
			break;
		}
	}
}
bool sol() {
	memset(base,0,sizeof(base));
	for(int i=N;i>=1;--i) {
		if(S[i]=='0') {
			ins(A[i]);
		}
		else {
			for(int j=62;~j;--j) if(A[i]>>j&1) {
				if(!base[j]) return 1;
				A[i]^=base[j];
			}
		}
	}
	return 0;
}
int main() {
	scanf("%d",&T);
	for(int kase=1;kase<=T;++kase) {
		scanf("%d",&N);
		for(int i=1;i<=N;++i) scanf("%lld",&A[i]);
		scanf("%s",S+1);
		printf("%d\n",sol());
	}
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
int n,A,B,C,D;
char s[300005];
void walk(int &i){
	if (s[i+1]!='#'){
		swap(s[i],s[i+1]);
		i++;
	}
	else if (s[i+2]!='#'){
		swap(s[i],s[i+2]);
		i+=2;
	}
	else{
		puts("No");
		exit(0);
	}
}
void walkk(int &i){
	if (s[i+1]!='#'){
		swap(s[i],s[i+1]);
		i++;
	}
	else if (s[i+2]!='#'){
		swap(s[i],s[i+2]);
		i+=2;
	}
	else if (B==i+2)
		walk(B);
	else{
		puts("No");
		exit(0);
	}
}
int main(){
	scanf("%d%d%d%d%d%s",&n,&A,&B,&C,&D,s+1);
	s[A]=s[B]='#';
	if (C>D){
		for (;A<=C&&B<=D&&A<B;){
			if (B-A>1) walkk(A);
			else if (B-A==1&&s[A+2]!='#') walk(A);
			else walk(B);
		}
	}
	if (C>D){
		for (;A<C;walk(A));
		for (;B<D;walk(B));
	}
	else{
		for (;B<D;walk(B));
		for (;A<C;walk(A));
	}
	if (A!=C||B!=D) puts("No");
	else puts("Yes");
}

Measured memory_bytes: 384
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

/** ワーシャル・フロイド法による全点対最短路探索

    経路を逐次最小化していく。

    頂点番号は0オリジン。

    知らないパスにはコスト大きめを設定しておくこと。
    その初期コストはすべての都市を回ってくるパスよりも大きくすべし。
    ただ、内部で加算するのでオーバーフローに注意。MAXダメ、絶対。
    std::fill(mat.data(), mat.data() + mat.num_elements(), MAXCOST+1);

    O(|V|^3)

    @note 反対方向もいれた？
    mat[a][b] = mat[b][a] = c;

    @note 自分自身へのルートはコスト0か？
    for (int i = 0; i < N; ++i) {
    mat[i][i] = 0;
    }

    @param[in] V  頂点数
    @param[in, out] distance[i][j]: 頂点i -> jのコスト
*/
template<typename T, typename M>
void warshall_floyd(T V, M& distance)
{
    for (T k = 0; k < V; ++k) {
        for (T i = 0; i < V; ++i) {
            for (T j = 0; j < V; ++j) {
                distance[i][j] = std::min(distance[i][j],
                                          distance[i][k] + distance[k][j]);
            }
        }
    }
}



int main()
{
    int64_t H, W;
    std::cin >> H >> W;

    boost::multi_array<int64_t, 2> C(boost::extents[10][10]);
    for (auto p = C.data(); p < (C.origin() + C.num_elements()); ++p) {
        std::cin >> *p;
    }
    warshall_floyd(10, C);


    int64_t sum = 0;
    for (size_t i = 0; i < H * W; ++i) {
        int a;
        std::cin >> a;
        if (a != -1) {
            sum += C[a][1];
        }
    }

    std::cout << sum << std::endl;

    return 0;
}


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

using namespace std;

typedef long long int ll;

int main(){
    int N,M;
    priority_queue<ll> A;

    cin >> N >> M;

    for(int i=0;i<N;i++){
        ll Ai;
        cin >> Ai;
        A.push(Ai);
    }

    ll ans=0;

    for(int i=0;i<M;i++){
        ll max=A.top();
        A.pop();
        max/=2;
        A.push(max);
    }

    while(A.empty()!=1){
        ans+=A.top();
        A.pop();
    }

    cout << ans << endl;

}

Measured memory_bytes: 1400
import Control.Applicative
import Control.Monad
import Data.Monoid
import Data.List
import Data.List.Split
import Data.Ord
import Data.Fixed
 

apply2 f [x,y] = f x y

f ps = firstP : sub firstP 0
  where
    sub p a = let np = nextP p a in if np==firstP then [] else np : sub np (angleFrom p np)
    firstP = minimumBy (comparing snd <> flip (comparing fst)) ps
    nextP p a = minimumBy (comparing (flip mod' (2*pi) . subtract a . angleFrom p)) (delete p ps)
    angleFrom (x0,y0) (x,y) = atan2 (y-y0) (x-x0)

main = do
    n <- readLn
    unless (n==0) $ map (apply2 (,) . map read . wordsBy (==',')) <$> replicateM n getLine >>= print . (n-) . length . f >> main


Measured memory_bytes: 4704
N, M = map(int, input().split())

mx = 0
for i in range(1, int(M ** 0.5) + 1)[::-1]:
    if M % i == 0 and M // i >= N:
        mx = max(mx, i)
    if M % i == 0 and i >= N:
        mx = max(mx, M // i)
print(mx)


Measured memory_bytes: 3060
// Tenki.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <string>

using namespace std;

string a, b;
int ans = 0;

int main() {
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++) {
		ans += (a[i] == b[i]);
	}
	cout << ans << endl;
	return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt()-1;
        int y = sc.nextInt()-1;

        int[][] dis = new int[n][n];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j)
                    dis[i][j] = 2 * n;
            }
        }
        
        for (int i = 0; i < n; i++) {
            int dist = 1;
            for (int j = i + 1; j < n; j++) {
                dis[i][j] = Math.min(dis[i][j], dist);
                dist++;
            }
            int dist2 = (x >= i)?x - i + 1:i - x + 1;
            if(dist2 > 0) {
                for (int k = y; k < n; k++) {
                    dis[i][k] = Math.min(dis[i][k], dist2);
                    dist2++;
                }
                dist2 = (x >= i)?x - i + 1:i - x + 1;
                for (int k = y; k >= 0; k--) {
                    dis[i][k] = Math.min(dis[i][k], dist2);
                    dist2++;
                }
            }   
            dist2 = (y >= i)?y - i + 1:i - y + 1;
            if (dist2 > 0) {
                for (int k = x; k < n; k++) {
                    dis[i][k] = Math.min(dis[i][k], dist2);
                    dist2++;
                }
                dist2 = (y >= i)?y - i + 1:i - y + 1;
                for (int k = x; k >= 0; k--) {
                    dis[i][k] = Math.min(dis[i][k], dist2);
                    dist2++;
                }
            }
        }
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                ans[dis[i][j]]++;
            }
        }
        for(int i = 1; i < n; i++) {
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 52768
#include <stdio.h>

int main(void)
{
    int h, w;
    int i, j;

    while (1){
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0){
            break;
        }else{
            for (i = 1; i <= h; i++){
                for (j = 1; j <= w; j++){
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

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

	vector<ll> argA(argN);
	for (ll i = 0; i < argN; ++i) {
		cin >> argA.at(i);
	}

	map<ll, ll> mapA;
	for (ll i = 0; i < argN; ++i) {
		if (mapA.find(argA.at(i)) != mapA.end()) {
			mapA.erase(argA.at(i));
		}
		else {
			mapA.emplace(argA.at(i), 1);
		}
	}

	cout << mapA.size() << endl;
}

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

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

    int n;
    cin >> n;
    int lowest_rank = 0;
    int lowest_point;
    int a, b;
    while (n--) {
        cin >> a >> b;
        if (a > lowest_rank) {
            lowest_rank = a;
            lowest_point = b;
        }
    }

    cout << lowest_rank + lowest_point  << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
int main(void)
{
	LL i,j,n,m,k;
	cin>>n>>m>>k;
	for(i=0;i<k;i++) cin>>bol[i]>>r1[i]>>r2[i];
	for(i=0;i<n;i++) club[i]=0,node[i]=i,size[i]=1;
	for(i=0;i<k;i++) {
		int x,y,c,s;
		if(bol[i]==1) {
			x=r1[i],y=r2[i];
			while(x!=node[x]) x=node[x];
			while(y!=node[y]) y=node[y];
			if(club[x]!=0&&club[y]!=0&&club[x]!=club[y]) {
				cout<<i+1<<endl;
				break;
			}
			else if(club[x]!=0&&club[y]==0) club[y]=club[x];
			else if(club[x]==0&&club[y]!=0) club[x]=club[y];
			if(x!=y) {
				if(size[x]>size[y]) node[y]=x;
				else if(size[y]>size[x]) node[x]=y;
				else node[y]=x,size[x]++;
			}
		}
		else {
			s=r1[i],c=r2[i];
			while(s!=node[s]) s=node[s];
			if(club[s]==0) club[s]=c;
			else if(club[s]!=c) {
				cout<<i+1<<endl;
				break;
			}
		}
	}
	if(i==k) cout<<"0"<<endl;
}

Measured memory_bytes: 10104
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;cin >>a  >> b;cout << a*b;
    }

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

struct UnionFind {
    // parent[a] = b: "aの親がbである"
    // 親の場合は-(その集合のサイズ)を返す。
    vector<int> parent;

    // 全て根であるとみなす。
    // parent[x] == -1のとき、そのノードは根である。
    UnionFind(int n=0): parent(n, -1) {}

    // xがどのグループに属しているかを返す。
    int find(int x) {
        if (parent[x] < 0) return x; // 今の頂点が根ならその値を返す
        return parent[x] = find(parent[x]); // 経路縮約（メモ化）
    }

    // AとBをつなげる。AとBを直接つなぐのではなく、root(A)とroot(B)をつなげる。
    bool unite(int x, int y) { // Minimum Spanning Treeのためにboolを返す実装にしている。
        x = find(x); // それぞれのノードの親を取得する。
        y = find(y);

        if (x == y) return false; // すでにくっついているのでくっつけない。
        // 大きい方に小さい方をくっつけたい。
        if (size(x) < size(y)) swap(x, y); // マイナスサイズなので不等号が逆。xのサイズの方が大きいようにする。
        parent[x] += parent[y]; // 連結成分のサイズを管理するためのコード
        parent[y] = x; // xにyをくっつける。yの値をxの根とする。

        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -parent[find(x)]; }
};


int main(){
    int n, m;
    cin >> n >> m;

    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    vector<ll> ans(m);
    ans[m-1] = (ll)n * (n - 1) / 2;

    UnionFind uni(n); // 頂点数を渡す。

    for (int i=m-1;i>=1;--i) {
        ans[i - 1] = ans[i];

        // つながっていなかったものがつながったとき
        if (uni.find(a[i]) != uni.find(b[i])) {
            ans[i - 1] -= (ll)uni.size(a[i]) * uni.size(b[i]);
            uni.unite(a[i], b[i]);
        }
    }

    rep(i, m) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3328
s = input()
k = int(input())
que = []

def insert(t):
    global que
    for i in range(len(que)):
        if t < que[i]:
            que.insert(i, t)
            if len(que) > 5:
                que = que[:5]
            return
        if que[i] == t:
            return
    if len(que) < 5:
        que.append(t)

for i in range(len(s)):
    for j in range(i+1, min(len(s)+1, i+6)):
        t = s[i:j]
        insert(t)

print(que[k-1])




Measured memory_bytes: 41964
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int A,B,C,X,Y; cin >>A >>B >>C >>X >>Y;

  int ans=0;
  if (2*C<A+B) {
    int Z=min(X,Y);
    X-=Z;
    Y-=Z;
    ans+=2*C*Z;
  }
  A=min(A,2*C);
  B=min(B,2*C);
  ans+=A*X;
  ans+=B*Y;

  cout <<ans <<'\n';
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
    #include <vector>
    using namespace std;
     
    int main() {
        int N;
        cin >> N;
        vector<int> A(N);
        int mod = 1000000007;
        long long sum = 0;
        for (int i = 0; i < N; i++)
        {
            cin >> A[i];
            sum += A[i];
            sum %= mod;
        }
     
        long ans = 0;
     
        //Search for all i
        for (int i = 0; i < N; i++)
        {
            //Update the values of A[i+1] ... A[N]
            sum -= A[i];
            if (sum < 0) sum += mod;
     
            ans += A[i] * sum;
            ans %= mod;
        }
     
        cout << ans << endl;
    }

Measured memory_bytes: 4056
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	int x = 0;
	for(int i = 0;i<n;i++)cin >> a[i]>> b[i];
	for(int i = 0;i<n;i++)
	{
		if(a[i]==b[i])x++;
		else x = 0;
		if(x==3)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000007],ans,qz[1000007];
const ll N=1000000007;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]%=N;
		qz[i]=a[i];
	}


    for(int i=2;i<=n;i++)
    {
    	qz[i]+=qz[i-1]%N;
    	qz[i]%=N;
    
    }

	for(int i=n;i>=3;i--)
	{
		ans+=((a[i]%N)*(qz[i-1]%N))%N;
	}
	ans+=(a[1]%N)*(a[2]%N);
	ans%=N;
	cout<<ans;
	return 0;
}

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

using namespace std;
int main(){
  
  int n;
  cin >> n;
  string w[n],tmp;
  cin >> w[0];
  char f,b=w[0].back();
  
  for(int i=1;i<n;i++){
    cin >> w[i];
    if(w[i].front()!=b){cout << "No" << endl; return 0;}
    for(int j=0;j<i;j++){
      if(w[i]==w[j]){cout << "No" << endl; return 0;}
    }
    f=w[i].front();
    b=w[i].back();
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
    int n = cin.nextInt();
    int k = cin.nextInt();
    int res = n-k+1;
    if (res>=0) {
      System.out.println(res);
    }
    else {
      System.out.println(0);
    }
  }

}


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

using namespace std;

int n;
string s;
int w[200005], b[200005];

int main(void)
{
	cin >> n;
	cin >> s;
	s = "%" + s;
	
	for(int i = 1; i <= n; i++){
		w[i] = w[i-1], b[i] = b[i-1];
		if(s[i] == '#') b[i]++;
		else w[i]++;
	}
	
	int ans = w[n];
	for(int i = 1; i <= n; i++){
		ans = min(ans, b[i] + w[n]-w[i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2112
N, M = map(int, input().split())
p = [int(x) for x in input().split()]

class UnionFind:
    def __init__(self, n):
        self.group = list(range(n))
    
    def find(self, x):
        cv = self.group[x]
        if cv != x:
            self.group[x] = self.find(cv)
        return self.group[x]
    
    def union(self, x, y):
        self.group[self.find(x)] = self.find(y)

g = UnionFind(N + 1)
for _ in range(M):
    x, y = map(int, input().split())
    g.union( x, y)

ans = 0
for i, n in enumerate(p, 1):
    ans += g.find(i) == g.find(n)
print(ans)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    string S;
    cin >> S;
    bool a = false;
    bool b = false;
    if(S[0] == 'A' || S[1] == 'A' || S[2] == 'A')a = true;
    if(S[0] == 'B' || S[1] == 'B' || S[2] == 'B')b = true;
    if(a && b)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;
using P = pair<int,int>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

class BECC{
private:
    int N;
    vvec<int> G;
    vec<int> order,inS;
    stack<int> S,roots;
    vec<int> cmp;
public:
    vec<P> bridge;
    vvec<int> bccs;
    vvec<int> dcmp;
    BECC(int n,vvec<int> graph){
        N = n;
        G = graph;
        order = inS = cmp = vec<int>(N,0);
    }
    void dfs(int cur,int prev,int k){
        order[cur] = ++k; //訪問順に番号付け
        S.push(cur); inS[cur] = true;//訪問した頂点の集合に追加
        roots.push(cur);//各bccの根を管理
        for(auto to:G[cur]){
            if(order[to]==0) dfs(to,cur,k);
            else if(to!=prev && inS[to]){//後退辺なら
                while(order[roots.top()]>order[to]) roots.pop();//(to,cur]を捨てる
            }
        }
        if(cur==roots.top()){
            if(prev!=-1) bridge.emplace_back(prev,cur);//根でないなら橋になる
            vec<int> bcc;
            while(true){
                int node = S.top(); S.pop(); inS[node] = false;//nodeを捨てる
                bcc.emplace_back(node);//nodeをbccに追加
                cmp[node] = bccs.size();
                if(node==cur) break;
            }
            bccs.emplace_back(bcc);
            roots.pop();
        }
    }
    void bridge_detection(){
        int k = 0;
        for(int i=0;i<N;i++) if(order[i]==0) dfs(i,-1,k);
    }
    int find(int n){return cmp[n];}
    int cmp_size(int n){return bccs[cmp[n]].size();}
    void decomposition(){
        int k = 0;
        for(int i=0;i<N;i++) if(order[i]==0) dfs(i,-1,k);
        dcmp = vvec<int>(bccs.size()+1);
        for(auto x:bridge){
            dcmp[cmp[x.first]].push_back(cmp[x.second]);
            dcmp[cmp[x.second]].push_back(cmp[x.first]);
        }
    }
};

int N,M;
int main(){
    cin >> N >> M;
    vector<vector<int>> v(N+1);
    int a,b;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    BECC becc(N,v);
    becc.bridge_detection();
    for(auto& x:becc.bridge) if(x.first>x.second) swap(x.first,x.second);
    sort(becc.bridge.begin(),becc.bridge.end());
    for(auto& x:becc.bridge) cout << x.first << " " << x.second << endl;
}


Measured memory_bytes: 5668
def yakusu(a):
    c = 0
    for i in range(1,a+1):
        if a%i==0:
            c += 1
    return c
n=int(input())
m=0
for i in range(1,n+1):
    if i%2==1 and yakusu(i)==8:
        m += 1
print(m)

Measured memory_bytes: 2940
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑


ll n, k[100005], sum, even;
vector<ll>ans;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		sum += k[i];
		if (i % 2) { even += k[i]; }
	}

	ans.push_back(sum - 2 * even);
	for (int i = 1; i < n; ++i) {
		ans.push_back(2 * k[i - 1] - ans[ans.size() - 1]);
	}


	for (auto i : ans) { cout << i << " "; }
	cout << endl;
}

Measured memory_bytes: 3060
#include<iostream>
//j=前の日,1=J,11=JO,111=JOI,100=I
using namespace std;
int n, ho[1202] = {} ,memo[112][1001][112];
char a[1202];
int sh(int j, int day,int ij)
{
	int A = 0;
	A = j - ho[day];
	if (A == 99 || A == 9 || A == 109 || A == 90 || A == 91 || A == -9 || A == -99 || A == -90 || A == -89)return 0;
	int B;
	B = j - ij;
	if (ij == 11)
	{
		if (j == 110)
			B=1000;
		if (j == 101)
			B=1000;
	}
	if (ij == 110 ){
		if (j==11)
		B = 1000;
		if (j == 101)
			B = 1000;
	}
	if (ij == 101 ){
		if (j==110)
		B = 1000;
		if (j == 11)
			B = 1000;
	}
	
	if (B == 9 || B == 99 || B == 109 || B == -9 || B == 90 || B == 91 || B == 89 || B == -99 || B == -90 || B == -89 || B == -109 || B == -91){
		return 0;
	}
	if (day > n)return 0;

	if (day == n)return 1;


	int ans = 0;
	if (memo[j][day][ij] != -1){
		return  memo[j][day][ij]; 
	} else{
	
	ans += sh(1, day + 1, j);
	ans += sh(11, day + 1, j);
	ans += sh(10, day + 1, j);
	ans += sh(100, day + 1, j);
	ans += sh(110, day + 1, j);
	ans += sh(111, day + 1, j);
	ans += sh(101, day + 1, j);
	}
	ans%=10007;
	memo[j][day][ij] = ans;
	return ans;
}
int main()
{
	int s[2500] = {};
	cin >> n;
	cin >> a;
	ho[0] = 1;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 'J')ho[i+1] = 1;
		if (a[i] == 'O')ho[i+1] = 10;
		if (a[i] == 'I')ho[i+1] = 100;
	}
	for (int i = 0; i < 112; i++)
	{
		for (int g = 0; g < 1001; g++)
		{
			for (int jk = 0; jk < 112; jk++)
			{
				memo[i][g][jk] = -1;
			}
			
		}
	}

	cout << sh(1,0,0) << endl;

	return 0;
}





/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

string moji,yoso[200];

int f(string a)
{
	if(moji.find(a,0))
	{
		
}
int main ()
{
	int z;
	int ans=0;
	cin>>z;
	cin>>moji;
	for(int i=0;i<z;i++)
	{
		cin>>yoso[i];
		
	}
	for(int i=0;i<z;i++)
	{
		if(moji.find(yoso[i],0)){ans++;continue;}
		f(yoso[i].at(0));
	}
	return 0;
}*/

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

void Solve(){
	char c;
	cin>>c;
	char s = toupper(c);
	if(s == c) cout<<"A\n";
	else cout<<"a\n";

}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin>>T;
	while(T--){
		Solve();
	}
}

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

class RR
{
private:
    queue<pair<string, int>> process;
    queue<pair<string, int>> done_process;

public:
    void push(string name, int time); //引数からpairを作ってprocessにpushする関数。mainから呼び出す。
    void execute(int quantum);        //ラウンドロビンスケジューリングの処理を行う関数
    pair<string, int> answer(void);
};

void RR::execute(int quantum)
{
    int total = 0;
    while (!process.empty())
    {
        if (process.front().second <= quantum)
        {
            total += process.front().second;
            done_process.push(make_pair(process.front().first, total));
        }
        else
        {
            int undone_time = process.front().second - quantum;
            push(process.front().first, undone_time);
            total += quantum;
        }
        process.pop();
    }
}

void RR::push(string name, int time)
{
    process.push(make_pair(name, time));
}

pair<string, int> RR::answer()
{
    pair<string, int> temp;
    temp = done_process.front();
    done_process.pop();

    return temp;
}

int main()
{
    RR round_robin;
    int n, q;
    string name;
    int time;
    cin >> n >> q;
    for (int i = 0; i < n; i++)
    {
        cin >> name >> time;
        round_robin.push(name, time);
    }
    round_robin.execute(q);
    for (int i = 0; i < n; i++)
    {
        pair<string, int> answer = round_robin.answer();
        cout << answer.first << " " << answer.second << endl;
    }
}


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

int main() {
  string s;
  cin >> s;
  bool flg = true;
  for(int i = 0; i < s.size(); i++){
    int cnt = 0;
    for(int j = 0; j < s.size(); j++){
      if(s[i] == s[j]) cnt++;
    }
    if(cnt % 2 != 0) flg = false;
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC077C
{
  // After reading editorial
  class Program
  {
    static void Main(string[] args)
    {
      int N = int.Parse(Console.ReadLine());
      int[][] nums = new int[3][] { new int[N], new int[N], new int[N] };

      string[] bufsA = Console.ReadLine().Split(' ');
      string[] bufsB = Console.ReadLine().Split(' ');
      string[] bufsC = Console.ReadLine().Split(' ');
      for (int i = 0; i < N; i++) {
        nums[0][i] = int.Parse(bufsA[i]);
        nums[1][i] = int.Parse(bufsB[i]);
        nums[2][i] = int.Parse(bufsC[i]);
      }

      Array.Sort(nums[0]);
      // Array.Sort(nums[1]);
      Array.Sort(nums[2]);

      long res = 0;
      for (int j = 0; j < N; j++) {
        int i = Array.BinarySearch(nums[0], nums[1][j]);
        int k = Array.BinarySearch(nums[2], nums[1][j]);
        while (i > 0) {
          i = Array.BinarySearch(nums[0], 0, i, nums[1][j]);
        }

        if (i < 0) {
          i = ~i;
        } else {
          i = 0;
        }

        while (k > 0 && k < N - 1) {
          k = Array.BinarySearch(nums[2], k + 1, N - k - 1, nums[1][j]);
        }

        if (k < 0) {
          k = N - ~k;
        } else {
          k = N - k - 1;
        }

        res += (long)i * k;
      }

      Console.WriteLine(res);
    }
  }
}


Measured memory_bytes: 42436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = RArInt();
            int r = vs[0];
            int g = vs[1];
            int b = vs[2];
            int n = vs[3];

            int res = 0;
            for (int i = 0; i <= n; i += r)
            {
                for (int j = 0; j <= n; j += g)
                {
                    if (i + j <= n && (n - (i + j)) % b == 0) res++;
                }
            }

            Console.WriteLine(res);
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


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

int main() {
  int a,b,k;
  cin >>a>>b>>k;
  for (int i=a;i<=b;i++) {
	if (i<=a+k-1 || i>=b-k+1) {
	  cout << i << endl;
	}
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n;
typedef struct node
{		
	long long a[51][51];
	long long scale;
	struct node operator *(const struct node & tmp)
	{
	        struct node ret;
		long long i,j,k;
	        ret.scale=scale;
		memset(ret.a,0,sizeof(ret.a));
	      	for(k=1;k<=scale;k++)
			for(i=1;i<=scale;i++)
				for(j=1;j<=scale;j++)
					if(a[i][k]&&tmp.a[k][j])
						ret.a[i][j]=(ret.a[i][j]+(long long)a[i][k]*tmp.a[k][j])%1000000007;
	        return ret;
	}
}NODE,*PNODE;
NODE g,ans;
int main()
{	
	long long s=0,flag=0;
	long long i,j,k,q,w;
	scanf("%lld %lld",&n,&k);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%lld",&g.a[i][j]);		
		}
	}
	g.scale=n;
	while(k)
	{
		if(k%2)
		{
			if(!flag)
			{
				ans=g;
				flag=1;
			}
			else 
				ans=ans*g;
		}
		g=g*g;
		k/=2;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			s=(s+ans.a[i][j])%1000000007;
		}
	}
	printf("%lld",s);
	return 0;
}	

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
bool direct(int i, pii b, pii bb){
  return abs(b.second - bb.second)*(i + 2) <= bb.first - b.first;
}

bool back(int i, pii b, pii bb){
  return bb.second + b.second*(i + 2) <= bb.first - b.first;
}
int main(){
  int n;
  while(cin >> n, n){
    vector<pii> b(n);
    for(int i = 0; i < n; i++){
      cin >> b[i].second >> b[i].first;
    }
    sort(b.begin(), b.end());
    int dp[3][n];
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < n; j++){
	dp[i][j] = 1e9;
      }
    }
    dp[0][0] = b[0].second;
    if(b[0].second > b[0].first){
      cout << "NG " << 1 << endl;
      continue;
    }
    for(int j = 0; j < n - 1; j++){
      for(int i = 0; i < 3; i++){
	if(dp[i][j] == 1e9)continue;
	if(i < 2 && direct(i, b[j], b[j + 1])){
	  dp[i + 1][j + 1] = min(dp[i + 1][j + 1], 
				 dp[i][j] + abs(b[j].second - b[j + 1].second));
	}
	if(back(i, b[j], b[j + 1])){
	  dp[0][j + 1] = min(dp[0][j + 1],
			     dp[i][j] + b[j].second + b[j + 1].second);
	}
      }
    }
    int ans = 1e9;
    for(int i = 0; i < 3; i++){
      ans = min(ans, dp[i][n -1]);
    }
    if(ans != 1e9){
      cout << "OK " << ans + b[n - 1].second << endl;      
    }else{

      
      for(int j = n - 1; j >= 0; j--){
	for(int i = 0; i < 3; i++){
	  if(dp[i][j] != 1e9){
	    cout << "NG " << j + 2 << endl;
	    j = 0;
	    break;
	  }
	}
      }

      
    }
  }
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n > 999) cout << "ABD" << endl;
    if(n <= 999) cout << "ABC" << endl;
}

Measured memory_bytes: 256
//
//  main.c
//  ITP1_4_A
//
//  Created by k16031kk on 2018/05/21.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n", d, r, f);
    return 0;
}



Measured memory_bytes: 2104
a, b, c, d, e, f = map(int, input().split())

n = f//(100*a)
m = f//(100*b)
p = f//c
q = f//d

mx = 0
for i in range(n+1):
    for j in range(m+1):
        for k in range(p+1):
            for l in range(q+1):
                if i == 0 and j == 0:
                    continue
                s = 100*a*i+100*b*j
                t = c*k+d*l
                u = 100*t/s
                if s + t> f:
                    continue
                if u > e:
                    continue
                if mx <= u:
                    mx = u
                    ans1, ans2 = s+t, t
                    if mx == e:
                        print(ans1, ans2)
                        exit()
print(ans1, ans2)


Measured memory_bytes: 3064
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 2e4 + 1;


void solve() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].second >> a[i].first;
	}
	sort(rall(a));

	set<int> st;
	for (int i = 0; i < m; i++) st.insert(i);

	int ans = 0;
	for (int i = 0; i < n && !st.empty(); i++) {
		int x = m - a[i].second;
		auto it = st.upper_bound(x);
		if (it == st.begin()) continue;
		it--;
		st.erase(it);
		ans += a[i].first;
	}
	cout << ans;
}


signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 6528
#include<stdio.h>


int main(void)

{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	if (a + b >= c)

	{
		printf("Yes\n");

	}if (a + b < c)
	{
		printf("No\n");

	}
	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define MAX_V 10010

int V, cmp[MAX_V];
bool used[MAX_V];
vector<int> G[MAX_V], rG[MAX_V], vs;

void add_edge(int from, int to)
{
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v)
{
  used[v] = true;
  for (int i = 0; i < (int)G[v].size(); i++) {
    if (!used[G[v][i]]) {
      dfs(G[v][i]);
    }
  }
  vs.push_back(v);
}

void rdfs(int v, int k)
{
  used[v] = true;
  cmp[v] = k;
  for (int i = 0; i < (int)rG[v].size(); i++) {
    if (!used[rG[v][i]]) {
      rdfs(rG[v][i], k);
    }
  }
}

int scc()
{
  memset(used, false, sizeof(used));
  vs.clear();
  for (int v = 0; v < V; v++) {
    if (!used[v]) {
      dfs(v);
    }
  }
  memset(used, false, sizeof(used));
  int k = 0;
  for (int i = vs.size() - 1; i >= 0; i--) {
    if (!used[vs[i]]) {
      rdfs(vs[i], k++);
    }
  }
  return k;
}

int main() {
  int E, s, t;
  cin >> V >> E;
  while(E--) {
    cin >> s >> t;
    add_edge(s, t);
  }
   
  scc();
   
  int q, u, v;
  cin >> q;
  while(q--) {
    cin >> u >> v;
    cout << ( cmp[u] == cmp[v] ) << endl;
  }
   
  return 0;
}

Measured memory_bytes: 4828
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main(void){
	double r;

	cin >> r;

	cout << fixed << setprecision(6) << r*r*M_PI << " " << 2 * r*M_PI << "\n";

	return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,cnt=2;
    int x[1000];
    x[0]=1;
    for(int i=1;i<1000;i++)
    {
        x[i]=cnt+x[i-1];
        cnt++;
    }
    while(scanf("%d%d",&a,&b)==2)
    {
        int res=x[b-a-1]-b;
        printf("%d\n",res);
    }
    return 0;
}


Measured memory_bytes: 256