akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<ll> sum(N + 1);
    rep(i, N) { cin >> A[i]; }
    rep(i, N) { sum[i + 1] = sum[i] + A[i]; }
    map<ll, ll> cnt;
    queue<ll> que;
    ll res = 0;
    for(int i = 0; i <= N; i++) {
        ll num = (sum[i] - i) % K;
        que.push(num);
        res += cnt[num];
        cnt[num]++;
        if(que.size() >= K) {
            cnt[que.front()]--;
            que.pop();
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 17536
import java.io.PrintWriter;
import java.util.*;

import static java.lang.Math.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in); 
		PrintWriter out=new PrintWriter(System.out);
		while(sc.hasNext()){
			int count=0;
			int input=sc.nextInt();
			for(int i=2;i<=input;i++){
				if(judge(i))count++;
			}
			System.out.println(count);
		}

	}
	static boolean judge(int temp){
		boolean judge=true;
		if(temp==2)return true;
		if(temp%2!=0){
			for(int i=3;i*i<=temp;i+=2){
				if(temp%i==0){
					judge=false;
					break;
				}
			}
		}else judge=false;
		return judge;
	}

}

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

#define STAT_MAX 100
#define LINE_MAX 3000

int main(){
	
	int n;
	int p,q,r;

	int i,j;
	bool flg;

	int statNum;
	int stat[STAT_MAX];
	
	int lineNum;
	int lineTo[LINE_MAX][2];
	int lineCost[LINE_MAX][2];

	while(1){
		//???????????±
		cin>>lineNum>>statNum;if(!lineNum && !statNum) break;
		for(i=0;i<lineNum;i++){
			cin>>lineTo[i][0]>>lineTo[i][1]>>lineCost[i][0]>>lineCost[i][1];
			lineTo[i][0]--;lineTo[i][1]--;
		}

		//???????????????
		cin>>n;
		while(n--){
			cin>>p>>q>>r;
			p--;q--;
			for(i=0;i<statNum;i++) stat[i]=1000*STAT_MAX;
			stat[p]=0;

			do{
				flg=false;
				for(i=0;i<lineNum;i++){
					for(j=0;j<2;j++){
						if(stat[lineTo[i][1-j]]+lineCost[i][r]<stat[lineTo[i][j]]){
							stat[lineTo[i][j]]=stat[lineTo[i][1-j]]+lineCost[i][r];
							flg=true;
						}
					}
				}
			}while(flg);

			cout<<stat[q]<<endl;
		}
	}

	return 0;
}

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

template <typename Monoid>

struct SegmentTree
{
    using F = function<Monoid(Monoid, Monoid)>;
    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
    {
        sz = 1;
        while (sz < n)
            sz *= 2;
        seg.assign(2 * sz, M1);
    }
    void set(int k, const Monoid &x)
    {
        seg[k + sz] = x;
    }
    void build()
    {
        for (int k = sz - 1; k > 0; k++)
        {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }
    void update(int k, const Monoid &x)
    {
        k += sz;
        seg[k] = x;
        while (k >>= 1)
        {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }
    Monoid query(int a, int b)
    {
        Monoid L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1)
        {
            if (a & 1)
                L = f(L, seg[a++]);
            if (b & 1)
                R = f(seg[--b], R);
        }
        return f(L, R);
    }
    Monoid operator[](const int &k) const
    {
        return seg[k + sz];
    }
};

int f(int a, int b)
{
    return min(a, b);
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    SegmentTree<int> seg(N, f, INT_MAX);
    rep(i, Q)
    {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 0)
            seg.update(x, y);
        else
            cout << seg.query(x, y + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    int MIN=0;
    int MAX=a[n-1];
    int MID=(MAX+MIN)/2;
    int tmp=0;
    while(MAX-MIN>1){
        MID=(MAX+MIN)/2;
        tmp=0;
        for(int i=0;i<n;i++)tmp+=((a[i]+MID-1)/MID-1);
        if(tmp>k)MIN=MID;
        else MAX=MID;
    }
    cout << MAX;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    ll d,t,s;
    cin >> d >> t >> s;
    if(d > t*s) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3644
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> W(N+1,0);
  for( int i=1; i<=N; i++ ) cin >> W.at(i);
  
  vector<int> S(N+1,0);
  for( int i=1; i<=N; i++ ) S.at(i) = S.at(i-1) + W.at(i);
  
  for( int i=1; i<=N; i++ ){
    if( S.at(i) >= S.at(N)/2 ){
      cout << min( abs( S.at(N) - S.at(i-1)*2 ), abs( S.at(N) -S.at(i)*2 ) );
      break;
    }
  }
  return 0;
}



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

ll x[500005],y[500005];
ll table[500005];
bool visited[500005];
ll n,i;
ll cnt;

vector <ll> G[500005];
vector <P> constraints;

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

void dfs(ll v){
	//cout << v << endl;
	if(visited[v])return;
	visited[v] = true;
	ll nv = G[v][0];
	cnt++;
	dfs(nv);
}

void swap_dfs(ll v,ll bring){
	if(bring == 0){
		ll tmp = table[v];
		table[v] = 0;
		ll nv = G[v][0];
		swap_dfs(nv, tmp);
	}else if(table[v] == 0){
		table[v] = bring;
		return;
	}else{
		ll tmp = table[v];
		table[v] = bring;
		ll nv = G[v][0];
		swap_dfs(nv, tmp);
	}
}

bool dfs_check(ll v,ll cnt){
	if(cnt < -3){
		return true;
	}
	if(table[v] == v){
		ll nv = G[v][0];
		dfs_check(nv, cnt - 1);
	}else{
		return false;
	}
}

int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> x[i];
	}
	for(int i=1;i<=n;i++){
		cin >> y[i];
	}
	for(int i=1;i<=n;i++){
		G[i].push_back(y[i]);
		table[x[i]] = i;
	}
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			cnt = 0;
			dfs(i);
			ll k = 0;
			while(table[i] != i){
				k++;
				swap_dfs(i,0);
				if(k > n + 2){
					cout << -1 << endl;
					return 0;
				}
			}
			bool ok = dfs_check(i, cnt);
			if(!ok){
				cout << -1 << endl;
				return 0;
			}
			//cout << "const = " << cnt << " " << k << endl;
			constraints.push_back(P(cnt, k));
		}
	}
	P cons1 = constraints[0];
	ll cntn = cons1.first;
	ll kn = cons1.second;
	ll m = constraints.size();
	for(int i=1;i<m;i++){
		P conslook = constraints[i];
		ll cnti = conslook.first;
		ll ki = conslook.second;
		bool ok = false;
		for(int j=0;j<cnti;j++){
			ll nv = j * cntn + kn;
			if(nv > 1000000000000000000ll){
				cout << -1 << endl;
				return 0;
			}
			if(nv % cnti == ki){
				ok = true;
				cntn = (cntn / mygcd(cntn, cnti));
				cntn *= cnti;
				kn = nv;
				break;
			}
			//cout << "cntc = " << cntn << endl;
			//cout << "kn = " << kn << endl;
		}
		if(!ok){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << kn << endl;

}


Measured memory_bytes: 14864
#include <stdio.h>

int main(){
    int N,i,b4t=0,dt;
    long T,t,ans;
    scanf("%d%ld",&N,&T);
    ans=T;
    for(i=0;i<N;i++){
    	scanf("%ld",&t);
    	dt=t-b4t;
    	if(dt<T)
    	ans+=dt;
    	else
    	ans+=T;
    	b4t=t;
    }
    printf("%ld",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,b;
  int a[200000];
  long long ans=0;
  int med,meda;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]=a[i]-(i+1);
  }
  sort(a,a+n);
  med=a[n/2];
  for(int i=0;i<n;i++){
    ans+=abs(a[i]-med);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    ll a,ans;
    double b;
    cin >> a >> b;
    ans = b*100+0.5; //これはdoubleからlong long への型変換（キャスト）をしている
                     //このとき小数点以下は切り捨てなので0.5を足しておかないと
                     //計算結果がおかしくなる.例えば0.999999など
    a *= ans;
    a /= 100;
    printf("%lld\n", a); // lld:long long int (aがlldだから)
    return 0;
}

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

int main(){
    int arr[100001];
    long long x;
    long long count = 0;
    cin >> x;
    for(int i = 1; i <= x; i++){
        cin >> arr[i];
    }
    for(int i = 1; i <= x; i+=2){
        if(arr[i] % 2 != 0) count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3580
def resolve():
    s = input()
    step_odd = 'RUD'
    step_even = 'LUD'
    ans = 'Yes'
    for i,j in enumerate(s):
        if i%2==0 and j not in step_odd:
            ans = 'No'
        elif i%2!=0 and j not in step_even:
            ans = 'No'
        else:
            pass
    print(ans)
resolve()

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 3e3 + 5;
int comb[MAX][MAX], memo[MAX][MAX];

inline int add(int a, int b, int mod) {
	a += b;
	if(a >= mod) {
		a -= mod;
	}
	return a;
}

inline int sub(int a, int b, int mod) {
	a -= b;
	if(0 > a) {
		a += mod;
	}
	return a;
}

inline int mult(int a, int b, int mod) {
	return (1LL * a * b) % mod;
}

inline int f_exp(int x, int exp, int mod) {
	if(exp == 0) {
		return 1;
	}
	else if(exp & 1) {
		return mult(x, f_exp(x, exp - 1, mod), mod);
	}
	return f_exp(mult(x, x, mod), exp / 2, mod);
}

inline int phi(int x) {
	return x - 1;
}

int S(int n, int k, const int &mod) {
	if(k > n) {
		return 0;
	}
	else if(n == 0 && k == 0) {
		return 1;
	}
	else if(k == 0) {
		return 0;
	}

	int &ans = memo[n][k];
	if(~ans) {
		return ans;
	}

	ans = add(mult(k, S(n - 1, k, mod), mod), S(n - 1, k - 1, mod), mod);
	return ans;
}

inline int kernel(int n, int k, int mod) {
	return add(mult(k + 1, S(n, k + 1, mod), mod), S(n, k, mod), mod);
}

int n;
int ways(int x, int mod) {
	int total = 1;
	fori(i, 1, x + 1) {
		int cur = mult(kernel(x, i, mod), f_exp(2, (n - x) * i, mod), mod);

		total = add(total, cur, mod);
	}

	total = mult(total, f_exp(2, f_exp(2, n - x, phi(mod)), mod), mod);

	return total;
}

int main() {
	memset(memo, -1, sizeof memo);

	int mod;
	scanf("%d %d", &n, &mod);

	fori(i, 0, MAX) {
		fori(j, 0, i + 1) {
			if(i == j || j == 0) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = add(comb[i - 1][j], comb[i - 1][j - 1], mod);
			}
			S(i, j, mod);
		}
	}

	int ans = 0;

	fori(i, 0, n + 1) {
		int cur = mult(comb[n][i], ways(i, mod), mod);

		if(i % 2 == 0) {
			ans = add(ans, cur, mod);
		}
		else {
			ans = sub(ans, cur, mod);
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 70912
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

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

	int imos[100005];
	memset(imos, 0, sizeof(imos));

	rep(i, n) {
		int a, b;
		cin >> a >> b;

		imos[a]++;
		imos[b+1]--;
	}

	REP(i, 1, 100005) {
		imos[i] += imos[i-1];
	}

	int ans = 0;
	rep(i, 100005) {
		if(imos[i+1] >= i) {
			ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1560
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
   int a,b;
   cin>>a>>b;
   if(a>b)
       cout<<"a > b"<<endl;
   else if(a<b)
       cout<<"a < b"<<endl;
   else
       cout<<"a == b"<<endl;
    return 0;
}



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

int main() {
  char S[222];
  scanf("%s", S);
  int n = strlen(S);
  for (int i = n-2;i > -1; i -=2) {
    if(strncmp(S, S+i/2, i/2)==0) {
      printf ("%d\n" ,i);
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  string S;
  cin >> S;

  ll cnt_S = 0;
  ll cnt_op = 0;
  REP(i, S.length()) {
    if (S[i] == 'S') {
      cnt_S++;
    } else {
      if (cnt_S > 0) {
        cnt_S--;
        cnt_op++;
      }
    }
  }
  cout << S.length() - cnt_op * 2;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
//const int mod= int(1e9)+7;
const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int dx=c-a;
   int dy=b-d;
   cout <<c+dy<<" "<<d+dx<<" "<<a+dy<<" "<<b+dx<<"\n";
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	cout<<(N-K+1)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	R[] rs;
	int[][] pin;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			sc.nextLine();
			rs=new R[n];
			pin=new int[n][22];
			for(int j=0; j<n; j++){
				Scanner s=new Scanner(sc.nextLine());
				rs[j]=new R();
				rs[j].id=s.nextInt();
				for(int i=0; s.hasNext(); i++){
					pin[j][i]=s.nextInt();
				}
			}
			solve();
		}
	}

	void solve(){
		for(int i=0; i<n; i++){
			rs[i].score=score(pin[i]);
		}
		Arrays.sort(rs);
		for(R r : rs){
			// println(r.id+" "+r.score);
			println(String.format("%d %d", r.id, r.score));
		}
	}

	int score(int[] pin){
		int[] score=new int[10];
		int res=0;
		for(int frame=0, i=0; frame<10; frame++){
			if(frame<9){
				if(pin[i]==10){
					score[frame]=10+pin[i+1]+pin[i+2];
					i++;
				}else if(pin[i]+pin[i+1]==10){
					score[frame]=10+pin[i+2];
					i+=2;
				}else{
					score[frame]=pin[i]+pin[i+1];
					i+=2;
				}
			}else{
				score[frame]=pin[i]+pin[i+1]+pin[i+2];
			}
			res+=score[frame];
		}
		// debug(score);
		return res;
	}

	class R implements Comparable<R>{
		int id, score;

		@Override
		public int compareTo(R r){
			if(r.score!=score){
				return r.score-score;
			}else{
				return id-r.id;
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <cstdio>
#include <vector>
using namespace std;
#define low(i) ((i)&(-(i)))

const int maxm=1e5+5;

int n,m,cnt;
vector<int>range[maxm];
vector<int>::iterator it;

int read() {
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return x*f;
}

struct TreeArray {
	int c[maxm];

	void change(int pos,int v) {
		for(int i=pos;i<=m;i+=low(i))
			c[i]+=v;
	}

	int query(int pos) {
		int res=0;
		for(int i=pos;i;i-=low(i))
			res+=c[i];
		return res;
	}
}T;

int main() {
	cnt=n=read(),m=read();
	for(int i=1;i<=n;i++) {
		int l=read(),r=read();
		range[r-l+1].push_back(l);
	}
	for(int i=1;i<=m;i++) {
		int ans=cnt;
		for(int pos=i;pos<=m;pos+=i)
			ans+=T.query(pos);
		for(it=range[i].begin();it!=range[i].end();it++)
			T.change(*it,1),T.change((*it)+i,-1),cnt--;
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 1000000000;

int main() {
  string str="01234567";
  map<string, int> m;
  do{
    m.insert(make_pair(str,INF));
  }while(next_permutation(begin(str),end(str)));
  m["01234567"] = 0;
  queue<string> q;
  q.push("01234567");
  while(!q.empty()) {
    string s = q.front();
    q.pop();
    int d[4] = {1,-1,4,-4};
    for(int i = 0; i < 8; ++i) {
      if (s[i] == '0') {
        for(int j = 0; j < 4; ++j) {
          int ni = i + d[j];
          if(ni < 0 || ni >= 8) continue;
          if(i == 3 && ni == 4 || i == 4 && ni == 3)continue;
          string ns = s;
          swap(ns[ni],ns[i]);
          if(m[ns] > m[s] + 1) {
            m[ns] = m[s] + 1;
            q.push(ns);
          }
        }
      }
    }
  }
  while(true){
    int ary[8];
    if(scanf("%d",&ary[0]) == EOF) break;
    string s="";
    s+=ary[0]+'0';
    for(int i=1;i<8;++i){
      scanf("%d",&ary[i]);
      s+=ary[i]+'0';
    }
    printf("%d\n",m[s]);
  }
  return 0;
}

Measured memory_bytes: 5780
def print_line(W,even_char,odd_char):
    for j in range(W):
        if j%2==0:
            print(even_char,end="")
        else:
            print(odd_char,end="")
    print("")

while True:
    H,W = [int(x) for x in input().split()]
    if (H,W)==(0,0): break
    for i in range(H):
        if i%2==0:
            print_line(W,"#",".")
        else:
            print_line(W,".","#")
    print("")

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    char w;
    for(;;){
        scanf("%c",&w);
        if(w=='\n'){
            break;
        }else if(isupper(w)){
            w=tolower(w);
            printf("%c",w);
        }else if(islower(w)){
            w=toupper(w);
            printf("%c",w);
        }else{
            printf("%c",w);
        }
    }
    printf("\n");
    return 0;
}

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

#define N 5055
const int MOD = 1e9 + 7;

int n, m;
int a[N];
vector <int> E[N];

void add(int x, int y) {
	E[x].push_back(y);
	E[y].push_back(x);
}

int L, R;
bool vis[N];
int col[N];
bool flag;
void dfs(int x) {
	vis[x] = 1;
	if (!col[x]) col[x] = 2;
	if (col[x] == 2) L++; else R++;
	for (auto &v : E[x]) {
		if (!vis[v]) col[v] = col[x] ^ 1, dfs(v);
		else if (col[v] != (col[x] ^ 1)) {
			flag = 0;
			return;
		}
	}
}

vector < pair<int, int> > b;

long long dp[N];

int main() {
	scanf("%d%d", &n, &m);
	//while (clock() < n * 0.001 * CLOCKS_PER_SEC);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	flag = 1;
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			if (a[j] > a[i]) add(i, j);
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			L = R = 0;
			dfs(i);
			if (!flag) break;
			b.push_back({L, R});
		}
	}
	if (!flag) return puts("0"), 0;
	int sum = 0;
	dp[0] = 1;
	for (auto v : b) {
		sum += max(v.first, v.second);
		for (int j = sum; j >= 0; j--) {
			if (v.first == 0 || v.second == 0) {
				if (v.first > 0 && j >= v.first) (dp[j] += dp[j - v.first]) %= MOD;
				if (v.second > 0 && j >= v.second) (dp[j] += dp[j - v.second]) %= MOD;
			}
			else {
				dp[j] = 0;
				if (j >= v.first) (dp[j] += dp[j - v.first]) %= MOD;
				if (j >= v.second) (dp[j] += dp[j - v.second]) %= MOD;
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		int j = max(i, n - i);
		if (j <= m) (ans += dp[i]) %= MOD;
	}
	printf("%d\n", int(ans % MOD));
}



Measured memory_bytes: 6324
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

vector<long long> DIVISOR(long long N) {
    vector<long long> v;
    for (long long i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            v.push_back(i);
            if (i != N / i)v.push_back(N / i);
        }
    }
    sort(v.begin(), v.end());
    return v;
}

int main() {

    long long N, M;
    cin >> N >> M;

    long long ans = 1;
    auto D = DIVISOR(M);
    for (int i = 0; i < D.size(); i++) {
        if (D[i] * N <= M) ans = D[i];
    }
    cout << ans << endl;

    return 0;
}











































































Measured memory_bytes: 256
import bisect
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
for b in B:
    ok_a = bisect.bisect_left(A,b)
    ok_c = bisect.bisect_right(C,b)
    if ok_a!=0 and ok_c!=N:
        ans += ok_a*(N-ok_c)
print(ans)


Measured memory_bytes: 22468
#include <stdio.h>
#include <string.h>
int main(){
	char words1[15];
	char words2[15];
	scanf("%s %s",&words1,&words2);
	getchar();
	
	int num1,num2;
	scanf("%d %d",&num1,&num2);
	getchar();
	
	char words3[15];
	scanf("%s",words3);
	getchar();
	
	if(strcmp(words3,words1)==0)
	printf("%d %d",num1-1,num2);
	if(strcmp(words3,words2)==0)
	printf("%d %d",num1,num2-1);
	
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int h, w;
  cin >> h >> w;
  int a[90][90] = {};
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w)
  {
    int b;
    cin >> b;
    a[i][j] = abs(a[i][j] - b);
  }

  bool can[90][90][80 * 200] = {};
  can[0][0][a[0][0]] = true;
  rep(i, h) rep(j, w)
  {
    rep(k, 80 * 170)
    {
      if (can[i][j][k])
      {
        can[i + 1][j][k + a[i + 1][j]] = true;
        can[i + 1][j][abs(k - a[i + 1][j])] = true;
        can[i][j + 1][k + a[i][j + 1]] = true;
        can[i][j + 1][abs(k - a[i][j + 1])] = true;
      }
    }
  }/*
  rep(i, h) rep(j, w)
  {
    cerr << i << " " << j << ":";
    rep(k, 10)
    {
      if (can[i][j][k])
        cerr << k << ",";
    }
    cerr << endl;
  }*/

  rep(k, 80 * 200)
  {
    if (can[h - 1][w - 1][k])
    {
      cout << k << endl;
      return 0;
    }
  }
  assert(false);
  return 0;
}


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

using namespace std;

char s[5];

int main()
{
    int i, n, a=0, r=0, t=0, w=0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> s;
        if(s[0]=='A'){
            a++;
        }
        if(s[0]=='W'){
            w++;
        }
        if(s[0]=='R'){
            r++;
        }
        if(s[0]=='T'){
            t++;
        }
    }
    cout << "AC x " << a << "\nWA x " << w << "\nTLE x " << t << "\nRE x " << r << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
ll C[32];
ll S[366][32];
ll T[366];
ll P[32];
ll L[32];
set<int> H[32];

ll calcSum(int D) {
  ll ret = 0;
  for (int i=1; i<=D; i++) {
    ret += S[i][T[i]];
  }
  return ret;
}
ll calcPenalty(int con, int D) {
  ll ret = 0;
  ll prev = 0;
  for (auto& it: H[con]) {
    ll dif = it - prev;
    ret += (dif - 1) * dif / 2;
    prev = it;
  }
  ll dif = D + 1 - prev;
  ret += (dif - 1) * dif / 2;
  ret *= C[con];
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  for (int i=1; i<=26; i++) {
    cin >> C[i];
  }
  for (int i=1; i<=D; i++) {
    for (int j=1; j<=26; j++) {
      cin >> S[i][j];
    }
  }
  // decide initial result
  for (int day=1; day<=D; day++) {
    ll ocon = 1;
    ll oval = S[day][ocon] - (day - L[ocon]) * C[ocon];
    for (int con=2; con<=26; con++) {
      ll val = S[day][con] - (day - L[con]) * C[con];
      if (val > oval) {
        ocon = con;
        oval = val;
      }
    }
    T[day] = ocon;
    L[ocon] = day;
    H[ocon].insert(day);
  }
  for (int day=1; day<=D; day++) {
    cout << T[day] << '\n';
  }

  /*
  for (int i=1; i<=D; i++) {
    cin >> T[i];
  }
  ll ret = calcSum(D);
  for (int i=1; i<=26; i++) {
    P[i] = calcPenalty(i, D);
    ret -= P[i];
  }
  int M;
  cin >> M;
  for (int query=0; query<M; query++) {
    int day, ncon;
    cin >> day >> ncon;
    int pcon = T[day];
    ll pen = -P[pcon] - P[ncon];
    H[pcon].erase(day);
    H[ncon].insert(day);
    T[day] = ncon;
    P[pcon] = calcPenalty(pcon, D);
    P[ncon] = calcPenalty(ncon, D);
    pen += P[pcon] + P[ncon];
    ret -= pen;
    ret -= S[day][pcon];
    ret += S[day][ncon];
    cout << ret << endl;
  }
  */
}

Measured memory_bytes: 3756
N,A,B = map(int,input().split(" "))

if A > B:
    print(0)
    exit(0)
if N == 1:
    if A ==  B:
        print(1)
    else:
        print(0)
    exit(0)
if N == 2:
    print(1)
    exit(0)

print((N-2)*(B-A)+1)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};


int main()
{
    ll x;
    cin >> x;

    ll s = x / 11;
    ll a = x % 11;
    ll ans = s * 2;
    if(a!=0){
        if(a<=6){
            ans += 1;
        }else{
            ans += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using pci = pair<char, int>;
using vpci = vector<pci>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(int i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) { ll prime; double sqrtmax = sqrt(max); vector<ll> primeVec, searchVec; FOR(i, 2, max + 1) searchVec.push_back(i); do { prime = searchVec[0]; primeVec.push_back(prime); auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; }); searchVec.erase(itr, searchVec.end()); } while (prime < sqrtmax); primeVec.reserve(primeVec.size() + searchVec.size()); primeVec.insert(primeVec.end(), beginend(searchVec)); return primeVec; }
bool isPrime(ll x) { if (x == 2) return true; if (x < 2 || x % 2 == 0) return false; ll i = 3; while (i <= sqrt(x)) { if (x%i == 0) return false; i += 2; }return true; }


vi dp, odddp;
int main() {
	int N;
	int p = 4;
	REP(i, 1000001) {
		dp.pb(i);
		odddp.pb(i);
	}
	int n = 3;
	while (p<=1000000)
	{
		for (int i = 0; i+p <=1000000; i++)
		{
			dp[i + p] = min(dp[i + p], dp[i] + 1);
		}
		if (p % 2 == 1) {
			for (int i = 0; i + p <= 1000000; i++)
			{
				odddp[i + p] = min(odddp[i + p], odddp[i] + 1);
			}
		}

		p = n*(n + 1)*(n + 2) / 6;
		n++;
	}

	

	while (cin>>N,N)
	{
		cout << dp[N] << " " << odddp[N] << endl;
	}

	return 0;
}

Measured memory_bytes: 10704
#include<stdio.h>
int main(void){
	int a, b, i, j, k, arr[100][100], m[100], sum = 0;
	
	scanf("%d %d\n", &a, &b);
	for(i = 0; i < a; i++){
		for(j = 0; j < b; j++){
			if(j == b-1){
				scanf("%d\n", &arr[i][j]);
				break;
			}
			scanf("%d", &arr[i][j]);
		}
	}
	for(j = 0; j < b; j++){
		scanf("%d\n", &m[j]);
	}
	for(i = 0; i < a; i++){
		for(j = 0; j < b; j++){
			sum += arr[i][j] * m[j];
		}
		printf("%d\n", sum);
		sum = 0;
	}
	
	return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    vector<ll> n(4);
    rep(i, 4) {
        char c; cin >> c;
        n[i] = c - '0';
    }

    // for (auto elem : n) cout << elem << " "; cout << endl;

    for (int i = 0; i < 8; i++)
    {
        ll num = n[0];
        rep(j, 3) {
            num += (((i>>j) & 1) ? n[j+1] : -n[j+1]);
        }
        if (num == 7) {
            cout << n[0];
            rep(j, 3) {
                cout << ((i>>j & 1) ? '+' : '-') << n[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio> 
#include<cstring>
#include<cmath>
#include<map>
#include<queue> 
#include<vector>
using namespace std;
vector<int> a[110000];
int n,f[110000],d[110000],p,i,tt,o,ff[110000][30],b[110000],pp,tot; 
long long ans;
void dfs(int x) {
	int p = a[x].size();
	for (int i = 0; i < p; i++) {
		d[a[x][i]] = d[x] + 1;
		ff[a[x][i]][0] = x;
		dfs(a[x][i]);
	}
}
void init()
{
  int i,j;
  //p[i][j]表示i?点的第2^j祖先
  for(j=1;(1<<j)<=n;j++)
    for(i=1;i<=n;i++)
      if(ff[i][j-1]!=-1)
        ff[i][j]=ff[ff[i][j-1]][j-1];//i的第2^j祖先就是i的第2^(j-1)祖先的第2^(j-1)祖先
}
int lca(int a,int b)//最近公共祖先
{
  int i,j;
  if(d[a]<d[b])swap(a,b);
  for(i=0;(1<<i)<=d[a];i++);
  i--;
  //使a，b?点的深度相同
  for(j=i;j>=0;j--)
    if(d[a]-(1<<j)>=d[b])
      a=ff[a][j];
  if(a==b)return a;
  //倍?法，?次向上?深度2^j，找到最近公共祖先的子?点
  for(j=i;j>=0;j--)
  {
    if(ff[a][j]!=-1&&ff[a][j]!=ff[b][j])
    {
      a=ff[a][j];
      b=ff[b][j];
    }
  }
  return ff[a][0];
}
int main() {
	scanf("%d", &n);
	for (i = 2; i <= n; i++) {
		scanf("%d", &f[i]);
		a[f[i]].push_back(i);
	}
	for (i = 1; i <= n; i++) sort(a[i].begin(), a[i].end());
	//for (i = 0; i < a[2].size(); i++) cout<<a[2][i]<<" ";cout<<endl;
	d[1] = 0;
	dfs(1);
	queue<int> q;
	while (!q.empty()) q.pop();
	q.push(1); 
	while (!q.empty()) {
		int p = q.front();  q.pop();
		b[++pp] = p;
		int pp = a[p].size();
		for (int i = 0; i < pp; i++) {
			q.push(a[p][i]); 
		}
	}
	init(); ff[1][0] = -1;
	ans = 0;
	//for (i = 1; i <= pp; i++) cout<<b[i]<<" "; cout<<endl;
	for (i = 1; i < pp; i++) {
		p = lca(b[i], b[i + 1]);
		tot = (d[b[i]] - d[p]) + (d[b[i + 1]] - d[p]);
		ans = ans + tot;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 26420
#include <stdio.h>
#include <math.h>

int main(void){
	int a,b,n,i,j,p,num,sum,cnt=0;

	scanf("%d %d %d",&n,&a,&b);

	for(i=1;i<=n;i++){
		num=i;
		sum=0;
		for(j=4;j>=0;j--){
			p=(int)pow(10.0,(double)j);
			if(num>=p){
				sum+=num/p;
				num=(num%p);
			}
		}
		if(a<=sum && sum<=b){
			cnt+=i;
		}
	}

	printf("%d",cnt);

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    int N,X,Y;
    cin>>N>>X>>Y;
    vector<int> cnt(N,0);
    for (int i = 1; i <=N-1; ++i) {
        for (int j = i+1; j <= N; ++j) {
            if(j<=X||i>=Y) cnt[j-i]++;
            else if(i<=X){
                if(j>X&&j<Y) cnt[X-i+min(j-X,Y-j+1)]++;
                else if(j>=Y) cnt[X-i+j-Y+1]++;
            }else if(i>X){
                if(j<Y) cnt[min(j-i,i-X+Y-j+1)]++;
                else if(j>=Y) cnt[j-Y+min(Y-i,i-X+1)]++;
            }
        }
    }
    for (int i = 1; i < N; ++i) {
        cout<<cnt[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// use gp_hash_table<int,int,custom_hash> m;
// in place of map
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
// This custom_hash is for unordered_map 
// use map<int, int, custom_hash> mp;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);

	// #endif
	int x;
	cin>>x;
	while(1){
		int flag=0;
		for(int i=2;i*i<=x;i++){
			if(x%i == 0){
				flag=1;break;
			}
		}
		if(flag){
			x++;
			continue;
		}
		else{
			break;
		}
	}
	cout<<x;
	return 0;
}

Measured memory_bytes: 256
#096b
A,B,C = map(int, input().split())
K = int(input())

if max(A,B,C) == A:
    A = A*(2**K)
elif max(A,B,C) == B:
    B = B*(2**K)
elif max(A,B,C) == C:
    C = C*(2**K)
    
print(sum([A,B,C]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<pll> A(N+1,{0,-1});
  for(int i=0;i<N;i++){
    cin>>A[i].F;
    A[i].S=i;
  }
  sort(A.begin(),A.end(),greater<pll>());
  //cout<<A<<endl;
  vector<ll> ans(N,0);
  ll mi=N-1,k=A[0].F,sum=0;
  for(ll i=0;i<=N;i++){
    //cout<<i<<" "<<A[i]<<" "<<mi<<" "<<k<<endl;
    sum+=i*(k-A[i].F);
    k=A[i].F;
    if(mi>A[i].S){
      ans[mi]+=sum;
      sum=0;
      k=A[i].F;
      mi=A[i].S;
    }
    //cout<<ans<<endl;
  }
  for(auto &I:ans){cout<<I<<endl;}

  return 0;
}


Measured memory_bytes: 3456
#include <iostream>

int getSumEachDigit(int number);

int main(int argc, char const *argv[]) {
        int N;
        std::cin >> N;

        int sumEachDigit = getSumEachDigit(N);
        if( N % sumEachDigit == 0)
                std::cout << "Yes" << '\n';
        else
                std::cout << "No" << '\n';

        return 0;
}

int getSumEachDigit(int number)
{
        int origin_number = number;
        int sum = 0;
        while(origin_number > 0)
        {
                int tailNum = origin_number % 10;
                sum += tailNum;
                origin_number /= 10;
        }
        return sum;
}


Measured memory_bytes: 256
//看题解了，部分和那里，背下来，重做 
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
 
const int NN = 110;
char str1[NN];
int n;
unsigned long long a, b, c, d, e, ans;
int main(){
	scanf("%d", &n);
	while(n--){
		scanf("%s", str1);
		if (str1[0] == 'M') a++;
		if (str1[0] == 'A') b++;
		if (str1[0] == 'R') c++;
		if (str1[0] == 'C') d++;
		if (str1[0] == 'H') e++;
	}
	ans = a*b*c + a*b*d + a*b*e + a*c*d + a*c*e + a*d*e + b*c*d + b*c*e + b*d*e + c*d*e;
	printf("%llu", ans);

	return 0;
}
 

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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001
using namespace std;
typedef long long ll;

int n,m;
int k,a;
int food[50];

int main(int argc, char const *argv[]) {
  std::cin >> n >> m;
  rep(i,0,n){
    std::cin >> k;
    rep(j,0,k){
      std::cin >> a;
      food[a]++;
    }
  }
  int res = 0;
  rep(i,0,50){
    if(food[i] == n)res++;
  }
  std::cout << res << '\n';
  return 0;
}


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     ll a,v,b,w,t;
     cin >> a >> v >> b >> w >> t;
     if(a<b){
        if(a+v*t>=b+w*t)cout << "YES";
        else cout << "NO";
     }
     else{
        if(a - v*t <= b - w*t)cout << "YES";
        else cout << "NO";
     }

  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3804
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main() {
    double x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double d = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    cout << fixed << d << endl;
    return 0;
}

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

int main() {
  long long N;
  cin >> N;
  
  long long minv = 10000000000000010;
  for (int i = 0; i < 5; i++) {
    long long num;
    cin >> num;
    minv = min(minv, num);
  }

  long long ans = (N + minv - 1) / minv + 4;

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int l=0;
        int r=Integer.MAX_VALUE;
        for(int i=0;i<m;i++){
            l=Math.max(l,sc.nextInt());
            r=Math.min(r,sc.nextInt());
        }
        System.out.println(((r-l)<0)?0:r+1-l);
    }
}


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	cin >> n;
	vector <ll> inp (n);
	trav (a, inp) cin >> a;
	ll ans = 0;
	for (i = 0; i < n; ++i)
		for (j = i + 1; j < n; ++j)
			for (int k = j + 1; k < n; ++k)
				if (inp[i] != inp[j] && inp[i] != inp[k] && inp[j] != inp[k])
				{
					vector <ll> aux = {inp[i], inp[j], inp[k]};
					sort (aux.begin (), aux.end ());
					if (aux[0] + aux[1] > aux[2])
						++ans;
				}
	cout << ans << '\n';

	return 0;
}



Measured memory_bytes: 3652
require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){j=i.split(' ');if(j[1])a=j[0],b=j[1],c=j[2],d=j[3],e=j[4],f=j[5],g=a*a,h=b*b,k=c*c,l=d*d,m=e*e,n=f*f,o=a-c,r=b-d,s=b-f,t=a-e,p=(s*(h-l+g-k)-r*(h-n+g-m))/(2*s*o-2*r*t),q=(t*(g-k+h-l)-o*(g-m+h-n))/(2*t*r-2*o*s),console.log(p.toFixed(3),q.toFixed(3),Math.sqrt((a-p)*(a-p)+(b-q)*(b-q)).toFixed(3))})

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a ,b; cin >> a >> b;
  cout << 6 - a - b << endl;
  return 0;
}


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

int main() {
  long long H,W;
  cin >> H >> W;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }
  else if((H*W)%2 == 0){
    cout << (H*W)/2 << endl;
    return 0;
  }
  else{
    cout << (H*W)/2+1 << endl;
  }
}


Measured memory_bytes: 3592