akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <tuple>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl

int main(){
  int n;
  cin >> n;
  ll A[300][300],B[300][300];
  rep(i,0,n){
    rep(j,0,n){
      int a;
      cin >> a;
      A[i][j] = B[i][j] = a;
    }
  }
  ll ans = 0LL;
  rep(k,0,n){
    rep(i,0,n){
      rep(j,0,n){
        if(A[i][j] > A[i][k]+A[k][j]){
          i = k = n;
          ans = -1LL;
          break;
        }
        if(A[i][j] == A[i][k]+A[k][j]){
          if(B[i][k] != 0 && B[k][j] != 0){
            B[i][j] = 0;
          }
        }
      }
    }
  }
  if(ans != -1LL){
    ans = 0;
    rep(i,0,n-1){
      rep(j,i+1,n){
        ans += B[i][j];
      }
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
 
int main(int argc, const char * argv[]) {
    int n, b, f, r, v;
    int i1, i2, i3;
     
    int num[4][3][10]={{{}}};
     
    n=0;
    cin >> n;
     
    for(i1=0;i1<n;i1++){
        cin >> b >> f >> r >> v;
        num[b-1][f-1][r-1] += v;
    }
     
    for(i1=0;i1<4;i1++){                    //棟
        for(i2=0;i2<3;i2++){                //階
            for(i3=0;i3<10;i3++){
                cout << " ";
                cout << num[i1][i2][i3];
            }
            cout << endl;
        }
        if(i1<3){
            cout << "####################" << endl;
        }
    }
     
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<math.h>
#include<vector>
 
using namespace std;
 
int n,w;
vector< pair<int, int> > item;
long long dp[101][100001];
long long m = -1;
 
int dfs(int k){
  if(k == n){
    for(int i = 0; i <= w; i++){
      m = max(m, dp[n][i]);
    }
    return 0;
  }
  for(int i = 0; i <= w; i++){
//    if(dp[k][i] == -1) continue;
    dp[k+1][i] = max(dp[k+1][i], dp[k][i]);
    if(i + item[k].first <= w)dp[k+1][i + item[k].first] = max(dp[k+1][i + item[k].first], dp[k][i] + item[k].second);
  }
  return dfs(k+1);
}
 
int main(){
  cin >> n >> w;
  for(int i = 0; i < n ; i++){
    int a,b;
    cin >> a >> b;
    item.push_back(make_pair(a,b));
  }
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= w; j++){
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;
  dfs(0);
  cout << m << endl;
}

Measured memory_bytes: 79104
# https://atcoder.jp/contests/abc144/tasks/abc144_c

import math

N = int(input())

mi = -1

for i in range(1, int(math.sqrt(N)) + 1):
    a = i
    if N % a != 0:
        continue

    b = N // a
    count = a + b - 2
    
    if mi <= -1 or mi > count:
        mi = count

print(mi)





Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int A, B, C;
	int tmp;

	scanf("%d %d %d", &A, &B, &C);

	tmp = A;
	A = B;
	B = tmp;

	tmp = A;
	A = C;
	C = tmp;

	printf("%d %d %d\n", A, B, C);

	return 0;
}


Measured memory_bytes: 128
/**
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/                          
All Required Header Files ********/
#include <bits/stdc++.h>  
using 		namespace 		std;
using 		lli= 			long long  int;
using 		ulli= 			unsigned long long int;
using 		ld= 			long double;
int main() {
	
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	
	lli n;
	cin>>n;
	
	lli ans=0;
	
	ans+=1000*(n/500);
	n=n%500;
	ans+=5*(n/5);
	cout<<ans;
	
	
	
	return 0;
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A + B < C + D){
    cout << "Right" << endl;
  }
  if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  if(A + B > C + D){
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 3564
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a(), m = o.a(), v = o.a(), p = o.a();
  var a = o.l();
  a.sort((a,b)=>a-b);
  var ok = n-p, ng = -1;
  while(ok-ng > 1){
    var c = ok+ng+1>>1;
    var d = a[c] + m;
    if(d < a[n-p]){
      ng = c;
    }else if(v <= c+p){
      ok = c;
    }else{
      var amari = (v-c-p)*m;
      for(var i = c+1; amari > 0 && i < n-p+1; i++){
        amari -= d-a[i];
      }
      if(amari <= 0)ok = c;
      else ng = c;
    }
  }
  return n-ok;
}

Measured memory_bytes: 30544
import java.util.*;
import java.awt.geom.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayDeque<Integer> ans = new ArrayDeque<Integer>();

		while(sc.hasNext()){
			double[] x = new double[3];
			double[] y = new double[3];
			for(int i=0;i<3;i++){
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
			}
			double xp = sc.nextDouble();
			double yp = sc.nextDouble();
			
			if(Line2D.linesIntersect(x[0],y[0],x[1],y[1],x[2],y[2],xp,yp)==false
					&& Line2D.linesIntersect(x[1],y[1],x[2],y[2],x[0],y[0],xp,yp)==false
					&& Line2D.linesIntersect(x[2],y[2],x[0],y[0],x[1],y[1],xp,yp)==false){
				Arrays.sort(x);
				Arrays.sort(y);
				if(x[0]<xp && x[2]>xp && y[0]<yp && y[2]>yp){
					ans.push(1);
				}else{
					ans.push(0);
				}
			}else{
				ans.push(0);
			}
			
		}
		int num = ans.size();
		for(int i=0;i<num;i++){
			int z = ans.pollLast();
			if(z==1){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 23360
package main

import (
	"fmt"
)

func saidaikouyakusuu(a int,b int)(ans int){
  var big,little int
  if a < b {
    big = b
    little = a
  }else {
    big = a
    little = b
  }
  r := big % little
  if r == 0{
    ans = little
  }else{
    ans = saidaikouyakusuu(little,r)
  }
  return
}

func main() {
	var N int
	fmt.Scan(&N)
  A := make([]int,N)
  for i:=0;i<N;i++{
    fmt.Scan(&A[i])
  }
  var ans = A[0]
  for i:=1;i<N;i++{
    ans = saidaikouyakusuu(ans,A[i])
  }
  fmt.Println(ans)
	return
}


Measured memory_bytes: 7424
//C
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 105;
bool vis[maxn];
int main(){
	int x,n;
	cin >> x >> n;
	for(int i = 1;i <= n;i++){
		int y;
		cin >> y;
		vis[y] = 1;
	}
	int ans = 0,delta = x;
	for(int i = 0;i <= 101;i++)if(!vis[i]){
		if(delta > abs(i-x)){
			delta = abs(i-x);
			ans = i;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3628
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    if n % 2 == 0:
        print("Yes" if s[:n//2] == s[n//2:] else "No")
    else:
        print("No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	string s, t;
	cin >> s >> t;
	int count = 0;
	rep(i, t.size()-1) {
		if (s.at(i) != t.at(i)) {
			cout << "No" << endl;
			count = 1;
			break;
		}
	}
	if (count != 1)cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

ll fac[MAX],finv[MAX],inv[MAX];
//http://drken1215.hatenablog.com/entry/2018/06/08/210000
//テーブルを作る前処理　O(n)
//pが素数でなくてはならない
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
//二項係数計算
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}



int main(){
    COMinit();
    int N,K;
    cin>>N>>K;
    for(int i=1;i<=K;i++){
        ll ans=1;
        ans*=COM(K-1,i-1);
        //cout<<ans<<endl;
        ans*=COM(N-K+1,i);
        ans%=MOD;
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 2560
// OURL: https://atcoder.jp/contests/abc138/tasks/abc138_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  int n;
  cin >> n;
  // auto vs = make_v<int>(n);
  priority_queue<double, vector<double>, greater<double>> vs;
  for (int i = 0; i < n; ++i) {
    double v;
    cin >> v;
    vs.push(v);
  }
  debug(vs.top());
  while(vs.size() > 1) {
    double x = vs.top(); vs.pop();
    double y = vs.top(); vs.pop();
    vs.push((x + y) / 2);
  }
  cout << vs.top() << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
void hoandoi(int &c,int &b)
{
	int t=c;c=b;b=t;
}
void hoandoistring(string &c,string &b)
{
	string t=c;c=b;b=t;
}
void SelectionSort(string a[],int n,bool tr,int b[]){
	int mini;
	for(int i=0;i<n-1;i++)
	{
		mini=i;
		for(int j=i+1;j<n;j++){
			if(a[j][1]<a[mini][1]){
				mini=j;
			}
		}
		
			hoandoistring(a[i],a[mini]);
			hoandoi(b[i],b[mini]);

	}
	for(int i=0;i<n;i++)
		{
                cout <<a[i];
		if(i<n-1){
			cout <<" ";
			if(a[i][1]==a[i+1][1] && b[i]>b[i+1])
				tr=false;
		}
	}
	if(tr)
		cout << endl << "Stable";
	else
		cout << endl << "Not stable";
}
void bubbleSort(string a[],int n,bool tr,int b[]){
	for(int i=0;i<n-1;i++){
		for(int j=n-1;j>i;j--){
			if(a[j][1]<a[j-1][1]){
				hoandoistring(a[j],a[j-1]);
				hoandoi(b[j],b[j-1]);
			}

		}

	}

	for(int i=0;i<n;i++)
		{cout <<a[i];
		if(i<n-1){
			
			cout<<" ";
			if(a[i][1]==a[i+1][1]&&b[i]>b[i+1])
				tr=false;
		}
	}
	if(tr)
		cout << endl << "Stable";
	else
		cout << endl << "Not stable";

}

int main(){
	//int n;
	bool tr=true;
	string *a,*c,x;
	int n,*b,*d;
	cin >>n;
	a=new string[n];
	c=new string[n];
	b=new int[n];
	d=new int[n];
	for(int i=0;i<n;i++){
		cin >>x;
		a[i]=x;
		b[i]=i;
		d[i]=i;
		c[i]=x;
	}

	bubbleSort(a,n,tr,b);
	tr=true;
	cout <<endl;
	SelectionSort(c,n,tr,d);
	cout << endl;

	return 0;
}

Measured memory_bytes: 3152
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int as = sc.nextInt();
        int bs = sc.nextInt();
        int mod = 1000000007;

        long ans = pow(2, n, mod) - 1;
        long a = 1;
        for (int i = 2; i <= as; i++) {
            a *= i;
            a %= mod;
        }
        a = pow(a, mod - 2, mod);
        long ax = 1;
        for (int i = n; i >= n - as + 1; i--) {
            ax *= i;
            ax %= mod;
        }
        long minus = ax * a % mod;
        long b = 1;
        for (int i = 2; i <= bs; i++) {
            b *= i;
            b %= mod;
        }
        b = pow(b, mod - 2, mod);
        long bx = 1;
        for (int i = n; i >= n - bs + 1; i--) {
            bx *= i;
            bx %= mod;
        }
        minus += bx * b % mod;
        minus %= mod;

        System.out.println(ans - minus < 0 ? ans - minus + mod : ans - minus);
    }

    //return a^b mod M O(logB)
    private static long pow(long a, long b, int M) {
        long ret = 1;
        long tmp = a;
        while (b > 0) {
            if ((b & 1) == 1) ret = (ret * tmp) % M;
            tmp = (tmp * tmp) % M;
            b = b >> 1;
        }
        return ret;
    }
}


Measured memory_bytes: 22612
#include <iostream>

using namespace std;
long a,b,c[3];
long gcd,lcm;
int main(){
	while(cin >> a >> b){
		c[0] = a;
		c[1] = b;
		c[2] = a;
		while(c[2]>0){
			c[2] = c[0] % c[1];
			c[0] = c[1];
			c[1] = c[2];
		}
		cout << c[0] << ' ' << a/c[0]*b << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MOD = 1000 * 1000 * 1000 + 7;

//const int MAX = 1000007;

int n;
vector<int> g[200000];
int a[200000];
int H[200000];

void dfs(int v)
{
    vector<int> u;
    FOR (i,0,g[v].size())
    {
        //cout << v<<" "<<g[v][i]<<"*\n";
        dfs(g[v][i]);
        u.PB(H[g[v][i]]);
    }
    sort(u.begin(),u.end());
    reverse(u.begin(),u.end());
    H[v] = 0;
    FOR (i,0,u.size())
        H[v] = max(H[v],u[i]+i+1);
    //cout << v<<" "<<H[v]<<endl;
}



int main()
{
    //freopen("in.txt", "r", stdin);
    //ios::sync_with_stdio(false); cin.tie(0);
    //freopen("/Users/Taras/Downloads/big_top.txt", "r", stdin);
    //freopen("/Users/Taras/Downloads/mout.txt", "w", stdout);
    
    cin >> n;
    FOR (i,1,n)
    {
        cin >> a[i];
        a[i]--;
        g[a[i]].PB(i);
    }
    dfs(0);
    cout << H[0]<< endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=2005*3;
int n,mod;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int Fac[N],Inv[N];
int v1[N],v2[N],v3[N];
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int main(){
	n=read(),mod=read();
	int n3=n*3;
	Fac[0]=1;
	For(i,1,n3)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n3]=Pow(Fac[n3],mod-2);
	Fod(i,n3,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
	v1[0]=1;
	For(i,1,n3)
		v1[i]=(LL)C(i*1-1,0)*v1[i-1]%mod;
	v2[0]=1;
	For(i,1,n)
		v2[i]=(LL)C(i*2-1,1)*v2[i-1]%mod;
	v3[0]=1;
	For(i,1,n)
		v3[i]=(LL)C(i*3-1,2)*v3[i-1]%mod*2%mod;
	int ans=0;
	For(i3,0,n)
		For(i2,0,n-i3){
			int i1=n*3-i3*3-i2*2;
//			printf("(%d,%d,%d)\n",i1,i2,i3);
			Add(ans,(LL)v1[i1]*v2[i2]%mod*v3[i3]%mod
				*C(n*3,i1)%mod*C(n*3-i1,i2*2)%mod);
//			outval(ans);
		}
	cout<<ans<<endl;
	return 0;
}
/*
//123
132  32
213  21
231  31
312  31
//321
*/

Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
mod = 1000000007
s1 = list(input())
s2 = list(input())

idx = 0
before = -1
ans = 1
while idx<N:
    if s1[idx]==s2[idx]:
        if before==-1:
            ans *= 3
            ans %= mod
        elif before==1:
            ans *= 2
            ans %= mod
        else:
            pass
        before = 1
        idx += 1
    else:
        if before==-1:
            ans *= 6
            ans %= mod
        elif before==1:
            ans *= 2
            ans %= mod
        else:
            ans *= 3
            ans %= mod
        before = 2
        idx += 2
print(ans)

Measured memory_bytes: 62024
//
//AtCoder Beginner Contest 161
//C - Replacing Integer
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define zero(a) memset(a, 0, sizeof(a))

using ll = long long;

int main()
{
    ll n, k;

    cin >> n >> k;

    ll s = n / k;


    ll s1 = n - (k * s);
    ll s2 = abs(n - (k * (s + 1)));

    if (s1<s2) {
        cout << s1 << endl;
    }else{
        cout << s2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<vector<int>> v(n, vector<int>(3, 0));
  rep(i, 0, n - 1) cin >> v[i][0] >> v[i][1] >> v[i][2];

  rep(i, 0, n) {
    int ans = 0;
    rep(j, i, n - 1) {
      if (ans < v[j][1])
        ans = v[j][1];
      else if (ans % v[j][2])
        ans += v[j][2] - ans % v[j][2];
      ans += v[j][0];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        long[] A = new long[N];
        string[] str = Console.ReadLine().Split();
        for (var i = 0; i < N; i++)
        {
            A[i] = long.Parse(str[i]);
        }
        long[] D1 = new long[61];
        long[] D2 = new long[61];
        long mod = 1000000007;
        for (var i = 0; i < N; i++)
        {
            long digit = 1;
            for (var j = 0; j <= 60; j++)
            {
                if (A[i] / digit % 2 == 1)
                {
                    D1[j]++;
                }
                else
                {
                    D2[j]++;
                }
                digit *= 2;
            }
        }
        long digit1 = 1;
        long ans = 0;
        for (var i = 0; i <= 60; i++)
        {
            long temp = D1[i] * D2[i] % mod;
            temp = digit1 % mod * temp % mod;
            ans = (ans + temp) % mod;
            digit1 *= 2;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 54216
#計算でもとまるのか・・・
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
#*S, = input() 
S =input().strip()
c1 =S.count("1")
c0 =S.count("0")
print(min(c0,c1)*2)

Measured memory_bytes: 9056
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "queue"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

ll INF = 1e18;

void dfs(ll u, ll p, V<V<ll>>& edge_list, V<ll>& lis, V<ll>& res, V<ll>& as) {
  auto it = lower_bound(all(lis), as[u]);
  ll i = it - lis.begin();
  ll pr = *it;
  lis[i] = as[u];
  res[u] = lower_bound(all(lis), INF) - lis.begin();

  for (auto v : edge_list[u]) {
    if (v == p) continue;
    dfs(v, u, edge_list, lis, res, as);
  }

  lis[i] = pr;
}

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

  ll N;
  cin >> N;

  V<ll> as(N);
  rep(i, N) cin >> as[i];

  V<V<ll>> edge_list(N, V<ll>(0));

  rep(i, N - 1) {
    ll u, v;
    cin >> u >> v;
    --u, --v;
    edge_list[u].push_back(v);
    edge_list[v].push_back(u);
  }

  V<ll> lis(N, INF);
  V<ll> res(N, 0);

  dfs(0, -1, edge_list, lis, res, as);

  rep(i, N) { cout << res[i] << "\n"; }

  return 0;
}


Measured memory_bytes: 36120
N, M = map(int, input().split())

A = list(map(int, input().split()))
sum_A = sum(A)

A_M = [A_i for A_i in A if A_i >= (sum_A / (4 * M))]

m = len(A_M)

if m >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>

using namespace std;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
    int n;
    cin>>n;
    int v[n];
    for(int i = 0; i<n;i++){
      cin>>v[i];
    }
    int c[n];
    for(int i = 0; i<n;i++){
      cin>>c[i];
    }
    int d[n];
    int sum = 0;
    for(int i = 0; i<n;i++){
      d[i]=v[i]-c[i];
      if(d[i]>0){
        sum+=d[i];
      }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long 
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
   // cout<<x<<' '<<y<<endl;
    if(y==0)
    return x;
    else
    return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
    if(m%2)
	r=(r*n)%p;
    n=(n*n)%p;
    m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
       return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r)
	z[i] = min (r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]])
	++z[i];
    if (i + z[i] - 1 > r)
	l = i, r = i + z[i] - 1;
    }
    return z;
}
int n;
double p[3000];
bool vis[3000][3000];
double dp[3000][3000];
double solve(int i,int j)
{
	if(i==n)
	{
		if(j>i-j)
			return 1.0;
		return 0;
	}
	if(vis[i][j])
		return dp[i][j];
	double ans=p[i]*solve(i+1,j+1)+(1.0-p[i])*solve(i+1,j);
	dp[i][j]=ans;
	vis[i][j]=true;
	return ans;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/
   cin>>n;
   for(int i=0;i<n;i++)
   {
   	cin>>p[i];
   }
   cout<<fixed<<setprecision(15)<<solve(0,0)<<endl;
}                       

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


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

    string s;
    cin>>s;
    int n=s.size();
    int cnt[3]={};
    for(int i=0;i<n;i++){
        cnt[s[i]-'a']++;
    }
    bool ok=true;
    if(n==1){
        cout<<"YES"<<endl;
        return 0;
    }
    if(n==2){
        for(int i=0;i<3;i++){
            if(cnt[i]==2) ok=false;
        }
        if(ok){
            cout<<"YES"<<endl;
        }
        else cout<<"NO"<<endl;
        return 0;
    }
    for (int i = 0; i < 3; i++)
    {
        if(cnt[i]==0) ok=false;
        int k=(n+(3-n%3)%3)/3;
        if(cnt[i]>k) ok=false;
    }
    if(ok){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;

    
}

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

int getOrderTime(int x_time) {
    return (x_time + 9) / 10 * 10;
}

int getRestTime(int x_time) {
    return getOrderTime(x_time) - x_time;
}

int main(void) {
    int a, b, c, d, e, sum = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    sum = getOrderTime(a) + getOrderTime(b) + getOrderTime(c) + getOrderTime(d) + getOrderTime(e);
    cout << sum - max(getRestTime(a), max(getRestTime(b), max(getRestTime(c), max(getRestTime(d), getRestTime(e))))) << "\n";
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<P> red(n), blue(n);
  rep(i,n) cin >> red[i].first >> red[i].second;
  rep(i,n) cin >> blue[i].first >> blue[i].second;

  sort(blue.begin(), blue.end());

  rep(i,n) {
    vector<P> cand;
    rep(j,red.size()) {
      if (red[j].first < blue[i].first && red[j].second < blue[i].second) {
	cand.push_back(red[j]);
      }
    }
    if (cand.size() == 0) continue;
    sort(cand.begin(), cand.end(), [](P a, P b) {
				     return (a.second > b.second);});
    red.erase(find(red.begin(), red.end(), cand[0]));
  }
  cout << n - red.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string o, e;
  cin >> o >> e;
  
  ll L = o.size() + e.size();
  rep(i, 0, L) {
    if(i %2 == 0)
      cout << o[i/2];
    else
      cout << e[i/2];
  }
  cout << "\n";

}

Measured memory_bytes: 384
def floor(a, b):
    return ((-a)//b)*-1


N = int(input())
ratio = []
for _ in range(N):
    ratio.append(list(map(int, input().split())))

v_T = ratio[0][0]
v_A = ratio[0][1]

for t, a in ratio[1:]:
    diff_t = t - v_T
    diff_a = a - v_A

    if diff_t < 0 or diff_a < 0:
        d = max(floor(v_T, t), floor(v_A, a))
        v_T = d*t
        v_A = d*a

    elif diff_t >= 0 and diff_a >= 0:
        m = max(diff_t, diff_a)
        v_T = t
        v_A = a

print(v_T+v_A)


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
  map<pair<int,int>,int> cnt;
  int n;
  cin>>n;
  for(int i=1; i<=n; ++i){
    string num = to_string(i);
    int dig1 = num[0] - '0';
    int dig2 = num[num.size()-1] - '0';
    cnt[{dig1, dig2}] += 1;
  }
  int ans = 0;
  for(auto i : cnt){
    int f = i.first.first;
    int s = i.first.second;
    ans += i.second * cnt[{s,f}];
  }
  cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int a[2][110];
int main(){
	int n,t,mx=-1;
	scanf("%d",&n);
	for(int i=0;i<=1;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		t=0;
		for(int j=1;j<=i;j++){
			t+=a[0][j];
		}
		for(int j=i;j<=n;j++){
			t+=a[1][j];
		}
		if(t>mx){
			mx=t;
		}
	}
	printf("%d",mx);
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		if(a+b>c){
			System.out.println("No");
			return;
		}
		if((-a-b+c)*(-a-b+c)>4*a*b){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector <string> W(N);
  for( int i=0;i<N;i++ )
    {
      cin >> W[i];
    }

  for( int i=1;i<N;i++ )
    {
      if( W[i-1].back() != W[i].front())
	{
	  cout << "No" << endl;
	  return 0;
	}
      for( int j=0;j<i;j++ )
	{
	  //	  cout << i << " " << j << endl;
	if( W[i] == W[j] )
	  {
	    cout << "No" << endl;
	    return 0;
	  }
	}
    }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))
 
using namespace std;

signed main() {
	int N;
	cin >> N;

	vector<int> A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	int ret = 0;
	rep(i, N) {
		int tmp = 0;
		rep(j, i + 1) tmp += A[j];
		REP(j, i, N - 1) tmp += B[j];
		ret = max(ret, tmp);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,v,i;
string s;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>s;
  int cnt=0;
  string ans_s = s;
  rep(i,n){
    if(cnt<1&&s[i]==')') ans_s='('+ans_s;
    if(cnt>0&&s[i]==')') cnt--;
    if(s[i]=='(') cnt++;
  }
  rep(i,cnt) ans_s = ans_s+')';
  cout<<ans_s<<endl;
  
}

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


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

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define fr(i,n) for(i=1;i<=n;i++)

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,tp,cnt,mn=1e9;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cnt=0;
        tp=i;
        while(tp>0)
        {
            cnt+=(tp%10);
            tp/=10;
        }
        tp=n-i;
        while(tp>0)
        {
            cnt+=(tp%10);
            tp/=10;
        }
        mn=min(mn,cnt);
    }
    cout<<mn<<endl;
    return 0;
}


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

void bfs(queue<ll> que, vector<ll> &isVisited, vector<vector<ll> > &vec, vector<vector<pair<ll,ll> > > &length, vector<ll> &color){
    que.push(0);
    isVisited[0] = 1;
    while(que.size() != 0){
        ll q = que.front();
        rep(i,vec[q].size()){
            if (isVisited[vec[q][i]] == 0){
                que.push(vec[q][i]);
                color[vec[q][i]] = color[q] + length[q][i].second;
                isVisited[vec[q][i]] = 1;
            }
        }
        que.pop();
    }
}

int main(){
    ll N;
    cin >> N;
    vector<ll> color(N,0);
    vector<ll> isVisited(N,0);
    vector<vector<pair<ll,ll> > > length(N, vector<pair<ll,ll> > (0));
    vector<vector<ll> > connection(N,vector<ll> (0));
    rep(i,N - 1){
        ll u,v,w;
        cin >> u >> v >> w;
        connection[u - 1].push_back(v - 1);
        connection[v - 1].push_back(u - 1);
        length[u - 1].push_back(pair<ll,ll> (v - 1, w));
        length[v - 1].push_back(pair<ll,ll> (u - 1, w));
    }
    queue<ll> que;
    bfs(que, isVisited, connection, length, color);
    rep(i,N){
        if (color[i] % 2 == 0) cout << 0 << endl;
        else cout << 1 << endl;
    }
}


Measured memory_bytes: 18084
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

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

#define SENT 1000000000


int merge(int A[], int first, int mid, int last){
    
    int i,j,k, former, latter, *L, *R, cmp;
    cmp = 0;
    
    
    former = mid - first + 1;
    latter = last - mid;
    
    L = (int*)malloc(sizeof(int) * (former+1));
    R = (int*)malloc(sizeof(int) * (latter+1));
    
    for (i=0; i < former; i++) {
        L[i] = A[first + i];
    }
    L[former] = SENT;
    
    for (i=0; i < latter; i++) {
        R[i] = A[i + mid + 1];
    }
    R[latter] = SENT;
    
    j=k=0;
    for (i = first; i < last + 1; i++) {
        if (L[j] < R[k]) {
            A[i] = L[j];
            j++;
        }
        else
        {
            A[i] = R[k];
            k++;
        }
        cmp += 1;
    }
    return cmp;
    
}

int MergeSort(int A[], int first, int last){
    
    int cmp, mid;
    cmp = 0;
    
    if (first < last) {
        mid = (first + last)/2;
        cmp += MergeSort(A, first, mid);
        cmp += MergeSort(A, mid+1, last);
        cmp += merge(A, first, mid, last);
    }
    
    return cmp;
}


int main(){
    
    int i,n, *array, cmp;
    
    cmp = 0;
    
    //the number
    scanf("%d",&n);
    
    array = (int*)malloc(sizeof(int)*n);
    
    for (i=0; i<n; i++) {
        scanf("%d", &array[i]);
    }
    
    cmp = MergeSort(array, 0, n-1);
    
    for (i=0; i<n; i++) {
        printf("%d", array[i]);
        if (i != n-1) {
            printf(" ");
        }
    }
    printf("\n");
    
    printf("%d\n", cmp);
    
    free(array);
    
    return 0;
}

Measured memory_bytes: 63188
import math

inp = input().split(" ")
A, B = int(inp[0]), int(inp[1])

# print(int(A * 1/0.08))

possible = int(B * 1/0.10) // 10
# print(possible)

answer = []
for i in range(possible * 10, possible * 10 + 10):
  tax_a = int(i * 0.08)
  tax_b = int(i * 0.1)
  # print(tax_a, tax_b)
  if tax_a == A and tax_b == B:
    answer.append(i)

if len(answer) == 0:
  print(-1)
else:
  print(answer[0])

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

using namespace std;

int n, a, ans;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a;

		if ((i & 1) && (a & 1))
			++ans;
	}

	cout << ans << endl;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> vec(N);
  for(int i = 0; i < M; i++){
    int a ,b;
    cin >> a >> b;
    vec.at(a-1) += 1;
    vec.at(b-1) += 1;
  }
  for(int i = 0; i < vec.size(); i++){
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
main(){
    double a,b;
    cin >> a >> b;
    cout << fixed << setprecision(10) << a/b;


}


Measured memory_bytes: 256
#include <stdio.h>
 
#define N 100
 
int G[N][N], S[N], C[N];
 
void numchk(int a, int k){
    int i;
 
    C[a] = k;
 
    for (i = 1; i <= S[a]; i++){
        if (C[G[a][i]] > k){
            numchk(G[a][i], k + 1);
        }
    }
}
 
int main(void){
    int i,j;
    int n,l;
 
    scanf("%d", &n);
 
    for (i = 1; i <= n; i++){
        C[i] = N * N;
        for (j = 1; j <= n; j++){
            G[i][j] = 0;
        }
    }
 
    for (i = 1; i <= n; i++){
        scanf("%d", &l);
        scanf("%d", &S[l]);
        for (j = 1; j <= S[l]; j++){
            scanf("%d", &G[l][j]);
        }
    }
 
    numchk(1, 0);
 
    for (i = 1; i <= n; i++){
        if (C[i] == N * N){
            C[i] = -1;
        }
        printf("%d %d\n", i, C[i]);
    }
 
    return 0;
}


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

int main(){
    int q, h, s, d;
    cin >> q >> h >> s >> d;
    int n;
    cin >> n;
    
    vector<int> e(4);
    e.at(0) = 8*q;
    e.at(1) = 4*h;
    e.at(2) = 2*s;
    e.at(3) = d;

    long long sum = 0;
    int rps = min({e.at(0), e.at(1), e.at(2), e.at(3)});
    int rps_A = min({e.at(0), e.at(1), e.at(2)});
    while(n>0){
        if(n >= 2 && rps == e.at(3)){
            sum += d;
            n -= 2;
        } else {
            sum += rps_A/2;
            n -= 1;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main()
{
    ll a1,a2,a3,a4,a5,a6,a7,k;
    cin>>a1>>a2>>a3>>a4>>a5>>a6>>a7;
    ll p=min(a1,min(a4,a5)),x=a2+a1/2*2+a4/2*2+a5/2*2;
    if(!p)
        cout<<x<<endl;
    else
        cout<<max(x,max(a2+(p-1)*3+(a1-p+1)/2*2+(a4-p+1)/2*2+(a5-p+1)/2*2,a2+p*3+(a1-p)/2*2+(a4-p)/2*2+(a5-p)/2*2))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int cross(int ax, int ay, int bx, int by, int cx, int cy) {
	int x1 = bx-ax, x2 = cx-ax;
	int y1 = by-ay, y2 = cy-ay;
	return x1*y2 - x2*y1;
}

int main() {
	int n;
	int seq = 0;
	int ax, ay, bx, by, cx, cy;
	while (1) {
		cin >> n;
		if (!n)
			break;
		seq++;
		int area = 0;
		cin >> ax >> ay >> bx >> by;
		for (int i = 0; i < n-2; i++) {
			cin >> cx >> cy;
			area += cross(ax,ay,bx,by,cx,cy);
			bx = cx, by = cy;
		}
		printf("%d %.1f\n", seq, (double)(area>=0.0 ? area : -area) * 0.5);
	}
	return 0;
}

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

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

    int amari_500;
    amari_500 = N % 500;
    if(amari_500 <= A){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <algorithm>

static const std::string kSpaceChars = " \t\n\r\f\v";

inline std::string& rtrim(std::string& str, const std::string& chars = kSpaceChars) {
    str.erase(str.find_last_not_of(chars) + 1);
    return str;
}

inline std::string& ltrim(std::string& str, const std::string& chars = kSpaceChars) {
    str.erase(0, str.find_first_not_of(chars));
    return str;
}

inline std::string& trim(std::string& str, const std::string& chars = kSpaceChars) {
    return ltrim(rtrim(str, chars), chars);
}


class TaskD {
public:
    void solve(std::istream &in, std::ostream &out) {
        int h, w;
        in >> h >> w;

        int n;
        in >> n;

        std::vector<int> row_paint;
        int row = 0;
        int col = 0;
        for (int i = 0; i < n; ++i) {
            int a;
            in >> a;

            while (a > 0) {
                bool left_to_right = (row % 2 == 0);

                if (left_to_right) {
                    int to_paint = std::min(a, w - col);

                    col += to_paint;
                    a -= to_paint;

                    for (int j = 0; j < to_paint; ++j) {
                        row_paint.push_back(i + 1);
                    }

                    if (col == w) {
                        ++row;
                        std::string row_paint_str;
                        for (auto c: row_paint) {
                            row_paint_str += std::to_string(c) + " ";
                        }
                        trim(row_paint_str);
                        out << row_paint_str << '\n';
                        row_paint.clear();
                    }
                } else {
                    int to_paint = std::min(a, col);

                    col -= to_paint;
                    a -= to_paint;

                    for (int j = 0; j < to_paint; ++j) {
                        row_paint.push_back(i + 1);
                    }

                    if (col == 0) {
                        ++row;
                        std::reverse(row_paint.begin(), row_paint.end());
                        std::string row_paint_str;
                        for (auto c: row_paint) {
                            row_paint_str += std::to_string(c) + " ";
                        }
                        trim(row_paint_str);
                        out << row_paint_str << '\n';
                        row_paint.clear();
                    }
                }
            }
        }
    }
};


int main() {
    TaskD solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256