akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
const int maxn = 55;
int a[maxn], b[maxn], c[maxn], d[maxn];
int main(){
    int n,m;
    while(cin >> n >> m){
        for(int i = 1; i <= n; i ++){
            cin >> a[i] >> b[i];
        }
        for(int i = 1; i <= m; i ++){
            cin >> c[i] >> d[i];
        }
        for(int i = 1; i <= n; i++){
            int ans = 1;
            int pos = abs(a[i] - c[1]) + abs(b[i]-d[1]);
            for(int j = 2; j <= m; j ++){
                int pos1 = abs(a[i] - c[j]) + abs(b[i]-d[j]);
                //cout << pos1 << endl;
                if(pos1 < pos){
                    //cout << pos1 << ' ' << pos << endl;
                    ans = j;
                    pos = pos1;
                //    cout << pos1 << ' ' << pos << endl;
                //    cout << j << endl;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	long long N,x;
	cin >> N >> x;
	long long a[N];
	long long count = 0;
	for(long long i=0;i < N; i++){
		cin >> a[i];
	}
	for(long long i = 1; i < N; i++){
		if(a[i-1] + a[i] > x){
			long long delta = a[i-1] + a[i] - x;
			if(a[i] < delta){
				a[i] = 0;
				a[i-1] -= delta - a[i];
			}else{
				a[i] -= delta;
			}
			count += delta;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int N= 1e5 + 10;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

ll gcd(ll a,ll b)
{
    ll m = max(a, b);
    b = a + b - m, a = m;
    while(a%b!=0)
    {
        ll temp = b;
        b = a % b;
        a = temp;
    }
    return b;
}
int main()
{
    int n, ans;
    cin >> n;
    ans = n % 10;
    if(ans==3)
        cout << "bon" << endl;
    else if(ans==0||ans==1||ans==6||ans==8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	string x;
	cin >> x;
	int przo = 1;
	int q;
	cin >> q;
	vector<char> przod, tyl;
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			przo = 1 - przo;
		} else {
			int f;
			char c;
			cin >> f >> c;
			--f;
			if (f + przo == 1) przod.pb(c);
			else tyl.pb(c);
		}
	}
	vector<char> odp;
	if (przo == 0) {
		// printf("przo: %d, sz: %d, %d\n", przo, sz(przod), sz(tyl));
		swap(przod, tyl);
		reverse(ALL(x));
		// reverse(ALL(przod));
	}
	FORD(i, sz(przod), 0) cout << przod[i];
	cout << x;
	REP(i, sz(tyl)) cout << tyl[i];
	cout << endl;
}

Measured memory_bytes: 976
#import <stdio.h>
int main(){
    int A,B,C,D,E,F;
    scanf("%d %d %d %d %d %d",&A,&B,&C,&D,&E,&F);
    int maxX = A;
    int maxZ = 0;
    double maxZX = 0;
    int x=0;
    while(1){
        if(100*A*x>F){
            break;
        }
        int y=0;
        while(1){
            int X = 100*A*x+100*B*y;
            if (X>F) {
                break;
            }
            int z=0;
            while(1){
                if (X+C*z > F || 100*C*z > E*X) {
                    break;
                }
                int w=0;
                while(1){
                    int Z = C*z+D*w;
                    if (X+Z>F || 100*Z > E*X) {
                        break;
                    }
                    double ZX = (double)Z/X;
                    if (ZX >= maxZX) {
                        maxX = X;
                        maxZ = Z;
                        maxZX = ZX;
                    }
                    w++;
                }
                z++;
            }
            y++;
        }
        x++;
    }
    printf("%d %d",maxX+maxZ, maxZ);
}


Measured memory_bytes: 7116
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#define maxn 2000005
#define ll long long
#define inf 0x3f3f3f3f
#define P 1000000007
using namespace std;
int X[7],Y[7];
namespace Math{
	int fac[maxn],facinv[maxn];
	int C(int n,int m){return 1ll*fac[n]*facinv[m]%P*facinv[n-m]%P;}
	int F(int x,int y){return C(x+y,x);}
	int ksm(int x,int k){
		int ret=1;
		while(k){if(k&1)ret=1ll*ret*x%P;k>>=1,x=1ll*x*x%P;}
		return ret;
	}
	void init(){
		fac[0]=facinv[0]=1;
		for(int i=1;i<=2000000;++i)fac[i]=1ll*fac[i-1]*i%P;
		facinv[2000000]=ksm(fac[2000000],P-2);
		for(int i=1999999;i>=1;--i)facinv[i]=1ll*facinv[i+1]*(i+1)%P;
	}
	int f[3][3];
	int cal(int x1,int y1,int x2,int y2){
		f[1][1]=F(x1,y1),f[1][2]=F(x1,y2+1),f[2][1]=F(x2+1,y1),f[2][2]=F(x2+1,y2+1);
		return ((1ll*f[2][2]+f[1][1]-f[1][2]-f[2][1])%P+P)%P;
	}
}
int main(){
	Math::init();
	for(int i=1;i<=6;++i)scanf("%d",&X[i]);
	for(int i=1;i<=6;++i)scanf("%d",&Y[i]);
	int x,y;
	ll ret=0;
	x=X[3];
	for(y=Y[3];y<=Y[4];++y)ret-=1ll*Math::cal(y-Y[2],x-X[2]-1,y-Y[1],x-X[1]-1)*Math::cal(Y[5]-y,X[5]-x,Y[6]-y,X[6]-x)%P*(x+y)%P,ret+=(ret<0)?P:0;
	y=Y[3];
	for(x=X[3];x<=X[4];++x)ret-=1ll*Math::cal(x-X[2],y-Y[2]-1,x-X[1],y-Y[1]-1)*Math::cal(X[5]-x,Y[5]-y,X[6]-x,Y[6]-y)%P*(x+y)%P,ret+=(ret<0)?P:0;
	x=X[4];
	for(y=Y[3];y<=Y[4];++y)ret+=1ll*Math::cal(y-Y[2],x-X[2],y-Y[1],x-X[1])*Math::cal(Y[5]-y,X[5]-x-1,Y[6]-y,X[6]-x-1)%P*(x+y+1)%P,ret-=(ret>=P)?P:0;
	y=Y[4];
	for(x=X[3];x<=X[4];++x)ret+=1ll*Math::cal(x-X[2],y-Y[2],x-X[1],y-Y[1])*Math::cal(X[5]-x,Y[5]-y-1,X[6]-x,Y[6]-y-1)%P*(x+y+1)%P,ret-=(ret>=P)?P:0;
	printf("%lld",ret);
	return 0;
}

Measured memory_bytes: 16000
s = gets.chomp
t = gets.chomp
sz = s.size
tz = t.size
(sz-tz).downto(0) do |i|
    ok = true
    tz.times do |j|
        ok = false if s[i+j] != '?' && s[i+j] != t[j]
    end
    if ok
        tail = s[i+tz..-1]
        tail = "" if tail.nil?
        # puts [s[0,i],t ,tail].join(" ")
        ans = s[0,i] + t + tail
        sz.times do |j|
            ans[j] = "a" if ans[j] == "?"
        end
        puts ans
        exit
    end
end
puts "UNRESTORABLE"



Measured memory_bytes: 1788
from fractions import gcd
import math

A, B = map(int, input().split())

N = gcd(A, B)

def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

factor = prime(N)
print(len(factor) + 1)

Measured memory_bytes: 5688
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    a,b = LI()
    print(math.ceil((a+b)/2))

#B
def B():
    s = S()
    t = S()
    s.sort()
    t.sort()
    t = t[::-1]
    l = [s,t]
    l.sort()
    if s == t:
        print("No")
    elif l[0] == s:
        print("Yes")
    else:
        print("No")
#C
def C():
    n = I()
    d = defaultdict(int)
    a = LI()
    for i in a:
        d[i] += 1
    ans = 0
    for i in d.keys():
        if i <= d[i]:
            ans += d[i]-i
        else:
            ans += d[i]
    print(ans)
#D
def D():
    s = input().split("T")
    x,y = LI()
    a,b = [0,0]
    l = len(s)
    dp_x = [-1 for i in range(17000)]
    dp_y = [-1 for i in range(17000)]
    dp_x[len(s[0])+8000] = 1
    dp_y[8000] = 0
    c,d = [1,0]
    q = deque()
    for i in range(1,l):
        if i%2 == 0:
            k = len(s[i])
            if k > 0:
                for j in range(17000):
                    if dp_x[j] == c:
                        q.append(j)
                c += 1
                while q:
                    j = q.pop()
                    if j+k < 17000:
                        dp_x[j+k] = min(c,dp_x[j]+1)
                    if j-k >= 0:
                        dp_x[j-k] = min(c,dp_x[j]+1)
    for i in range(1,l):
        if i%2 == 1:
            k = len(s[i])
            if k > 0:
                for j in range(17000):
                    if dp_y[j] == d:
                        q.append(j)
                d += 1
                while q:
                    j = q.pop()
                    if j+k < 17000:
                        dp_y[j+k] = min(d,dp_y[j]+1)
                    if j-k >= 0:
                        dp_y[j-k] = min(d,dp_y[j]+1)
    if dp_x[x+8000] == c and dp_y[y+8000] == d:
        print("Yes")
    else:
        print("No")
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 46300
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;

int main (){
  int n;    cin >> n;
  vector <int> a(n+1);
  vector <int> b(n);
  rep(i,n+1) {
      cin >> a.at(i);
  }

  rep(i,n){
      cin >> b.at(i);
  }

  for(int i=0;i<n;i++){
      if(a.at(i)+a.at(i+1) <= b.at(i)){//隣の町まで全部倒せる
       cnt += a.at(i)+a.at(i+1);
          a.at(i) = 0;
          a.at(i+1) = 0;
         
      }else if(a.at(i) >= b.at(i)){//i番目の町のモンスターを倒すのが限界
          a.at(i) = a.at(i)-b.at(i); 
          cnt += b.at(i);
      }else {//自分の町と隣町の一部を倒せる
          a.at(i+1) = a.at(i+1) + a.at(i) - b.at(i);
          a.at(i) = 0;
          cnt += b.at(i);
      }
  }
  
cout << cnt << endl;

}

Measured memory_bytes: 1024
// problem: "https://atcoder.jp/contests/abc143/tasks/abc143_d"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll binarySearch(vector<ll>&V,ll l,ll r,ll n)
{
    if(l > r)
        return r;

    ll m = (l+r)/2;
    if(V[m] == n)
        return max(m,binarySearch(V,m+1,r,n));

    else if(V[m] > n)
        return binarySearch(V,m+1,r,n);

    return binarySearch(V,l,m-1,n);
}

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

    ll i,x;
    vector<ll>V;

    for(i=0;i!=n;i++)
    {
        cin>>x;
        V.push_back(x);
    }

    ll j,c;
    c = 0;

    sort(V.begin(),V.end(),greater<ll>());

    for(i=0;i!=n-2;i++)
        for(j=i+1;j!=n-1;j++)
            c += binarySearch(V,j+1,n-1,V[i]-V[j]+1)-j;

    cout<<c;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        int N = cin.Int();
        var a = cin.ArrayInt(N);

        int M = N;
        M -= 1;
        while (M >= 0)
        {
            Console.Write(a[M] + " ");
            M -= 2;
        }

        if(N % 2 == 0)
        {
            M = 0;
            while(M < N)
            {
                Console.Write(a[M] + " ");
                M += 2;
            }
        }
        else
        {
            M = 1;
            while (M < N)
            {
                Console.Write(a[M] + " ");
                M += 2;
            }
        }
        Console.WriteLine();
        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 36112
/*  -*- coding: utf-8 -*-
 *
 * r.cc: R - Walk
 */

#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 MAX_N = 50;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef int mat[MAX_N][MAX_N];

/* global variables */

mat ma, mb, mc;

/* subroutines */

inline void initmat(const int n, mat a) { memset(a, 0, sizeof(mat)); }
inline void unitmat(const int n, mat a) {
  initmat(n, a);
  for (int i = 0; i < n; i++) a[i][i] = 1;
}

inline void copymat(const int n, const mat a, mat b) {
  memcpy(b, a, sizeof(mat));
}

inline void addmat(const int n, const mat a, const mat b, mat c) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) c[i][j] = (a[i][j] + b[i][j]) % MOD;
}

inline void mulmat(const int n, const mat a, const mat b, mat c) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      c[i][j] = 0;
      for (int k = 0; k < n; k++)
        c[i][j] = (c[i][j] + (ll)a[i][k] * b[k][j] % MOD) % MOD;
    }
}

inline void powmat(const int n, const mat a, ll b, mat c) {
  static mat s, t;
  copymat(n, a, s);
  unitmat(n, c);

  while (b > 0) {
    if (b & 1) {
      mulmat(n, c, s, t);
      copymat(n, t, c);
    }

    mulmat(n, s, s, t);
    copymat(n, t, s);
    b >>= 1;
  }
}

void printmat(const int n, const mat a) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) putchar(' ');
      printf("%d", a[i][j]);
    }
    putchar('\n');
  }
}

/* main */

int main() {
  int n;
  ll k;
  scanf("%d%lld", &n, &k);

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &ma[i][j]);

  powmat(n, ma, k, mb);

  int sum = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) sum = (sum + mb[i][j]) % MOD;

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    for i in range(1, 10):
        j = N / i
        if j.is_integer() and 1 <= j <= 9:
            print('Yes')
            exit()
    else:
        print('No')


if __name__ == '__main__':
    main()


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{	
	int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}
	vector<int> T(D);
	int k = 0;
	fx(26) {
		if (k < table[0][x]) {
			T[0] = x+1;
			k = table[0][x];
		}
	}
	fx(D-1) {
		ll res = -LLONG_MAX;
		int las = 0;
		fy(26) {
			ll sum = 0;
			sum += table[x + 1][y];
			fz(26){
				if (y == z) { continue; }
				sum -= C[z] * (x + 1 - Las[z]);
			}

			if (res<sum) {
				res = sum;
				T[x + 1] = y+1;
				las = y;
			}
		}
		Las[las] = x + 1;
	}
	fx(D) {
		ce(T[x])
	}
    return 0;
}



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

int main() {
  int64_t a, b;
  cin >> a >> b;
  if (a*b <= 0) {
    cout << "Zero" << endl;
  } else if (a > 0) {
    cout << "Positive" << endl;
  } else if (b < 0) {
    if ((b-a+1)%2 == 0) {
      cout << "Positive" << endl;
    } else {
      cout << "Negative" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<queue>
#include<vector>
#include<tuple>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
bool comparator(P a, P b) {
	return a.first / a.second < b.first / b.second;
}

int main() {
	map<string, int> m;
	int n, k;
	cin >> n;

	string s;
	rep(i, n) {
		cin >> s
			;
		m[s] += 1;
	}
	cin >> k;
	rep(i, k) {
		cin >> s;
		m[s] -= 1;
	}
	ll max = 0;
	for (auto&& kv : m) {
		if (kv.second > max)max = kv.second;
	}
	cout << max << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N, Q; cin >> N >> Q;
    vec A(N), X(Q);
    readv(A);
    readv(X);
    SORT(A);
    vec sumA(N + 1);
    sumA[0] = 0;
    REP(i, N) sumA[i + 1] = sumA[i] + A[i];
    vec sumA2(N + 2);
    sumA2[0] = 0;
    sumA2[1] = 0;
    REP(i, N) sumA2[i + 2] = sumA2[i] + A[i];

    REP(q, Q){
        int t1 = 1, t2 = N;
        while(t2 - t1 > 1){
            int t = (t1 + t2) / 2;
            //int d = A[N - 1] - A[N - t];
            int d = llabs(X[q] - A[N - t]);
            int n = N - t - Lower_bound(A, X[q] - d);
            if(n >= t - 1) t1 = t;
            else t2 = t;
        }
        int ans = sumA[N] - sumA[N - t1];
        int r = N - 2 * t1;
        ans += sumA2[r - 1 + 2];
        //cout << t1 << "," << ans << endl;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
//けんちょんさんの記事を参考に

//ＤＰ　テーブル
long long dp[100010]={0};

int main(){

    for ( int i = 0 ; i < 30 ; i++){
    int n; cin >> n;
    if ( n == 0 ) return 0;

    //初期化・初期条件
    dp[10010] = {};
    dp[0] = 1;

    //ループ
    for ( int j = 0 ; j <= n ; j++ ){
        if ( j==1 ) dp[j] = dp[j-1];
        if ( j==2 ) dp[j] = dp[j-1] + dp[j-2];
        if ( j>2 ) dp[j] = dp[j-1] + dp[j-2] + dp[j-3];
    }
    cout << ( ( dp[n] - 1) / (365*10) ) + 1 << endl;
    }
}


Measured memory_bytes: 3108
import sys
from itertools import accumulate
from bisect import bisect
def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    ac = [0] + list(accumulate(A))

    def calc(lst): return abs(max(lst) - min(lst))
    def sm(l,r): return ac[r+1] - ac[l]

    ans = 10**18
    Q_left, S_left = 1, 3
    for R_left in range(2,N-1):
        P, Q = ac[Q_left], sm(Q_left, R_left-1)
        for nql in range(Q_left+1, R_left):
            nP, nQ = ac[nql], sm(nql, R_left-1)
            if calc([nP, nQ]) > calc([P, Q]): break
            Q_left, P, Q = nql, nP, nQ
        R, S = sm(R_left, S_left-1), sm(S_left, N-1)
        for nsl in range(S_left+1, N):
            nR, nS = sm(R_left, nsl-1), sm(nsl, N-1)
            if calc([nR, nS]) > calc([R, S]): break
            S_left, R, S = nsl, nR, nS
        ans = min(ans, calc([P,Q,R,S]))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 91160
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let ans = min(a * n, b);
    println!("{}", ans);
}


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

d = {}
d_W = {}

for i in range(1, M+1):
    p, S = list(map(str, input().split()))
    if S == "WA":
        if p not in d_W.keys():
            d_W[p] = 1
        else:
            d_W[p] += 1
    else:
        if p not in d_W.keys():
            d[p] = 0
        elif p not in d.keys():
            d[p] = d_W[p]

print(len(d), sum(d.values()))


Measured memory_bytes: 17232
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();

    int ans = n + n*n + n*n*n;



    System.out.println(ans);

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35636
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut f: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut fi: Vec<char> = Vec::new();
        for _ in 0..10 {
            fi.push(iterator.next().unwrap().parse().unwrap());
        }
        f.push(fi);
    }
    let mut p: Vec<Vec<isize>> = Vec::new();
    for _ in 0..n {
        let mut pi: Vec<isize> = Vec::new();
        for _ in 0..11 {
            pi.push(iterator.next().unwrap().parse().unwrap());
        }
        p.push(pi);
    }

    let mut ans: isize = std::isize::MIN;
    for i in 1..(1<<10) {
        let q: Vec<char> = binary_string(i, 10).chars().collect();
        let mut current = 0;
        for j in 0..n {
            let mut count = 0;
            for k in 0..10 {
                if q[k] == '1' && f[j][k] == '1' {
                    count += 1;
                }
            }
            current += p[j][count]
        }
        ans = max(ans, current);
    }
    ans.to_string()
}

fn binary_string(n: usize, keta: usize) -> String {
    return format!("{:0>1$b}", n, keta);
}


Measured memory_bytes: 2260
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int h,w;cin>>h>>w;
    vector<string> s(h);
    REP(i,h){
        cin>>s[i];
    }

    bool f = true;

    REP(i,h){
        REP(j,w){
            if(s[i][j] != '#'){
                continue;
            }

            if(i > 0 && s[i-1][j] == '#'){
                continue;
            }
            if(i < h-1 && s[i+1][j] == '#'){
                continue;
            }
            if(j > 0 && s[i][j-1] == '#'){
                continue;
            }
            if(j < w-1 && s[i][j+1] == '#'){
                continue;
            }

            f = false;
        }
    }


    if(f){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
N=int(input())
a=[int(i) for i in input().split()]
l=0
f=0
n=0
for i in range(N):
  if abs(a[i])>l:
    if a[i]>0:
      f=1
      n=i
      l=abs(a[i])
    else:
      f=-1
      n=i
      l=abs(a[i])
      
if f==0:
  print(0)
elif f==1:
  print(2*N-2)
  for i in range(N):
    if i!=n:
      print(n+1,i+1)
  for i in range(N-1):
    print(i+1,i+2)
elif f==-1:
  print(2*N-2)
  for i in range(N):
    if i!=n:
      print(n+1,i+1)
  for i in range(N-1)[::-1]:
    print(i+2,i+1)


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int a, b, c;


int main(void) {

	cin >> a >> b >> c;
	string ans;
	ans = "No";
	if (c - a - b <= 0) { ans = "No"; }
	else {
		long long int tmp = c - a - b;
		if (tmp*tmp > a*b * 4) { ans = "Yes"; }
	}

	cout << ans << endl;

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}

int fun(int x, int y, int z){
    return (x*x + y*y + z*z + x*y + y*z + z*x);
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  
    int T=1;
    //cin >> T;
    while(T--){
        int n;
        cin>>n;
        int cnt[n+1]={0}, z;

        rep_a(i,1,101){
            rep_a(j,1,101){
                rep_a(k,1,101){
                    z  = fun(i,j,k);
                    if(z<=n) cnt[z]++;
                }
            }
        }
        rep_a(i,1,n+1) cout<<cnt[i]<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3824
from collections import deque
n, m = map(int, input().split())
dat_m = [deque([]) for x in range(n + 1)]

for i in range(m):
    a, b = map(int, input().split())
    dat_m[a].append(b)

c = False
for i in dat_m[1]:
    if n in dat_m[i]:
        c = True

print("POSSIBLE" if c else "IMPOSSIBLE")

Measured memory_bytes: 161164
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){

    int d, k, n;
    cin>>d>>k;
    
    if(d==0){
        n=1;
    }else if(d==1){
        n=100;
    }else if(d==2){
        n=10000;
    }
    
    
    if(k%100==0){
        cout<<n*(k+1)<<endl;
    }else{
        cout<<n*k<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
int gcd(int x, int y) {
	if (y == 0)return x;
	else return gcd(y, x % y);
}
int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				int x = gcd(i, j);
				x = gcd(x, k);
				sum += (ll)x;
			}
		}
	}

	cout << sum << '\n';

}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,fa[2][SZ],ro[2];
vector<int> ch[2][SZ];
void re(int g)
{
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&fa[g][i]);
		if(fa[g][i]<0) ro[g]=i;
		else ch[g][fa[g][i]].pb(i); 
	}
}
Edg
int r[SZ],dd[SZ];
void eul(int c)
{
	for(int i=fst[c];i;i=nxt[i])
	{
		fst[c]=i;
		if(r[i]||r[i^1]) continue;
		r[i]=1;
		eul(vb[i]);
		i=fst[c];
	}
	fst[c]=0;
}
int main()
{
	scanf("%d",&n);
	re(0); re(1);
	for(int i=1;i<=n;++i)
		if((ch[0][i].size()^ch[1][i].size())&1)
		{
			puts("IMPOSSIBLE");
			return 0;
		}
	puts("POSSIBLE"); M=1;
	for(int i=1;i<=n;++i)
		if(fa[0][i]>0) adde(fa[0][i],i);
		else adde(i,n+n+1);
	for(int i=1;i<=n;++i)
		if(fa[1][i]>0) adde(fa[1][i]+n,i+n);
		else adde(i+n,n+n+1);
	for(int i=1;i<=n;++i)
		if(!(ch[0][i].size()&1)) adde(i,i+n),dd[i]=M-1;
	eul(n+n+1);
	for(int i=1;i<=n;++i)
	{
		if(ch[0][i].size()&1) printf("0 ");
		else printf("%d ",r[dd[i]]?1:-1);
	}
}


Measured memory_bytes: 55040
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N;
	cin >> N;
	
	map<int, int> mp;

	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		++mp[a];
	}

	bool flags = true;
	int i = 0;
	if (N % 2 == 0) {
		i = 1;
	}
	else {
		if (mp[0] != 1) {
			cout << 0 << endl;
			return 0;
		}
		i = 2;
	}
	for (; i < N; i += 2) {
		if (mp[i] != 2) {
			cout << 0 << endl;
			return 0;
		}
	}


	long long ans = 1;
	for (int i = 0; i < N / 2; ++i) {
		ans = (ans * 2) % MOD;
	}

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

Measured memory_bytes: 6484
import sys

lines = sys.stdin.readlines()

N = int(lines[0])
A, B = map(int, lines[1].split())
Ps = [int(n) for n in lines[2].split()]

Ps.sort()

count = 0

p_p1 = [x for x in Ps if x <= A]
p_p2 = [x for x in Ps if (x >= A + 1) and (x <= B)]
p_p3 = [x for x in Ps if x >= B + 1]

#print(p_p1)
#print(p_p2)
#print(p_p3)

print(min([len(p_p1), len(p_p2), len(p_p3)]))

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

int main() {
int64_t H,W;
cin >> H >> W;
int64_t count = 0;
int64_t koma = H*W;

 if (H == 1 || W == 1) {
  count = 1;
} else if (koma%2 == 0) {
  count = H*W/2;
} else if (koma%2 == 1) {
count = H*W/2 +1;
}

cout << count << endl;

return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
a=0
mx=0
p=0
while a!=n-1:
    if h[a]>=h[a+1]:
        p+=1
        a+=1
    else:
        if p>mx:
            mx=p  
            a+=1
            p=0
        else:
            a+=1
            p=0
print(-min(-mx,-p))

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
  int X,Y = 0;
  cin >> X >> Y;
  //a + b = X, 2a + 4b = Y
  //b = (Y - 2X)/2,a = -(Y - 4X)/2
  if (Y % 2 == 1){
    cout << "No" << endl;
  }else	if(Y - 2*X >= 0 && Y - 4*X <= 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define re register
#define rint register int
#define isdight(c) (c<='9'&&c>='0')
using namespace std;
inline int read()
{
	int x=0;register char c=getchar();int f=1;
	for(;!isdight(c);c=getchar()) if(c=='-') f=-1;
	for(;isdight(c);c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
template <typename ty> inline void write(ty x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+48);
}
const int N = 1000;
ll a,b,c;

int main()
{
	cin >> a >> b;
	printf("%lld",max(a+b,max(a-b,a*b)));
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

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

	int mi = N;
	rep(i, 0, N)rep(j, 0, N) {
		if (i != j) {
			ll dx = X[i] - X[j];
			ll dy = Y[i] - Y[j];
			int num = 0;
			rep(k, 0, N) {
				int ok = 0;
				rep(l, 0, N) {
					if (k != l) {
						if (X[k] + dx == X[l] && Y[k] + dy == Y[l])ok = 1;
					}
				}
				num += 1 - ok;
			}
			mi = min(num, mi);
		}
	}

	cout << mi << endl;
	
	return 0;
}

Measured memory_bytes: 256
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (w,h,x,y) = get!(f64,f64,f64,f64);
    println!("{} {}", w*h/2.0 , if x==w/2.0&&y==h/2.0 {1} else {0});
}


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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int cmp(string a, string b) {
    if (a.length == b.length) {
        if (a == b) return 0;
        return a < b ? -1 : 1;
    }
    else if (a.length < b.length) {
        return -1;
    }
    return 1;
}

void main() {
    auto a = read!string;
    auto b = read!string;

    auto c = cmp(a, b);
    if (c < 0) writeln("LESS");
    else if (c == 0) writeln("EQUAL");
    else writeln("GREATER");
}


Measured memory_bytes: 256
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
B = [0]*N # 1: top, -1: bottom

inc = 0 # 1: increasing, -1: decreasing
val = A[0]
bot = 0
for i, a in enu(A):
    if i == N-1:
        B[i] = 1
    if inc == 0:
        if val < a:
            B[i-1] = -1
            inc = 1
        elif val == a:
            pass
        else:
            B[i-1] = 1
            inc = -1
    elif inc == 1:
        if val < a:
            pass
        elif val == a:
            pass
        else:
            B[i-1] = 1
            inc = -1
    else:
        if val < a:
            B[i-1] = -1
            inc = 1
        elif val == a:
            pass
        else:
            pass
    val = a

# print(B)
money = 1000
stock = 0
for i, a in enu(A):
    if B[i] == -1:
        # print('buy')
        stock += money//A[i]
        money %= A[i]
    elif B[i] == 1:
        # print('sell')
        money += stock*A[i]
        stock = 0 

print(money)


Measured memory_bytes: 67240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i, N) cin >> t[i];
    long long ans = T;
    rep(i, N - 1) {
        if (t[i] + T < t[i + 1]) ans += T;
        else ans += t[i + 1] - t[i];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
x = int(input())

def main():
    if 400 <= x and x <=599:
        print("8")
    elif 600 <= x and x <= 799:
        print("7")
    elif 800 <= x and x <= 999:
        print("6")
    elif 1000 <= x and x <= 1199:
        print("5")
    elif 1200 <= x and x <= 1399:
        print("4")
    elif 1400 <= x and x <= 1599: 
        print("3")
    elif 1600 <= x and x <= 1799:
        print("2") 
    elif 1800 <= x and x <= 1999:
        print("1")       

main()

Measured memory_bytes: 61812
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  bool hitachi = true;
  cin >> s;
  if(s.length() % 2 == 1){
  	cout << "No" << endl;
  }else{
  	for(int i = 0;i < s.length();i+=2){
    	if(s.at(i) != 'h' || s.at(i+1) != 'i'){
        	hitachi = false;
        }
    }
    if(hitachi){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl; 
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll MOD = (ll)1e9 + 7LL;

ll dp[101][10];
ll fib[101];

/*
	https://misteer.hatenablog.com/entry/ABC113-D-quick
	が参考になった。
	行列を用いた別解もある。
	なぜ、フィボナッチ数を掛けるのか腑に落ちた。
*/

int main()
{
	memset(fib, 0LL, sizeof(fib));
	memset(dp, 0LL, sizeof(dp));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	fib[0] = 1LL;
	fib[1] = 1LL;
	for (int i = 2; i <= 100; ++i){
		fib[i] = (fib[i-1] + fib[i-2]) % MOD;
	} // end for

	int H, W, K; cin >> H >> W >> K;

	dp[0][0] = 1LL;
	for (int h = 0; h < H; ++h){
		for (int i = 0; i < W; ++i){
			if (dp[h][i] != 0LL){
				// そのまま下に行く
				dp[h+1][i] += dp[h][i] * fib[i] * fib[W - i - 1];
				dp[h+1][i] %= MOD;
				if (i == 0){
					// 右に行く
					dp[h+1][i+1] += dp[h][i] * fib[i] * fib[W - i - 2];
					dp[h+1][i+1] %= MOD;
				}else
				if (i == W - 1){
					// 左に行く
					dp[h+1][i-1] += dp[h][i] * fib[i - 1] * fib[W - i - 1];
					dp[h+1][i-1] %= MOD;
				}else{
					dp[h+1][i+1] += dp[h][i] * fib[i] * fib[W - i - 2];
					dp[h+1][i+1] %= MOD;
					dp[h+1][i-1] += dp[h][i] * fib[i - 1] * fib[W - i - 1];
					dp[h+1][i-1] %= MOD;
				} // end if
			} // end for
		} // end for
	} // end for

	ll res = dp[H][K-1];

	cout << res << endl;

	return 0;
}

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

int main(){
  int n,e=0;
  cin >> n;
  int a[n],b[n],c[n+1],d[n+1];
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<n;i++)
    cin >> b[i];
  c[0]=0;
  d[0]=0;
  for(int i=0;i<=n;i++){
    c[i+1] = c[i]+a[i];
    d[i+1] = d[i]+b[i];
  }
  for(int i=0;i<n;i++){
    e = max(c[i+1]-c[0]+d[n]-d[i],e);
  }
  cout << e << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;


int main(){  
  string s;
  cin >> s;
  int n = s.size();
  if(s.substr(0,7)=="keyence"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,6)=="keyenc" && s.substr(n-1)=="e"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,5)=="keyen" && s.substr(n-2)=="ce"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,4)=="keye" && s.substr(n-3)=="nce"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,3)=="key" && s.substr(n-4)=="ence"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,2)=="ke" && s.substr(n-5)=="yence"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,1)=="k" && s.substr(n-6)=="eyence"){ cout << "YES" << endl; return 0; }
  if(s.substr(n-7)=="keyence"){ cout << "YES" << endl; return 0; }


  cout << "NO" << endl;
  return 0;
}

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;

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = c-(a-b);
  
  if (ans < 0) ans = 0;
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256