akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

bool checkValidity(ll a, ll b, ll c) 
{ 
    if (a + b <= c || a + c <= b || b + c <= a) 
        return false; 
    else
        return true; 
} 

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<ll> v(n);
	for(ll &x: v)cin >> x;
	if(n <= 2)
	{	
		cout << 0;
		return 0;
	}
	ll ans = 0;
	for(int i = 0;i < n-2;i++)
	{
		for(int j = i+1;j < n-1;j++)
		{
			for(int k = j+1;k < n;k++)
			{
				if(v[i] == v[j] or v[j] == v[k] or v[i] == v[k]) continue;
				if(checkValidity(v[i],v[j],v[k]))
				{	
					ans++;
				}
			}
		} 
	}
	cout << ans;	
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const double pi = 3.141592653589793;

#define INF 1000000000000


signed main(){
int a,b,h,m;
cin>>a>>b>>h>>m;
double s=2*pi*h/12+2*pi/12*m/60-2*pi*m/60;
cout<<fixed<<setprecision(10)<<pow(a*a+b*b-2*a*b*cos(s),0.5);
}


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

int main()
{
  ios::sync_with_stdio(false);
  int a, b, t = 0;
  cin >> a >> b;

  if (a > b)
    t += a--;
  else
    t += b--;

  if (a > b)
    t += a--;
  else
    t += b--;

  cout << t << "\n";

  return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(void)
{
  string s; cin >> s;
  int ok = 0;
  REP(i, s.size()) {
    if(ok == 0 && s[i] == 'C') ok = 1;
    if(ok == 1 && s[i] == 'F') ok = 2;
  }
  cout << (ok==2?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int buf[N],bcnt,*x[N];
bool cmp(int *a,int *b){
	return (*a)<(*b);
}
void lsh(int *a,int sz){
	for(int i=1;i<=sz;i++) x[i]=&a[i];
	bcnt=0;sort(x+1,x+sz+1,cmp);
	buf[1]=++bcnt;
	for(int i=2;i<=sz;i++) buf[i]=*x[i]==*x[i-1] ? buf[i-1]:++bcnt;
	for(int i=1;i<=sz;i++) *x[i]=buf[i];
}

int n;
int bcj[N];
int ff(int x){
	return bcj[x]==x? x:bcj[x]=ff(bcj[x]);
}
void connect(int x,int y){
	if(ff(x)==ff(y)) return;
	bcj[ff(x)]=ff(y);
}

int a[N],b[N];
int c[N],d[N],m;
int main(){
	scanf("%d",&n);int ta=0,tb=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),ta^=a[i];
	for(int i=1;i<=n;i++) scanf("%d",&b[i]),tb^=b[i];
	n++;
	a[n]=ta;b[n]=tb;
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i])
			c[++m]=a[i],d[m]=b[i];
	int fl1=0,fl2=0;
	if(a[n]==b[n]) fl1=1;
	for(int i=1;i<=m;i++) if(c[i]==a[n]) fl2=1;
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++) if(a[i]!=b[i]) return puts("-1"),0;
	
	int ans=0;
	if(fl1==1&&fl2==1) ans=-1;
	if(fl1==0) ans-=2;
	ans+=m;
	
	lsh(c,m);
	lsh(d,m);
	for(int i=1;i<=m;i++) bcj[i]=i;
	for(int i=1;i<=m;i++) connect(c[i],d[i]);
	for(int i=1;i<=bcnt;i++) if(ff(i)==i) ans++;
	
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 4864
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int a,b,c;

  cin>>a>>b>>c;

  cout<<min(c,b/a)<<endl;

  return 0;

}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop, heappush 
def main():
    N, M, *m = map(int, read().split())
    tasks = [[] for _ in range(M)]
    for a, b in zip(m[::2], m[1::2]):
        if M-a>=0:
            tasks[M-a].append(b)
    s = 0
    h = []
    for i in [i for i in range(M)][::-1]:
        for b in tasks[i]:
            heappush(h, -b)
        if len(h)>0:
            s-=heappop(h)
    print(s)
if __name__ == '__main__':
    main()


Measured memory_bytes: 27892
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    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;
    }
}
 
// 二項係数計算
long long COM(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;
}

struct UnionFind {
    vector<ll> par;

    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }

    ll root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    ll size(ll x) {
        return -par[root(x)];
    }
};
 

 
int main(){
    ll N,M;
  	cin >> N >> M;
  	vector<ll> A(M), B(M);
  	rep(i,M){
      cin >> A[i] >> B[i];
      A[i]--;
      B[i]--;
    }
  
  	vector<ll> ans(M);
  	ans[M-1] = N * (N - 1) / 2;
  
  	UnionFind Uni(N);
  
  	repprev(i, 1, M){
      //繋がってなかったのが繋がった時
      	if(Uni.root(A[i]) != Uni.root(B[i])){
          ans[i - 1] = ans[i] - Uni.size(A[i]) * Uni.size(B[i]);
          Uni.merge(A[i],B[i]);
        }
      else ans[i - 1] = ans[i]; 
    }
  
  rep(i,M){
    cout << ans[i] << endl;
  }
  	
}

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

int main(){
  int a, x; cin >> a >> x;
  if(a < x){
    cout << 0 << endl;
    return 0;
  }else{
    cout << 10 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws IOException{
               BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));	
		long N= Long.parseLong(reader.readLine());
		String res = "";
		while(N>0){
			N--;
			res =  (char)('a'+ N%26)+ res;
			N/=26;			
		}
		System.out.println(res);
	}
	private static String getCharForNumber(int i) {
    	char[] alphabet = "zabcdefghijklmnopqrstuvwxyz".toCharArray();
    	return Character.toString(alphabet[i]);
	}
}


Measured memory_bytes: 37164
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> p(N);
    for(auto& x : p) cin >> x;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= i; j++) {
            swap(p[i], p[j]);
            int k;
            for(k = 0; k < N; k++) {
                if(k > 0 && p[k - 1] > p[k]) {
                    break;
                } 
            }
            if(k == N) {
                cout << "YES" << endl;
                return 0;
            }
            swap(p[i], p[j]);
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> A(M);
  for(pair<int,int> &p:A)
    cin>>p.first>>p.second;
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int n=N+1,ans=0;
  for(int i=0;i<M;i++){
    if(A[i].second<n+1){
      n=A[i].first;
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4816
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	private long Sum = 0;

	public static void main(String[] args) {
		String S;//長さ1~10
		Scanner scanner = new Scanner(System.in);
		S = scanner.next();
		scanner.close();
		Main main = new Main();
		System.out.println(main.calc(S));
	}

	private long calc(String S) {
		int maxPlus = S.length() - 1;//数0~9

		for (int i = 0; i <= maxPlus; i++) {
			//'+' がi個入ってないといけない
			if (i == 0) {
				Sum += Long.parseLong(S);
				continue;
			}
			if (i == maxPlus) {
				for (char charactor : S.toCharArray()) {
					Sum += (charactor - '0');
				}
				continue;
			}
			func(S, i, new ArrayList<String>());

		}
		return Sum;
	}

	private void func(String S, int plusCount, ArrayList<String> list) {
		// 100 0 1

		if (S == null || S.length() <= plusCount) return;
		if (plusCount == 0) {
			if (S.length() != 0) {
				list.add(S);
				long sum = 0;
				for (String str : list) {
					sum += Long.parseLong(str);
				}
				Sum += sum;
			}
		} else {
			for (int i = 1; i < S.length(); i++) {
				ArrayList<String> templist = (ArrayList<String>) list.clone();
				templist.add(S.substring(0, i));
				func(S.substring(i), plusCount - 1, templist);
			}
		}
	}
}


Measured memory_bytes: 9940
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	int a, b;
	cin >> a >> b;
 
	if (a >= b) {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

n, X = map(int, input().split())
x = list(map(int, input().split()))
for i in range(len(x)):
    x[i] = abs(x[i] - X)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(x))



Measured memory_bytes: 16284
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int k, x; cin >> k >> x;
    if(500*k >= x) cout << "Yes";
    else cout <<"No";
    cout << endl;
    return 0;
}




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

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        if ( i % 3 == 0) cout << " " << i;
        else{
			int keta = i;
            for (int j = 0; j < 4; j++){
                if ( keta % 10 == 3 ){
                    cout << " " << i;
                    break;
                }
				keta /= 10;
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3136
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
    a[i]--;
  }

  vector<bool> is_visited(N, false);
  is_visited[0] = true;
  int i = 0;
  int cnt = 0;
  while (!is_visited[a[i]]) {
    i = a[i];
    is_visited[i] = true;
    cnt++;
    if (i == 1) {
      cout << cnt << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
  int main(void){
      int i,j,m,n,a,b,c,M,N;
       while(scanf("%d %d",&m,&n)!=EOF){
        M=m;
        N=n;
        if(n>m){
         a=m;
         m=n;
         n=a;
               }
        while(m%n!=0){
        i=m%n;
        m=n;
        n=i;
        }
        b=N/n*M;

        printf("%d %d\n",n,b);
        }
        return 0;
        }

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    string s; cin >> s;
    ll ans = 0;
    rep(i, s.size()){
        ans += s[i] - '0';
    }
    if(ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int64 X, K;
	cin >> X >> K;
	vector<int64> R(K+1, 0);
	vector<int64> l(K+1, 0), r(K+1, X), diff(K+1, 0);
	vector<int64> slo(K+1, 0), shi(K+1, X);
	int64 lo = 0, hi = X, nl = 0, nr = X;
	REP(i, K){
		cin >> R[i+1];
	}
	FOR(i, 1, K+1){
		if(i%2){
			slo[i] = max((int64)0, slo[i-1]-(R[i]-R[i-1]));
			shi[i] = max((int64)0, shi[i-1]-R[i]+R[i-1]);
			nr -= R[i]-R[i-1];
			nl -= R[i]-R[i-1];
			diff[i] = diff[i-1]-R[i]+R[i-1];
		}else{
			slo[i] = min((int64)X, slo[i-1]+R[i]-R[i-1]);
			shi[i] = min((int64)X, shi[i-1]+R[i]-R[i-1]);
			nr += R[i]-R[i-1];
			nl += R[i]-R[i-1];
			diff[i] = diff[i-1]+R[i]-R[i-1];
		}
		if(nl < 0){
			lo += abs(nl); nl = 0;
		}
		if(nr > X){
			hi -= abs(nr-X); nr = X;
		}
		l[i] = lo; r[i] = hi;
	}
	int32 Q;
	auto ok = [&](int64 x){return max((int64)0, min(X, x));};
	cin >> Q;
	REP(_, Q){
		int64 t, a;
		cin >> t >> a;
		int32 in = upper_bound(all(R), t)-R.begin()-1;
		if(a < l[in]){
			cout << ok(slo[in]+(in%2?1:-1)*(t-R[in])) << endl;
		}else if(r[in] < a){
			cout << ok(shi[in]+(in%2?1:-1)*(t-R[in])) << endl;
		}else{
			cout << ok(a+diff[in]+(in%2?1:-1)*(t-R[in])) << endl;
		}
	}
}

Measured memory_bytes: 7168
n = int(input())
s = input()

def calc():
  global ans
  for i in range(1, n-1):
    temp = s[i]
    if ans[i]=="S":
      if temp=="o":
        ans[i+1]=ans[i-1]
      else:
        if ans[i-1]=="S":
          ans[i+1]="W"
        else:
          ans[i+1]="S"
    else:
      if temp=="o":
        if ans[i-1]=="S":
          ans[i+1]="W"
        else:
          ans[i+1]="S"
      else:
        ans[i+1]=ans[i-1]

def judge():
  global ans
  global last
  if ans[n-1]!=last:
    return False
  else:
    if ans[n-1]=="S":
      if s[n-1]=="o":
        if ans[n-2]==ans[0]:
          return True
        else:
          return False
      else:
        if ans[n-2]==ans[0]:
          return False
        else:
          return True
    else:
      if s[n-1]=="o":
        if ans[n-2]==ans[0]:
          return False
        else:
          return True
      else:
        if ans[n-2]==ans[0]:
          return True
        else:
          return False
#1 i=0 が　羊だとする。
##1-1 i=1が羊の場合
ans = ["a"]*n
ans[0]="S"
ans[1]="S"
if s[0]=="o":
  last = "S"
else:
  last = "W"

calc()
#print(ans)
if judge():
  print("".join(ans))
  quit()
  
##1-2 i=1が狼 
ans = ["a"]*n
ans[0]="S"
ans[1]="W"
if s[0]=="o":
  last = "W"
else:
  last = "S"
  
calc()
#print(ans)
if judge():
  print("".join(ans))
  quit()
  
#2 i=0 が　狼だとする。
##2-1 i=1が羊
ans = ["a"]*n
ans[0]="W"
ans[1]="S"
if s[0]=="o":
  last = "W"
else:
  last = "S"

calc()
#print(ans)
if judge():
  print("".join(ans))
  quit()
##2-2 i=1が狼 
ans = ["a"]*n
ans[0]="W"
ans[1]="W"
if s[0]=="o":
  last = "S"
else:
  last = "W"
  
calc()
#print(ans)
if judge():
  print("".join(ans))
  quit()
print(-1)

Measured memory_bytes: 10664
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            if i*500 + j*100 + k*50 == x:
                count += 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int x, y;

	cin >> x >> y;

	cout << x * x - y << endl;

	}


Measured memory_bytes: 256
n=int(input())
ans=[0]*(n+1)
m=int(n**0.5)+1
for x in range(1,m):
    for y in range(1,m):
        for z in range(1,m):
            a=x**2+y**2+z**2+x*y+y*z+z*x
            if 1<=a<=n:
                ans[a]+=1
for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 9324
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e6+10;
int n,m,a[4][N];
ll ans,cnt[N];

 
int main()
{
//	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=3;i++)
		for(int j=1;j<=n;j++)
		scanf("%d",&a[i][j]);
	for(int i=1;i<=3;i++)
		sort(a[i]+1,a[i]+n+1);
	for(int i=1,j=1;j<=n;j++)
	{
		while(a[1][i]<a[2][j]&&i<=n) i++;
		cnt[j]+=i-1;
	}
	for(int i=1;i<=n;i++) cnt[i]+=cnt[i-1];
	for(int i=1,j=1;j<=n;j++)
	{
		while(a[2][i]<a[3][j]&&i<=n) i++;
		ans+=cnt[i-1];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9216
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n  = Integer.parseInt(sc.next());
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        for(int i =0;i<n;i++){
            System.out.print(s[i]);
            System.out.print(t[i]);

        }
    }
}

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

int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    for (ll i = 0; i<n; i++){
        cin >> a[i];
        if (a[i] == 0){
            ans = 0;
        }
    }
    if (ans == 0){
        cout << ans << endl;
        return 0;
    }
    for (ll i = 0; i < n; i++){
        if (a[i] > 1000000000000000000/ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int s[n];
    int c[100000] = {};
    int k = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> s[i];
        k = s[i];
        c[k] = c[k] + 1;
    }
    int d[99998] = {};
    d[0] = c[0] + c[1] + c[2];
    int x = d[0];
    for(int j = 1; j < 99998; j++)
    {
        d[j] = c[j] + c[j + 1] + c[j + 2];
        if(d[j] > x)
        {
            x = d[j];
        }
        else
        {
        
        }
    }
    cout << x << endl;


}

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

int main(){
  long long N,K;
  cin>>N>>K;
  if(K%2==1){
  long long a=N/K;
  long long b=a/2, c=a-b;
  cout<<a*a*a<<endl;
  }
  else {
  K=K/2;
  long long a=N/K;
  long long b=a/2, c=a-b;
  cout<<b*b*b+c*c*c<<endl;
  }
  return 0;
}
  

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

int main()
{
	int n;
	cin>>n;
	
	int f=0;
	for(int t=n;t>0;t/=10) f+=t%10;
	
	cout<<((n%f==0)? "Yes":"No")<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main() {
	char taro[101], hanako[101];
	int tscore = 0, hscore = 0;
	int judge;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %s", taro, hanako);
		judge = strcmp(taro, hanako);
		if (judge == 0) {
			tscore++; hscore++;
		}
		else if (judge > 0) {
			tscore += 3;
		}
		else if (judge < 0) {
			hscore += 3;
		}
	}
	printf("%d %d\n", tscore, hscore);
	return 0;
}


Measured memory_bytes: 2040
y, m ,d = map(int, input().split('/'))
if y < 2019:
  print('Heisei')
elif y > 2019:
  print('TBD')
else:
  if m < 4:
    print('Heisei')
  elif m > 4:
    print('TBD')
  else:
    if d <= 30:
      print('Heisei')
    else:
      print('TBD')

Measured memory_bytes: 9076
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
int main() {
    int w,h,c,ans;
    cin>>w>>h>>c;
    for(int i=1000;;i--){
        if(w%i==0&&h%i==0){
            w/=i;
            h/=i;
            break;
        }
    }
    ans=w*h*c;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3124
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <complex>
#include <cmath>
using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
vector<P> convex_hull(vector<P> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<P> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

int main(int argc, char const *argv[]) {
    long long n;cin>>n;
    vector<P> ps(n);
    P p = 0.5 + 0.5 * 1i;
    for(int i=0;i<n;++i){
        double x, y;cin>>x>>y;
        ps[i] = x + 1i * y;
        // ps[i] = ps[i] * p;
    }
    if(n==2){
        cout<<0.5<<endl<<0.5<<endl;
        return 0;
    }
    if(n==1){
        cout<<1.0<<endl;
        return 0;
    }
    vector<P> ch = convex_hull(ps);
    int k = ch.size();
    map<P,double> res;
    for(int i=0;i<k;++i){
        P x = ch[(i+1)%k] - ch[i];
        x = x / sqrt(norm(x));
        P y = ch[i] - ch[(i+k-1)%k];
        y = y / sqrt(norm(y));
        res[ch[i]] = acos(dot(x,y))/(2*M_PI);
        // res[ch[i]] = acos(-dot(ch[(i+1)%k]-ch[i],ch[(i-1+k)%k]-ch[i])/sqrt(norm(ch[(i+1)%k]-ch[i])*norm(ch[(i-1+k)%k]-ch[i])))/(2*M_PI);
    }
    for(int i=0;i<n;++i){
        cout<<fixed<<setprecision(100)<<res[ps[i]]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;
const int maxq=1005;

struct edge{int to,cap,cost,rev;};

int n,m,k;
int d[maxn];
int a[maxn];
int p1[maxn];
int p2[maxn];
bool inq[maxn];
vector<edge>G[maxn];

void add_edge(int u,int v,int c,int w) {
	G[u].pb(edge{v,c,w,int(G[v].size())});
	G[v].pb(edge{u,0,-w,int(G[u].size()-1)});
}

int mcmf(int s,int t) {
	int flow=0 , cost=0;
	while (1) {
		memset(d,0x3f,sizeof(d));
		d[s]=0; a[s]=max(0,k-flow);
		int qh=0,qt=0,q[maxq];
		q[qt++]=s; inq[s]=1;
		while (qh<qt) {
			int u=q[qh++];
			inq[u]=0;
			for (int i=0;i<G[u].size();i++) {
				edge e=G[u][i];
				if (d[e.to]>d[u]+e.cost && e.cap) {
					d[e.to]=d[u]+e.cost;
					a[e.to]=min(a[u],e.cap);
					p1[e.to]=u;
					p2[e.to]=i;
					if (!inq[e.to]) {
						q[qt++]=e.to;
						inq[e.to]=1;
					}
				}
			}
		}
		if (d[t]==INF || !a[t]) break;
		flow+=a[t];
		cost+=a[t]*d[t];
		for (int u=t;u!=s;u=p1[u]) {
			edge& e=G[p1[u]][p2[u]];
			e.cap-=a[t];
			G[e.to][e.rev].cap+=a[t];
		}
	}
	if (flow<k) return -1;
	else return cost;
}

int main() {
	cin>>n>>m>>k;
	for (int i=0;i<m;i++) {
		int u,v,c,w; cin>>u>>v>>c>>w;
		add_edge(u,v,c,w);
	}
	cout<<mcmf(0,n-1)<<'\n';
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#ifdef LOCAL
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#else
#define D(x)
#define R(X, l)
#endif
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int _max(int cnt, ...);
inline int _min(int cnt, ...);
signed main(void)
{
	#ifdef LOCAL
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>(), ans = 0;
	hrp(i, 1, n) hrp(j, 1, n) hrp(k, 1, n) ans += __gcd(__gcd(i, j), k);
	cout<<ans<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int _max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int _min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


Measured memory_bytes: 3652
import sys
import numpy as np

color_1, color_2 = input().split()

co1_n, co2_n = map(int, input().split())

del_col = input()

if del_col == color_1:
    co1_n -= 1
if del_col == color_2:
    co2_n -= 1
    
print(str(co1_n), str(co2_n))

Measured memory_bytes: 21488
#include<stdio.h>
int main(void)
{
    int n,i,j,s=0,max=-1,ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        j=i;
        s=0;
        while(j%2<1){
            j=j/2;
            s++;
        }
        if(max<s){
            max=s;
            ans=i;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1728
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,v[23],c[23];
	int max = 0;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)	scanf("%d",&v[i]);
	for (int i = 0; i < n; ++i)	scanf("%d",&c[i]);
	for (int i = 0; i < n; ++i){
		if(v[i] > c[i])	max += (v[i] - c[i]);
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define pai 3.141592653589793238462643383279

int main(){
    int a, b; cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 3636
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
edges = defaultdict(list)
for i in range(N-1):
	u, v, w = rl()
	u, v = u-1, v-1
	edges[u].append((v,w))
	edges[v].append((u,w))

visited = {}
colors = [None] * N
colors[0] = 0
def dfs(node, prev=-1):
	if node in visited: return
	visited[node] = 1
	color = colors[node]
	for next_node, dist in edges[node]:
		if next_node == prev: continue
		if dist % 2 == 0:
			colors[next_node] = colors[node]
		else:
			colors[next_node] = int(not colors[node])
		dfs(next_node, node)
dfs(0)
for c in colors:
	print(c)


Measured memory_bytes: 192544
rika=[]
shakai=[]
for i in range(4):
    r=int(input())
    rika.append(r)
    
for j in range(2):
    s=int(input())
    shakai.append(s)
    
rika.sort(reverse=True)
shakai.sort(reverse=True)

print(sum(rika)-min(rika)+shakai[0])



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<ll> a(N);
    FOR(i,0,N) cin>>a[i];
    ll sum1=0;
    ll res1=0;
    FOR(i,0,N){
        if(i%2==0){
            if(sum1+a[i]>0){
                sum1+=a[i];
                continue;
            }else{
                res1+=abs(sum1+a[i])+1;
                sum1=1;
            }
        }else{
            if(sum1+a[i]<0){
                sum1+=a[i];
                continue;
            }else{
                res1+=sum1+a[i]+1;
                sum1=-1;
            }
        }
    }
    ll sum2=0;
    ll res2=0;
    FOR(i,0,N){
        if(i%2==1){
            if(sum2+a[i]>0){
                sum2+=a[i];
                continue;
            }else{
                res2+=abs(sum2+a[i])+1;
                sum2=1;
            }
        }else{
            if(sum2+a[i]<0){
                sum2+=a[i];
                continue;
            }else{
                res2+=sum2+a[i]+1;
                sum2=-1;
            }
        }
    }
    cout << min(res1,res2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
int a,b,c;
int five=0;
int seven=0;
std::cin >> a>>b>>c;
if(a==5)five++;
else seven++;

if(b==5)five++;
else seven++;

if(c==5 && seven==1)std::cout << "YES" << '\n';
else if(c==7 && five==2)std::cout << "YES" << '\n';
else  std::cout << "NO" << '\n';

return 0;
}


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

int r[105];
int c[105];
int cache[105][105];

int f(int a, int b) {
    if (a == b) return 0;
    if (cache[a][b] == -1) {
        cache[a][b] = 2000000000;
        for (int i = a; i < b; i++) {
            int res = f(a, i) + f(i + 1, b) + r[a] * c[i] * c[b];
            if (res < cache[a][b]) cache[a][b] = res;
        }
    }
    return cache[a][b];
}

int main(void) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> r[i];
        cin >> c[i];
    }
    memset(cache, -1, sizeof(cache));
    cout << f(0, n-1) << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,m,n) for(int i=m;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=200020;

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


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int N;
    cin >> N;
    int p = N%10;

    if(p==3){
        cout << "bon";
    }
    else if(p==0||p==1||p==6||p==8){
        cout << "pon";
    }
    else cout << "hon";

    return 0;
}

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

int gcd( int i, int j ){
	if( i < j ) swap(i,j);
	while( j != 0 ){
		i = i % j;
		swap(i,j);
	}
	return i;
}

int main() {
	int N; cin >> N;
	vector<int> A(N);
	for(int &k : A)cin >> k;
	vector<int> S_Afront(N + 1);
	S_Afront[1] = A[0];
	for( int i = 1 ; i < N ; i++ ){
		S_Afront[ i + 1 ] = gcd( A[ i ], S_Afront[ i ]);
	}
	
	vector<int> S_Aback( N + 1 );
	reverse(A.begin(),A.end());
	S_Aback[1] = A[0];
	for( int i = 1 ; i < N ; i++ ){
		S_Aback[ i + 1 ] = gcd( A[ i ], S_Aback[ i ]);
	}
	
	int ans = 0;
	ans =  max(S_Afront[N-1],S_Aback[N-1]);
	for( int i = 1 ; i < N - 1 ; i++ ){
		ans = max( ans, gcd(S_Afront[ i ],S_Aback[ N - i - 1 ]));
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1408
k, n = map(int, input().split())
a = list(map(int, input().split()))

b = [0] * n

for i in range(n):
    if i != n - 1:
        b[i] = a[i + 1] - a[i]
    else:
        b[i] = k - a[n - 1] + a[0]

max_b = max(b)

print(k - max_b)


Measured memory_bytes: 26444
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define inf ll(10e16)
#define mod ll(10e5+7)
#define ff first
#define ss second
ll power(ll a,ll b)
{
    if(!b)
        return 1;
    ll temp=power(a,b/2);
    if(b&1)
        return (temp*temp)*a;
    return (temp*temp);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll k;
        string str;
        cin>>k>>str;
        if(str.size()<=k)
        cout<<str;
        else {
            for(ll i=0;i<k;++i)
            cout<<str[i];
            cout<<"...";
        }

    }
    return 0;
}


Measured memory_bytes: 3676
#include<cstdio>
#include<vector>
#define rep(i,a,b) for(int i=(a);i<=(b);++i) 

typedef std::vector<int> P;
const int N=100005;

int n,k;
P a[6];

void print(P a){
	for(int i=0;i<a.size();++i)printf("%d ",a[i]+1);puts("");
}

P mul(P a,P b){
	P c(n);
	rep(i,0,n-1)c[i]=a[b[i]];
	return c;
}

P inv(P a){
	P b(n);
	rep(i,0,n-1)b[a[i]]=i;
	return b;
}

P fpow(P a,int b){
	P c(n);rep(i,0,n-1)c[i]=i;
	for(;b;b>>=1,a=mul(a,a))if(b&1)c=mul(c,a);
	return c;
}

int main(){
	scanf("%d%d",&n,&k);a[0].resize(n),a[1].resize(n);
	rep(i,0,n-1)scanf("%d",&a[0][i]),--a[0][i];
	rep(i,0,n-1)scanf("%d",&a[1][i]),--a[1][i];
	rep(i,2,5)a[i]=mul(a[i-1],inv(a[i-2]));
	P A=mul(mul(a[1],inv(a[0])),mul(inv(a[1]),a[0])),B=fpow(A,(k-1)/6);
	print(mul(mul(B,a[(k-1)%6]),inv(B)));
	return 0;
}

Measured memory_bytes: 6632
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int countDivisor(int n){
    int c = 0;
    for(int i = 1; i <= n; i++){
        if(n % i == 0){
            c++;
        }
    }
    return c;
}

int main(void)
{
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i= i + 2){
        int divisorNum = countDivisor(i);
        if(divisorNum == 8)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
w,h,n=map(int,input().split())
l,r=0,w
d,u=0,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==2:
        r=min(r,x)
    elif a==1:
        l=max(l,x)
    elif a==4:
        u=min(u,y)
    else:
        d=max(d,y)
print(0 if r<=l or u<=d else (r-l)*(u-d))

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <iostream>

#include <stdio.h>

using namespace std;

int main()
{
  multiset<int> mset;
  
  int n,m;
  cin >> n;
  cin >> m;
  
  // printf("n = %d , m = %d\n",n,m);
  
  int i;
  for(i=0;i<n;i++){
    int v;
    cin >> v;
    mset.insert(v);
  }
  
  for(i=0;i<m;i++){
    auto itr = mset.end();
    --itr;
    int v,v2;
    v = *itr;
    v2 = ( v >> 1 );
    //printf(" v(%d) -> v2(%d) \n",v,v2);
    mset.erase(itr);
    mset.insert(v2);
  }
  
  long long int sm = 0;
  
  for(auto itr = mset.begin(); itr != mset.end(); ++itr) {
    sm += *itr;
  }
  cout << sm << "\n";
  return 0;
  
}



Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 1000000000;

int main()
{
  int n, k; cin >> n >> k;
  int h[100200] = {}; for (int i = 0; i < n; ++i) cin >> h[i];
  int dp[100200]; dp[0] = 0; for (int i = 1; i < 100200; ++i) dp[i] = INF;
  
  for (int i = 0; i < n; ++i) for (int j = i+1; j <= i+k; ++j)
    dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]));
  
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(1){
        string s; cin >> s;
        int ans=0;
        if(s=="0")break;
        for(char c:s){
            ans+=(c-'0');
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
int main()
{
	dhoom;
	int n;
	cin >> n;
	//string s = to_string(n);
	if(n <= 999){
		cout << "ABC";
	}
	else
		cout << "ABD";
	
	return 0;
} 



Measured memory_bytes: 256
#include<cstdio>
int main(){
  int a,b,c,ans;
  scanf("%d%d%d",&a,&b,&c);
  if(a>=b&&a>=c) ans=b+c;
  else if(b>=a&&b>=c) ans=a+c;
  else ans=a+b;
  printf("%d",ans);
}

Measured memory_bytes: 128
X,N=map(int,input().split())
if(N==0):
  print(X)
  exit()
P= list(map(int,input().split()))
c=-100
ans=100000
for i in range(200):
  a=0
  for i in range(200):
    if (abs(X-c)>=abs(X-c-a)):
      if not (c+a in P):
        
        if (abs(X-ans) >=abs(X-c-a)):
          ans=c+a
          
          
    a+=1
  c+=1
if (ans>X):
  if not(X-ans+X in P):
    ans=X-ans+X
print(ans)

Measured memory_bytes: 67656
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = Integer.parseInt(sc.next());
    int Y = Integer.parseInt(sc.next());
    for(int i = 0; i<=X;i++){
      if(2*i + (X - i)*4==Y){
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 35668
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>

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

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    int ans = 0;
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        int lar = max(tmp, K);
        int sma = min(tmp, K);

        if (lar - sma > tmp)
        {
            ans += tmp;
        }
        else
        {
            ans += (lar - sma);
        }
    }

    cout << ans * 2 << endl;

    return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  1000000007
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 


int bigmod(int a,int p){
    if (p==0) return 1;
    if (p&1){
        int p1=a%mod;
        int p2 = bigmod(a,p-1);
        return (p1*p2)%mod;
    }
    int p1=bigmod(a,p/2);
    return (p1*p1)%mod;
}

inline void solve(){
    bool ok=true;
    int x,y; 
    cin>>x>>y; 
    int n=0,m=0,ans=0; 
    if ((x+y)%3 or (min(x,y)*2<max(x,y))) ok=false;
    while (x*2>y) n++, x -= 2 , y-- ; 
    while (x>0) m++, x-- ; 
    n = n+m;
    x=1,y=1;
    for (int i=1;i<=m;i++){
        x = (x*(n-i+1))%mod; 
        y = (y*i)%mod;
    }
    cout << (ok?(( (x * bigmod(y,mod-2)) + 2LL*mod ) % mod ):0) << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>

  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
  typedef string str;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 998244353;
  lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;



// void solve(){

// string s;
// cin>>s;


// }
  set<int> co;
  set<int> ro;
  char a[7][7];
  int n,m;

  int ans(){
    int l = 0;
    for (int ii = 0;ii<n;ii++){
      for (int jj = 0;jj<m;jj++){
        if (!ro.count(ii) && !co.count(jj) && a[ii][jj] == '#'){
          l++;

        }
      }
    }
    return l;

  }

  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
      cin>>n>>m;
      int k;
      cin>>k;
      for (int i = 0;i<7;i++){
        for (int j = 0;j<7;j++) a[i][j] = '.';
      }
      
      for (int i = 0;i<n;i++){
        for (int j = 0;j<m;j++) cin>>a[i][j];
      }
    int an = 0;
    for (int maskrow = 0;maskrow < (1<<n);maskrow++){
      for (int maskcol = 0;maskcol <(1<<m);maskcol++){

       
          co.clear();
        ro.clear();
        for (int p = 0;p<n;p++){
          if (int(pow(2,p)) & maskrow){
            ro.insert(p);
          }
        }
        for (int p = 0;p<m;p++){
          if (int(pow(2,p)) & maskcol){
            co.insert(p);
          }
        }
        if (ans() == k) {an++; 
          // set<int>::iterator it;
          // it = co.begin();
          // while (it!= co.end()){
          //   cout<<*it<<" ";
          //   it++;
          // }
          // cout<<endl;
          // it = ro.begin();
          // while (it!= ro.end()){
          //   cout<<*it<<" ";
          //   it++;
          // }
          // cout<<endl;
          // cout<<maskrow<<" "<<maskrow<<endl;
        }
      }
    }
  
  cout<<an<<"\n";
}



Measured memory_bytes: 3144