akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split( ))
x = list(map(int, input().split( )))
ans_list = []
for i in range(N-K+1):
	ans_list.append(abs(x[i])+abs(x[i]-x[K+i-1]))
	ans_list.append(abs(x[K+i-1])+abs(x[i]-x[K+i-1]))
print(min(ans_list))
	

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vvi c(10, vi(10, INF));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    vvi a(h, vi(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    rep(k, 10) rep(i, 10) rep(j, 10) chmin(c[i][j], c[i][k] + c[k][j]);
    int ans = 0;
    rep(i, h) rep(j, w) if (a[i][j] != -1) ans += c[a[i][j]][1];
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0;i < n;i++) {
    cin >> a[i];
  }
  for (int i = 0;i < n;i++) {
    b[a[i] -1] = i + 1;
  }
  for (int i = 0;i < n;i++) {
    cout << b[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1536
use std::io::*;
use std::str::FromStr;

fn main() {
	let mut a = Vec::new();
	let mut temp: u32;
	for _ in 0..9 {
		temp = read();
		a.push(temp);
	}
	let n: u32 = read();
	let mut b = Vec::new();
	for _ in 0..n {
		temp = read();
		b.push(temp);
	}
	let mut v = Vec::new();
	v.push( b.contains(&a[0]) && b.contains(&a[1]) && b.contains(&a[2]) );
	v.push( b.contains(&a[3]) && b.contains(&a[4]) && b.contains(&a[5]) );
	v.push( b.contains(&a[6]) && b.contains(&a[7]) && b.contains(&a[8]) );
	v.push( b.contains(&a[0]) && b.contains(&a[3]) && b.contains(&a[6]) );
	v.push( b.contains(&a[1]) && b.contains(&a[4]) && b.contains(&a[7]) );
	v.push( b.contains(&a[2]) && b.contains(&a[5]) && b.contains(&a[8]) );
	v.push( b.contains(&a[0]) && b.contains(&a[4]) && b.contains(&a[8]) );
	v.push( b.contains(&a[2]) && b.contains(&a[4]) && b.contains(&a[6]) );
	let mut x: bool = false;
	for i in v {
		x = x || i;
	}
	if x {
		println!("Yes");
	} else {
		println!("No");
	}
}


fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 4352
#include<stdio.h>

int main(){
    int N;
    int v[110000];
    int count1[110000], count2[110000];
    int i,j;
    int value;
    int mode11=0, mode12=-1, mode21=0, mode22=-1;
    int modev11=0, modev12, modev21=0, modev22;

    for(i=0; i<110000; i++){
        count1[i] = 0;
        count2[i] = 0;
    }

    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &v[i]);
    }
    modev12 = 0;
    modev22 = 0;

    for(i=0; i<N; i+=2){
        value = v[i];
        count1[value] += 1;
        if(modev11 < count1[value]){
            mode11 = value;
            modev11 = count1[value];
        }
    }
    for(i=0; i<N; i+=2){
        value = v[i];
        count2[value] += 1;
        if(modev12 < count2[value] && value!=mode11){
            mode12 = value;
            modev12 = count2[value];
        }
    }
    for(i=0; i<110000; i++){
        count1[i] = 0;
        count2[i] = 0;
    }
    for(i=1; i<N; i+=2){
        value = v[i];
        count1[value] += 1;
        if(modev21 < count1[value]){
            mode21 = value;
            modev21 = count1[value];
        }
    }
    for(i=1; i<N; i+=2){
        value = v[i];
        count2[value] += 1;
        if(modev22 < count2[value] && value!=mode11){
            mode22 = value;
            modev22 = count2[value];
        }
    }
    if(mode11 == mode21){
        if(modev12>modev22){
            printf("%d", N-modev12-modev21);
        }else{
            printf("%d", N-modev11-modev22);
        }
    }else{
        printf("%d", N-modev11-modev21);
    }

    return 0;
}


Measured memory_bytes: 1408
import scala.io.StdIn.readInt

object Main {
  def main(args:Array[String]) = {
    val w = { for(i <- 1 to 10) yield readInt }.sortWith( _ > _ ).take(3).sum
    val k = { for(i <- 1 to 10) yield readInt }.sortWith( _ > _ ).take(3).sum
    println(w + " " + k)
  }
}

Measured memory_bytes: 43496
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,mx;
    cin >> n;
    vector<int> h(n);
    for(int i = 0;i < n;i++) cin >> h[i];
    mx = h[0];
    int ans = 1;
    for(int i = 1;i < n;i++){
        if(h[i] >= mx){
            ans++;
            mx = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,x,y=map(int,input().split())
array=[0 for i in range(n)]
for i in range(1,n):
    for j in range(i+1,n+1):
        res=min(abs(j-i),abs(x-j)+1+abs(y-i),abs(y-j)+1+abs(x-i))
        array[res]+=1
for i in range(1,n):
    print(array[i])


Measured memory_bytes: 3444
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int a,b,c;
 cin>>a>>b>>c;
 if(a-b==b-c)
 cout<<"YES"<<endl;
 
 else
 cout<<"NO"<<endl;
 return 0;
}

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

int main() {
  ll L, R;
  cin >> L >> R;
  R = min(R, L + 673);
  int ans = 2018;
  for (ll i = L; i < R; i++) {
    for (ll j = i + 1; j <= R; j++) {
      int x = i * j % 2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
}

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

long long a, b;

long long gcd(long long x, long long y) {
	return y == 0 ? x : (gcd(y, x%y));
}

void init() {
	scanf("%lld%lld", &a, &b);
	return ;
}

void solve() {
	printf("%lld", a*b/gcd(a, b));
	return ;
}

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

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 100
#define INFTY 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int n,T[MAX][MAX];
 
void dijkstra(){
  int minv,i,v,u;
  int d[MAX],color[MAX];
 
  for(i=0;i<n;i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
 
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v = 0;v<n;v++){
      if(color[v] != BLACK && T[u][v] != INFTY){
	if(d[v]>d[u]+T[u][v]){
	  d[v] = d[u] + T[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0;i<n;i++){
    printf("%d",i);
    printf(" ");
    d[i]= (d[i] == INFTY) ? -1 : d[i];
    printf("%d\n",d[i]);
  }
}
 
int main(){
  int i,k,c,u,v,j;
 
  scanf("%d",&n);
  for(i = 0;i<n;i++){
    for(j = 0;j<n;j++){
      T[i][j] = INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j = 0;j<k;j++){
      scanf("%d %d",&v,&c);
      T[u][v] = c;
    }
  }
  dijkstra();
 
  return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int a,b;
  cin >>a>>b;
  if(a%3==0||b%3==0|(a+b)%3==0){
    cout << "Possible" << endl;  
  }
  else{
    cout << "Impossible" << endl;  
  }
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <math.h>
#include <complex>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef complex<double> P;

inline double dot(const P& a, const P& b) { return real(conj(a)*b); }
P projection(const P& l0, const P& l1, const P& p) {
    return l0 + dot(p-l0, l1-l0) / norm(l1-l0) * (l1-l0);
}

int main() {
    double x1, y1, x2, y2, xq, yq;
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf",
                &x1, &y1, &x2, &y2, &xq, &yq) != EOF) {
        const P q = P(xq, yq);
        const P m = projection(P(x1, y1), P(x2, y2), q);
        P r = q+2.0*(m-q);
        printf("%.6f %.6f\n", r.real(), r.imag());
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S,T;
    cin>>S>>T;
    lint l=S.size()-T.size();
    lint t=T.size();
    lint ans=inf;
    for(lint i=0;i<=l;i++){
        lint sm=0;
        for(lint j=0;j<t;j++){
            if(S[j+i]!=T[j]) sm++;
        }
        ans=min(ans,sm);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-14 14:59:04 +0900
# LastModified: 2020-06-14 15:07:55 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd
from itertools import accumulate as ac

def main():
    n,q = map(int,input().split())
    s = input()
    poly = [0]*len(s)
    for i in range(0,len(s)-1):
        if s[i]=='A' and s[i+1]=='C':
            poly[i]=1
    ans = list(ac(poly))
    ans.insert(0,0)
    for _ in range(q):
        l,r = map(int,input().split())
        print(ans[r-1]-ans[l-1])


if __name__ == "__main__":
    main()


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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 10002
#define mod 1000000007
#define mod2 998244353
#define inf 1e18


int dp[N][101][2];
vector <int> vec;
int D;
string k;
int n;


//flag 0 means constrained
int solve(int id,int sum,int flag)
{

  //  cout << id << " " << sum << " " << flag << endl;

    if(id==n)
    {
        if(sum%D==0)
            return 1;
        else
            return 0;
    }

    int &ans=dp[id][sum][flag];
    if(ans!=-1)
        return ans;

    int lim;
    if(flag==0)
        lim=vec[id];
    else
        lim=9;
    ans=0;
    for(int dig=0;dig<=lim;dig++)
    {
        int nf=flag;
        if(nf==0 && dig<lim)
            nf=1;
        ans=(ans+solve(id+1,(sum+dig)%D,nf))%mod;
    }
    return ans;
}


int32_t main()  
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif

        

    cin >> k >> D;
    memset(dp,-1,sizeof dp);

    int l=k.length();
    int i;
    for(i=0;i<l;i++)
    {
        int d=k[i]-'0';
        vec.pb(d);
    }
    n=vec.size();
    int ans=solve(0,0,0);

    cout << (ans-1+mod)%mod;




}

Measured memory_bytes: 17024
#include <cstdio>

const int maxn=1e5+100;

int a[maxn];
int n,k;

int mydiv(int a,int b)
{
	if(a%b) return a/b+1;
	else return a/b;
}

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int ans=mydiv(n-1,k-1);
	printf("%d\n",ans);
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double EPS = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll m,n;
  while(cin >> m && m){
    vector<double> v(m);
    ll sum = 0;
    rep(i,m-1){
      cin >> v[i];
      sum += v[i];
    }
    v[m-1] = 360 - sum;
    cin >> n;
    vector<double> v2(n);
    sum = 0;
    rep(i,n-1){
      cin >> v2[i];
      sum += v2[i];
    }
    v2[n-1] = 360 - sum;
    double s1 = 0,s2 =0;
    rep(i,m){
      s1 += sin(v[i]/180 * PI);
    }
    rep(j,n){
      s2 += sin(v2[j]/180 * PI);
    }
    if(s2 - s1 > EPS){
      cout << 2 << endl;
    }
    else if(s1 - s2 > EPS){
      cout << 1 << endl;
    }
    else{
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3460
// inputに入力データ全体が入る
function Main(input) {

 	input = input.split(" ");
	var tap = input[0];
	var need = input[1];
	
	var current = 1;
	var ans = 0;
	
	while(current < need){
	    current += tap - 1
	    ans++;
	}
	
	console.log(ans);


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

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <set>
#define rep(i, a, n) for(int i = a;i < n;i++)
#define repr(i, a, n) for(int i = a;i > n;i--)
using namespace std;


int main(){
	int n;
	set<char> s;
	cin >> n;
	char c;
	rep(i, 0, n){
		cin >> c;
		s.insert(c);
	}

	if(s.size() == 3) cout << "Three" << endl;
	else cout << "Four" << endl;


	return 0;
}

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

struct TimeTable{
	int c;	//本站运行时间
	int s;	//本站首发时间
	int f;	//发车间隔 
};
int main()
{
	int n;
	cin>>n;
	TimeTable a[n+1];
	for(int i=1;i<=n-1;i++)
		cin>>a[i].c>>a[i].s>>a[i].f;
	for(int i=1;i<=n-1;i++){
		int b=i,tb=0,e=i+1,te; 
		//b当前出发站台,tb当前出发时间，e当前到达站台，te当前到达时间
		while (e<=n){
		 	if (tb<=a[b].s) tb=a[b].s;
		 	else tb=a[b].s+(tb-a[b].s+a[b].f-1)/a[b].f*a[b].f;
			te=tb+a[b].c;
			b++;e++;
			tb=te;
		}
		cout<<te<<endl;
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
string s,t,ans="";
int f[3003][3003];
pair <int,int> g[3003][3003];

int main(){
	cin>>s>>t;
	int sl=s.size(),tl=t.size();
	for (int i=0;i<sl;i++){
		f[i][0]=0;
	}
	for (int i=0;i<tl;i++){
		f[0][i]=0;
	}
	for (int i=0;i<sl;i++){
		for (int j=0;j<tl;j++){
			if (s[i]==t[j]){
				if (i-1<0 || j-1<0) f[i][j]=1;
				else f[i][j]= f[i-1][j-1]+1;
				g[i][j]=make_pair(i,j);
			}
//			f[i][j]=max(f[i-1][j],f[i][j-1]);
			if (i>0)
				if (f[i-1][j] > f[i][j]) {
					f[i][j]=f[i-1][j];
					g[i][j]=g[i-1][j];
				}
			if (j>0)
				if (f[i][j-1] > f[i][j]) {
					f[i][j]=f[i][j-1];
					g[i][j]=g[i][j-1];
				}
		}
	}
//	cout<<endl<<f[0][0]<<endl;
	int i=sl-1,j=tl-1;
	while (f[i][j]>0){
		ans+=s[g[i][j].first];
		int i1=i;
		if (g[i1][j].first-1<0 || g[i1][j].second-1<0) break;
		i=g[i1][j].first-1;
		j=g[i1][j].second-1;
	}
	if (ans==""){
		cout<<" "<<endl;
		return 0;
	}
	for (int i=ans.size()-1;i>=0;i--){
		cout<<ans[i];
	}
	return 0;
}

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


void solve(long long N, std::vector<long long> A){
    map<ll, ll> mp;
    rep(i, N)
        mp[A[i]]++;

    // for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    //     std::cout << "key = " << itr->first           // キーを表示
    //                     << ", val = " << itr->second << "\n";    // 値を表示
    // }
    ll pat = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        ll num = itr->second;
        pat += num * (num - 1) / 2;
    }

    rep(i, N)
        cout << pat - (mp[A[i]] - 1) << endl;
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main()
{
    int n;
    int x,y;
    cin>>n;
    if(n==1)
    {
        cout<<"Hello World"<<endl;
    }
    else
    {
        cin>>x>>y;
        cout<<x+y<<endl;
        
    }
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import math
x =  [int(s) for s in input().split()]
aji = [x[1]+i-1 for i in range(1,x[0]+1)]

sum = 0
for i in range(0,len(aji)):
        sum += aji[i]

sum2 = 0
if(0 in aji):
    for i in range(0,len(aji)):
        sum2 += aji[i]
else:
    if(sum < 0):
        for i in range(0,len(aji)-1):
            sum2 += aji[i]
    else:
        for i in range(1,len(aji)):
            sum2 += aji[i]
print(sum2)
   
            
            

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int q;
vector<int> l, r;
vector<LL> sosuu_list, sosuu2_list;
/**********************************************/

bool isprime(LL x){
    if(x == 2) return true;
    if(x < 2 || x % 2 == 0) return false;
    LL i = 3;
    LL sqrtx = sqrt(x);
    while(i <= sqrtx){
        if(x % i == 0) return false;
        i += 2;
    }
    return true;
}
// maxまでの素数をvectorに入れて返す
vector<LL> eratos(LL max){
    vector<LL> primeVec;
    vector<bool> isprime;
    double sqrtmax = sqrt(max);
    isprime.resize(max + 1);
    isprime[0] = false; isprime[1] = false;
    FOR(i, 2, max + 1){
        isprime[i] = true;
    }
    FOR(i, 2, sqrtmax){
        if(isprime[i]){
            for(int j = 0; i * (j + 2) < max + 1; ++j){
                isprime[i * (j + 2)] = false;
            }
        }
    }
    REP(i, max + 1){
        if(isprime[i])  primeVec.pb(i);
    }
    return primeVec;
}
 

int solve(int l, int r){
    int ans = 0;
    
    auto itr = lower_bound(sosuu2_list.begin(), sosuu2_list.end(), l);
    auto itr2 = upper_bound(sosuu2_list.begin(), sosuu2_list.end(), r); 
    for(; itr < itr2; itr++){
        ans++;
    } 

    return ans;
}

int main(){
    cin >> q;
    l.resize(q);
    r.resize(q);
    REP(i, q){
        cin >> l[i] >> r[i];
    }
    
    sosuu_list = eratos(100000);
    REP(i, sosuu_list.size()){
        if(isprime((sosuu_list[i]+1)/2)) sosuu2_list.pb(sosuu_list[i]);
    }

    REP(i, q){
        cout << solve(l[i], r[i]) << endl;
    }
}


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

const int N = 1e5 + 5;
const double inf = 1e18;
double x[N], y[N];
double dx[N], dy[N];
int n;

double f(double a) {
    double minx = inf, maxx = -inf, miny = inf, maxy = -inf;
    for (int i = 0; i < n; i++) { //n个点
        double nx = x[i] + a * dx[i];
        double ny = y[i] + a * dy[i];
        minx = min(minx, nx);
        maxx = max(maxx, nx);
        miny = min(miny, ny);
        maxy = max(maxy, ny);
    }
    return (maxx - minx) * (maxy - miny);
}

double ternary_search(double l, double r) {
   double ans = inf;
  int times = 300;
    while (times--) {
        double m1 = l + (r - l) / 3;
         double m2 = r - (r - l) / 3;
        //double m1 = (l*2+r) / 3;
        //double m2 = (r*2+l) / 3;
        double f1 = f(m1);
        double f2 = f(m2);
        ans = min(ans, f1);
         ans = min(ans, f2);
        if (f1 < f2) r = m2;
        else l = m1;
    }
    return ans;
}

int main() {
   // while (cin >> n) {
      cin>>n;
        //memset(dx, 0, sizeof(dx));
        //memset(dy, 0, sizeof(dy));

        string s;
        for (int i = 0; i < n; i++) {
            cin >> x[i] >> y[i] >> s;
            if (s == "R") dx[i] = 1;
            if (s == "L") dx[i] = -1;
            if (s == "U") dy[i] = 1;
            if (s == "D") dy[i] = -1;
        }


        cout << fixed << setprecision(11) <<ternary_search(0, 1e9) << endl;
      //printf("%f\n",ternary_search(0, 1e9));
   // }

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int n,a,b,c,ans;
int f(int n){
    int tmp=0;
    while(n){
        tmp+=n%10;
        n/=10;
    }
    return tmp;
}
int main(void){
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        c=f(i);
        if(a<=c&&c<=b)ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    const ll INF = (1ll << 60);
    int n, m;
    ll l;
    cin >> n >> m >> l;
    int a[m], b[m];
    ll c[m];
    ll dist[n][n];
    rep(i, n) rep(j, n)
    {
        if (i == j)
            dist[i][j] = 0;
        else
            dist[i][j] = INF;
    }

    rep(i, m)
    {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    rep(k, n) rep(i, n) rep(j, n)
    {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    ll dp[n][n];
    rep(i, n) rep(j, n)
    {

        if (i == j)
            dp[i][j] = 0;
        else
            dp[i][j] = INF;
    }
    rep(i, n) rep(j, n)
    {
        if (dist[i][j] <= l)
            dp[i][j] = min(dp[i][j], 1ll);
    }
    rep(k, n) rep(i, n) rep(j, n)
    {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }

    int q;
    cin >> q;
    rep(i, q)
    {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        if (dp[s][t] == INF)
            cout << -1 << endl;
        else
            cout << dp[s][t] - 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, k;
    cin >> n >> k;

    int l, r;
    l = r = 0;
    vs32 x;
    rep (i, n)
    {
        int temp;
        cin >> temp;
        if (temp < 0)
        {
            x.push_back(temp);
            ++l;
        }
        else if (temp > 0)
        {
            x.push_back(temp);
            ++r;
        }
        else --k;
    }

    if (k == 0)
    {
        cout << "0\n";
        return 0;
    }

    int ans = 1e9;
    for (int i = l; i >= MAX(1, k - r); --i)
    {
        if (i >= k) ans = MIN(ans, -x[l - k]);
        else ans = MIN(ans, 2 * (-x[l - i]) + x[l + k - i - 1]);
    }

    for (int i = r; i >= MAX(1, k - l); --i)
    {
        if (i >= k) ans = MIN(ans, x[l + k - 1]);
        else ans = MIN(ans, 2 * x[l + i - 1] - x[l - k + i]);
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 892
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

struct BIT {
	int n;
	vector<int> bit;
	BIT(int N) {
		bit.resize(N + 1);
		n = N;
	}
	void add(int a, int w) {
		for (int x = a; x <= n; x += x&-x)
			bit[x] += w;
	}
	int sum(int a) {
		int ret = 0;
		for (int x = a; x > 0; x -= x&-x)
			ret += bit[x];
		return ret;
	}
};



int main() {
	int n, m;
	cin >> n >> m;
	vector<int> lll(n), rrr(n);

	vector<pair<int, pair<int, int>>> dis(n);

	FOR(i, 0, n) {
		cin >> lll[i] >> rrr[i];
		dis[i] = make_pair(rrr[i] - lll[i] + 1, make_pair(lll[i], rrr[i]));

	}
	sort(dis.begin(), dis.end());

	BIT bit(m);
	int itr = 0;
	int cnt = n;
	IFOR(d, 1, m) {
		if (itr < n && dis[itr].first <= d) {
			while (itr < n&&dis[itr].first <= d) {
				// Add to a range
				bit.add(dis[itr].second.first, 1);
				bit.add(dis[itr].second.second + 1, -1);
				itr++;
				cnt--;
			}

		}
		int now = cnt;
		// Inspect the multiples of d
		for (int i = d; i <= m; i += d) {
			now += bit.sum(i);
		}
		cout << now << endl;

	}



	return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define int long long
#define REP(i,l,r) for(int i=l;i<r;i++)
using namespace std;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
signed main(){
    int a,b;
    cin>>a>>b;
    if(a!=b)cout<<max(a,b)*2-1<<endl;
    else cout<<a+b<<endl;
}



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

int main() {
  int A;
  cin >> A;
  int B = A - 2;
  string S;
  cin >> S;
  int count = 0;
  rep(i,B){
    int n = i + 1;
    int m = i + 2;
    if(S[i] == 'A' && S[n] == 'B' && S[m] == 'C'){
       count++;
       }
       }
       cout << count << endl;
}


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

ll c[200005];

int main(){

    int N,Q;
    cin >> N >> Q;
    vector< vector<int> > T;
    T.resize(N);
    for(int i=1,a,b;i<N;i++){ //辺の数：ノード数-1
        cin >> a >> b;
        a--; b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }

    for(int i=1,p,x;i<=Q;i++) {
        cin >> p >> x;
        p--;
        c[p] += x;
    }

    queue<int> q;
    int vis[N]{};
    vis[0] = 1;
    q.push(0);
    while(!q.empty()) {
        int n = q.front();
        q.pop();
        for(int i:T[n]) {
            if(vis[i] == 1) continue;
            vis[i] = 1;
            c[i] += c[n];
            q.push(i);
        }
    }
    for(int i=0;i<N;i++) {
        cout << c[i] << ' ';
    }
    cout<<endl;
}


Measured memory_bytes: 17140
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
string N;
unsigned long long sum =0;
cin>>N;
for(char c:N)
{
    sum+= c - '0';
}
if(sum%9 == 0)
cout<<"Yes\n";
else
{
    cout<<"No\n";
}


return 0;
}

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

using namespace std;

long N, A, B, C, D;
string s;

vector<bool> visited;

bool reach(int start, int end){
    visited = vector<bool>(N, 0);
    for(int i=0; i<N; ++i){
        if(s[i] == '#'){
            visited[i] = true;
        }
    }
    visited[start] = true;

    queue < int > pq;
    pq.push(start);
    while(!pq.empty()){
        int p=pq.front();
        pq.pop();
        int m = p;

        if(m == end){
            return true;
        }

        if(m+1 < N && visited[m+1] == false && s[m+1] == '.'){
            visited[m+1] = true;
            pq.push(m+1);
        }

        if(m+2 < N && visited[m+2] == false && s[m+2] == '.'){
            visited[m+2] = true;
            pq.push(m+2);
        }
    }
    return false;
}

int main(){
    cin>>N>>A>>B>>C>>D;
    cin>>s;

    if(A<B && B<C && C<D){
        if(reach(A-1, C-1) && reach(B-1, D-1)){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else if(A<C && C<B && B<D){
        if(reach(A-1, C-1) && reach(B-1, D-1)){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else if(A<B && B<D && D<C){
        if(reach(A-1, C-1) && reach(B-1, D-1)){
            bool flag = false;
            for(int i=B-1-1; i<D-1; ++i){
                if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
                    flag = true;
                    break;
                }
            }
            if(flag){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

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

  if(s=="ABC") puts("ARC");
  if(s=="ARC") puts("ABC");
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << (a + b + c >= 22 ? "bust" : "win") << endl;

    return 0;
}

Measured memory_bytes: 256
xr,yt,n,*l=map(int,open(0).read().split())
xl=yb=0
for x,y,a in zip(*[iter(l)]*3):
	if a==1:xl=max(xl,x)
	elif a==2:xr=min(xr,x)
	elif a==3:yb=max(yb,y)
	else:yt=min(yt,y)
print(max(0,xr-xl)*max(0,yt-yb))

Measured memory_bytes: 3064
using System;

namespace C___Low_Elements
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var input = Console.ReadLine ().Split (' ');
            var p = new int[n];
            var ans = 0;
            for (var i = 0; i < n; i++)
            {
                p[i] = int.Parse (input[i]);
            }
            var m = int.MaxValue;
            for (var i = 0; i < n; i++)
            {
                m = Math.Min (m, p[i]);
                if (p[i] == m)
                    ans++;
            }
            Console.WriteLine (ans);
        }
    }
}

Measured memory_bytes: 33116
#整数の入力
N= input()
N_list = list(N)



if(N_list[len(N_list)-1] == "2"):
  print("hon")
elif(N_list[len(N_list)-1] == "4"):
  print("hon")
elif(N_list[len(N_list)-1] == "5"):
  print("hon")
elif(N_list[len(N_list)-1] == "7"):
  print("hon")
elif(N_list[len(N_list)-1] == "9"):
  print("hon")
elif(N_list[len(N_list)-1] == "3"):
  print("bon")

else:
  print("pon")



Measured memory_bytes: 9076
#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;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    int sum = 0;
    rep(i, n - 1) sum += l[i];
    if (l[n - 1] < sum)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
N = int(input())
ab = []
for i in range(N):
    a,b = map(int,input().split())
    c = a+b
    ab.append([c,a,b])
ab.sort(reverse=True)
t = 1
A,B = 0,0
for i in range(N):
    if t == 1:
        A += ab[i][1]
        t *= -1
    else:
        B += ab[i][2]
        t *= -1
print(A-B)

Measured memory_bytes: 23260
//Radhe Radhe
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include<boost/math/common_factor.hpp>
#include <ext/numeric>
using namespace __gnu_cxx;
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define array(a,n) int a[n]; for(int i=0;i<n;i++) cin>>a[i];
#define loop(i,a,b,x) for(int i=a;i<b;i+=x)
const int MOD = 1000000007;
const int N = 10001;




int longestCommonSubsequence(string s1, string s2, vector<vector<int>>& dp)
{
    for (int i = 1; i <= s1.size(); i++)
    {
        for (int j = 1; j <= s2.size(); j++)
        {
            if (s1[i - 1] == s2[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;

            dp[i][j] = max({dp[i][j], dp[i][j - 1], dp[i - 1][j]});
        }
    }
    return dp[s1.size()][s2.size()];
}


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
   
    int t = 1;
    //cin >> t;
    while (t--) {
        string s1, s2;
        cin >> s1 >> s2;

        vector<vector<int>> dp(s1.size() + 1, vector<int>(s2.size() + 1, 0));
        int count = longestCommonSubsequence(s1, s2, dp);  

        string s = "";
        int i = s1.size(), j = s2.size();
        while (i > 0 && j > 0)
        {
            if (dp[i - 1][j - 1] + 1 == dp[i][j] && dp[i - 1][j] + 1 == dp[i][j] && dp[i][j - 1] + 1 == dp[i][j])
            {
                i--;
                j--;
                s = s1[i] + s; 
            }
            else if (dp[i][j - 1] > dp[i - 1][j])
                j--;
            else
                i--;
        }
        cout << s << endl;
    }
    return 0;

}






Measured memory_bytes: 74036
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - AtCoder Beginner Contest 111
            var line = Console.ReadLine();
            int n = int.Parse(line);

            //最初の1文字を取得
            var c = line.Substring(0, 1);

            //x回目を取得("x"は最初の数字を3回繰り返したもの)
            string s = String.Concat(Enumerable.Repeat(c, 3));
            int x = int.Parse(s);

            if (n > x)
            {
                Console.WriteLine(x + 111);
            }
            else
            {
                Console.WriteLine(x);
            }
        }
    }
}

Measured memory_bytes: 11220
// stay fuckin hard -- Abhinav -IIITA
#include<bits/stdc++.h>
#define int long long
#define ld long double
using namespace std;
int mod=1e9;
ld pi=3.1415926535;
int32_t main(){
	int n,m; cin>>n;
	int a[n+1]={0};
	for(int i=1;i<n;++i){
		int t; cin>>t;
		a[t]++;
	}
	for(int i=1;i<=n;++i)
		cout<<a[i]<<"\n";
	return 0;
}


Measured memory_bytes: 5156
#include <stdio.h>
int main()
{
	int w,h,n,i,j,a,b,c,m,q;
	int d[105];
	int f[105];
	scanf("%d %d %d",&w,&h,&n);
	for(i=1;i<=w;i++){
		d[i] = 1;
	}
	for(i=1;i<=h;i++){
		f[i] = 1;
	}
	for(i=1;i<=n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(c==1){
			for(j=1;j<=a;j++){
				d[j] = 0;			 
		    }
		}
		if(c==2){
			for(j=a+1;j<=w;j++){
				d[j] = 0;			 
		    }
		}
		if(c==3){
			for(j=1;j<=b;j++){
				f[j] = 0;			 
		    }
		}
		if(c==4){
			for(j=b+1;j<=h;j++){
				f[j] = 0;			 
		    }
		}
	}
	for(i=1;i<=w;i++){
		if(d[i]==1){
			q++;
			//printf("%d\n",i);
		}
	}
	for(i=1;i<=h;i++){
		if(f[i]==1){
			m++;
			//printf("%d\n",i);
		}
	}
	printf("%d\n",m*q);
	//printf("%d %d\n",q,m);
	return 0;	
} 

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

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

const int inf = 999999999;
const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

ll a[2010];

int main() {
	cin.tie(0);
	int N, Z, W;
	cin >> N >> Z >> W;
	REP(i, N) cin >> a[i];
	ll op1 = abs(a[N - 1] - W);

	if (N >= 2) {
		ll op2 = abs(a[N - 2] - a[N - 1]);
		if (op1 <= op2) cout << op2;
		else cout << op1;
	}
	else {
		cout << op1;
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#define MAX_N 1010

typedef struct _Elm {
  char name[11];
  int time;
} Elm;



Elm que[MAX_N];
int head, tail;

void push(Elm value) {
  que[tail] = value;
  tail = (tail+1)%MAX_N;
}

Elm pop() {
  Elm value = que[head];
  head = (head+1)%MAX_N;
  return value;
}

int que_size() {
  return (MAX_N+tail-head)%MAX_N;
}

int main() {
  int n, q, i, cnt, time, t;
  Elm elm;
  scanf("%d %d", &n, &q);
  for(i = 0; i < n; ++i) {
    scanf(" %s %d", que[i].name, &(que[i].time));
  }

  head = 0;
  tail = n;

  time = 0;
  cnt = 0;

  while(que_size()) {
    elm = pop();
    t = q < elm.time ? q : elm.time;
    elm.time -= t;
    time += t;
    if(elm.time <= 0) {
      printf("%s %d\n", elm.name, time);
      ++cnt;
    } else {
      push(elm);
    }
  }
  return 0;

  for(i = 0, cnt = 0, time = 0; cnt < n; i = (i+1)%n) {
    if(que[i].time <= 0) continue;
    t = q < que[i].time ? q : que[i].time;
    que[i].time -= t;
    time += t;
    if(que[i].time <= 0) {
      printf("%s %d\n", que[i].name, time);
      ++cnt;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio> 
#include<algorithm>
using namespace std;
 
long long a[3];
long long ans;
 
 int main() {
 	scanf("%lld%lld%lld",a,a+1,a+2);
 	if((a[0]%2==0)||(a[1]%2==0)||(a[2]%2==0)) {
 		ans=0;
 		printf("%lld\n",ans);
	 }
 	else {
 		sort(a,a+3);
 		ans=a[0]*a[1];
 		printf("%lld\n",ans);
	 }
	 return 0;
 }

Measured memory_bytes: 256
n,t=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
l.sort()
dp=[0]*(t+max(l)[0])
for a,b in l:
  for i in range(0,t+a)[::-1]: 
    if i-a>=0:
      dp[i]=max(dp[i],dp[i-a]+b)
print(max(dp[t:]))

Measured memory_bytes: 47064
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <cstdint>
#include <string>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

const uint64_t mod = 1000000007;

int main() {
	uint64_t res = 1;
	string s;
	int n;
	cin >> n >> s;
	map<char,set<int>> k;
	for(int i = 0;i < n;i++) k[s[i]].insert(i);
	for(auto itr = k.begin();itr != k.end();itr++) res = (res * (itr->second.size() + 1)) % mod;
	res--;
	cout << res << endl;
#ifdef _DEBUG
	system("pause");
#endif
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
using namespace std;

string toString(int a) {
  char buff[128];
  sprintf(buff, "%d", a);
  return string(buff);
}

int main() {
  string a;
  cin >> a;
  int res = 0;
  for(int i = 0; i <= a.size(); ++i) {
    string ss = a.substr(0,i);
    string st = a.substr(i);
    if(ss.empty()) ss = "0";
    if(st.empty()) st = "0";
    int s = atoi(ss.c_str());
    int t = atoi(st.c_str());
    if((t-s) % 2 == 0 && (t+s)%2 == 0) {
      int x = (t+s)/2;
      int y = (t-s)/2;
      if(x >= 0 && y >= 0) {
        string ans;
        if(x-y == 0) ans = toString(x+y);
        else ans = toString(x-y)+toString(x+y);
        if(ans == a) {
          ++res;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1240
import Data.List

g :: [Int] -> Mint
g c@(1:_) = product $ zipWith (^) (map M c) (tail c)
g _ = 0

f :: [Int] -> [Int]
f d@(0:_) = map (pred.length) $ group $ sort $ [0..maximum d] ++ d
f _ = []

main :: IO ()
main = getLine >> getLine >>= print.g.f.map read.words

modulus = 998244353
newtype Mint = M Int
instance Num Mint where
  (M a) + (M b)
    | a + b < modulus = M $ a + b
    | otherwise = M $ a + b - modulus
  (M a) - (M b)
    | a - b < 0 = M $ modulus + a - b
    | otherwise = M $ a - b
  (M a) * (M b) = toEnum $ a * b
  fromInteger = toEnum . fromInteger
  abs = id
  signum = const $ M 1
instance Enum Mint where
  fromEnum (M a) = a
  toEnum a = M $ mod a modulus
instance Show Mint where
  show = show . fromEnum

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;
  map<char, bool> alp;
  for (char c : s) {
    alp[c] = true;
  }

  if (alp.size() == 26) {
    cout << "None" << '\n';
  } else {
    for (char c = 'a'; c <= 'z'; ++c) {
      if (!alp.count(c)) {
        cout << c << '\n';
        break;
      }
    }
  }

  return 0;
}


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

int answer = 0;
int N;
void dfs(int64_t n,bool three,bool five,bool seven){
  if(n>N){
    return;
  }
  if(three&&five&&seven){
    answer++;
  }
  dfs(10*n+3,true,five,seven);
  dfs(10*n+5,three,true,seven);
  dfs(10*n+7,three,five,true);
  return;
}

int main(){
  cin >> N;
  dfs(0,false,false,false);
  cout << answer << endl;
}

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

int main() {
  string s,t;//s=ID, t=ID+1
  cin >> s >> t;
  
  int n = 0;
  for(int i = 0; i < s.size();i++){
     if(s.at(i) != t.at(i)){
       n++;
       cout << "No" << endl;
       break;
     }
     
  }
  if(t.at(s.size()) != ' ' && n != 1){
   	cout << "Yes" << endl;
  	 }
 
  
    
}


Measured memory_bytes: 3488
# coding: utf-8
# Your code here!

from collections import defaultdict

n = int(input())
x = [str(input()) for _ in range(n)]
m = int(input())
y = [str(input()) for _ in range(m)]

dx = defaultdict(int)
dy = defaultdict(int)

for temp_x in x:
    dx[temp_x] += 1
for temp_y in y:
    dy[temp_y] += 1
    
max_count = 0
for k in dx.keys():
    max_count = max(max_count, dx[k] - dy[k])
    
print(max_count)

Measured memory_bytes: 38256
N=int(input())
a=sorted([int(input()) for i in range(N)])
r=[0]*N
r[1:-1:2]=a[:(N-1)//2]
r[-1]=a[(N-1)//2]
r[:-1:2]=a[(N-1)//2+1:]
A=list(reversed(a))
R=[0]*N
R[1:-1:2]=A[:(N-1)//2]
R[-1]=A[(N-1)//2]
R[:-1:2]=A[(N-1)//2+1:]
print(max(sum([abs(r[i]-r[i+1]) for i in range(N-1)]),sum([abs(R[i]-R[i+1]) for i in range(N-1)])))

Measured memory_bytes: 13264
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#define N 100010
#define ll long long
using namespace std;

vector<int> V[N];
vector<ll> L[N], R[N];
struct info {int to, nex;} e[N * 2];
int n, tot, head[N], mo, fa[N];
ll f[N], Ans[N];
inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
inline void Link(int u, int v) {
	e[++tot].to = v; e[tot].nex = head[u]; head[u] = tot;
}
void dfs(int u, int fa) {
	f[u] = 1, ::fa[u] = fa;
	int tot = 0;
	for (int i = head[u]; i; i = e[i].nex) {
		int v = e[i].to;
		if (v == fa)continue;
		dfs(v, u), V[u].push_back(v), ++tot;
		L[u].push_back(0), R[u].push_back(0);
		f[u] = (f[u] * 1ll * (f[v] + 1)) % mo;
	}
	for (int i = 0; i < tot; ++i) {
		L[u][i] = (i == 0) ? 1 : L[u][i - 1];
		(L[u][i] *= 1ll * (f[V[u][i]] + 1)) %= mo;
	}
	for (int i = tot - 1; i >= 0; --i) {
		R[u][i] = (i == (tot - 1)) ? 1 : R[u][i + 1];
		(R[u][i] *= 1ll * (f[V[u][i]] + 1)) %= mo;
	}
}

void ddfs(int u, ll x) {
	Ans[u] = f[u] * 1ll * (x + 1) % mo;;
	for (int i = V[u].size() - 1; i >= 0; --i) {
		int v = V[u][i];
		ddfs(v, ((i == 0 ? 1 : L[u][i - 1]) * 1ll * (i == (V[u].size() - 1) ? 1 : R[u][i + 1])) % mo * (x + 1) % mo);
	}
}
int main() {
	n = read(), mo = read();
	for (int i = 1; i < n; ++i) {
		int u = read(), v = read();
		Link(u, v), Link(v, u);
	}
	dfs(1, 0), ddfs(1, 0);
	for (int i = 1; i <= n; ++i)printf("%lld\n", Ans[i]);
	return 0;
}


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

long long cut_times(const long long *logs, long long cut_len, int log_num);

int main() {
    int N,K;
    cin >> N >> K;
    long long logs[N];
    long long max_long = 0;

    for(int i = 0;i<N;i++){
        cin >> logs[i];
        if(logs[i] > max_long) {
            max_long = logs[i];
        }
    }
    if(K==0){
        cout << max_long;
        return 0;
    }

    long long start = 1;
    long long end = max_long;
    long long mid;

    while(start<end){
        mid = (start + end)/2;
        //cout << "mid: " << mid << endl;
        //cout << cut_times(logs, mid, N) << endl;
        if(cut_times(logs, mid, N)<=K){
            end = mid;
        }else if(cut_times(logs, mid, N)>K){ //cut times equals to k, still need to try a smaller one to find min(max)
            start = mid+1;
        }

    }

    cout << start;

}

// Given max cut length, get needed cut times
long long cut_times(const long long *logs, long long cut_len, int log_num){
    long long  need_times = 0;
    for(int i = 0;i<log_num;i++){
        if(*logs%cut_len==0){
            need_times += *logs/cut_len-1;
        }else{
            need_times += *logs/cut_len;
        }
        logs++;
    }
    return need_times;
}


Measured memory_bytes: 5132