akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

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

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    VAR(i64, H, W);
    i64 ans = 0;

    if (W == 1 || H == 1) {
        print(1);
        return 0;
    }

    if (W % 2 == 1) {
        const i64 k = H / 2;
        dump(k);
        ans += ((W + 1) / 2) * (H - k);
        ans += (W / 2) * k;
    } else {
        ans = (W / 2) * H;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
input()
numbers = list(map(lambda x: int(x), input().split(" ")))
numbers.sort(reverse=True)
alice = 0
bob = 0
isAlice = True;
for number in numbers:
    if isAlice:
        alice += number
        isAlice = False
    else:
        bob += number
        isAlice = True

print(alice - bob)

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

const ll INF = pow(10, 9) + 7;

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i,N) cin >> h[i];
  bool ok =true,aa = true;
  rep(i,N-1){
    if(!aa){
     if(h[i+1]<=h[i]-1){
     ok=false;
     break;
    }
   if(h[i+1]>h[i]){
     aa =true;
     continue;
    }
   }
    if(h[i+1]<h[i]-1){
     ok=false;
     break;
    }
   if(h[i+1]==h[i]-1) aa = false;
  }
  if(ok) cout <<"Yes";
  else cout <<"No";
}


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

int main() {
	int n;
	cin >> n;
	int x = 0, y = 0, z = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (a % 4 == 0) {
			++x;
		} else if (a % 2 == 0) {
			++y;
		} else {
			++z;
		}
	}
	if (y == 0) {
		if (z <= x + 1) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	} else {
		if (z <= x) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc =  new Scanner(System.in);

		int a = sc.nextInt();
		int i = 0;
		while(i*i <= a){
			i++;
			
		}
		System.out.println((i-1)*(i-1));
	}
}

Measured memory_bytes: 21972
/*
[keyence2019] A - Beginning
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

vector<int> N(4);

bool solve() {
    sort(N.begin(), N.end());
    return N == vector<int>{1, 4, 7, 9};
}

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

    cout << (solve() ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
(defvar *n* (read))
(defvar *m* (read))
(defvar *x* (read))
(defvar *y* (read))

(defun set-lst (n)
  (let ((lst (list nil)))
    (dotimes (x n)
      (let ((tmp (read)))
        (push tmp lst)))
    (cdr (reverse lst))))

(defvar *lst-x* (sort (set-lst *n*) #'>))
(defvar *lst-y* (sort (set-lst *m*) #'<))

(defun calc (x y z)
  (cond ((and (< x z) (>= y z) (< *x* z) (>= *y* z))
         t)
        ((> z *y*)
         nil)
        (t (calc x y (1+ z)))))

(defun main ()
  (if (calc (nth 0 *lst-x*) (nth 0 *lst-y*) (1+ *x*))
      (princ "No War")
      (princ "War")))

(main)

Measured memory_bytes: 4456
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		vector<int> v;
		for(int i=0,in;i<n/4;++i){
			cin>>in;
			v.push_back(in);
		}
		int sum=0;
		for(vector<int>::iterator it=v.begin();it<v.end();++it){
			sum+=*it;
		}
		cout<<sum<<"\n";
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  int a,b;
  cin>>a>>b;
  if(a>8||b>8)
    cout<<":(";
  else
    cout<<"Yay!";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
double  dp[3000][3000];
double ans(int ind,double *a,int h)
{if(ind==n)
{if(h>(n-h))
  return 1.0;
else
  return 0.0;}
if(dp[ind][h]!=-1.0)
  return dp[ind][h];
double op1=ans(ind+1,a,h+1)*a[ind];
double op2=ans(ind+1,a,h)*(1-a[ind]);
return dp[ind][h]=op1+op2;
}
int main()
{

cin>>n;
double a[n];
for(int i=0;i<=n;i++)
{for(int j=0;j<=n;j++)
  dp[i][j] = -1.0;

}
for(int i=0;i<n;i++)
cin>>a[i];
double d=ans(0,a,0);
printf("%0.9f",d);

}

Measured memory_bytes: 70784
#include <cstdio>

void process() {
    int H, W;

    do {
        scanf(" %d %d", &H, &W);
        if( H == 0 && W == 0 ) return;

        for(int j = 0; j < W; j++) putchar('#');
        putchar('\n');
        for(int i = 1; i < H-1; i++) {
            putchar('#');
            for(int j = 1; j < W-1; j++) putchar('.');
            putchar('#');
            putchar('\n');
        }
        for(int j = 0; j < W; j++) putchar('#');
        putchar('\n');
        putchar('\n');

    } while( true );
}

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


Measured memory_bytes: 2588
while True:
    a,op,b = map(str,input().split())
    if op == "?" :
        break
    elif op == "+":
        print(int(a) + int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "/":
        print(int(a) // int(b))


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<=a.size();i++)
	{
		if(a[i]=='9')
		{
			cout<<"Yes"<<endl;
			goto pos;	
		}
	}
	cout<<"No"<<endl;
	pos:
	return 0;
}

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

using namespace std;
int a[103],dp[maxn],n,k;
int main(){
    cin >> n >> k;
    for (int i=1;i<=n;i++) cin >> a[i];
    for (int i=1;i<=k;i++){
        for (int j=1;j<=n;j++) if (i>=a[j]) dp[i]|=(!dp[i-a[j]]);
    }
    if (dp[k]) puts("First"); else puts("Second");
}


Measured memory_bytes: 640
import java.util.Scanner;

//Cup
public class Main{

	int[] last;
	int N, M;
	
	int f(int[] c, int from, int to){
		int res = 1;
		boolean con = true;
		while(!(c[0]==(1<<N)-1||c[2]==(1<<N)-1)&&res<=M){
			con = true;
			for(int f=0;f<3&&con;f++)for(int t=0;t<3&&con;t++){
				if(Math.abs(f-t)>1)continue;
				if(from==t&&to==f)continue;
				if(last[c[f]]<=last[c[t]])continue;
				c[t]+=1<<last[c[f]]; c[f]-=1<<last[c[f]];
				from = f; to = t;
				con = false;
			}
			res++;
		}
		return res;
	}
	
	void run(){
		last = new int[1<<15];
		for(int S=0;S<1<<15;S++){
			int k = 14;
			while(k>=0&&((S>>k)&1)==0)k--;
			last[S] = k;
		}
		Scanner sc = new Scanner(System.in);
		for(;;){
			N = sc.nextInt(); M = sc.nextInt();
			if((N|M)==0)break;
			int[] cup = new int[3];
			for(int i=0;i<3;i++){
				int k = sc.nextInt();
				while(k--!=0)cup[i]+=1<<(sc.nextInt()-1);
			}
			if(cup[0]==(1<<N)-1||cup[2]==(1<<N)-1){
				System.out.println(0); continue;
			}
			int res = M+1;
			for(int f=0;f<3;f++)for(int t=0;t<3;t++){
				if(Math.abs(f-t)>1)continue;
				if(last[cup[f]]<=last[cup[t]])continue;
				int[] c = new int[3];
				c[0] = cup[0]; c[1] = cup[1]; c[2] = cup[2];
				c[t]+=1<<last[c[f]]; c[f]-=1<<last[c[f]];
				res = Math.min(res, f(c, f, t));
			}
			System.out.println(M<res?"-1":res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

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


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var a = -1
    var b = -1
    for (i in 1..n){
        val (ta,tb) = readLine()!!.split(" ").map(String::toInt)
        if (a < ta){
            a = ta
            b = tb
        }
    }
    println(a+b)
}

Measured memory_bytes: 56032
#include <stdio.h>
#include <algorithm>
using namespace std;

void solve();
int main() {
	solve();
#ifdef DBG
	while (true);
#endif // DBG
}

void solve() {
	int n, score = 9 * 5;
	scanf("%d", &n);

	for (int i = 1; i < n; i++) {
		int A = i, B = n - i;
		int ac = 0, bc = 0;
		while (A)
			ac += A % 10, A /= 10;
		while (B)
			bc += B % 10, B /= 10;
		score = min(score, ac + bc);
	}
	printf("%d\n", score);
}

Measured memory_bytes: 128
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    static int[] t;
    static int[] x;
    static int[] y;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        System.out.println(n / 3);
    }

}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n;
	cin >> n;
	ll o[n], c[n+1]={0};
	REP(i, 0, n){
		cin >> o[i];
		++c[o[i]];
	}
	ll pos = 0;
	REP(i, 0, n+1){
		pos += c[i]* (c[i] - 1)/2;
		c[i] = (c[i] - 1)*(c[i] - (c[i]-2))/2;
	}
	REP(i, 0, n){
		cout <<  pos - c[o[i]] << endl;
	}
		

}


Measured memory_bytes: 5760
#include<iostream>
using namespace std;
long long int f[101];
long long int digui(int k)
{
	if(k==0) return f[0];
	if(k==1) return f[1];
	if(f[k]!=0) return f[k];
	else return f[k]=digui(k-1)+digui(k-2);
} 
int main()
{
	f[0]=2;
	f[1]=1;
	int n;
	cin>>n;
	digui(n);
	cout<<f[n];
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);

  rep(i, n) cin >> a[i];

  deque<ll> dq;
  rep(i, n) {
    ll idx = lower_bound(dq.begin(), dq.end(), a[i]) - dq.begin();
    if (idx == 0)
      dq.push_front(a[i]);
    else
      dq[idx - 1] = a[i];
  }
  cout << dq.size() << endl;
  return 0;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

int toInt(string s){
	return (int)(s[0]-'0')*100+(int)(s[1]-'0')*10+(int)(s[2]-'0');
}


void solve(){
	int n,t;
	cin>>n>>t;
	int ans=1e8;
	int in=ans;
	while(n--){
		int x,y;
		cin>>x>>y;
		if(y<=t)ans=min(ans,x);
	}
	if(ans==in)cout<<"TLE";
	else cout<<ans;

}


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

Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static final int MOD = 998244353;

	static int add(int a, int b) {
		int res = a + b;
		return res >= MOD ? res - MOD : res;
	}

	static int sub(int a, int b) {
		int res = a - b;
		return res < 0 ? res + MOD : res;
	}

	static int mul(int a, int b) {
		int res = (int) ((long) a * b % MOD);
		return res < 0 ? res + MOD : res;
	}

	static int pow(int a, int e) {
		if (e == 0) {
			return 1;
		}
		int r = a;
		for (int i = 30 - Integer.numberOfLeadingZeros(e); i >= 0; i--) {
			r = mul(r, r);
			if ((e & (1 << i)) != 0) {
				r = mul(r, a);
			}
		}
		return r;
	}

	static int inv(int a) {
		return pow(a, MOD - 2);
	}

	static int facts[], factsInv[];

	static int c(int x, int y) {
		return mul(mul(facts[x + y], factsInv[x]), factsInv[y]);
	}

	static void solve() throws Exception {
		int n = scanInt(), m = scanInt();
		facts = new int[n + 3 * m / 2 + 1];
		facts[0] = 1;
		for (int i = 1; i < facts.length; i++) {
			facts[i] = mul(facts[i - 1], i);
		}
		factsInv = new int[facts.length];
		factsInv[facts.length - 1] = inv(facts[facts.length - 1]);
		for (int i = facts.length - 1; i > 0; i--) {
			factsInv[i - 1] = mul(factsInv[i], i);
		}
		int ans = 0;
		for (int nOdd = m % 2; nOdd <= m && nOdd <= n; nOdd += 2) {
			int cans = c(nOdd, n - nOdd);
			int cans1 = c((3 * m - nOdd) / 2, n - 1);
			int cans2 = mul(nOdd, c((m - nOdd) / 2, n - 1));
			if (nOdd < m) {
				cans2 = add(cans2, mul(n - nOdd, c((m - nOdd) / 2 - 1, n - 1)));
			}
			ans = add(ans, mul(cans, sub(cans1, cans2)));
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 34132
n = int(input())
lst = [[] for i in range(n+1)]
for i in range(n-1):
    ai, bi = map(int, input().split())
    lst[ai].append(bi)
    lst[bi].append(ai)

tf = [0 for i in range(n+1)]
tf[1] = 1
iro = 1
queue = lst[1]
while queue != []:
    iro = -iro
    new_queue = []
    for i in queue:
        if tf[i] == 0:
            tf[i] = iro
            for j in lst[i]:
                if tf[j] == 0:
                    new_queue.append(j)
    queue = new_queue

n_minus = tf.count(-1)
n_plus = tf.count(1)
ans = [0 for i in range(n)]

if n_minus <= n//3:
    bai = 1
    for i in range(1, n+1):
        if tf[i] == -1:
            ans[i-1] = 3 * bai
            bai += 1
    kouho = 1
    for i in range(1, n+1):
        if tf[i] == 1:
            if bai <= n//3:
                ans[i-1] = 3 * bai
                bai += 1
            else:
                ans[i-1] = kouho
                kouho += 1
                if kouho % 3 == 0:
                    kouho += 1

elif n_plus <= n//3:
    bai = 1
    for i in range(1, n+1):
        if tf[i] == 1:
            ans[i-1] = 3 * bai
            bai += 1
    kouho = 1
    for i in range(1, n+1):
        if tf[i] == -1:
            if bai <= n//3:
                ans[i-1] = 3 * bai
                bai += 1
            else:
                ans[i-1] = kouho
                kouho += 1
                if kouho % 3 == 0:
                    kouho += 1

else:
    bai = 1
    kouho1 = 1
    kouho2 = 2
    for i in range(1, n+1):
        if tf[i] == 1:
            if kouho1 <= n:
                ans[i-1] = kouho1
                kouho1 += 3
            else:
                ans[i-1] = 3 * bai
                bai += 1
        else:
            if kouho2 <= n:
                ans[i-1] = kouho2
                kouho2 += 3
            else:
                ans[i-1] = 3 * bai
                bai += 1

print(' '.join(map(str, ans)))

Measured memory_bytes: 64736
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200000;

int n, m;
string st;
int ways[5050][5050];
int walk[5050][5050];

long long fact[N];

long long pw(long long a, long long b)
{
	if (b == 0)
		return 1;
	if (b % 2)
		return a*pw(a, b - 1) % bs;
	return pw(a*a%bs, b / 2);
}

long long inv(long long x)
{
	return pw(x, bs - 2);
}

void add(int&a, int b)
{
	a += b;
	if (a >= bs)
		a -= bs;
}


long long C(long long n, long long m)
{
	if (m > n)
		return 0;
	long long res = fact[n];
	res *= inv(fact[m]);
	res %= bs;
	res *= inv(fact[n - m]);
	res %= bs;
	return res;
}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n;
	cin >> st;
	m = st.size();

	fact[0] = 1;
	for (int i = 0; i < N; i++)
	{
		fact[i] = fact[i - 1] * i%bs;
	}

	ways[0][0] = 1;
	for (int i = 0; i < 5000; i++)
	{
		for (int j = 0; j <= 5000; j++)
		{
			add(ways[i + 1][j + 1], ways[i][j] * 2 % bs);
			add(ways[i + 1][max(j - 1, 0)], ways[i][j]);
		}
	}

	walk[0][0] = 1;
	for (int i = 0; i <= 5000; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			add(walk[i + 1][j+1], walk[i][j]);
			if (j > 1)
				add(walk[i + 1][j - 1], walk[i][j]);
		}
	}

	long long ans = 0;

	for (int start = 0; start <= n; start++)
	{
		int res1 = ways[start][0];
		int rem = n - start;
		if (rem % 2 !=m%2)
			continue;
		if (rem < m)
			continue;
		//cout << res1 << " " << start << endl;

		int rem_ways = walk[n - start][m];
		res1 = 1ll * res1*rem_ways%bs;
		//cout << res1 << endl;
		int ohead_let = (rem - m) / 2;
		//cout << ohead_let << endl;

		//res1 = res1 * 1ll * C(ohead_let + m, m) % bs;
		res1 = res1 * 1ll * pw(2, ohead_let) % bs;
		//cout << res1 << endl;
		ans += res1;
		ans %= bs;
	}
	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int d; cin >> d;

    vector<int> c(26);
    for (int i = 0; i < 26; ++i) {
        cin >> c[i];
    }

    vector<vector<int>> s(d, vector<int>(26));
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }

    vector<int> t(d);
    for (int i = 0; i < d; ++i) {
        cin >> t[i];
        t[i]--;
    }

    vector<int> score(d, 0);
    vector<vector<int>> last(d, vector<int>(26, 0));

    auto re_score = [&](int start) {
        for (int i = start; i < d; ++i) {
            score[i] = (i - 1 >= 0 ? score[i - 1] : 0) + s[i][t[i]];

            if (i - 1 >= 0) {
                last[i] = last[i - 1];
            } else {
                for (int j = 0; j < 26; ++j) {
                    last[0][j] = 0;
                }
            }

            last[i][t[i]] = i + 1;

            int j = i + 1;

            for (int k = 0; k < 26; ++k) {
                score[i] -= c[k] * (j - last[i][k]);
            }
        }
    };

    re_score(0);

    int m; cin >> m;
    vector<pair<int, int>> p(m);
    for (int i = 0; i < m; ++i) {
        int td, tq;
        cin >> td >> tq;
        td--; tq--;

        p[i] = make_pair(td, tq);
    }

    for (int i = 0; i < m; ++i) {
        t[p[i].first] = p[i].second; // d日目をqに変更

        re_score(p[i].first);

        cout << score[d - 1] << endl;
    }
}

Measured memory_bytes: 3968
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n,count int
	fmt.Scan(&n)
	a := make([]int,n)
	for i := 0 ; i < n ; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	for i := 0 ; i < n ; i++ {
		if i%2 == 0{
			count += a[i]
		} else {
			count -= a[i]
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



ll d;
vector<vector<ll>> e;
vector<bool> used;

ll dfs(ll p, ll r){
    ll sum = (r > d)? 1 : 0;
    
    for(auto x : e[p]){
        if(!used[x]){
            used[x] = true;
            sum += dfs(x, r + 1);
        }
    }
    
    return sum;
}

int main() {
    ll n, k;
    cin >> n >> k;
    
    d = (k & 1)? (k - 1) / 2 : k / 2;
    e.resize(n);
    REP(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--;b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    
    ll ans = INF;
    if(k & 1){
        REP(i, n){
            for(auto x : e[i]){
                used.assign(n, false);
                used[i] = true;
                used[x] = true;
                ans = min(ans, dfs(i, 0) + dfs(x, 0));
            }
        }
    }
    else{
        REP(i, n){
            used.assign(n, false);
            used[i] = true;
            ans = min(ans, dfs(i, 0));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	int x=1,ans=0;
	while(x<b){
		x+=(a-1);
		ans++;
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 256
// see https://github.com/LumaKernel/vimfiles/tree/master/snippets/cp-cpp/temp.snip
const bool DEBUG = 1;
/// --- .lumrc Template {{{ ///
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = tuple<ll, ll>;
using P3 = tuple<ll, ll, ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VP = vector<P>;
using VS = vector<string>;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define FORI(i,a,b) for(int i=int(a);i<=int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPI(i,n) FORI(i,0,n)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define RFORI(i,a,b) for(int i=int(b);i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)
#define RREPI(i,n) RFORI(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n";

#define dump(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)<<"\n";
#define dump2(x,y) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n";
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<<"] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)\
<<" , "<<#z<<"="<<(z)<<"\n";

#define SAY(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<(x)<<"\n";

#define YES(x) cout<<((x)?"YES":"NO")<<"\n";
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n";
#define yes(x) cout<<((x)?"yes":"no")<<"\n";

inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;}
inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;}
inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;}
inline int int_in(){int n;cin>>n;return n;}
inline ll ll_in(){ll n;cin>>n;return n;}
inline string string_in(){string n;cin>>n;return n;}
#define oini omajinai_int_in()
#define oinl omajinai_ll_in()
#define oins omajinai_string_in()
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define isInside(y,x) (0<=(y)&&(y)<h&&0<=(x)&&(x)<w)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))
#define fif(x) (get<4>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }

template <typename T> inline void smax(T &a, T b) { a = a > b ? a : b; }
template <typename T> inline void smin(T &a, T b) { a = a < b ? a : b; }

/// }}}--- ///

constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr int MOD = 1e9+7;


ll ans;

int main() {
  int n=ini,a=ini,b=ini;
  if(abs(b-a)%2!=0) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
}

//


Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc068_a.cpp
 * time   : Tue Apr 28 23:18:45 2020
 * quest  : A - ABCxxx
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cout << "ABC" << n << "\n";
  return 0;
}


Measured memory_bytes: 256
# B
if __name__=='__main__':
    N,L = map(int,input().split())
    if L > 0:
        ans = (2*L+N)*(N-1)/2
    elif L+N-1<0:
        ans = (2*L+N-2)*(N-1)/2
    else:
        ans = (2*L+N-1)*N/2
    print(int(ans))

Measured memory_bytes: 3060
###############################################################################
#Imports
import collections
import itertools
from functools import lru_cache
import sys
import math
from decimal import Decimal
###############################################################################
#Constants
MOD = int(1e9)+7
###############################################################################
#Helper
def helper():
	pass
###############################################################################
#Solver
def solve():
	s=input()
	t=input()
	count = 0
	for i in range(len(s)):
		if s[i]!=t[i]: count+=1
	print(count)
###############################################################################
#Driver
t = 1
for _ in range(t):
	solve()
###############################################################################


Measured memory_bytes: 78280
import math
a,b,h,m = map(int,input().split())
pi = math.pi
x1 = a * math.sin(2 * pi * (h/12 + m/12/60))
y1 = a * math.cos(2 * pi * (h/12 + m/12/60))
x2 = b * math.sin(2*pi * m/60)
y2 = b * math.cos(2*pi * m/60)
print(math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2))

Measured memory_bytes: 9576
#include <bits/stdc++.h>
#define Sekai_No_Owari return 0

using namespace std;
typedef long long ll;
void chmax(int & a, int b) { if (a <= b) a = b; }

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

	int res = 0, tmp = 0, pre = 0, h;
	for (int i = 0; i < n; i++) {
		scanf("%d", &h);
		if (pre >= h) tmp++;
		else tmp = 0;

		chmax(res, tmp);
		pre = h;
	}
	cout << res << endl;

	Sekai_No_Owari;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int n_ans = 0;
    int m_ans = 0;
    if(n>1){
        n_ans++;
        n_ans *= n*(n-1);
        n_ans /= 2;
    }

    if(m>1){
        m_ans++;
        m_ans *= m*(m-1);
        m_ans /= 2;
    }

    cout << n_ans + m_ans << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll kai[400001], inv[400001];
ll n, k;
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n /= 2;
  }
  return res;
}
void init() {
  kai[0] = 1LL;
  for (ll i = 1LL; i <= n; i++) {
    kai[i] = kai[i - 1] * i;
    kai[i] %= MOD;
  }
  inv[n] = mod_pow(kai[n], MOD - 2LL, MOD);
  for (ll i = n - 1; i >= 0; i--) {
    inv[i] = inv[i + 1] * (i + 1);
    inv[i] %= MOD;
  }
}

ll comb(ll r, ll c) {
  ll res;
  res = kai[r];
  res *= inv[c];
  res %= MOD;
  res *= inv[r - c];
  res %= MOD;
  return res;
}
int main() {
  scanf("%lld%lld", &n, &k);
  ll ans = 0;
  n *= 2;
  init();
  n /= 2LL;
  ans = comb(2LL * n - 1LL, n);
  ll x, y;
  for (ll i = k + 1LL; i < n; i++) {
    x = comb(i + n - i - 1, i);
    x *= comb(n, i);
    x %= MOD;
    ans -= x;
    if (ans < 0) {
      ans += 10LL * MOD;
      ans %= MOD;
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 6400
n, m, x = gets.split().map(&:to_i)
books = Array.new(n).map{Array.new(m)}

n.times do |i|
  books[i] = gets.split().map(&:to_i)
end

ans = 100000000

(1..2**n-1).each do |i|
  sum = 0
  abi = Array.new(m, 0)
  i.to_s(2).rjust(n, '0').split('').reverse.each_with_index do |bit, index|
    next if bit == "0"
    book = books[index]
    sum += book[0]
    book.each_with_index do |a, j|
      next if j == 0
      abi[j-1] += a
    end 
  end
  if abi.all?{|num| num >= x}
    ans = [ans, sum].min
  end
end

puts ans == 100000000 ? -1 : ans 

Measured memory_bytes: 14388
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    REP(a,3){
        int t1 = 0;
        int t2 = 0;
        CIN(A);CIN(B);CIN(C);CIN(D);CIN(E);CIN(F);
        t1 = A * 3600 + B * 60 + C;
        t2 = D * 3600 + E * 60 + F;
        int t = t2 - t1;
        cout<< t/3600 <<" "<<t%3600/60 <<" "<<t%60<<endl;
    }

    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
template<class T> bool umin(T &x,T y) { if (x<y) return 0; x=y; return 1; }
template<class T> bool umax(T &x,T y) { if (x>y) return 0; x=y; return 1; }
using ll = long long;
using ld = long double;

int const INF=1e9;

struct dist_func {
	ll l1,r1,l2,r2,m1,m2;
	vector<ll> ts;
	
	dist_func(ll a,ll b,ll c,ll d,ll e,ll f): l1(a),r1(b),l2(c),r2(d),m1(e),m2(f) {
		ts.push_back(0);
		while (true) {
			ll nt=find_next(ts.back());
			if (nt==INF) break;
			ts.push_back(nt);
		}
	}
	
	ll eval(ll t) const {
		return max({r1+t,r2-t,m2})-min({l1+t,l2-t,m1});
	}
	
	ll operator()(ll t) const {
		return eval(t);
	}
	
	ll find_next(ll t) {
		ll s=eval(t+1)-eval(t);
		ll l=t,r=INF;
		while (l<r) {
			ll m=l+(r-l)/2;
			if (eval(m+1)-eval(m)==s) l=m+1; else r=m;
		}
		return l;
	}
};

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	ll r1,r2,l1,l2,x1,x2,d1,d2,u1,u2,y1,y2;
	r1=l1=x1=d1=u1=y1=INF;
	r2=l2=x2=d2=u2=y2=-INF;
	
	int N;
	cin>>N;
	rep(i,0,N) {
		ll x,y;
		string s;
		cin>>x>>y>>s;
		x*=2;
		y*=2;
		switch (s[0]) {
			case 'R':
				umin(r1,x),umax(r2,x),umin(y1,y),umax(y2,y);
				break;
			case 'L':
				umin(l1,x),umax(l2,x),umin(y1,y),umax(y2,y);
				break;
			case 'U':
				umin(u1,y),umax(u2,y),umin(x1,x),umax(x2,x);
				break;
			case 'D':
				umin(d1,y),umax(d2,y),umin(x1,x),umax(x2,x);
				break;
			default:
				throw;
		}
	}

	dist_func dx(r1,r2,l1,l2,x1,x2);
	dist_func dy(u1,u2,d1,d2,y1,y2);

	ll res=dx(0)*dy(0);
	for (ll t:dx.ts) umin(res,dx(t)*dy(t));
	for (ll t:dy.ts) umin(res,dx(t)*dy(t));
	cout<<ld(res)/4<<"\n";	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,k,a[N],b[N],c[N];
int dp[N][3];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    printf("%d\n",max(max(dp[n][0],dp[n][1]),dp[n][2]));
}


Measured memory_bytes: 2560
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
q = sum(a)
for i in range(n):
  if a[i] <= b[i]:
    a[i+1] -= b[i]-a[i]
    a[i] = 0
    if a[i+1] < 0:
        a[i+1] = 0 
  elif a[i] > b[i]:
    a[i] -= b[i]
    
print(q - sum(a))

Measured memory_bytes: 24156
/**
		Author : Avi J Patel
		University : DA-IICT
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
int main()
{
	int n,l;
	cin>>n>>l;
	int sum=(n*(n-1))/2;
	int sum1=sum+(l*n);
	if(l>0)
	{
		cout<<sum1-(l);
	}
	else if(l>(-n) && l<=0)
	{
		cout<<sum1;
	}
	else
	{
		cout<<sum1-(l+n-1);
	}
	return 0;
}








Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.size();
    ll S = 0, P = 0;
    rep(i,n){
        if(s[i] == 'S') ++S;
        else{
            if(S > 0){
                ++P;
                --S;
            }
        }
        chmax(S, 0LL);
    }
    ll ans = n - P*2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int N;
vector<int> a, b;

long long calc(int shift)
{
	// T
	long long t = (1 << shift);
	//cout << n << endl;
	vector<int> aa(N), bb(N);
	for(int i=0; i<N; i++){
		aa[i] = a[i] % (t*2);
		bb[i] = b[i] % (t*2);
	}

	sort(bb.begin(), bb.end());
	//cout << "aa : ";
	//for(int i=0; i<N; i++)
	//	cout << aa[i] << " ";
	//cout << endl;
	//cout << "bb : ";
	//for(int i=0; i<N; i++)
	//	cout << bb[i] << " ";
	//cout << endl;

	long long cnt = 0;
	for(int i=0; i<N; i++){
		for(int j=1; j<=2; j++){
			int c = 2 * j -1;
			int lt = c * t;
			int rt = lt + t;
			auto left = lower_bound(bb.begin(), bb.end(), lt-aa[i]);
			auto right = lower_bound(bb.begin(), bb.end(), rt-aa[i]);
			cnt += right - left;
			//cout << aa[i] << " : [" << lt << ", " << rt << ") : " << lt-aa[i] << " " << rt-aa[i] << " : " << right - left << endl;
		}
	}

	return (cnt%2 == 1 ? t : 0);
}

int main(void)
{
	cin >> N;

	a = vector<int>(N);
	for(int i=0; i<N; i++)
		cin >> a[i];

	b = vector<int>(N);
	for(int i=0; i<N; i++)
		cin >> b[i];

	long long ret = 0;
	for(int i=0; i<30; i++){
		ret += calc(i);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3432
# 棒の本数
n = gets.to_i
# 棒の長さ
a = gets.split.map(&:to_i).sort
# 答えの変数
sum = 0
# 全探索
(n - 2).times do |i|
  ((i + 1)...(n - 1)).each do |j|
    next if a[i] == a[j]
    ((j + 1)...n).each do |k|
      next if a[i] + a[j] <= a[k] || a[j] == a[k]
      sum += 1
    end
  end
end
puts sum

Measured memory_bytes: 14384
A,B,C=map(int,input().split())
L=[A,B,C]
L.sort()
ans=0
s=(L[-1]-L[0])//2
L[0]=L[0]+2*s
t=(L[-1]-L[1])//2
L[1]=L[1]+2*t
L.sort()
a=0
if L[0]!=L[1]:
    a=2
elif L[1]!=L[2]:
    a=1
print(s+t+a)

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int x;
  cin >> x;
  if (x < 1200) cout << "ABC" << '\n';
  else cout << "ARC" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3604
S = raw_input()
S1, S2 = [], []
 
ans = pool = 0
for i in xrange(len(S)):
    if S[i] == "/" and len(S1) > 0:
        j = S1.pop()
        ans += i - j
        a = i - j
        while (len(S2) > 0 and S2[-1][0] > j):
            a += S2.pop()[1]
        S2.append([j, a])
    if S[i] == "\\":
        S1.append(i)
print ans
if len(S2) > 0:
    print len(S2), " ".join(map(str, [a for j, a in S2]))
else:
    print 0

Measured memory_bytes: 6956
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int main() {
  int N;
  int ans = 0;
  cin >> N;
  vector<ull> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  for(int i = 0; i < N - 2; i++) {
    for (int j = i; j < N - 1; j++) {
      for (int k = j; k < N; k++) {
        if(L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
          if (L[i] + L[j] + L[k] > 2 * max(L[i], max(L[j], L[k]))) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
from fractions import gcd
from functools import reduce

lcm = lambda a, b: b // gcd(a, b) * a
mod = 10 ** 9 + 7

N, *A = map(int, open(0).read().split())

L = reduce(lcm, A) % mod
print(sum(L * pow(a, mod - 2, mod) for a in A) % mod)

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


vl num(52);
vl p(52);
ll ans = 0;
vl add(52, -1);


ll dfs(int level, ll nokori) {
  if (nokori == num[level]) {
    ans += p[level];
    return nokori;
  }
  if (level == 0) {
    ans += 1;
    return 1;
  }
  ll res = 0;
  nokori--;
  res++;
  if (nokori > 0) {
    if (nokori >= num[level - 1]) {
      res += num[level - 1];
      ans += p[level - 1];
      nokori -= num[level - 1];
    }
    else {
      ll temp = dfs(level - 1, nokori);
      nokori -= temp;
      res += temp;
    }
  }
  if (nokori > 0) {
    ans++;
    nokori--;
    res++;
  }
  if (nokori > 0) {
    if (nokori >= num[level - 1]) {
      res += num[level - 1];
      ans += p[level - 1];
      nokori -= num[level - 1];
    }
    else {
      ll temp = dfs(level - 1, nokori);
      nokori -= temp;
      res += temp;
    }
  }
  if (nokori > 0) {
    nokori--;
    res++;
  }
  return res;
}
      
  
int main() {
  int n;
  cin >> n;
  ll x;
  cin >> x;
  num[0] = 1;
  p[0] = 1;
  rep (i, n) {
    num[i + 1] = 3 + 2 * num[i];
    p[i + 1] = 1 + 2*p[i];
  }
  dfs(n, x);
  cout << ans << endl;
}
  


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

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

int main() {
	int max, count=0;
        char A[100], B[100], C[100];
	cin >> max;
	cin >> A;
	cin >> B;
	cin >> C;

	for(int j=0; j<max; j++) {
		int flag1=0, flag2=0, flag3=0;
		
		if (A[j] == B[j]) flag1 = 1;
		if (A[j] == C[j]) flag2 = 1;
		if (B[j] == C[j]) flag3 = 1;
	
		if (flag1 == 1 && flag2 == 1) continue;
		if (flag1 == 0 && flag2 == 0 && flag3 == 0) {
                   count = count+2;
                    continue;
               }
		
		count++;
	}

cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#D解説実装
n,q = map(int,input().split())
l = [0 for i in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    l[b-1] = (a-1)
ans = [0 for _ in range(n)]
p = [list(map(int,input().split())) for i in range(q)]
for p1 in p:
    ans[p1[0]-1] += p1[1]
for i in range(1,n):
    ans[i] += ans[l[i]]
print(" ".join(map(str,ans)))

Measured memory_bytes: 83744
# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 22:17:58 2019

@author: over-
"""

import numpy as np

a,b,x=map(int,input().split())

S=x/a
if S > a*b/2:
    c=2*S/a-b
    tan=(b-c)/a
    deg=np.rad2deg(np.arctan(tan))
else:
    c=2*S/b
    tan=b/c
    deg=np.rad2deg(np.arctan(tan))
    
print(deg)

Measured memory_bytes: 12424
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned int llu;
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define YUGEN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define BPC(x)  __builtin_popcountll(x)
#define test() ll t; cin>>t; while(t--)
#define gcd(a,b)  __gcd(a,b)
#define SIZE 26
ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

int main()
 {
    YUGEN;
      // test()
      // {
        // ll a,b;
       // cin>>a>>b;
       // ll ans=0;
        //if(a<b)
        //{
         //  int x=(b-a);
         //  if(x&1)
        //   ans++;
        //   else
        //   ans+=2;
       // }
      //   else if(a==b)
      //   ans=0;
      //   else if(a>b)
      //   {
      //     int x=(a-b);
      //     if(x&1)
      //     ans+=2;
      //     else
      //     ans++;
          
      //   }
      //   cout<<ans<<endl;
      // }
      ll n;
      cin>>n;
      ll a[n];
      for(int i=0;i<n;i++)
      cin>>a[i];
      ll sum=0;
      for(int i=0;i<n;i++)
      {
        sum+=a[i];
        sum%=mod;
      }
      ll ans=0;
      for(int i=0;i<n;i++)
      {
        sum-=a[i];
        if(sum<0)
        sum+=mod;
        ans+=a[i]*sum;
        ans%=mod;
      }
      cout<<ans;
 }




Measured memory_bytes: 5216
import math

n = int(input())
ret = 10000000000000000
for i in range(1, int(math.sqrt(float(n))+5.0)):
    if n % i:
        continue;
    ret = min(ret, max(int(math.log10(n//i)), int(math.log10(i))) + 1)

print(ret)


Measured memory_bytes: 3188
#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>
 
using namespace std;


int main(){
    int C;
    cin >> C;
    if(C >= 30){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}


Measured memory_bytes: 3096