akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>

void print(T x)
{
	std::cout << x <<" " ;
}


signed main(void) {
	double N,D;
	cin >> N >>D  ;
	double look = D * 2 + 1;
	print((int)ceil(N/look));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,even=0,odd=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		if(a%2==0) even++;
		else odd++;
	}
	if(odd%2==1) cout<<"NO\n";
	else cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
button = list(map(int,input().split()))
visit = [-1]*n
hisitory = [-1]
push = 0
f = 0

for i in range(k):
    visit[push] = i+1
    hisitory.append(push)
    push = button[push] -1
    if(visit[push] != -1):  
        f = 1
        start = visit[push]
        last=push
        end = i+1
        break
if(f == 0):
    print(button[hisitory[-1]])
else:
    geta = start -1
    loopk = k - geta
    loop = end -start + 1
    modk = loopk%loop
    if(modk == 0):
        modk = loop
    print(button[hisitory[geta + modk]])
    # print(hisitory)
    # print(geta,modk,loop)


Measured memory_bytes: 32356
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int b,c,n,k,x,y;

int main(){
  int ans=0;
  cin >> n >> k;
  vector<int> a(n);
  REP(i,n) cin>>a[i];

  vector<int> so(22361);
  int sum=accumulate(a.begin(),a.end(),0);
  int bigsum=sum;
  if (bigsum==0){
    cout<<k<<endl;
    return 0;
  }


  int w=0;
  REP(i,22361){
    if (sum%(i+1)==0){
      so[i]=1;
      w++;
    }
  }

  vector<int> m(n);//あまりソート用

int ssum;
int ii;
int t;
  REP(i,22361){
    if (so[i]==1){
      sum=0;
      ii=i+1;
      //ii=bigsum/ii;
      REP(j,n){
        t=a[j]%ii;
        m[j]=t;
        sum+=t;
      }
      sort(m.begin(), m.end(),greater<int>());
      sum/=ii;
      ssum=sum*ii;
      REP(j,sum){
        ssum-=m[j];
      }
      if (ssum<=k){
        ans=max(ii,ans);
      }

      sum=0;
      ii=i+1;
      ii=bigsum/ii;
      //int t;
      REP(j,n){
        t=a[j]%ii;
        m[j]=t;
        sum+=t;
      }
      sort(m.begin(), m.end(),greater<int>());
      sum/=ii;
      ssum=sum*ii;
      REP(j,sum){
        ssum-=m[j];
      }
      if (ssum<=k){
        ans=max(ii,ans);
      }

    }
  }








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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,K;
string S;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> S >> K;
  char ch = S[K-1];
  REP(i,N) {
    if (S[i] == ch) cout << ch;
    else cout << "*";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
komoji = [chr(i) for i in range(97, 97+26)]

ans = ""
# print(N)
while True:
    N -= 1
    q, mod = divmod(N, 26)
    ans = komoji[mod] + ans
    # print("q: {} mod: {} ans: {}".format(q, mod, ans))
    if q == 0:
        break
    N = q
print(ans)

Measured memory_bytes: 9208
input = gets.chomp.split(' ').map{ |v| v.to_i }
h = input[0]
w = input[1]

mass = []
v_check = []
for i in 1..w
  v_check.push(true)
end

for i in 1..h
  line = gets.chomp
  line_s = line.split('')
  mass.push(line_s) if line.count('.') != w
  
  for i in 0...line_s.size
    v_check[i] = false if line_s[i] != '.'
  end
end

#p mass

for i in 0...mass.size
  for j in 0...mass[i].size
    print mass[i][j] if !v_check[j]
  end
  puts ''
end


Measured memory_bytes: 4604
sa = [s for s in input()]
sb = [s for s in input()]
sc = [s for s in input()]

next_turn = "a"
flag = True

while flag:
    if next_turn == "a":
        if len(sa) == 0:
            print("A")
            flag = False
        else:
            next_turn = sa.pop(0)
    elif next_turn == "b":
        if len(sb) == 0:
            print("B")
            flag = False
        else:
            next_turn = sb.pop(0)
    elif next_turn == "c":
        if len(sc) == 0:
            print("C")
            flag = False
        else:
            next_turn = sc.pop(0)
        



Measured memory_bytes: 3064
n,m = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(m)]


dst1 = []
dst2 = []

for i in range(m):
    if lst[i][0] == 1:
        dst1.append(lst[i][1])
    elif lst[i][1] == n:
        dst2.append(lst[i][0])

if (set(dst1) & set(dst2)):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 61012
#include <stdio.h>

int main(void) {
  int ans;
  ans=0;
  long long int x,yokin;
  yokin=100;
  scanf("%lld",&x);
  while(yokin<x)
    {
      ans++;
      yokin=yokin+yokin/100;
    }
    printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N, M, S, T;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    for(int i = 0; i < M; ++i){
        int u, v;
        cin >> u >> v;
        --u, --v;
        graph[u].emplace_back(v);
    }
    cin >> S >> T;
    --S, --T;
    vector<vector<int>> dist(3, vector<int>(N, INF));
    dist[0][S] = 0;
    using Tup = tuple<int, int, int>;
    priority_queue<Tup, vector<Tup>, greater<Tup>> que;
    que.emplace(0, 0, S);
    while(!que.empty()){
        int d, idx, from;
        tie(d, idx, from) = que.top();
        que.pop();
        if(d > dist[idx][from]) continue;
        for(int to : graph[from]){
            int nxt_idx = (idx + 1) % 3;
            if(chmin(dist[nxt_idx][to], dist[idx][from] + 1)){
                que.emplace(dist[nxt_idx][to], nxt_idx, to);
            }
        }
    }
    if(dist[0][T] == INF)   dist[0][T] = -1;
    else    dist[0][T] /= 3;
    cout << dist[0][T] << endl;
}

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

int main()
{
	int x,y,a,b,c;
	
	cin>>x>>y>>a>>b>>c;
	
	deque<int>arr;
	deque<int>arr2;
	deque<int>arr3;
	
	int num;
	
	for(int i=0;i<a;i++)
	{
		cin>>num;
		arr.push_back(num);
	}
	
	for(int i=0;i<b;i++)
	{
		cin>>num;
		arr2.push_back(num);		
	}	
	
	for(int i=0;i<c;i++)
	{
		cin>>num;
		arr3.push_back(num);		
	}		
	
	sort(arr.begin(),arr.end());
	sort(arr2.begin(),arr2.end());
	sort(arr3.begin(),arr3.end());
	
	reverse(arr3.begin(),arr3.end());
	
	while(arr.size()>x){ arr.pop_front();}
	while(arr2.size()>y){ arr2.pop_front();}
	
	while(arr3.size())
	{
		int variable=arr3.front();
		int minimo=min(arr.front(),arr2.front());
		
		if(variable<=minimo) break;
		
		if(arr.front()<arr2.front()){
			arr.pop_front();
			arr.push_back(variable);
		}
		else
		{
			arr2.pop_front();
			arr2.push_back(variable);
		}
		arr3.pop_front();
	}
	
	long long resultado=0;
	
	for(int i=0;i<arr.size();i++)
		resultado+=arr[i];
	
	for(int i=0;i<arr2.size();i++)
		resultado+=arr2[i];	
	
	cout<<resultado;
	
	return 0;
}


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


int main(){
  int n, m;
  cin>>n>>m;
  int temp, total = 0;
  while (m--) {
    cin>>temp;
    total+=temp;
  }

  if((n-total)<0) cout<<-1;
  if((n-total)>=0) cout<<n-total;
  return 0;
}


Measured memory_bytes: 3636
"""
Writer: SPD_9X2
https://atcoder.jp/contests/agc014/tasks/agc014_d

白にしか隣接しない白を作れれば勝ちである
黒は、直前に置かれた白に対して対策するような動きをする羽目になる

距離2の葉の対があったら100%可能

ある時点での残りの森を考える(残りのどの点も黒が隣接していないとする)
葉に白を置く→葉において阻止
葉に隣接する点にしろを置く→葉において阻止
それ以外の点は、置いたら横に置くだけ(葉ではないので、隣接頂点が存在する)

なので、十分性もおｋ？
距離2の葉が存在するかだけを判定すればよさそう

そうでないとき、
奇数個の頂点の部分木が2つ以上存在したらおｋ？
検証してみるか

"""

N = int(input())

lis = [ [] for i in range(N) ]

for i in range(N-1):

    a,b = map(int,input().split())

    a -= 1
    b -= 1
    lis[a].append(b)
    lis[b].append(a)

import sys
sys.setrecursionlimit(500000)

if N == 2:
    print ("Second")
    sys.exit()

def dfs(v,p):

    if len(lis[v]) == 1:
        return 1,1

    pl = 0
    cnum = 0
    oddc = 0
    for nex in lis[v]:
        if nex != p:
            lf,nc = dfs(nex,v)
            pl += lf
            cnum += nc
            oddc += nc % 2

    if (N-(cnum+1)) % 2 == 1:
        oddc += 1

    if pl >= 2 or oddc >= 2:
        print ("First")
        sys.exit()

    return 0,cnum+1


fi = None
for i in range(N):
    if len(lis[i]) > 1:
        fi = i
        break

dfs(fi,fi)
print ("Second")

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#include <queue>
#define INF 1e15
typedef long long ll;
struct edge{ll to, cost;};
typedef pair<ll,ll> P;

int n;
ll dijkstra(VI& board){
  VLL d(n+100,INF);
  d[0] = 0;
  priority_queue<P,vector<P>, greater<P> > que;
  que.push(P(0,0));
  while(!que.empty()){
    P p = que.top(); que.pop();
    ll cdist = p.first;
    ll v = p.second;
    // cout << v << endl;
    if(d[v]<cdist) continue;
    // cout << v << endl;
    FOR(i,1,6+1){
      int nextNode = v+i;
      bool ngFlag = false;
      while(board[nextNode] != 0){
        //cout << nextNode << endl;
        if( d[nextNode] > cdist + 1) d[nextNode] = cdist + 1;
        else{
          ngFlag = true;
          break;
        }
        int tmp = nextNode + board[nextNode];
        nextNode = tmp;
      }
      if(ngFlag) continue;

      if(d[nextNode] > cdist+1 && nextNode < n+7){
        d[nextNode] = cdist+1;
        if(nextNode >= n){
          FOR(j,n-1,nextNode) d[nextNode] = min(d[nextNode],cdist+1);
        }

        que.push(P(d[nextNode],nextNode));
      }
    }
  }
  return d[n-1];
}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  VI board(n+100,0);
  rep(i,n) cin >> board[i];
  cout << dijkstra(board) << endl;
  return 0;
}



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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) int a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    int ds[26]={},dt[26]={};
    int cnt_ds=1,cnt_dt=1;
    string s;cin>>s;
    string t;cin>>t;

    rep(i,s.size()){
        int tmp = (int)s[i]-97; 
        if(!ds[tmp]){
            ds[tmp]=cnt_ds;
            cnt_ds++;
        }
        s[i]=ds[tmp];
    }
    rep(i,t.size()){
        int tmp = (int)t[i]-97; 
        if(!dt[tmp]){
            dt[tmp]=cnt_dt;
            cnt_dt++;
        }
        t[i]=dt[tmp];
    }

    string ans = "Yes";
    rep(i,s.size()){
        if(s[i]==t[i]) continue;
        else ans = "No";
    }

    cout << ans << endl;
}

Measured memory_bytes: 776
x = []
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
x.append(int(input()))
tmp = str(x[0])
tmp = int(tmp[-1])
ans = 0


def a(b):
    c = str(b)
    if c[-1] == "0":
        return b
    else:
        return b - int(c[-1]) + 10


for i in x:
    ans += a(i)
    d = str(i)
    if int(d[-1]) != 0:
        tmp = min(tmp, int(d[-1]))

if tmp == 0:
    print(ans)
else:
    print(ans - (10 - tmp))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
int main() {
    std::string s;
    std::cin >> s;
    int ans = 0;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        ans += (s[i] != (i % 2 ? '0' : '1'));
    }
    if (ans > n / 2) {
        ans = n - ans;
    }
    std::cout << ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;
typedef long long int ll;
#define space " "
#define vi vector<int>
#define pb push_back

#define MOD (int)(1e9  + 7)

ll fastpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * a) % MOD;
        }
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    int n, k;
    cin >> n >> k;
    ll dp[k + 4];
    // for(int i = 0; i <= k ; i++ ) dp[i] = 0 ;
    for (int i = k; i >= 1; i--) {
        dp[i] = fastpow(k / i, n);
        for (int j = 2 * i; j <= k; j += i) {
            dp[i] -= dp[j];
        }
    }
    ll ans = 0;

    for (int i = 1; i <= k; i++) {
        ans += (i * 1ll * dp[i]) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 4304
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

K = int(input())
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += math.gcd(k, math.gcd(i, j))
print(ans)

Measured memory_bytes: 78440
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2;
    cout << " ";
    if (x == w / 2 && y == h / 2) {
        cout << 1;
    } else {
        cout << 0;
    }   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
#define Mod 1000000007
using namespace std;
int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int main(){
	int n=read(),m=read(),tmp=m-n;
	printf("%d\n",((tmp-1)*tmp>>1)-n);
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var tmp = input.split(" ");
    var L = Number(input,10);
    

    //-input
    //L=正の整数

    //-output
    //L=x+y+zを満たす直方体の体積S=x*y*z

    console.log(Math.pow(L/3,3));



}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));




Measured memory_bytes: 7372
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long N,a1[100005],a2[100005],F[200005],pre[100005],l,r,mid;
void insert(long long n)
{
	for(;n<=N*2+1;n+=n&-n)
	F[n]+=1;
}
int find(long long n)
{
	int cnt=0;
	for(;n;n-=n&-n)
	cnt+=F[n];
	return cnt;
}
bool check(long long n)
{
	memset(F,0,sizeof(F));
	memset(pre,0,sizeof(pre));
	long long cnt=0;
	long long zj=a2[n];
	for(int i=1;i<=N;i++)
	if(a1[i]<=zj) pre[i]=pre[i-1]-1 , cnt += pre[i] < 0 ? 1 : 0;
	else pre[i]=pre[i-1]+1;
	for(int i=1;i<=N;i++)
	{
		cnt+=i-find(pre[i]+N+1)-1;
		insert(pre[i]+N+1);
	}
	if(cnt<=N*(N+1)/2/2)
	return true;
	return false;
}
int main()
{
	scanf("%lld",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%lld",&a1[i]);
		a2[i]=a1[i];
	}
	sort(a2+1,a2+N+1);
	l=1,r=N;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(check(mid))
		l=mid;
		else
		r=mid;
	}
	printf("%lld",a2[r]);
	return 0;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    int ab = stoi(a+b);
    for(int i=1;i<=1000;i++){
        if(i*i==ab){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; vl num(n); ll count = 0;
  rep(i,n){ ll x; cin >> x; num[i] = x; }
  
  for(ll i=1; i < n-1; i++){
    if((num[i] != max( num[i], max(num[i+1],num[i-1])))&&
        (num[i] != min( num[i], min(num[i+1],num[i-1])))) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_macros, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Main
fn main(){
    input!{
        N: usize,
        M: usize,
        PY: [(usize,u64); M],
    }
    // P(県)別にVecにまとめる、その際に何番目のデータかを一緒に記録しておく
    let mut v = vec![vec![(0,0);0]; N];
    for (i, py) in PY.iter().enumerate(){
        v[py.0 -1].push((py.1,i));
    }
    // それぞれソートする
    for i in 0..N{
        v[i].sort();
    }
    // 出力用に、最初のデータ順にまとめて
    let mut ans = vec![(0,0) ;M];
    for i in 0..N{
        for j in 0..v[i].len(){
            ans[v[i][j].1] = (i+1, j+1);
        }
    }
    // 出力する
    for i in 0..M{
        println!("{:06}{:06}",ans[i].0, ans[i].1);
    }
}


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

A.sort()

max_dis = A[0] + K - A[-1]
max_disidx = 0

for i in range(1, N):
    distance = A[i] - A[i-1]
    if max_dis < distance:
        max_dis = distance
        max_disidx = i

print(K-max_dis)

Measured memory_bytes: 77644
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 3000

const int INF = 1e9+7;

int dp[105][15];

int main(){

    //h+1の全探索O(HK*2^W)
    int h,w,k;
    cin >> h >> w >> k;
    dp[0][0] = 1;
    //dp[h][k]:h列目に来た時に棒の番号がkにいる場合の数

    for(int i = 1;i <= h;i++){

        for(int j = 0;j < w;j++){

            for(int k = 0;k < (1<<(w-1));k++){//橋がどうつながっているか(縦棒 W 本に対して最大(W-1)本の橋)
                
                bool flag = true;

                for(int l = 0;l < w-2;l++){//連続する橋があればこれはあみだくじの条件を満たさないので調べない,(w-2)回調べる
                    if((k >> l) & 1 && (k >> (l+1)) & 1){
                        flag = false;
                    }
                }
                if(flag == true){

                    if(j >= 1 && (k >> (j-1)) & 1){
                        //左にたどる
                        dp[i][j-1] += dp[i-1][j];
                        dp[i][j-1] %= MOD;
                    }else if(j <= w-2 && (k >> j) & 1){
                        //右にたどる
                        dp[i][j+1] += dp[i-1][j];
                        dp[i][j+1] %= MOD;
                    }else{
                        //下にたどる
                        dp[i][j] += dp[i-1][j];
                        dp[i][j] %= MOD;
                    }
                }
            }
        }
    }

    cout << dp[h][k-1] << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from math import sin, cos, radians, sqrt

def solve():
    input = sys.stdin.readline
    A, B, H, M = map(int, input().split())
    tMin = H * 60 + M
    hT = tMin * 0.5
    mT = 6 * M
    dT = abs(hT - mT)
    dT = min(dT, 360 - dT)
    diff = sqrt((A * cos(radians(dT)) - B) ** 2 + (A * sin(radians(dT))) ** 2)
    print(diff)

    return 0

if __name__ == "__main__":
    solve()

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

const long long INF=1LL<<60;

vector<long long> h(100010);
vector<long long> dp(100010);


int main(){
  int N;
  cin>>N;
  for(int i=0; i<N; i++){
    dp.at(i)=INF;
    cin>>h.at(i);
  }
  dp.at(0)=0;
  for(int i=1; i<N; i++){
    dp.at(i)=min(dp.at(i),dp.at(i-1)+abs(h.at(i)-h.at(i-1)));
    if(i>1){
      dp.at(i)=min(dp.at(i),dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
    }
  }
  
  cout<<dp.at(N-1)<<endl;
}
  



Measured memory_bytes: 4632
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a+b > c+d) cout << "Left" << endl;
    else if (a+b < c+d) cout << "Right" << endl;
    else cout << "Balanced" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    x = int(input())
    if x%11 > 6:
        print((x//11) * 2 + 2)
    else:
        if x%11 == 0:
            print((x//11) * 2)
        else:
            print((x//11) * 2 + 1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=n; i<N; i++)
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long ll;

int N,A,B,C,X;
int method(int x){
	return (A*x+B)%C;
}

int main() {
	while(1) {
		cin >> N >> A >> B >> C >> X;
		vector<int> rand(N);
		if (N == 0)break;
		REP(i,0,N) cin >> rand[i];

		int idx=0,ans=-1;
		REP(i,0,10001){
			if(i==0){
				if(X==rand[0])idx++;
				if(idx==N){
					ans=i;
					break;
				}
				continue;
			}
			X=method(X);
			if(rand[idx]==X){
				idx++;
			}
			if(idx==N){
				ans=i;
				break;
			}
		}
		p(ans);
	}
	return 0;
}


Measured memory_bytes: 2976
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 100'000
int n, k;
int a[N];
int memL[N];
int optL(int i) {
    int& ans = memL[i];
    if(ans == -1) {
        if(i == 0) {
            ans = 0;
        } else {
            ans = 1 + optL(max(0, i - k + 1));
        }
    }
    return ans;
}
int memR[N];
int optR(int i) {
    int& ans = memR[i];
    if(ans == -1) {
        if(i == n - 1) {
            ans = 0;
        } else {
            ans = 1 + optR(min(n - 1, i + k - 1));
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    int min_i = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] < a[min_i]) {
            min_i = i;
        }
    }
    memset(memL, -1, sizeof memL);
    memset(memR, -1, sizeof memR);
    int ans = 2 * n;
    for(int start = max(0, min_i - k + 1); start <= min_i; start++) {
        int end = start + k - 1;
        ans = min(ans, 1 + optL(start) + optR(end));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2176
s = 'S' + input()
t = 'T' + input()

dp = [[0] * len(t) for _ in range(len(s))]
for i in range(len(s)) :
    for j in range(len(t)) :
        if i == 0 or j == 0 :
            continue
            
        if s[i] == t[j] :
            dp[i][j] = dp[i-1][j-1] + 1
        else :
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
ret = ''
i, j = len(s)-1, len(t)-1
while i >= 1 and j >= 1 :
    if dp[i][j] == dp[i-1][j] :
        i -= 1
    elif dp[i][j] == dp[i][j-1] :
        j -= 1
    else :
        ret += s[i]
        i -= 1
        j -= 1
        
print(ret[::-1])

Measured memory_bytes: 112220
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const int mod = 1000000007;
const int INF = 1001001001;

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    if(n % 2 == 0) n -= 1;
    int ans = n / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

a, b, c, d = I()
print(max([a * c, a * d, b * c, b * d]))


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

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
//unique
/*
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
*/
const int MAX  = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

void solve(void){
    ll K;
    cin >> K;
    ll Limit[K];
    rep(K, i) scanf("%lld ", &Limit[i]);
    reverse(Limit, Limit+K);
    ll low = 2, high = 2;
    bool flag = true;
    if (Limit[0] != 2) flag = false;
    rep(K, i) {
        //cout << low << ' ' << high << '\n';
        ll l = Limit[i];
        if (high < l) flag = false;
        low = ((low-1)/l+1)*l;
        high = (high / l + 1) * l - 1;
    }
    if (flag and low <= high) cout << low << ' ' << high << '\n';
    else cout << -1 << endl;
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int x, y; cin >> x >> y;
    ans += y - x + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int divide(int t)
{
	int cnt = 0;
	for(;t%100==0;t/=100) {
		cnt++;
	}
	return cnt;
}


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

	int mul = 1;
	for(int i=1; i<=d; i++) mul*=100;

	int tmp = 0;
	for(int i=1; i<=n; i++) {
		tmp+=mul;
		while(divide(tmp)!=d) tmp+=mul;
	}
	printf("%d\n",tmp);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        scan.close();

        List<String> list = func(n);

        Collections.sort(list);

        for (String s : list) {
            System.out.println(s);
        }

    }

    private static List<String> func(int n) {
        List<String> list = new ArrayList<String>();
        if (n == 1) {
            list.add("a");
        } else {
            List<String> prevList = func(n - 1);
            for (String s : prevList) {
                // 含まれている最大の文字を探索
                char max = 'a';
                for (int i = 0; i < s.length(); i++) {
                    if (max < s.charAt(i)) {
                        max = s.charAt(i);
                    }
                }

                for (char c = 'a'; c <= max + 1; c++) {
                    String newString = s + c;
                    list.add(newString);
                }
            }
        }
        return list;
    }
}


Measured memory_bytes: 54628
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 
#define JUUHATIPLUS 1000000000000000001 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N,M,ansN = 0,ansM=0;
    cin >> N >> M;

    if(N >= 2){
        ansN = 1;
        for(int i = N -1;i <= N;i++)
            ansN *= i;

        ansN /= 2;
    }

    if(M >= 2){
        ansM = 1;
        for(int i = M -1;i <= M;i++)
            ansM *= i;
        ansM /= 2;
    }

    cout << ansN + ansM << endl;

    

}

Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int main(){
  int a[5]={};
  int diff=0;
  int i=0,j=0,k=0;
  int count;
  for(i=0;i<5;i++){
  cin >> a[i];
  }
  cin >> k;

  if(a[4]-a[0] > k){
    cout << ":(" << endl;
  }else {
    cout << "Yay!" << endl;
  }
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  puts(a+b>c+d ? "Left" : (a+b<c+d ? "Right" : "Balanced"));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
map<int, int> mp;
int res;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		int x;
		cin >>x;
		mp[x]++;
	}
	for (map<int, int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		int x=it->first,y=it->second;
		if (x==y) continue;
		if (x<y) res+=y-x;
		else res+=y;
	}
	cout <<res;
	return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,M;cin>>N>>M;
    vector<pair<int,int>> cond(M);
    REP(i,M){
        int s;
        char c;
        cin>>s>>c;
        s--;
        cond[i]=make_pair(s,c);
    }
    REP(i,1000){
        string s=to_string(i);
        if(s.size()!=N) continue;
        bool ok=true;
        for(auto c:cond) if(s[c.first]!=c.second) ok=false;
        if(ok){
            cout<<s<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


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

string S;
int x,y;
vector<int> X,Y;

bool dp[5][160010];

int main()
{
    cin >> S;
    scanf("%d%d",&x,&y);

    int N = S.size();
    bool F = false;
    int cnt = 0;
    for(int i = 0; i <= N; i++)
    {
        if(i == N || S[i] == 'T')
        {
            if(!F)X.push_back(cnt);
            else Y.push_back(cnt);
            F ^= true;
            cnt = 0;
        }
        else cnt++;
    }

    memset(dp,false,sizeof(dp));
    dp[0][80000 + X[0]] = true;
    for(int i = 1; i < X.size(); i++)
    {
        for(int j = 0; j < 160000; j++)
        {
            if(dp[0][j])
            {
                dp[1][j + X[i]] = true;
                dp[1][j - X[i]] = true;
            }
        }
        for(int j = 0; j < 160000; j++)
        {
            dp[0][j] = dp[1][j];
            dp[1][j] = false;
        }
    }
    if(!dp[0][x + 80000])
    {
        printf("No\n");
        return 0;
    }

    memset(dp,false,sizeof(dp));
    dp[0][80000] = true;
    for(int i = 0; i < Y.size(); i++)
    {
        for(int j = 0; j < 160000; j++)
        {
            if(dp[0][j])
            {
                dp[1][j + Y[i]] = true;
                dp[1][j - Y[i]] = true;
            }
        }
        for(int j = 0; j < 160000; j++)
        {
            dp[0][j] = dp[1][j];
            dp[1][j] = false;
        }
    }
    if(!dp[0][y + 80000])
    {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    return 0;
}


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

int main() {
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	long long p=0;
	int i=0,j=0,a,c;
	for(int i=0;i<=n;i+=r)
	{
		for(int j=0;j<=n;j+=g)
		{
			if ( (n-i-j)%b ==0 && (n-i-j)>=0)
			p++;
		}
		
	}
	cout<<p;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int t,n,i,ans[4];

  for(i=0;i<4;i++){
    scanf("%d %d",&t,&n);
    if(t==1)printf("%d\n",n*6000);
    if(t==2)printf("%d\n",n*4000);
    if(t==3)printf("%d\n",n*3000);
    if(t==4)printf("%d\n",n*2000);
  }
  return 0;
}




Measured memory_bytes: 2112
def main():
    n = int(input())
    a = list(map(int, input().split()))
    s, cnt = [0]*n, 0
    for i in range(n):
        s[i] = abs(a[i])
        if a[i] < 0:
            cnt += 1
    if cnt%2:
        print(sum(s) - 2*min(s))
    else:
        print(sum(s))

if __name__ == "__main__":
    main()

Measured memory_bytes: 20136
//abc136_b.cpp
//Sun Aug  4 21:02:54 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 0;

	for (int i=1;i<=n;i++){
		string s = to_string(i);
		if (s.size()%2==1){
			ans++;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N;
    cin >> N;
    int num, ans[N];
    Fp(i, 1, N + 1){
        cin >> num;
        ans[num - 1] = i;
    }
    Fp(i, 0, N) cout << ans[i] << endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
ll lcm(ll l,ll a){
    return a/__gcd(l,a)*l;
}
ll exp(ll a, ll b,ll c){
  if(b==0)return 1;
  if(b%2==0){
    ll t =exp(a,b/2,c);
    return t*t%c;
  }
  else return exp(a,b-1,c)*a%c;
}
const ll big=1000000007;


int main(){
    ll n,k;cin >> n >> k;
    ll ans=0;
    rep2(l,k,n+2){
        ans+=l*(n-l+1)+1;
        ans%=big;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll mypow(ll b, ll e) {
  if(e==0)
    return 1;
  if(e%2==0) {
    ll t = mypow(b,e/2);
    return t*t;
  }
  return mypow(b,e-1)*b;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  ll ans=0;
  rep(k,30) {
    ll c = 0;
    vector<ll> modb(n);
    ll T = mypow(2,k);
    rep(i,n) modb[i]=b[i]%(2*T);
    sort(modb.begin(),modb.end());
    rep(i,n) {
      ll ta = a[i]%(2*T);
      ll c1 = (lower_bound(modb.begin(),modb.end(),(2*T-ta))-lower_bound(modb.begin(),modb.end(),T-ta));
      ll c2 = (lower_bound(modb.begin(),modb.end(),(4*T-ta))-lower_bound(modb.begin(),modb.end(),3*T-ta));
      c+=(c1+c2);
    }
    if(c%2==1) {
      ans+=mypow(2,k);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
main(){
  int w,h,pp=100000;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++)cin>>s[i];
  for(int i=1;i<h;i++)
    for(int j=i+1;j<h;j++){
      int p=0;
      for(int k=0;k<i;k++)
        for(int l=0;l<w;l++)
          if(s[k][l]!='W')p++;
      for(int k=i;k<j;k++)
        for(int l=0;l<w;l++)
          if(s[k][l]!='B')p++;
      for(int k=j;k<h;k++)
        for(int l=0;l<w;l++)
          if(s[k][l]!='R')p++;
      pp=min(p,pp);
    }
  cout<<pp<<endl;
}

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

ll dp[4][3001];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  dp[0][0] = 1;
  for (int i = 0; i <= n; i++)
    for (int j = i; j >= 0; j -= r)
      dp[1][i] += dp[0][j];
  for (int i = 0; i <= n; i++)
    for (int j = i; j >= 0; j -= g)
      dp[2][i] += dp[1][j];
  for (int i = 0; i <= n; i++)
    for (int j = i; j >= 0; j -= b)
      dp[3][i] += dp[2][j];
  cout << dp[3][n] << endl;
}


Measured memory_bytes: 384
import numpy as np

a=[]

for i in range(3):
    a.append(list(map(int,input().split())))

a=np.array(a)

n=int(input())

for i in range(n):
    b=int(input())

    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=-1
                break

bingo=False
for r in range(3):
    if np.all(a[r,:]==-1):
        bingo=True
        

for c in range(3):
    if np.all(a[:,c]==-1):
        bingo=True

if a[0][0]==-1 and a[1][1]==-1 and a[2][2]==-1:
    bingo=True

if a[0][2]==-1 and a[1][1]==-1 and a[2][0]==-1:
    bingo=True

if bingo:
    print('Yes')
else:
    print('No')



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

X=int(input())

400 <= X <=1999

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

Measured memory_bytes: 9200
#include <stdio.h>

int main(void){
  int i,n;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int max=a[1]-a[0];
  int minv=a[0];
  for(i=1;i<n;i++){
    if(max<a[i]-minv) max=a[i]-minv;
    if(minv>a[i]) minv=a[i];
  }
  printf("%d\n",max);
  return 0;
}


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

class Program
{
	static int N,M,X;
	static int[,] bookArr;
	static int minPrice;

	//全探索
	static void Search(int num, int price, int[] pointArr){
			//最後の場合
			if(num == N){
					//条件を満たしているか検索
					bool not_clear = false;
					for(int i=0; i<M; i++){
							if(pointArr[i] < X){
									not_clear = true;
									break;
							}
					}
					if(!not_clear){
							if(price < minPrice){
									minPrice = price;
							}
					}
			}

			else{
					//配列をコピー
					int[] newArr1 = new int[M];
					int[] newArr2 = new int[M];
					Array.Copy(pointArr,newArr1,M);
					Array.Copy(pointArr,newArr2,M);

					//num番目を買わない場合
					Search(num+1, price, newArr1);

					//num番目を買う場合
					for(int i=0; i<M; i++){
							newArr2[i] += bookArr[num,i+1];
					}
					int new_price =  price + bookArr[num, 0];
					Search(num+1, new_price, newArr2);
			}
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む]
		string[] line = Console.ReadLine().Split(' ');
		N = int.Parse(line[0]);
		M = int.Parse(line[1]);
		X = int.Parse(line[2]);

		bookArr = new int[N,M+1];

		for(int i=0; i<N; i++){
				string[] line1 = Console.ReadLine().Split(' ');
				for(int j=0; j<M+1; j++){
						bookArr[i,j] = int.Parse(line1[j]);
				}
		}

		minPrice = 1000000000;

		//全探索
		int[] pointArr = new int[M];
		Search(0, 0, pointArr);

		if(minPrice == 1000000000){
				Console.WriteLine(-1);
		}else{
				Console.WriteLine(minPrice);
		}
	}
}



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

using namespace std;

int main (){
    int A,B,C,D;
    cin >>A >>B >>C >>D;
    if (A*B<C*D){
        cout <<C*D<< endl;
    }
    if (A*B>C*D){
        cout <<A*B<< endl;
    }
    if (A*B==C*D){
        cout <<A*B<< endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
   
int main() {
    double n;
    cin>>n;
    bool ans=false;
    for(int i=0;i<=n;i++){
        if(n<=1.08*i && 1.08*i<n+1){
            cout<<i;
            ans=false;
            break;
        }
        else ans=true;
    }
    if(ans) cout<<":(";
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string mat[500];
    int arr[500]={0};
    int a,b;
    scanf("%d", &a);
    int cnt=0;
    for(int i=0;i<a;i++){
        string s;
        cin>>s;
        int check=0;
        for(int j=0;j<cnt;j++){
            if(mat[j]==s){
                arr[j]+=1;
                check+=1;
            }
        }
        if (check==0){
            mat[cnt]=s;
            arr[cnt]+=1;
            cnt+=1;
        }
    }
    scanf("%d", &b);
    for(int i=0;i<b;i++){
        string s;
        cin>>s;
        int check=0;
        for(int j=0;j<cnt;j++){
            if(mat[j]==s){
                arr[j]-=1;
                check+=1;
            }
        }
        if (check==0){
            mat[cnt]=s;
            arr[cnt]-=1;
            cnt+=1;
        }
    }
    int max=0;
    for(int i=0;i<=cnt;i++){
        if(arr[i]>max){
            max=arr[i];
        }
    }
    printf("%d", max);
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

input = gets.chomp.split(' ')

takahashi_hp = input[0].to_i
takahashi_attack = input[1].to_i
aoki_hp = input[2].to_i
aoki_attack = input[3].to_i

ans = ''
while true do
  aoki_hp -= takahashi_attack
  if aoki_hp <= 0
    ans = 'Yes'
    break
  end
  takahashi_hp -= aoki_attack
  if takahashi_hp <= 0
    ans = 'No'
    break
  end
end

puts ans

Measured memory_bytes: 14356