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

using namespace std;

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

const double EPS=1e-10;

typedef pair<double,int> P;

#define EQ(a,b) fabs(a-b)<EPS

struct Vector{
	double x,y;
	Vector(double x=0.0,double y=0.0):x(x),y(y){}

	Vector operator + (const Vector &a)const{
		return Vector(x+a.x,y+a.y);
	}
	Vector operator - (const Vector &a)const{
		return Vector(x-a.x,y-a.y);
	}
	Vector operator * (double k)const{
		return Vector(x*k,y*k);
	}
	Vector operator / (double k)const{
		return Vector(x/k,y/k);
	}
	bool operator == (const Vector &a)const{
		return EQ(x,a.x) && EQ(y,a.y);
	}
	double norm(){
		return x*x+y*y;
	}
	double abs(){
		return sqrt(norm());
	}
	bool operator < (const Vector &a)const{
		return x!=a.x ? x<a.x : y<a.y;
	}
};

double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

typedef Vector Point;

struct Segment{
	Point p1,p2;
};

const int MAX_N=100;

Segment x;
int n;
Segment s[MAX_N];
int o[MAX_N],l[MAX_N];

struct Rail{
	Point p;
	int l;
	Rail(Point p=Point(),int l=0):p(p),l(l){};
};

vector<Rail> r;
vector<P> d;

const int COUNTER_CLOCKWISE=1,CLOCKWISE=-1,ONLINE_BACK=2,ONLINE_FRONT=-2,ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
	Vector a=p1-p0,b=p2-p0;
	if (cross(a,b)>EPS){
		return COUNTER_CLOCKWISE;
	}
	if (cross(a,b)<-EPS){
		return CLOCKWISE;
	}
	if (dot(a,b)<-EPS){
		return ONLINE_BACK;
	}
	if (a.norm()<b.norm()){
		return ONLINE_FRONT;
	}
	return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
	return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
	return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

Point getCrossPoint(Segment s1,Segment s2){
	Vector base=s2.p2-s2.p1;
	double d1=abs(cross(base,s1.p1-s2.p1));
	double d2=abs(cross(base,s1.p2-s2.p1));
	double t=d1/(d1+d2);
	return s1.p1+(s1.p2-s1.p1)*t;
}

int main(){
	int T;
	scanf("%d",&T);
	REP(t,T){
		int xa,ya,xb,yb;
		scanf("%d %d %d %d",&xa,&ya,&xb,&yb);
		x.p1=Point(xa,ya);
		x.p2=Point(xb,yb);
		scanf("%d",&n);
		REP(i,n){
			scanf("%d %d %d %d %d %d",&xa,&ya,&xb,&yb,&o[i],&l[i]);
			s[i].p1=Point(xa,ya);
			s[i].p2=Point(xb,yb);
		}
		r.clear();
		REP(i,n){
			if (intersect(x,s[i])){
				r.push_back(Rail(getCrossPoint(x,s[i]), o[i] ? l[i] : 1-l[i]));
			}
		}
		int ans=0;
		d.clear();
		REP(i,r.size()){
			d.push_back(P((x.p1-r[i].p).norm(),r[i].l));
		}
		sort(d.begin(),d.end());
		if (d.empty()){
			printf("0\n");
			continue;
		}
		int m=d[0].second;
		REP(i,d.size()){
			if (m!=d[i].second){
				m=d[i].second;
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}
		

Measured memory_bytes: 3120
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    t = [0]*60

    for a in a_list:
        for count, i in enumerate(reversed(format(a, "b"))):
            if i == "1":
                t[count] += 1

    sum = 0
    for i, count in enumerate(t):
        sum += 2 ** i * count * (N - count)
    print(sum % mod)


if __name__ == '__main__':
    main()

Measured memory_bytes: 42212
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
ll take_p5(ll n){
	return (n*n*n*n*n);
}
int main() 
{
	ll n , k;
	cin>>n>>k;
	ll arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	vector<int>path;
	map<int, int>mp;
	ll tot=0;
	ll tk=1;
	bool f=false;
	while(arr[tk]!=tk&&k){
		
		if(mp[tk]==1){
			f=true;
			break;
		}
		k--;
		mp[tk]=1;
		tk=arr[tk];
		
	}
	if(!f)
		cout<<tk;
	else{
	//	cout<<tot<<"\n";
		map<int, int>c;
		while(c[tk]!=1){
			path.push_back(tk);
			c[tk]=1;
			tk=arr[tk];
		}	
	//	cout<<path.size();
		ll fn=k%(int(path.size()));
		cout<<path[fn];
	}


}

Measured memory_bytes: 41132
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

	int l, r;
	cin >> l >> r;
	long long ans = 2019;
	for (int i = l; i <= r; i++) {
		for (int j = i + 1; j <= r; j++) {
			ans = min(ans, (long long)i * j % 2019);
			if (ans == 0)break;
		}
		if (ans == 0)break;
	}

	cout << ans << endl;

}

Measured memory_bytes: 892
#include <stdio.h>

int main(void){
	while(1){
		int n,i,j,a,b;
		int masu[20][20]={0};
		int ura[20][20]={0};
		int bad[2];
		
		scanf("%d %d", &a, &b);
		if(a==0)break;
		scanf("%d",&n);
		
		
		for(i=0;i<n;i++){
			scanf("%d %d", &bad[0], &bad[1]);
			ura[bad[0]][bad[1]]=1;
		}
		masu[0][1]=1;
		for(i=1;i<=a;i++){
			for(j=1;j<=b;j++){
				masu[i][j]=masu[i-1][j]+masu[i][j-1];
				if(ura[i][j]==1)masu[i][j]=0;
			}
		}
		printf("%d\n",masu[a][b]);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cmath>
bool fang(int n){
    int cache=sqrt(n);
    if(cache*cache==n){
        return true;
    }
    return false;
}
int wei(int n){
    int i=0;
    while(n){
        n/=10;
        i++;
    }
    return i;
}
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    int len=wei(b);
    int c=0;
    for(int i=1;i<=len;i++){
        a*=10;
    }
    c+=a+b;
    if(fang(c)){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC140E
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            List<int> P = new List<int>();
            P.AddRange(ReadInt());

            int[] numToIndex = new int[P.Count + 1];
            for (int i = 0; i < P.Count; i++)
            {
                numToIndex[P[i]] = i + 1;
            }

            // 見終わったものの座標のリスト　昇順 <index, value>
            SortedList<int, int> finished = new SortedList<int, int>();
            finished.Add(-1, -1);
            finished.Add(0, 0);
            finished.Add(N + 1, N + 1);
            finished.Add(N + 2, N + 2);

            //大きいものから入れていく 今探しているナンバーはi
            long ans = 0;
            for (int i = N; i > 0; i--)
            {
                int ind = numToIndex[i];

                int R1ind = LowerBound(finished.Keys, ind);
                int R1 = finished.Keys[R1ind];
                int R2 = finished.Keys[R1ind + 1]; if (R2 == N + 2) R2 = N + 1;
                int L1 = finished.Keys[R1ind - 1];
                int L2 = finished.Keys[R1ind - 2]; if (L2 == -1) L2 = 0;

                long c1 = (long)i * (R1 - ind) * (L1 - L2);
                long c2 = (long)i * (ind - L1) * (R2 - R1);
                ans += c1 + c2;

                finished.Add(ind, i);
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }

        /// <summary>
        /// 二分探索 key以上の最低
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="a"></param>
        /// <param name="v"></param>
        /// <returns></returns>
        public static int LowerBound<T>(IList<T> a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(IList<T> a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Count - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
    }

}


Measured memory_bytes: 23520
from itertools import accumulate
from collections import Counter

p = int(input().split()[1])
a = list(map(int, input()))
if 10 % p == 0:
  r = sum(i for i, x in enumerate(a, 1) if x % p == 0)
else:
  a = accumulate(x * pow(10, i, p) for i, x in enumerate(reversed(a), 1))
  c = Counter(x % p for x in a) 
  c[0] += 1
  r = sum(i * (i - 1) // 2 for i in c.values())
print(r)


Measured memory_bytes: 5916
from sys import stdin, setrecursionlimit
from math import radians, cos


def main():
    input = stdin.buffer.readline
    a, b, h, m = map(int, input().split())

    d_h = 360 * (h + m / 60) / 12
    d_m = 360 * m / 60

    d = abs(radians(d_h - d_m))

    print((a ** 2 + b ** 2 - 2 * a * b * cos(d)) ** 0.5)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int n,tmp;
    int s[1000];
    double avg,total,ans;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        total=0;
        ans=0;
        for(int j=0;j<n;j++){
            scanf("%d",&s[j]);
            total+=s[j];
        }
        avg=total/n;
        for(int k=0;k<n;k++){
            ans+=(s[k]-avg)*(s[k]-avg);
        }
        ans=sqrt(ans/n);
        printf("%.12lf\n",ans);
    }

    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int n,t;
	int ans = INF;
	cin>>n>>t;
	rep(i,n){
		int x,y; cin>>x>>y;
		if(y<=t) ans = min(ans,x);
	}
	if(ans > 1e8) puts("TLE");
	else cout<<ans<<endl;
}

Measured memory_bytes: 384
M = 1046527
POW = [pow(4, i) for i in range(13)]


def insert(dic, string):
    # i = 0
    # while dic[(hash1(string) + i*hash2(string)) % M]:
    #     i += 1
    # dic[(hash1(string) + i*hash2(string)) % M] = string
    dic[get_key(string)] = string


def find(dic, string):
    # i = 0
    # while dic[(hash1(string) + i*hash2(string)) % M] and dic[(hash1(string) + i*hash2(string)) % M] != string:
    #     i += 1
    # return True if dic[(hash1(string) + i*hash2(string)) % M] == string else False
    # print(dic[get_key(string)], string)
    return True if dic[get_key(string)] == string else False


def get_num(char):
    if char == "A":
        return 1
    elif char == "C":
        return 2
    elif char == "G":
        return 3
    else:
        return 4


def get_key(string):
    num = 0
    for i in range(len(string)):
        num += POW[i] * get_num(string[i])
    return num


def main():
    n = int(input())
    dic = [None] * POW[12]
    # print(dic)
    for i in range(n):
        order, string = input().split()
        if order == "insert":
            insert(dic, string)
        else:
            if find(dic, string):
                print('yes')
            else:
                print('no')


if __name__ == "__main__":
    main()



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll cnt=0;
    ll n,d;cin >>n>>d;
    vector<ll>x(n);
    vector<ll>y(n);
    for (int i = 0; i < n; ++i) {
        cin >>x[i]>>y[i];
        if(x[i]*x[i]+y[i]*y[i]<=d*d)cnt++;
    }
    cout <<cnt<<endl;
}


Measured memory_bytes: 6356
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;


int main() {
    int s;
    cin >> s;
    bool f1 = s / 100 > 0 && s / 100 <= 12;
    bool f2 = s % 100 > 0 && s % 100 <= 12;
    if(f1 && f2)cout << "AMBIGUOUS" << endl;
    else if(f1)cout << "MMYY" << endl;
    else if(f2)cout << "YYMM" << endl;
    else cout << "NA" << endl;

}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    vector<pair<long long, long long>> task(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
        task[i] = make_pair(B[i], -A[i]);
    }
    sort(task.begin(), task.end());
    long long time = 0;
    REP(i, N) {
        time += -task[i].second;
        if(time > task[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int N;
  cin >> N;
  ostringstream stream;
  stream << N;
  string strN= stream.str();
  char a[10]={'0','1','2','3','4','5','6','7','8','9'};
  int Nsum=0;
  for(int i=0; i< strN.size(); i++){
  	for(int j=0; j<10; j++){
    	if(strN[i]==a[j]) Nsum+=j;
    }
  }
  
  if(N%Nsum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
"use strict"

const main = (input) => {
  const _input = input.split(" ");
  const A = parseInt(_input[0], 10);
  const B = parseInt(_input[1], 10);

  const sum = A + B;
  const div = Math.floor(sum / 2);
  const mod = sum % 2;

  if(mod != 0){
    console.log("IMPOSSIBLE");
    return;
  }

  console.log(div);
}

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

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        int dn[] = new int[n];
        for (int i = 0; i < n; i++) {
            dn[i] = Integer.parseInt(scanner.nextLine());
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (dn[i] > dn[j]) {
                    int tmp = dn[i];
                    dn[i] = dn[j];
                    dn[j] = tmp;
                }
            }
        }
        int x = 1;
        for (int i = 0; i < n - 1; i++) {
            if (dn[i] < dn[i + 1]) {
                x++;
            }
        }

        System.out.println(x);
        scanner.close();
    }
}


Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 5;
const ll oo = 1e18;

int n, a[N], opt[N];
ll f[N][3];

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  opt[1] = 1; cin >> a[1];
  for (int i = 2; i <= n; ++i) {
    char c;
    cin >> c >> a[i];
    opt[i] = (c == '+') ? 1 : -1;
  }
  f[0][1] = f[0][2] = -oo;
  for (int i = 1; i <= n; ++i) {
    f[i][0] = *max_element(f[i - 1], f[i - 1] + 3) + 1LL * opt[i] * a[i];
    f[i][1] = max(f[i - 1][1], f[i - 1][2]) - 1LL * opt[i] * a[i];
    f[i][2] = f[i - 1][2] + 1LL * opt[i] * a[i];
    if (opt[i] == -1) {
      f[i][2] = max(f[i][2], f[i][1]);
      f[i][1] = max(f[i][1], f[i][0]);
    }
  }
  cout << *max_element(f[n], f[n] + 3);
  return 0;
}

Measured memory_bytes: 3328
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　  ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    string s;
    cin >> s;
    Yes(s[2] == s[3] && s[4] == s[5]);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


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

  int a[n],b[n];
  int c[m],d[m];

  for(int i = 0; i < n; i++){
    cin>>a[i]>>b[i];
  }
  for(int i = 0; i < m; i++){
    cin>>c[i]>>d[i];
  }

  for(int i = 0; i < n; i++){
   ll tmp = 100000000000000;
   int ans = 0;
   for(int j = 0; j < m; j++){
     if(tmp>abs(a[i]-c[j])+abs(b[i]-d[j])){
       tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
       ans = j+1;
     }
   }
   cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
count = {}
for _ in range(N):
    s = input()
    if s in count:
        count[s] += 1
    else:
        count[s] = 1
res = sorted(count.items(), key=lambda x: (-x[1], x[0]))
max_count = res[0][1]
res = [x[0] for x in res if x[1] == max_count]
print(*res, sep='\n')

Measured memory_bytes: 125784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

//最大公約数
int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main(){
    ll N, X; cin >> N >> X;
    vector<ll> V(N); for(int i = 0; i < N; i++) cin >> V[i];
    bool flag = true;
    for(int i = 0; i < N; i++) if(X == V[i]) flag = false;
    if(flag){V.push_back(X); N++;}
    sort(V.begin(), V.end());
    
    vector<ll> D(N-1);
    for(int i = 0; i < N-1; i++){
        D[i] = V[i+1]-V[i];
    }
    ll ans = gcd(D[0], D[1]);
    for(int i = 2; i < N-1; i++) ans = gcd(D[i], ans);
    cout << ans << endl;


}

Measured memory_bytes: 1792
/*
 * 0287.cc: Jinkoki
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int K = 18;
const int KU = 10000;

const string uns[] = {
  "",
  "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan",
  "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"
};

/* typedef */

struct JKK {
  int ds[K];
  JKK() { memset(ds, 0, sizeof(ds)); }
  JKK(int d) {
    memset(ds, 0, sizeof(ds));
    for (int i = 0; d > 0 && i < K; i++) {
      ds[i] = d % KU;
      d /= KU;
    }
  }

  JKK operator+(const JKK &j0) const {
    JKK rj;
    int co = 0;
    for (int i = 0; i < K; i++) {
      int di = ds[i] + j0.ds[i] + co;
      rj.ds[i] = di % KU;
      co = di / KU;
    }
    return rj;
  }

  JKK operator*(const JKK &j0) const {
    JKK rj;
    for (int i = 0; i < K; i++) {
      int co = 0;
      for (int j = 0; j < K - i; j++) {
	int dj = ds[j] * j0.ds[i] + co;
	rj.ds[i + j] += dj % KU;
	co = dj / KU + rj.ds[i + j] / KU;
	rj.ds[i + j] %= KU;
      }
    }
    return rj;
  }

  JKK pow(int n) {
    JKK rj(1), pa = *this;
    while (n > 0) {
      if (n & 1) rj = rj * pa;
      pa = pa * pa;
      n >>= 1;
    }
    return rj;
  }
  
  void print() {
    for (int i = K - 1; i >= 0; i--)
      if (ds[i]) cout << ds[i] << uns[i];
    putchar('\n');
  }
};

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    int m, n;
    cin >> m >> n;
    if (m == 0) break;

    JKK j0(m);
    j0.pow(n).print();
  }
  return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

int n, k, s;
ll xmin[60], ymin[60], zmin[60], xmax[60], ymax[60], zmax[60];
ll x[114], y[114], z[114];
ll ans;

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++){
		scanf("%lld%lld%lld%lld%lld%lld", &xmin[i], &ymin[i], &zmin[i], &xmax[i], &ymax[i], &zmax[i]);
		//xmin[i]++; ymin[i]++; zmin[i]++;
		x[s] = xmin[i]; y[s] = ymin[i]; z[s] = zmin[i];
		s++;
		x[s] = xmax[i]; y[s] = ymax[i]; z[s] = zmax[i];
		s++;
	}
	sort(x,x+s); sort(y,y+s); sort(z,z+s);
	for(int i = 1; i < s; i++){
		for(int j = 1; j < s; j++){
			for(int u = 1; u < s; u++){
				int cnt = 0;
				for(int v = 0; v < n; v++){
					if(xmin[v] <= x[i-1] && x[i] <= xmax[v] && ymin[v] <= y[j-1] && y[j] <= ymax[v] && zmin[v] <= z[u-1] && z[u] <= zmax[v]){
						cnt++;
					}
				}
				if(cnt >= k){
					ans += (x[i]-x[i-1])*(y[j]-y[j-1])*(z[u]-z[u-1]);
				}
			}
		}
	}
	printf("%lld\n", ans);
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  if (s.at(k - 1) == 'A') s.at(k - 1) = 'a';
  if (s.at(k - 1) == 'B') s.at(k - 1) = 'b';
  if (s.at(k - 1) == 'C') s.at(k - 1) = 'c';
  cout << s << endl;
}

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

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    vector <ll> x(n);
    ll ans=0;

    rep(i,n){
        cin >> x[i];
        if(i!=0){
            ans+=min((x[i]-x[i-1])*a,b);
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <cmath>

#define N_MAX 1000000

using namespace std;

int main(void)
{
	int n = 0;
	bool isNotPrime[N_MAX] = { false };
	
	isNotPrime[0] = true;
	int rootN = sqrt(N_MAX);
	for(int i = 2; i <= rootN; i++){
		for(int j = 2 * i; j < N_MAX; j += i){
			isNotPrime[j - 1] = true;
		}
	}
	
	while(cin >> n){
		//素数の数をカウント
		int cnt = 0;
		for(int i = 0; i < n; i++){
			if(!isNotPrime[i]){
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2144
import heapq

n,m = map(int,input().split())
a = [int(x)*(-1) for x in input().split()]
heapq.heapify(a)
for _ in range(m):
    x = heapq.heappop(a) * (-1)
    heapq.heappush(a,x//2*(-1))
print(sum(a)*(-1))


Measured memory_bytes: 72216
N = int(input())
A = list(map(int, input().split()))

# 1例を示せ、なので、操作しないで良い場合も操作することにする

p = 0
m = 0
for i in range(N):
    if A[i] >= 0:
        p += 1
    else:
        m += 1


# 全部正なので左から累積和
ans = []
if m == 0:
    for i in range(N-1):
        ans.append((i+1, i+2))
    print(len(ans))
    for x,y in ans:
        print(x,y)
# 全部負なので左から累積和
elif p == 0:
    for i in range(N-1, 0, -1):
        ans.append((i+1, i))
    print(len(ans))
    for x,y in ans:
        print(x,y)
else:
    # 絶対値の大きい方で実施
    big = -1 * float("inf")
    big_idx = 0
    small = float("inf")
    small_idx = 0
    for i in range(N):
        if big < A[i]:
            big = A[i]
            big_idx = i

        if small > A[i]:
            small = A[i]
            small_idx = i

    # 全体を正にしてから左から累積和
    if abs(big) >= abs(small): 
        for i in range(N):
            if A[i] < 0:
                ans.append((big_idx+1, i+1))

        for i in range(N-1):
            ans.append((i+1, i+2))
        print(len(ans))
        for x,y in ans:
            print(x,y)
    # 全体を負にしてから右から累積和
    else:
        for i in range(N):
            if A[i] > 0:
                ans.append((small_idx+1, i+1))
        for i in range(N-1, 0, -1):
            ans.append((i+1, i))
        print(len(ans))
        for x,y in ans:
            print(x,y)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

struct Node {
  int a, b, x;

  Node() {}

  Node(int a, int b, int x) : a(a), b(b), x(x) {}

  bool operator<(const Node& rhs) const {
    if (b * (ll)rhs.a == rhs.b * (ll)a) return x < rhs.x;
    else
      return b * (ll)rhs.a < rhs.b * (ll)a;
  }
};

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> p(n - 1), v(n);
  cin >> p >> v;
  p.insert(p.begin(), {0, 0});
  v.insert(v.begin(), {0});
  vector<int> f(n + 1);
  vector<Node> a(n + 1);
  for (int i = 1; i <= n; ++i)
    a[i] = Node(v[i] == 0, v[i] == 1, i);
  iota(f.begin(), f.end(), 0);
  function<int(int)> find = [&](int x) {
    return f[x] == x ? x : f[x] = find(f[x]);
  };
  set<Node> heap(a.begin() + 2, a.end());
  ll ans = 0;
  for (int rep = 1; rep < n; ++rep) {
    Node tmp = *heap.begin();
    heap.erase(heap.begin());
    int y = find(p[tmp.x]);
    if (y != 1) heap.erase(a[y]);
    ans += a[y].b * (ll)tmp.a;
    f[tmp.x] = y;
    a[y].a += tmp.a;
    a[y].b += tmp.b;
    if (y != 1) heap.insert(a[y]);
  }
  cout << ans;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 17504
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	long long n,x,i,m,memo;
	cin >> n >> x;
	m=2*n-1;
	if(x==1||x==m){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	if(n==2){
		cout << "1" << endl;
		cout << "2" << endl;
		cout << "3" << endl;
		return 0;
	}
	memo=1;
	if(x!=2){
		for(i=1;i<=m;i++){
			if(i<n-1||i>n+2){
				if(memo==x-2) memo=x+2;
				cout << memo << endl;
				memo++;
			} else if(i==n-1){
				cout << x-1 << endl;
			} else if(i==n){
				cout << x+1 << endl;
			} else if(i==n+1){
				cout << x << endl;
			} else if(i==n+2){
				cout << x-2 << endl;
			}
		}
	} else {
		memo=5;
		for(i=1;i<=m;i++){
			if(i<n-1||i>n+2){
				cout << memo << endl;
				memo++;
			} else if(i==n-1){
				cout << "3" << endl;
			} else if(i==n){
				cout << "1" << endl;
			} else if(i==n+1){
				cout << "2" << endl;
			} else if(i==n+2){
				cout << "4" << endl;
			}
		}
	}
	return 0;
}

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

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  if(c-a-b < 0) {
    cout << "No" << endl;
  } else {
    if(4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl; 
  }
  return 0;
}


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

int main(){
    int N; cin >> N;
    string X; cin >> X;
    vector<int> f(N + 1, -1);
    vector<int> facminus, facplus;
    int cnt = 0;
    rep(i, N)if(X[i] == '1') cnt++;
    bool forbiddenMinus = false;
    int xminus = 0, xplus = 0;
    int t = 1;
    cnt--;
    if(cnt < 1){
        forbiddenMinus = true;
    }else{
        rep(i, N){
            if(X[N - i - 1] == '1'){
                xminus += t;
                xminus %= cnt;
            }
            t %= cnt;
            facminus.push_back(t);
            t *= 2;
        }
    }
    
    cnt += 2;
    t = 1;
    rep(i, N){
        if(X[N - i - 1] == '1'){
            xplus += t;
            xplus %= cnt;
        }
        t %= cnt;
        facplus.push_back(t);
        t *= 2;
    }
    cnt--;
    // cout << xminus << endl;
    // cout << xplus << endl;
    // rep(i, N) cout << facminus[i] << endl;
    // rep(i, N) cout << facplus[i] << endl;
    rep(i, N){
        if(forbiddenMinus == true && X[i] == '1'){
            cout << 0 << endl;
            continue;
        }
        int tmp = 0;
        if(X[i] == '0'){
            tmp = xplus + facplus[N - i - 1];
            tmp %= cnt + 1;
        }else{
            tmp = xminus - facminus[N - i - 1];
            tmp += cnt - 1;
            tmp %= cnt - 1;
        }
        // cout << i << " " << tmp << endl;
        int ans = 1;
        while(tmp != 0){
            bitset<20> s(tmp);
            int cnt2 = 0;
            rep(i, 20)if(s.test(i)) cnt2++;
            tmp %= cnt2;
            ans++;
        }
        cout << ans << endl;         
    }
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

int main() {
	IOS;
	// cout << fixed << setprecision(20);
	// int a;cin >> a;
	// string s;cin>>s;
	Int n, k; cin >> n >> k;
	vector<int> a(n), b;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	Int cnt = 0, cnt2 = 0;
	Int ans = 0;
	for (int i = 0; i < n; i++) {
		int num = a[i];
		cnt = 0;
		cnt2 = 0;
		for (int j = i + 1; j < n; j++) {
			if (num > a[j])cnt++;
		}
		for (int k = 0; k < n; k++) {
			if (num > a[k])cnt2++;
		}
		//cout << num << " " << cnt << endl;
		Int dif = cnt2 - cnt;
		//cout << dif << endl;
		Int z = k % MOD;
		// ans += k *(k + 1) / 2 % MOD *cnt2 % MOD - dif * k % MOD;
		ans += k * (k - 1) / 2 % MOD * cnt2 % MOD + k * cnt % MOD;//AC
		ans%=MOD;
	}

	cout << ans % MOD;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


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

typedef long long ll;
using namespace std;

typedef long double ldouble;

const ll MAXN = 1e5 + 1;

int n, a, b, p[101], sum, cnt[4];

int main()
{
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i ++){
        cin >> p[i];
        if(p[i] <= a) cnt[1] ++;
        else if(p[i] > a && p[i] <= b) cnt[2] ++;
        else cnt[3] ++;
    }
    cout << min(cnt[1], min(cnt[2], cnt[3]));
    return 0;
}


Measured memory_bytes: 256
function main(c){var b=c.split("\n");c=parseInt(b[0]);var d=[];b[1]=b[1].split(" ");for(var a=0;a<c;++a)d.push(parseInt(b[1][a],10));for(a=b=0;a<c;++a)d[a]!=a+1&&(b+=1);console.log(2>=b?"YES":"NO")}main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int H,W,N; cin >> H >> W >> N;
    map<Pi,int> mp;
    rep(i,N){
        int a,b; cin >> a >> b;
        a--; b--;
        rep(j,3)rep(k,3){
            if(a-j >= 0 && b-k >= 0 && a-j+2 < H && b-k+2 < W){
                mp[Pi(a-j,b-k)]++;
            }
        }
    }
    vector<ll> ans(10);
    for(auto u : mp){
        ans[u.second]++;
    }
    ll sum = 0;
    rep(i,10) sum += ans[i];
    ans[0] = (ll)(H-2)*(W-2)-sum;
    rep(i,10){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

struct UnionFind{
    vector<int> par;
    UnionFind(int n) : par(n, -1){}
    
    int root(int x){
        if(par[x]<0) return x;
        return par[x] = root(par[x]); 
    }

    bool same(int a, int b){
        return root(a)==root(b);
    }

    void unite(int a, int b){
        int x=root(a), y=root(b);
        if(x==y) return;
        if(y<x) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
    int size(int x){
        return -par[root(x)];
    }

};

int main(){
    int n, m, k;    cin >> n >> m >> k;
    vector<vector<int>> g(n);
    UnionFind fr(n);
    vector<set<int>> ff(n);
    for(int i=0; i<m; i++){
        int a, b;   cin >> a >> b;
        a--;    b--;
        ff.at(a).insert(b);
        ff.at(b).insert(a);
        fr.unite(a, b);
    }
    for(int i=0; i<k; i++){
        int a, b;   cin >> a >> b;
        a--;    b--;
        if(!fr.same(a, b)) continue;
        ff.at(a).insert(b);
        ff.at(b).insert(a);
    }

    for(int i=0; i<n; i++){
        int ans = fr.size(i)-1;
        cout << ans-ff.at(i).size() << ' ';
    }
    cout << endl;


}

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


void solve(long long A, long long B, long long K){

    if(A<B){
        ll tmp = A;
        A = B;
        B = tmp;
    }
    ll r = B;
    ll count =0;
    while(r>0){
        if(A%r==0 && B%r==0){
            count++;
        }
        if(count==K){
            cout << r << endl;
            return;
        }
        r--;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

ll pow_mod(ll n,ll p,ll m){
    ll res = 1;
    while(p>0){
        if(p%2==1) res = (res * n) % m;
        n = (n * n) % m;
        p /= 2;
    }
    return res;
}

int main(){
    string s;cin >> s;
    int n = s.size();
    vector<int> v(s.size(),0);
    reverse(s.begin(), s.end());
    rep(i,n){
        int d = s[i] - '0';
        d = (d * pow_mod(10,i,2019)) % 2019;
        v[i] = ((i!=0?v[i-1] : 0) + d) % 2019;
    }
    ll ans = 0;
    map<int,int> mp;
    mp[0]++;
    rep(i,n){
        if(mp.find(v[i])!=mp.end()){
            ans += mp[v[i]];
        }
        mp[v[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4364
h, w, k = map(int, input().split())
grid = [None]*h
for i in range(h):
  grid[i] = input()

ans = 0
for i in range(2**h):
  key = [0]*h
  for a in range(h):
    if (i>>a)&1:
      key[a] = 1
  for j in range(2**w):
    key2 = [0]*w
    for b in range(w):
      if (j>>b)&1:
        key2[b] = 1
    count = 0
    for p in range(h):
      for q in range(w):
        if grid[p][q] == "#" and key[p] == 0 and key2[q] == 0:
          count += 1
    if count == k:
      ans += 1
print(ans)

Measured memory_bytes: 9160
#include<bits/stdc++.h>
#define FILE
#define ll long long
#define cn continue
#define pb push_back
using namespace std;
const ll M = 1e3;
ll n  ,mx , m , a , cnt , ans;
string s , s1;
int main(){
    cin >> n;
    map<string , int>mp;
    for( int i = 0;i < n;i ++ )
        cin >> s , mp[s] ++;
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}


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


long long int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int A,B,C,K;
  cin >> A >>B >>C >>K;
  for(int i=0;i<=K;i++){
    if(A>=B){
      B = B*2;
    }else if(B>=C){
      C = C*2;
    }else{
      cout << "Yes" <<endl;
      exit(0);
    }
  }
  cout << "No" <<endl;
}


long long int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  ll A;
  cin >> A;
  if (A > 500000) {
    cout << 1;
    return 0;
  }
  rep(i, A/100+1) {
    rep(j, A / 100 + 1) {
      rep(k, A / 100 + 1) {
        rep(l, A / 100 + 1) {
          rep(m, A / 100 + 1) {
            rep(n, A / 100 + 1) {
              if (i * 100 + j * 101 + k * 102 + l * 103 + m * 104 + n * 105 == A) {
                cout << 1;
                return 0;
              }
            }
          }
        }
      }
    }
  }
  cout << 0;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string, int> mp;
  vector<int> sum(n);
  rep(i, n) {
    string s;
    int a;
    cin >> s >> a;
    mp[s] = i;
    sum[i] = a;
    if (i)
      sum[i] += sum[i-1];
  }
  string s;
  cin >> s;
  int idx = mp[s];
  cout << sum[n-1]-sum[idx] << endl;
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i = 0; i < n; i++)
    cin >> s.at(i);
  sort(s.begin(), s.end());
  vector<pair<int, int>> c;
  c.push_back({1, 0});
  for(int i = 1; i < n; i++) {
    if(s[i - 1] != s[i])
      c.push_back({1, i});
    else
      c.back().first++;
  }
  sort(c.begin(), c.end());
  for(auto a : c)
    if(a.first == c.back().first)
      cout << s[a.second] << '\n';
}

Measured memory_bytes: 14576
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int a,b;
int main() {
	//freopen("1.txt","r",stdin);
	read(a); read(b);
	printf("%d\n",max(max(a+b,a-b),a*b));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define BG begin
#define ED end

#define For(i,j,k) for (int i=(j);i<=(int)k;i++)
#define Rep(i,j,k) for (int i=(j);i>=(int)k;i++)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
using namespace std;
/*int k;

int main(){
	scanf("%d",&k);
	ll ans=1,t=1,v=1;
	while (k--){
		printf("%lld\n",ans);
		if ((++t)==10) v=v*10,t=1;
		ans+=v; 
	}
}*/
int n,k;
int main(){
	scanf("%d%d",&n,&k);
	printf("%d\n",(n-1)/(k-1)+((n-1)%(k-1)!=0));
}

Measured memory_bytes: 256
import itertools
n = int(input())
c = list(itertools.product(['S', 'H', 'C', 'D'], range(1,14)))
for _ in range(n):
    s, num = input().split()
    c.remove((s, int(num)))
for i in range(4*13 - n):
    print(c[i][0], c[i][1])

Measured memory_bytes: 7744
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

int N;
vector<vector<char>> cells;

char convert(int w, int h) {

    //while (w >= N) w -= N;
    //while (h >= N) h -= N;
    //while (w <= -N) w += N;
    //while (h <= -N) h += N;

    auto x = (h + w) / 2;
    auto y = (h - w) / 2;

    while (x >= N) x-= N;
    while (y >= N) y -= N;
    while (x <= -N) x += N;
    while (y <= -N) y += N;

    // cout << "x, y = " << x << "," << y << endl;
    return cells[y][x];
}


ll faster() {
    int ans = 0;
    FOR(w, -N + 1, N) {
        auto h_start = abs(w);
        int diff = 0;

        REP(h_offset, N - abs(w)) {

            auto w1 = w;
            auto h1 = h_start + h_offset * 2;

            //cout << "=== w1, h1 = " << w1 << "," << h1 << endl;
            //cout << "  initialize" << endl;
            // 非対称性を崩す要素の数を数える
            if (h_offset == 0) {
                // (w, h_start)
                // 軸を中心とした左右
                FOR(i, 1, N) {
                    REP(j, N - i) {
                        diff += convert(w1 - i, h1 + i + 2 * j) != convert(w1 + i, h1 + i + 2 * j);
                    }
                }
            }

            ans += (diff == 0);

            //cout << "  for next" << endl;

            // 次のために要素を入れ替える
            if (h_offset != N - abs(w) - 1) {
                FOR(i, 1, N) {
                    diff -= convert(w1 - i, h1 + i) != convert(w1 + i, h1 + i);
                    diff += convert(w1 - i, h1 + i + 2 * N) != convert(w1 + i, h1 + i + 2 * N);
                }
            }
        }
    }
    return ans;
}


int main(void) {
    cin >> N;
    cells.resize(N);
    REP(n, N) cells[n].resize(N);
    REP(n1, N) REP(n2, N) cin >> cells[n1][n2];

    auto ans = faster();
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int X[10][10];

int main() {
  int N, D;
  cin >> N >> D;
  rep(i,N) rep(j,D) cin >> X[i][j];
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      int d = 0;
      rep(k,D) d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      int t = sqrt(d);
      if (t*t == d) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>
int n,i,A[100];
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %d",&A[i]);
  }
  for(i=n-1;i>0;i--){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[0]);
  return 0;
}

Measured memory_bytes: 2684
n = int(input())
yo =[]
for i in range(n):
    yo.append(list(map(int,input().split())))
now =[0, 0, 0]
for i in range(n):
    c = yo[i][0] - now[0]-(abs(yo[i][1]-now[1]) + abs(yo[i][2]-now[2]))
    if c >= 0 and c%2 == 0:
        now =yo[i]
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 60504