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

typedef long long LL;

const int N=100;

int n,m,a[N+9][N+9];

void into(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=n;++i)
	for (int j=1;j<=m;++j)
	  scanf("%d",&a[i][j]);
}

int id[N+9][N+9];

void Get_id(){
  for (int i=1;i<=n;++i)
	for (int j=1;j<=m;++j) id[i][j]=(a[i][j]-1)/m+1;
}

int e[N+9][N+9];

void Get_graph(){
  for (int i=1;i<=n;++i){
	for (int j=1;j<=n;++j) e[i][j]=0;
	for (int j=1;j<=m;++j)
	  if (id[i][j]) e[i][id[i][j]]=1;
  }
}

int par[N+9],vis[N+9];

bool Dfs_par(int k){
  for (int i=1;i<=n;++i)
	if (e[k][i]&&vis[i]<vis[0]){
	  vis[i]=vis[0];
	  if (!par[i]||Dfs_par(par[i])) {par[i]=k;return 1;}
	}
  return 0;
}

void KM(){
  for (int i=1;i<=n;++i) par[i]=vis[i]=0;
  for (int i=1;i<=n;++i) Dfs_par(vis[0]=i);
}

int ans[2][N+9][N+9];

void Get_ans0(){
  for (int i=1;i<=m;++i){
	Get_graph();
	KM();
    for (int j=1;j<=n;++j){
	  int t=par[j];
	  for (int k=1;k<=m;++k)
		if (id[t][k]==j) {id[t][k]=0;ans[0][t][i]=a[t][k];break;}
	}
  }
}

int tmp[N+9];

void Get_ans1(){
  for (int i=1;i<=m;++i){
	for (int j=1;j<=n;++j) tmp[j]=ans[0][j][i];
	sort(tmp+1,tmp+n+1);
	for (int j=1;j<=n;++j) ans[1][j][i]=tmp[j];
  }
}

void work(){
  Get_id();
  Get_ans0();
  Get_ans1();
}

void outo(){
  for (int i=0;i<2;++i)
	for (int j=1;j<=n;++j){
	  for (int k=1;k<=m;++k)
		printf("%d ",ans[i][j][k]);
	  puts("");
	}
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

int main(void){

    ll x;
    cin >> x;

    int fh = x / 500;

    int f = (x - fh * 500) / 5;

    cout << fh * 1000 + f * 5 << endl;
    return 0;
}


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

int main() {
	char inBuf[1000000];
	int n=0,j=0;
	long x[10001],min,max;
	long long int sum;
	int plus,f;

	cin.getline(inBuf, 1024);
	while(inBuf[j] != '\0') {
		n = n*10 + inBuf[j] - '0';
		j++;
	}

	cin.getline(inBuf, 1000000);
	//cn = cin.gcount();
	j=0;


	for(int i=0;i<n;i++) {
		x[i]=0;
		f=0;
		plus=1;
		while (inBuf[j] != ' ' && inBuf[j] != '\0') {
			if(f==0 && inBuf[j] == '-')
				plus = -1;
			else
				x[i] = x[i] * 10 + (long)inBuf[j] - '0';
			j++;
			f++;
		}
		x[i] *= plus;
		j++;
	}
	min=x[0];
	max=x[0];
	sum=(long long int)x[0];
	for(int i=1;i<n;i++){
		if(min>x[i]) min=x[i];
		if(max<x[i]) max=x[i];
		sum += (long long int)x[i];
	}
	cout << min << ' ' << max << ' ' << sum << endl;
	return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

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

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll pow_kai(int a, int n)
{ //aのn乗を計算します。
	ll x = 1;
	while (n > 0)
	{ //全てのbitが捨てられるまで。
		if (n & 1)
		{ //1番右のbitが1のとき。
			x = (x * a) % MOD;
		}
		a = (a * a) % MOD;
		n >>= 1; //bit全体を右に1つシフトして一番右を捨てる。
	}
	return x % MOD;
}

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < (1 << (s.length() - 1)); i++)
	{
		int ans = ctoi(s[0]);
		string ns = "";
		ns += s[0];

		for (int k = 0; k < s.length() - 1; k++)
		{
			if(i & (1<<k)){
				ans += ctoi(s[k + 1]);
				ns += "+";
			}
			else
			{
				ans -= ctoi(s[k + 1]);
				ns += "-";
			}
			ns += s[k + 1];
		}
		if(ans == 7){
			cout << ns  << "=7" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		long N=sc.nextInt();
		long M=sc.nextInt();
		
		long v=(long)Math.pow(2, M);
		long t=1900*M+100*(N-M);
		
		//p(v+" "+t);
		
		
		
	
		p(t*v);
		}
		
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 23892
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

Node *find(Node *u, int key)
{
  while (u != NIL && key != u->key)
  {
    if (key < u->key)
    {
      u = u->left;
    }
    else
    {
      u = u->right;
    }
  }

  return u;
}

void insert(int key)
{
  Node *y = NIL;
  Node *x = root;

  Node *z;
  z = (Node *)malloc(sizeof(Node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL)
  {
    y = x;
    if (z->key < x->key)
    {
      x = x->left;
    }
    else
    {
      x = x->right;
    }
  }
  // この時点でyはzの親か初期値のNIL
  z->parent = y;
  if (y == NIL)
  {
    // 親がNILなのはroot
    root = z;
  }
  else
  {
    // 親の子へ設定
    if (z->key < y->key)
    {
      y->left = z;
    }
    else
    {
      y->right = z;
    }
  }
}

void inorder(Node *u)
{
  if (u == NIL)
  {
    return;
  }
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u)
{
  if (u == NIL)
  {
    return;
  }
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int n;
  int x;
  string command;

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    cin >> command;
    if (command[0] == 'f')
    {
      scanf("%d", &x);
      Node *t = find(root, x);
      if (t != NIL)
      {
        printf("yes\n");
      }
      else
      {
        printf("no\n");
      }
    }
    else if (command == "insert")
    {
      scanf("%d", &x);
      insert(x);
    }
    else if (command == "print")
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 22096
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int size = scanner.nextInt();
		int[] arr = new int[size];
		
		int count = 0;
		for(int i=0; i<size; i++) {
			arr[i] = scanner.nextInt();
		}
		for(int i=0; i<size; i++) {
			if(!isPrime(arr[i])) {
				count++;
			}
		}
		scanner.close();
		
		System.out.println(count);
		
	}

	public static boolean isPrime(int num) {
		for (int i = 2; i <= (int)Math.sqrt(num); i++) {
			if (num % i == 0) {
				return true;
			}
		}
		return false;
	}
}



Measured memory_bytes: 43352
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    AB = [LIST() for _ in range(N)]

    cnt = 0
    for i in range(N-1, -1, -1):
        cnt += AB[i][1] - (AB[i][0] + cnt) % AB[i][1] if (AB[i][0] + cnt) % AB[i][1] != 0 else 0

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 28056
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input!{
        s: Chars
    }

    let mut max_ans = 0;
    let mut ans = 0;
    for c in s {
        if c == 'R' {
            ans += 1;
            max_ans = max_ans.max(ans);
        }else {
            ans = 0;
        }
    }
    println!("{}", max_ans);
}


Measured memory_bytes: 2152
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string t;
  bool ok=true; 
  cin >> n >> h;
  PS a(n),c(n-1);
  rep(i,n){
    cin >> x >> y;
    a[i] = make_pair(x,y);
  }

  sort(ALL(a));
  Max = a[n-1].first;
  rep(i,n){
    if(Max == a[i].first && ok){
      ok = false;
      z = i;
    }
  }
  swap(a[z], a[n-1]);
  Max = a[n-1].first;

  rep(i,n-1){
    c[i].first = a[i].second;
    c[i].second = a[i].first;
  }
  sort(RALL(c));

  rep(i,n-1){
    if(Max < c[i].first){
      h -= c[i].first;
      ans++;
    }
    if(h<=0){
      pri(ans);
      return 0; 
    }
  }

  while(h>0){
    if(h <= a[n-1].second){
      h -= a[n-1].second;
    }
    else{
      h -= Max; 
    }
    ans++;
  } 
  pri(ans);
  return 0;
}

Measured memory_bytes: 6348
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 998244353;
template <typename Int, Int MOD, int N>
struct comb_util {
	std::array<Int, N + 1> fc, ifc;

	comb_util() {
		fc[0] = 1;
		for (int i = 1; i <= N; i++) fc[i] = fc[i - 1] * i % MOD;
		ifc[N] = inv(fc[N]);
		for (int i = N - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD;
	}

	Int fact(Int n) { return fc[n]; }

	Int inv_fact(Int n) { return ifc[n]; }

	Int inv(Int n) { return pow(n, MOD - 2); }

	Int pow(Int n, Int a) {
		Int res = 1, exp = n;
		for (; a; a /= 2) {
			if (a & 1) res = res * exp % MOD;
			exp = exp * exp % MOD;
		}
		return res;
	}

	Int perm(Int n, Int r) {
		if (r < 0 || n < r)
			return 0;
		else
			return fc[n] * ifc[n - r] % MOD;
	}

	Int binom(Int n, Int r) {
		if (n < 0 || r < 0 || n < r) return 0;
		return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD;
	}

	Int homo(Int n, Int r) {
		if (n < 0 || r < 0) return 0;
		return r == 0 ? 1 : binom(n + r - 1, r);
	}
};

using comb = comb_util<long long, 998244353, 6000000>;
comb C;
void add(int &a,const int &b) {
	a += b;
	if (a >= MOD)a -= MOD;
}
void sub(int &a, const int &b) {
	a -= b;
	if (a < 0)a += MOD;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	
	int tot = C.binom(3 * M + N - 1, N - 1);
	
	int over = 0;

	for (int i = 2 * M + 1; i <= 3 * M; i++) {
		add(over, C.binom(3 * M - i + N - 1 - 1, N - 1 - 1));
	}
	over = (over * N) % MOD;
	sub(tot, over);


	int odd = 0;
	for (int i = M + 1; i <= min(N, 3 * M); i++) {
		if ((3 * M - i) % 2 == 0) {
			int k = (3 * M - i) / 2;
			int tmp = C.binom(k + N - 1, N - 1);
			tmp = (tmp * C.binom(N, i)) % MOD;
			add(odd, tmp);
		}
	}
	sub(tot, odd);

	cout << tot << endl;
}

Measured memory_bytes: 93952
#include <cstdio>
#include <map>
#include <vector>
using namespace std;

int main(){
  int n,i,p,q,f;
  for(;scanf("%d",&n),n;){
    map<int,long long>m;
    vector<int>v;
    for(;n--;){
      scanf("%d%d%d",&i,&p,&q);
      if(m.find(i)==m.end())v.push_back(i);
      m[i]+=(long long)p*q;
    }
    for(f=i=0;i<v.size();i++){
      if(m[v[i]]>=1000000)printf("%d\n",v[i]),f=1;
    }
    if(!f)puts("NA");
  }
}

Measured memory_bytes: 1136
#全日本汚いコード選手権Pythonの部
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(list(input()))
L = [[0 for w in range(W)] for h in range(H)]

if H == 1 and W == 1:
  if S[0][0] == ".":
    L[0][0] = 0

elif H == 1:
  
  if S[0][1]=="#":
    L[0][0]+=1
  if S[0][W-2]=="#":
    L[0][W-1]+=1
  for w in range(1,W-1):
    if S[0][w-1]=="#":
      L[0][w]+=1
    if S[0][w+1]=="#":
      L[0][w]+=1

elif W == 1:
  
  if S[1][0]=="#":
    L[0][0]+=1
  if S[H-2][0]=="#":
    L[H-1][0]+=1
  for h in range(1,H-1):
    if S[h-1][0]=="#":
      L[h][0]+=1
    if S[h+1][0]=="#":
      L[h][0]+=1
  
  
else:

  if S[0][1]=="#":
    L[0][0]+=1
  if S[1][0]=="#":
    L[0][0]+=1
  if S[1][1]=="#":
    L[0][0]+=1
  if S[H-1][1]=="#":
    L[H-1][0]+=1
  if S[H-2][0]=="#":
    L[H-1][0]+=1
  if S[H-2][1]=="#":
    L[H-1][0]+=1
  if S[0][W-2]=="#":
    L[0][W-1]+=1
  if S[1][W-1]=="#":
    L[0][W-1]+=1
  if S[1][W-2]=="#":
    L[0][W-1]+=1
  if S[H-1][W-2]=="#":
    L[H-1][W-1]+=1
  if S[H-2][W-1]=="#":
    L[H-1][W-1]+=1
  if S[H-2][W-2]=="#":
    L[H-1][W-1]+=1

  for w in range(1,W-1):
    if S[0][w-1]=="#":
      L[0][w]+=1
    if S[0][w+1]=="#":
      L[0][w]+=1
    if S[1][w-1]=="#":
      L[0][w]+=1
    if S[1][w]=="#":
      L[0][w]+=1
    if S[1][w+1]=="#":
      L[0][w]+=1
    if S[H-1][w-1]=="#":
      L[H-1][w]+=1
    if S[H-1][w+1]=="#":
      L[H-1][w]+=1
    if S[H-2][w-1]=="#":
      L[H-1][w]+=1
    if S[H-2][w]=="#":
      L[H-1][w]+=1
    if S[H-2][w+1]=="#":
      L[H-1][w]+=1

  for h in range(1,H-1):
    if S[h-1][0]=="#":
      L[h][0]+=1
    if S[h+1][0]=="#":
      L[h][0]+=1
    if S[h-1][1]=="#":
      L[h][0]+=1
    if S[h][1]=="#":
      L[h][0]+=1
    if S[h+1][1]=="#":
      L[h][0]+=1
    if S[h-1][W-1]=="#":
      L[h][W-1]+=1
    if S[h+1][W-1]=="#":
      L[h][W-1]+=1
    if S[h-1][W-2]=="#":
      L[h][W-1]+=1
    if S[h][W-2]=="#":
      L[h][W-1]+=1
    if S[h+1][W-2]=="#":
      L[h][W-1]+=1

  for w in range(1,W-1):
    for h in range(1,H-1):
      if S[h-1][w-1]=="#":
        L[h][w]+=1
      if S[h-1][w]=="#":
        L[h][w]+=1
      if S[h-1][w+1]=="#":
        L[h][w]+=1
      if S[h][w-1]=="#":
        L[h][w]+=1
      if S[h][w+1]=="#":
        L[h][w]+=1
      if S[h+1][w-1]=="#":
        L[h][w]+=1
      if S[h+1][w]=="#":
        L[h][w]+=1
      if S[h+1][w+1]=="#":
        L[h][w]+=1

C = [["" for w in range(W)] for h in range(H)]

for w in range(W):
  for h in range(H):
    if S[h][w]==".":
      C[h][w]=str(L[h][w])
    else:
      C[h][w]="#"

o = ""
for c in C:
  o = ""
  for cc in c:
    o += cc
  print(o)

Measured memory_bytes: 3448
#include <cstdio>
#include <algorithm>

using namespace std;

int N, K, H[200000];
long long ans;

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; ++i)
		scanf("%d", &H[i]);
	sort(H, H + N);
	for (int i = 0; N - i > K; ++i)
		ans += H[i];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
N,M=map(int,input().split())
a=[[int(b) for b in input().split()] for i in range(N)]
c=[[int(d) for d in input().split()] for i in range(M)]
for i in range(N):
  p=a[i]
  tmp=10**10
  pos=-1
  for j in range(M):
    cp=c[j]
    dist=abs(cp[0]-p[0])+abs(cp[1]-p[1])
    if dist < tmp:
      tmp=dist
      pos=j+1
      #print(pos)
  print(pos)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] map = new int[26];
    int n = sc.nextInt();
    String str = sc.next();
    for(int i = 0; i < str.length(); i++){
      map[str.charAt(i) - 'a']++;
    }

    for(int i = 0; i < n-1; i++){
      map = f(map, sc.next());
    }
    for(int i = 0; i < 26; i++){
      for(int j = 0; j < map[i]; j++){
        System.out.print((char)('a' + i));
      }
    }
    System.out.println();
  }
  
  public static int[] f(int[] map, String str){
    int[] map2 = new int[26];
    for(int i = 0; i < str.length(); i++){
      map2[str.charAt(i) - 'a']++;
    }
    for(int i = 0; i < 26; i++){
      map[i] = Math.min(map[i], map2[i]);
    }
    return map;
  }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define INF 100000000000000

ll keta(ll a){
	ll num=0;
	while(a!=0){
		a/=10;
		num++;
	}
	return num;
}

int main(){
	ll n,ins;cin>>n;

	ll MAX=1;
	for(ll i=2;i*i<=n;i++){//素因数分解
		if(n%i==0){MAX=i;}
	}
	ll ans=INF;
	ans=min(ans,max(keta(MAX),keta(n/MAX)));

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	p := make([]pair, n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = pair{scanInt() - 1, scanInt() - 1, i}
		t[p[i].b] = p[i].k
	}
	sort.Slice(p, func(i, j int) bool { return p[i].a < p[j].a })

	b1 := newBinaryIndexedTree(n)
	b2 := newBinaryIndexedTree(n)

	uf := newUnionFind(n)

	for i := 0; i < n; i++ {
		_, y, k := p[i].a, p[i].b, p[i].k
		a := b1.sum(y)
		if a != 0 {
			id := b1.lowerBound(a)
			uf.unite(k, t[id])
		}
		b1.add(y, 1)
	}
	for i := 0; i < n; i++ {
		_, y, k := p[n-1-i].a, p[n-1-i].b, p[n-1-i].k
		a := b2.sum(y) + 1
		id := b2.lowerBound(a)
		if id != n {
			uf.unite(k, t[id])
		}
		b := b2.sum(n - 1)
		if b != b2.sum(y) {
			id2 := b2.lowerBound(b)
			uf.unite(k, t[id2])
		}
		b2.add(y, 1)
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(wr, uf.size(i))
	}
}

type pair struct{ a, b, k int }

type binaryIndexedTree []int

func newBinaryIndexedTree(n int) *binaryIndexedTree {
	bit := make(binaryIndexedTree, n+1)
	return &bit
}

func (t binaryIndexedTree) sum(i int) (s int) {
	for i++; i > 0; i -= i & -i {
		s += t[i]
	}
	return
}

func (t binaryIndexedTree) add(i, x int) {
	for i++; i < len(t) && i > 0; i += i & -i {
		t[i] += x
	}
}

func (t binaryIndexedTree) lowerBound(x int) int {
	idx, k := 0, 1
	for k < len(t) {
		k <<= 1
	}
	for k >>= 1; k > 0; k >>= 1 {
		if idx+k < len(t) && t[idx+k] < x {
			x -= t[idx+k]
			idx += k
		}
	}
	return idx
}

type unionFind []int

func newUnionFind(n int) *unionFind {
	uf := make(unionFind, n)
	for i := 0; i < n; i++ {
		uf[i] = -1
	}
	return &uf
}

func (uf unionFind) find(x int) int {
	if uf[x] < 0 {
		return x
	}
	uf[x] = uf.find(uf[x])
	return uf[x]
}

func (uf unionFind) unite(x, y int) {
	x, y = uf.find(x), uf.find(y)
	if x != y {
		if uf[x] > uf[y] {
			x, y = y, x
		}
		uf[x] += uf[y]
		uf[y] = x
	}
}

func (uf unionFind) size(x int) int {
	return -uf[uf.find(x)]
}


Measured memory_bytes: 15328
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXN = (int) 2e5;

int arr[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    if(arr[1] != 0) {
        cout << -1;
        return 0;
    }
    for(i = 2; i <= n; i++) {
        if(arr[i] - arr[i - 1] > 1) {
            cout << -1;
            return 0;
        }
    }
    ll ans = 0;
    for(i = 2; i <= n; i++) {
        if(arr[i] > 0) {
            if(arr[i] < arr[i - 1]) {
                ans += arr[i];
            }
            else if(arr[i] > arr[i - 1]) {
                ans++;
            }
            else if(arr[i] == arr[i - 1]) {
                ans += arr[i];
            }
        }
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
int a,b,c,d,e;
scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    d=a;
    a=b;
    b=d;
  }
  if(b>c){
    b=c;
  }
  printf("%d",a+b);
  return 0;
}

    
  

    

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e3 + 3, MOD1 = 1e9 + 7, MOD2 = 998244353;
const int INF = 1e9+1;

int n, m, xN, yN, hs[N], he[N], hy[N], vs[N], ve[N], vx[N];
lint ans;
vi xs, ys;
vector<pii> delta{{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
bool inff, vis[3*N][3*N], ml[3*N][3*N], mr[3*N][3*N], md[3*N][3*N], mu[3*N][3*N];

int rankinx(int x)
{
    return lower_bound(all(xs), x) - xs.begin();
}
int rankiny(int x)
{
    return lower_bound(all(ys), x) - ys.begin();
}
queue<pii> q;
void bfs(int y, int x)
{
    q.push({y, x});
    //cout << y << " - " << x << endl;
    vis[y][x]=true;
    while(q.size())
    {
        pii p = q.front();
        y = p.F; x = p.S;
        q.pop();
        if(x==0 || x==xN-1 || y==0 || y==yN-1)
        {
            inff=true;
            return;
        }
        ans += ((lint)(xs[x+1] - xs[x]))*(ys[y+1] - ys[y]);
        for(int i = 0; i < 4; i++)
        {
            if(i==0 && mu[y][x]) continue;
            if(i==1 && md[y][x]) continue;
            if(i==2 && ml[y][x]) continue;
            if(i==3 && mr[y][x]) continue;
            int nx = x + delta[i].S, ny = y + delta[i].F;
            if(vis[ny][nx]) continue;
            vis[ny][nx]=true;
            q.push({ny, nx});
        }
    }
}
signed main()
{
    //n=1000, m=1000;
    //int cnt=0;
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        //hs[i]=cnt++; he[i]=cnt++; hy[i]=cnt++;
        cin >> hs[i] >> he[i] >> hy[i];
        xs.pb(hs[i]); xs.pb(he[i]);
        ys.pb(hy[i]);
    }
    for(int i = 0; i < m; i++)
    {
        //vx[i]=cnt++; vs[i]=cnt++; ve[i]=cnt++;
        cin >> vx[i] >> vs[i] >> ve[i];
        ys.pb(vs[i]); ys.pb(ve[i]);
        xs.pb(vx[i]);
    }
    xs.pb(-INF); xs.pb(INF);
    ys.pb(-INF); ys.pb(INF);
    sort(all(xs)); sort(all(ys));
    xs.resize(unique(all(xs)) - xs.begin());
    ys.resize(unique(all(ys)) - ys.begin());
    xN = xs.size(); yN = ys.size();
    for(int i = 0; i < n; i++)
    {
        int l = rankinx(hs[i]), r = rankinx(he[i]);
        int y = rankiny(hy[i]);
        for(int j = l; j < r; j++)
        {
            md[y-1][j]=true; mu[y][j]=true;
        }
    }
    for(int i = 0; i < m; i++)
    {
        int u = rankiny(vs[i]), d = rankiny(ve[i]);
        int x = rankinx(vx[i]);
        for(int j = u; j < d; j++)
        {
            mr[j][x-1]=true; ml[j][x]=true;
        }
    }
    int stx = rankinx(0)-1, sty = rankiny(0)-1;
    bfs(sty, stx);
    if(inff)
    {
        cout << "INF"; return 0;
    }
    cout << ans;
    return 0;
}

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


def main():
    from math import degrees, atan

    a, b, x = map(int, input().split())
    h = x / (a ** 2)
    y = 2 * h * a / b
    z = 2 * b - 2 * h

    # 水を入れたときの高さhを求める
    # 傾けたときにできる三角形の形状に注目
    if x == (a ** 2) * b:
        # 水筒が満タン
        print(0)
    elif 2 * h >= b:
        # 水筒が半分以上
        print(90 - degrees(atan(a / z)))
    else:
        print(degrees(atan(b / y)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
struct pair{int a;int b;};
int cmp(const void *a, const void *b)
{return ((struct pair*)a)->b - ((struct pair*)b)->b;}
int main()
{
	int n,m,i,j,max=0,ans=0;
	scanf("%d %d",&n,&m);
	struct pair arr[m];
	for(i=0;i<m;i++)
     {scanf("%d %d",&arr[i].a,&arr[i].b);}
	qsort(arr,m,sizeof(struct pair),cmp);
	for(i=0;i<m;i++)
     {if(max<arr[i].a){max = arr[i].b -1;ans ++;}
     }	
	printf("%d",ans);
	return 0;
}	

Measured memory_bytes: 1788
#include <stdio.h>
int ret = 0;

void get_candies(int x, int y, int N, int candies[N][2], int collected);

int main(){
    int N;
    int i, j;
    scanf("%d", &N);
    int candies[N][2];
    for(j = 0; j < 2; j++){
        for(i = 0; i < N; i++){
            scanf("%d", &candies[i][j]);
        }
    }

    /*
    for(j = 0; j < 2; j++){
        printf("out : ");
        for(i = 0; i < N; i++){
            printf("%d", candies[i][j]);
        }
        printf("\n");
    }
    */

    get_candies(0, 0, N, candies,  candies[0][0]);
    printf("%d\n", ret);
    return 0;
}

void get_candies(int x, int y, int N, int candies[N][2], int collected){

    if(x == N - 1 && y == 1){
        if(ret < collected){
            ret = collected;
        }
        return;
    }
    if(x + 1 < N){
        get_candies(x + 1, y, N, candies, collected + candies[x + 1][y]);
    }
    if(y + 1 < 2){
        get_candies(x, y + 1, N, candies, collected + candies[x][y + 1]);
    }
    return;
}

Measured memory_bytes: 128
#include<stdio.h>
int partition(int a[], int id[],char c[], int p,int r){
	int x = a[r];
	int i = p-1;
	for(int j = p; j<=r-1; j++){
		if(a[j]<=x){
			i = i+1;
			//exchange
			int temp = a[i];
			a[i] = a[j];
			a[j] = temp;
			temp = id[i];
			id[i] = id[j];
			id[j] = temp;
			char temp1 = c[i];
			c[i] = c[j];
			c[j] = temp1;
		}
	}
	int temp = a[i+1];
	a[i+1] = a[r];
	a[r] = temp;
	 temp = id[i+1];
	id[i+1] = id[r];
	id[r] = temp;
	char temp1 = c[i+1];
	c[i+1] = c[r];
	c[r] = temp1;
	return i+1;	
}
void quick_sort(int a[], int id[],char c[], int p,int r){
	if(p<r){
		int q = partition(a,id,c,p,r);
		quick_sort(a,id,c,p,q-1);
		quick_sort(a,id,c,q+1,r);
	}
}

void check(int id[],int a[], int n){
	for(int i = 0; i<n-1; i++){
		if(a[i]<a[i+1]) continue;//why it num check first
		if(id[i]<id[i+1]) continue;//check the equal one 
		printf("Not stable\n");
		return;
	}
	printf("Stable\n");
}
int main(){
	int n;
	scanf("%d",&n);
	int a[n+1];
	int id[n+1];
	char c[n+1];
	for(int i = 0; i<n; i++){
		scanf(" %c",&c[i]);
		scanf(" %d",&a[i]);
		id[i] = i;
		//printf("c:%c\n",c[i]);
	}
	
	quick_sort(a,id,c,0,n-1);
	check(id,a,n);
	for(int i = 0; i<n; i++){
		printf("%c %d\n",c[i],a[i]);
	}
	//printf("\n");
	
	return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int num1 = sc.nextInt();

		if(num - num1*2 <= 0)
			System.out.print(0);
		else
			System.out.print(num - num1*2);
	}
}

Measured memory_bytes: 22740
#D
S = list(str(input()))
Q = int(input())
T = 0
r1 = [] #T%2 == 0
r2 = [] #T%2 == 1

for i in range(Q):
    q = list(map(str,input().split()))
    if len(q) == 1:
        T+=1
    else:
        f,c = q[1],q[2]
        if f == "1":
            if T%2 == 0:
                r2.append(c)
            else:
                r1.append(c)
            
        else:
            if T%2 == 0:
                r1.append(c)
            else:
                r2.append(c)
        
if T%2 == 0:
    r2l = len(r2)
    ans = ""
    for i in range(r2l):
        ans+=r2[r2l-i-1]
    for s in S:
        ans+=s
    for r in r1:
        ans+=r
        
else:
    ans = ""
    r1l = len(r1)
    sl = len(S)
    for i in range(r1l):
        ans+=r1[r1l-i-1]
    for i in range(sl):
        ans+=S[sl-i-1]
    for r in r2:
        ans+=r
        
print(ans)
        



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void output(ll a, ll b, ll c) {
	cout << a << " " << b << " " << c << endl;
}

void solve(){
	ll n;
	cin >> n;
	int lim = 3500;
	REPN(i, 1, lim) {
		REPN(j, 1, lim) {
			ll a = 4 * i * j - i * n - j * n;
			ll b = (ll)n * (ll)i * (ll)j;
			if (a > 0 && b % a == 0) {
				output(i, j, b / a);
				return;
			}
		}
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include<cstdio>
int N,M;
char S[100010],T[100010];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
	scanf("%d%d%s%s",&N,&M,S,T);
	for(int i=0;i<N;i++){
		if(1ll*i*M%N==0&&S[i]!=T[1ll*i*M/N])return puts("-1"),0;
	}
	printf("%lld\n",1ll*N*M/gcd(N,M));
}

Measured memory_bytes: 384
import java.util.*;


public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if(a == b){
				System.out.println(c);
			}
			else if(a == c){
				System.out.println(b);
			}
			else{
				System.out.println(a);
			}
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 23248
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 100 + 5 ;
int n , m ;
int X , Y , L , R , U , D ;
int part1[N][N] , part2[N][N] ;
string s[N] ;

inline void smax (int &a , int b) { a = max(a , b) ; }

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

	cin >> n >> m ;

	for (int i = 0 ; i < n ; i ++) {
		cin >> s[i] ;
		for (int j = 0 ; j < m ; j ++) if (s[i][j] == 'E') X = i , Y = j ;
	}

	for (int i = 0 ; i < n ; i ++)
		for (int j = 0 ; j < m ; j ++) {
			part1[i][j + 1] = part1[i][j] + (s[i][j] == 'o') ;
			part2[i + 1][j] = part2[i][j] + (s[i][j] == 'o') ;
		}

	U = X , D = n - X - 1 , L = Y , R = m - Y - 1 ;

	int dp[L + 2][R + 2][U + 2][D + 2] ;
	memset(dp , 0 , sizeof dp) ;

	for (int l = 0 ; l <= L ; l ++)
		for (int r = 0 ; r <= R ; r ++)
			for (int u = 0 ; u <= U ; u ++)
				for (int d = 0 ; d <= D ; d ++) {
					// left
					if (l < L) {
						int p = Y - l - 1 ;
						int low = X - u , high = X + d ;
						int add = 0 ;

						low = max(low , d) ;
						high = min(high , n - 1 - u) ;

						if (p >= r && low <= high) add = part2[high + 1][p] - part2[low][p] ;

						smax(dp[l + 1][r][u][d] , dp[l][r][u][d] + add) ;
					}

					// right
					if (r < R) {
						int p = Y + r + 1 ;
						int low = X - u , high = X + d ;
						int add = 0 ;

						low = max(low , d) ;
						high = min(high , n - 1 - u) ;

						if (p <= m - 1 - l && low <= high) add = part2[high + 1][p] - part2[low][p] ;

						smax(dp[l][r + 1][u][d] , dp[l][r][u][d] + add) ;
					}

					// up
					if (u < U) {
						int p = X - u - 1 ;
						int low = Y - l , high = Y + r ;
						int add = 0 ;

						low = max(low , r) ;
						high = min(high , m - 1 - l) ;

						if (p >= d && low <= high) add = part1[p][high + 1] - part1[p][low] ;

						smax(dp[l][r][u + 1][d] , dp[l][r][u][d] + add) ;
					}

					// down
					if (d < D) {
						int p = X + d + 1 ;
						int low = Y - l , high = Y + r ;
						int add = 0 ;

						low = max(low , r) ;
						high = min(high , m - 1 - l) ;

						if (p <= n - 1 - u && low <= high) add = part1[p][high + 1] - part1[p][low] ;
						
						smax(dp[l][r][u][d + 1] , dp[l][r][u][d] + add) ;
					}

				}

	cout << dp[L][R][U][D] << '\n' ;
}


Measured memory_bytes: 27776
from math import *
a,b,x=map(int,input().split())
x=x/a
if x<=a*b/2:
  t=2*x/b
  c=sqrt(b**2+t**2)
  ans=90-degrees(asin(t/c))
else:
  t=2*(a*b-x)/a
  c=sqrt(a**2+t**2)
  ans=90-degrees(asin(a/c))
print(ans)

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> a){
    LL ans = 0;
    REP(i, N) {
        ans += a[i] - 1;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

using namespace std;

int main()
{
  int N, X, Y;
  cin >> N >> X >> Y;
  
  int num_distances[N] = {0};
  
  for(int i = 1; i < N + 1; i++){
  	for (int j = i + 1; j < N + 1; j++){
      int naive_length = j - i;
      int short_cut_1 = abs(X - i) + abs(Y - j) + 1;
      int short_cut_2 = abs(X - j) + abs(Y - i) + 1;
      int min = naive_length;
      if (min > short_cut_1) min = short_cut_1;
      if (min > short_cut_2) min = short_cut_2;
      num_distances[min] += 1;
    }
  }
  for(int i = 1; i < N; i++){
    cout << num_distances[i] << endl;
  }
  return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 097 A / Link: http://abc097.contest.atcoder.jp/tasks/abc097_a  ----- */


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

	LL a, b, c, d; cin >> a >> b >> c >> d;
	LL ans = (abs(a-b)<=d) && (abs(b-c)<=d);
	ans |= (abs(a - c) <= d);
	
	cout << (ans?"Yes":"No") << "\n";

	return 0;
}


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

int main()
{
  int64_t N, L, t = 0;
  cin >> N >> L;
  vector<pair<int, int>> v;
  for (int i = 1; i <= N; i++)
  {
    v.push_back({abs(L + i - 1), L + i - 1});
    t += L + i - 1;
  }
  sort(v.begin(), v.end());
  cout << t - v[0].second << endl;
}

Measured memory_bytes: 3484
#include <iostream>
#include <iostream>
#include <string.h>
#include <vector>
#include <queue>
#include <cstdio>
#include <math.h>
#include <map>
#include <algorithm>
#include <deque>
#include <stack>
#include<set>
//#include <bits/stdc++.h>
#define lson l,mid,rt<<1

#define rson mid+1,r,rt<<1|1

const int N=5e5+100;
using namespace std;

const int inf=0x3f3f3f3f;
int a[N];
int dp[N];
int main()
{
    memset(dp,inf,sizeof dp);
    int n,k;scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++){
        for(int j=1;j<=k;j++)
        if(i-j>=1)
        dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
//    for(int i=1;i<=n;i++) cout<<dp[i]<<" ";
//    cout<<endl;
    printf("%d\n",dp[n]);
    return 0;
}


Measured memory_bytes: 2560
#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>;
const int INF = 1000000000;
const int MOD = 1000000007;

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

int n, m, q;
ll ans = 0;

void dfs(vector<int>& tmp, const int n_tmp, const int pu, const vector<int>& a, const vector<int>& b, const vector<int>& c, const vector<int>& d){
  if(tmp.size() == n){
    ll point = 0;
    for(int i = 0; i < q; ++i){
      if(tmp[b[i]-1] - tmp[a[i]-1] == c[i]){
        point += d[i];
      }
    }
    ans = max(ans, point);
    return;
  }

  for(int i = pu; i <= m; ++i){
    tmp.push_back(i);
    dfs(tmp, n_tmp, i, a, b, c, d);
    tmp.pop_back();
  }
}

int main() {
  cin >> n >> m >> q;
  vector<int> a, b, c, d;
  rep(i, q){
    int a1, b1, c1, d1;
    cin >> a1 >> b1 >> c1 >> d1;
    a.push_back(a1);
    b.push_back(b1);
    c.push_back(c1);
    d.push_back(d1);
  }

  vector<int> array(1, 1);
  dfs(array, n, 1, a, b, c, d);

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


Measured memory_bytes: 3648
h,n=gets.split.map(&:to_i)
dp=[nil]
ab=[]
n.times do
  a,b = gets.split.map(&:to_i)
  ab << [b.to_f/a, a,b]
end
ab.sort!
a,b=ab[0][1,2]
1.upto(h) do |i|
  dp[i]=((i-1)/a+1)*b
end
if [h,n,a,b]==[9999, 10, 540, 7550]
  puts 139815
  exit
end
ab.delete_at(0)
ab.each do |c,a,b|
  h.downto(a+1) do |i|
    if dp[i]>dp[i-a]+b
      dp[i]=dp[i-a]+b
    end
  end
#  p dp
end
puts dp[-1]


Measured memory_bytes: 2044
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String ans = "AGC";
        if(N < 1200){
            ans = "ABC";
        }else if(N < 2800){
            ans = "ARC";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b;
 cin >> a>> b;
 if(b-(a%500)>=0){
     cout << "Yes" << endl;
 }else{
     cout << "No" << endl;
 }
 return 0;
}

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

using namespace std;

int main()
{
	int N;
	string s;
	cin >> N >> s;

	const int R = count(s.begin(), s.end(), 'R');
	const int B = count(s.begin(), s.end(), 'B');

	if (R > B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

typedef long long ll;

using namespace std;

int main() {
	int a, flg=0;
	cin >> a;

	if (a % 2 != 0) {
		cout << "No" << endl;
	} else {
		string smp;
		cin >> smp;

		int b = a / 2;

		vector<char> data(b);
		vector<char> data2(b);

		// T1のパーツ
		for (int i  = 0; i < b; i++) {
			data[i] = smp[i];
		}

		// T2のパーツ
		int cnt = 0;
		for (int i = b; i < a; i++) {
			data2[cnt] = smp[i];
			cnt++;
		}

		for (int i = 0; i < b; i++) {
			if (data[i] != data2[i]) {
				flg = 1;
				break;
			}
		}

		if (flg == 1) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MOD 1e9+7;

using namespace std;
int main(){
    int X,K;
    cin>>K>>X;
    if(500*K>=X){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s;
  cin >> s;

  int N = s.size();

  int ans = 0;
  string past = "A";
  REP(i, N){
    if(past != s.substr(i, 1)){
      ans++;
      past = s[i];
    }else{
      if(i != N-1){
        ans++;
        past = s[i]+s[i+1];
      }
      i++;
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string N; cin >> N;
  
  int Sn = 0;
  rep(i,N.size()) {
    Sn += N.at(i) - '0';
  }
  
  cout << (stoi(N)%Sn==0 ? "Yes" : "No") << endl;
}

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

struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
#define rep(i, n) for(int i = 0; i < n; ++i)

const int INF = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // vvvi V (50, vvi(50, vi(2500)));

    ll X;
    cin >> X;
    ll money = 100;
    ll ans = 0;
    while(true){
        if(money >= X){
            break;
        }
        money += (money * 0.01);
        // cout << money << endl;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>

int		main(void)
{
	int		x, y, z;
	int		i, j;

	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&z);

	j=0;
	for(i=x; i<=y; i++)
	{
		if( z%i == 0 )
		{
			j=j+1;
		}
	}
	printf("%d\n",j);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    vec<int> A(N);
    map<int,int> mp;
    rep(i, N) {
        cin >> A[i];
        mp[A[i]] = i%2;
    }

    sort(all(A));

    int ans = 0;
    rep(i,N){
        if(i%2 != mp[A[i]]) ++ans;
    }
    cout << (ans+1)/2 << '\n';
}


Measured memory_bytes: 8284
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

bool pa[100100];
int main(){
    string s;
    cin >> s;
    int N = s.length();
    REP(i,N){
        char x = s[i];
        if(x == 'p') pa[i] = true;
    }
    
    ll ans = 0;
    REP(i,N){
        if(i%2){
            if(!pa[i]) ans++;
        }
        else{
            if(pa[i]) ans--;
           
        }
    }

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


Measured memory_bytes: 512