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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void judge(bool b){b?Yes():No();}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstr;

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vll a(n);
    int ans=INF;

    rep(i, n){
        cin >> a[i];
    }

    rep(i, n){
        int cnt=0;
        while(a[i]%2==0){
            a[i] /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }

    ppp(ans);



    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>

typedef long long ll;
using namespace std;

int main()
{
	int c[8];
	while(~scanf("%d",c)){
		for(int i=1;i<8;i++){
			scanf("%d",c+i);
		}
		int h=0;
		int b=0;

		for(int i=0;i<4;i++){
			if(c[i]==c[i+4]){
				h++;
			}
		}

		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(c[i]==c[j+4] && i!=j){
					b++;
				}
			}
		}
		printf("%d %d\n",h,b);
	}
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;
bool isPrime[MAXN];
vector<int> pr;
vector<int> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

            ans.push_back(i);
        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
int main()
{
    FAST
    int n;
    cin>>n;
    int arr[n+1];
    int cnt=0;
    for(int i=1;i<=n;i++){
    cin>>arr[i];
    if(arr[i]%2==1 && i%2==1)
        cnt++;

    }
    cout<<cnt<<endl;
    return 0;
}


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

int main()
{
	string S, T;
	cin >> S >> T;
	int N = S.size();
	bool ok = false;
	for (int i = 0; i < N; i++) {
		if (S == T) {
			ok = true;
			break;
		}
		rotate(S.begin(), S.begin() + 1, S.end());
	}
	puts(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def solve(N, W, w_v):
    memo = collections.defaultdict(int)
    memo[0] = 0
    for w, v in w_v:
        for w_memo, v_memo in sorted(list(memo.items()), key=lambda x: -x[0]):
            if w + w_memo > W:
                continue
            if memo[w + w_memo] < v_memo + v:
                memo[w + w_memo] = v_memo + v

    return max(memo.values())


def main():
    N, W = ILI()
    w_v = IAI(N)
    print(solve(N, W, w_v))


if __name__ == "__main__":
    main()


Measured memory_bytes: 4648
#include <iostream>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int a, b, c, x; cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i, a+1) rep(j, b+1) rep(k, c+1) {
    if(x == i*500 + j*100 + k*50) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 998244353;

const int MAX = 10010;

int DP[MAX][MAX];

char buf[MAX];
int A[MAX];
int B[MAX];

LL F[MAX];

LL bpow(LL a, LL b)
{
	LL res = 1;
	while(b)
	{
		if (b & 1) res = (res * a) % MOD;
		b /= 2;
		a = (a * a) % MOD;
	}

	return res;
}

LL inv(LL a)
{
	return bpow(a, MOD - 2);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	F[0] = 1;
	FOR (i, 1, MAX)
	{
		F[i] = (F[i-1] * (LL)i) % MOD;
	}

	scanf("%s", buf);
	int n = strlen(buf);
	FOR (i, 0, n)
	{
		A[i] = buf[i] - '0';
	}

	scanf("%s", buf);
	FOR (i, 0, n)
	{
		B[i] = buf[i] - '0';
	}

	int x, y;
	x = y = 0;
	FOR (i, 0, n)
	{
		if (A[i] == 1 && B[i] == 1) x++;
		if (A[i] == 0 && B[i] == 1) y++;
	}

	DP[0][0] = 1;
	FOR (i, 0, x+1)
	{
		FOR (j, 0, y+1)
		{
			if (i == 0 && j == 0) continue;
			LL cur = 0;
			if (j)
			{
				LL c = j;
				c *= DP[i][j-1];
				cur += c;
			}

			if (i && j)
			{
				LL c = j;
				c *= DP[i-1][j];
				cur += c;
			}

			DP[i][j] = cur % MOD;
		}
	}

	LL C = 1;
	LL C2 = 1;

	LL N = x + y;

	LL res = 0;
	FOR (i, 0, x+1)
	{
		LL cur = DP[x - i][y];
		cur *= F[y];
		cur %= MOD;
		cur*= F[x - i];
		cur %= MOD;
		cur *= F[i];
		cur %= MOD;
		cur *= F[i];
		cur %= MOD;
		cur *= C;
		cur %= MOD;
		cur *= C2;
		res = (res + cur) % MOD;

		C = (C * (N - i)) % MOD;
		C = (C * inv(i + 1)) % MOD;

		C2 = (C2 * (x - i)) % MOD;
		C2 = (C2 * inv(i+1)) % MOD;
	}

	cout<<res<<endl;


}


Measured memory_bytes: 389760
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    N = int(inp.readline().strip())
    X = list(map(int, inp.readline().strip().split(' ')))

    r = 999999999999
    for i in range(1, max(X) + 1):
        s = sum(map(lambda x: abs(i - x) * abs(i - x), X))
        r = min(r, s)

    return str(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = int(input().rstrip())
 
current_max = 0
current = []
table = {}
 
for i in range(n):
    s = input().rstrip()
    table[s] = table[s] + 1 if table.get(s) is not None else 1
 
score_sorted = sorted(table.items(), key=lambda x:-x[1])

max = 0
results = []
for k, v in score_sorted:
    if max > v:
      break
    max = v
    results.append(k)

results.sort()

for word in results:
  print(word)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
     
     cin >> a.at(i) ;
     
  }  
  int res =1;
  sort(a.begin(),a.end());
  for(int j=0;j<N-1;j++){
    if (a.at(j+1)!=a.at(j))res++;
  }  
  cout << res<< endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,l;cin>>s;
  ll q,t,f,tsum=0;cin>>q;
  char c;
  rep(i,q) {
    cin>>t;
    if(t==1) tsum++;
    else {
      cin>>f>>c;
      if(f==1) {
        if(tsum%2==0) l+=c;
        else s+=c;
      }
      else {
        if(tsum%2==0) s+=c;
        else l+=c;
      }
    }
  }
  reverse(l.begin(),l.end());s=l+s;
  if(tsum%2==1) reverse(s.begin(),s.end());
  print(s);
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define 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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 100000009;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  ll ans = 1;
  rep(i,n){
    cin >> vec[i];
    if(vec[i] == 0){
      ans = 0;
    }
  }
  if(ans != 0){
    rep(i,n){
      t1 = INFLONG;
      if(t1 / ans < vec[i]){
        ans = -1;
        break;
      }
      ans *= vec[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
#include<iostream>
using namespace std;
#define l long long
#define pb push_back
#define find(v,n) find(v.begin(),v.end(),n)
void frooty()
{
	l n,m;
	cin>>m>>n;
	l sum=0;
	for(l i=0;i<n;i++)
	{
		l a;
		cin>>a;
		sum+=a;
	}
	if(sum>m)
	{
		cout<<-1<<"\n";
	}
	else
		cout<<m-sum<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	l t=1;
	//cin>>t;
	while(t--)
	{
		frooty();
	}
}
		

Measured memory_bytes: 3644
function Main(input){
	input=input.split(/\n|\s/);
	input.forEach(function(e,i,a){a[i]=Number(a[i]);});
	var ans="";
	var lg=input[0];
	input[0]=0;
	var kr=0;
	var aa=0;
	var ar=[];
	
	for(var i=1;i<=lg;i=(i+1)|0){
		aa=input[i]-input[i-1];
		kr+=(aa^(aa>>31))-(aa>>31);
		
		ar[i]=0;
		if((input[i]>input[i+1]&&input[i+1]>=input[i-1])||(input[i]<input[i+1]&&input[i+1]<=input[i-1])){
			ar[i]=input[i]-input[i+1];
			ar[i]=(ar[i]^(ar[i]>>31))-(ar[i]>>31);
			ar[i]=ar[i]<<1;
		}
		else if((input[i]>input[i-1]&&input[i-1]>=input[i+1])||(input[i]<input[i-1]&&input[i-1]<=input[i+1])){
			ar[i]=input[i]-input[i-1];
			ar[i]=(ar[i]^(ar[i]>>31))-(ar[i]>>31);
			ar[i]=ar[i]<<1;
		}
	}
	kr+=(input[lg]^(input[lg]>>31))-(input[lg]>>31);
	for(var i=1;i<=lg;i=(i+1)|0){
		aa=kr-ar[i];
		ans+=aa+"\n";
	}
	ans=ans.slice(0,ans.length-1);
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 31820
H, W = [int(x) for x in input().split()]
A = [input() for _ in range(H)]
blank = [True] * W
for i in range(W):
    for j in range(H):
        if A[j][i] == '#':
            blank[i] = False
            break

for i in A:
    if '#' in i:
        for i,v in enumerate(i):
            if not blank[i]:
                print(v,end='')
        print()

Measured memory_bytes: 4340
#include <iostream>
using namespace std;
int main(void){
    while(true){
        string str;
        cin >> str;
        if(str == "0"){
            break;
        }
        else{
            int sum = 0;
            for(int i = 0; i < str.size(); i++){
                sum += str[i] - '0';
            }
        cout << sum << endl;
        }
    }
    return 0;
}


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

int main(){
  int D, G;
  cin >> D >> G;
  vector<vector<int>> vec(D,vector<int>(2));
  for(int i=0; i<D; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  int ans = 10000000;

  for(int bit = 0; bit < (1 << D); bit++){
    map<int,bool> mp;
    for(int i=0; i<D; i++){
      if(bit & (1 << i)){
        mp[i+1] = true;
      }
    }
    int point = 0;
    int cnt = 0;
    for(int i=0; i<D; i++){
      if(mp.count(i+1)){
        point += vec.at(i).at(0)*(i+1)*100 + vec.at(i).at(1);
        cnt += vec.at(i).at(0);
      }
    }
    if(point >= G){
      ans = min(ans,cnt);
    }
    else{
      for(int i=D-1; i>=0; i--){
        if(mp.count(i+1)){
          continue;
        }
        else{
          for(int j=0; j<vec.at(i).at(0); j++){
            cnt++;
            point += (i+1)*100;
            if(point >= G){
              break;
            }
          }
          break;
        }
      }
      if(point >= G){
        ans = min(ans,cnt);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(n int, b []int) int {
        a := make([]int, n)
        a[0], a[n-1] = b[0], b[n-2]

        for i := 1; i < n-1; i++ {
                a[i] = min(b[i], b[i-1])
        }

        out := 0
        for i := range a {
                out += a[i]
        }
        return out
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func main() {
        var n int
        fmt.Scan(&n)
        b := make([]int, n-1)
        for i := range b {
                fmt.Scan(&b[i])
        }
        fmt.Println(solution(n, b))
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main() {
	int n, m;
	cin >> n >> m;
	ll ans = 0ll, temp;
	vector<ll> x(n), y(n), z(n);
	rep(i, 0, n)cin >> x[i] >> y[i] >> z[i];
	rep(_i, 0, 8) {
		vector<ll> t(n);
		rep(i, 0, n) {
			t[i] += ((_i & 1) ? 1ll : -1ll) * x[i];
			t[i] += ((_i >> 1 & 1) ? 1ll : -1ll) * y[i];
			t[i] += ((_i >> 2 & 1) ? 1ll : -1ll) * z[i];
		}
		sort(all(t));
		reverse(all(t));
		temp = 0ll;
		rep(i, 0, m) {
			temp += t[i];
		}
		ans = max(ans, temp);
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main() {
    
    char c[3][3];
    FOR(i, 0, 3){
        FOR(j, 0, 3){
            cin >> c[i][j];
        }
    }
    
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
    
    return 0;
}


Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
     int h,w;int a[600][600];int color[600][600];vector<pair<pair<int,int>,pair<int,int>>> ans;
    int n=0;int odd=0;bool err=0;int nx=1;int ny=1;
    bool abc=0;
   cin>>h>>w;
    
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
            if(a[i][j]%2!=0)
                odd++;
        }
    odd/=2;
    int i=1,j=1;
    int ca=1;
    while(1){
        if((i==h&&j==w&&ca==1)||(i==h&&j==1&&ca==-1))
            break;
        int pi=i,pj=j;
        if(j==w&&ca==1){
            ca=(-1);
            i++;
        }
        else if(j==1&&ca==-1){
            ca=1;
            i++;
        }
        else
            j+=ca;
        //cout<<i<<" "<<j<<endl;
        if(a[pi][pj]%2!=0){
            a[i][j]++;
            a[pi][pj]--;
            n++;
            ans.pb(mp(mp(pi,pj),mp(i,j)));
        }
    }
    cout<<n<<endl;
    for(int i=0;i<siz(ans);i++)
        cout<<ans[i].fi.fi<<" "<<ans[i].fi.se<<" "<<ans[i].se.fi<<" "<<ans[i].se.se<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 5360
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	


	int N;
	cin >> N;
	vector<ll> dum(N);

	rep(i, N) cin >> dum[i];

	vector<ll> tmps(N);
	tmps[0] = 0;

	int tmp = 0;
	for (int i = 1; i != N - 1;) {
		tmp += dum[i] - dum[(i - 1 == -1) ? N - 1 : i - 1];

		//cout << to_string(i) + ":" + to_string(tmp) << endl;
		tmps[i + 1] = tmp;

		//cout << i << endl;

		i += 2;
		i %= N;
	}

	int A = (dum[0] - tmps[1]);

	for (int i = 0; i < N; i++) {
		cout << to_string(A + 2 * tmps[i]) + " ";
	}


	/* ABC 125_c
	int N;
	cin >> N;

	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	vector<ll> Forward(N), Backward(N);
	Forward[0] = A[0];
	int tmp = A[0];
	for (int i = 1; i < N; i++) {
		tmp = gcd(tmp, A[i]);
		Forward[i] = tmp;
	}

	tmp = A[N - 1];
	Backward[N - 1] = tmp;
	for (int i = N - 2; i >= 0; i--) {
		tmp = gcd(tmp, A[i]);
		Backward[i] = tmp;
	}
	*/


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

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

   vector<int> ans(10000000,0);

   for(int x=1;x<=sqrt(n);x++){
      for(int y=1;y<=x;y++){
         for(int z=1;z<=y;z++){
            int p=x*x+y*y+z*z+x*y+y*z+z*x;
           
            if(x==y && x==z){
               ans[p]+=1;
            }
            else if(x!=y && y!=z && z!=x){
               ans[p]+=6;
            }
            else{
               ans[p]+=3;
            }
         }
      }
   }

   for(int i=1;i<=n;i++){
      cout<<ans[i]<<endl;
   }
   return 0;
}


Measured memory_bytes: 42208
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	a := getNextInt64(scanner)
	b := getNextInt64(scanner)

	g := gcd64(a, b)

	m := map[int64]int{}
	m[1] = 1

	for g > 0 {
		found := false
		for i := int64(2); i*i <= g; i++ {
			if g%i == 0 {
				m[i] = 1
				g /= i
				found = true
				break
			}
		}
		if found == false {
			break
		}
	}

	m[g] = 1

	fmt.Fprintln(writer, len(m))
	writer.Flush()
}

func gcd64(m, n int64) int64 {
	if n == 0 {
		return m
	}
	return gcd64(n, m%n)
}


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

int N, M;
vector<vector<int>> G;
vector<int> indeg;  // 入次数
vector<bool> visited;
vector<int> ans;  // トポロジカルソートの結果

void bfs(int s) {
  queue<int> q;
  q.push(s);
  visited.at(s) = true;
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int nx : G.at(cur)) {
      indeg.at(nx)--;
      if (indeg.at(nx) == 0 && !visited.at(nx)) {
        q.push(nx);
        ans.at(nx) = cur + 1;
      }
    }
  }
}


int main() {
  cin >> N >> M;
  G.resize(N);
  for (int i = 0; i < N-1+M; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    G.at(a).push_back(b);
  }

  indeg.resize(N);
  visited.resize(N);
  ans.resize(N);
  for (int i = 0; i < N; i++) {
    for (int e : G.at(i)) {
      indeg.at(e)++;
    }
  }
  for (int i = 0; i < N; i++) {
    if (indeg.at(i) == 0 && !visited.at(i)) bfs(i);
  }
  for (int v : ans) cout << v << endl;
}

Measured memory_bytes: 9552
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    H = I()
    div_cnt = 0
    ans = 0
    while H > 0:
        ans += (1 << div_cnt)
        H = H // 2
        div_cnt += 1
    print(ans)
main()



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

using namespace std;

int main()
{
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;
    string ans="";
    for(int i=0;i<n;i++){
        ans+=s[i];
        ans+=t[i];
    }
    cout << ans << endl;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e5 + 100;
int a[maxn];

int main()
{
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  ll a = n % k;
  cout << min(a,abs(a - k)) << endl;

  

  return 0;
}

Measured memory_bytes: 3660
using System;
using System.Linq;

namespace PracticeForAtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int k = int.Parse(str[1]);

            str = Console.ReadLine().Split(' ');
            int[] p = new int[n];
            for(int i = 0; i < n; i++)
            {
                p[i] = int.Parse(str[i]);
            }

            int sum=0;

            for(int i = 0; i < k; i++)
            {
                sum += p[i];
            }

            int max = sum;
            for(int i = k; i < n; i++)
            {
                sum = sum - p[i - k] + p[i];
                max = (sum > max) ? sum : max;
                
            }
            double d = (double)(max + k) / 2;

            Console.WriteLine(d);
    
            //ここまで
        }
    }
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF INT_MAX

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1000000007;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int dp[401][401];

int main() {
	int N, Ma, Mb;
	scanf("%d %d %d", &N, &Ma, &Mb);
	int a[40], b[40], c[40];
	rep(i, N) scanf("%d %d %d", &a[i], &b[i], &c[i]);
	fill(dp[0], dp[401], 1e7);
	int res = 1e7;
	dp[0][0] = 0;
	rep(i, N) {
		for(int wa = 400; a[i] <= wa; --wa) {
			for(int wb = 400; b[i] <= wb; --wb) {
				dp[wa][wb] = min(dp[wa][wb], dp[wa - a[i]][wb - b[i]] + c[i]);
				if (wa * Mb == wb * Ma) {
					res = min(res, dp[wa][wb]);
				}
			}
		}
	}
	(res != 1e7) ? printf("%d\n", res) : printf("-1\n");
	return 0;
}

Measured memory_bytes: 1024
S=gets.chop;n=S.size;L=[0]*n;l=[n]*26;(n-1).downto(0){|i|L[i]=l.dup;l[S[i].ord-97]=i};L[-1]=l;q=[-1];z={-1=>[nil,0]};(v=q.shift;l=L[v];26.times{|c|!z[l[c]]&&(z[l[c]]=[v,c];q<<l[c])})while q[0]&&q[0]!=n;r='';(n,c=z[n];r<<(c+97))while n;$><<r.reverse[1..-1]

Measured memory_bytes: 86164
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  if(s[0]!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  string str = s.substr(2,s.length()-2);
  int flag = 0;
  int count = 0;
  rep(i,str.length()){
    if(str[i] == 'C'){
      flag = 1;
      count++;
    }else if(isupper(str[i])){
      cout << "WA" <<endl;
      return 0;
    }
  }
  if((flag==0)||(count!=1)){
    cout << "WA"<<endl;
    return 0;
  }
  
  if(isupper(s[1]) || isupper(s[s.length()-1])){
    cout << "WA" << endl;
  }else{
    cout << "AC"<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 111111
#define M 444444
#define LL long long
using namespace std;
int n,i,k,j,a[N];LL f[N],V1[M],V2[M],E,T;
void ins(int k,int l,int r,int x,LL z1,LL z2){
	if(l==r){V1[k]=z1;V2[k]=z2;return;}
	int md=l+r>>1;
	if(x<=md)ins(k<<1,l,md,x,z1,z2);else ins(k<<1|1,md+1,r,x,z1,z2);
	V1[k]=min(V1[k<<1],V1[k<<1|1]);
	V2[k]=min(V2[k<<1],V2[k<<1|1]);
}
LL qu1(int k,int l,int r,int x,int y){
	if(x>y)return 1e18;
	if(x<=l&&r<=y)return V1[k];
	int md=l+r>>1;
	if(y<=md)return qu1(k<<1,l,md,x,y);
	if(x>md)return qu1(k<<1|1,md+1,r,x,y);
	return min(qu1(k<<1,l,md,x,y),qu1(k<<1|1,md+1,r,x,y));
}
LL qu2(int k,int l,int r,int x,int y){
	if(x>y)return 1e18;
	if(x<=l&&r<=y)return V2[k];
	int md=l+r>>1;
	if(y<=md)return qu2(k<<1,l,md,x,y);
	if(x>md)return qu2(k<<1|1,md+1,r,x,y);
	return min(qu2(k<<1,l,md,x,y),qu2(k<<1|1,md+1,r,x,y));
}
int main(){
	for(i=0;i<M;i++)V1[i]=V2[i]=1e18;
	scanf("%d%lld%lld",&n,&E,&T);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(i=0,k=0;i<=n;i++){
		f[i]=1e18;
		for(;(a[i]-a[k+1])*2>T&&k<i;k++);
		//f[i]=f[k]+max(a[i]-a[k+1]+a[i]-a[k+1],T)+a[i]-a[k];
		//j<=k a[i]-a[j+1*2>T
		//f[i]=qu2(1,0,0,k)
	//	printf("%d %d\n",(a[i]-a[k+1])*2,T);
		if(i==0)f[i]=0;else 
		f[i]=min(qu1(1,0,n,k,i-1)+T+a[i],qu2(1,0,n,0,k-1)+1ll*a[i]*3);
		//printf("%lld %lld\n",qu1(1,0,n,k,i-1)+T+a[i],qu2(1,0,n,0,k-1)+1ll*a[i]*3);
		//printf("%d %d %lld\n",i,k,f[i]);
	//	printf("%lld %lld %d\n",qu1(1,0,n,k,i-1),qu2(1,0,n,0,k-1),T+a[i]);
		//puts("-----------------------");
			//f[i]=min(f[i],f[j]+a[i]-a[j]+max((a[i]-a[j+1])*2,T));
		
		ins(1,0,n,i,f[i]-a[i],f[i]-a[i]-a[i+1]*2);
	}
	printf("%lld\n",f[n]+E-a[n]);
}

Measured memory_bytes: 8448
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N, M, K] = r.nn()

    const uf = _unionFind(N)
    const friends: number[] = []

    for (let i = 0; i < M; i++) {
      let [a, b] = r.nn()

      a--
      b--

      uf.merge(a, b)
      friends[a] = (friends[a] || 0) + 1
      friends[b] = (friends[b] || 0) + 1
    }

    const blocks: number[][] = []

    for (let i = 0; i < K; i++) {
      let [a, b] = r.nn()

      a--
      b--

      if (!blocks[a]) blocks[a] = []
      if (!blocks[b]) blocks[b] = []
      blocks[a].push(b)
      blocks[b].push(a)
    }
    const res: number[] = []

    for (let i = 0; i < N; i++) {
      const size = uf.size(i)
      const f = friends[i] || 0

      const b = (blocks[i] || []).map(v => uf.issame(v, i)).filter(Boolean)
        .length

      res.push(size - f - b - 1)
    }

    return res.map(String).join(' ')
  }

  const _unionFind = n => {
    const par: number[] = Array.from(Array(n).keys())
    const siz: number[] = Array(n).fill(1)

    // 根の検索
    const root = (x: number): number => {
      while (par[x] !== x) x = par[x] = par[par[x]]

      return x
    }
    const merge = (x: number, y: number): boolean => {
      x = root(x)
      y = root(y)
      if (x === y) return false
      if (siz[x] < siz[y]) [x, y] = [y, x]
      // merge technique（データ構造をマージするテク．小を大にくっつける）
      siz[x] += siz[y]
      par[y] = x
      return true
    }
    const issame = (x: number, y: number) => root(x) === root(y)
    const size = (x: number) => siz[root(x)]

    return { root, merge, issame, size }
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map(line => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 75392
#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 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 DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

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

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

    int s,w;
    cin>>s>>w;
    string ans = (s<=w)?"unsafe":"safe";
    cout << ans << endl;
    return 0;
}

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

int main() {
    char x,y;
    cin >> x >> y;
    if(x < y) cout << "<" << endl;
    else if(x == y) cout << "=" << endl;
    else cout << ">" << endl;
}

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

#define int long long 

#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define pb push_back
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MP make_pair
#define sqr(x) ((x) * (x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
	fastio;
	#ifdef FlameDragon
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	
	int n;
	cin >> n;
	vector<int> a[2], pref[2];
	for (int i = 0; i < 2; i++) {
		a[i].resize(n);
		pref[i].resize(n);
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
		for (int j = 0; j < n; j++) {
			pref[i][j] = a[i][j];
			if (j) pref[i][j] += pref[i][j - 1];
		}
	}	
	int ans = 0;
	auto get_sum = [&](int z, int l, int r) {
		return pref[z][r] - (l ? pref[z][l - 1] : 0ll);
	};

	for (int i = 0; i < n; i++) {
		ans = max(ans, get_sum(0, 0, i) + get_sum(1, i, n - 1));
	}
	cout << ans << '\n';

}

Measured memory_bytes: 3620
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

l = [a1,a2,a3,b1,b2,b3]
l.sort()

x = True

for i in range(4):
    if (l[i] == l[i+1]) and (l[i] == l[i+2]):
        x = False
if x == True:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let rec is_prime n i =
  if i*i > n then true
  else if n mod i = 0 then false
  else is_prime n (succ i)

let arr = Array.init (succ 100_000) (fun i ->
    if i <= 2 then 0
    else if i mod 2 = 1 && is_prime i 2 &&
            is_prime ((succ i)/2) 2 then 1 else 0)

let q = scan "%d" id

let () =
  ListL.iter (1 ++^ 100_000) ~f:(fun i ->
      arr.(i) <- arr.(i) + arr.(i-1));
  ListL.iter (scan_lines q "%d %d" Tuple2.make) ~f:(fun (l, r) ->
      Printf.printf "%d\n" @@ arr.(r) - arr.(l-1))


Measured memory_bytes: 11520
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	abt := strings.Split(sc.Text(), " ")
	a, _ := strconv.Atoi(abt[0])
	b, _ := strconv.Atoi(abt[1])
	t, _ := strconv.Atoi(abt[2])
	res := t / a * b
	fmt.Println(res)
}


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

int main() {
    int N, W; cin >> N >> W;
    int v[N], w[N];
    for (int i = 0; i < N; i++) cin >> v[i] >> w[i];

    int dp[N + 1][W + 1] = {};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7068
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}
func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Fscan(fp, &n)
	tree := make([][]int, n+1)
	visited := make([]int, n+1)
	dp := make([][]int64, 2)
	dp[0] = make([]int64, n+1)
	dp[1] = make([]int64, n+1)
	for i := 0; i < n-1; i++ {
		xy := strings.Split(getNextLine(scanner), " ")
		x, _ := strconv.Atoi(xy[0])
		y, _ := strconv.Atoi(xy[1])
		tree[x] = append(tree[x], y)
		tree[y] = append(tree[y], x)
	}
	chokudai(1, tree, visited, dp)
	fmt.Println((dp[0][1] + dp[1][1]) % 1000000007)
}

func chokudai(node int, tree [][]int, visited []int, dp [][]int64) {
	l := len(tree[node])
	a := int64(1)
	b := int64(1)
	visited[node] = 1
	for i := 0; i < l; i++ {
		if visited[tree[node][i]] == 1 {
			continue
		}
		visited[tree[node][i]] = 1
		chokudai(tree[node][i], tree, visited, dp)
		a = (a * (dp[0][tree[node][i]] + dp[1][tree[node][i]])) % 1000000007
		b = (b * dp[0][tree[node][i]]) % 1000000007
	}
	dp[0][node] = a
	dp[1][node] = b
}


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

#define ll long long
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,n,m) for(int i=m; i<n; i++)
#define MAX 100005
#define MOD 1000000007
#define pb push_back
#define debug(x) cout << x << endl;
#define END cout << endl;
#define sorti(x) sort(x.begin(), x.end())
#include <vector>
using namespace std;

/* Union-Find-Tree */
/* 必ず要素数をコンストラクタに入れること */
class Union_Find {
public:
  vector<long long> par;
  vector<long long> rnk;

  Union_Find (long long n) {
    par.resize(n), rnk.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rnk[i] = 0;
    }
  }

  // 木の根を求める
  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }

  // xとyの属する集合を併合
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
  }

  // xとyが同じ集合に属するか否か
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int n,m;
  cin >> n >> m;
  Union_Find ufi(n+1);
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  rep(i,m) {
    int x,y; cin >> x >> y;
    ufi.unite(x,y);
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    if (ufi.same(p[i], i+1)) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const ll MOD=1e9+7;
const int MAXN=1e6+7;

ll ans=0;
ll n,a,b;
ll pot(ll pod,ll wyk){
    ll res=1;
    while(wyk){
        if(wyk&1)res*=pod,res%=MOD;
        pod*=pod;
        pod%=MOD;
        wyk/=2;
    }
    return res;
}
ll gcdE(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll g=gcdE(b,a%b,x1,y1);
    y=x1-(a/b)*y1;
    x=y1;
    return g;
}
ll modInv(ll a){
    ll x, y;
    ll g=gcdE(a,MOD,x,y);
    if(x<0)x+=MOD;
    return x;
}

ll modDiv(ll a,ll b){
    a%=MOD;
    ll inv=modInv(b);
    return (a*inv)%MOD;
}
ll Nwt(ll d,ll g){
    ll l=1,m=1;
    d=max(d,g-d);
    FORE(i,d+1,g){
        l*=i;
        l%=MOD;
    }
    FORE(i,1,g-d){
        m*=i;
        m%=MOD;
    }
    return modDiv(l,m);
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>a>>b;
    ans=pot(2,n);
    ans-=Nwt(a,n);
    ans-=Nwt(b,n);
    ans%=MOD;
    --ans;
    if(ans<0)ans+=MOD;
    cout<<ans<<"\n";
    return 0;
}


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

typedef long long  ll;
typedef vector<int> vec;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int>par;
typedef vector<par>vpar;

#define forn(i,n) for(ll i=0;i<n;i++)
#define wez(n) ll (n); cin>>(n);
#define setmax(a,b) (a)=max((a),(b))
#define setmin(a,b) (a)=min((a),(b))
#define pb push_back
#define mp make_pair
#define outa(a,e) forn(i,e) cout << a[i] << (i==e-1?'\n':' ')
#define oute(n) cout<<n<<"\n"

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ll n,k;
    cin>>n>>k;
    ll h[n],dp[n];
    forn(i,n)cin>>h[i];
    forn(i,n)dp[i]=1e9+5;
    dp[0]=0;
    for(ll i=0;i<n;i++){
      for(int j=i+1;j<=i+k;j++){
        if(j<n){
          dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
      }
    }
    cout<<dp[n-1]<<endl;
return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int n; cin >> n;
  int A[n];
  rep(i,n) scanf("%d",&A[i]);
  int q; cin >> q;
  int m[q];
  rep(i,q) scanf("%d",&m[i]);

  vector<vector<bool>> dp(n+1,vector<bool>(2001,false));
  rep(i,n+1) dp[i][0] = true;

  for (int i=n-1;i>=0;i--){
    for (int j=1;j<=2000;j++){
      if (j-A[i]>=0) dp[i][j] = dp[i+1][j] || dp[i+1][j-A[i]];
      else dp[i][j] = dp[i+1][j];
    }
  }

  rep(i,q){
    cout << (dp[0][m[i]]? "yes" : "no") << endl; 
  }
  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 3252
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N, K;
int l[100];

int main() {
  cin >> N >> K;
  rep(i, 0, N) { cin >> l[i]; }

  sort(l, l + N, greater<int>());

  int ans = 0;
  rep(i, 0, K) { ans += l[i]; }
  cout << ans;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e6+5;
int a[N];
int main()
{
	int n,l,f=0;scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(f)continue;
        if(i>1&&a[i]+a[i-1]>=l)f=i-1;
    }
    if(!f){printf("Impossible\n");return 0;}
    printf("Possible\n");
    for(int i=1;i<=f-1;i++)printf("%d\n",i);
    for(int i=n-1;i>f;i--)printf("%d\n",i);
    printf("%d\n",f);
}


Measured memory_bytes: 1152
s=input()
flg=0
for i in range(len(s)):
    if(s[i] in ['U','D']):
        pass
    elif(s[i]=='R'):
        if(i%2!=0):
            print("No")
            flg=1
            break
    elif(s[i]=='L'):
        if(i%2==0):
            print("No")
            flg=1
            break
if(flg==0):
    print("Yes")



   

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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    rep(i, Q) cin >> A[i];
    vector<int> score(N);
    rep(i, N) score[i] = K-Q;  // 初期値を工夫するのがこの問題のポイント
    rep(i, Q) ++score[A[i]-1];
    rep(i, N) {
        if (score[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1408