akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","w",stdout);
    ll n, x, y;
    cin >> n >> x >> y;
    ll ans = (n + x - 1) / x * y;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			char c[]=new char[n];
			for(int i=0;i<n;i++){
				int pm=sc.nextInt();
				int pe=sc.nextInt();
				int pj=sc.nextInt();
				if(pm==100||pe==100||pj==100)c[i]='A';
				else if((pm+pe)/2>=90)c[i]='A';
				else if((pm+pe+pj)/3>=80)c[i]='A';
				else if((pm+pe+pj)/3>=70)c[i]='B';
				else if((pm+pe+pj)/3>=50&&(pm>=80||pe>=80))c[i]='B';
				else c[i]='C';
				System.out.println(c[i]);
			}
		}
	}
}

Measured memory_bytes: 28204
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()

int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}

int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int kaijou(int a){
  int b=1;
  fo(i,a)
    b*=i+1;
  return b;
}

int lcm(int a,int b){
  return a*b/gcd(a,b);
}
signed main(){
  int n;
  cin>>n;
  V<int> a(n);
  fo(i,n){
    cin>>a[i];
  }
  int now=1;
  fo(i,n){
    now=a[now-1];
    if(now==2){
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

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

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

using namespace std;

int main(){
	int n; cin>>n;
	vector<pair<int,int>> a(n);
	rep(i,n) cin>>a[i].first, a[i].second=i;

	sort(a.begin(),a.end());

	vector<int> ans(n);
	rep(i,n) ans[a[i].second]=a[i<n/2?n/2:n/2-1].first;
	rep(i,n) cout<<ans[i]<<endl;

	return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	
    int n;
    
    while( cin >> n ) {
    
    while( n-- ) {
    	
    	int L[3];
    	
    	for(int i=0;i<3;i++)
    	cin >> L[i];
	
		sort(L, L+3);
		
		if( L[0] * L[0] + L[1] * L[1] == L[2] * L[2] )
		cout << "YES\n";
		
		else
		cout << "NO\n";
	}
	}
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {

  while(1){
    std::string str;
    int x;
    std::cin >> str;
    if(str == "-")break;
    std::cin >> x;
    for(int i=0;i<x;i++){
      int shuffle;
      std::cin >> shuffle;
      std::string s = str.substr(shuffle,str.size());
      std::string temp = str.substr(0,shuffle);
      str = s + temp;
    }
    std::cout << str << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3148
def func(x, y)
  mod = 1000000007
  return 1 if  y == 0
  return x % mod if y == 1
  return func(x, y / 2) ** 2 % mod if y % 2 == 0
  return func(x, y / 2) ** 2 * x % mod
end

m, n = gets.split(' ').map(&:to_i)
puts func(m,n)



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

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))


lli solve(int j,int k,int s,int *x,lli ***dp,bool ***bl){
	//printf("j = %3d k = %3d s = %3d x = %3d\n",j,k,s,x[j] );
	if(bl[j][k][s]){
		return dp[j][k][s];
	}
	bl[j][k][s] = 1;
	if(j == 0 && k == 0 && s == 0){
		return dp[j][k][s] = 1;
	}else if(j > 0 && s < x[j]){
		return dp[j][k][s] = solve(j-1,k,s,x,dp,bl);
	}else if(j > 0 && k > 0 && s >= x[j]){
		return dp[j][k][s] = solve(j-1,k,s,x,dp,bl) + solve(j-1,k-1,s-x[j],x,dp,bl);
	}
	return dp[j][k][s] = 0;
}

int main(void){
	int i,j;
	int n,a;
	int *x;
	lli ***dp;
	bool ***bl;
	lli res = 0;

	scanf("%d%d",&n,&a);
	dp = calloc(sizeof(lli**),n+1);
	bl = calloc(sizeof(bool**),n+1);
	x = calloc(sizeof(int),n+1);
	for(i=1;i<=n;i++){
		scanf("%d",&x[i]);
	}
	for(i=0;i<=n;i++){
		dp[i] = calloc(sizeof(lli*),n+1);
		bl[i] = calloc(sizeof(bool*),n+1);
		for(j=0;j<=n;j++){
			dp[i][j] = calloc(sizeof(lli),n*a+1);
			bl[i][j] = calloc(sizeof(bool),n*a+1);
		}
	}
	for(i=1;i<=n;i++){
		res += solve(n,i,i*a,x,dp,bl);
	}
	printf("%lld\n", res);
	return 0;
}
/*
想定解法1
*/

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int f = A + B - C - D;
		if (f>0) cout << "Left";
		else if (f<0) cout << "Right";
		else cout << "Balanced";
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3
# -*- coding: UTF-8 -*-

n,m=map(int,input().split())
g={int(i):[] for i in range(n)}
for i in range(n):
    x,y=map(int,input().split())
    g[i].append((x,y))

for i in range(m):
    x,y=map(int,input().split())
    for j in range(n):
        tmp=abs(g[j][0][0]-x)+abs(g[j][0][1]-y)
        if i==0:
            g[j].append(tmp)
            g[j].append(i)
        elif tmp<g[j][1]:
            g[j][1]=tmp
            g[j][2]=i
for i in range(n):
    print(g[i][2]+1)

Measured memory_bytes: 3064
def calc_digit_sum(n):
    return sum(list(map(int, list(str(n)))))

n = int(input())
ans = 10000000
for i in range(1, int(n/2) + 1):
    ans = min(calc_digit_sum(i) + calc_digit_sum(n-i), ans)
print(ans)

Measured memory_bytes: 3060
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

# S=input()
# print(input().split('/'))
a,b,c=map(int,input().split('/'))

if b>=5:
    print("TBD")
elif c>30:
    print("TBD")
else:
    print("Heisei")


Measured memory_bytes: 14296
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;



int main(){
	int n,m,b;
	static int a[1000],h[1000];
	scanf("%d%d",&n,&m);
	rep(i,n){
		scanf("%d",&a[i]);
	}
	rep(i,m){
		scanf("%d",&b);
		rep(j,n)if(b>=a[j]){
			h[j]++;
			goto ok;
		}
		ok:;
	}
	int ma=-INF,k;
	rep(i,n)if(h[i]>ma){ma=h[i];k=i;}
	printf("%d\n",k+1);
	
	return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <complex>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

void solve(void){
	stack<int> s;
	string ope;
	while (cin >> ope) {
		if (ope == "+") {
			int x = s.top(); s.pop();
			int y = s.top(); s.pop();
			s.push(x+y);
		}
		else if (ope == "-") {
			int x = s.top(); s.pop();
			int y = s.top(); s.pop();
			s.push(y-x);
		}
		else if (ope == "*") {
			int x = s.top(); s.pop();
			int y = s.top(); s.pop();
			s.push(x*y);
		}
		else {
			s.push(stoi(ope));
		}
	}
	cout << s.top() << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3196
import java.io.*;
import java.io.ObjectInputStream.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	//final static long MOD = 998244353;

	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		slove(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void slove(String[] args) throws Exception{

		int N = nextInt();
		int M = nextInt();

		for(int i = M/N;i>0;i--) {
			if(M%i==0) {
				pw.println(i);
				return;
			}
		}

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}



Measured memory_bytes: 23124
#include <iostream>
#include <set>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    
    ll place[N + 1];
    
    for (int i = 1; i <= N; ++i) {
        ll a;
        cin >> a;
        place[a] = i;
    }

    ll ans = 0;
    multiset<ll> used = {0, 0, N + 1, N + 1};
    // すでに見た要素のindexを保持する
    
    for (int i = N; i >= 1; --i) {
        ll r, l, r2, l2;
        
        auto itr = used.lower_bound(place[i]);
        r = *itr;
        // lower_boundで右端を調べる(upper_boundでもいい)
        itr++;
        r2 = *itr;
        itr--;
        itr--;
        l = *itr;
        itr--;
        l2 = *itr;

      	
        /*
        if (itr == used.end()) {
            r2 = r;
        } else {
            r2 = *(++itr);
        }
        if ((--itr) == used.end()) {
            l2 = l;
        } else {
            l2 = *(++itr);
        }*/

        ll a = l - l2, d = r2 - r;
        ll b = place[i] - l, c = r - place[i];
        //cerr << "join " << i << "\n";
        //cerr << l2 << " " << l << " " << place[i] << " " << r << " " << r2 << "\n";
      	//cerr << a << " " << b << " " << c << " " << d << "\n";
        ans += i * (a * c + b * d);
        used.insert(place[i]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7040
n,l = [int(z) for z in input().split()]
a = [0]*n
m = 10000000000
index = 0
for i in range(n):
      a[i] = l+i
      if (abs(a[i])<m):
            index = i
            m = abs(a[i])
print(sum(a)-a[index])


Measured memory_bytes: 9116
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		Tree t = new Tree(n);

		for (int i = 0; i < n; i++)
			if (scan.next().equals("insert"))
				t.insert(i, scan.nextInt());
			else {
				t.printInorder();
				t.printPreorder();
			}

		scan.close();
		System.exit(0);
	}
}

class Tree {

	private class Node {
		public Node(int _key) {
			key = _key;
		}

		int key;
		int Parent = -1;
		int LeftChild = -1;
		int RightChild = -1;
	}

	Node[] node;
	int root = -1;

	public Tree(int n) {
		node = new Node[n];
	}

	public void printPreorder() {
		printPre(root);
		System.out.println();
	}

	private void printPre(int id) {
		if (id == -1)
			return;
		System.out.print(" " + node[id].key);
		printPre(node[id].LeftChild);
		printPre(node[id].RightChild);
	}

	public void printInorder() {
		printIn(root);
		System.out.println();
	}

	private void printIn(int id) {
		if (id == -1)
			return;
		printIn(node[id].LeftChild);
		System.out.print(" " + node[id].key);
		printIn(node[id].RightChild);
	}

	public void insert(int i, int key) {
		node[i] = new Node(key);
		insert(i);
	}

	private void insert(int z) {
		int y = -1;
		int x = root;
		while (x != -1) {
			y = x;
			if (node[z].key < node[x].key)
				x = node[x].LeftChild;
			else
				x = node[x].RightChild;
		}
		node[z].Parent = y;

		if (y == -1)
			root = z;
		else if (node[z].key < node[y].key)
			node[y].LeftChild = z;
		else
			node[y].RightChild = z;
	}
}

Measured memory_bytes: 222868
def solve():
    N = int(input())
    Ass = []
    for _ in range(N):
        As = list(map(lambda x: int(x)-1, input().split()))
        Ass.append(As+[N])

    games = []
    numReadyss = [[0]*(N) for _ in range(N)]
    iAs = [0] * N
    for i in range(N):
        j = Ass[i][iAs[i]]
        if j > i: i, j = j, i
        numReadyss[i][j] += 1
        if numReadyss[i][j] >= 2:
            games.append((i, j))
    ans = 1
    numOK = 0
    while True:
        if not games:
            print(-1)
            return
        game2s = []
        for i, j in games:
            iAs[i] += 1
            i2 = Ass[i][iAs[i]]
            if i2 == N:
                numOK += 1
            else:
                if i2 > i: i, i2 = i2, i
                numReadyss[i][i2] += 1
                if numReadyss[i][i2] >= 2:
                    game2s.append((i, i2))
            iAs[j] += 1
            j2 = Ass[j][iAs[j]]
            if j2 == N:
                numOK += 1
            else:
                if j2 > j: j, j2 = j2, j
                numReadyss[j][j2] += 1
                if numReadyss[j][j2] >= 2:
                    game2s.append((j, j2))
        if numOK >= N:
            print(ans)
            return
        ans += 1
        games = game2s


solve()


Measured memory_bytes: 69092
import bisect
n=int(input())
a,b,c=[sorted(map(int,input().split())) for i in range(3)]

ans=0
for i in b:
      idx1=bisect.bisect_left(a,i)
      idx2=n-bisect.bisect_right(c,i)
      ans+=idx1*idx2
print(ans)


Measured memory_bytes: 22720
/*
 * C言語のサンプルプログラム - Webkaru
 * - 入力した2つの自然数の最小公倍数を求める -
 */
#include <stdio.h>

int main(void){
  long i, j = 1;
  long N, a[200000], ans = 0;
  scanf("%ld", &N);
  for (int i = 0; i < N; i++) {
    scanf("%ld", a + i);
  }
  for (i = 0; i < N; i++) {
    if (a[i] == j) {
      j++;
    }
    else {
      ans++;
    }
  }
  if (ans != N) {
    printf("%ld", ans);
  }
  else {
    printf("%d", -1);
  }
  return 0;
}


Measured memory_bytes: 1664
import sys
C = []
D = []

for _ in range(2):
    l = list(input())
    C.append(l)

count = 0
for i in range(1,-1,-1):
    D.append([])
    for j in range(2,-1,-1):
        D[count].append(C[i][j])

    count = count + 1
for i in range(2):
    for j in range(3):
        if C[i][j]!=D[i][j]:
            print("NO")
            sys.exit()
print("YES")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n1,n2) for(int i=n1;i<n2;i++)
using namespace std;
typedef long long ll;

int div2(int n){
    int rtn=0;
    while(n%2==0){
        rtn++;
        n /= 2;
    }
    return rtn;
}

int main() {
    int n,m;
    ll x[1010],y[1010],z[1010];
    ll a[8][1010];;
    //,b[1010],c[1010],d[1010],e[1010],f[1010],g[1010],h[1010];
    cin >> n >> m;
    ll res[8];
    int dx[8] = { 1, 1, 1, 1,-1,-1,-1,-1};
    int dy[8] = { 1, 1,-1,-1, 1, 1,-1,-1};
    int dz[8] = { 1,-1, 1,-1, 1,-1, 1,-1};
    REP(i,n){
        cin >> x[i];
        cin >> y[i];
        cin >> z[i];
        REP(j,8){
            a[j][i] = dx[j]*x[i]+dy[j]*y[i]+dz[j]*z[i];
        }
    }
    REP(j,8){
        sort(a[j],a[j]+n,greater<ll>());
        REP(i,m){
            res[j] += a[j][i];
        }
    }
    sort(res,res+8,greater<ll>());
    
    cout << res[0] << endl;
    /*vector<pair<int,int>> pair1(n);
     vector<pair<int,int>> pair2(n);
     REP(i,n){
     int a,b;
     cin >> a >> b;
     pair1[i] = make_pair(a,b);
     }
     REP(i,n){
     int c,d;
     cin >> c >> d;
     pair2[i] = make_pair(c,d);
     }
     
     sort(pair1.begin(),pair1.end());
     sort(pair2.begin(),pair2.end());
     REP(i, n){
     cout << pair1[i].first << pair1[i].second <<endl;
     }
     int maxn = -1;
     int cand = -1;
     REP(i,n){
     REP(j,n){
     if(pair1[i].first<pair2[j].first){
     if(pair1[i].second>maxn){
     cand = i;
     }
     }
     }
     }
     /*REP(i, n){
     cout << pairs[i].first << pairs[i].second <<endl;
     }
     /*int n;
     int res = 100000;
     cin >> n;
     //vector<int> x(n);
     REP2(i,1,n/2+1){
     res = min(res,psum(i)+psum(n-i));
     if(psum(i)+psum(n-i)==1){
     cout << "i:" << i <<endl;
     }
     }
     cout << res << endl;*/
    return 0;
}



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

int main(){
    char a[100],b[100],c[100];
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    int sa=strlen(a);
    int sb=strlen(b);
    int sc=strlen(c);

    char s[3][100];
    for(int t=0;t<100;t++){
        s[0][t]=a[t];
        s[1][t]=b[t];
        s[2][t]=c[t];   
    }

    int x=0;
    int y=0;

    int i=0;
    int j=0;
    int k=0;
    for(;;){
        if(s[x][y]=='a'){
            if(x==0){
                i++;
            }else if(x==1){
                j++;
            }else if(x==2){
                k++;
            }
            x=0;
            y=i;
        }else if(s[x][y]=='b'){
            if(x==0){
                i++;
            }else if(x==1){
                j++;
            }else if(x==2){
                k++;
            }
            x=1;
            y=j;
        }else if(s[x][y]=='c'){
            if(x==0){
                i++;
            }else if(x==1){
                j++;
            }else if(x==2){
                k++;
            }
            x=2;
            y=k;
        }else{
            if(x==0){
                i++;
            }else if(x==1){
                j++;
            }else if(x==2){
                k++;
            }
            break;
        }
    }

    if(i>sa){
        printf("A\n");
    }else if(j>sb){
        printf("B\n");
    }else if(k>sc){
        printf("C\n");
    }
    return 0;
}

Measured memory_bytes: 1644
getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y
    where
      toInt x = read x ::Int
getMat x
  |x==1 = do
    y <- getInts
    return [y]
  |otherwise = do
    y <- getInts
    z <- getMat (x-1)
    let w = [y] ++ z
    return w

-- [Char]あるいは String を Int にする
toInt :: (String -> Int)
toInt x = read x ::Int

score::[Int]->[Int]->Int
score x abcd
  |(x!!(abcd!!1 -1)) -(x!!(abcd!!0 -1)) == (abcd!!2) = (abcd!!3)
  |otherwise =0

scores x abcdq = sum [score x abcd | abcd <- abcdq]

--使用例
main = do
  nmq <- getInts
  abcdq <- getMat (nmq!!2)
  let x = [[z1,z2,z3,z4,z5,z6,z7,z8,z9,z0] | z1 <-[1..(nmq!!1)],z2 <-[z1..(nmq!!1)],z3 <-[z2..(nmq!!1)],z4 <-[z3..(nmq!!1)],z5 <-[z4..(nmq!!1)],z6 <-[z5..(nmq!!1)],z7 <-[z6..(nmq!!1)],z8 <-[z7..(nmq!!1)],z9 <-[z8..(nmq!!1)],z0 <-[z9..(nmq!!1)]]
  let y = maximum[scores z abcdq | z <- x]
  print y

















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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 100005;
int a[N<<2],b[N<<2],f[N<<2],n;
int find(int x){return x==f[x]?x:f[x]=find(f[x]);}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<=2*N;i++)f[i]=i;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		f[find(x)]=find(y+N);
	}		
	for(int i=1;i<=N;i++)a[find(i)]++;
	for(int i=N+1;i<=2*N;i++)b[find(i)]++;
	LL ans=0;
	for(int i=1;i<=2*N;i++)ans+=1ll*a[i]*b[i];
	cout<<ans-n<<endl;
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A[3][3];
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            cin>>A[i][j];
        }
    }
    
    vector<vector<bool>> ok(3,vector<bool>(3,false));
    
    int N;
    cin>>N;
    for(int k=0;k<N;++k){
        int b;
        cin>>b;
        
        for(int i=0;i<3;++i){
            for(int j=0;j<3;++j){
                if(A[i][j]==b){
                    ok[i][j]=true;
                }
            }
        }
    }
    
    bool ans=false;
    for(int i=0;i<3;++i){
        ans=ans
            ||(ok[i][0]&&ok[i][1]&&ok[i][2])
            ||(ok[0][i]&&ok[1][i]&&ok[2][i]);
    }
    
    ans=ans
        ||(ok[0][0]&&ok[1][1]&&ok[2][2])
        ||(ok[0][2]&&ok[1][1]&&ok[2][0]);
    
    cout<<(ans?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long test(in int[] a, const int n) {
  const int m = n / 2;
  long[] prev;
  int e;
  const long minf = long.min / 2;
  foreach (l; 1 .. m + 1) {
    const int minlen = 2 * (m + 1 - l) - 1;
    const int last = n - minlen;
    if (l == 1) {
      prev = a[0 .. last + 1].map!(to!long).array;
    } else {
      const int pl = prev.length.to!int;
      auto next = new long[pl + last - e];
      next[] = minf;
      foreach (j; 0 .. pl) {
        const int delta = e - (pl - 1); 
        //int o = j + delta;
        foreach (k; j + 2 .. next.length) {
          long w = prev[j] + a[k + delta];
          if (next[k] < w) next[k] = w;
        }
      }
      while (next.front == minf) next.popFront();
      prev = next;
    }
    e = last;
    debug stderr.writeln ("prev = ", prev, ", e = ", e);
  }
  return maxElement(prev);
}

/*
long odd(int[] a) {
  //auto x = new long[a.length];
  auto s = new long[a.length + 2];
  foreach_reverse (i; 0 .. a.length) {
    s[i] = s[i + 2] + a[i];
  }
  long 
  const int
  foreach (j; 0 .. a.length) {
  }
}

long even(int[] a) {
  long res = long.max;
  foreach (i; 0 .. 2) {
    long s;
    for (int j = i; j < a.length; j += 2) s += a[j];
    res = max (res, s);
  }
  return res;
}
*/

void main() {
  int n;
  readf (" %d", &n);
  auto a = new int[n];
  foreach (t; 0 .. n) {
    readf (" %d", &a[t]);
  }
  writeln(test(a,n));
}



Measured memory_bytes: 7964
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

typedef long long ll;

const int sz = (1 << 18) + 1;
const int sz2 = (1 << 9) + 1;

int n, q;
int dp[sz2][sz];
int vw[sz][2];

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> vw[i][1] >> vw[i][0];
	}

	for (int i = 1; i < sz2; i++)
		for (int j = 0; j < sz; j++)
			dp[i][j] = -1;

	dp[1][0] = 0;
	dp[1][vw[1][0]] = vw[1][1];

	for (int i = 2; i < sz2; i++) {
		for (int j = sz - 1; j >= 0; j--) {
			if (dp[i / 2][j] == -1)
				continue;
			dp[i][j] = max(dp[i][j], dp[i / 2][j]);
			if (j + vw[i][0] < sz)
				dp[i][j + vw[i][0]] = max(dp[i][j + vw[i][0]], dp[i / 2][j] + vw[i][1]);
		}
	}

	for (int i = 1; i < sz2; i++) {
		for (int j = 1; j < sz; j++)
			dp[i][j] = max(dp[i][j - 1], dp[i][j]);
	}

	cin >> q;
	for (int i = 0; i < q; i++) {
		int v, l;
		cin >> v >> l;
		if (v < sz2) {
			cout << dp[v][l];
		}
		else {
			vector<int> anc;
			int u = v;
			while (u != 0) {
				anc.push_back(u);
				u >>= 1;
			}
			int ind = anc.size();
			for (int j = 0; j < (int)anc.size(); j++)
				if (anc[j] < sz2) {
					ind = j;
					break;
				}
			int otv = 0;
			for (int j = 0; j < (1 << ind); j++) {
				int w = 0, val = 0;
				for (int k = 0; k < ind; k++)
					if (((j >> k) & 1) == 1) {
						w += vw[anc[k]][0];
						val += vw[anc[k]][1];
					}
				if (w > l)
					continue;
				otv = max(otv, val + dp[anc[ind]][l - w]);
			}

			cout << otv;
		}
		cout << '\n';
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 530008
import bisect
n=int(input())
X=[]
for i in range(n):
    a,b=map(int,input().split())
    X.append([a,b,0])
for i in range(n):
    c,d=map(int,input().split())
    X.append([c,d,1])

X.sort(key=lambda x:x[0])

R=[]
ans=0
for i in range(2*n):
    if X[i][2]==0:
        R.append(X[i][1])
        R.sort()
    if X[i][2]==1:
        if len(R)==0:
            continue
        if min(R)>X[i][1]:
            continue
        R.pop(bisect.bisect_left(R,X[i][1])-1)
        ans+=1
print(ans)

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

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size()-1;i++){
    if(s.substr(i,2)=="AC"){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

int n;
int x[200001],y[200001];
vector<int> pt;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int res=-INF;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        pt.push_back(x[i]+y[i]);
    }
    sort(pt.begin(),pt.end());
    res=max(res,pt[ pt.size()-1 ]-pt[0]);

    pt.clear();

    for(int i=0;i<n;i++){
        pt.push_back(x[i]-y[i]);
    }
    sort(pt.begin(),pt.end());
    res=max(res,pt[ pt.size()-1 ]-pt[0]);

    cout<<res<<endl;


    return 0;
}


Measured memory_bytes: 8128
void main() {
	bool[string] dict;
	foreach(i; 0..ri) {
		auto ip = readln.split, command = ip[0], str = ip[1];
		switch(command) {
			case "insert":
				dict[str] = true;
				break;
			case "find":
				if(str in dict && dict[str]) "yes".writeln;
				else "no".writeln;
				break;
			default:
				break;
		}
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 87572
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define llong long long
using namespace std;

llong solve(llong n,llong m)
{
	if(m==0 || n==0) {return 0ll;}
	if(n%m==0) return (2ll*(n/m)-1)*m;
	return solve(m,n%m)+(n/m)*m*2ll;
}

int main()
{
	llong n,x;
	scanf("%lld%lld",&n,&x);
	if(x==0) {puts("0"); return 0;}
	llong ans = solve(max(x,n-x),min(x,n-x))+n;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int a = ab[0];
			int b = ab[1];
			if (b == 1) {
				Console.WriteLine(0);
				return;
			}

			if (b <= a) {
				Console.WriteLine(1);
			} else {
				int c = b - a;
				int ans = (c + a - 2) / (a - 1) + 1;
				Console.WriteLine(ans);
			}
		}
	}
}

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

#define pii pair<int, int>
#define endl "\n"
// #define int long long
#define F first
#define S second
#define B begin
#define E end
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const ll Q = 31;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}

const int DSUM = 80 * 80;
 
signed main()
{
    hello();

    int n, m;
    cin >> n >> m;
    int a[n][m];
    int b[n][m];
    bitset <2 * 80 * 80 + 1> dp[n][m]; 

    int sum = 0;

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

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
        {
            cin >> b[i][j];
            sum += b[i][j];
        }


    dp[0][0][a[0][0] - b[0][0] + DSUM] = 1;
    dp[0][0][b[0][0] - a[0][0] + DSUM] = 1;

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (!i && !j)
                continue;
            bitset <2 * 80 * 80 + 1> pos;
            if (i)
                pos |= dp[i - 1][j];
            if (j)
                pos |= dp[i][j - 1];

            dp[i][j] = (pos << abs(a[i][j] - b[i][j])) | (pos >> abs(a[i][j] - b[i][j]));
        }
    }
    int res = sum;
    for (int i = 0; i < 2 * 80 * 80 + 1; ++i)
    {
        if (dp[n - 1][m - 1][i])
        {
            // cout << i - DSUM << endl;
            res = min(res, abs(i - DSUM));
            // cout << res << endl << endl;
        }
    }

    cout << res << endl;
    
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n;
    int a,b,c;
    int memo = 0,sum = 0;
    cin >> n >> a >> b >> c;
    int d[n] = {0};
    
    rep(i,0,n){
        cin >> d[i];
    }
    sort(d,d+n,greater<int>());
    
    sum = c;
    memo = c/a;
    
    rep(i,0,n){
        if(memo > (sum+d[i])/(a+(i+1)*b)){
            cout << memo << endl;
            return 0;
        }
        else{
            memo = (sum+d[i])/(a+(i+1)*b);
            sum += d[i];
        }
    }
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
  int a, b;
  char c;
  while (cin >> a >> c >> b) {
    if (c == '+') cout << a + b << endl;
    else if (c == '-') cout << a - b << endl;
    else if (c == '*') cout << a * b << endl;
    else if (c == '/') cout << a / b << endl;
    else if (c == '?') break;
  }
}

Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int s[100010];
int main(){
    int n,m,i,x,y;
    scanf("%d %d",&n,&m);
    for(i=1;i<=m;i++){
        scanf("%d %d",&x,&y);
        s[x]++;s[y]++;
    }
    for(i=1;i<=n;i++)
        if(s[i]&1) break;
    if(i<=n) printf("NO\n");
    else printf("YES\n");
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, mx = 0; cin >> n;
	vi v(n), d;
	rep(i, n){
		cin >> v[i];
		mx = max(mx, v[i]);
	}
	for(int i = 1; i <= mx; i++) if(mx % i == 0) d.pb(i);
	
	ll ans = 0;
	rep(i, n) ans += *lower_bound(all(d), v[i]) - v[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3340
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a=0;
        int[]po=new int[n];
        for(int i=0;i<n;i++){
            po[i]=sc.nextInt();
        }
        boolean t=false;
        PO:for(int i=0;i<n-1;i++){
            for(int j=i;j<n;j++){
               int b[]= swap(po.clone(),i,j);
               t=true;
               for(int k=1;k<n;k++){
                   if(b[k-1]>b[k]){
                       t=false;
                       //break;
                   }
               }
               if(t)break PO;
            } 
            
        }
        System.out.println(t?"YES":"NO");
    }
    public static int[] swap(int[]a,int x,int y){
        x=Math.abs(x);
        y=Math.abs(y);
        if(a.length>x&&a.length>y){
            int po=a[x];
            a[x]=a[y];
            a[y]=po;
        }
        return a;
    }
}


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

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXS 200005

LL pwr(LL a,LL b){
	
	if(b==1)
		return a%MOD;	
	if(b%2==0){
		LL c=pwr(a,b/2);
		return (c*c)%MOD;
	}
	return (pwr(a,b-1)*a)%MOD;
} 

LL inv_p(LL a){
	return pwr(a,MOD-2);
}

LL m_MOD(LL a,LL b){
	return (a*b)%MOD;
}

LL fact[MAXS];
LL inv_fact[MAXS];

LL bin(LL a,LL b){
	if(a<0||b<0||a-b<0)
		return 0;
	return m_MOD(m_MOD(fact[a],inv_fact[a-b]),inv_fact[b]);
}

LL fx(LL a,LL b){
	return bin(a+b,a);
}


LL h,w,n;
LL dp[MAXS];

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin>>h>>w>>n;
	fact[0]=1;
	inv_fact[0]=1;
	
	FOR(i,1,h+w){
		fact[i]=(fact[i-1]*i)%MOD;
		inv_fact[i]=inv_p(fact[i]);
	}
	
	vector<PI> zb(n);
	REP(i,n)
		cin>>zb[i].ST>>zb[i].ND;
		
	sort(ALL(zb));
	
	LL wyn=fx(h-1,w-1);
	
	REP(i,n){
		dp[i]=fx(zb[i].ST-1,zb[i].ND-1);
		REP(j,i){
			if(zb[j].ST<=zb[i].ST&&zb[j].ND<=zb[j].ND){
				dp[i]-=m_MOD(dp[j],fx(zb[i].ST-zb[j].ST,zb[i].ND-zb[j].ND));
				dp[i]+=MOD;
				dp[i]%=MOD;
			}
		}
		
		wyn-=m_MOD(dp[i],fx(h-zb[i].ST,w-zb[i].ND));
		wyn+=MOD;
		wyn%=MOD;
	}
	
	cout<<wyn;
	
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main (){
  int a,b,c,x,y,z;
  cin >> a >> b >> c;
  x = a;
  z = 0;
  while (x <= b){
    y = c/x;
    if ( y * x == c ){z = z + 1;}
    x = x + 1;
  }
  cout << z << endl;
  return 0;
}


Measured memory_bytes: 3092
x=int(input())
if x >=400 and 599>=x:
  print("8")
if x >=600 and 799>=x:
  print("7")
if x >=800 and 999>=x:
  print("6")
if x >=1000 and 1199>=x:
  print("5")
if x >=1200 and 1399>=x:
  print("4")
if x >=1400 and 1599>=x:
  print("3")
if x >=1600 and 1799>=x:
  print("2")
if x >=1800:
  print("1")

Measured memory_bytes: 61636
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

#define MAX_N 3005
int n;
int px[MAX_N],py[MAX_N];
char ch[MAX_N];

int solve(int si){
  bool used[MAX_N]={};
  set< P > sx[MAX_N],sy[MAX_N];
  for(int i=0;i<n;i++){
    if(i==si)continue;
    sx[ px[i] ].insert( P(py[i],i) );
    sy[ py[i] ].insert( P(px[i],i) );
  }
  int res=1;
  int x=px[si],y=py[si];
  char dir=ch[si];

  set< P > :: iterator it;
  while(1){
    P next;
    if(dir=='v'){
      it= sx[x].lower_bound( P(y,0) );
      if(it==sx[x].end())break;
      next=*it;
    }else if(dir=='^'){
      it= sx[x].lower_bound( P(y,0) );
      if(it==sx[x].begin())break;
      it--;
      next=*it;
    }else if(dir=='>'){
      it= sy[y].lower_bound( P(x,0) );
      if(it==sy[y].end())break;
      next=*it;      
    }else if(dir=='<'){
      it= sy[y].lower_bound( P(x,0) );
      if(it==sy[y].begin())break;
      it--;
      next=*it;
    }
    res++;
    int id=next.second;
    x=px[id];
    y=py[id];
    dir=ch[id];
    sx[ x ].erase(P(y,id));
    sy[ y ].erase(P(x,id));
  }
  return res;
}

int main(){
  vector<int> X,Y;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>px[i]>>py[i]>>ch[i];
    X.push_back(px[i]);
    Y.push_back(py[i]);
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  X.erase(unique(X.begin(),X.end()),X.end());
  Y.erase(unique(Y.begin(),Y.end()),Y.end());

  for(int i=0;i<n;i++){
    px[i]=lower_bound(X.begin(),X.end(),px[i])-X.begin();
    py[i]=lower_bound(Y.begin(),Y.end(),py[i])-Y.begin();
  }



  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans,solve(i));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1832
const solve = (n, k) => {
  let num = Math.floor(n / k)
  let n2 = num * (num - 1) * 3
  let n3 = num * (num - 1) * (num - 2)
  let cnt = num + n2 + n3

  if (k % 2 == 0) {
    let m = k / 2
    let num2 = Math.floor(n / m) - num
    let n22 = num2 * (num2 - 1) * 3
    let n23 = num2 * (num2 - 1) * (num2 - 2)
    cnt += num2 + n22 + n23
  }

  return cnt
}

const main = (input) => {
  const [n, k] = input.split(" ").map(Number)
  return solve(n, k)
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}
template<typename T>
void debug(vector<T> V){
    for(auto x:V){
        cout<<x<<" ";
    }
    cout<<endl;
}
void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout<<fixed<<setprecision(8);
    go();
    return 0;
}
/*************************************/

void go(){
    int n,l;
    R(n,l);
    ll sum=0;
    rep(i,1,n){
        sum+=i+l-1;
    }
    ll ans;
    ll cha=1e9;
    rep(i,1,n){
        ll now=sum-(i+l-1);
        if(abs(now-sum)<cha){
            cha=abs(now-sum);
            ans=now;
        }
    }
    W(ans);
}


Measured memory_bytes: 256
using System;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var minIndex = 0;
            var maxIndex = 0;

            for(int i = 0; i < s.Length; i++)
            {
                if(s[i] == 'A')
                {
                    minIndex = i;
                    break;
                }
            }
            for(int i = s.Length - 1; i >= 0; i--)
            {
                if(s[i] == 'Z')
                {
                    maxIndex = i;
                    break;
                }
            }
            Console.WriteLine(maxIndex - minIndex + 1);
        }
    }
}


Measured memory_bytes: 26652
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	getint(N);

	std::vector<std::pair<LLONG, LLONG>> plates(N);
	for (int i = 0; i < N; i++) {
		getint(plates[i].first, plates[i].second);
	}

	std::sort(plates.begin(), plates.end(),
		[](const std::pair<LLONG, LLONG>& a, const std::pair<LLONG, LLONG>& b) {
		return (a.first + a.second) > (b.first + b.second);
	});

	bool tkhs = true;
	std::vector<std::pair<LLONG, LLONG>> tk, ao;
	for (int i = 0; i < N; i++) {
		if (tkhs) {
			tk.push_back(plates[i]);
			tkhs = false;
		}
		else {
			ao.push_back(plates[i]);
			tkhs = true;
		}
	}
	
	LLONG tkSum = 0;
	for (auto it = tk.begin(); it != tk.end(); it++) {
		tkSum += it->first;
	}
	LLONG aoSum = 0;
	for (auto it = ao.begin(); it != ao.end(); it++) {
		aoSum += it->second;
	}

	printf("%lld\n", tkSum - aoSum);
}


Measured memory_bytes: 6580
import sys
sys.setrecursionlimit(10**5)

class Node:
    # def __init__(self, val):
    def __init__(self):
        self.val = None
        self.color = None
        self.a = []

n = int(input())
nodes = []

for i in range(n):
    nodes.append(Node())
    # nodes.append(Node(i+1))

for i in range(n-1):
    u, v, w = map(int, input().split())
    node1 = nodes[u-1]
    node2 = nodes[v-1]
    node1.val = u
    node2.val = v
    node1.a.append([node2, w])
    node2.a.append([node1, w])

# for i in range(n):
#     node = nodes[i]
#     for pair in node.a:
#         print(pair[0])
#         print(pair[1])

root = nodes[0]
root.color = True
nodeSet = set()

def traverse(node, distance):
    if node in nodeSet:
        return
    else:
        nodeSet.add(node)
    # print('# traverse: ' + str(node.val))
    for pair in node.a:
        adjNode = pair[0]
        dis = pair[1]
        if (distance + dis) % 2 == 0:
            adjNode.color = root.color
        else:
            adjNode.color = not root.color
        traverse(adjNode, distance + dis)

traverse(root, 0)

for i in range(n):
    node = nodes[i]
    if node.color:
        print(1)
    else:
        print(0)


Measured memory_bytes: 162208
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector <string> vs;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef vector< vpii > vvpii;
typedef vector< vpll > vvpll;
#define all(v)     (v).begin(), (v).end()
#define srt(v)    sort (all (v))
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
 
int main(){
	int n;ll d;
	cin>>n>>d;
	int c=0;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)c++;
	}
	cout<<c<<endl;
	return 0;
}

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

signed main() {
    int n, a[50], b[50], c[50], ans;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> a[i];
        a[i]--;
    }
    for ( int i = 0; i < n; i++ ) {
        cin >> b[i];
    }
    for ( int i = 0; i < n-1; i++ ) {
        cin >> c[i];
    }
    
    ans = 0;
    for ( int i = 0; i < n; i++ ) {
        ans += b[ a[i] ];
        
        if ( i < n-1 && a[i] == a[i+1]-1 ) {
            ans += c[ a[i]];
        }
    }
    
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3588