akhauriyash/Code-Regression huggingface dataset:
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
ans=[]
1.upto(N-1) do|i|
  (i+1).upto(N) do|j|
    ans<<[i,j].join(" ") unless i+j==N+(N+1)%2
  end
end
puts ans.size
ans.each{|x| puts x}

Measured memory_bytes: 14756
#include <utility>
#include <vector>

template <typename T>
int selection_sort(std::vector<T> &A) {
    int swap_cnt = 0;

    for(std::size_t j = 0; j + 1 < A.size(); ++j) {
        std::size_t argmin = j;
        for(std::size_t i = j + 1; i < A.size(); ++i) {
            if(A[i] < A[argmin]) argmin = i;
        }
        if(j != argmin) ++swap_cnt;
        std::swap(A[j], A[argmin]);
    }

    return swap_cnt;
}

#include <iostream>
int main() {
    int n;
    std::cin >> n;
    std::vector<int> A(n);
    for(int i = 0; i < n; ++i) std::cin >> A[i];
    
    int swap_cnt = selection_sort<int>(A);
    for(std::size_t k = 0; k < A.size(); ++k) std::cout << A[k] << (k + 1 == A.size() ? '\n' : ' ');
    std::cout << swap_cnt << std::endl;
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

string s;
int a,b,c,n;
ll ans,tmp;
int main(void){
    cin>>n;
    ans=1;tmp=2;
    REP(i,0,n-1){
        ll ttmp=tmp+ans;
        tmp=ans;
        ans=ttmp;
        
    }
    p(ans);
}


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

int main()
{
  int a,b,c;
  int res=0;
  cin >> a>>b>>c;

  if(a<=c && c<=b) cout << "Yes" <<endl;
  else  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#define MEM 1046527
#define LEN 14
using namespace std;
using ll = long long;

class Dict
{
private:
    char data[MEM][LEN];
    ll h1(ll key){ return key % MEM; }
    ll h2(ll key){ return 1 + (key % (MEM - 1)); }
    ll get_key(char s[]){
        ll sum = 0;
        ll p = 1;
        for(ll i = 0; i < strlen(s); i++){
            sum += p*(s[i] - 'A' + 1);
            p *= 5;
        }
        return sum;
    }
public:
    Dict(){}

    bool find(char s[]){
        ll i = 0;
        while(1){
            ll key = get_key(s);
            ll h = (h1(key) + i*h2(key)) % MEM;
            if(!strcmp(data[h], s)) return 1;
            else if(!strlen(data[h])) return 0;
            i++;
        }
    }

    bool insert(char s[]){
        ll i = 0;
        while(1){
            ll key = get_key(s);
            ll h = (h1(key) + i*h2(key)) % MEM;
            if(!strcmp(data[h], s)) return 1;
            else if(!strlen(data[h])) {
                strcpy(data[h], s);
                return 0;
            }
            i++;
        }
    }
};

int main(){
    ll n; cin >> n;
    char com[LEN];
    char s[LEN];
    Dict dict;
    vector<string> ans;
    for(ll i = 0; i < n; i++){
        scanf("%s %s", com, s);
        if(com[0] == 'i') dict.insert(s);
        else ans.push_back((dict.find(s)) ? "yes" : "no");
    }
    for(string a : ans) cout << a << endl;
    return 0;
}


Measured memory_bytes: 40608
n, m = map(int, input().split())
C = [1]*n
X = [0]*n
X[0] = 1
for i in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    if X[x] == 1:
        C[x] -= 1
        C[y] += 1
        X[y] = 1
        if C[x] == 0:
            X[x] = 0
    else:
        C[x] -= 1
        C[y] += 1
#print(C)
#print(X)
print(sum(X))


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

namespace EDPCC
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int N = int.Parse(Console.ReadLine());
            long[,] h = new long[N + 1,3];

            long[] a = new long[N + 1];
            long[] b = new long[N + 1];
            long[] c = new long[N + 1];
            for (int i = 1; i <= N; i++)
            {
                // スペース区切りの整数の入力
                string[] input = Console.ReadLine().Split(' ');
                a[i] = int.Parse(input[0]);
                b[i] = int.Parse(input[1]);
                c[i] = int.Parse(input[2]);
            }
            h[1,0] = a[1];
            h[1,1] = b[1];
            h[1,2] = c[1];

            for (int i = 2; i <= N; i++)
            {
                h[i,0] = Math.Max(h[i - 1,1] + a[i], h[i - 1,2] + a[i]);
                h[i,1] = Math.Max(h[i - 1,0] + b[i], h[i - 1,2] + b[i]);
                h[i,2] = Math.Max(h[i - 1,0] + c[i], h[i - 1,1] + c[i]);
            }
            long max = h[N,0];
            if (max < h[N,1]) max = h[N,1];
            if (max < h[N,2]) max = h[N,2];
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 19648
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll n, k;
    cin >> n >> k;
    VL a(n);
    REP(i,n) a[i] = in();
    sort(ALL(a));
    VL neg, pos;
    ll zero = 0;
    REP(i,n){
        if (a[i] < 0) neg.push_back(a[i]);
        else if (a[i] > 0) pos.push_back(a[i]);
        else zero++;
    }
    ll ok = 1e18, ng = -1e18;
    while (ok - ng > 1){
        ll p = (ok + ng) / 2;
        ll c = 0;
        // cout << ng << " " << ok << endl;
        // cout << "check " << p << endl;
        for (ll x : neg){
            if (p == 0) c += n - neg.size();
            else if (p > 0){
                ll b = - (p / (-x));
                c += n - (lower_bound(ALL(neg), b) - neg.begin());
            }else{
                ll b = (-p - x - 1) / (-x);
                c += pos.end() - lower_bound(ALL(pos), b);
            }
        }
        // cout << c << endl;
        if (p >= 0) c += n * zero;
        for (ll x : pos){
            if (p == 0) c += n - pos.size();
            else if (p > 0){
                ll b = p / x;
                c += neg.size() + zero + (upper_bound(ALL(pos), b) - pos.begin());
            }else{
                ll b = - ((-p + x - 1) / x);
                c += upper_bound(ALL(neg), b) - neg.begin();
            }
        }
        // cout << c << endl;
        for (ll x : a) if (x * x <= p) c--;
        c /= 2;
        // cout << c << endl;
        if (c >= k) ok = p;
        else ng = p;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,p,k,l,Max,ans,t,ans2,B,r,b,d,ind,x,y,dp[200001][4];
pair <long long,pair<long long,long long>> a[2000001];
int main () {
    cin>>n;
    for (i=1;i<=n;i++) {
        cin>>a[i].first>>a[i].second.first>>a[i].second.second;
    }
    for (i=1;i<=n;i++) {
        dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i].first;
        dp[i][2]=max(dp[i-1][1],dp[i-1][3])+a[i].second.first;
        dp[i][3]=max(dp[i-1][1],dp[i-1][2])+a[i].second.second;
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]))<<endl;
    return 0;
}

Measured memory_bytes: 10496
#include <stdio.h>
#include <string.h>
#define pai 3.14159265
int main(void){
	char s[81];
	int buf;
	int i,j;
	
	while(fgets(s,sizeof(s),stdin) != '\0'){
		for(i = 0;i < 26;i++){
			for(j = 0;j < strlen(s);j++){
				if(s[j] >= 65&&s[j] <= 90){
					buf = s[j]-65+1;
					buf %= 26;
					s[j] = buf+65;
				}else if(s[j] >= 97&&s[j] <= 122){
					buf = s[j]-97+1;
					buf %= 26;
					s[j] = buf+97;
				}
					
			}
			if(strstr(s,"this") != NULL||strstr(s,"that") != NULL||strstr(s,"the") != NULL)
			printf("%s",s);
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int A[50];
	A[0] = 1;
	A[1] = 1;
	for (int i = 2; i < 50; i++)
		A[i] = A[i - 1] + A[i - 2];
	int N;
	scanf("%d", &N);
	printf("%d\n", A[N]);

	return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>

int main(void){
        int i, j, k, N, v;
        int A[10000];

        scanf("%d", &N);
        for(i=0; i<N; i++){
                scanf("%d", &A[i]);
        }
        for(k=0; k<N-1; k++){
                printf("%d ", A[k]);
        }
        printf("%d\n", A[k]);
        for(i=1; i<N; i++){
                v = A[i];
                j = i-1;
                while(j >= 0 && A[j] > v){
                        A[j+1] = A[j];
                        j--;
                }
                A[j+1] = v;
                for(k=0; k<N-1; k++){
                        printf("%d ", A[k]);
                }
                printf("%d\n", A[k]);
        }

        return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
#define MAXDIGIT 40

long long up[1<<20], down[1<<20];
long long down_max[1<<20];

int main() {
    int n; cin >> n;
    long long k; cin >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    long long count[MAXDIGIT][2];
    memset(count, 0, sizeof(count));
    for (int i = 0; i < n; i++) {
        for (int digit = 0; digit < MAXDIGIT; digit++) {
            if (a[i] & (1LL << digit)) count[digit][1]++;
            else count[digit][0]++;
        }
    }
    int half = MAXDIGIT / 2;
    for (int bit = 0; bit < (1 << half); bit++) {
        for (int i = 0; i < half; i++) {
            int digit = i + half;
            if (bit & (1 << i)) {
                up[bit] += (count[digit][0] << digit);
            } else {
                up[bit] += (count[digit][1] << digit);
            }
        }
    }
    for (int bit = 0; bit < (1 << half); bit++) {
        for (int i = 0; i < half; i++) {
            if (bit & (1 << i)) {
                down[bit] += (count[i][0] << i);
            } else {
                down[bit] += (count[i][1] << i);
            }
        }
    }
    for (int i = 0; i < (1 << half); i++) {
        down_max[i] = down[i];
        if (i != 0) down_max[i] = max(down_max[i], down_max[i-1]);
    }
    long long ans = 0;
    for (long long upbit = 0; upbit < (1 << half); upbit++) {
        long long remain = k - (upbit << half);
        if (remain < 0) continue;
        if (remain < (1LL << half)) {
            ans = max(ans, up[upbit] + down_max[remain]);
        } else {
            ans = max(ans, up[upbit] + down_max[(1<<half) - 1]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

void call(int n)
{
    int i;
    for(i = 1; i <=n; i++){
        int tmp = i;
        if(tmp % 3 == 0)
            cout << ' ' << i;
        else for(; tmp; tmp /=10)
                if(tmp % 10 == 3){
                    cout << ' ' << i;
                    break;
                }
    }
    cout << endl;
}


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

Measured memory_bytes: 1160
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    String n = kbd.next();
	    if(n.length()!=0){
		String[] c = new String[n.length()];
		int i;
		int count = 0;
		for(i=0; i<n.length(); i++){
		    c[i] = n.substring(i, i+1);
		    //System.out.println(c[i]);
		}
		//System.out.println();
		if(c.length%2 == 1) {
		    if(c[c.length/2].equals("(") || c[c.length/2].equals(")")) {
			count++;	
			// System.out.println("a");
		    }
		}

		for(i=0; i<c.length/2; i++){
		    if(!check(c[i], c[c.length-i-1])) {
			count++;
			//System.out.println("b"+i);
		    }
		}

		System.out.println(count);
	    }
	}
    }

    static boolean check(String a, String b){
	if(a.equals("(")){
	    if(!b.equals(")")) return false;   
	}
	else if(a.equals(")")){ 
	    if(!b.equals("(")) return false;   
	}
	else{
	    if(!a.equals(b)) return false;
	}
	return true;
    }
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	ll x;
	cin>>x;
	for(ll i=0;i<=5000000;i++){
		ll now=i*1.08;
		if(now==x){
			cout <<i;
			return 0;
		}
	}
	cout << ":(";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  string a;
  int ans=0;
  cin>>a;
  int n=atoi(a.c_str());
 

  for(int i=1;i<=n;i++){
    string st=to_string(i);
    int k=st.length();
    if(k%2==1) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n;
string s;

bool read()
{
	if (scanf("%s", buff) != 1)
		return false;

	s = buff;
	return true;
}

int sol(int c)
{
	if (!count(s.begin(), s.end(), char('a' + c)))
		return inf;

	string t = s;
	int res = 0;

	while (count(t.begin(), t.end(), char('a' + c)) != size(t))
	{
		++res;
		string tt;

		forn (i, size(t) - 1)
			if (t[i] == char('a' + c) || t[i + 1] == char('a' + c))
				tt.push_back(char('a' + c));
			else
				tt.push_back(t[i]);

		t = tt;
	}

	return res;
}

void solve()
{
	int ans = inf;

	forn (i, 26)
		ans = min(ans, sol(i));

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

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif
 
	while (read())
		solve();
 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int cnt;
int w,h;
char map[24][24];
void func(int y,int x)
{
    cnt++;
    map[y][x]='#';
    int ny,nx;
    int dx[]={0,0,1,-1};
    int dy[]={1,-1,0,0};
    for(int i=0;i<4;i++)
    {
        ny=y+dy[i];
        nx=x+dx[i];
        if(map[ny][nx]=='.'&&0<=ny&&0<=nx&&ny<h&&nx<w)func(ny,nx);
    }
    return;
}
int main()
{
    while(cin>>w>>h,w)
    {
        cnt=0;
        int x,y;
        for(int i=0;i<24;i++)
        {
            for(int j=0;j<24;j++)
            {
                map[i][j]='#';
            }
        }
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                cin>>map[i][j];
                if(map[i][j]=='@')
                {
                    y=i;
                    x=j;
                }
            }
        }
        func(y,x);
        cout<<cnt<<endl;
    }
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int ans = 0, suma = 0;
  int a[n];
  rep(i,n){
    cin >> a[i];
    suma += a[i];
  }
  rep(i,n){
    if(a[i]>=(double)suma*1.0/(double)(4*m))ans++;
  }
  if(ans>=m)cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 3640
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int a = sc.nextInt();
		int b = sc.nextInt();

		if((a+b)%2!=0){
			System.out.println("IMPOSSIBLE");
		}else{
			System.out.println((a+b)/2);

		}

	}
}


Measured memory_bytes: 21076
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

const int MOD = 1000000007;

ll mypow(ll x, ll n) {
  if(n == 0) return 1;
  if(n % 2 == 1) return mypow(x*x%MOD, n/2)*x%MOD;
  return mypow(x*x%MOD, n/2);
}

ll fac[200000+10];
ll invfac[200000+10];

inline ll cmb(ll n, ll k) {
  if(k > n || k < 0) return 0;
  return fac[n] * invfac[k] % MOD * invfac[n-k] % MOD;
}

int n;
int vs[100000+10];

ll memo[210][100000+10];
ll solve(int i, int x) {
  ll &res = memo[i][x];
  if(res < 0) {
    if(i == n) {
      res = x;
    } else {
      ll r1 = solve(i+1, x%vs[i]) * mypow(n-i, MOD-2) % MOD;
      ll r2 = solve(i+1, x) * (n-i-1) % MOD * mypow(n-i, MOD-2) % MOD;
      res = (r1 + r2) % MOD;
    }
  }
  return res;
}

int main(void) {
  fac[0] = 1;
  REP(i, 200000) {
    fac[i+1] = (fac[i] * (i+1)) % MOD;
  }
  invfac[200000] = mypow(fac[200000], MOD-2);
  for(int i = 200000; i > 0; --i) {
    invfac[i-1] = (invfac[i] * i) % MOD;
  }

  int X;
  scanf("%d%d", &n, &X);
  REP(i, n) {
    scanf("%d", &vs[i]);
  }
  sort(vs, vs + n);
  reverse(vs, vs + n);
  memset(memo, -1, sizeof memo);
  ll ex = solve(0, X);
  ll res = ex * fac[n] % MOD;
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 167936
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define lli long long int  
#define ll  long long 
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl   vector<lli>
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0);
const int INF = 1e9 + 7;
//ull power(ull a,ull b){ ull res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}
bool sortinrev(const pair<int,int> &a,   const pair<int,int> &b) {  if(a.second==b.second) return a.first>b.first;  return (a.second > b.second);} 

void WetPitch()
{
    
string s;
cin>>s;
lli cnt=0,ans=0;
for(int i=0;i<3;i++)
{
	if(s[i]=='R')
		cnt++;
	else
		{
			ans=max(cnt,ans);
			cnt=0;
		}
}
ans=max(ans,cnt);
cout<<ans<<endl;
 

}     
signed main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	lli tst;
    tst=1; 
    //cin>>tst;
    while(tst--)
    WetPitch();
    return 0;
 } 

Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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--)
#define mp make_pair
#define fi first
#define sc second
ll a,b,c,k;
int main(){
	cin >> a >> b >> c >> k;

	if(abs(a - b) > 1000000000000000000) {
		cout << "Unfair" << endl;
	}else if(k % 2 == 1) {
		cout << b - a << endl;
	}else 
		cout << a - b << endl;

	return 0;
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main 
{
	static long[] bar = new long[200];
	
	static long getbar(int num)
	{
		if(num < 0)return 1;
		else return bar[num];
	}
	
	static long getdp(int x, int y)
	{
		if(x < w && y < h)return dp[x][y];
		else return 0;
	}

	static long[][] dp;
	static long MOD = 1000000007l;
	static boolean[][] cache;
	static int w,h,k;
	
	static long go(int x, int y)
	{
		if(cache[x][y])return dp[x][y];
		long cur = 0;
		if(y == h)
		{ //no more moves
			if(x == k)cur = 1;
		}
		else
		{
//			System.out.println("from " + x + " " + y);
			long curm = 0;
			//straight ahead
			curm = getbar(x-1);
			curm = (curm *getbar(w-x-2))%MOD;
			curm = (curm * go(x, y+1))%MOD;
			cur = (cur + curm)%MOD;
//			System.out.println("straight: " + curm);
			
			//left
			if(x>0)
			{
				curm = getbar(x-2);
				curm = (curm *getbar(w-x-2))%MOD;
				curm = (curm * go(x-1, y+1))%MOD;
				cur = (cur + curm)%MOD;
//				System.out.println("left: " + curm);
			}
			//right
			if(x<w-1)
			{
				curm = getbar(x-1);
				curm = (curm *getbar(w-x-3))%MOD;
				curm = (curm * go(x+1, y+1))%MOD;
				cur = (cur + curm)%MOD;
//				System.out.println("right: " + curm);
			}
			
		}
		
		cache[x][y] = true;
		dp[x][y] = cur;
		return cur;
	}
	
	
	public static void main(String[] args) 
	{
		long MOD = 1000000007l;
		Scanner sc = new Scanner(System.in);
		
		bar[0] = 1;
		bar[1] = 2;
		for(int i = 2; i < 200; i++)
		{
			bar[i] = (bar[i-2] + bar[i-1])%MOD;
		}
		
		
		h = sc.nextInt();
		w = sc.nextInt();
		k = sc.nextInt()-1;

		dp = new long[w][h+1];
		cache = new boolean[w][h+1];
		
		System.out.println(go(0,0));
		

	}

}


Measured memory_bytes: 23764
/// a.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    int ans = 1;
    while (1ll * ans * (ans + 1) / 2 < n) ++ans;
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int n;
	cin >> n;
	
	cout << n * n * n << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		string a,s;
		cin>>a>>s;
		reverse(all(a));
		rep(i,a.size()){
			if(a[i]=='A')
				reverse(all(s));
			else if(a[i]=='J')
				s=s.substr(s.size()-1)+s.substr(0,s.size()-1);
			else if(a[i]=='M'){
				rep(j,s.size())if(isdigit(s[j])){
					s[j]++;
					if(s[j]=='9'+1)s[j]='0';
				}
			}else if(a[i]=='P'){
				rep(j,s.size())if(isdigit(s[j])){
					s[j]--;
					if(s[j]=='0'-1)s[j]='9';
				}
			}else if(a[i]=='C')
				s=s.substr(1)+s.substr(0,1);
			else if(a[i]=='E'){
				string tmp="";
				int t=0;
				if(s.size()%2){t=1;tmp=s[s.size()/2];}
				s=s.substr(s.size()/2+t)+tmp+s.substr(0,s.size()/2);
			}
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct point{
  ll x,y;
};
bool comp(point a, point b)
{
  return a.y<b.y;
}

int main()
{
  ll n;
  cin>>n;
  vector<point>a(n);;
  for(ll i=0;i<n;i++)
  {
    ll x,y;
    cin>>x>>y;
    a[i].x=x-y;
    a[i].y=x+y;
    //cout<<a[i].x<<" "<<a[i].y<<"\n";
  }
  ll res=1;
  sort(a.begin(), a.end(),comp);
  ll prev=a[0].y;
  for(ll i=1;i<n;i++)
  {
    if(a[i].x>=prev)
    {  res++;
     	prev=a[i].y;
    }
    
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>


using namespace std;

int main()
{
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int mn;
    int mx;
    int co=0;
    for(int i=1;i<n-1;i++){
        mn=min(p[i-1],min(p[i],p[i+1]));
        mx=max(p[i-1],max(p[i],p[i+1]));
        if(p[i]!=mn&&p[i]!=mx){
            co++;
        }
    }
    cout << co<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<list>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}

ll lcm(ll a1,ll b1){
	if(a1*b1==0){return 0;}
	return (a1*b1/gcd(a1,b1));
}

int main() {

	ll a,b,c,d;
	cin>>a>>b>>c>>d;

	ll s=lcm(c,d);
	ll ans=b/c+b/d-b/s;
	ans-=(a-1)/c+(a-1)/d-(a-1)/s;
	cout<<b-a-ans+1<<endl;

	return 0;
}


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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

int main() {
  string L;
  cin >> L;
  int N = L.length();
  vector<vector<modint>> dp(N + 5, vector<modint>(2));
  dp[0][1] = 1;
  for (int i = 0; i < N; i++) {
    if (L[i] == '1') {
      dp[i + 1][0] = dp[i][0] * 3 + dp[i][1];
      dp[i + 1][1] = dp[i][1] * 2;
    } else {
      dp[i + 1][0] = dp[i][0] * 3;
      dp[i + 1][1] = dp[i][1];
    }
  }
  modint ans = dp[N][0] + dp[N][1];
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, m, s, c;
    int a[3];
    fill(a, a + 3, -1);
    cin >> n >> m;
    if (n == 1 && m == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (n > 1 && m == 0) {
        cout << pow(10, n - 1) << endl;
        return 0;
    }
    while (m--) {
        cin >> s >> c;
        if (a[s - 1] >= 0 && a[s - 1] != c) {
            cout << -1 << endl;
            return 0;
        }
        a[s - 1] = c;
    }
    for (int i = (n == 1 ? 0 : pow(10, n - 1)); i < pow(10, n); ++i) {
        string v = to_string(i);
        for (int j = 0; j < n; ++j) {
            if (v[j] - '0' != a[j] && a[j] >= 0)
                break;
            if (j == n - 1) {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# from typing import *
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def solve(A, B):
    print(A*B)


def main():
    A, B = map(int, input().split())
    solve(A, B)

if __name__ == '__main__':
    main()
'''
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh test_py.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh etest_py.sh
cd ~/Desktop/Programming/AtCoder/contest/abc169/abc169_a && sh submit_py.sh
'''


Measured memory_bytes: 9204
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
//    #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//        freopen("output.txt","w",stdout);
//    #endif
}
int main()
{
    vok();
    int n,m;
    IN n>>m;
    vector<double> v(n);
    double sum=0.0;
    loop(i,0,n)
    {
        IN v[i];
        sum+=(v[i]+0.0);
    }
    double cond= (1.0 * sum);
    cond/=(4.0*m);
    int count=0;
    loop(i,0,n)
    {
        if((v[i]+0.0)>=(cond+0.0))
        {
            count++;
        }
    }
    if(count>=m)
    {
        OUT "Yes"<<endl
    }
    else
    {
        OUT "No"<<endl
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC095A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int ans = 700;
            for (int i = 0; i < 3; i++)
            {
                if (S[i] == 'o') ans += 100;
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13140
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int s,d,t;
		Scanner scanner = new Scanner(System.in);
		
		d = scanner.nextInt();
		t = scanner.nextInt();
		s = scanner.nextInt();
		
		if(s * t >= d)
			System.out.println("Yes");
			
		else 
			System.out.println("No");
	}
}

Measured memory_bytes: 35528
dp = [[0 for j in range(4001)] for i in range(4)]
for j in range(4001):
  if j <= 1000:
    dp[0][j] = 1
for i in range(1,4):
  for j in range(4001):
    for k in range(0, min(1000, j) + 1):
      dp[i][j] += dp[i - 1][j - k]

while True:
  try:
    n = int(input())
  except:
    break
  print(dp[3][n])


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

ll ans = -10e10;
int n;
ll k;
vector<int> p;
vector<ll> c;

void simulate(int st) {
  int next = st;

  // get loop cnt
  ll loop_score = 0;
  ll loop_cnt = 0;
  while(true) {
    next = p[next];
    loop_score += c[next];
    loop_cnt++;
    if(next == st) break;
  }

  ll score = 0;

  // get rest cnt
  ll rest_cnt = k;
  if(loop_score > 0 && k / loop_cnt >= 2) {
    score += loop_score * (k / loop_cnt - 1);
    rest_cnt -= loop_cnt * (k / loop_cnt - 1);
    ans = max(ans, score);
  } else if(loop_score <= 0) {
    rest_cnt = loop_cnt;
  }

  // calc score
  while(rest_cnt > 0) {
    score += c[next];
    next = p[next];
    rest_cnt--;
    ans = max(ans, score);
  }
  return;
};

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

  p.resize(n+1);
  rep(i, n) cin >> p[i+1];

  c.resize(n+1);
  rep(i, n) cin >> c[i+1];

  rep(i, n) {
    simulate(i+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if L[i] == L[j]:
                continue
            for k in range(j+1, N): 
                if L[i] == L[k] or L[j] == L[k]:
                    continue
                if (((L[i] + L[j]) > L[k]) and ((L[j] + L[k]) > L[i]) and ((L[i] + L[k])) > L[j]):
                     ans += 1
    print(ans)

main()

Measured memory_bytes: 73276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define endl '\n'

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

	int n, w;
	cin >> n >> w;
	ll dp[n+1][100005], wi, vi;
	for(int i=0; i<=n; i++)
		for(int j=0; j<100005; j++)
			dp[i][j] = 1e10;

	for(int i=1; i<=n; i++)
	{
		cin >> wi >> vi;
		for(int j=1; j<vi; j++)
			dp[i][j] = dp[i-1][j];
		dp[i][vi] = min( wi , dp[i-1][vi] );
		for(int j=vi+1; j<100005; j++)
			dp[i][j] = min( wi + dp[i-1][j-vi] , dp[i-1][j] );
	}
	ll max = 0;
	for(int i=0; i<=n; i++)
		for(int j=0; j<100005; j++)
			if( dp[i][j] <= w && j > max )
				max = j;
	cout << max;
	return 0;
}

Measured memory_bytes: 79232
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
 
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
 
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
 
struct Edge{
    int to,cost;
    Edge(int to,int cost) :to(to),cost(cost){}
    Edge(){}
};
struct Lost{
    int s,t;
    Lost(int s,int t) :s(s),t(t){}
    Lost(){}
};
struct State{
    int v;
    int cost;
    int bit1,bit2;
    State(int v,int cost,int bit1,int bit2):
        v(v),cost(cost),bit1(bit1),bit2(bit2){}
    State(){}
 
    bool operator>(const State rth) const {
        return this->cost>rth.cost;
    }
};
int n,m,k,p;
vector<Edge> G[1003];
Lost lost[10];
int dp[1003][1<<6][1<<6];
 
int dijk() {
    rep(i,1003) rep(j,1<<6) rep(c,1<<6) dp[i][j][c]=INF;
    dp[p][0][0]=0;
    priority_queue<State,vector<State> ,greater<State> > que;
    que.push(State(p,0,0,0));
 
    while(que.size()) {
        State s=que.top(); que.pop();
        if(s.bit2+1==(1<<k)) break;
        if(dp[s.v][s.bit1][s.bit2]>s.cost) continue;
 
        rep(i,G[s.v].size()) {
            Edge e=G[s.v][i];
            rep(a,k) {
                if(lost[a].s==e.to) {
                    if(dp[e.to][s.bit1|1<<a][s.bit2]>dp[s.v][s.bit1][s.bit2]+e.cost) {
                        dp[e.to][s.bit1|1<<a][s.bit2]=dp[s.v][s.bit1][s.bit2]+e.cost;
                        que.push(State(e.to,dp[e.to][s.bit1|1<<a][s.bit2],s.bit1|1<<a,s.bit2));
                    }
                }
                if(lost[a].t==e.to&&(s.bit1>>a)&1) {
                    if(dp[e.to][s.bit1][s.bit2|1<<a]>dp[s.v][s.bit1][s.bit2]+e.cost) {
                        dp[e.to][s.bit1][s.bit2|1<<a]=dp[s.v][s.bit1][s.bit2]+e.cost;
                        que.push(State(e.to,dp[e.to][s.bit1][s.bit2|1<<a],s.bit1,s.bit2|1<<a));
                    }
                }
            }
            if(dp[e.to][s.bit1][s.bit2]>dp[s.v][s.bit1][s.bit2]+e.cost) {
                dp[e.to][s.bit1][s.bit2]=dp[s.v][s.bit1][s.bit2]+e.cost;
                que.push(State(e.to,dp[e.to][s.bit1][s.bit2],s.bit1,s.bit2));
            }
        }
    }
 
    int ans=INF;
    rep(i,n) ans=min(ans,dp[i][(1<<k)-1][(1<<k)-1]);
 
    return ans;
}
 
int main() {
    cin>>n>>m>>k>>p;
    p--;
    rep(i,m) {
        int x,y,w;
        cin>>x>>y>>w;
        x--,y--;
        G[x].pb(Edge(y,w));
        G[y].pb(Edge(x,w));
    }
    rep(i,k) {
        int s,t;
        cin>>s>>t;
        s--,t--;
        lost[i].s=s;
        lost[i].t=t;
    }
    int ans=dijk();
    if(ans==INF) cout<<"Cannot deliver"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19236
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  ll sum=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    sum += A[i];
  }
  int ans=0;
  ll half;
  ll sum_2=0;
  half = sum/2;
  for(int i=0; i<N; i++){
    if(sum_2+A[i] >= half || sum_2+A[i] >= half+1){
      ll sa;
      if(half-sum_2 >= sum_2+A[i]-half){
        half = sum/2;
      }else{
        half = (sum+1)/2;
      }
      sa = min(half-sum_2, sum_2+A[i]-half);
      if(sum%2 == 1){
        sa--;
        ans++;
      }
      ans += sa*2;
      break;
    }
    sum_2 += A[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    string S;
    int N, size;
    cin >> N >> S;
    size = S.size();
    for(int i=0; i < size; ++i){
        S.at(i) = S.at(i) + N;
    }
    for(int i=0; i < size; ++i){
        if(S.at(i) > 'Z'){
        S.at(i) += 'A'-'Z';
        S.at(i) += 'A'-'B';
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
char grid[2][3],enter;
int i,j,f=0;
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
scanf("%c",&grid[i][j]);
}
scanf("%c",&enter);
}
i=0;
for(j=0;j<3;j++)
{
if(grid[i][j]!=grid[1-i][2-j])
{f=1;
break;
}

}
if(f==1)
printf("\nNO");
else printf("\nYES");
return 0;
}

Measured memory_bytes: 128
$N=<>;
@ab=sort{@$b[1]-@$a[1]}map[glob<>],1..$N;
@cd=sort{@$a[0]-@$b[0]}map[glob<>],1..$N;
for$cd(@cd){
	for$ab(@ab){
		if(@$ab[0]<@$cd[0]&&@$ab[1]<@$cd[1]){
			++$%;
			$ab=[inf,inf];
			last
		}
	}
}
print$%


Measured memory_bytes: 896
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


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


if __name__ == '__main__':
    s = sread()
    for i in range(10):
        if str(i) * 2 in s:
            print("Bad")
            exit()

    print("Good")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=2e3+10;
vector<int>G[N];
int n,x,y;
ll ans[N],dis[N][N];
struct node
{
    int u,w;
    bool operator <(const node &o)const{
        return w>o.w;
    }
};
void bfs(int root)
{
    priority_queue<node>que;
    que.push({root,0});
    dis[root][root]=0;
    while(que.size())
    {
        node now=que.top();que.pop();
        for(int v:G[now.u]){
            if(dis[root][v]>now.w+1){
                dis[root][v]=now.w+1;
                que.push({v,dis[root][v]});
            }
        }
    }
}
int main()
{
	cin>>n>>x>>y;
	for(int i=1;i<=n-1;++i){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
	}
	G[x].push_back(y);
	G[y].push_back(x);
	memset(dis,0x3f3f3f3f3f3f3f3f,sizeof(dis));
	for(int i=1;i<n;++i){
        bfs(i);
	}
	for(int i=1;i<n;++i){
        for(int j=i+1;j<=n;++j){
            //printf("i:%d j:%d dis:%lld\n",i,j,dis[i][j]);

            ans[dis[i][j]]++;
        }
	}
	rep(i,1,n-1) printf("%lld\n",ans[i]);
}


Measured memory_bytes: 32000
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<' ';
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    vint v(n), c(n);
    rep(i,n) cin>>v[i];
    rep(i,n) cin>>c[i];
    vint vd(n);
    rep(i,n) vd[i] = v[i]-c[i];
    int ans = 0;
    rep(i,n){
        if(vd[i]>0)ans += vd[i];
    }
    cout<<ans<<endl; return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

const int INF = 1e9+7;

using ipair = pair<int, int>;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

ll N, K;
vector<ll> A;
vector<ll> cnt(64);
vector<ll> original_pattern(64);
ll judge;
string K_str;



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

    // original count
    rep(i, 64){
        if(K>>i & 1) original_pattern[i]=1;
    }
    reverse(original_pattern.begin(), original_pattern.end());


    A.resize(N);
    rep(i, N) cin >> A[i];

    // cnt
    for(ll num: A){
        rep(i, 64){
            if(num>>i & 1) cnt[i]++;
        }
    }
    reverse(cnt.begin(), cnt.end());

    judge = N/2 + N%2;

    vector<ll> ans_pattern(64);

    bool flipped = false;
    rep(i, 64){
        int one_cnt = cnt[i];
        int zero_cnt = N - cnt[i];
        if(zero_cnt >= judge){
            // 0 -> 1
            if(original_pattern[i]==0){
                if(!flipped){
                    ans_pattern[i] = 0;
                }else{
                    ans_pattern[i] = 1;
                }
            }else{
                ans_pattern[i] = 1;
            }
        }else{
            // 1 -> 0
            if(original_pattern[i]==1 && !flipped) flipped = true;
            ans_pattern[i] = 0;
        }
    }

    // rep(i, 64) cout << cnt[i] << " ";
    // rep(i, 64) cout << original_pattern[i] << " ";
    // rep(i, 64) cout << ans_pattern[i] << " ";
    // cout << endl;

    reverse(ans_pattern.begin(), ans_pattern.end());
    reverse(cnt.begin(), cnt.end());

    ll ans = 0;
    ll mul = 1;
    rep(i, 64){
        // cout << "==" << endl;
        // cout << "i:" << i << endl; 
        if(ans_pattern[i] == 1){
            // cout << "added:" << (N - cnt[i])*mul << endl;
            ans += (N - cnt[i])*mul;
        }else{
            // cout << "added:" << cnt[i]*mul << endl;
            ans += cnt[i]*mul;
        }
        mul *= 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 2110000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
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;
    }
}
// 二項係数計算
long long 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;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    // 前処理
    COMinit();

    int k;
    string s;
    cin >> k >> s;
    int n = s.size();

    ll ans = 0;

    rep(i,k+1){
        ll tmp = 1;

        tmp = mod_pow(26, i, MOD);

        tmp = tmp * COM(k-i+n-1, n-1) % MOD * mod_pow(25, k-i, MOD) % MOD;

        ans = (ans + tmp) % MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 54784