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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n; cin >> n;
  vector<int> itm;
  int v[n],c[n];
  REP(i,n) cin >> v[i];
  REP(i,n) cin >> c[i];
  REP(i,n) {
    itm.PB(v[i] - c[i]);
  }

  sort(ALL(itm));
  int ans = 0;
  REP(i,SIZE(itm)) {
    if (itm[i]>0) ans += itm[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){

    int n;
    I(n);

    int ar[n+2];
    map<int,int>mp;
    for(int i = 1;i<=n;i++){
        I(ar[i]);
        mp[ar[i] + i]++;
    }

    ll res = 0;
    for(int i = 1;i<=n;i++){
        mp[ar[i] + i]--;
       // cout<<(i-ar[i])<<endl;
        res += mp[i - ar[i]];
         mp[ar[i] + i]++;
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 21380
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

#define YES_ cout<<"Yes"<<endl; return 0;
#define NO_ cout<<"No"<<endl; return 0;

struct MASU {
	int X, Y;
};

vector<MASU> masu(90001);
int d[90001];

//int D[300*300][300*300];
std::map<pair<int, int>, int> mp;
int main() {
	int H, W, D, Q;
	cin >> H >> W >> D;

	masu.resize(H*W + 1);

	REP(h, H)REP(w, W) {
		int a;
		cin >> a;
		masu[a].X = w;
		masu[a].Y = h;
	}
	memset(d, 0, sizeof(d));
	for (int i = D + 1; i <= H * W; i++) {
		d[i] = d[i - D] + abs(masu[i].X - masu[i - D].X) + abs(masu[i].Y - masu[i - D].Y);
	}
	cin >> Q;
	REP(q, Q) {

		int L, R;
		cin >> L >> R;
		LL dist = d[R] - d[L];
		cout << dist << endl;
	}

}


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int X, Y;
    cin >> X >> Y;

    cout << (Y % 2 == 0 and 2*X <= Y and Y <= 4*X ? "Yes": "No") << '\n';

    return 0;
}


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

int main() {
    string inputStr, outputStr, tmpStr;
    cin >> inputStr;
    inputStr += ',';
    stringstream SS(inputStr);
    while( getline(SS,tmpStr,',') ) {
        outputStr += tmpStr + ' ';
    }
    cout << outputStr.substr(0,outputStr.size()-1) << endl;
    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c;
	int tmp;

	scanf("%d%d%d", &a, &b, &c);
	if (a > b) tmp = a, a = b, b = tmp;
	if (b > c) {
		tmp = b, b = c, c = tmp;
		if (a > b) tmp = a, a = b, b = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  int n;
  cin >> n;
  vector<ll> s(n+1);
  s[0] = 0;
  REP(i,n){
    ll a;
    cin >> a;
    s[i+1] = s[i] + a;
  }
  sort(ALL(s));
  ll cnt = 1;
  ll ans = 0;
  REP(i,n){
    if(s[i]==s[i+1]) cnt++;
    else{
      ans += cnt*(cnt-1)/2;
      cnt = 1;
    }
  }
  if(cnt>1) ans += cnt*(cnt-1)/2;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  
  ll m=0;
  ll ans=INF;
  FOR(i,-100,101){
    FOR(j,0,n){
    m+=(A[j]-i)*(A[j]-i);
    }
    
    chmin(ans,m);
    m=0;
  }
  co(ans)
}

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

using namespace std;

typedef long long ll;

#define INF 1LL<<60

ll n;
ll s;

ll f(ll b, ll n) {
    if (n < b) {
        return n;
    } else {
        ll nn = floor((double) n / b);
        return f(b, nn) + (n % b);
    }
}

int main(int argc, char* argv[]) {
    //cin >> n >> s;
    scanf("%ld", &n);
    scanf("%ld", &s);

    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }

    ll ans = INF;

    for (ll b = 2; b < sqrt(n) + 1; ++b) {
        if (f(b, n) == s) {
            ans = min(ans, b);
        }
    }

    ll d = n-s;

    for (ll i = 1; i < sqrt(d) + 1; ++i) {
        ll b = (n-s)/i + 1;

        if (f(b, n) == s) {
            ans = min(ans, b);
        }
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();

		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int sum = 0;

		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int tmp = a[i] * a[j];
				sum += tmp;
			}

		}
		System.out.println(sum);

	}

}


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

n, m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(m)]

set1 = set()
setN = set()
for a in A:
    if a[0] == 1:
        set1.add(a[1])
    elif a[1] == n:
        setN.add(a[0])

if len(set1.intersection(setN)) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 58896
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	M := Int(s)
	X := Int(s)
	Y := Int(s)
	xList := scanNums(s, N)
	xList = append(xList, X)
	yList := scanNums(s, M)
	yList = append(yList, Y)
	xMax := max(xList)
	yMin := min(yList)
	if xMax < yMin {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}

}

func max(nums []int) int {
	res := nums[0]
	for _, num := range nums {
		if res < num {
			res = num
		}
	}
	return res
}

func min(nums []int) int {
	res := nums[0]
	for _, num := range nums {
		if res > num {
			res = num
		}
	}
	return res
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] stf = new double[n];

        for(int i = 0;i < n;i++){
            stf[i] = sc.nextDouble();
        }

        Arrays.sort(stf);

        for(int i = 0;i < n-1;i++){
            stf[i+1] = (stf[i]+stf[i+1])/2.0;
        }
        
        System.out.println(stf[n-1]);

    }
}

Measured memory_bytes: 25300
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] b = new int[n-1];

    int[] a = new int[n];

    for (int i = 0; i < n-1; i++) {
      b[i] = sc.nextInt();
    }

    a[0] = b[0];

    for (int i = 0; i < n-1; i++) {
      if (a[i] > b[i]) {
        a[i] = b[i];
      }
      a[i+1] = b[i];
    }

    int sum = 0;

    for (int i = 0; i < n; i++) {
      sum += a[i];
    }

    System.out.println(sum);
    
  }

}


Measured memory_bytes: 23124
#include<stdio.h>

int n,A[50];

int solve(int i, int m){
    if(m==0)return 1;
    if(i>=n)return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(){
    int q,M,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&M);
        if(solve(0,M))printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#define MAX 44
using namespace std;

long long fib[MAX];

int main(){
  int n; cin>>n;
  fib[0]=fib[1]=1;
  for(int i=2;i<=n;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }
  cout<<fib[n]<<endl;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> v(N);
    REP(i,N){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = (v[0] + v[1]) / 2;
    for(int i=2;i<N;i++) ans += v[i], ans /= 2.0;

    printf("%.8lf\n",ans);

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <numeric>
#include <cmath>
#include <cctype>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


int main(){
  queue<pair<string,int> > q;
  int N,Q; cin>>N>>Q;
  REP(i,N){
    string name;
    int time;
    cin >> name >> time;
    q.push( make_pair(name,time) );
  }
  int t = 0;
  while(!q.empty()){
    pair<string, int> p = q.front();
    q.pop();
    if(p.second<=Q){
        t += p.second;
        cout << p.first << " " << t <<"\n";
    }else{
        t += Q;
        p.second -= Q;
        q.push( p );
    }
  }
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

mt19937 mt(736);


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n;

	cin >> n;

	vector<ll> arr(n);

	for (auto &it : arr)
	{
		string str;

		cin >> str;

		if (str.find('.') == string::npos)
			str.push_back('.');

		str.resize(str.find('.') + 10, '0');

		it = stoi(str.substr(0, str.find('.'))) * (ll) 1e9 + stoi(str.substr(str.find('.') + 1));
	}

#ifdef LOCAL
	for (auto it : arr)
		cout << it << ' ';
	cout << endl;
#endif

	vector<vector<int>> cnt(19, vector<int>(19));

	for (auto it : arr)
		if (it != 0)
		{
			int two = 0, five = 0;

			while (it % 2 == 0)
			{
				it /= 2;
				two++;
			}

			while (it % 5 == 0)
			{
				it /= 5;
				five++;
			}

			cnt[min(two, (int) cnt.size() - 1)][min(five, (int) cnt.size() - 1)]++;
		}
		else
			cnt.back().back()++;

	auto C2 = [](ll q)
	{
		return q * (q - 1ll) / 2;
	};

	ll ans = 0;

	for (int two = 0; two < cnt.size(); two++)
		for (int five = 0; five < cnt.size(); five++)
			for (int i = 18 - two; i < cnt.size(); i++)
				for (int j = 18 - five; j < cnt.size(); j++)
				{
					if (two == i && five == j)
						ans += 2 * C2(cnt[i][j]);
					else
						ans += cnt[two][five] * (ll) cnt[i][j];
				}

	cout << ans / 2 << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	do
	{
		solve(fin);

		cout << "===" << endl;

		string str;
		while (getline(fin, str) && str != string(max(1, (int) str.size()), '='));
	} while (fin);

	cout << setprecision(6) << "clock: " << double(clock() - st) / CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


Measured memory_bytes: 4732
import java.util.*;

 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();
    
    n = n % k;
    
    if(n == 0){
      System.out.println(0);
      return;
    }
    
    long ans = Math.min(k-n,n);
    System.out.println(ans);
    
  }
}

Measured memory_bytes: 23124
p=lambda n:2**(n+1)-1
a=lambda n:2**(n+2)-3
def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    if x<=1+a(n-1):
        return f(n-1,x-1)
    return p(n-1)+1+f(n-1,x-2-a(n-1))
n,x=map(int,input().split())
print(f(n,x))


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String param[] = input.split(" ");
        int W = Integer.parseInt(param[0]);
        int H = Integer.parseInt(param[1]);
        int x = Integer.parseInt(param[2]);
        int y = Integer.parseInt(param[3]);
        int r = Integer.parseInt(param[4]);
        if(r <= x && x <= W - r && r <= y && y <= H - r) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

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

using namespace std;

const int MAX_H = 100;
const int MAX_W = 8;
//const int MAX_K = 8;
const int64_t MOD = 1000000007;
int h, w, k;
int64_t dp[MAX_H+1][MAX_W];
int64_t l[MAX_W][2], r[MAX_W][2];

int main()
{
  cin >> h >> w >> k;
  k--;

  l[0][0] = 1, l[0][1] = 0;
  for (int i = 1; i < w; i++) {
    l[i][0] = l[i-1][0] + l[i-1][1];
    l[i][1] = l[i-1][0];
    //cout << l[i][0] << " " << l[i][1] << endl;
  }
  r[w-1][0] = 1; r[w-1][1] = 0;
  for (int i = w-2; i >= 0; i--) {
    r[i][0] = r[i+1][0] + r[i+1][1];
    r[i][1] = r[i+1][0];
    //cout << r[i][0] << " " << r[i][1] << endl;
  }

  for (int i = 0; i < w; i++) {
    dp[0][i] = i == k ? 1 : 0;
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 0; j < w; j++) {
      int64_t x = 0;
      if (j > 0) {
        x = l[j][1] * r[j][0] * dp[i-1][j-1] % MOD;
      }

      x = (x + l[j][0] * r[j][0] * dp[i-1][j] % MOD) % MOD;

      if (j < w-1) {
        x = (x + l[j][0] * r[j][1] * dp[i-1][j+1] % MOD) % MOD;
      }

      dp[i][j] = x;
    }
  }

  cout << dp[h][0] << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A = [ir() for _ in range(5)]
ceil_time = [(x+9)//10*10 for x in A]
can_save = [y - x for y, x in zip(ceil_time, A)]
answer = sum(ceil_time) - max(can_save)
print(answer)


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

const int N=200010;
int n,X,Y,f[N][20],dep[N],vis[N],ans;

struct graph{
	struct edge{int s,t,n;}e[4*N];
	int h[N];

	void init()
	{
		for (int i=1,u,v,tot=0; i<n; i++)
			{
				scanf("%d %d",&u,&v);
				e[++tot]=(edge){u,v,h[u]},h[u]=tot;
				e[++tot]=(edge){v,u,h[v]},h[v]=tot;
			}
	}	

	int dis(int x,int y)
	{
		int s=0;
		if (dep[x]>dep[y])  swap(x,y);
		for (int i=19; i>=0; i--)
			if (dep[f[y][i]]>=dep[x])
				y=f[y][i],s+=1<<i;
		if (x==y)  return s;
		for (int i=19; i>=0; i--)
			if (f[x][i]!=f[y][i])
				x=f[x][i],y=f[y][i],s+=2<<i;
		return s+2;
	}

	bool dfs(int x,int fa)
	{
		int _=(x==X);
		f[x][0]=fa,dep[x]=dep[fa]+1,vis[x]=vis[0];
		for (int i=1; i<20; i++)  f[x][i]=f[f[x][i-1]][i-1];
		for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
			if ((y!=fa)&&(dfs(y,x)))  _=1;
		return _;
	}

	void mark()
	{
		dep[0]=-1;
		for (int i=h[Y],y; y=e[i].t,i; i=e[i].n)
			if (vis[0]++,dfs(y,Y))  vis[n+1]=vis[0];
	}

	void dfs2(int x,int tim)
	{
		ans=max(ans,dep[x]),vis[x]=vis[0]+1;
		for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
			if ((vis[y]==vis[n+1])&&(dep[y]>tim))
				dfs2(y,tim+1);
	}
}A,B;

void work()
{
	scanf("%d %d %d",&n,&X,&Y);
	A.init(),B.init(),B.mark(),A.dfs2(X,1);
	for (int i=2; i<2*n; i+=2)
		if ((vis[A.e[i].s]>vis[0])||(vis[A.e[i].t]>vis[0]))
			if (B.dis(A.e[i].s,A.e[i].t)>2)
				puts("-1"),exit(0);
	printf("%d",2*ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 38528
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn= new Scanner(System.in);
		int N = scn.nextInt();
		int T = scn.nextInt();
		int ans = T;
		int b_t = 0;
		for(int i = 0;i < N;i++) {
			int t = scn.nextInt();
			ans -= Math.max(0, T+b_t - t);
			ans +=T;
			b_t = t;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 64132
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
//for (int i = 0; i < N; i++){}

int main() {
    string b;
	cin >> b;

    if(b == "A"){
        cout << "T" << endl;
    }
    else if(b == "T"){
        cout << "A" << endl;
    }
    else if(b == "C"){
        cout << "G" << endl;
    }
    else if(b == "G"){
        cout << "C" << endl;
    }

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	x, y, a, b, c := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	p := make([]int, a)
	q := make([]int, b)
	r := make([]int, c)
	for i := range p {
		p[i] = nextInt()
	}
	for i := range q {
		q[i] = nextInt()
	}
	for i := range r {
		r[i] = nextInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	sort.Sort(sort.Reverse(sort.IntSlice(r)))

	r = append(r, p[0:x]...)
	r = append(r, q[0:y]...)
	sort.Sort(sort.Reverse(sort.IntSlice(r)))

	var ans int
	for i := 0; i < x+y; i++ {
		ans += r[i]
	}

	fmt.Println(ans)
}


Measured memory_bytes: 10112
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int n,cnt[1000005]={0},pr[1000005]={0},ar[1000005],st[1000005];
ll gcd(ll a,ll b)
{
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    fr(i,2,1000001)
    {
        if(cnt[i]==0)
        {
            for(int j=i;j<=1000000;j=j+i)
            {
                cnt[j]++;
                st[j]=i;
            }
        }
    }
    ll g=0;
    fr(i,0,n)
    {
        cin>>ar[i];
        g=gcd(ar[i],g);
    }
    if(g!=1)
    {
        cout<<"not coprime"<<endl;
    }
    else
    {
        ll no=0;
        fr(i,0,n)
        {
            ll st1=ar[i];

            while(st1>1)
            {
                ll fl=st[st1];
                while(st1%fl==0)
                {
                    st1/=fl;
                }
                if(pr[fl]==0)
                pr[fl]++;

                else
                no=1;
            }
        }

        if(no==1)
        {
            cout<<"setwise coprime"<<endl;
        }
        else
        {
            cout<<"pairwise coprime"<<endl;
        }
    }
    return 0;
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll W, H, x, y;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> W >> H >> x >> y;
  double answer = (double)W * ((double)H / 2.0);
  int ans2;
  if (2 * x == W && 2 * y == H) {
    ans2 = 1;
  }else {
    ans2 = 0;
  }
  cout << answer << " " << ans2 << endl;

  return 0;
}



Measured memory_bytes: 256
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D = map(int,input().split())
CD = lcm(C,D)
C_num = B//C-A//C+(1 if A%C==0 else 0)
D_num = B//D-A//D+(1 if A%D==0 else 0)
CD_num = B//CD-A//CD+(1 if A%CD==0 else 0)
print(B-A+1-C_num-D_num+CD_num)

Measured memory_bytes: 3064
#include <iostream>

#define NMAX (5)

using namespace std;

int hand[NMAX];

int main() {
	int result;
	for(int i; cin >> i && i!= 0;) {
		hand[0] = i;
		cin >> hand[1] >> hand[2] >> hand[3] >> hand[4];
		result = 0;
		for(int j=0; j<5; j++) {
			switch(hand[j]) {
			case 1:
				result |= 1;
				break;
			case 2:
				result |= 2;
				break;
			case 3:
				result |= 4;
			}
		}
		int typenum = 0;
		for(int res = result; res; res >>= 1)
			if(res&1)
				typenum++;
		
		switch(typenum) {
		case 1:
		case 3:
			for(int k=0; k<5; k++)
				cout << 3 << endl;
			break;
		case 2:
			if(!(result & 1)) {
				for(int k=0; k<5; k++)
					if(hand[k] == 2)
						cout << 1 << endl;
					else
						cout << 2 << endl;				
			}else if(!(result & 2)) {
				for(int k=0; k<5; k++)
					if(hand[k] == 3)
						cout << 1 << endl;
					else
						cout << 2 << endl;								
			}else{
				for(int k=0; k<5; k++)
					if(hand[k] == 1)
						cout << 1 << endl;
					else
						cout << 2 << endl;								
			}
			break;
		default:
			cerr << "err" << endl;
		}
	}	
	return 0;
}

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


int main(){
    int n,a,b;
    cin>>n>>a>>b;

    cout<< min(a*n,b)<<endl;


    return 0;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B := sc.nextInt(), sc.nextInt()
	total := A * B

	fmt.Fprintln(wtr, total-A-B+1)
	wtr.Flush()
}


Measured memory_bytes: 640
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
#N, M = map(int, input().split())
A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

print(A.index(0) + 1)

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

using i64 = int64_t;

class Trie{
private:
    struct TrieNode {
        vector<int> next;
        vector<int> accept;
        int num_string;
        TrieNode(int num_edge): num_string(0), next(num_edge, -1) {}
    };

    int num_edge;
    int margin;
    vector<TrieNode> nodes;

public:
    Trie(int num_edge, int margin): num_edge(num_edge), margin(margin) {
        nodes.push_back(TrieNode(num_edge));
    }

    void add(const string &str, int str_id, int str_index=0, int node_index=0) {
        if(str_index == str.size()) {
            nodes[node_index].accept.push_back(str_id);
        } else {
            const int n = str[str_index] - margin;
            if(nodes[node_index].next[n] == -1) {
                nodes[node_index].next[n] = (int)nodes.size();
                nodes.push_back(TrieNode(num_edge));
            }
            nodes[node_index].num_string++;
            add(str, str_id, str_index+1, nodes[node_index].next[n]);
        }
    }

    void add(const string &str) {
        add(str, nodes[0].num_string);
    }

    void query(const string &str, const function<void(int)> &f, int str_index=0, int node_index=0) {
        for(auto &index: nodes[node_index].accept) f(index);
        if(str_index == str.size()) return;

        const int n = str[str_index] - margin;
        if(nodes[node_index].next[n] == -1) return;
        query(str, f, str_index+1, nodes[node_index].next[n]);
    }

    int count(const string &str, int str_index=0, int node_index=0) {
        if(str_index == str.size()) return nodes[node_index].accept.size();

        const int n = str[str_index] - margin;
        if(nodes[node_index].next[n] == -1) return 0;
        return count(str, str_index+1, nodes[node_index].next[n]);
    }

    int size(){
        return nodes[0].num_string;
    }
};

int main(){
    int n;
    cin >> n;
    Trie trie(26, 'A');
    for(int i=0;i<n;++i){
        string command, str;
        cin >> command >> str;
        if(command == "insert"){
            trie.add(str);
        }else{
            cout << (trie.count(str) ? "yes" : "no") << endl;
        }
    }

    return 0;
}



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

int main(void)
{
    int i;
    vector<int> v(3);

    cin >> v[0] >> v[1] >> v[2];

    sort(v.begin(), v.end());

    for (int x : v){
        if (x == v[v.size() - 1]){
            cout << x << "\n";
            break;
        }
        cout << x << " ";
    }

    /*for (i = 0; i < 2; i++){
        cout << v[i] << " ";
    }*/

    //cout << v[2] << "\n";

    return (0);
}



Measured memory_bytes: 3120
N, Y = map(int, input().split())
a = 0
b = 0
c = 0
for i in range(N+1):
    for j in range(N+1):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y and N-i-j>=0:
            a = i
            b = j
            c = N-i-j
if a == 0 and b == 0 and c == 0:
    print(-1,-1,-1)
else:
    print(a,b,c)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int rf,rt;
  double f,t;
  for(;;){
    f=-1.0;
    t=-1.0;
    cin>>f>>t;
    if(f==-1&&t==-1)
      break;
    if(f<35.5)
      rf=0;
    else if(f<37.5)
      rf=1;
    else if(f<40)
      rf=2;
    else if(f<43)
      rf=3;
    else if(f<50)
      rf=4;
    else if(f<55)
      rf=5;
    else if(f<70)
      rf=6;
    else
      rf=7;
    if(t<71)
      rt=0;
    else if(t<77)
      rt=1;
    else if(t<83)
      rt=2;
    else if(t<89)
      rt=3;
    else if(t<105)
      rt=4;
    else if(t<116)
      rt=5;
    else if(t<148)
      rt=6;
    else
      rt=7;
    switch(rf>rt?rf:rt){
    case 0:
      cout<<"AAA"<<endl;
      break;
    case 1:
      cout<<"AA"<<endl;
      break;
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      cout<<(char)('A'+(rf>rt?rf:rt)-2)<<endl;
      break;
    default:
      cout<<"NA"<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 0
text=input()
string=input()


#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す


len_string=len(string)
common_length=[0]*len_string
tmp=0
for i in range(1,len_string):
    if(string[i]==string[tmp]):
        if(string[i-1]==string[tmp-1]):
            common_length[i-1]=1
        else:
            common_length[i-1]=0
        tmp+=1
    else:
        common_length[i-1]=tmp
        if(string[i]==string[0]):
            tmp=1
        else:
            tmp=0

if(string[-1]==string[tmp-1]):
    common_length[-1]=tmp
common_length[0]=0



tmp=0

for i in range(len(text)):
    if(text[i]!=string[tmp]):
        while(text[i]!=string[tmp] and tmp>0):
            tmp=common_length[max([tmp-1,0])]
        if(text[i]==string[tmp]):
            tmp+=1
    else:
        tmp+=1
        if(tmp==len_string):
            print(i-tmp+1)
            tmp=common_length[-1]


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

int main(){
    long long k,a,b;
    cin >> k >> a >> b;
    long long it;
    long long  res;
    if(b <= (a+2)) res = 1+k;
    else{
        it = (k-a+1)/2;
        res = 1+k+it*(b-a-2);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u==s) cout << a-1 <<" "<< b <<endl;
    else cout << a <<" "<< b-1 <<endl;
}


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

signed main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;

  if (m1 != m2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> vec(N);
  
  for(int i=0;i<N;i++) 
    cin>>vec.at(i);
  
  int alice=0,bob=0;
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(), vec.end());
  
  for(int i=0;i<N;i++)
    if(i%2==0)
      alice += vec.at(i);
  else
    bob += vec.at(i);
  cout<<alice-bob<<endl;
    
  
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main() {
    string String, t;
    getline(cin, String);
    getline(cin, t);
    bool c = true;
    for (int i = 0; i < String.length(); i++) {
        if (String[i] != t[i]) {
            c = false;
            break;
        }
    }
    cout << (c ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    string s ;
    int q ;
    cin >> s ;
    cin >> q ;
    bool turn = false ; 
    string back ;
    string front ; 
    rep(i, q){
        int t ;
        cin >> t ;
        if(t == 1){
            if(turn){
                turn = false ;
            }
            else {
                turn = true ;
            }
        }
        if(t == 2){
            int f ;
            string c ;
            cin >> f >> c ;
            if(turn){
                if(f == 1){
                    back = back + c;
                }
                else {
                    front = c + front ;
                }
            }
            else{
                if(f == 1){
                    front = c + front ;
                }
                else {
                    back = back + c ;
                }

            }
        }
    }
    s = front + s + back ;
    if(turn){
        reverse(s.begin(), s.end()) ;
    }
    cout << s << endl ;
    return 0 ;
}  

Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,k,a;
    cin >> n >> m;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        cin >> k;
        for(int j = 0; j < k; j++){
            cin >> a;
            mp[a-1]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < m; i++){
        if(mp[i] == n) ans+=1;
    }
    cout << ans;
}


Measured memory_bytes: 256
def main():
    a, b = map(int, input().split())
    print(lcm(a, b))


def gcd(a, b):
    while b != 0:
        tmp = a % b
        a = b
        b = tmp
    return a


def lcm(a, b):
    return (a * b) // gcd(a, b)


if __name__ == "__main__":
    main()


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

void solve(long long N, std::vector<long long> T, long long M, std::vector<long long> P, std::vector<long long> X){
    REP(i, M) {
        long long ans = 0;
        REP(j, N) {
            if (j == P[i] - 1) ans += X[i];
            else ans += T[j];
        }
        cout << ans << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    std::vector<long long> T(N);
    REP(i, N) cin >> T[i];
    long long M;
    cin >> M;
    std::vector<long long> P(M);
    std::vector<long long> X(M);
    REP(i, M) cin >> P[i] >> X[i];
    solve(N, std::move(T), M, std::move(P), std::move(X));
    return 0;
}


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

using type = pair<int, long long>; // 1: query, 0; delete, -1: insert
using event = pair<long long, type>;

int main() {
    int N, Q; cin >> N >> Q;
    vector<event> v;
    for (int i = 0; i < N; ++i) {
        int s, t, x; cin >> s >> t >> x;
        v.push_back({s-x, type(-1, x)});
        v.push_back({t-x, type(0, x)});
    }
    for (int i = 0; i < Q; ++i) {
        int d; cin >> d;
        v.push_back({d, type(1, i)});
    }
    sort(v.begin(), v.end());

    vector<long long> res(Q);
    multiset<long long> se;
    for (auto p : v) {
        long long x = p.first;
        int type = p.second.first;
        long long val = p.second.second;
        if (type == -1) se.insert(val);
        else if (type == 0) se.erase(se.lower_bound(val));
        else res[val] = (se.empty() ? -1 : *(se.begin()));
    }
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 27748
////////////////////////////////////////////    _LeMur_
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 150005;
const int inf = 1000 * 1000 * 1000;
const int mod = 998244353;

int n;

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    cout << (n - 2) * 180 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;

int n;
int a[200005],pre[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  pre[i]=(pre[i-1]+a[i])%mod;
	
	int ans=0;
	for (int i=1;i<=n;i++)  ans=(ans+a[i]*pre[i-1]%mod)%mod;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 6692
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110];
int main(){
    ll x,ans=0;
    cin>>x;
    ll d=x/100;
    ll f =x%100;
    if(d*5<f)cout<<0;
    else cout<<1;

    
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> dis(n);
    for (int i = 0; i < n;i++){
        cin >> dis.at(i);
    }
    sort(dis.begin(), dis.end());
    cout << dis.at(n - 1) - dis.at(0) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d,e,k;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&k);
  if(e-a<k || e-a==k) printf("Yay!");
  else printf(":(");
  return 0;
}


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


using namespace std;



const int MAXN = 100 * 1000 + 23;













int n, a[MAXN];




int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n, greater<int>());
	int tmp, cnt = 0;
	for (int i = 0; i < n; i++)
		if (a[i + 1] < i + 2) {
			tmp = i;
			break;
		}
	for (int i = tmp; i < n; i++) if (a[i] >= tmp + 1) cnt++;
	if ((cnt - 1) & 1 || (a[tmp] - tmp + 1) & 1) cout << "First";
	else cout << "Second";
	return 0;
}

Measured memory_bytes: 640
N = int(input())
H = list(map(int,input().split()))
ANS = True
if N == 1:
    pass
else:
    for i in range(N-2,-1,-1):
        if (H[i] - H[i+1]) >= 2:
            ANS = False
            break
        elif (H[i] - H[i+1]) == 1:
            H[i] -= 1

print('Yes' if ANS else 'No')

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   ll N, Y;
   cin >> N >> Y;

   ll x = 10000, y = 5000, z = 1000;
   for (ll a = 0; a <= N; a++) {
      for (ll b = 0; b <= N; b++) {

         ll c = N - a - b;
         if (c >= 0 && c <= N) {
            if (a*x + b*y + c*z == Y) {
               printf("%lld %lld %lld\n", a, b, c);
               return 0;
            }
         }

      }
   }

   printf("-1 -1 -1\n");

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n, k;
int a[111111];

int main(){
  ios_base::sync_with_stdio(false);
  
  int ans = 0;

  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  n -= k;
  ans++;
  k--;
  ans += n / k;
  if(n%k != 0){
    ans++;
  } 

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int res=-1;
	for(int i=0;i<1000;i++){
		int l=(a+b)*i,r=(a+b)*i+a;
		for(int j=l;j<=r;j++) if(j%60==c){
			res=j;
			break;
		}
		if(res!=-1) break;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3112
#include<iostream> 
 using namespace std;
 using ll = long long;

 int N;
 int cntr = 0;

 bool check753(ll n){
 	bool flag[9] = {};
 	while(n>0){
 		if(n%10==0 || 105%(n%10)!=0) return false;
 		flag[n%10] = true;
 		n/=10;
 	}
 	return flag[3]*flag[5]*flag[7];
 }
 
 void solve(ll n){
 	if(n>N) return;
 	n = 10*n + 3;
 	if(check753(n) && n<=N)cntr++;
 	solve(n);
 	n+=2;
 	if(check753(n) && n<=N)cntr++;
 	solve(n);
 	n+=2;
 	if(check753(n) && n<=N)cntr++;
 	solve(n);
 }
 
 int main(){
 	cin >> N;
 	solve(0);
 	cout << cntr << endl;
 }

Measured memory_bytes: 256