akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
 
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
 
#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
 
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;}
 
char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
 
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};


int main(){
    ll n; cin >> n;
    vector<ll> es(1e7, 0);
    vector<ll> lis;
    map<ll, ll> mp;
    REP(i, 2, 1e7){
        if(es[i] == 0){
            for(ll l = i * 2; l < 1e7; l += i){
                es[l] = -1;
            }
            for(ll l = i; l < 1e7; l *= i){
                lis.pb(l);
                mp[l]++;
            }
        }
    }
    sort(ALL(lis));
    ll ans = 0;
    REP(i, 0, lis.size()){
        if(n % lis[i] == 0){
            ans++;
            n = n / lis[i];
        }
    }
    if(n > 1){
        ll f = 1;
        REP(i, 2, (ll)pow(n, 0.5)+100){
            if(n % i == 0){
                f = 0;
                break;
            }
        }
        if(mp[n] >= 1){
            f = 0;
        }
        ans += f;
    }
    cout << ans << endl;
}

Measured memory_bytes: 128236
import java.io.*;
import java.lang.Math;
class Main{
    public static void main(String[] args)throws IOException{
        double r, s, l; // s:??¢???, l:??¨?????????
    	InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
        String buf = br.readLine();
        r = Double.parseDouble(buf);
    	s = r * r * Math.PI;
    	l = 2 * r * Math.PI;
        System.out.printf("%.6f %.6f\n", s, l);
    }
}

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

int main(){
  int N,kind,P,W,G,Y;
  string color;
  string result;
  kind = 0;
  P = 0;Y = 0;W = 0;G = 0;
  cin >> N;
  for(int i = 0;i<N;i++){
  	cin >> color;
    if(color == "P"){
    	P = 1;
    }
    if(color == "W"){
    	W = 1;
    }
    if(color == "Y"){
    	Y = 1;
    }
    if(color == "G"){
    	G = 1;
    }  
  }
  kind = (P+W+G+Y);
  if(kind == 4){
  	result = "Four";
  }else if(kind == 3){
    result = "Three";
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#!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
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    #print(ab)
    for i, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
                #print(a,b,c,d)
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return

#D
def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(29):
        t = 2 ** i
        a2 = [A % (2 * t) for A in a]
        b2 = [B % (2 * t) for B in b]
        a2.sort()
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in reversed(a2):
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += (r2 - r1) + (N - r3)
        ans += ((ansb %2 ) << i)
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


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

void solve(int n) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    auto safe = [&](int x, int y) {
        return a <= x && x <= c && b <= y && y <= d;
    };
    auto dist = [&](int x, int y) {
        if (a <= x && x <= c) {
            return min(abs(y - b), abs(y - d));
        }
        if (b <= y && y <= d) {
            return min(abs(a - x), abs(c - x));
        }
        return min(abs(x - a), abs(x - c)) + min(abs(y - b), abs(y - d));
    };
    auto kyori = [&](int xp, int yp, int x, int y) {
        if (safe(xp, yp) && safe(x, y)) return 0;
        if (safe(xp, yp)) return dist(x, y);
        if (safe(x, y)) return dist(xp, yp) - 1;
        return min(dist(x, y) + dist(xp, yp) - 1, abs(x - xp) + abs(y - yp));
    };
    int ans = 0;
    int xp, yp;
    cin >> xp >> yp;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        ans += kyori(xp, yp, x, y);
//        cerr << "Step: " << i << ": " << kyori(xp, yp, x, y) << endl;
        xp = x;
        yp = y;
    }
    cout << ans << endl;
}

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

    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        solve(n);
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define LL long long 
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
int main()
{
	int arr[1005],n;
	while(cin>>n)
	{
		int _min=inf,_max=-1;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			_min=min(_min,arr[i]);
			_max=max(_max,arr[i]);
		}
		cout<<_max-_min<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
# 素因数分解
from collections import defaultdict


def divide(n):  # unsort
    ans = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            ans.append(i)
            if n // i == i:
                continue
            ans.append(n // i)
    return ans


ans = 1
soin = divide(m)
soin.sort(reverse=True)
for num in soin:
    if num * n <= m:
        ans = num
        break

print(ans)


Measured memory_bytes: 38640
#include <cstdio>
#include <utility>
#include <cctype>
#include <string>
#include <deque>
#include <unordered_map>
#include <iostream>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
	int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	unordered_map<char, int> m;
	{
		int i {26};
		for (char c : " .,-'?")
			m[c] = i++;
	}
	string n = "____________ EP_D___CKIR___________LOST_F______________________'?W,____________H.___________________A__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________Z-XY____JMBGUVNQ";
	for (string s; getline(cin, s);) {
		deque<bool> d;
		for (char c: s) {
			int t = isalpha(c) ? c - 'A' : m[c];
			for (int i = 4; i >= 0; i--)
				d.push_back((t >> i) & 1);
		}
		while (!d.empty()) {
			int i = 0;
			for (;d.size() && n[i] == '_';) {
				bool t = d.front();
				d.pop_front();
				i = i * 2 + 1 + t;
			}
			if (n[i] != '_')
				out(n[i]);
		}
		outl();
	}
}


Measured memory_bytes: 3148
#include<stdio.h>
int main(void)
{
  int n,x;
  int num[10000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  x=n-1;
  for(int i=x;i>=0;i--){
   if(x==i){
     printf("%d",num[i]);
   }else{
     printf(" %d",num[i]);
   }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2060
class Dice():
	def __init__(self, label):
		self.d = label
	
	def roll(self, drt):
		if drt == 'N':
			self.d[1], self.d[2], self.d[6], self.d[5] = self.d[2], self.d[6], self.d[5], self.d[1]
		elif drt == 'E':
			self.d[1], self.d[3], self.d[6], self.d[4] = self.d[4], self.d[1], self.d[3], self.d[6]
		elif drt == 'S':
			self.d[2], self.d[6], self.d[5], self.d[1] = self.d[1], self.d[2], self.d[6], self.d[5]
		elif drt == 'W':
			self.d[4], self.d[1], self.d[3], self.d[6] = self.d[1], self.d[3], self.d[6], self.d[4]
	
	def printl(self, lct):
		print(self.d[lct])
	
	def rot(self, drc):
		self.roll('N')
		if drc == 'r':
			self.roll('E')
		elif drc == 'l':
			self.roll('W')
		self.roll('S')
		
label = [0]	
label.extend(list(map(int, input().split())))
dice1 = Dice(label)
q = int(input())

ST = 'NNNNEEE'
SF = 'rrr'

for i in range(q):
	s = list(map(int, input().split()))
	for j in range(7):
		if dice1.d[1] == s[0]:
			break
		dice1.roll(ST[j])
	for k in range(3):
		if dice1.d[2] == s[1]:
			break
		dice1.rot(SF[k])
	dice1.printl(3)

Measured memory_bytes: 7836
n=int(input())
arr=[]
for i in range(n):
	a,b=map(int,input().split())
	arr.append((b,a))
arr.sort()
time=0
flag=0
for i in range(n):
	if(time+arr[i][1]>arr[i][0]):
		flag=1
		break
	else:
		time+=arr[i][1]

if(flag==0):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 29444
a=int(input())
a1 = a // 2
b1=list(input().split( ))
b=list(map(int, b1))
d=[]

s1=0
for j in range(a1):
    s1 += b[(2*j + 1)]
x1 = sum(b) - 2 * s1
d.append(x1)

for k in range(a-1):
    x = 2 * b[k] - d[k]
    d.append(x)

print(' '.join(map(str, d)))


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

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	int d, c;
	cin >> d >> c;
	c /= 100;
	vector<PAIR> p;
	REP(i, d) {
		int t1, t2;
		cin >> t1 >> t2;
		p.emplace_back(PAIR(t1, t2/100));
	}

	int mn = 1e7;
	//(1&i>>j)
	REP(i, 1 << d) {
		int score = 0;
		int n = 0;
		REP(j, d) {
			int bit = 1 & i >> j;
			if (bit == 1) {
				score += p[j].second;
				score += p[j].first*(j + 1);
				n += p[j].first;
			}
		}

		RREP(j, d) {
			if (score >= c) { mn = min(mn, n); break; }
			int bit = 1 & i >> j;
			if (bit == 0) {
				REP(t, p[j].first - 1) {
					score += (j + 1);
					++n;
					if (score >= c) { mn = min(mn, n); break; }
				}
			}
		}
	}
	cout << mn << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct nd{ 
  int key;
  struct nd *next;
  struct nd *prev;
};
typedef struct nd * ndPointer;
ndPointer nil;
ndPointer listSearch(int key){
  ndPointer i;
  for(i=nil;i->next!=nil;i=i->next){
  if(i->next->key==key)return i->next;
  }
  return NULL;
} 
void init(){
  nil = malloc(sizeof(struct nd));
  nil->next = nil; 
  nil->prev = nil;
}
void printList(){ 
  ndPointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0) printf(" "); 
    printf("%d", cur->key);
    cur = cur->next; isf = 0; 
  } 
  printf("\n");
}
void deleteFirst(){ 
  ndPointer t = nil->next;
  if ( t == nil )return;
  deletend(t);
}
void deletend(ndPointer t){
  t->next->prev=t->prev;
  t->prev->next=t->next;
  free(t);
}
void deleteLast(){
  ndPointer i;
  i=nil->prev;
  deletend(i);
}
void delete(int key){
  ndPointer i; 
  i=listSearch(key);
  if(i!=NULL)deletend(i);
} 
void insert(int key){ 
  ndPointer x;
  x = malloc(sizeof(struct nd));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
int main(){  
  char com[20]; 
  int np = 0, nd = 0,key, n, i,si = 0;
  scanf("%d", &n); 
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {
      insert(key);
      np++;
      si++;
    } 
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      }
      else { delete(key); nd++; } si--; }
  }
  printList(); 
  return 0;
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl //小数をn桁で出力

int main() {
    IN(int, h);
    IN(int, w);
    int white = 0;
    vector<vector<char>> a(h,vector<char>(w));
    vector<vector<int>> dist(h,vector<int>(w,-1));
    queue<pair<int, int>> que;
    REP(i, h){
        REP(j, w){
            cin >> a[i][j];
            if (a[i][j] == '#') {
                que.push(MP(i, j));
                dist[i][j] = 0;
            }
        }
    }
    
    
    while (!que.empty()) {
        pair<int, int> now = que.front();
        que.pop();
        if (now.first > 0){
            if ((dist[now.first-1][now.second]==-1)&&(a[now.first-1][now.second]=='.')) {
                dist[now.first-1][now.second] = dist[now.first][now.second]+1;
                que.push(MP(now.first-1, now.second));
            }
        }
        if (now.second > 0){
            if ((dist[now.first][now.second-1]==-1)&&(a[now.first][now.second-1]=='.')) {
                dist[now.first][now.second-1] = dist[now.first][now.second]+1;
                que.push(MP(now.first, now.second-1));
            }
        }
        if (now.first < h-1){
            if ((dist[now.first+1][now.second]==-1)&&(a[now.first+1][now.second]=='.')) {
                dist[now.first+1][now.second] = dist[now.first][now.second]+1;
                que.push(MP(now.first+1, now.second));
            }
        }
        if (now.second < w-1){
            if ((dist[now.first][now.second+1]==-1)&&(a[now.first][now.second+1]=='.')) {
                dist[now.first][now.second+1] = dist[now.first][now.second]+1;
                que.push(MP(now.first, now.second+1));
            }
        }
    }
    int ans = 0;
    REP(i, h){
        ans = max(ans, *max_element(dist[i].begin(),dist[i].end()));
    }
    COUT(ans);
}


Measured memory_bytes: 13456
def digitSum(n):
	s = str(n)
	array = list(map(int, s))
	return sum(array)

N = int(input())
a = list(range(1,N))
ans = 999999
 
for i in a:
	b = N - i
	c = digitSum(i)
	d = digitSum(b)
	if c + d < ans:
		ans = c + d

print
print(ans)


Measured memory_bytes: 7028
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   std::vector<Int> xs(n);
   rep(i,n) std::cin >> xs[i];
   Int t = 0;
   std::vector<Int> ys;
   ys.emplace_back(t);
   rep(i,n) {
      ys.emplace_back(ys[i] + xs[i]);
   }
   std::map<Int,Int> map;
   rep(i,ys.size()) {
      map[ys[i]] += 1;
   }
   Int res = 0;
   for(auto xn : map) {
      Int t2 = xn.second;
      res += t2 * (t2-1) / 2;
   }
   printf("%ld\n", res);
}



Measured memory_bytes: 15856
#define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std; 
int main(){
	int n, r;
	int d = 100000;
	cin >> n;
	for(int i = 0; i < n; i++){
		r = d*1.05;
		if(r%1000!=0){
			while(r%1000!=0){
			r = r+1;
			}
		}
		d = r;
	}
	cout << d << endl;
	return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int h,w;
  cin >> h >> w;
  vector<string>vec(h);
  rep(i,h) cin >> vec[i];
  rep(i,h){
    rep(j,w){
      if(vec[i][j]=='.')continue;
      bool ok=false;
      rep(k,4){
        int nx=j+dx[k],ny=i+dy[k];
        if(nx<0||w<=nx||ny<0||h<=ny)continue;
        if(vec[ny][nx]=='#')ok=true;
      }
      if(!ok){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

const int MAX = 100000;

bool solve(int rest, int depth) {
  if (rest == 0) return true;
  if (depth > 5) return false;

  for (int i = 0;; ++i) {
    int next_rest = rest - i * (100 + depth);
    if (next_rest < 0) return false;
    if (solve(next_rest, depth + 1)) {
      return true;
    }
  }
}

int main() {
  int x;
  cin >> x;
  cout << (solve(x, 0) ? '1' : '0') << endl;
  return 0;
}


Measured memory_bytes: 888
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for D - Brick Break
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = nextInt()
	}

	var num int = 1
	for i := 0; i < N; i++ {
		if num == a[i] {
			num++
		}
	}
	if num == 1 {
		fmt.Println("-1")
	} else {
		fmt.Println(N - num + 1)
	}
}


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

int n ;
void input ( ) {
    cin >> n ;
}

void solve ( ) {
    cout << ( 1000 - ( n % 1000 ) ) % 1000 << "\n" ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3616
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll a,b,n,ans=0;
	string s = "NG";

	cin >> a >> b >> n;

	ll i = min(n,b-1);
	if (b == 1)
	{
		ans = 0;
	}
	else
	{
		while (i <= n)
		{
			double buf1 = floor((double)(a*i) / (double)b);
			double buf2 = (double)a * floor((double)i / (double)b);

			double buf = buf1 - buf2;

			ans = max(ans, (ll)buf);

			if (i / b == n)
				i++;
			else
				i += b;
		}
	}
		

	cout << ans;

}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b; cin>>a>>b;
	string ans=(a==b?"=="s:a>b?">"s:"<"s);
	cout<<"a "s<<ans<<" b"s<<"\n"s;
}


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


int n;
int h[100005];
long long f[100005];

int main()
{
    cin>>n;
    for (int i=0;i<n;i++) cin>>h[i];
    f[0]=0;
    f[1]=abs(h[0]-h[1]);
    for (int i=2;i<n;i++) f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
    cout<<f[n-1];
    return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
const int inf = 1e9+7;
const ll INF = 1e18+7;
/////////////////////////////////////////



int n,t;
int main(){speed;
    cin>>n>>t;

    int ans = 1e9;
    for(int i=1;i<=n;i++)
    {
        int f,s;
        cin>>f>>s;

        if(s<=t)
        {
            ans = min(f,ans);
        }

    }
    if(ans==1e9) cout<<"TLE";
    else cout<<ans;

}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    stack<char> st;
    string S; cin >> S;
    rep(i, S.length()){
        if(S[i] == 'B'){
            if(!st.empty()) st.pop();
        }
        else st.push(S[i]);
    }
    string ans = "";
    while(!st.empty()){
        char c = st.top();
        st.pop();
        ans += c;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# C - Lower
def main():
    n = int(input())
    h = list(map(int, input().split()))
    cnt = 0
    ans = []

    if n == 1:
        print(0)
        exit()
    for i in range(n-1):
        if h[i] >= h[i+1]:
            cnt += 1
            if i == n-2:
                ans.append(cnt)

        else:
            ans.append(cnt)
            cnt = 0
    print(max(ans))


if __name__ ==  "__main__":
    main()

Measured memory_bytes: 20208
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

int N, K;
vector<int> G[2000];

int main() {
	scanf("%d%d", &N, &K);
	for (int i = 0, A,B; i < N-1; ++i) {
		scanf("%d%d", &A, &B);
		--A, --B;
		G[A].push_back(B);
		G[B].push_back(A);
	}

	int res = 1<<30;

	if (K%2) {
		for (int i = 0; i < N; ++i) {
			for (auto& j : G[i]) {
				vector<int> checked(N, 0);
				checked[i] = checked[j] = 1;
				queue<pair<int, int>> q;
				q.emplace(i, 0), q.emplace(j, 0);
				while (q.size()) {
					auto p = q.front(); q.pop();
					if (p.second < (K-1)/2) for (auto& d : G[p.first]) if (!checked[d]) {
						checked[d] = 1;
						q.emplace(d, p.second+1);
					}
				}
				res = min(res, N-accumulate(checked.begin(), checked.end(), 0));
			}
		}
	} else {
		for (int i = 0; i < N; ++i) {
			vector<int> checked(N, 0);
			checked[i] = 1;
			queue<pair<int, int>> q;
			q.emplace(i, 0);
			while (q.size()) {
				auto p = q.front(); q.pop();
				if (p.second < K/2) for (auto& d : G[p.first]) if (!checked[d]) {
					checked[d] = 1;
					q.emplace(d, p.second+1);
				}
			}
			res = min(res, N-accumulate(checked.begin(), checked.end(), 0));
		}
	}

	printf("%d\n", res);

	return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  int number = 100*r + 10*g + b;
  
  if (number % 4 == 0) {
    cout << "YES" <<endl;
  }
  else {
    cout << "NO" <<endl;
  }
}

Measured memory_bytes: 256
/*input
3
2 1 3
*/
#include <iostream>
#include <algorithm>

int main(int argc, char const *argv[]){
	int n;
	std::cin>>n;
	int arr[n];
	for(int i = 0; i < n; i++){
		std::cin>>arr[i];
	}
	int arr1[n], arr2[n];
	std::copy(arr, arr+n, arr1);
	std::copy(arr, arr+n, arr2);
	if(std::prev_permutation(arr1, arr1+n)){
		for(int i = 0; i < n; i++){
			std::cout<<arr1[i];
			if(i != n-1){
				std::cout<<' ';	
			}
		}
		std::cout<<std::endl;
	}
	for(int i = 0; i < n; i++){
		std::cout<<arr[i];
		if(i != n-1){
			std::cout<<' ';	
		}
	}
	std::cout<<std::endl;
	if(std::next_permutation(arr2, arr2+n)){
		for(int i = 0; i < n; i++){
			std::cout<<arr2[i];
			if(i != n-1){
				std::cout<<' ';	
			}
		}
		std::cout<<std::endl;
	}
	return 0;
}


Measured memory_bytes: 3152
def main():
    N, L = map(int, input().split())
    min_abs = 1e10
    s = 0
    for i in range(N):
        if abs(L + i) < min_abs:
            min_abs = abs(L+i)

    for i in range(N):
        if abs(L+i) != min_abs:
            s += L+i
    print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000000;

int B[100];

int main(){
    int N, K;
    cin >> N >> K;
    rep(i,K){
        int d;
        cin >> d;
        rep(j,d){
            int x;
            cin >> x;
            if(B[x-1] == 0) B[x-1]++;
        }
    }

    int ans = 0;
    rep(i,N){
        if(B[i] == 0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << end
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    string s; cin >> s;
    ll res = 0;
    map<char,int> mp;
    rep(i,n) mp[s[i]]++;
    if(mp.size()==3)res=1;
    for(auto a:mp)res*=a.second;
    //cout << res << endl;
    for(int j=0;j<n;j++){
        for(int k=j+1;k<n;k++){
            int i = j - abs(k-j);
            if(i<0)continue;
            if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])res--;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
  long h, tmp = 0, count = 0;
  scanf("%ld", &h);
  while(h != 1) {
    h = h / 2;
    tmp++;
  }
  rep(i, tmp+1) count += pow(2, i);
  printf("%ld\n", count);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/










ll A, B;
//---------------------------------------------------------------------------------------------------
int greedy(int a, int b, int x) {
	int cnt = 0;

	cnt += x / b; x %= b;
	cnt += x / a; x %= a;
	cnt += x;

	return cnt;
}
int opt(int a, int b, int x) {
	vector<int> dp(x + 1, inf);
	dp[0] = 0;
	rep(i, 0, x) {
		chmin(dp[i + 1], dp[i] + 1);
		if(i + a <= x) chmin(dp[i + a], dp[i] + 1);
		if (i + b <= x) chmin(dp[i + b], dp[i] + 1);
	}
	return dp[x];
}
int naive() {
	rep(x, 1, A * B * 2) {
		int g = greedy(A, B, x);
		int o = opt(A, B, x);
		if (o < g) return x;
	}
	return -1;
}
void labo() {
	int ma = 30;
	rep(a, 1, ma) rep(b, a + 1, ma) {
		A = a, B = b;
		printf("%d\t%d\t->\t%d\n", a, b, naive());
	}
}
//---------------------------------------------------------------------------------------------------
void _main() {
	//labo(); return;

	cin >> A >> B;

	ll x = B / A;
	if (B % A != 0) x++;

	ll L = A * (x - 1) + 1;
	ll R = A * x - x;

	if (L <= R and L <= B and B <= R) cout << A * x << endl;
	else cout << -1 << endl;
}





Measured memory_bytes: 3204
import sys
sys.setrecursionlimit(100000000)
n=int(input())
es=[[]for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    es[u-1].append([v-1,w])
    es[v-1].append([u-1,w])
color = [0 for i in range(n)] # 頂点0とのパスが存在すればFalse, 存在しないならTrue と定義する
def dfs(v,c):
    color[v] = c
    for i in es[v]:
        if color[i[0]]==0:
            # print(v,i[0],c)
            if i[1]%2==1:
                dfs(i[0],-c)
            else:
                dfs(i[0],c)
dfs(0,1)
# print(color)
for i in color:
    if i==-1:
        print(0)
    else:
        print(1)

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

ud = [0]

if A[1] > A[0]:
    trend = 1
elif A[1] == A[0]:
    trend = 0
else:
    trend = -1

if trend != 0:
    first_trend = trend
else:
    first_trend = 0
for i in range(1,N):
    if A[i] > A[i-1]:
        if first_trend==0:
            first_trend = 1
        if trend==-1:
            ud.append(i-1)
        trend = 1
    elif A[i] < A[i-1]:
        if first_trend==0:
            first_trend = -1
        if trend==1:
            ud.append(i-1)
        trend = -1

ud.append(N-1)

M = 1000

for i in range(len(ud)):
    if first_trend == 1:
        if i%2==0 and i!=len(ud)-1:
            stock = M // A[ud[i]]
            M = stock*A[ud[i+1]] + M % A[ud[i]]
    else:
        if i%2==1 and i!=len(ud)-1:
            stock = M // A[ud[i]]
            M = stock*A[ud[i+1]] + M % A[ud[i]]


print(M)

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


#define debug(x) cerr<< #x << ": "<< x << endl;
#define print(x) cerr<< x << endl;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define REP(i,x,y) for(int i=x;i<y;i++)
#define REPIT(it,A) for(typeof(A.begin()) it = (A.begin()); it!=A.end();it++)
#define fst first
#define snd second
#define sqr(x) ((x)*(x))

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define ones(x) __builtin_popcountll(x)
using namespace std;

typedef pair<int,int> ii ;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<ii> vii;

struct PT{
	int x , y , id;
	PT(int _x, int _y, int _id){
		x = _x; y = _y; id = _id;
	}
};

vector<PT> data;

int r, c, n;
bool cmp(PT a, PT b){
	if(a.x == 0){
		if(b.x != 0) return true;
		return a.y < b.y;
	}else if(a.y == c){
		if(b.x == 0) return false;
		if(b.y != c) return true;
		return a.x < b.x;
	}else if(a.x == r){
		if(b.x == 0 || b.y == c) return false;
		if(b.x != r) return true;
		return a.y > b.y;
	}else if(a.y == 0){
		if(b.y != 0) return false;
		return  a.x > b.x;
	}
}

const int MAXN = 1e5+100;
int tmp[MAXN];

int main(){
   fastio;
	cin >> r >> c >> n;
	swap(r,c);
	REP(i,0,n){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		swap(x1,y1); swap(x2,y2);
		if(x1 == 0 || x1 == r || y1 == 0 || y1 == c){
			if(x2 == 0 || x2 == r || y2 == 0 || y2 == c){
				data.pb(PT(x1, y1, i));
				data.pb(PT(x2, y2, i));
			}
		}
	}

	sort(all(data), cmp);
	REP(i,0,n) tmp[i] = 0;
	stack<int> st;	
	REP(i,0,data.size()){
		int id = data[i].id;
		if(!tmp[id]){
			st.push(id);
			tmp[id] = 1;
		}else{
			int t = st.top();
			if(t != id){
				cout<<"NO"<<endl;
				return 0;
			}
			st.pop();
		}
	}
	cout<<"YES"<<endl;

   return 0;
}



Measured memory_bytes: 4980
S = int(input())
ans = [0]*2001
mod = 10**9+7

for i in range(0,76):
  if i <= 2:
    ans[i] = 0
  elif i <= 5:
    ans[i] = 1



for m in range(6,S+1):
  ans[m] = ans[m-1] + ans[m-3]

print(ans[S]%mod)

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    unordered_map<char,ll> m;
    vl t(26,0);
    rep(i,Size(s)){
        rep(j,26){
            if(j!=s[i]-'a')t[j]++;
        }
    }
    ll res=0;
    rep(i,Size(s)){
        res+=t[s[i]-'a']-i+m[s[i]];
        m[s[i]]++;
    }
    cout<<res+1<<endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin(), x.end()
typedef long long int unsigned lliu;
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<pi> vpi;


int main(){
	lli x;
	cin>>x;
	for(lli i = -118; i<=119; i++){
		for(lli j= -118; j<=119; j++){
			if(i*i*i*i*i - j*j*j*j*j==x){
				cout<<i<<" "<<j<<endl;
				exit(0);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;}
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;}
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N),b(N),c(2*N),d(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    rep(i,N) c[i]=a[i]^a[(i+1)%N],c[i+N]=c[i];
    rep(i,N) d[i]=b[i]^b[(i+1)%N];
    vector<int> kmp(N+1,-1);
    for (int i=0,j=-1;i<N;kmp[++i]=++j){
        while(j>=0&&d[i]!=d[j]) j=kmp[j];
    }
    vector<int> candidate;
    int i=0,j=0;
    while(i+j<2*N){
        if (d[j]==c[i+j]){
            if (++j!=N) continue;
            candidate.push_back(i);
        }
        i+=j-kmp[j];
        j=max(kmp[j],0);
    }
    for (auto k:candidate){
        if (k==N) continue;
        cout << k << ' ' << (a[k]^b[0]) << endl;
    }
}

Measured memory_bytes: 13044
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int sum1 = 0, sum2 = 0;
    rep(i, n)
    {
        sum1 += a[i];
        sum2 += b[i];
    }
    if (sum1 < sum2)
    {
        cout << -1 << endl;
        return 0;
    }
    vector<int> c;
    int ans = 0, sum = 0;
    rep(i, n)
    {
        int d = a[i] - b[i];
        if (d > 0)
            c.push_back(d);
        if (d < 0)
        {
            sum += -d;
            ans++;
        }
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    rep(i, c.size())
    {
        if (sum <= 0)
            break;
        sum -= c[i];
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2428
#include <stdio.h>
int main() {
	int a, s, t, d = 0, i;
	for(i = 0; i < 5; i++) {
		scanf("%d", &a);
		t = !!(a % 10) * (10 - (a % 10));
		s += a + t;
		if(t > d)
			d = t;
	}
	printf("%d", s - d);
	return 0;
}

Measured memory_bytes: 128
import itertools
import math

n = int(input())
towns = []
for i in range(n):
  towns.append([int(x) for x in input().split()])
#print(towns)

patterns = list(itertools.permutations(towns, n))

answers = []
for pattern in patterns:
  distance = 0
  for i in range(n-1):
    distance += math.sqrt((pattern[i+1][0] - pattern[i][0])**2+(pattern[i+1][1] - pattern[i][1])**2)
  answers.append(distance)

#print(answers)
print(sum(answers)/len(answers))

Measured memory_bytes: 9252
#n=int(input())
a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
count=0
for i in range(a,b+1):
    istr=str(i)
    if istr[0]==istr[4] and istr[1]==istr[3]:
        count+=1
print(count)


Measured memory_bytes: 9036
using System;
class main
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string ans = "";
            switch(N % 10)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    ans = "hon";
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    ans = "pon";
                    break;
                case 3:
                    ans = "bon";
                    break;
                    
            }
 
            Console.WriteLine(ans);
        }
        
    }

Measured memory_bytes: 27480
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P = sorted(P, reverse=True)[:x]
Q = sorted(Q, reverse=True)[:y]
concat = P + Q + R
concat.sort(reverse=True)
print(sum(concat[:x+y]))

Measured memory_bytes: 23876
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int M = sc.nextInt();
        int danger[] = new int[N+1];
        for (int i=0;i<M;i++) {
            int a = sc.nextInt();
            danger[a] = 1;
        }

        int dp[] = new int[N+1];
        dp[0] = 1;

        for (int i=1;i<=N;i++) {
            if (danger[i] == 1) continue;

            if (i >= 2) {
                dp[i] += dp[i-2];
            }
            dp[i] += dp[i-1];
            dp[i] %= 1000000007;
        }

        System.out.println(dp[N]);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}

Measured memory_bytes: 32356
#include <bits/stdc++.h>
using namespace std ;
int main() {
	char s[101] ;
	int N ;
	cin >> N ;
	int ans = 0 ; 
	int maxn = -233 ;
	for(int i = 0 ; i < N ; i++){
	 cin >> s[i] ;
	 if(s[i] == 'I') ++ans ;
	 else --ans ;
	 maxn = max(maxn,ans);
}
maxn = max(0,maxn);
	cout << maxn << endl ; 
	return 0 ;

} 

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

int main() {
	int N;
	long long T;
	cin >> N >> T;
	vector<long long> t(N),dt(N);
	cin >> t[0];
	for (int i = 1; i < N; i++) {
		cin >> t[i];
		dt[i - 1] = t[i] - t[i - 1];
	}
	for (int i = 0; i < N - 1; i++) {
		if (dt[i] > T) dt[i] = T;
	}
	dt[N - 1] = T;
	cout << accumulate(dt.begin(), dt.end(), 0) << endl;
	return 0;
}

Measured memory_bytes: 3328
import numpy as np


def f(_b, _a):
    return sum([abs(i - _b) for i in _a])


N = int(input())
A = list(map(int, input().split()))
A = [a - i - 1 for i, a in enumerate(A)]
A = sorted(A)
b = 0
half = len(A) // 2
if len(A) % 2:
    b = A[half]
else:
    b = int((A[half] + A[half - 1])/2)
print(f(b, A))


Measured memory_bytes: 34188