akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           printf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,k,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};

bool chk(ll x,ll pos){return (bool)(x&(1<<pos));}
ll Set(ll x,ll pos){return x=x|(1<<pos);}
ll clr(ll x,ll pos){return x=x&~(1<<pos);}

ll n,m;
double dp[305][305][305];

double fn(ll one,ll two,ll three)
{
    if(one<0 || two<0 || three<0 || (one+two+three)==0)return 0;
    double &z=dp[one][two][three];
    if(z!=-1.0)return z;
    z=1.0+one/double(n)*fn(one-1,two,three)+two/double(n)*fn(one+1,two-1,three)+three/double(n)*fn(one,two+1,three-1);
    z=(n*z)/double(one+two+three);
    return z;
}

int main()
{
    ll var;
    for(i=0;i<=300;i++)for(j=0;j<=300;j++)for(k=0;k<=300;k++)dp[i][j][k]=-1.0;
    sfl(n);
    z=0,c=0,x=0;
    for(i=0;i<n;i++)
    {
        sfl(y);
        if(y==1)z++;
        if(y==2)x++;
        if(y==3)c++;
    }
    double zz=fn(z,x,c);
    pf("%.15lf\n",zz);
}


Measured memory_bytes: 219008
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC118 {
    class C {
        static void Main() => CustomMain();

        static void Solve() {
            var n = ReadInt();
            var a = ReadIntArray();

            long ans = a[0];
            for (int i = 0; i < n - 1; i++) {
                ans = GCD(ans, a[i + 1]);
            }

            WriteAnswer(ans);
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }
    }
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define MOD 1000000007

using namespace std;

template <class T, T M>
class modulo {
public:
    T data;

    modulo(T data = 0) : data(data % M) {
    }

    modulo operator+(const modulo &x) const {
        return modulo(data + x.data);
    }

    modulo operator-(const modulo &x) const {
        return modulo(data + (M - x.data));
    }

    modulo operator*(const modulo &x) const {
        return modulo(data * x.data);
    }

    modulo operator/(const modulo &x) const {
        return modulo(data * x.inv().data);
    }

    modulo operator+=(const modulo &x) {
        data = (data + x.data) % M;
    }

    modulo operator-=(const modulo &x) {
        data = (data + (M - x.data)) % M;
    }

    modulo operator*=(const modulo &x) {
        data = (data * x.data) % M;
    }

    modulo operator/=(const modulo &x) {
        data = (data * x.inv().data) % M;
    }

    modulo inv() const {
        return _pow(M - 2);
    }

    template <class Integer>
    modulo operator^(Integer n) const {
        if (n >= 0) {
            return _pow(n);
        } else {
            return _pow(M - 1 - (-n) % (M - 1));
        }
    }

    friend std::ostream& operator<<(std::ostream &os, const modulo &x) {
        os << x.data;
        return os;
    }

private:
    template <class NonNegativeInteger>
    modulo _pow(NonNegativeInteger n) const {
        modulo result(1);
        modulo x(*this);
        while (n) {
            if (n & 1) {
                result *= x;
            }
            x *= x;
            n >>= 1;
        }
        return result;
    }
};

using ll = long long;
using M = modulo<ll, MOD>;

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    //--H; --W; --A; --B;
    vector<M> factorial(H + W + 1), inv_factorial(H + W + 1);
    factorial[0] = inv_factorial[0] = 1;
    FOR(i, 1, H + W + 1) {
        factorial[i] = M(i) * factorial[i - 1];
        inv_factorial[i] = factorial[i].inv();
    }
    auto C = [&](int n, int k) {
        return factorial[n] * inv_factorial[k] * inv_factorial[n - k];
    };
    M result = 0;
    REP(i, H - A) {
        int x1 = i;
        int y1 = B - 1;
        int x2 = H - 1 - x1;
        int y2 = W - 1 - 1 - y1;
        result += C(x1 + y1, x1) * C(x2 + y2, x2);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3328
first,second = gets.split(" ")
a,b= gets.split(' ').map(&:to_i)
third = gets
long = first.length
flag = 0
compare=0
while flag==0 &&compare<long
  if first[compare]!=third[compare]
    flag=1
  end
  compare+=1
end

if flag==1
  puts a
  puts b-1
else
  puts a-1
  puts b
end


Measured memory_bytes: 1788
import math
a, b, x = map(int, input().split())
if ((a ** 2) * b) / 2 <= x:
    print(math.degrees(math.atan((a ** 2 * b - x) / (a ** 2) / a * 2)))
else:
    print(90 - math.degrees(math.atan(x / (a * b) / b * 2)))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

import sys
import os


def input_to_list():
    return list(map(int, input().split()))

def get_column(M, i):
    lst = []
    for row in M:
        lst.append(row[i])
    return lst

def dot(lst0, lst1):
    if len(lst0) != len(lst1):
        print('error')
    else:
        s = 0
        for i in range(len(lst0)):
            s += lst0[i] * lst1[i]
        return s

n, m, l = input_to_list()

A = []
for i in range(n):
    A.append(input_to_list())

B = []
for i in range(m):
    B.append(input_to_list())

C = []
for i in range(n):
    C_row = []
    for j in range(l):
        row = A[i]
        col = get_column(B, j)
        C_row.append(dot(row, col))
    C.append(C_row)

# print
for row in C:
    print(*row)

Measured memory_bytes: 9212
#!/usr/bin/env python3
 
import sys
# 以下を記述しないとTLEになる, 何故？
from heapq import heappushpop, heapify, heapreplace
from collections import defaultdict
# ---- ここまで -----------------------
 
S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()
 
ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1
 
print(ans)

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  cout << fixed << setprecision(10);
  int n,k,sum = 0;
  int ans = 0;
  cin >> n >> k;
  vector<int>num(n);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  for (int i = 0; i < k; i++) {
    sum += num.at(i);
    ans = sum;
  }
  for (int i = 0; i < n-k; i++) {
    sum = sum - num.at(i) + num.at(k+i);
    ans = max(ans,sum);
  }
  cout << (double)(ans+k) / 2 << endl;
  
}

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

int main (){
  int n;
  string s;
  cin >> n >> s;
  long long ans = 0;
  long long  r, g, b;
  int k;
  r = count(s.begin(), s.end(), 'R');
  g = count(s.begin(), s.end(), 'G');
  b = count(s.begin(), s.end(), 'B');
  ans = r * g * b;
  for(int j = 1; j < n; j++){
    for(int i = 0; i < j; i++){
      k = 2 * j - i;
      if(k < n){
	if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
      }
    }
  }
 
  cout << ans << endl;
}


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

using namespace std;
using ll=long long;
int main(){
    ll n;
    cin>>n;
    ll ans=n*2;
    for (ll i = 1; i*i <= n; ++i) {
        if(n%i!=0)continue;
        ans=min(ans,i+(n/i));
    }
    cout<<ans-2<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}



int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      cin>>n;


      m=n/1000;

      m=n-(m*1000);

     if(!m)cout<<0<<endl;

     else cout<<1000-m<<endl;


}



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

using namespace std;

int main() {
    int n,AC=0,WA=0,TLE=0,RE=0;
   cin>>n;
   string s[n];
    for (int i = 0; i <n ; ++i) {
        cin >> s[i];
        if(s[i]=="AC")
            AC++;
        else if (s[i]=="WA")
            WA++;
        else if(s[i]=="TLE")
            TLE++;
        else
            RE++;
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE;
}




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

int main(){
    string n;
    cin>>n;
    if(n[0]=='7'||n[1]=='7'||n[2]=='7'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3616
n = int(input())
A = list(map(int, input().split()))

li = []
for i in range(n):
    li.append(A[i] - i - 1)
li.sort()

if n == 1:
    print(0)
elif n % 2 == 0:
    l = n // 2
    s = 0
    for i in range(l):
        s += li[i]
    print(sum(li)- 2 * s)
else:
    l = (n - 1) // 2
    s = 0
    for i in range(l):
        s += li[i]
    print(sum(li) - 2 * s - li[l])


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

int main()
{
    int N, M;

    cin >> N >> M;
    
    cout << N * (N - 1) / 2 + M*(M - 1) / 2;
    return 0;
}

Measured memory_bytes: 256
import bisect
#二分探索をするライブラリ

n = int(input())
L = sorted(map(int,input().split()))
ans = 0

# c <= b <= a とする

for i in range(n-2):
    for j in range(i+1,n-1):
        a = L[n-1-i]
        b = L[n-1-j]
        
        if a-b < b:
            ans += (n-1-j) - bisect.bisect_left(L,a-b+1)
        
print(ans)

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class C {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;in>>n;
        vector<vector<ll>> vv(n,vector<ll> (26,0));

        rep(i,n){
            string s;in>>s;
            rep(j,s.size()){
                vv.at(i).at(s.at(j)-'a')++;
            }
        }

        string res;
        rep(j,26){
            ll cnt=51;
            rep(i,n){
                cnt=min(cnt,vv.at(i).at(j));
            }
            res += string(cnt, j+'a');

        }
        out<<res<<endl;

	}
};


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


Measured memory_bytes: 380
while(1):
	m, f, r = map(int, input().split())
	if m == -1 and f == -1 and r == -1:
		break
	
	if m == -1 or f == -1:
		print('F')
	elif m + f >= 80:
		print('A')
	elif m + f >= 65:
		print('B')
	elif m + f >= 50:
		print('C')
	elif m + f >= 30:
		if r >= 50:
			print('C')
		else:
			print('D')
	else:
		print('F')

Measured memory_bytes: 7624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	int copy = n;
	int sum = 0;
	while (copy > 0) {
		sum += copy % 10;
		copy /= 10;
	}
	if (n%sum == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
vector<int> to[1000000];
int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v;
    rep(i,m){
        int a,b;
        cin >> a >>b;
        a--;
        b--;
        v.emplace_back(a,b);
    }
    sort(v.begin(),v.end());
    int left = v[0].first;
    int right = v[0].second;
    int cnt = 1;
    rep(i,m-1){
        int nleft = v[i+1].first;
        int nright = v[i+1].second;
        if(nleft < right){
            if(nright < right){
                right = nright;
            }
            left = nleft;
        }else{
            cnt++;
            left = nleft;
            right = nright;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 24824
import java.util.*;

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

        int D = sc.nextInt();
        int G = sc.nextInt() / 100;

        int[] p = new int[D];
        int[] c = new int [D];

        for (int i = 0; i < D; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt() / 100;
        }

        int minQNum = 1000000;

        NEXT_PTN: for (int i = 0; i <= Math.pow(2, D) - 1; i++) {
            String binary = Integer.toBinaryString(i);
            String dlenZeros = "";
            for (int j = 0; j < D; j++) dlenZeros += "0";
            if (binary.length() < D) {
                binary = dlenZeros.substring(0, D - binary.length()).concat(binary);
            }

            int score = 0;
            int qnum = 0;

            for (int j = 0; j < D; j++) {
                if (binary.charAt(j) == '1') {
                    score += (j + 1) * p[j] + c[j];
                    qnum += p[j];
                }
            }

            if (score >= G) {
                if (qnum < minQNum) {
                    minQNum = qnum;
                }

                continue;
            }

            for (int j = D - 1; j >= 0; j--) {
                if (binary.charAt(j) == '1') {
                    continue;
                }

                int remain = G - score;
                if (remain > (j + 1) * (p[j] - 1)) {
                    continue NEXT_PTN;
                }

                int remainNum = (int) (Math.ceil(remain / (j + 1.0)));
                qnum += remainNum;
                break;
            }

            if (qnum < minQNum) minQNum = qnum;
        }

        System.out.println(minQNum);
    }
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	string s[n];
	rep(i, n) {
		cin >> s[i];
	}
	
	ll cnt = 0;
	rep(i, n) {
		rep(j, s[i].length() - 1) {
			if (s[i][j] == 'A' and s[i][j + 1] == 'B') {
				cnt++;
				s[i][j] = 'C';
				s[i][j + 1] = 'C';
			}
		}
	}
	
	bool allba = true;
	ll bcnt = 0;
	ll acnt = 0;
	rep(i, n) {
		if (s[i][0] == 'B') {
			bcnt++;
			if (s[i][s[i].length() - 1] != 'A') {
				allba = false;
			}
		}
		if (s[i][s[i].length() - 1] == 'A') {
			acnt++;
			if (s[i][0] != 'B') {
				allba = false;
			}
		}
	}
//	cout << allba << endl;
	
	if (n == 1) {
		cout << cnt << endl;
	} else if (bcnt == 0 or acnt == 0) {
		cout << cnt << endl;
	} else if (allba) {
		cout << cnt + bcnt - 1 << endl;
	} else {
		cout << cnt + min(bcnt, acnt) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 768
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.max(0,a-b*2));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 24532
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		double x = 0;
		for(int i=0;i<N;i++){
			x += 1.0 / (double) A[i];
		}
		Console.WriteLine(1/x);
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int h, w;
	cin >> h >> w;
	vector<string> maze(h);
	rep(i,h) cin >> maze[i];
	int ans = 0;
	rep(si, h) {
		rep(sj, w) {
			if (maze[si][sj] == '#') continue;
			queue<pii> q;
			vector<vector<int>> d(h, vector<int> (w, INF));
			auto update = [&](int i, int j, int x) {
				if (d[i][j] != INF) return;
				d[i][j] = x;
				q.push(pii(i, j));
			};
			update(si, sj, 0);
			while (!q.empty()) {
				auto p = q.front(); q.pop();
				for (int k = 0; k < 4; k++) {
					int ni = dy[k] + p.first;
					int nj = dx[k] + p.second;
					if (0 > ni || ni >= h || 0 > nj || nj >= w) continue;
					if (maze[ni][nj] == '#') continue;
					update(ni, nj, d[p.first][p.second] + 1);
				}
			}
			rep(y,h) rep(x,w) {
				if (d[y][x] == INF) continue;
				ans = max(ans, d[y][x]);
			}
		}
	}
	cout << ans << endl;
}

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

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

int main() {

	int a, b, i;

	cin >> a >> b;
	for (i = 1; i < 4; i++) {
		if ((a*b*i) % 2 == 1) {
			cout << "Yes";
			break;
		}
		else {
			cout << "No";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 888
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    while(n!=0) {
        int num = n%10;
        if(num ==1) 
        {
            a.pb(9);
        }else if(num==9){
            a.pb(1);
        }
        n = n/10;
    }
reverse(a.begin(), a.end());
for(int i = 0 ; i < a.size() ; i++){
    cout << a[i];
}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1000000000+7;
static const double PI = 3.141592653589793;
vector<long long> vecmodfact(2,1);

long long modpow(long long x, long long n, long long mod = 0) {
  if (mod == 0) {
      long long res=1;
    while (n > 0) {
      if (n%2 == 1) {
        res = ( res*x );
      }
      x = (x*x);
      n /= 2;
    }
    return res;
  }

  long long res=1;
  while (n > 0) {
    if (n%2 == 1) {
      res = ( res*x ) % mod;
    }
    x = (x*x) % mod;
    n /= 2;
  }
  return res;
}

long long modinverse(long long x, long long mod) {
  // mod must be prime number.
  return modpow(x, mod-2, mod);
}

long long modfact(long long n, long long mod) {
  if (vecmodfact.size()-1 >= n) return vecmodfact.at(n);
  int i=vecmodfact.size();
  vecmodfact.resize(n+1);
  for (; i<=vecmodfact.size()-1; i++) {
    vecmodfact.at(i) = vecmodfact.at(i-1)*i % mod;
  }
  return vecmodfact.at(n);
}

long long modcomb(long long m, long long n, long long mod){
  if (m < n || n < 0) return 0;
  if (n == 0 || n == m) return 1;
  long long ans = modfact(m,mod) * modinverse(modfact(n,mod), mod) % mod;
  ans = ans * modinverse(modfact(m-n,mod), mod) % mod;
  return ans;
}



int main() {
  unsigned long long a, b100;
  double b;
  cin >> a >> b;
  b100 = b*100+0.5;

  unsigned long long ans = a*b100;
  ans = ans / 100;

  cout << ans << endl;
}

Measured memory_bytes: 3676
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

int in() { int x; scanf("%d", &x); return x; }
int min(int a,int b){
  if(a > b) return b;
  return a;
}

int main() {
  int K, S, i, ans;
  ans = 0;
  scanf("%d %d", &K, &S);

  for (int x=0;x<=min(S, K);x++) {
    for (int y=0;y<=K;y++){
      int z = S - x - y;
      if(0<=z && z <=K) {
        ans++;
      }
    }
  }
  printf("%d",ans);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}


int main()
{
	int a, b, c, d, e;
	int k;

	cin >> a >> b >> c >> d >> e >> k;

	int antena[5] = {a, b, c, d, e};

	bool is_candidate = false;

	for (int i = 0; i < 5; ++i)
	{
		for (int j = i + 1; j < 5; ++j)
		{
			if (antena[j] - antena[i] > k)
			{
				is_candidate = true;
			}
		}
	}

	if (is_candidate)
	{
		cout << ":(" << endl;
	}
	else
	{
		cout << "Yay!" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func g(x int) int {
	return x * (x + 1) / 2
}
func main() {
	sc := NewScanner()
	N := sc.NextInt()
	ans := 0
	for j := 1; j <= N; j += 1 {
		ans += j * g(N/j)
	}
	fmt.Println(ans)

}

func getSieves(N int) []int {
	field := make([]bool, N+1)
	sieves := make([]int, 0)
	for i := 2; i <= N; i++ {
		if !field[i] {
			for k := i * i; k <= N; k += i {
				field[k] = true
			}
			sieves = append(sieves, i)
		}
	}
	return sieves
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int>> sw(n);
  for(int i=0; i<m; i++) {
    int k;
    cin>>k;
    for(int j=0; j<k; j++) {
      int s;
      cin>>s;
      sw[s-1].push_back(i);
    }
  }
  bool p[m];
  for(int i=0; i<m; i++) {
    cin>>p[i];
  }

  int ans = 0;
  for(int bit=0; bit<(1<<n); bit++) {
    bool light[m];
    for(int i=0; i<m; i++) light[i]=false;

    for(int i=0; i<n; i++) {
      if((bit>>i)&1) {
        for(int on : sw[i]) {
          light[on] = !light[on];
        }
      }
    }

    bool ok = true;
    for(int i=0; i<m; i++) {
      if(light[i]!=p[i]) {
        ok = false;
        break;
      }
    }
    if(ok) ans++;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3588
#include<iostream>

typedef long long ll;

int main()
{
	ll n;
	std::cin >> n;
	
	ll sum = 0;
	for( int i = 0; i != n; ++i )
	{
		ll p;
		std::cin >> p;
		sum += p;
	}

	std::cout << sum / n << std::endl;

	return 0;
}

Measured memory_bytes: 1156
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    # ダブったカードは好きな順に2枚ずつ減らせる
    M = N - len(set(A))
    if M % 2:
        M += 1
    return N - M


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 26640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll k,a,b; cin>>k>>a>>b;
    if(b/k-a/k>0)cout<<"OK"<<endl;
    else if(a%k==0||b%k==0)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}





Measured memory_bytes: 3620
n,r=(int(i)-1 for i in input().strip().split(" "))
ar=[]
for _ in range(r+1):
    a,b=(int(i)-1 for i in input().strip().split(" "))
    ar.append((min(a,b),max(a,b)))

ar.sort()
count=1
cur=ar[0]
for i in range(1,len(ar)):
    if ar[i][0]<cur[1]:
        t=(ar[i][0],min(ar[i][1],cur[1]))
        cur=t
    else:
        count+=1
        cur=ar[i]
print(count)


Measured memory_bytes: 83388
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mkp make_pair
  #define pb push_back
  #define inf INT_MAX
  void pairsort(int a[], int b[], int n)
  {
      pair<int, int> pairt[n];
      for (int i = 0; i < n; i++) 
      {
          pairt[i].first = a[i];
          pairt[i].second = b[i];
      }
      sort(pairt, pairt + n);
      for (int i = 0; i < n; i++) 
      {
          a[i] = pairt[i].first;
          b[i] = pairt[i].second;
      }
  }
   int binomialCoeff(int n, int k) 
  { 
       int res = 1; 
    
      // Since C(n, k) = C(n, n-k) 
      if ( k > n - k ) 
          k = n - k; 
    
      // Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1] 
      for (int i = 0; i < k; ++i) 
      { 
          res *= (n - i); 
          res /= (i + 1); 
      } 
    
      return res; 
  } 
  void printVector(vector<ll> v) {
    for(int i=0;i<v.size();i++)
      {
        cout << v[i];
      }
 
    }
  int divisor(int num)
  { int div=0;
    for (int i = 1; i <= num; i++)
    {
      /* code */
      if(num%i==0)
        div++;
    }
      return div;
    
  }
  int sub(int a, int b)
  {
    if(a>=b)
      return a-b;
    else
      return b-a;
 
  }
  int32_t main()
  { 
  	IOS
    int n,m;
    cin>>n>>m;
    int sum=0;
    priority_queue<int> pq;
    for(int i=0;i<n;i++)
    {
      int x; cin>>x;
      pq.push(x);
      sum+=x;
    }
    double val=1/(4.0*m) * sum;
    int k=0;
    bool ans=false;
    while(!pq.empty())
    {
      if(pq.top()>=val)
       {k++;}
       pq.pop(); 
       if(k>=m) {
         ans=true; break;}
       }
       if(ans)
       cout<<"Yes";
       else cout<<"No";
    
    return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[2001] = {0};
int main(){
    int S;
    long long sum=0;
    cin >> S;
    dp[0] = 1;
    for(int i=3;i<S+1;i++){
        dp[i] = dp[i-1] + dp[i-3];
        dp[i] %= (1000000000+7);
    }
    cout << dp[S] << endl;
    return 0;
}

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

int main(){
    int n,d;
    scanf("%d",&n);
    scanf("%d",&d);
    int ans=0;
    int count=0;
    while(1){
        ans++;
        count+=2*d;
        if(count>=n-1) break;
        count++;
    }
    printf("%d\n",ans);
}

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

#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = 200005;
int ar[NN];
int n, m, k;
int sum[11][2000];

int get(int a, int b, int c, int d){
    int ans = 0;
    for (int i = a; i <= c; i++){
        ans += sum[i][d] - (b ? sum[i][b-1] : 0);
    }
    return ans;
}

int calc(int c1, int c2){
    int prev = 0;
    int tot = 0;
    int ans = 0;
    for (int i = 0; i < n; i++){
        int tmp = get(i, c1, i, c2);
        if (tmp > k) {
            return 1e18;
        }
        if (tot + tmp > k){
            if (prev == i) return 1e18;
            tot = tmp;
            prev = i;
            ans++;
        } else {
            tot += tmp;
        }
    }
    return ans;
}

int solve(int st, int en) {
    if (en == m-1){
        return calc(st, en);
    }
    int ans = min(solve(st, en+1), 1 + calc(st, en) + solve(en+1, en+1));
    return ans;
}

integer main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> m >> k;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            char c;
            cin >> c;
            ar[i] = c - '0';
            sum[i][j] = ar[i];
            if (j){
                sum[i][j] += sum[i][j-1];
            }
        }
    }
    int best = 1e18;
    for (int i = 0; i < (1 << (n-1)); i++){
        vector<pair<int, int>> v;
        int cur = 0;
        for (int j = 0; j < n-1; j++){
            if ((1 << j) & i){
                v.push_back({cur, j});
                cur = j+1;
            }
        }
        if (!v.empty())
            v.push_back({v.back().second+1, n-1});
        else
            v.push_back({0, n-1});

        int ans = v.size() - 1;
        int st = 0;
        for (int l = 0; l < m; l++){
            for (int j = 0; j < v.size(); j++){
                int c1 = st, c2 = l;
                int r1 = v[j].first, r2 = v[j].second;
                int tmp = get(r1, c1, r2, c2);
                if (tmp > k && st == l){
                    goto here;
                } else if (tmp > k){
                    ans++;
                    st = l;
                }
            }
        }
        best = min(best, ans);
        here:
        int z;
    }
    cout << best << endl;

//    cout << solve(0, 0) << endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  int n;
  cin>>n;
  cin>>s>>t;
  string ans="";
  for(int i=0;i<n;i++)
  {
    ans+=s[i];
    ans+=t[i];
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stack>

using namespace std;

int main() {
	stack<long int> n;
	char a[1000000];
	long int b;
	
	while(scanf("%s", a) != EOF){
		if(!strcmp(a , "+")){
			int x,y;
			x = n.top();
			n.pop();
			y = n.top();
			n.pop();
			n.push(x+y);
		}
		else if(!strcmp(a , "-")){
			int x,y;
			x = n.top();
			n.pop();
			y = n.top();
			n.pop();
			n.push(y-x);
		}
		else if(!strcmp(a , "*")){
			int x,y;
			x = n.top();
			n.pop();
			y = n.top();
			n.pop();
			n.push(x*y);
		}
		else {
			n.push(atol(a));
		}
	}
	printf("%ld\n", n.top());
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N,X,M;

int main(){
    cin>>N>>X>>M;

    vector<ll> A(M+1,0);
    A[0]=X;
    ll s=1;
    vector<ll> idx(M,-1);
    idx[A[0]]=0;
    ll id=0;
    repn(i,M){
        A[i]=A[i-1]*A[i-1]%M;
        if(idx[A[i]]!=-1){
            id=idx[A[i]];
            break;
        }
        if(A[i]==A[0]){
            break;
        }
        idx[A[i]]=i;
        s++;
    }
    //rep(i,s) cout<<i<<' '<<A[i]<<endl;
    ll sum=0;
    for(int i=id;i<s;i++){
        sum+=A[i];
    }
    //cout<<same<<endl;

    ll ans=0;
    rep(i,min(id,N)) ans+=A[i];
    ans+=(N-id)/(s-id)*sum;
    rep(i,max((ll)0,(N-id)%(s-id))) ans+=A[id+i];

    cout<<ans<<endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

// aのn乗
ll modpow(ll a, ll n){
  ll r = 1;
  while (n) {
    r = r * ( (n%2)?a:1 ) %MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return r;
}

ll dp[5050][5050];

int main(){
  int N; cin>>N;
  string S; cin>>S;
  int m=S.length();
  dp[0][0]=1;
  rep(i,N) rep(j,N) if(dp[i][j]){
    (dp[i+1][j+1]+=2*dp[i][j])%=MOD;
    if(j) (dp[i+1][j-1]+=dp[i][j])%=MOD;
    else (dp[i+1][j]+=dp[i][j])%=MOD;
  }
  ll x=1;
  rep(i,m) (x*=2)%=MOD;
  (dp[N][m]*=modpow(x,MOD-2))%=MOD;
  cout<<dp[N][m]<<endl;
  return 0;
}


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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0n(i, n) for (i = 0; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
//*/

//int row, column;
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        ll i, n;
        string s;

        cin >> s >> n;

        for(i = 0; i < s.length(); i += n)
        {
            cout << s[i];
        }
        cout << endl;
    }
    return 0;
}
template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    vector<map<ll, ll>> dp(n+1);
    dp[0][0] = 1000;
    rep(i, n){
        for(auto x : dp[i]){
            chmax(dp[i+1][0], x.second + a[i] * x.first);
            ll now = x.second / a[i];
            chmax(dp[i+1][x.first+now], x.second % a[i]);
        }
    }
    cout << dp[n][0]<< endl;
}

Measured memory_bytes: 3676
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

typedef vector<long long> vec;
typedef vector<vec> mat;

constexpr long long MAX_LOG_H = 62;
constexpr long long mod = 1000000009;

mat F[MAX_LOG_H];

mat operator*(const mat &A, const mat &B) {
	const int n = A.size();
	const int m = B[0].size();

	mat C(n, vec(m, 0));

	for(int i = 0; i < n; ++i) {
		for(int k = 0; k < static_cast<int>(B.size()); ++k) {
			for(int j = 0; j < m; ++j) {
				C[i][j] += A[i][k] * B[k][j];
				if(C[i][j] >=  mod) C[i][j] %= mod;
			}
		}
	}

	return C;
}

void init(int w, long long h) {
	const int log_h = log2(h) + 1;

	F[0].assign(w, vec(w));
	for(int i = 0; i < w; ++i) {
		F[0][i][i] = 1;
		if(i) F[0][i][i - 1] = 1;
		if(i < w - 1) F[0][i][i + 1] = 1;
	}

	for(int i = 0; i < log_h; ++i) {
		F[i + 1] = F[i] * F[i];
	}
}

mat calc(int n, long long k) {
	mat res(n, vec(n));
	for(int i = 0; i < n; ++i) {
		res[i][i] = 1;
	}

	for(int i = 0; k > 0; ++i) {
		if(k & 1) res = move(res) * F[i];
		k >>= 1;
	}

	return res;
}

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

	int w, n;
	long long h;

	for(int case_number = 1; cin >> w >> h >> n && w; ++case_number) {
		init(w, h);

		map<long long, vector<int>> ng;
		for(int i = 0; i < n; ++i) {
			int x;
			long long y;
			cin >> x >> y;
			ng[y].emplace_back(x - 1);
		}

		mat ans(1, vec(w, 0));
		ans[0][0] = 1;

		long long prev = 1;
		for(auto it = ng.cbegin(); it != ng.cend(); ++it) {
			ans = calc(w, it->first - prev) * move(ans);

			for(const auto &x : it->second) {
				ans[x][0] = 0;
			}

			prev = it->first;
		}

		ans = calc(w, h - prev) * move(ans);

		cout << "Case " << case_number << ": " << ans[w - 1][0] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 4220
object Main extends App {
	
	val N = scala.io.StdIn.readInt
	val a = scala.io.StdIn.readLine.split(" ").map(_.toLong)
	val b = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	var count = 0L

	for(i<-0 until N){
		val t = a(i) - b(i)
		if(t > 0){
			count = count + t
		}else{
			count = count + t/2
		}
	}

	if(count <= 0L) println("Yes")
	else println("No")


}


Measured memory_bytes: 33276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
		ll n,k,x;
		cin>>n>>k;
		vector<ll> a;
		ll dp[100003];
		for(ll i=0;i<n;i++)
		{
			cin>>x;
			a.push_back(x);
		}
		for(ll i=0;i<a[0];i++)
		{
			dp[i]=0;
		}
		for(ll i=a[0];i<=k;i++)
		{
			dp[i]=0;
			for(ll j=0;j<n;j++)
			{
				if(i-a[j]>=0&&dp[i-a[j]]==0)
				{
					dp[i]=1;
					break;
				}
			}
		}
		if(dp[k])cout<<"First\n";
		else cout<<"Second\n";
		
}


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

xor_a=0
for i in range(len(a)):
    xor_a=xor_a^a[i]
#print(xor_a)

b = [xor_a^a[i] for i in range(len(a))]
print(" ".join(map(str, b)))

Measured memory_bytes: 41780
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,m,a[200009],ans;
	string s;
	cin>>n>>m;
	ans+=(n*(n-1))/2;
	ans+=(m*(m-1))/2;
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256