akhauriyash/Code-Regression huggingface dataset:
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

struct UnionFind {
  vector<int> data;  // size defined only for root node
  UnionFind(int size) : data(size, -1) { }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int solve(){
  int N,M;cin>>N>>M;
  int A[M];
  int B[M];
  rep(m, M){
    cin>>A[m]>>B[m];
    A[m]--;B[m]--;
  }


  UnionFind uf(N);

  vi res;
  rrep(m, M) {
    if (!uf.same(A[m], B[m])) {
      int tmp = uf.size(A[m]) * uf.size(B[m]);
      uf.merge(A[m], B[m]);
      res.pb(tmp);
    }
    else{
      res.pb(0LL);
    }
  }
  dump(res);

  int t = 0;
  assert(sz(res)==M);
  rrep(m, M){
    t += res[m];
    cout << t << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 4596
program main
	implicit none
    integer::n,x,c,l,i
    integer, allocatable :: a(:)
    read*,n,x
    allocate(a(n))
    read(*, *)(a(i), i = 1,n)
    c=1
    l=0
    i=1
    do i=1,n
    l=l+a(i)
   		if (l<=x) then
    	c=c+1
    	else 
        c=c+0
        end if
    end do
    
print*,c
end program main

Measured memory_bytes: 256
N=int(input())
S=input()
flag=0

if N%2==0:
    for i in  range(0,int(N/2)):
        if S[i]!=S[i+int(N/2)]:
            flag+=1

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

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys


L = input()
#%%
MOD = 10**9+7


dp = [[0]*2 for _ in range(len(L))]
dp[0][0] = 1
dp[0][1] = 2
for i,l in enumerate(L[1:]):
    dp[i+1][0] = (3*dp[i][0] + int(l)*dp[i][1])%MOD
    dp[i+1][1] = ((1+int(l))*dp[i][1])%MOD
print((dp[-1][0]+dp[-1][1])%MOD)

Measured memory_bytes: 19748
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<string>

int main() {
	ll n;
	cin >> n;
	vector<int>p;
	ll sum(0);
	rep(i, n) {
		sum+=i;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
def ncr(n,r):
    ret = 1
    if n<r:
        return 0
    if n-r <r:
        r = n-r
    for i in range(1,r+1):
        ret*=(n-r+i)
        ret//=i
    return ret

n,a = ma()
X = lma()
for i in range(n):
    X[i] -= a
co = collections.Counter(X)
ans = 0
mx = 49*n #ずれの最大はA=1,x=50 2*mx +1この配列
dp = [[0 for j in range(-mx,mx+1)] for i in range(n+1)]# dp[i][j] iまで使って値をjにする組み合わせ
dp[-1][0] = 1 #一個も使わない組み合わせ
for i in range(n):
    x = X[i]
    #print(x)
    for j in range(-mx,mx+1,1):
        dp[i][j] += dp[i-1][j] + dp[i-1][j-x] #選ばない/ぶ
        #if j==0:print(i,j,dp[i-1][j] , dp[i-1][j-x])
print(dp[n-1][0]-1)


Measured memory_bytes: 11816
var
n,m,i:longint;
s:string;
begin
readln(n,m);
read(s);
for i:=1 to n do
  if not(s[i] in['0'..'9']) then begin writeln('No');halt;end;
if s[n+1]<>'-' then begin writeln('No');halt;end;
for i:=n+2 to n+m+1 do
  if not(s[i] in['0'..'9']) then begin writeln('No');halt;end;
writeln('Yes');
end.

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

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans = a[0];
    int res = n-2;
    int i = 1;
    while(1){
        if(res-2>=0){
            ans += a[i]*2;
            res-=2;
        }
        else if(res-1>=0){
            ans += a[i];
            res-=1;
        }
        if(res<=0) break;
        ++i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int V,E;
int G[501][501]; // テ」ツつーテ」ツδゥテ」ツδ陛」ツ?ョテゥツ堋」テヲツ篠・テ」ツδェテ」ツつケテ」ツδ暗ィツ。ツィテァツ渉セ
vector<int> used; // DFSテ」ツ?ァテ」ツ?凖」ツ?ァテ」ツ?ォティツェツソテ」ツ?ケテ」ツ?淌」ツつ嘉」ツδ陛」ツδゥテ」ツつー

// fromテ」ツ?凝」ツつ液oテ」ツ?クテ・ツ青妥」ツ?凝」ツ??・ツョツケテゥツ?縦apテ」ツ?ョティツセツコテ」ツつ津」ツつーテ」ツδゥテ」ツδ陛」ツ?ォティツソツステ・ツ環?」ツ?凖」ツつ?
void add_edge(int from, int to, int cap) {
    G[from][to] = G[to][from] = cap;
}

// テ・ツ「ツ療・ツ環?」ツδ妥」ツつケテ」ツつ奪FSテ」ツ?ァテヲツ篠「テ」ツ??
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < V; i++) {
        auto &cap = G[v][i];
        if (!used[i] && cap > 0) {
            int d = dfs(i, t, min(f, cap));
            if (d > 0) {
                cap -= d;
                G[i][v] += d;
                return d;
            }
        }
    }
    return 0;
}

// sテ」ツ?凝」ツつ液テ」ツ?クテ」ツ?ョテヲツ慊?・ツ、ツァテヲツオツ?」ツつ津ヲツアツづ」ツつ?」ツつ?
int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        fill(used.begin(), used.end(), 0);
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

/* one_path check*/
bool check(int v, int t) {
	if (v == t)return true;
	used[v] = true;
	for (int i = 0; i < V;i++) {
		auto& cap = G[v][i];
		if (!used[i] && cap > 0) {
			if (check(i, t)) {
				cap--;
				G[i][v]++;
				return true;
			}
		}
	}
	return false;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> V >> E;
    int Q; cin >> Q;
    for(int i = 0; i < 501;i++){
        for(int j = 0;j < 501;j++){
            G[i][j] = 0;
        }
    }
    used.resize(V);
    for (int i = 0; i < E;i++) {
        int s, t; cin >> s >> t;
        s--;t--;
        add_edge(s, t, 1);
    }
    
    int f = max_flow(0, V - 1);
    for(int i = 0; i < Q;i++){
        int M,A,B; cin >> M >> A >> B;
        A--;B--;
        if(M == 1){
            G[A][B] = G[B][A] = 1;
            fill(used.begin(),used.end(),0);
            f += dfs(0,V-1,INF);
        }else{
            if(G[A][B] == 0 || G[B][A] == 0){
                int u,v;
                if(G[A][B] == 0){ u = A; v = B;}
                else{u = B; v = A;}
				fill(used.begin(), used.end(), 0);
                if(!check(u,v)){
                    fill(used.begin(),used.end(),0);
					check(u, 0);
                    fill(used.begin(),used.end(),0);
					check(V - 1, v);
                    f--;
                }
            }
            G[A][B] = G[B][A] = 0;
        }
		cout << f << endl;
	}
    return 0;
}

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

typedef long long LL;
inline LL max(LL a, LL b) { return  a > b ? a : b; }

LL flippingSign(int N, vector<int>& A) {
	vector<vector<LL>> dp(2, vector<LL>(N));
	
	dp[0][0] = A[0];
	dp[1][0] = -A[0];
	
	for(int i = 1; i < N-1; i++) {
		dp[0][i] = max( dp[0][i-1] + A[i], dp[1][i-1] - A[i]);
		dp[1][i] = max( dp[0][i-1] - A[i], dp[1][i-1] + A[i]);
	}
	return max(dp[0][N-2] + A[N-1], dp[1][N-2] - A[N-1]);
}

int main() {
	ios::sync_with_stdio(false);
	int N;
	
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	
	cout << flippingSign(N, A);
}



Measured memory_bytes: 2944
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	if((a+b)%2>0){
		c=(a+b)/2+1;
	}else{
		c=(a+b)/2;
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>
#define ll long long
#define lowbit(x) (x&(-x))
using namespace std;

char s[30][30];
int h,w,d[501][501];

int main(){
    memset(d,-1,sizeof d);
    scanf("%d%d",&h,&w);
    for (int i=1;i<=h;++i)
        scanf("%s",s[i]+1);
    for (int i=1;i<=h;++i)
        for (int j=1;j<=w;++j)
            if (s[i][j]=='.'){
                int id=(i-1)*w+j-1;
                if (id>=w&&s[i-1][j]=='.') d[id][id-w]=1;
                if (s[i+1][j]=='.') d[id][id+w]=1;
                if (id&&s[i][j-1]=='.') d[id][id-1]=1;
                if (s[i][j+1]=='.') d[id][id+1]=1;
            }
    for (int k=0;k<h*w;++k)
        for (int i=0;i<h*w;++i)
            for (int j=0;j<h*w;++j)
                if (d[i][k]!=-1&&d[k][j]!=-1){
                    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                    if (d[i][j]==-1) d[i][j]=d[i][k]+d[k][j];
                }
    int ans=0;
    for (int i=0;i<h*w;++i)
        for (int j=0;j<h*w;++j)
        if (i!=j){
            ans=max(ans,d[i][j]);
        }
    printf("%d\n",ans);
}

Measured memory_bytes: 1280
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())


def main():
	a,b,c=map(int,input().split())
	aa=a+b+c
	
	if aa>=22:
		print("bust")
	else:
		print("win")
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
package main

import (
  "fmt"
)

func main() {
  var S, T string
  fmt.Scanf("%s", &S)
  fmt.Scanf("%s", &T)
  
  var cnt int
  for i := 0; i < 3; i++ {
    if S[i] == T[i] {
      cnt++
    }
  }
  
  fmt.Println(cnt)
}

Measured memory_bytes: 512
X, Y = [int(v) for v in input().rstrip().split()]

r = 'No'
if Y % 2 == 0:
	for n in range(X + 1):
		cn = n
		tn = X - cn
		if cn * 2 + tn * 4 == Y:
			r = 'Yes'
			break

print(r)


Measured memory_bytes: 8952
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;


int n, m, c, cou, s[20];
int b[20];
int a[20][20];

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

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

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			s[i] += a[i][j] * b[j];
		}
		if (s[i] + c > 0) cou++;
	}


	cout << cou << endl;




	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b,ll mod) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 1e5+7;
int T,n,m;
int a[N];
int main()
{
    //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    while(cin>>n){
        
        cin >> T >> m;
        if(n==1)
            puts("Hello World");
        else
            printf("%d\n", T + m);
    }
    return 0;
}

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

ll solve() {
    ll N, a, s=0;
    cin >> N;
    vector<ll> AA(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        AA[i] = a - i - 1;
        s += AA[i];
    }
    sort(AA.begin(), AA.end());
    ll b = AA[N/2];
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        ans += abs(AA[i]-b);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
def main():
    class rolling_hash():
        def __init__(self, sequence, char_list=None):
            self.sequence = sequence  # 文字列
            self.seq_size = len(self.sequence)  # 文字列の長さ
            self.mod = 2**61-1  # mod
            if char_list is None:  # 使われている文字のリスト
                self.char_list = "abcdefghijklmnopqrstuvwxyz"
            else:
                self.char_list = char_list
            self.base = len(self.char_list)+1  # 文字の種類数
            self.char_dict = {j: i+1 for i,
                              j in enumerate(self.char_list)}  # 文字と数値の対応表
            self.Hash_0start = [0]*(self.seq_size+1)  # 先頭からi-1文字目までのハッシュ値
            for i in range(self.seq_size):
                self.Hash_0start[i+1] = self.Hash_0start[i] + \
                    self.char_dict[self.sequence[i]] * \
                    pow(self.base, i, self.mod)

        def calc_hash(self, l, r):  # l文字目からr-1文字目までのハッシュ値
            return ((self.Hash_0start[r] - self.Hash_0start[l])
                    * pow(self.base, l*(self.mod-2), self.mod)) % self.mod

    n = int(input())
    s = input()
    h_s = rolling_hash(s)

    def value(num):
        h_dict = {}
        for i in range(len(s)-num+1):
            j = h_s.calc_hash(i, i+num)
            if j not in h_dict.keys():
                h_dict[j] = i
            else:
                if i-h_dict[j] >= num:
                    return True
        return False

    def b_search(a, b, value):
        while a+1 < b:
            med = (a+b)//2
            if value(med):
                a = med
            else:
                b = med-1
        if a == b:
            return a
        elif a+1 == b:
            if value(b):
                return b
            else:
                return a

    print(b_search(0, len(s), value))


main()


Measured memory_bytes: 4016
function Main(input) {
	input = input.trim(); 
	input = input.split("\n");

	var member = input[0];

	var imput_tmp = input[1].split(" ");
	var days = parseInt(imput_tmp[0], 10);
	var nokori = parseInt(imput_tmp[1], 10);

	var chocolate_cnt = 0;
	var eatday;
	for (var i = 2; i < input.length + 1; i++) {

		for (var j = 0; j < days + 1; j++) {
			eatday = input[i] * j + 1;
			if (eatday <= days) {
				chocolate_cnt += 1;
			} else {
				break;
			}
		}
	}
	
	console.log(chocolate_cnt + nokori);

}

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

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std; 
int n,m;
long long int k;
long long int a[300000];
long long int b[300000];
int main() {
    cin>>n>>m>>k;
    long long int sum = 0;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
 
    int res = 0;
    int atake = n;
    int btake = 0;
    while(true) {
        
        if(sum<=k) {
            res = max(res, atake + btake);
            if(btake<m) {
                sum+=b[btake];
                btake++;
            }
            else {
                break;
            }
        }
        else {
            if(atake==0) {
                break;
            }
            atake--;
            sum-=a[atake];
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 6728
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    long long int n,an=-1,bn=-1,k=0;
    cin>>n;
    string c,s="12345678";
    vector<char>a(1000);
    vector<char>b(1000);
    for(int i=0;i<n;i++){
        c+=s[i];
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    while(an==-1||bn==-1){
        for(int i=0;i<n+1;i++){
            if(a[i]!=c[i]){
                break;
            }
            if(i==n){
                an=k;
            }
        }
        for(int i=0;i<n+1;i++){
            if(b[i]!=c[i]){
                break;
            }
            if(i==n){
                bn=k;
            }
        }
        
        k++;
        std::next_permutation(c.begin(),c.end());
    }
    cout<<abs(an-bn)<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll x,y;
int main(){
	cin >> x >> y;
	if(x % y == 0){
		puts("-1");
	}
	else{
		cout << x << endl;
	}
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define N 300009
#define inf 1e18
//int mod=1e9+7;
int mod=998244353;
#define ll int
#define P pair<int,int>

int MOD(int n){
    if(n>=mod)
    n-=mod;
    return mod;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe\n";
    }
    else{
        cout<<"safe\n";
    }

    return 0;
}

Measured memory_bytes: 3636
import sys
readline = sys.stdin.buffer.readline
def main():
    x1, y1, x2, y2 = map(int, readline().split())
    A = complex(x1, y1)
    B = complex(x2, y2)
    routate = 1j
    C = (B-A) * routate + B
    D = (B-A) * routate + A
    print(int(C.real), int(C.imag), int(D.real), int(D.imag))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input!(n: usize, a: usize, b: usize);
    if n < a + b - 1 || a * b < n {
        println!("-1");
        std::process::exit(0);
    }
    let part: Vec<_> = (0..=a).map(|i| (i * b).min(n - a + i)).collect();
    let mut ans: Vec<_> = (0..n).collect();
    for i in 0..a {
        let l = part[i];
        let r = part[i + 1];
        ans[l..r].reverse();
    }
    println!(
        "{}",
        ans.into_iter()
            .map(|x| (x + 1).to_string())
            .fold("".to_string(), |acc, s| if acc.is_empty() {
                s
            } else {
                acc + " " + s.as_ref()
            })
    );
}


Measured memory_bytes: 7844
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int a, b, c, d, A, B;
	cin >> a >> b >> c >> d;
	A = min(a, b);
	B = min(c, d);
	cout << A + B << endl;





	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
l = []

for i in range(1, n, 2):
    ans -= a[i]
    ans += a[i + 1]

l.append(ans)

for i in range(n - 1):
    ans = (a[i] - ans//2)*2
    l.append(ans)

for i in l:
    print(i, end = " ")

Measured memory_bytes: 20644
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
struct st
{
	int kt,d;
};
bool cmp(st a,st b)
{
	return a.d>b.d;
}
int n,k;
st a[101010];
bool vis[101010];
stack<int>s;
long long cnt,ans,tp,now;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].kt>>a[i].d;
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	{
		if(cnt<k)
		{
			if(!vis[a[i].kt])
			{
				vis[a[i].kt]=true;
				tp++;
			}
			else
			{
				s.push(a[i].d);
			}
			now+=a[i].d;
			cnt++;
			ans=max(ans,now+tp*tp);
		}
		else
		{
			if(s.empty())
			{
				break;
			}
			if(vis[a[i].kt])
			{
				continue;
			}
			vis[a[i].kt]=true;
			tp++;
			now-=s.top();
			now+=a[i].d;
			s.pop();
			ans=max(ans,now+tp*tp);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define N 102

int h, w, v[N][N], ey, ex;
short dp[N][N][N][N], ch[N][N], cv[N][N], ans;
char gr[N][N];
int main() {
	scanf("%d %d", &h, &w);
	fo(i,0,h) {
		scanf("%s", gr[i]);
		fo(j,0,w) {
			if (gr[i][j]=='o') v[i+1][j+1] = 1;
			if (gr[i][j]=='E') ey = i+1, ex = j+1;
		}
	}
	fo(i,1,h+1) fo(j,1,w+1) {
		ch[i][j] = ch[i][j-1] + v[i][j];
		cv[i][j] = cv[i-1][j] + v[i][j];
	}
	int sx1 = w - ex, sx2 = ex-1, sy1 = h - ey, sy2 = ey-1;
	fo(x1,0,sx1+1) fo(x2,0,sx2+1) fo(y1,0,sy1+1) fo(y2,0,sy2+1) {
		ans = max(ans, dp[x1][x2][y1][y2]);
		int tx1 = min(x1, sx1 - x2), tx2 = min(x2, sx2 - x1), ty1 = min(y1, sy1 - y2), ty2 = min(y2, sy2 - y1);
		if (x1 + x2 < sx1) dp[x1+1][x2][y1][y2] = max(dp[x1+1][x2][y1][y2], short(dp[x1][x2][y1][y2] + cv[ey + ty1][ex + x1 + 1] - cv[ey-ty2-1][ex + x1 + 1]));
		if (x1 + x2 < sx2) dp[x1][x2+1][y1][y2] = max(dp[x1][x2+1][y1][y2], short(dp[x1][x2][y1][y2] + cv[ey + ty1][ex - x2 - 1] - cv[ey-ty2-1][ex - x2 - 1]));
		if (y1 + y2 < sy1) dp[x1][x2][y1+1][y2] = max(dp[x1][x2][y1+1][y2], short(dp[x1][x2][y1][y2] + ch[ey + y1 + 1][ex + tx1] - ch[ey + y1 + 1][ex - tx2 - 1]));
		if (y1 + y2 < sy2) dp[x1][x2][y1][y2+1] = max(dp[x1][x2][y1][y2+1], short(dp[x1][x2][y1][y2] + ch[ey - y2 - 1][ex + tx1] - ch[ey - y2 - 1][ex - tx2 - 1]));
	}
	printf("%d\n", (int)ans);

	return 0;
}

Measured memory_bytes: 52224
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int ans;
  long int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(abs(A - B) < pow(10,18))ans = pow(-1,(K%2)) * (A - B);
  else cout << "Unfair";
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll level[100005];
vector<pair<ll int,ll int>>adj[100005];
void dfs(ll int child,ll int par,ll int dis)
{
    level[child]=level[par]+dis;
    for(auto x:adj[child])
    {
        if(x.first==par) continue;
        dfs(x.first,child,x.second);
    }
}
int main()
{
    long long int i,j,k,z,t,x,y,n;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>x>>y>>z;
        adj[x].push_back({y,z});
        adj[y].push_back({x,z});
    }
    dfs(1LL,0LL,0LL);
    for(i=1;i<=n;i++)
    {
        if(level[i]%2==0)
            cout<<1<<endl;
        else
            cout<<0<<endl;
    }
}

Measured memory_bytes: 13340
/*
 * Ankit Raj, NIT Agartala
 */
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define MAX_RANGE 10000007
#define BOOST ios_base::sync_with_stdio(0) 
#define NITRO cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int main()
{
	BOOST;
	NITRO;
	//clock_t t1,t2;
	//t1 = clock();
	/*
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	*/ 
	//Main Code
	int n,cap;
	cin>>n>>cap;
	int wgt[n];
	int val[n];
	for(int i=0;i<n;i++)
	{
		cin>>wgt[i]>>val[i];
	}
	lld dp[n+1][cap+1];
	for(int i=0;i<=n;i++)
	{
		for(int wt=0;wt<=cap;wt++)
		{
			if(i==0 || wt==0)
			{
				dp[i][wt]=0;
			}
			else if(wgt[i-1]<=wt)
			{
				dp[i][wt] = max(val[i-1]+dp[i-1][wt-wgt[i-1]],dp[i-1][wt]);
			}
			else
			{
				dp[i][wt] = dp[i-1][wt];
			}
		}
	}
	cout<<dp[n][cap]<<"\n";

	//t2 = clock();
	//float diff = (float)t2 - (float)t1;
	//float execution_time = diff/CLOCKS_PER_SEC;
	//cout<<"\n"<<execution_time;
	//system("pause");
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const ll inf = 1e18 + 1;
const double eps = 1e-9;
const int MAXN = 2e5 + 5;
const int offset = 1<<18;

int n, m;
int l[MAXN], r[MAXN];
ll c[MAXN];
ll T[4*offset], prop[4*offset];
ll dp[MAXN];
ll sol;
vector <pii> vpii;
vector <vector<pii> > v;

void build(){
    for (int i = 0; i < 4*offset; i++) T[i] = prop[i] = 0;
    return;
}

void refresh(int cvor){
    T[cvor*2] += prop[cvor];
    prop[cvor*2] += prop[cvor];
    T[cvor*2+1] += prop[cvor];
    prop[cvor*2+1] += prop[cvor];
    prop[cvor] = 0;
}

void update(int cvor, int l, int r, int a, int b, ll x){
    if (l > b || r < a) return;
    if (l >= a && r <= b){
        T[cvor] += x;
        prop[cvor] += x;
        return;
    }

    refresh(cvor);

    int mid = (l+r)/2;

    update(cvor*2, l, mid, a, b, x);
    update(cvor*2+1, mid+1, r, a, b, x);

    T[cvor] = max(T[cvor*2], T[cvor*2+1]);
}

ll query(int cvor, int l, int r, int a, int b){
    if (l > b || r < a) return -inf;
    if (l >= a && r <= b) return T[cvor];

    refresh(cvor);

    int mid = (l+r)/2;

    ll x = query(cvor*2, l, mid, a, b);
    ll y = query(cvor*2+1, mid+1, r, a, b);

    return max(x, y);
}

int main(){

    build();

    cin >> n >> m;
    v.insert(v.begin(), n, vpii);
    for (int i = 0; i < m; i++){
        cin >> l[i] >> r[i] >> c[i];
        l[i]--; r[i]--;
        v[r[i]].pb(mp(l[i], c[i]));
        update(1, 0, offset-1, l[i], offset-1, -c[i]);
    }

    for (int i = 0; i < n; i++){
        dp[i] = -query(1, 0, offset-1, i, i);
        dp[i] = max(dp[i], dp[i]+query(1, 0, offset-1, 0, i-1));
        update(1, 0, offset-1, i, i, dp[i]);
        for (int j = 0; j < v[i].size(); j++) update(1, 0, offset-1, v[i][j].fi, offset-1, v[i][j].se);
        sol = max(sol, dp[i]);
    }

    cout << sol;

    return 0;

}


Measured memory_bytes: 32256
n = gets.to_i

s = 0
puts s
STDOUT.flush
l = gets[0]
exit if l == "V"

t = n - 1
puts t
STDOUT.flush
r = gets[0]
exit if r == "V"

18.times do
    u = (s + t) / 2
    puts u
    STDOUT.flush
    x = gets[0]
    exit if x == "V"

    if ((u - s + 1).odd? && l != x) || ((u - s + 1).even? && l == x)
        t = u
        r = x
    else
        s = u
        l = x
    end
end

Measured memory_bytes: 2384
#include<bits/stdc++.h>
using namespace std;
double a[100];
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
  	cin>>a[i];
  }
  sort(a,a+n);
  for(int i=1;i<n;i++)
  {
  	a[i]=(a[i-1]+a[i])/2*1.0;
  }
  cout<<a[n-1];
  return 0;
}

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

int main(){
	int a;
	int b;
	cin >> a;
	cin >> b;
	int c;
	if ( a*b != 0 ) {
		while(true) {
			if ( a>b ) {
				c=a;
				a=b;
				b=c;
			}
			if ( a==0 ) break;
			b=b%a;
		}
	}else {
		b=0;
	}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 1160
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

D = lines[0][0]
Inf = 10 ** 10

class Array
  def max_id
    max = - Inf
    tmp = -1
    for i in 1..self.length do
      if self[i-1] > max then
        tmp = i-1
        max = self[i-1]
      end
    end
    return tmp
  end
end

last_date = []
for i in 1..26 do
  last_date.push(0)
end

satis = 0
for i in 1..D do
  max_satis = - Inf
  best_contest = 0
  for k in 1..26 do
    now_satis = 0
    now_satis += lines[i+1][k-1]
    for j in 1..26 do
      if j != k then
        now_satis -= (i - last_date[k-1]) * lines[1][j-1]
      end
    end
    if now_satis > max_satis then
      max_satis = now_satis
      best_contest = k
    end
  end
  satis += lines[i+1][best_contest-1]
  last_date[best_contest-1] = i
  if i < D then
    puts best_contest
  else
    print best_contest
  end
end

Measured memory_bytes: 14388
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val al = List.fill(n)(sc.nextInt)

  val gcdL = al.foldLeft(Vector.empty[Int]){case (vec,a) =>
      if (vec.isEmpty) Vector(a)
      else vec :+ gcd(vec.last, a)
  }

  val gcdR = al.foldRight(Vector.empty[Int]){case (a,vec) =>
    if (vec.isEmpty) Vector(a)
    else vec :+ gcd(vec.last, a)
  }.reverse

//  gcdL.foreach(w => print(s"$w "))
//  println
//
//  gcdR.foreach(w => print(s"$w "))
//  println

  val res = (0 until n).foldLeft(1){case (max,k) =>
    val temp =
      k match{
        case 0     => gcdR(1)
        case x if x == n - 1 => gcdL(x - 1)
        case x     => gcd(gcdL(x - 1), gcdR(x + 1))
      }
//    println(s"temp = $temp")
    Math.max(temp, max)
  }

  println(res)


  def gcd(a: Int, b: Int): Int ={
    (a,b) match{
      case (x,y) if y == 0 => x
      case (x,y) if x < y  => gcd(y, x)
      case (x,y)           => gcd(y, x % y)
    }
  }

}


Measured memory_bytes: 79488
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1)

int main(){
  int a, b, c, d, p;
  cin >> a >> b >> c >> d >> p;
  int x, y;
  x = a * p;
  if(p <= c){
    y = b;
  }else{
    y = b + d * (p - c);
  }
  cout << min(x, y) << endl;
}

Measured memory_bytes: 1164
#!/usr/bin/perl
#abc086_a.pl
#Sun Jan 21 21:00:30 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;

my @temps = split(" ",$temp);

my $a = $temps[0];
my $b = $temps[1];

my $total = $a * $b;

if ($total%2==1){
	print "Odd\n";
}else{
	print "Even\n";
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=[LI() for i in range(n)]
for i in range(n-1):
    time=lis[i][1]+lis[i][0]
    pos=i+1
    #print(time,end=" ")
    #print(pos)
    while pos<n-1:
        if time<lis[pos][1]:
            time=lis[pos][1]
        if time%lis[pos][2]!=0:
            time+=(lis[pos][2]-time%lis[pos][2])
        time+=lis[pos][0]
        pos+=1
        #print(time,end=" ")
        #print(pos)
    print(time)
print(0)

Measured memory_bytes: 3572
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	int N,M,T,pre,current,maximum;

	scanf("%d %d %d",&N,&M,&T);

	scanf("%d",&current);

	maximum = current - M;
	pre = current;

	for(int i = 1; i < N; i++){
		scanf("%d",&current);

		if(current - pre > 2*M){
			maximum += current-pre-2*M;
		}

		pre = current;
	}
	if(T - pre > M){
		maximum += T-pre-M;
	}

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

	return 0;
}

Measured memory_bytes: 2768
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
int n,m,cnt[1025];
int F(int x,int y){
	return cnt[x&y];
}
int main(){
	For(i,0,1023) cnt[i]=cnt[i/2]^(i&1);
	scanf("%d%d",&n,&m);
	For(i,1,(1<<n)-1){
		For(j,1,(1<<m)-1)
			putchar('0'^F(i,j)^F(i-1,j)^F(i,j-1)^F(i-1,j-1));
		puts("");
	}
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int[] alpha = new int['z' - 'a' + 1];
		
		StringBuffer line;
		for (; sc.hasNextLine();) {
			line = new StringBuffer(sc.nextLine());
			for (int i = 0; i < line.length(); i++) {
				char ch = line.charAt(i);
				if (ch >= 'a' && ch <= 'z') {
					alpha[ch - 'a']++;
				} else if (ch >= 'A' && ch <= 'Z') {
					alpha[ch - 'A']++;
				}
			}
		}
		
		for (int i = 0; i < 'z' - 'a' + 1; i++) {
			StringBuffer result = new StringBuffer();
			result.append((char)(i + 'a'));
			result.append(" : ");
			result.append(alpha[i]);
			System.out.println(result);
		}
		
		sc.close();
	}
}

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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int four[] = {0, 1, 0, -1, 0};

int main(){
	int h, w;
	cin >> h >> w;
	std::vector<std::vector<char>> s(h, std::vector<char>(w));
	RC(i, h) RC(j, w) cin >> s[i][j];
	int max = 0;
	RC(i, h) RC(j, w) if(s[i][j] == '.'){
		vector<vector<int>> a(h, vector<int>(w, -1));
		a[i][j] = 0;
		queue<pair<int, int>> q;
		q.push(pair<int, int>(i, j));
		while(!q.empty()){
			pair<int, int> next = q.front();
			RC(k, 4){
				if(
					0 <= next.first + four[k]
					&& next.first + four[k] < h
					&& 0 <= next.second + four[k + 1]
					&& next.second + four[k + 1] < w
					&& s[next.first + four[k]][next.second + four[k + 1]] == '.'
					&& a[next.first + four[k]][next.second + four[k + 1]] == -1
				){
					anth(max, a[next.first + four[k]][next.second + four[k + 1]] = a[next.first][next.second] + 1);
					q.push(pair<int, int>(next.first + four[k], next.second + four[k + 1]));
				}
			}
			q.pop();
		}
//		RC(k, h) RC(l, w) printf("%3d%c", a[k][l], " \n"[l == w - 1]);
//		cout << endl;
	}
	cout << max << endl;
}


Measured memory_bytes: 256
//<editor-fold desc="Headers & Macros">
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define o(x) cout << x << '\n'
#define o2(x, y) cout << x << ' ' << y << '\n'
#define on() cout << '\n'
#define os(x) cout << x << ' '

#define i(x) cin >> x
#define i2(x, y) cin >> x >> y

#define DBG = 1

using ll = long long;
//</editor-fold>

struct Item {
    int weight;
    int value;
};

int main() {
    //<editor-fold desc="Init">
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //</editor-fold>

    int n, total_weight;
    i2(n, total_weight);

    vector<ll> best_value(total_weight + 1, 0);

    for (int i = 0; i < n; ++i) {
        Item item{};

        i2(item.weight, item.value);

        for (int remaining_weight = total_weight - item.weight; remaining_weight >= 0; --remaining_weight) {
            // Is it a good idea to take item i-th?
            ll best_value_with_item = best_value[remaining_weight] + item.value;
            int weight_with_item = remaining_weight + item.weight;

            if (best_value_with_item > best_value[weight_with_item]) {
                // Yes! Let's do it
                best_value[weight_with_item] = best_value_with_item;
            }
        }
    }

    o(best_value[total_weight]);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>

void check_multiplicity(const int* sorted_cards, std::map<int,int>& multiplicities)
{
	multiplicities.clear();

	const int* current = sorted_cards;
	const int* end = sorted_cards + 5;
	while (current != end) {
		const int* next = std::upper_bound(current, end, *current);
		++multiplicities[next - current];
		current = next;
	}
}

int count(const std::map<int,int> multiplicities, int multiplicity)
{
	std::map<int,int>::const_iterator i = multiplicities.find(multiplicity);
	return (i != multiplicities.end()) ? i->second : 0;
}

bool check_straight(const int* sorted_cards, std::map<int,int> multiplicities)
{
	if (count(multiplicities, 1) != 5) {
		return false;
	}
	return (sorted_cards[4] == sorted_cards[0] + 4)
		|| (sorted_cards[0] == 1 && sorted_cards[1] == 10);
}

int main()
{
	int cards[5] = {};
	while (scanf("%d,%d,%d,%d,%d",&cards[0],&cards[1],&cards[2],&cards[3],&cards[4]) == 5) {
		std::sort(cards, cards + 5);
		std::map<int,int> multiplicities;
		check_multiplicity(cards, multiplicities);

		if (count(multiplicities, 4) > 0) {
			std::cout << "four card\n";
		} else if (count(multiplicities, 3) > 0 && count(multiplicities, 2) > 0) {
			std::cout << "full house\n";
		} else if (check_straight(cards, multiplicities)) {
			std::cout << "straight\n";
		} else if (count(multiplicities, 3) > 0) {
			std::cout << "three card\n";
		} else if (count(multiplicities, 2) == 2) {
			std::cout << "two pair\n";
		} else if (count(multiplicities, 2) == 1) {
			std::cout << "one pair\n";
		} else {
			std::cout << "null\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1192
<?php
fscanf(STDIN, '%d %d %d', $n, $a, $b);

$sum = $a + $b;
$fraction = $n % $sum;
if ($n >= $sum) {
  $count = (int)floor($n / $sum);
  $result = $count * $a;
} else {
  $result = 0;
}

if ($a >= $fraction) {
  $result += $fraction;
} else {
  $result += $a;
}

echo $result;

Measured memory_bytes: 4604
#include <bits/stdc++.h> 
using namespace std;
typedef vector<int> int_vector;
typedef vector< vector<int> > int_matrix;
typedef vector<string> string_vector;
typedef vector< vector<string> > string_matrix;
int main(){
    string S;
    cin >> S;
    int n = S.size();
    int cnt=0;
    for (int i=0; i < n/2; i++){
        if (S[i] != S[n-1-i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  vector<ll> a(3);
  rep(i,3) cin >> a[i];
  
  vsort(a);

  ll m = a[2] - a[1] + a[2] - a[0];

  if(m % 2) m += 3;

  cout << m / 2 << endl;
 
  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
 
using namespace std;

signed main() {
  double r;
  cin >> r;
  printf("%.10f\n", 2 * r * M_PI);
  return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#define llint long long
#define inf 1000000000

using namespace std;

llint n;
vector<llint> G[205];
int color[205];
llint dist[205];

bool dfs(int v, int p, int c)
{
	color[v] = c;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		if(color[G[v][i]] == -c) continue;
		if(color[G[v][i]] == c) return false;
		if(!dfs(G[v][i], v, -c)) return false;
	}
	return true;
}

llint bfs(int s)
{
	for(int i = 1; i <= n; i++) dist[i] = inf;
	dist[s] = 0;
	
	queue<int> Q;
	Q.push(s);
	while(Q.size()){
		int v = Q.front();
		Q.pop();
		for(int i = 0 ;i < G[v].size(); i++){
			if(dist[G[v][i]] < inf) continue;
			dist[G[v][i]] = dist[v] + 1;
			Q.push(G[v][i]);
		}
	}
	
	llint ret = 0;
	for(int i = 1; i <= n; i++) ret = max(ret, dist[i]);
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	char c;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cin >> c;
			if(c == '1') G[i].push_back(j);
		}
	}
	
	if(!dfs(1, -1, 1)){
		cout << -1 << endl;
		return 0;
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, bfs(i));
	}
	cout << ans+1 << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll n , r = 0 , ans=0 ;
    cin >> n ;
    vector<ll> a(n) , b(n) , v ;
    rep( i , 0 , n )
        cin >> a[i] ;
    rep( i , 0 , n )
        cin >> b[i] ;
    rep( i , 0 , n )
    {
        if( a[i] < b[i] )
        {
            ans++;
            r += b[i] - a[i] ;
        }
        else if( a[i] > b[i] )
        {
            v.pb( a[i] - b[i] ) ;
        }
    }
    sort(all(v));reverse(all(v));
    rep( i , 0 , sz(v) )
    {
        if( r > 0 ){
            r -= min(r,v[i]) ;
            ans++;
        }
    }
    if( r > 0 )
        cout << -1 ;
    else
        cout << ans ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 2428
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int i,j,c,g,tim,head,last;
int wait[101],seat[17];

int main(){
	last=-1;
	while(head<100){
		if(tim%5==0 && last<100)last++;

		for(i=0;i<17;i++)if(seat[i]>0)seat[i]--;
		for(g=head;g<=last;g++){
			c=0;
			for(i=0;i<17;i++){
				if(seat[i]>0)c=0; else c++;
				if(c == (g%5==1?5:2) ) break;
			}
			if(i<17){
				for(c--;c>=0;c--)seat[i-c]=17*(g%2)+3*(g%3)+19;
				head++;
			}
			else break;
		}
		
		for(g=head;g<=last;g++)wait[g]++;

		tim++;
	}

	while(scanf("%d",&g)!=EOF)printf("%d\n",wait[g]);

	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    vector<pair<int, ll>> v(n);
    
    ll x;
    pair<ll, int> p;
    for (int i = 0; i < n; i++) {
        cin >> x;
        p .first = x;
        p.second = i;
        v[i] = p;
    }
    sort(v.begin(), v.end());
    int a[n];
    for (int i = 0; i < n; i++) {
        a[v[i].second] = i;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] < n / 2) {
            cout << v[(n+1)/2+1-1].first << endl;
        }else{
            cout << v[(n+1)/2-1].first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6144
yakusu = []
i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
if a == 10000 and b == 10000 and c ==1:
    print(0)
elif a == c and b == a and c == b:
    print(1)
else:
    for i in range(1,c+1):
        if c % i == 0 and a<=i and i<=b and c != 1:
            yakusu.append(i)
    print(len(yakusu))


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    PRINT(3*r*r);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    if (s == "Sunny"){
        cout << "Cloudy" << endl;
    }
    if (s == "Cloudy"){
        cout << "Rainy" << endl;
    }
    if (s == "Rainy"){
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256