akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n , m ;
	cin>> n >> m ;
	vector<pair<ll,ll>> vec;

	for(ll i=0 , a , b ;i< m ;i++){
		cin>>a>> b ;
		vec.pb({a,b});
	}
	ll l=0 , r=10000000000;
	for(ll i=0;i< m ;i++){
		l=max(l , vec[i].f);
		r=min(r,vec[i].s);
	}
	ll cnt=0;
	for(ll i=l;i<=r;i++){
		if(i<=n)cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 2420
n = int(input())
A = []

for i in range(n):
    A.append(int(input()))

if len(set(A)) == 1:
    for i in range(n):
        print(A[0])
else:
    A_ = sorted(A)
    max_1 = A_[-1]
    max_2 = A_[-2]
    for i in A:
        if i == max_1:
            print(max_2)
        else:
            print(max_1)
    

Measured memory_bytes: 70104
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int f[15][10][10],k,out[15],sum[15],pre[15][11];
signed main(){
	k=read();
	for(int i=0;i<=9;i++){
		f[1][i][i]=1;
		pre[1][i]=1;
	}
	sum[1]=9;
	for(int i=2;i<=11;i++){
		for(int j=0;j<=9;j++){
			for(int k=0;k<=9;k++){
				if(k>0)
				f[i][j][k]+=f[i-1][j][k-1];
				if(k<9)
				f[i][j][k]+=f[i-1][j][k+1];
				f[i][j][k]+=f[i-1][j][k];
				pre[i][j]+=f[i][j][k];
			}
			if(j!=0)
			sum[i]+=pre[i][j];
		}
		sum[i]+=sum[i-1];
		//printf("%d %d\n",sum[i],i);
	}
	for(int i=11;i>=1;i--){
		if(sum[i-1]>=k){
			continue;
		}
		k=k-sum[i-1];
		int alfa=0;
		for(int j=1;j<=9;j++){
			alfa+=pre[i][j];
			if(alfa>=k){
				alfa=alfa-pre[i][j];
				k=k-alfa;
				//printf("%d\n",k);
				out[i]=j;
				int len=i-1;
				while(len){
					alfa=0;
					//printf("%d %d\n",max(out[len+1]-1,0),min(out[len+1]+1,9));
					for(int v=max(out[len+1]-1,0);v<=min(out[len+1]+1,9);v++){
						alfa+=pre[len][v];
						if(k<=alfa){
							alfa-=pre[len][v];
							out[len]=v;
							k-=alfa;
							break;
						}
					}
					//printf("%d %d\n",k,alfa);
					len--;
				}
				break;
			}
		}
		break;
	}
	int flag=1;
	for(int i=10;i>=1;i--){
		if(flag&&(!out[i]))continue;
		flag=0;
		printf("%d",out[i]);
	}
	puts("");
	return 0;
}


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

mod = 10**9 + 7

a.sort(reverse = True)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """

    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(100010)
ans = 0

for i in range(n-k+1):
    ans += a[i] * comb(n-i-1, k-1)
    ans %= mod

a = a[::-1]

for i in range(n-k+1):
    ans -= a[i] * comb(n-i-1, k-1)
    ans %= mod

print(ans)


Measured memory_bytes: 71848
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (auto& v : s)
	{
		cin >> v;
	}
	REP(i, h)
	{
		REP(j, w)
		{
			if (s[i][j] == '#')
				continue;

			int hs = max(0, (int)i - 1);
			int he = min(h-1, (int)i + 1);
			int js = max(0, (int)j - 1);
			int je = min(w - 1, (int)j + 1);

			int cnt = 0;
			for (int y = hs; y <= he; ++y)
			{
				for (int x = js; x <= je; ++x)
				{
					if (s[y][x] == '#')
						cnt++;
				}
			}
			s[i][j] = '0' + cnt;
		}
	}

	REP(i, h)
		print(s[i]);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>

using namespace std;

int a[1000010];
int f[1000010];

int main(void)
{
    //freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	f[1] = 0;
	f[2] = abs(a[1]-a[2]);
	for(int i=3;i<=n;i++)
	{
		f[i] = min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
		//cout << f[i] << endl;
	}
	cout  << f[n] << endl;
	return 0;
}












Measured memory_bytes: 4736
#include <stdio.h>

int main(void)
{
    int b1, b2, b3;

    scanf("%d %d %d", &b1, &b2, &b3);
    if (b1 == b2 && b1 != b3){
        printf("Open\n");
    }
    else {
        printf("Close\n");
    }

    return (0);
}

Measured memory_bytes: 584
builds = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    builds[b-1][f-1][r-1] += v

for i, building in enumerate(builds):
    for floor in building:
        for room in floor:
            print(" {}".format(room), end="")
        print()
    if i != 3:
        print("#"*20)


Measured memory_bytes: 5624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define x first
#define y second

namespace ZheDaoTiWoJianGuo
{
	inline void check_min(int a,int &b){if(a<b)b=a;}
	inline void check_max(int a,int &b){if(a>b)b=a;}

	typedef std::pair<int,int> pii;
	inline bool cmpx(pii A,pii B){return A.x<B.x;}
	inline bool cmpy(pii A,pii B){return A.y<B.y;}

	const int N=200010,MOD=1000000007;
	inline void inc(int a,int &b){b=(a+b)%MOD;}

	pii s[N];
	int L[N],R[N];
	int n;

	void initialize()
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
			scanf("%d%d",&s[i].x,&s[i].y);

		std::sort(s+1,s+n+1,cmpy);
		for(int i=1;i<=n;i++)s[i].y=i;
		std::sort(s+1,s+n+1,cmpx);
		for(int i=1;i<=n;i++)s[i].x=i;

		int w=0;
		for(int i=1;i<=n;i++)
			check_max(s[i].y,w),R[i]=w;
		w=233333;
		for(int i=n;i;i--)
			check_min(s[i].y,w),L[i]=w;
	}

	int f[N];
	void solve()
	{
		initialize();
		int right=0;
		f[0]=1;
		for(int i=1,w;i<=n;i++)
		{
			for(;right<R[i];right++)
				inc(f[right],f[right+1]);

			w=(f[R[i]]-(L[i]>1?f[L[i]-2]:0))%MOD;
			inc(w,f[R[i]]);
		}
		int ans=((f[n]-f[n-1])%MOD+MOD)%MOD;
		printf("%d\n",ans);
	}
}

int main()
{
	ZheDaoTiWoJianGuo::solve();
	return 0;
}


Measured memory_bytes: 4096
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
       
        while(true){
        	int n = scan.nextInt();
        	if(n==0)break;
        	while(n!=0){
        	boolean flag=true;
        	double [] p=new double [3];
        	int sum=0;
        	for(int i=0;i<3;i++){
        		p[i]=scan.nextInt();
        		if(p[i]==100){
        			System.out.println("A");
        			flag=false;
        			scan.nextLine();
        			break;
        		}
        		sum+=p[i];
        	}
        	double av =sum/3.0;
        	if(flag){
        		
        		if((p[0]+p[1])/2.0 >= 90){
        			System.out.println("A");
        		}
        		
        		else if(av >= 80){
        			System.out.println("A");
        		}
        		
        		else if(av >= 70){
        			System.out.println("B");
        		}
        		
        		else if(av >= 50 && (p[0]>=80 || p[1] >= 80)){
        			System.out.println("B");
        		}
        		else {
        			System.out.println("C");
        		}
        	}
        	n--;
        	}
        }
    }
}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split();
        Console.WriteLine(int.Parse(input[2])+" "+int.Parse(input[0])+" "+int.Parse(input[1]));
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <map>
using namespace std;

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

    map<char, int> m;
    for (char c : s) m[c]++;

    string out = "Yes";
    if (m.size() != 2) out = "No";
    else if (m.begin()->second != 2) out = "No";

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
  double w,h,x,y;
  int i;
  scanf("%lf %lf %lf %lf", &w,&h,&x,&y);
  int res;
  if(x+x == w && y+y == h)res = 1;
  else res = 0;
  printf("%f %d\n", (w*h)/2.0, res);



  return 0;
}


Measured memory_bytes: 128
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *L = map(int, read().split())

L.sort()
ans = 0

for i in range(1,N-1):
    upper = N-1
    for j in reversed(range(0,i)):
        sum = L[i] + L[j]

        if upper == N :
            upper = N-1

        while upper > i and sum <= L[upper]:
            upper -= 1
        ans += upper-i

print(ans)




Measured memory_bytes: 42988
def main():
    import sys
    input=sys.stdin.readline
    n=int(input())
    ans=[0]*n
    A=list(map(int,input().split()))
    for i in range(n-1):
        a=A[i]
        ans[a-1]+=1
    for i in range(n):
        print(ans[i])
if __name__ == '__main__':
    main()

Measured memory_bytes: 92944
def spaceinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=spaceinput()


sa=sorted(a,reverse=True)
x=[]
i=0
while True:
    if i>=len(sa)-1:
        break
    ssa=sa[i]
    if sa[i]==sa[i+1]:
        x.append(ssa)
        i+=2
        if len(x)==2:
            break
        continue

    else:
        i+=1


x.extend([0,0])

print(x[0]*x[1])

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

#define M 1046527
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 2;
  else if (ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch =='T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for(i=0; i<strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for(i=0;; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {

  int i, n, h;

  char str[L], com[9];
  for(i=0; i<M; i++) H[i][0] = '\0';
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s %s", com, str);
    if(com[0] == 'i'){
      insert(str);
    }
    else {
      if(find(str)){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  } 
  return 0;
}

  



Measured memory_bytes: 16108
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
lli maxi=1e15;
vl tem[1001];
lli cost[1001],all,n,m;
lli dp[100001][1001];
lli rec(lli rom,lli j){
	//string binary = bitset<8>(rom).to_string();
	//cout<<binary<<endl;
	if(j==m){
		if(rom==all)return 0;
		else return maxi;
	}
	if(dp[rom][j]!=-1)return dp[rom][j];
	lli trom=rom;
	for(lli i=0;i<tem[j].size();i++){
		trom=trom|(1<<(tem[j][i]-1));
	}
	return dp[rom][j]=min(rec(rom,j+1),cost[j]+rec(trom,j+1));
}

int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    for(lli i=0;i<100001;i++)for(lli j=0;j<1001;j++)dp[i][j]=-1;
    //lli n;
    cin>>n>>m;
    for(lli i=0;i<m;i++){
    	lli c;
    	cin>>cost[i]>>c;
    	while(c--){
    		lli x;
    		cin>>x;
    		tem[i].pb(x);
    	}
    }
    all=pow(2,n)-1;
    lli ani=rec(0,0);
    if(ani>=maxi)cout<<-1;
    else cout<<ani;
















 	return 0;
 }

Measured memory_bytes: 782464
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
int n, a[maxn];
ll res;
map<int,int> cnt;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for (int i = 0;i < n;++i)
		cin >> a[i];
	for (int i = 0;i < n;++i) {
		res += cnt[ a[i] - i ];
		++cnt[ -i-a[i] ];
	}
	cout << res << '\n';
}



Measured memory_bytes: 21324
from collections import deque
n, m = map(int, input().split())
route = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    route[a].append(b)
    route[b].append(a)
dist = [0]*(n+1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)
ans = [0 for _ in range(n+1)]
while d:
    v = d.popleft()
    for i in route[v]:
        if dist[i] != 0:
            continue
        dist[i] = dist[v]+1
        ans[i] = v
        d.append(i)

if len(dist[2:]) > 0:
    print('Yes')
    print(*ans[2:], sep="\n")
else:
    print('No')


Measured memory_bytes: 36620
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
// sum(x) x以下の和
// sum(a,b) a以上b以下の和
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {  //x=1ならsumは個数のカウント
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int i,int j) {
    if(i>0) return sum(j)-sum(i-1);
    else return sum(j) ; } 
};

 int main(){
  ll n ; cin>> n ;
  ll a[3][n] ;
  rep(i,3){
    rep(j,n)  cin>>a[i][j] ;
  }
  bool ok=1 ;
  ll check[n] ; rep(i,n) check[i]=0 ;
  ll xy[n] ; rep(i,n) xy[i]=0 ;
  ll posi[n] ;
  rep(i,n){
    if(i%2==0){
      if(a[0][i]%6==1 && a[2][i]==a[1][i]+1 && a[1][i]==a[0][i]+1){
      xy[i]= 0 ;
      posi[i]= ((abs(a[0][i]-(1)))/3) ;
      check[i]++ ;
      }
      else if(a[0][i]%6==3 && a[0][i]==a[1][i]+1 && a[1][i]==a[2][i]+1){ 
      xy[i]=1 ;
      posi[i]=((abs(a[0][i]-(3)))/3) ;
      check[i]++ ;
      }
      else ok = 0;
    } 
    else{
      if(a[0][i]%6==4 && a[2][i]==a[1][i]+1 && a[1][i]==a[0][i]+1){
      xy[i]= 0 ;
      posi[i]=((abs(a[0][i]-(1)))/3) ;
      check[i]++ ;
      }
      else if(a[0][i]%6==0 && a[0][i]==a[1][i]+1 && a[1][i]==a[2][i]+1){ 
      xy[i]=1 ;
      posi[i] = ((abs(a[0][i]-(3)))/3) ;
      check[i]++ ;
      }
      else ok = 0;
    }
  }

  rep(i,n){
    if(check[i]!=1) ok=0 ;
  }

  if(!ok) cout<<"No"<<endl ;
  else{
  BIT<ll> bi(n),ci(n) ;
  ll p,q,r,s ;
  p=0 ; q=0 ;r=0 ;s= 0 ;
  rep(i,n){
  if(i%2==0){
    p+= xy[i] ;
    bi.add(posi[i]) ;
    r+= (i/2)+1 -bi.sum(posi[i]) ;
  }

  else{
  q+=xy[i] ;
  ci.add(posi[i]) ;
  s+= (i/2)+1-ci.sum(posi[i]) ;
  }

  }
  
  // cout<<p<<q<<r<<s<<endl ;
  if((p-s)%2!=0) ok= 0 ;
  if((q-r)%2!=0) ok= 0 ;

  if(ok) cout<<"Yes"<<endl; 
  else cout<<"No"<<endl ;
 }
   return 0 ;
 }



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

int N;

void dfs(string s) {
  if (s.size() == N) {
    cout << s << "\n";
    return;
  } else {
    char mx = *max_element(s.begin(), s.end());
    for (char c = 'a'; c <= mx + 1; c++) {
      dfs(s + c);
    }
  }
}

int main() {
  cin >> N;
  dfs("a");
}

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

const int maxn = 1e5 + 10;

int n;
int deg[maxn];
int m;

bool ok ()
{
	for (int i = 1; i <= n; ++i)
		if (deg[i] % 2 != 0)
			return false;

	return true;
}

int main ()
{
	scanf ("%d %d", &n, &m);

	for (int i = 1; i <= m; ++i)
	{
		int a, b;
		scanf ("%d %d", &a, &b);
		++deg[a];
		++deg[b];
	}

	if (ok())
		printf ("YES\n");
	else
		printf ("NO\n");

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long 
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int a[224524];
signed main() {
	int n, k, ansa = 0, ansb = 0;
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	int cnt[224514];
	rep(i, n)cnt[i] = 0;
	rep(i, n)cnt[a[i] - 1]++;
	rep(i, n)ansa += cnt[i];
	sort(cnt, cnt + n);
	reverse(cnt, cnt + n);
	rep(i, k)ansb += cnt[i];
	cout << ansa - ansb << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)n);i++)
typedef pair<int,int> P;
using ll = long long;
const int INF=1e9;

int n,m,q,ans=0;
vector<int> a,b,c,d;

void dfs(vector<int> A){
    if((int)A.size()==n){
        int sum=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i]) sum+=d[i];
        }
        ans=max(ans,sum);
        return;
    }
    
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
    return;
}

int main(){
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }
    dfs(vector<int>(1,1));
    cout<<ans;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
#include <iostream>
#include <vector>

using namespace std;

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

    if((a + b)%2==0){
        cout << (a+b)/2 << endl;

    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

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

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

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

    for(ll i=1;i*i<=n;i++){
        if(n%i == 0){
            ans = i + n/i - 2;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import heapq
from fractions import gcd
from functools import reduce

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, x = nm()
xl = nl()

xl.append(x)

heapq.heapify(xl)


hl = []

last = heapq.heappop(xl)
for i in range(n):
    h = heapq.heappop(xl)
    hl.append(h-last)

print(reduce(gcd,hl))




Measured memory_bytes: 16300
#include<stdio.h>
int main () {
	int p, q, r, min = 100;
	scanf("%d %d %d", &p, &q, &r);
	if(q < p){
		min = q;
		q = p;
		p = min;
	}
	if(r < q){
		min = q;
		q = r;
		r = min;
	}
	printf("%d\n", p + q);
 
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
	char input[100];
	int counter=0;
	cin >> input;
	if (input[0] == input[1] && input[2] == input[3]) {
		++counter;
	}

	if (input[0] == input[2] && input[1] == input[3]) {
		++counter;
	}

	if (input[0] == input[3] && input[1] == input[2]) {
		++counter;
	}

	if (counter == 1) {
		cout << "Yes";
	}
	else if (counter != 1) {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<vector>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define ll unsigned long long
vector<ll>val,c;
ll myabs(ll a,ll b){
	if(a>b)return a-b;
	else return b-a;
}
int main()
{
	int a,b;
	cin>>a>>b;
	int x = a;
	if(a>b)x--;
	cout<<x;
	system("pause");
	return 0;
}


Measured memory_bytes: 504
function Main(input) {
	var lines = input.split("\n");
	var n = lines[0].split(" ").map(el => Number(el))[0]
	var Ps = Number(lines[1].replace(/ /g, ''))
	var Qs = Number(lines[2].replace(/ /g, ''))

	var permutation = (result, pre, post, n) => {
		if (n > 0) {
			post.forEach((_, i) => {
				var rest = [...post];
				var elem = rest.splice(i, 1);
				permutation(result, [...pre, ...elem], rest, n - 1);
			});
		} else {
			result.push(Number(pre.join('')));
		}
		return result;
	};

	var makeArray = n => {
		var rs = []
		for(var i = 1; i <= n; i++) {
			rs.push('' + i)
		}
		return rs
	}

	var p = permutation([], [], makeArray(n), n)
	console.log(Math.abs(p.indexOf(Ps) - p.indexOf(Qs)))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 34352
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define se second
#define fi first
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef pair<double, double>  iidb;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define offset 3000
#define ptr nodo*
const ll MOD=998288383;

using namespace std;

int main()
{	
	ios::sync_with_stdio(false);cin.tie(0);
	int n,k;
	cin>>n>>k;
	int valor;
	map<int,int> mapa;
	forr(i,0,n)
	{
		cin>>valor;
		mapa[valor]++;
	}
	vector<ii> v;
	for(auto par:mapa)
	{
		v.pb({par.se,par.fi});
	}
	sort(all(v));
	reverse(all(v));
	int tot=n;
	k=min((int)v.size(),k);

	forr(i,0,k)
	{
		//cout<<v[i].fi<<' ';
		tot-=v[i].fi;
	}
	cout<<tot<<endl;
}

Measured memory_bytes: 16608
MOD = 1000000007

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

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

N = int(input())
A = list(map(int, input().split()))

l = 1
for i in A:
    l = lcm(l, i)

l %= MOD

ans = 0
for i in A:
    ans += l*pow(i, MOD-2, MOD)
    ans %= MOD

print(ans)

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (abs(b - a) > abs(c - a))cout << 'B' << endl;
	else cout << 'A' << endl;
}

Measured memory_bytes: 256
/*********** Template Starts Here ***********/

/*************** Shadman Taqi ***************/
#include<bits/stdc++.h>
using namespace std;

#define MAX 500
#define ll long long
#define ull unsigned long long
#define ___   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = b; i >= a; i--)
#define debug(x) cout << #x << " " << x << endl;
#define in(x) cin>>x;
#define out(x) cout<<x;
#define gap cout<<" ";
#define nl cout<<endl;
#define cs(x) cout<<"Case "<<x<<": ";

/*********** Template Ends Here ***********/

/** ################################## Code starts here ################################### **/

int main()
{
    ___
    int t,a,cnt=0;
    char ch[8];
    scanf("%s",&ch);
    if(ch[2]==ch[3]&&ch[4]==ch[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}

/** ################################## Happy Coding ################################### **/


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = scanner.nextInt();
        int m = scanner.nextInt();

        if (n == m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n, k; cin >> n >> k;
    int cnt = 0;
    vint f(n+1, 0);
    rep(i, n) {
        int a; cin >> a;
        f[a]++;
        if(f[a] == 1) cnt++;
    }
    sort(all(f));
    int s = 0;
    while(f[s] == 0) s++;
    int ans = 0;
    rep(i, cnt-k) {
        ans += f[s + i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int a, b; cin >> a >> b;
    if (a + b == 15) {
        cout << '+' << endl;
    } else if (a * b == 15) {
        cout << '*' << endl;
    } else {
        cout << 'x' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  bool prime[100005];
  bool like[100005];
  for(int i=0;i<100005;++i) prime[i] = true;
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<100005;++i) {
    if(prime[i]==false) continue;
    for(int j=2;i*j<100005;++j) {
      prime[i*j] = false;
    }
  }
  for(int i=0;i<100005;++i) {
    if(i%2==1 && prime[i] && prime[(i+1)/2]) like[i] = true;
    else like[i] = false;
  }
  int likenum[100005];
  for(int i=0;i<100005;++i) {
    if(like[i]) likenum[i] = 1;
    else likenum[i] = 0;
  }
  for(int i=1;i<100005;++i) likenum[i] += likenum[i-1];
  int Q;
  cin>>Q;
  int l, r;
  int ans[Q];
  for(int i=0;i<Q;++i) {
    cin>>l>>r;
    ans[i] = likenum[r]-likenum[l-1];
  }
  for(int i=0;i<Q;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 4568
main :-
	read_str(S),
	weather(S, X),
	write(X),
	nl,
	halt.

weather("RRR", 3).
weather("RRS", 2).
weather("RSR", 1).
weather("RSS", 1).
weather("SRR", 2).
weather("SRS", 1).
weather("SSR", 1).
weather("SSS", 0).

read_str(S) :-
        read_string(current_input, ' \n', '', _, S).



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

using namespace std;

int main(){
  
  int A,B,C; cin >> A >> B >> C;
  
  int ans = max<int>({
    10*A + B + C,
    A + 10*B + C,
    A + B + 10*C,
  });
  
  cout << ans << endl;
}
  
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	while(1){
		long long n,ans=1010101010101;
		cin >> n;
		if(n==0)	break;
		vector<long long> a(n);
		for(int i=0;i<n;i++)	cin >> a[i];
		sort(a.begin(),a.end());
		for(int i=0;i<n-1;i++){
			ans = min(ans,(a[i+1]-a[i]));
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w, bk, d[51][51];
char s[51][51];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> h >> w;
    rep(i, 0, h) rep(j, 0, w) {
        cin >> s[i][j];
        d[i][j] = INF;
        if (s[i][j] == '#') bk++;
    }
    queue<Pii> que;
    que.push(mp(0, 0));
    d[0][0] = 0;
    while (que.size()) {
        Pii p = que.front(); que.pop();
        int x = p.first, y = p.second;
        if (x == h-1 && y == w-1) break;
        rep(i, 0, 4) {
            int nx = x + dx[i], ny = y + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(mp(nx, ny));
                d[nx][ny] = d[x][y] + 1;
            }
        }
    }
    if (d[h-1][w-1] == INF) cout << -1 << endl;
    else cout << h * w - d[h-1][w-1] - 1 - bk << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
	for(auto &a : A) cin >> a;

    ll ans = 0;
    ll left = 0, right = 0;
    ll xor_sum = 0, sum = 0;

	for(left=0;left<N;left++) {
		while(right < N) {
			if((sum + A[right]) == (xor_sum ^ A[right])) {
				sum += A[right];
				xor_sum ^= A[right];
				right++;
			} else {
				break;
			}
		}
		ans += (right - left);
		sum -= A[left];
		xor_sum -= A[left];
		if(left == right) right++;
	}

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

main() {
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(W>=x+r && H>=y+r && x>=0 && y>=0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}



Measured memory_bytes: 2132
d[4],e[9],f,k;
char s[30];
z(){
	int a,b,c;
	a=e[f++];
	a>9?s[k++]=40,
		b=z(),
		s[k++]=a,
		c=z(),
		s[k++]=41,
		a=a-43?a-45?b*c:b-c:b+c:
		(s[k++]=a+48);
	return a;
}
y(o,n,i,j){
	if(i==7){
		f=k=0;
		if(z()==10){
			s[k]=0;
			puts(s);
			return 1;
		}
		return 0;
	}
	if(o){
		for(;j<3;j++){
			e[i] = "+-*"[j];
			if(y(o-1,n+1,i+1,0))return 1;
		}
	}
	if(n||i==6){
		for(j=0;j<4;j++){
			if(e[i]=d[j]){
				d[j]=0;
				if(y(o,n-1,i+1,0))return 1;
				d[j]=e[i];
			}
		}
	}
	return 0;
}

int main(void){
	for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)
		y(3,0,0,0)||puts("0");
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int n,sum = 0;
    cin >> n;
    int v[20];
    for (int i =0;i<n;i++){cin >> v[i];}
    
    int temp;
    for (int i =0;i<n;i++){
        cin >> temp;
        if (temp<v[i]){sum +=v[i]-temp;}
    }
    cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<P> a;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    a.push(P(tmp, 1));
  }
  rep(i, m) {
    int b, c;
    cin >> b >> c;
    a.push(P(c, b));
  }

  ll ans = 0;
  int i = 0;
  while (1) {
    P p = a.top();
    a.pop();
    int num = min(p.second, n - i);
    ans += (ll)p.first * num;
    i += p.second;
    if (i >= n) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
vector<ll> h(51);
vector<ll> p(51);
ll length_b(int N){//バーガーの層の数
	if (N == 0){
		return h[0] = 1;
	}
	else{
		return h[N] = length_b(N - 1) * 2 + 3;
	}
}

ll paty(int N){//パティの数
	if (N == 0){
		return p[0] = 1;
	}
	else{
		return p[N] = paty(N - 1) * 2 + 1;
	}
}
ll  solve(int N,ll X){
	if (N == 0 && X >= 1){
		return 1;
	}
	else if (X == 0){
		return 0;
	}
	if (X < (h[N]/2 + 1)){
		// cout << "1" << "N"<< N << "X" <<  h[N]/2 + 1 << "h[N]" << h[N] <<  endl;		
		return solve(N - 1,X - 1);
	}
	else if(X == (h[N]/2 + 1)){
		// cout << "2" <<  "N"<< N << "X" <<  h[N]/2 + 1 << "h[N]" << h[N] <<  endl;
		return 1 + solve(N - 1,X -2);
	}
	else{
		// cout << "3" << "N"<< N << "X" <<  h[N] /2 + 1 << "h[N]" << h[N] <<  endl;
		return solve(N - 1, X - (h[N] / 2 + 1)) + 1 + p[N - 1]; 
	}
}
int main(){
	int N;
	ll X;
	cin >> N >> X;
	length_b(N);
	paty(N);

	cout << solve(N,X) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
#define MAXN 100000
int n,A[MAXN+5],val;
int p[MAXN+5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<n;i++)
		val=A[i]-val;
	p[1]=(A[n]-val)/2;
	for(int i=2;i<=n;i++)
	p[i]=A[i-1]-p[i-1];
	for(int i=1;i<=n;i++)printf("%d ",p[i]*2);
}

Measured memory_bytes: 2048
package main

import "fmt"

func main() {
	var o, e string
	fmt.Scan(&o, &e)
	p := ""
	e += " "
	for i := 0; i < len(o); i++ {
		p += o[i:i+1] + e[i:i+1]
	}
	fmt.Println(p)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	unsigned side_1;
	unsigned side_2;
	unsigned diagonal;
	unsigned rectangle_num = 0u;
	unsigned lozenge_num = 0u;

	while (scanf("%u,%u,%u",&side_1,&side_2,&diagonal) != EOF) {
		if (side_1 == side_2) {
			++lozenge_num;
		}
		if (side_1*side_1 + side_2*side_2 == diagonal*diagonal) {
			++rectangle_num;
		}
	}
	printf("%u\n%u\n",rectangle_num,lozenge_num);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <list>
#include <queue>

using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    int mod2 = N%2;
    list<ll> lst;
    for(int i=1;i<=N;i++){
        int tmp;
        cin >> tmp;
        if(i%2==mod2){
            lst.push_front(tmp);
        }else{
            lst.push_back(tmp);
        }
    }

    for(auto itr=lst.begin();itr!=lst.end();++itr){
        cout << *itr << " ";
    }
    cout << endl;
    return 0;

}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, i;
      cin >> n;
      lld j, s;
      lld dda[10][10];
      foi(i, 10)
      {
      	foi(j, 10)
      	{
      		dda[i][j] = 0;
      	}
      }
      for(i = 1; i <= n; i += 1)
      {
      	lld z = log10(i);
      	lld x = i/pow(10, z);
      	lld y = i%10;
      	dda[x][y]+=1;
      }
      s = 0;
      for(i = 1; i < 10; i += 1)
      {
      	for(j = 1; j<10; j += 1)
        {
      		s+= dda[i][j]*dda[j][i];
      	}
      }
      cout<< s;
      return 0;
}

Measured memory_bytes: 384
import sys
import math

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def pro(k, l, n):
    if l < n:
        if k == 0:
            return(n - l)
        return (n - l + 2)
    if l == n:
        if k == 0:
            return 0
        elif k == 1:
            return 1
        return 3
    else:
        l -= n - 1
        if l == k:
            return 1
        elif l > k:
            return 0
        if l < k - 1:
            return 2
        else:
            return 3
            

def rt(k, l , n):
    if k < n:
        if l == 0:
            return (k * 2 + n)
        return (n + k * 2 - 1)
    elif k == n:
        if l == 1:
            return (k * 3 - 2)
        elif l == 0:
            return (k * 3)
        return (k * 3 - 3)
    else:
        k -= n - 1
        if k == l:
            return (n * 3 - 2)
        elif k > l:
            return (n * 3)
        if k < l - 1:
            return ((n - 1) * 3 - 1)
        else:
            return ((n - 1) * 3)



def main():
    n, k = rinput()
    n -= 1
    s = input()
    ch = 0
    for i in range(n):
        if s[i] == s[i + 1]:
            ch += 1
    print(min(ch + 2 * k, n))
            
        
    
    
    
    
    


main()

Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<long long> b(n+1, 0);
    long long sum;
    long ans=0;
	int mod = 1000000007;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		b[i + 1] = b[i] + a[i];
	}
	
	for (int i = 0; i < n; i++){
	    sum = (b[n]-b[i+1]) % mod;
	    ans += a[i]*sum;
	    ans %= mod;
	}
	
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const ll INF = 1e18;
signed main(){
    #define int long long
    int n;cin >> n;

    vector < int > a(n + 1);
    for(int i = 0 ; i <= n ;++i)
        cin >> a[i];
    if(n == 0){
        if(a[0] == 1)
            cout << 1;
        else
            cout << -1;
        return 0;
    }
    vector < ll > pw(n + 1);
    pw[0] = 1;
    for(int i = 1 ; i <= n; ++i){
        pw[i] = (pw[i - 1] * 2);
        if(pw[i] >= INF)
            pw[i] = INF;
    }
    vector < pair < int , int > > canbe(n + 1);
    canbe[n] = {a[n] , a[n]};
    for(int i = n - 1; i >= 0; --i){
        canbe[i] = {a[i] + ceil(canbe[i+1].fi/2.0) , a[i] + canbe[i+1].se};
    }
//    for(int i = 0 ; i <= n; ++i)
//        cout << canbe[i].fi << ' ' << canbe[i].se << '\n';
    if(1 >= canbe[0].fi && 1 <= canbe[0].se){
        canbe[0] = {1 , 1};
        ll ans = 1;
        ll lst = 1;
        for(int i = 1; i <= n; ++i){
            lst = min(canbe[i].se , lst * 2);
            ans += lst;
            lst -= a[i];
            if(lst < 0)
                assert(false);
        }
        cout << ans;
    }else
        cout << -1;
    return 0;
}


Measured memory_bytes: 6428
x = int(input())
if x<600:
    ans = 8
elif x<800:
    ans = 7
elif x<1000:
    ans = 6
elif x<1200:
    ans = 5
elif x<1400:
    ans = 4
elif x<1600:
    ans = 3
elif x<1800:
    ans = 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 61644
#include <cstdio>
#define int long long
int read()
{
	int x=0,flag=1;char c;
	while((c=getchar())<'0' || c>'9') if(c=='-') flag=-1;
	while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*flag;
}
int x;
signed main()
{
    x=read();
    for(int a=-1000;a<=1000;a++)
        for(int b=-1000;b<=1000;b++)
        {
            int t=a*a*a*a*a-b*b*b*b*b;
            if(t==x)
            {
                printf("%lld %lld\n",a,b);
                return 0;
            }
        }
}


Measured memory_bytes: 3160
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

string ans[] = {"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s;
	cin >> s;
	cout << ans[s.back()-'0'] << endl;
}	


Measured memory_bytes: 3644
import java.util.* ;

public class Main {

	static Scanner in = new Scanner(System.in) ;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int A = in.nextInt() ;
		int B = in.nextInt() ;
		double T = in.nextInt() ;
		T += 0.5 ;
		int sum = 0 ;
		while(T >= (A*1.0)){
			sum += B ;
			T -= A ;
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007
ll n, k;
ll weight[100010] = {};
bool visited[100010] = {};
vector<vector<ll>> g(100010);
void dfs(ll x, ll c){
    visited[x]=true;
    weight[x] = c;
    ll w = k-1;
    if(c!=k)w--;
    rep(i, g[x].size())if(!visited[g[x][i]]){
        dfs(g[x][i], w);
        w = max(w-1, (ll)0);
    }
}

int main(){
    cin >> n >> k;
    rep(i, n-1){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, k);
    ll ans = 1;
    rep(i, n)ans = (ans*weight[i+1])%MOD;
    cout << ans << endl;
}

Measured memory_bytes: 10112
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    for i in range(1,n):
        if a[i-1]>a[i]:
            ans += a[i-1]-a[i]
            a[i] = a[i-1]
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 32124
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        int x = sc.nextInt();

        int sum = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if (i * 500 + j * 100 + k * 50 == x) {
                        sum++;
                    }
                }
            }
        }
        System.out.println(sum);
    }
}

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

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

	long long n;
	int x, m;
	cin >> n >> x >> m;
	int prv = x;
	vector<int> rep; rep.reserve((int) 1e6);
	vector<bool> vis(m);
	while (!vis[prv]) {
		vis[prv] = 1;
		rep.push_back(prv);
		prv = (long long) prv * prv % m;
	}
	int i = 0;
	uint64_t ans = 0;
	for (; i < (int) rep.size() && n; ++i) {
		if (rep[i] == prv) break;
		ans += rep[i];
		--n;
	}
	if (n) {
		int period = (int) rep.size() - i;
		ll divs = n / period;
		int left = n % period;
		ans += ((long long) divs * accumulate(rep.begin() + i, rep.end(), (long long) 0) +
			accumulate(rep.begin() + i, rep.begin() + i + left, (long long) 0));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3640
# A - November 30
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if (M1 == 1 or M1 ==3 or M1 ==5 or M1 ==7 or M1 ==8 or M1 ==10 or M1 ==12) and D1 == 31:
    print(1)
elif (M1 == 4 or M1 == 6 or M1 ==9 or M1 ==11) and D1 == 30:
    print(1)
elif M1 == 2 and D1 == 28:
    print(1)
else:
    print(0)

Measured memory_bytes: 38384