akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;
ll  power(ll  x, ll y) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x ;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) ;
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) ;
    } 
    return res; 
}
 
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, k;
  cin >> n >> k;
  dll mul = (dll)((dll)1/ (dll)(n)) ;
  dll add = 0;
  for(ll i = 1; i <= n; i++) {
    if(i >= k) add = add + 1.00;
    else {
      ll poww = 0;
      ll tt = i;
      while(tt < k) {
        tt*=2;
        poww++ ;
      }
      ll div = power(2, poww) ;
      add = add + (dll) (dll)((dll)(1.000)/ (dll)(div)) ;
    }
  }
  add = (dll)((dll)(mul) * (dll)(add)) ;
  cout << fixed << setprecision(25) << add;
  return 0;
} //good night.

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    a:usize,b:usize,
     }
    if a >= 13 {
        println!("{}", b);
    } else if a >= 6 {
        println!("{}", b / 2);
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 2140
def main():
    X, Y = map(int, input().split())

    a = (4*X - Y)//2
    b = (Y - 2*X)//2

    if (a + b != X) or (2*a + 4*b != Y):
        print('No')
    elif a < 0 or b < 0:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()

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

typedef long long ll;

int main(){

    int n; cin >> n; vector<ll> vec(n);
    for ( ll& i : vec ) cin >> i , i *= 2;

    ll x = 0;
    for ( int i = 1; i <= n; ++i ){
        x += (i&1 ? 1 : -1) * vec[i%n];
    }
    x >>= 1;

    vector<int> ret;
    ret.push_back(x);

    for ( int i = 1; i < n; ++i ){
        ret.push_back(vec[i] - ret.back());
    }

    cout << ret.back() << " "; ret.pop_back();
    for ( ll i : ret )
        cout << i << " ";
    return 0;
}


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

typedef long long LL;

const int N=200000;

int n,x[N+9],y[N+9];
int ox[N+9],oy[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
	scanf("%d%d",&x[i],&y[i]);
	ox[i]=x[i];oy[i]=y[i];
  }
}

int id[N+9],p[N+9];

void Get_id(){
  sort(ox+1,ox+n+1);
  sort(oy+1,oy+n+1);
  for (int i=1;i<=n;++i){
	x[i]=lower_bound(ox+1,ox+n+1,x[i])-ox;
	y[i]=lower_bound(oy+1,oy+n+1,y[i])-oy;
	id[x[i]]=i;p[x[i]]=y[i];
  }
}

int le[N+9],ri[N+9];

void Get_le_ri(){
  le[1]=1;ri[n]=n;
  for (int i=2;i<=n;++i) le[i]=abs(p[i]-p[i-1])==1?le[i-1]:i;
  for (int i=n-1;i>=1;--i) ri[i]=abs(p[i]-p[i+1])==1?ri[i+1]:i;
}

map<int,LL>dp[2][N+9];

int Get_dis(int a,int b){
  a=id[a];b=id[b];
  return abs(ox[x[a]]-ox[x[b]])+abs(oy[y[a]]-oy[y[b]]);
}

LL Dfs_dp(int l,int r,int t,int mn,int mx){
  if (dp[t][l].find(r)!=dp[t][l].end()) return dp[t][l][r];
  LL res=l-r;
  int flag=0;
  if (l>1&&(p[l-1]==mn-1||p[l-1]==mx+1))
	res=Dfs_dp(le[l-1],r,0,min(mn,p[le[l-1]]),max(mx,p[le[l-1]]))+Get_dis(le[l-1],t?r:l),flag=1;
  if (r<n&&(p[r+1]==mn-1||p[r+1]==mx+1)){
	LL now=Dfs_dp(l,ri[r+1],1,min(mn,p[ri[r+1]]),max(mx,p[ri[r+1]]))+Get_dis(ri[r+1],t?r:l);
	res=flag?min(res,now):now;
  }
  return dp[t][l][r]=res;
}

LL ans[N+9];

void Get_dp(){
  for (int i=1;i<=n;++i) ans[id[i]]=Dfs_dp(i,i,0,p[i],p[i]);
}

void work(){
  Get_id();
  Get_le_ri();
  Get_dp();
}

void outo(){
  for (int i=1;i<=n;++i)
	printf("%lld\n",ans[i]);
}

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

Measured memory_bytes: 79536
# coding: utf-8

log = []

count = int(input())

isValid = True
prev = ""
for i in range(count):
    word = input().rstrip()
    if len(prev) > 0:
        if word[0] != prev[-1]:
            isValid = False
    if word in log:
        isValid = False

    log.append(word)
    prev = word

print("Yes" if isValid else "No")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] array = line.Split(' ');

            var N = int.Parse(array[0]);
            var K = int.Parse(array[1]);

            var k = 1;
            var count = 0;
            while ((N/k)>0)
            {
                k *= K;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define PI 3.14159265359
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;
int n,m;
vector<int> v[211111];
int d[211111];
int ans[211111];
signed main(){
	
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	fill(d,d+n,INF);
	queue<P> q;
	q.push(P(0,0));
	d[0]=0;
	while(q.size()){
		P p=q.front();
		q.pop();
		for(auto x:v[p.first]){
			if(d[x]!=INF)continue;
			q.push(P(x,p.second+1));
			d[x]=p.second+1;
			ans[x]=p.first;
		}
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<n;i++){
		cout<<ans[i]+1<<endl;
	}

}


Measured memory_bytes: 16876
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
#define int long long

signed main() {

	int h, w, k;
	cin >> h >> w >> k;
	int arr[h][w];
	for (int i=0; i<h; i++) {
		string s;
		cin >> s;
		for (int j=0; j<w; j++) {
			arr[i][j] = (s[j] == '1');
		}
	}
	
	int t = 1<<h;
	int mn = h - 1 + w - 1;
	for (int i=0; i<t; i++) {
		bool no = false;
		// if this subset is cut from t
		// cout << "for: " << i << endl;
		int here = 0;
		vector<int> group_enders;
		for (int j=0; j<h; j++) {
			if ((1 << j) & i) {
				group_enders.push_back(j);
			}
		}
		int grp[h];
		grp[0] = 0;
		for (int T=1; T<h; T++) {
			if ((1<<(T-1)) & i) {
				grp[T] = grp[T-1] + 1;
			}
			else {
				grp[T] = grp[T-1];
			}
		}
		// for (int i=0; i<h; i++) cout << grp[i] << ' '; cout << endl;
		int nm = grp[h-1] + 1;
		int si[nm];
		memset(si, 0, sizeof si);
		for (int j=0; j<w; j++) {
			// cout << "now: " << j << endl;
			bool need_split = false;
			for (int x=0; x<h; x++) {
				si[grp[x]] += arr[x][j];
				// out << "    ad " << arr[x][j] << endl;
				if (si[grp[x]] > k) need_split = true;
			}
			if (need_split) {
				// cout << "split before: " << j << endl;
				here++;
				memset(si, 0, sizeof si);
				for (int x=0; x<h; x++) {
					si[grp[x]] += arr[x][j];
					// cout << "    ad " << arr[x][j] << endl;
				}
				for (int x=0; x<nm; x++) {
					if (si[x] > k) no = true;
				}
				
			}
		}
		// cout << i << ' ' << here << endl;
		if (no) continue;
		mn = min(mn, here + __builtin_popcount(i));
	}
	
	cout << mn << endl;
	
	
}




Measured memory_bytes: 384
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
    int N,K,M;
    while(cin >> N >> K >> M, (N | K | M)){
	vector<int> vec;
	for(int i = 0 ; i < N ; i++){
	    vec.push_back(i+1);
	}
	vec.erase(vec.begin()+M-1);
	int cur = (K + M - 2) % vec.size();
	while(true){
	    if(vec.size() == 1) break;
	    vec.erase(vec.begin()+cur);
	    cur = (cur + K - 1) % vec.size();
	}
	cout << vec[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long inv(long long x){
  long long res = 1;
  long long k = mod - 2;
  long long y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

int main(){
  int n,m;cin >> n >> m;
  vector<int> a(m+1);
  for(int i = 0;i < m;i++){
    cin >> a[i];
  }
  a[m] = n+1;
  vector<long long> fact(n+5);
  fact[0] = 1;
  for(int i = 1;i < fact.size();i++){
    fact[i] = (fact[i-1]*i) % mod;
  }
  int cur = 0;
  long long ret = 1;
  for(int i = 0;i <= m;i++){
    int cnt = a[i]-1 - cur;
    int two = 0;
    long long num = 0;
    while(cnt >= two){
      num += (fact[cnt] * inv(fact[cnt-two]) % mod) * inv(fact[two]) % mod;
      num %= mod;
      cnt--;
      two++;
    }
    ret = ret*num%mod;
    cur = a[i]+1;
  }
  cout << ret << endl;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//?????????: n??\???????´???°
vector<int> getPrimes(int n) {
	vector<char> is_prime(n + 1, false);
	for (int i = 1; 7 * i - 1 <= n; i++)
		is_prime[7 * i - 1] = true;
	for (int i = 1; 7 * i + 1 <= n; i++)
		is_prime[7 * i + 1] = true;

	for (int i = 1; 7 * i - 1 <= n; i++) {
		int a = 7 * i - 1;
		if (is_prime[a]) {
			int b = a + a;
			while (b <= n) {
				is_prime[b] = false;
				b += a;
			}
		}
	}
	for (int i = 1; 7 * i + 1 <= n; i++) {
		int a = 7 * i + 1;
		if (is_prime[a]) {
			int b = a + a;
			while (b <= n) {
				is_prime[b] = false;
				b += a;
			}
		}
	}
	vector<int> primes;
	rep(i, 0, n + 1)
		if (is_prime[i])
			primes.emplace_back(i);
	return primes;
}

signed main() {
	for (int x; cin >> x&&x != 1;) {
		vector<int> res = getPrimes(x);
		cout << x << ":";
		rep(i, 0, res.size()) {
			if (x%res[i] == 0) {
				cout << " " << res[i];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	for (long long i=1;i<=1000000;i++)
	{
		if (a*i%b==c)
		{
			cout<<"YES\n";
			return 0;
		}
	}
	
	printf("NO\n");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int n = 0;			//1???????????´??°???????´????????????°
	int i = 0;			//for????????????????????????????????°
	int j = 0;
	int k = 0;			//???????????????????????????????????°
	long long int sum = 0;		//????¨????
	scanf("%d", &n);

	int num[n];			//n??????????´??????????int????????????num

	for(i = 0 ; i < n ; i++){
		scanf("%d",&num[i]);	//n?????´??°???????????????
		sum += num[i];			//????¨????
	}

	/*?????????????????????*/
	for(i = 0 ; i < n ; i++){
		for(j = 0; j+1 < n; j++){

			if(num[j] < num[j+1]){
				k = num[j];
				num[j] = num[j+1];
				num[j+1] = k;
			}

		}
	}

	/*????°????????????§??????????¨??????¨???*/
		printf("%d %d %lld\n",num[n-1],num[0],sum);




	return 0;
}

Measured memory_bytes: 640
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

const [, ..._p] = stdin.trim().split('\n')
const p = _p.map(Number)

const s = p.sort((a, b) => b - a)

let sum = 0
for (let i = 0; i < s.length; i++) {
  if (i === 0) {
    sum += s[i] / 2
  } else {
    sum += s[i]
  }
}

console.log(sum)


Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
 using namespace std;
 typedef long long ll;
 const int maxn=10010;
 ll cnt[3][maxn];
 map<char,int> m;
 map<int,char> m1;
 char s[maxn];
 int main()
 {
 	ll len,ans=0;
 	cin>>len>>s;
 	m['R']=0,m['G']=1,m['B']=2;
 	m1[0]='R',m1[1]='G',m1[2]='B';
 	for(int i=len-1;i>=0;i--){
 		for(int j=0;j<3;j++)
			cnt[j][i]=cnt[j][i+1];
		cnt[m[s[i]]][i]++; 			
	 }
	for(int i=0;i<len-2;i++){
		for(int j=i+1;j<len-1;j++){
			if(s[i]==s[j]) continue;
			int k=3-m[s[i]]-m[s[j]];
			ans+=cnt[k][j];
			if(s[j+(j-i)]==m1[k]) ans--;
		}
	}
	cout<<ans;
 	return 0;
 }

Measured memory_bytes: 3236
#include <stdio.h>

int main(void){
    int a,b,n,i;
    while(scanf("%d",&a) != EOF){
        scanf("%d",&b);
        n = a + b;
        i = 0;
        while (n != 0){
            i = i + 1;
            n = n/10;
        }
        printf("%d\n",i);
    }
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstring>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define N 500005
using namespace std;
int fa[N],f[305][305],n,cnt=0; long long ans=0;
bool vis[305][305];
struct Node{
	int x,y,d;
}a[N];
bool cmp(Node aa,Node bb)
{
	return aa.d<bb.d;
}
int find(int x)
{
	if (x==fa[x]) return x;
	fa[x]=find(fa[x]);
	return fa[x];
}
void make(int x,int y)
{
	fa[find(x)]=find(y);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++) scanf("%d",&f[i][j]);
	memset(vis,true,sizeof(vis));
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if (i==j) continue;
			for (int k=1;k<=n;k++){
				if (i==k||j==k) continue;
				if (f[i][j]>f[i][k]+f[k][j]){
					puts("-1");
					return 0;
				}
				else if (f[i][j]==f[i][k]+f[k][j]) vis[i][j]=false;
			}
		}
	}
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++) if (vis[i][j]) ans=ans+(long long)f[i][j];
	/*for (int i=1;i<n;i++){
		for (int j=i+1;j<=n;j++){
			if (i==j) continue;
			a[++cnt].x=i; a[cnt].y=j;
			a[cnt].d=f[i][j];
		}
	}
	for (int i=1;i<=n;i++) fa[i]=i;
	sort(a+1,a+cnt+1,cmp);
	int ans=0; int k=0;
	for (int i=1;i<=cnt;i++){
		if (find(a[i].x)!=find(a[i].y)){
			k++;
			ans=ans+a[i].d;
			make(a[i].x,a[i].y);
		}
		else continue;
		if (k==n-1) break;
	}*/
	printf("%lld\n",ans);
	return 0;
}

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

int N;
ll A[100000];
 
int main(){
    int i;
    ll a = 0, b, c, z = 0;
    cin >> N;
    for (i = 0; i < N; i++) {
        cin >> A[i];
        a ^= A[i];
    }
    for (b = 1LL << 59; b; b >>= 1) {
        if (b & a) continue;
        for (i = 0; i < N; i++) if (A[i] & b) break;
        if (i == N) continue;
        if(!(z & b)) z ^= A[i];
        c = A[i];
        for (; i < N; i++) if (A[i] & b) A[i] ^= c;
    }
    cout << 2 * (z & ~a) + a << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}


int main(){//
    int H, W, K;
    cin >> H >> W >> K;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    vector<string> c(H);
    for(int i=0; i<H; i++) cin >> c[i];

    const ll INF = 1e18;
    vector<ll> dist(H*W*4 + 5, INF);
    //xをKで割った切り上げ  に Kを掛けた値を返す
    auto modKceil = [&](ll x){
        ll kiriage = (x + K -1) / K;
        return  kiriage * K;
    };
    // h,w,4の3つの値を1セットとした　idに変換
    auto toID = [&](int h, int w, int dir){
        return  (h*W + w) * 4  + dir;
    };

    

    typedef pair<int ,int> P;
    typedef pair<ll, int> LP;
    priority_queue<LP, vector<LP>, greater<LP>> q;
    //値の更新 と qにemplace する
    auto push = [&](int h, int w, int dir, int x){
        ll id = toID(h, w, dir);
        if(dist[id] <= x ) return;//小さくできない場合は何もしない
        dist[id] = x;//値を更新
        q.emplace(x, id);
    };

    //初期値 4方向分
    for(int dir=0; dir<4; dir++) push(x1, y1, dir, 0); 
    
    const int dh[4] = {-1, 0, 1, 0};
    const int dw[4] = {0, -1, 0, 1};   
    while(!q.empty()){
        ll d = q.top().first;
        ll id = q.top().second;
        q.pop();
        if(dist[id] < d) continue;//もともとはif(dist[id]!=d) continue;//更新された時にqに残っている古い情報は何もしない
        int h = id /W/4;
        int w = id/4 % W;
        int dir = id % 4;

        //とりあえず向きが変化したとして，4方向動いてみる
        for(int nv=0; nv<4; nv++) push(h, w, nv, modKceil(d));
        
        //今向いている向きに進む
        int next_h = h + dh[dir];
        int next_w = w + dw[dir];
        if(next_h < 0  ||  H <= next_h) continue;
        if(next_w < 0  ||  W <= next_w) continue;
        if(c[next_h][next_w] == '@') continue;
        push(next_h, next_w, dir, d+1);//値の更新とqにemplaceする
        
    }


    ll ans = INF;
    for(int dir=0; dir<4; dir++){
        ll id = toID(x2, y2, dir);
        ans = min(ans, dist[id]);
    }
    if(ans == INF) ans = -1;
    else ans = modKceil(ans) / K;
    cout << ans << endl;
}


Measured memory_bytes: 44180
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,K;
int f[2100000][22];
char s[2100000];
int main() {
	scanf("%d%d",&n,&K);
	for(int i=0;i<=n;i++){
		scanf("%s",s);
		int lim=(1<<i);
		for (int j=0;j<lim;j++) f[lim|j][i]=(s[j]-'0');
	}
	for (int i=n;i>=0;i--)
		for (int s=0;s<(1<<i);s++)
			for (int j=i;j>=0;j--){
				int cur=f[(1<<i)|s][j];
				if (cur){
					int s1=s>>j;
					int s2=s&((1<<j)-1);
					if (j) f[(1<<(i-j))|s1][0]+=cur;
					if (s2){
						int p=j-1;
						while (!((s2>>p)&1)) p--;
						f[(1<<(i-(j-1-p)))|(s1<<(p+1))|(s2&((1<<p)-1))|(1<<p)][p]+=cur;
					}
					if (((1<<j)-1)&(~s2)){
						int p=j-1;
						while ((s2>>p)&1) p--;
						f[(1<<(i-(j-1-p)))|(s1<<(p+1))|(s2&((1<<p)-1))][p]+=cur;
					}
				}
			}
	for (int i=n;i>=0;i--)
		for (int j=0;j<(1<<i);j++)
			if (f[(1<<i)|j][0]>=K){
				for(int k=i-1;k>=0;k--) printf("%d",(j>>k)&1);
				return 0;
			}
	return 0;
}


Measured memory_bytes: 181504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << (in() % in() == 0 ? 0 : 1) << "\n";
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int x;cin>>x;
    if(x==0){
        cout<<1<<endl;
    }
    else{
        cout<<0<<endl;
    }
    
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

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

    if(D==25) cout<<"Christmas"<<endl;
    if(D==24) cout<<"Christmas Eve"<<endl;
    if(D==23) cout<<"Christmas Eve Eve"<<endl;
    if(D==22) cout<<"Christmas Eve Eve Eve"<<endl;
}

Measured memory_bytes: 256
#ifdef DEBUG
#include "../utils.cpp"
#endif
#include <bits/stdc++.h>
/*
Problem
最長共通部分列

 
Category
DP
 
URL:
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C&lang=ja

考察:
dp[X][Y] := Xに対するYのLCSを作るのに必要なXの部分文字列のindexの最小値
--> LCSのサイズの情報がないのでダメ。

dp[X][Y] := XとYで作れる LCS の長さ
--> 素直な定義。でも漸化式が作れるのか？
dp[0][Y] = 0
dp[i][j] = X[i] == Y[j] ? dp[i-1][j-1] + 1 : max(dp[i][j-1], dp[i-1][j])



Date: 2020/04/18
*/
 

using namespace std;
using ll = int64_t;
#define int int64_t
#define INF 10e9

 
/* ==== declarations ====== */
// functions
void solve();
void getInput();
 
// global variables
int Q;
vector<vector<int>> dp;
vector<int> V;
string X, Y;

/* ======================== */

void getInput() {
    cin>>X;
    cin>>Y;
}
 
 
void solve() {
    dp = vector<vector<int>>(X.size(), vector<int>(Y.size(), 0));

    for (int i=0; i<X.size(); ++i) {
        for (int j=0; j<Y.size(); ++j) {
            int a = (i>0 and j>0) ? dp[i-1][j-1] : 0;
            int b = (j>0) ? dp[i][j-1] : 0;
            int c = (i>0) ? dp[i-1][j] : 0;
            if (X[i] == Y[j]) {
                dp[i][j] = max(a + 1, max(b, c));
            }
            else {
                dp[i][j] = max(b, c);
            }
        }
    }
    // print(dp);
    cout<<dp[X.size()-1][Y.size()-1]<<endl;
}
 
 
 
signed main(){
    cin>>Q;
    for(int i=0; i<Q; ++i) {
        getInput();
        solve();
    }
    return 0;
}




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

int main()
{
    string a, b;
    cin >> a >> b;
    int s = stoi(a+b);
    bool flag = false;
    rep(i,500){
        if (i*i == s) flag =true;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <functional>
#include<stdio.h>
using namespace std;
#define ll       	long long int
#define dd      	long double
#define pb          push_back
#define pf          push_front
#define pi         pair<ll,ll>
#define vi          vector<ll>
#define vpi        vector<pi>
#define mi          map<ll,ll>
#define vvi         vector<vector<ll>>
#define mpi         map<pi,ll>
#define pipi        pair<ll,pair<ll,ll> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x         first
#define y         second
#define sz(x)       (ll)x.size()
#define u        	'\n'
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define rf(s)       for(auto &c : s)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++) //use Iterator
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define ef          else if
#define yes       cout<<"YES"<<'\n';
#define no        cout<<"NO"<<'\n';
#define C         continue;
#define wa(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<'\n'
#define debugp(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i.x<<","<<i.y<<" | "; cout<<'\n'
#include <ext/pb_ds/tree_policy.hpp>     
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>     
using namespace __gnu_pbds;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key
const ll N = 350;
 
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); } 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) 
    { 
        if (y & 1) 
        res = res*x; 
        y = y>>1; 
        x = x*x;  
    } 
    return res; 
}

signed main()
{
	tezz
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll a,b,c,d,i,j;
		cin>>a>>b>>c>>d;
		ll r=a*d;
		ll r1=a*c;
		ll r2=b*c;
		ll r3=b*d;
		cout<<max({r,r1,r2,r3})<<u;
	}
	return 0;
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for(int i=0; i<4; i++){
        if (s[i] == '2')cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include  <stdio.h>
int main ()
{
	int a, b;
	char op;
	scanf ("%d %c%d", &a, &op, &b);
	if(op=='+') 
	{
		printf ("%d", a+b);
	}
	else
	printf ("%d", a-b);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
vector<int> nex[114514];
int able[114514][3];
signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		nex[x].pb(y);
	}
	int s,t;
	cin>>s>>t;
	queue< pair<int,int> > que;
	que.push(mp(s,0));
	able[s][0] = 1;
	while(!que.empty()){
		pair<int,int> P = que.front(); que.pop();
		int ci = P.first;
		int cd = P.second;
		for(int i=0;i<nex[ci].size();i++){
			int nx = nex[ci][i];
			if( able[nx][ (cd+1)%3 ] == 0){
				able[nx][ (cd+1)%3 ] = able[ci][cd] + 1;
				que.push( mp(nx,(cd+1)%3 ) );
			}
		}
	}
	if( able[t][0] == 0)able[t][0]=-1;
	else able[t][0] = (able[t][0]-1)/3;
	cout<<able[t][0]<<endl;
	return 0;
}

Measured memory_bytes: 8704
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
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;}
const int INF = 1e9;
const ll LINF = 1e18;
#define ANS(ans) cout<<ans<<endl;
// clang-format on

struct restaurant {
  ll id;
  string venue;
  ll score;
};

void solve(long long N, std::vector<std::string> S, std::vector<long long> P) {
  vector<restaurant> r(N);
  rep(i, N) { r[i] = {i + 1, S[i], P[i]}; }
  sort(all(r), [](auto const &l, auto const &r) {
    if (l.venue == r.venue)
      return l.score > r.score;
    else
      return l.venue < r.venue;
  });
  rep(i, N) { ANS(r[i].id); }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  std::vector<long long> P(N);
  for (int i = 0; i < N; i++) {
    std::cin >> S[i];
    scanf("%lld", &P[i]);
  }
  solve(N, std::move(S), std::move(P));
  return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

count = 0

for i in range(max(h)):
	
	state = 0
	for j in range(N):
		if h[j] > i:
			 if state == 0:
			 	count += 1
			 	state = 1
		else:
			state = 0

print(count)

Measured memory_bytes: 3060
ans = 0
etc = []
for i in range(5):
  a = int(input())
  a10 = a % 10
  if a10 == 0:
    A = a
  else:
    A = a + 10 - a10
    etc.append(a10)
  ans += A
if len(etc) != 0:
  ans += min(etc) - 10
print(ans)


Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;

int z(int x)
{
  if(x>=0)
    return x;
  else
    return x*-1;
}

int main()
{
  string s;
  cin>>s;
  int ans=1000;
  for(int i=0;i<=s.size()-3;i++)
  {
    int x;
    x=(s.at(i)-48)*100+(s.at(i+1)-48)*10+(s.at(i+2)-48);
    ans=min(ans,z(x-753));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j;
bool f(pair<long int,long int> p1,pair<long int,long int>p2){
  if(p1.ft==p2.ft) return p1.sd>p2.sd;
  else return p1<p2;
}
int main(){
   
 ll n; cin>>n;
 vl v(n);
 vl b(n);
 vl c(n-1);
 for(i=0;i<n;i++) cin>>v[i];
  for(i=0;i<n;i++) cin>>b[i];
    for(i=0;i<n-1;i++) cin>>c[i];
      ll sum=0;
    ll t=0;
      for(i=0;i<n;i++){
        ll x=v[i]-1;
        sum=sum+b[x];
        //cout<<sum<<endl;
        if((v[max(t,i-1)]+1)==v[i]) sum=sum+c[x-1];
      }
   cout<<sum<<endl;

return 0;
}
 

Measured memory_bytes: 256
import math
a,b,c = map(float, input().split())

r = c * (math.pi/180)
h = b * math.sin(r)
S = 0.5 * a * b * math.sin(r)
L = a + b + math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(r))
print(S)
print(L)
print(h)



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

//bool ok[100];
int kind[14];

int n;
int num[100];
bool fin;
int mem[100];


const int MAX_PRIME = 1000;
void dfs(int sum,int cnt){
    if(cnt==1){
        for(int i = 1; i < 14; i++){
            if(kind[i]>0){
                mem[n-cnt]=i;
                break;
            }
        }
        fin=true;
        return;
    }
    for(int i = 1; i < 14; i++){
        if(kind[i]==0)
            continue;
        int nsum=sum-i;
        if(nsum%i==0){
            kind[i]--;
            mem[-cnt+n]=i;
            dfs(nsum,cnt-1);
            if(fin)
                return;
            kind[i]++;
        }
    }
}
//void dfs(int sum,int cnt){
//    if(cnt==n){
//        fin=true;
//        return;
//    }
//    for(int i = 0; i < n; i++){
//        if(ok[i])
//            continue;
//        int nsum=sum+num[i];
//        if(sum%num[i]==0){
//            ok[i]=true;
//            mem[cnt]=num[i];
//            dfs(nsum,cnt+1);
//            if(fin)
//                return;
//            ok[i]=false;
//        }
//    }
//}

int main(){
    while(cin>>n&&n!=0){
        int sum=0;
        fin=false;
        fill(kind,kind+14,0);
        for(int i = 0; i < n; i++){
            cin>>num[i];
            kind[num[i]]++;
            sum+=num[i];
        }
        dfs(sum,n);
        if(fin){
            for(int i = 0; i < n; i++){
                cout<<mem[n-1-i];
                if(i==n-1)
                    cout<<endl;
                else
                    cout<<" ";
            }
        }
        else
            cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
a = ord('a')
counts = [0] * 26
while 1:
    try:
        raw = input()
    except EOFError:
        break
    for c in raw.lower():
        if 0 <= ord(c) - a < 26:
            counts[ord(c) - a] += 1
for i, count in enumerate(counts):
    print('%s : %d' % (chr(a + i), count))

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

int main(){
  int n; cin>>n;
  vector<pair<ll,ll>> ab(n);
  
  for(int i=0;i<n;i++){
    ll a,b; cin>>a >>b;
    ab.push_back(make_pair(a,b));
  }
  
  sort(ab.rbegin(),ab.rend());
  
  cout<<ab[0].first+ab[0].second<<endl;
  return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
#include<cstring>
int main(){
    char ring1[101],ring2[101],ring3[201];
    scanf("%s %s",ring1,ring2);
    strcpy(ring3,ring1);
    strcat(ring3,ring1);
    if(strstr(ring3,ring2)==NULL) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2744
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	int maxP = 0;
	rep(i, N) {
		int p;
		cin >> p;
		ans += p;
		maxP = max(maxP, p);
	}
	ans = ans - maxP + (maxP / 2);
	cout << ans << endl;
	return 0;
}


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

int n, a, b;
vector<int> v[100010];
long long int dp[100010][5];
const int MOD = 1e9 + 7;

long long int rek(int x, int y, int prt, long long int slj) {
	if (v[x].size() == 1 && v[x][0] == prt) {
		dp[x][y] = 1;
		return 1;
	}
	
	long long int &ret = dp[x][y];
	if (ret != -1) return ret;
	ret = 1;
	
	if (y == 1) {
		for (int i = 0; i < v[x].size(); i ++) {
			if (v[x][i] != prt) {
				ret *= rek(v[x][i], 0, x, 1);
				ret %= MOD;
			}
		}
	}
	
	if (y == 0) {
		for (int i = 0; i < v[x].size(); i ++) {
			if (v[x][i] != prt) {
				y = rek(v[x][i], 0, x, 1) + rek(v[x][i], 1, x, 1);
				y %= MOD;
				slj *= y;
				slj %= MOD;
			}
		}
		
		ret = slj;
		ret %= MOD;
	}
	
	return ret;
}

int main () {
	
	cin >> n;
	memset(dp, -1, sizeof dp);
	for (int i = 0; i < n-1; i ++) {
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	long long int sol1 = rek(1, 0, 0, 1);
	sol1 += rek(1, 1, 0, 1);
	sol1 %= MOD;
	cout << sol1;
	
	return 0;
}

Measured memory_bytes: 16512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int length = S.length();
        for(int start=0; start<length; start++) {
            for(int remove_length=start; remove_length<length ; remove_length++) {
                String tmp = S.substring(0, start) + S.substring(remove_length, length);
//                System.out.println(tmp);
                if(tmp.equals("keyence")) {
                    System.out.println("YES");
                    return;
                };
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 25172
def make_divisors(n):
    #https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def f(a,b):
    str_a = str(a)
    str_b = str(b)
    return(max(len(str_a),len(str_b)))

n = int(input())
yakusu = make_divisors(n)
kazu = (len(yakusu)+1)//2
ans = 11
for j in range(kazu):
    ans = min(ans,f(yakusu[j],yakusu[-(j+1)]))

print(ans)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define txt                        \
    freopen("ip.txt", "r", stdin); \
    freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define quickie                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define div2(a) (!(a & 1))
#define deb(x) cout << (#x) << " " << (x) << "\n";
#define newl cout << "\n"
#define all(s) s.begin(), s.end()
#define pi 3.14159265358979323846
#define mod 1000000007
#define fp(x) fixed << setprecision(x) <<
template <class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template <class T>
void split(char c, T s)
{
    int n = s.size();
    int i = 0;
    while ((cout << s[i], i += 1) && (i < n) && (cout << c << ' '))
        ;
}

vector<ll> primes;
const int NN = 50;
int prime[NN];

void solve()
{
    ll n; cin>>n;
    ll a,b; cin>>a>>b;
    vi arr(n);
    for (ll i = 0; i < n; i++)
    {
        cin>>arr[i];
    }
    ll ans = 0;
    for (ll i = 1; i < n; i++)
    {
        ans += min(((arr[i] - arr[i-1])*a),b);
    }
    cout << ans;
}

int main()
{
    quickie;
    //txt;
    solve();
    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>

int main(){
	long W=0, H=0, N=0;
	long x=0, y=0, a=0;
	long size=0;

	scanf("%d%d%d", &W, &H, &N);
	int l=0, r=W, u=H, d=0;
	for (int i=0; i<N; i++){
		scanf("%d%d%d", &x, &y, &a);
		switch (a){
			case 1:
			if (l<x) l=x;
			break;
			case 2:
			if (r>x) r=x;
			break;
			case 4:
			if (u>y) u=y;
			break;
			case 3:
			if (d<y) d=y;
			break;
			default:
			break;
		}
	}
	size=(r-l)*(u-d);
	if (r<l || u<d) size=0;
	printf("%ld", size);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdint.h>
//#include <unordered_map>
#include <map>

using namespace std;

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

  //unordered_map<int32_t, unsigned> modA;
  map<int32_t, unsigned> modA;
  modA[0] = 1;

  int64_t sum = 0;
  for (int64_t n=0; n<N; ++n) {
    int64_t a;
    cin >> a;
    sum += a;
    int32_t key = sum%M;
    try {
      modA.at(key)++;
    } catch (...) {
      modA[key] = 1;
    }
  }

  int64_t count = 0;
  for (auto kv : modA) {
    unsigned value = kv.second;
    if (value > 1) {
      count += static_cast<int64_t>(value) * (value-1) / 2;
    }
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 3200
#include<cstdio>
#include<iostream>
#include<cstdlib>

using namespace std;
#define MAXN 5000000

int N,A,B,C,l[10]={},minn=MAXN,tmp;

void saiki(int n,int a,int b,int c,int count){
	if(n==0){
		if(a==0||b==0||c==0)return;
		tmp=abs(a-A)+abs(b-B)+abs(c-C)+(count-3)*10;
		minn=min(minn,tmp);
		return;
	}
	saiki(n-1,a,b,c,count);
	saiki(n-1,a+l[n-1],b,c,count+1);
	saiki(n-1,a,b+l[n-1],c,count+1);
	saiki(n-1,a,b,c+l[n-1],count+1);
}

int main(void) {


	cin>>N>>A>>B>>C;
	for (int i = 0; i < N; i++) {
		cin>>l[i];
	}

	saiki(N,0,0,0,0);

	cout<<minn<<"\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000



int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=1;i<=n;i++){
    scanf("%hu",&A[i]);
   
  }

  for(i=0;i<VMAX;i++){
    C[i]=0;
  }

  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n){
      printf(" ");
    }
  }

  printf("\n");

  free(A);
  free(B);
  
  

  


  return 0;
}




Measured memory_bytes: 9144
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
        if(v[i]>i+1){cout<<-1<<endl;return 0;}
    }
    vector<int> ans;
    for(int i=0;i<n;i++){
        int u=v[i];
        ans.insert(ans.begin()+u-1,u);


    }

    rep(i,ans.size()){
        cout<<ans[i]<<endl;
    }











    return 0;
}


Measured memory_bytes: 256
N = int(input())

if 100<=N<112: print(111)
elif 112<=N<223: print(222)
elif 223<=N<334: print(333)
elif 334<=N<445: print(444)
elif 444<=N<556: print(555)
elif 555<=N<667: print(666)
elif 667<=N<778: print(777)
elif 778<=N<889: print(888)
else: print(999)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

// #define int long long
using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
  for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
  os << "]";
  return os;
}

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

//const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

signed main(){
  int n;
  cin >> n;
  
  vector<int> pfc1(1000000,0);
  
  vector< map<int,int> > pf(n, map<int,int> {} );
  int a1 = 0;
  for(int i=0;i<n;i++){
    int aa;
    cin >> aa;
    pf[i] = prime_factor(aa);
    for (const auto& pp : pf[i]){
      if( pp.first != 1 && pfc1[pp.first]!=0 ){
        a1 = 1;
      }
      pfc1[pp.first] ++;
    }
  }
  if( a1 == 0 ){
    cout << "pairwise coprime" << endl;
    exit(0);
  }
  int a2 = 0;
  for(int i=2;i<=1000000;i++){
    if( pfc1[i]==n ){
      a2 = 1;  break;
    }
  }
  if( a2 ) {
    cout << "not coprime" << endl;
  } else {
    cout << "setwise coprime" << endl;
  }
  
  
  return 0;
}



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

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

int main()
{
    int n;
    ll ans = 0;

    cin >> n;

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

    for (int i = 1; i <= n - 1; i++)
    {
        ans += i;
    }

    cout << ans << endl;
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	ll l, r;
	cin >> l >> r;


	if(r-l >= 2019){
		puts("0");	
	} else {
		ll ans = 0x3f3f3f3f;
		for(int i=l;i<=r;i++)
			for(int j=i+1;j<=r;j++){
				ans=min(ans, (ll) i*j%2019);
			}
		cout<<ans;
	}

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

void solve(long long N, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    vll BA(N);
    rep(i, N){
        BA[i] = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    }

    vll BC(N);
    rep(i, N){
        BC[i] = C.end() - upper_bound(C.begin(), C.end(), B[i]);
    }

    ll ans = 0;
    rep(i, N){
        ans += BA[i]*BC[i];
    }
    cout << ans << endl;
}

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]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;
typedef long long int ll;


string S;
int ans;

vector<int> mem(27,0);
vector<string> ANS;

void solve(int n,string s){
    if (n == S.length()) {
        ans++;
        ANS.push_back(s);
        return;
    }
    if (s[n]=='z') {
        if (mem[25]>0) {
            solve(n+1, s);
        }
        return;
    }
    if (mem[(int)s[n]-(int)'a'+1]>0) {
        if (mem[(int)s[n]-(int)'a']==0) {
            return;
        }
        mem[(int)s[n]-(int)'a']++;
        solve(n+1, s);
        mem[(int)s[n]-(int)'a']--;
    }else{
        if (mem[(int)s[n]-(int)'a']>0) {
            string bef = s;
            int h = (int)S[n] + 1;
            char ss = (char)h;
            s[n]= ss;
            mem[(int)bef[n]-(int)'a']++;
            solve(n+1, bef);
            mem[(int)bef[n]-(int)'a']--;
            mem[(int)s[n]-(int)'a']++;
            solve(n+1, s);
            mem[(int)s[n]-(int)'a']--;
        }else{
            int h = (int)S[n] + 1;
            char ss = (char)h;
            s[n]= ss;
            mem[(int)s[n]-(int)'a']++;
            solve(n+1, s);
            mem[(int)s[n]-(int)'a']--;
        }
    }
}

int main(){
    for (;;){
        cin >> S;
        if(S== "#") break;
        for (int i=1; i<mem.size(); i++) {
            mem[i]=0;
        }
        ans = 0;
        ANS={};
        mem[0]=1;
        solve(0,S);
        if(ans==0) {
            cout << 0 << endl;
            continue;
        }
        if (ans > 10) {
            cout << ans << endl;
            for (int i=0; i<5; i++) {
                cout << ANS[i] <<endl;
            }
            for (int i=0; i<5; i++) {
                cout << ANS[ANS.size()+i-5]<<endl;
            }
        }else{
            cout << ans <<endl;
            for (int j=0; j<ANS.size(); j++) {
                cout << ANS[j]<<endl;
            }
        }
    }
}

Measured memory_bytes: 2352