akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  // 差が隅数の場合お互い勝ち負け試合って、めぐいあう、偶数の場合、巡り会えない
  if((b - a)%2 == 0){
    say((b - a)/2);
  }else{
    if((a - 1) <= (n - b)){
      // if(a == 1){
      //   say(((b-a)/2) + 1);
      //   return 0;
      // }
      ll hoge = min((a - (ll)1) + ((b - a)/(ll)2) + (ll)1, (a - (ll)1) + (b - a));
      say(hoge);
      // say((a - 1) + (b - a));
    }else{
      // if(b == n){
      //   say(((b-a)/2) + 1);
      //   return 0;
      // }
      ll hoge = min((n - b) + ((b - a)/(ll)2) + (ll)1, (n - b) + (b - a));
      say(hoge);
    }
  }
}

Measured memory_bytes: 256
n = gets.chomp.to_i
ary = gets.chomp.split.map(&:to_i)

# 色を変えるとき、簡単のため、0に変える
count = 0
tmp = ary[0]
for i in 1..(n-1)
  if ary[i] == tmp
    ary[i] = 0
    count += 1
  end
  tmp = ary[i]
end
puts count


Measured memory_bytes: 1788
#include <cstdio>
typedef long long ll;

const int N=3005;
int n,P,S[N][N],C[N][N],Ans;
inline int Mod(const int x){return x>=P?x-P:x;}
ll Pow(ll a,ll b,ll p,ll s=1){for(;b;b>>=1,a=a*a%p)if(b&1)s=s*a%p;return s;}

int main()
{
	scanf("%d%d",&n,&P);
	for(int i=**S=**C=1;i<=n+1;++i)for(int j=C[i][0]=1;j<=i;++j)
		C[i][j]=Mod(C[i-1][j-1]+C[i-1][j]),S[i][j]=(S[i-1][j-1]+(ll)S[i-1][j]*j)%P;
	for(int i=0;i<=n;++i)
	{
		int c=0,u=Pow(2,Pow(2,n-i,P-1),P),v=Pow(2,n-i,P),vs=1;
		for(int j=0;j<=i;++j)c=(c+(ll)S[i+1][j+1]*u%P*vs)%P,vs=(ll)vs*v%P;
		Ans=i&1?(Ans-(ll)c*C[n][i]%P+P)%P:(Ans+(ll)c*C[n][i])%P;
	}
	return printf("%d\n",Ans),0;
}


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


int main(){
	int a;cin >> a;
	cout << a*a*a+a*a+a << endl;
	return 0;
}












Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll ans = 0;
    ll l, r;
    rep(i, N){
        cin >> l >> r;
        ans += r - l + 1;
    }

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

Measured memory_bytes: 3612
a=input().split()
a[0]=int(a[0])
a[1]=int(a[1])
if(a[0]<=0 and a[1]>=0):
    print("Zero")
elif(a[0]<0 and a[1]<0 and (a[1]-a[0])%2==0):
    print("Negative")
else:
    print("Positive")

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

string dfs(ll n) {
    if (n == 0){
        return "" ;
    }
    n-- ;
    return dfs(n/26) + string(1, 'a' + n%26);    
}

int main() {
    ll n ;
    cin >> n;
    cout << dfs(n) << endl;
    return 0; 
}



Measured memory_bytes: 3616
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, M = map(int, input().split())
C = list(map(int, input().split()))
MAX = 20

dp = [list(range(N+1)) for _ in range(M+1)]

for i in range(1, M+1):
    c = C[i-1]
    for j in range(N+1):
        if j-c>=0:
            dp[i][j] = min(dp[i-1][j-c]+1, dp[i-1][j], dp[i][j-c]+1)
        else:
            dp[i][j] = dp[i-1][j]
#    pri(dp)
print(dp[M][N])



Measured memory_bytes: 39856
K = int(input())

queue = list(range(1,10))
counter = 0
while counter != K - 1:
    num = queue[counter]
    ichi = num % 10
    num *= 10
    if ichi != 0:
        queue.append(num + ichi - 1)
    queue.append(num + ichi)
    if ichi != 9:
        queue.append(num + ichi + 1)
    counter += 1
print(queue[counter])

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var a = array[0];
            var b = array[1];

            for( var i=0; i*k<=b; i++)
            {
                if( i*k >= a)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }

            Console.WriteLine("NG");

        }

    }
}


Measured memory_bytes: 28056
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{
	while (1) {
		auto x = readln.chomp.split.map!(to!int);
		if (!x[0])break;
		auto score = new int[][](x[1], 3);
		auto wa = new int[][](x[1], x[2]);
		foreach (i; 0..x[3]) {
			auto y = readln.chomp.split.map!(to!int);
			if (y[3] == 0) {
				score[y[1]-1][0]++;
				score[y[1]-1][1] += y[0] + 20 * wa[y[1]-1][y[2]-1];
			} else {
				wa[y[1]-1][y[2]-1]++;
			}
		}
		foreach (i; 0..x[1]) {
			score[i][2] = i + 1;
		}
		score = score.sort!((a,b) => a[0] == b[0] ? a[1] == b[1] ? a[2] > b[2] : a[1] < b[1] : a[0] > b[0]).array;

		auto pre = score[0][0..2];
		write(score[0][2]);
		foreach (i; 1..x[1]) {
			if (pre == score[i][0..2]) {
				write("=");
			} else {
				write(",");
			}
			write(score[i][2]);
			pre = score[i][0..2];
		}
		writeln("");
	}
}

Measured memory_bytes: 2032
import sys
import heapq

input=sys.stdin.readline
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
r=[-r[i] for i in range(0,C)]
apple=p[A-X:A]+q[B-Y:B]
heapq.heapify(apple)
heapq.heapify(r)
ans=0
while True:
    if apple and r:
        a=heapq.heappop(apple)
        b=-heapq.heappop(r)
        if b>a:
            ans+=b
        else:
            heapq.heappush(apple,a)
            break
    else:
        break

apple=list(apple)
print(ans+sum(apple))

Measured memory_bytes: 106704
n,m = map(int, input().split())
h = list(map(int, input().split()))
f = ["0"]*n
for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] < h[b-1]:
    f[a-1] = False
    if (f[b-1] != False):
    	f[b-1] = "n1"
  elif h[a-1] > h[b-1]:
    if (f[a-1] != False):
    	f[a-1] = "n1"
    f[b-1] = False
  else:
    f[a-1] = False
    f[b-1] = False
f = [i for i in f if i!=False]
print(len(f))

Measured memory_bytes: 20064
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var K = Sarray()[0];
            var ans = 1L;
            for(var i=0;i<N;++i)
                ans = Min(ans * 2, ans + K);
            WriteLine(ans);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28136
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FASTNIBBA   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define lbnd        lower_bound
#define ubnd        upper_bound
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
   string s; cin>>s;
   int n=s.size(),ans=0;
   stack<int> stk;
   rep(i,0,n)
   {
     if(!stk.empty())
     {
       char x=stk.top();
       if(x!=s[i]) {ans+=2; stk.pop(); continue;}
     }
     stk.push(s[i]);
   }
   cout<<ans;
}  
int main()
{
    FASTNIBBA;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 720
from datetime import datetime
n = input()

y = int(n[0:4])
m = int(n[5:7])
d = int(n[8:10])

t = datetime(y,m,d)
t2 = datetime(2019,4,30)

if t <= t2:
    print("Heisei")

else:
    print("TBD")

Measured memory_bytes: 3312
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)
#define END(x) (*(x.end()-1))

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)/b;
}


int main(void){
    int n,m;
    cin>>n>>m;
    ll a,b;
    vector<vector<ll>> G(n);
    rep(i,m){
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    queue<ll>check;
    vector<ll>len(n,-1);
    check.push(0);
    len[0]=0;
    while(!check.empty()){
        ll now=check.front();
        check.pop();
        for(auto next:G[now]){
            if(len[next]!=-1)continue;
            len[next]=len[now]+1;
            check.push(next);
        }
    }
    if(len[n-1]==2){
        cout<<"POSSIBLE";
    }
    else{
        cout<<"IMPOSSIBLE";
    }
}
/*

*/

Measured memory_bytes: 15208
//<MIHIR KHAMBHATI/>
 
#include<bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define deb(x) cout<<"\n"<<#x<<"="<<x<<"\n";
#define deb2(x,y) cout<<"\n"<<#x<<"="<<x<<"\n"<<#y<<"="<<y<<"\n";
#define ideb int _p_;cin>>_p_;
typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
ll n;
cin>>n;
ll k;
cin>>k;
ll ans=0;
for(int i=0;i<n;i++)
{
	ll a;
	cin>>a;
	if(a>=k)
	ans++;
}
cout<<ans;
}

Measured memory_bytes: 256
import math
n = int(input())
s_list = []
for _ in range(n):
    s_list.append(sorted(input()))
s_list = sorted(s_list)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


eq_count = 0
count = 0
for i in range(1,n):
    if s_list[i-1] == s_list[i]:
        eq_count = eq_count + 1
    elif eq_count != 0:
        count = count + combinations_count(eq_count+1,2)
        eq_count = 0
    if i == n-1 and eq_count!=0:
        count = count + combinations_count(eq_count+1,2)

print(count)

Measured memory_bytes: 27280
#include<bits/stdc++.h>
#define ll long long
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)
#define for0(n) for(int i=0;i<n;i++)
#define for1(n) for(int i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
using namespace std;
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
bool isPrime(int n) {
    
    if (n == 1) {
        return false;
    }

    int i = 2;
  
    while (i*i <= n) {
        
        if (n % i == 0) {
            
            return false;
        }
        i += 1;
    }
    
    return true;
}
int main()
{   ios::sync_with_stdio(0);
    int t;
    // cin>>t;
    t=1;
    cin.tie(0);
    cout.tie(0);
    while(t--)
    {
        int n;
        cin>>n;
        vector<int> v(n+1);
        vector<int> dp(n+1);
        for(int i=1;i<=n;i++){
            cin>>v[i];
        }
        dp[2]=abs(v[2]-v[1]);
        dp[3]=min(dp[2]+abs(v[3]-v[2]),abs(v[3]-v[1]));
        for(int i=4;i<=n;i++){
            dp[i]=min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i]));
            // cout<<dp[i]<<" ";
        }
        cout<<dp[n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include <set>

using namespace std;

string s;
set<int> used;

int main(void) {
    cin >> s;
    int zero = 0, one = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '0') {
            zero++;
        } else {
            one++;
        }
    }
    cout << min(zero, one) * 2 << endl;
}

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

////// Union Find https://atcoder.jp/contests/atc001/tasks/unionfind_a
// 引用資料：https://mickey24.hatenablog.com/entry/20090602/1243950241
// 経路圧縮のみ実装？ 深さ１の部分木を生成

class DisjointSet {
private:
    vector<int> p;              // 頂点 i の所属している集合の root を記録する or 集合の root には自分を含む要素数が負の数で記録してある
    int count;                  // 集合の数を記録(１となったときすべての要素が一つにまとまったことを示す)

    // 所属している部分木の root を調べる
    int root(int x) {         
        return p[x] < 0 ? x : p[x] = root(p[x]);
    }

public:
    // コンストラクタ　要素数の提示が必要
    DisjointSet(int size) {
        p.resize(size, -1); 
        count = size;
    }
    // 集合同士の結合
    bool unite_set(int x, int y) {          
        int rootX = root(x);
        int rootY = root(y);

        if (rootX != rootY) {                       // 部分木内でのループが起こらないように
            if (p[rootX] > p[rootY]) {              // 自分を含む要素数が多い方を rootX とする  
                swap(rootX, rootY); 
            }
            p[rootX] += p[rootY];                   // 自分を含む要素数を p[rootX] に渡す
            p[rootY] = rootX;                       // root を変更
            count--;                                // 集合同士がつながったので、集合の数を一つ減らす
            return true;
        }
        return false;
    }
    // 同じ集合に属しているか調べる
    bool is_same_set(int x, int y) {          
        if (root(x) == root(y)) {
            return true;
        }
        return false;
    }
    // 集合の数を出力
    int number_of_sets() {
        return count;
    }
};

int main() {
    // 入力
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> edge;
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--;  b--;
        edge.push_back(make_pair(a, b));
    }

    // 
    int cnt = 0;
    for (int i = 0; i < m; i++){
        DisjointSet sSet(n);        // コンストラクト、インスタンス化
        // 
        for (int j = 0; j < m; j++){
            if(i == j){
                continue;
            }
            auto ithEdge = edge[j];
            sSet.unite_set(ithEdge.first, ithEdge.second);
        }
        int tmp = sSet.number_of_sets();
        if(tmp != 1){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

using namespace std;

int main(){

	long x,y;
    cin >> x >> y ;
    for(long i=0;i<x+1;i++){
        if((i*2+(x-i)*4) == y){
		    cout << "Yes" << endl; 
            return 0;
        }
	}
    cout << "No" << endl; 
}


Measured memory_bytes: 3636
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
b = inp
ans = b[0]
(1..(n-2)).each do |i|
  ans += [b[i-1],b[i]].min
end
ans += b[-1]
p ans

Measured memory_bytes: 1788
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int a=ni();
        int b=ni();
        if(a<b)
        {
            for(int i=0;i<b;i++)
                p(a);
            pn("");
        }
        else
        {
            for(int i=0;i<a;i++)
                p(b);
            pn("");
        }
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 22228
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 200005;

/*******************************************************************/




int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t, z = 1; cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	char a;cin>>a;
	if(a>=65 && a<=90) cout<<"A\n";
	else cout<<"a\n";
	return 0;
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int a,b; cin >>a>>b;
  if(a-2*b<0)cout <<0<<endl;
  else cout <<a-2*b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    	string s;
    cin >> s;
    if(s=="ABC")
    	cout<<"ARC";
    else 
    	cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3608
n = int(input())

def rtnm(n,st):
    ans = 0
    for i in range(st,st*10):
        if(i > n):
            break
        else:
            ans += 1
    return ans

ans = 0

ans += rtnm(n,10**4) + rtnm(n,10**2) + rtnm(n,10**0)
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);


int main() {
    int N;
    std::cin >> N;

    std::vector<int> a(N);
    std::vector<int> b(N);
    std::vector<int> c(N);

    for(auto& val: a)
        std::cin >> val;
    for(auto& val: b)
        std::cin >> val;
    for(auto& val: c)
        std::cin >> val;

    std::sort(begin(a), end(a));
    std::sort(begin(b), end(b));
    std::sort(begin(c), end(c));

    std::vector<long long> numB(N, 0);
    {
        int j = 0;
        for (int i = 0; i < N; ++i) {
            while(c[j] <= b[i]) ++j;
            if(N <= j) break;
            numB[i] = N - j;
        }
    }

    for(int i = N - 2; i >= 0; --i)
        numB[i] = numB[i] + numB[i + 1];

    long long ans = 0;

    int j = 0;
    for(int i = 0; i < N; ++i) {
        while(b[j] <= a[i]) ++j;
        if(N <= j) break;
        ans += numB[j];
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2304
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n,m;
	List<List<Integer>> graph;
	List<Integer> V;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		n = nextInt();
		m = nextInt();
		graph = new ArrayList<List<Integer>>();

		for(int i=0;i<=n;i++) {
			V = new ArrayList<Integer>();
			graph.add(V);
		}

		for(int i=0;i<m;i++) {
			int a = nextInt();
			int b = nextInt();
			graph.get(a).add(b);
			graph.get(b).add(a);
		}
		sc.close();

		int res = 0;
		for(int i=1;i<=1;i++)res += SearchforAllVerticesPass(i);

		System.out.println(res);
	}

	private int SearchforAllVerticesPass(int gi) {
		boolean[] f = new boolean[n+1];
		return SearchforAllVerticesPass(gi,0+1,f);
	}

	private int SearchforAllVerticesPass(int gi,int cnt, boolean[] f) {
		List<Integer> VL=graph.get(gi);

		f[gi]=true;
		int sum=0;

		for(int i=0;i<VL.size();i++) {
			if(f[VL.get(i)])continue;
			if(cnt+1==n)sum++;
			else sum+=SearchforAllVerticesPass(VL.get(i),cnt+1,f);
		}
		f[gi]=false;
		return sum;
	}

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

}

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(10)





void solve() {

	char ch;
	cin >> ch;
	cout << char(ch + 1) << "\n";




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	solve();

	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b){
  if(b > a) swap(a, b);
  ll r = -1;
  while(r!=0){
    r = a % b;
    a = b, b = r;
  }
  return a;
}
int main(int argc, char const *argv[]) {
  int T;
  std::cin >> T;
  ll A, B, C, D, g;
  range(i, T){
    std::cin >> A >> B >> C >> D;
    if(A < B || D < B){
      std::cout << "No" << '\n';
      continue;
    }else if(C >= B){
      std::cout << "Yes" << '\n';
      continue;
    }
    g = gcd(B, D);
    if(g==1){
      std::cout << (B - C>=2?"No":"Yes") << '\n';
      continue;
    }


    if(A % g > C % g){
      C += A % g - C % g;
    }else if(A % g == C % g){
      C += g;
    }else{
      C += (g - C%g + A%g);
    }

    std::cout << (B>C?"No":"Yes") << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
import Data.Bits
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Control.Applicative
import Data.Maybe
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
-- import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce

query :: B.ByteString -> B.ByteString -> (Int, Bool)
query xs ys = (l, all (\i -> B.index xs (ndg * i) == B.index ys (mdg * i)) [0..g-1])
  where
    n = B.length xs
    m = B.length ys
    g = gcd n m
    l = lcm n m
    ndg = n `div` g
    mdg = m `div` g

main :: IO ()
main = do
  getLine
  xs <- B.getLine
  ys <- B.getLine
  let (i,b) = query xs ys
  putStrLn $ show $ if b then i else -1

Measured memory_bytes: 892
a,b = map(int, input().split())
l = list(map(int, input().split()))
L = []

for i in range(a):
  l2 = [l[i],l[i] + b]
  L.append(l2)
  
L = sorted(L, key = lambda x:x[1])
#print(L)

ri = 0
sum = 0

for x,y in L:
#  print(x,y)
  if ri > x:
    sum += y - ri
    ri = y
  else:
    sum += b
    ri = y
#  print("sum:" + str(sum), "ri:" + str(ri))

print(sum)

Measured memory_bytes: 41840
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    A=list(pin())#henkan
    seen=set([0])
    junban=[0]
    #print(seen)
    
    
    point_1=0
    for n in range(N):
        #print(A[point_1])
        point_1=A[point_1]-1
        junban.append(point_1)
        if (point_1) in seen:
            #print(n)
            b=n
            break 
        seen.add(point_1)
        
        
    #print(n,junban,point_1)
    for m in range(len(junban)):
        if junban[m]==point_1:
            a=m
            break
    g=(len(junban)-1-a)
    #print(g)
    if K>a:
        k=(K-a)%g
        print(junban[a+k]+1)
    else:print(junban[K]+1)
#%%submit!
resolve()

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  if(l > r){
    cout << "Left" << endl;
  }else if(l == r){
    cout << "Balanced" << endl;
  }else if(r > l){
    cout << "Right" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

signed main()
{
    showoff;
    int m,d;
    cin >> m >> d;
    int tot = 0;
    FOR(i,1,m+1){
        FOR(j,1,d+1){
            int d0 = j%10,d1 = ((j/10)%10);
            if(min(d0,d1) >= 2 && d0*d1 == i)++tot;
        }
    }
    cout << tot;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include<stdio.h>


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

	int ans = 0;
	int i = 1;
	int w = n / i;
	int count = 0;
	while (w) {
		i *= 10;
		++count;
		w = n / i;
	}

	switch (count) {
	case 6:
		ans = 90909;
		break;

	case 5:
		ans = 909;
		ans += (n - 9999);
		break;

	case 4:
		ans = 909;
		break;

	case 3:
		ans = 9;
		ans += (n - 99);
		break;

	case 2:
		ans = 9;
		break;

	case 1:
		ans =n;
		break;
	}
//	printf("%d\n", count); test
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

xs = inputs[1]

# body
if $debugFlag
  p xs
end

minabs = 10**9 + 1
sum = 0
minusNumMod2 = 0
xs.each do |x_i|
  sum += x_i.abs
  minabs = x_i.abs if x_i.abs < minabs
  minusNumMod2 ^= 1 if x_i < 0
end

pd minusNumMod2
pd minabs
pd sum
if minusNumMod2 == 0
  puts sum  
else
  puts (sum - 2*minabs)
end


Measured memory_bytes: 9748
#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,x,t;
  cin >> n >> x >> t;
  int ans = n/x;
  if(n%x!=0)ans++;
  cout << ans*t << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main()
{
  int N, a, b, c, i;

  scanf("%d",&N);
  for(i=1; i<=N; i++){
    scanf("%d %d %d", &a, &b, &c);
    if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==b*b+a*a){
      printf("YES\n");
    }else{
      printf("NO\n");;
    }
 }

  return 0;
}

  

Measured memory_bytes: 580
array = []                                         
raw = raw_input()                                  
array.append(int(raw))                             
raw = raw_input()                                  
array.append(int(raw))                             
raw = raw_input()                                  
array.append(int(raw))                             
raw = raw_input()                                  
array.append(int(raw))                             
raw = raw_input()                                  
array.append(int(raw))                             

total = 0                                          
last = 10                                          
for i in range(5):                                 
    n = array[i]                                   
    t = n / 10                                     
    total = total + t * 10                         
    l = n % 10
    if l!= 0:                                      
        total = total + 10                         
    if l != 0 and l < last:
        last = l                                   
total = total + last                               
print total - 10  

Measured memory_bytes: 2692
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#define ill long long
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  ill k, c = 0;
  cin >> k;
  rep(i, 1, k+1) {
    rep(j, 1, k+1) {
      rep(o, 1, k+1) {
        if(i == 1 || j == 1 || o == 1) {
          c++;
        } else {
          c += gcd(i, gcd(j, o));
        }
      }
    }
  }
  cout << c;
}

Measured memory_bytes: 3636
// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <iostream>
#include <queue>
#include <string>
#include <math.h>
#define mid(l,r) (( l + r ) / 2)
#define lowbit(x) (( x & ( - x )))
#define lc(root) ((root * 2))
#define rc(root) ((root * 2 + 1))
#define me(array,x) (memset( array , x , sizeof( array ) ) )
typedef long long LL;
using namespace std;
const LL inf = 10000000;
const int mod = 1e9 + 7;
const int maxn = 150000+10;
int a[maxn];

int main()
{
    int a;
    string s;
    cin>>a>>s;
    if(a<3200)printf("red\n");
    else cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(lambda x: int(x)%4 , input().split()))

p = a.count(0)
q = a.count(2)
r = n-p-q

if r > p:
    if r -p == 1 and q == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Measured memory_bytes: 11096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int k, x;
  cin >> k >> x;
  if (500*k >= x) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

from operator import mul
from functools import reduce

def nCr(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under



S = int(input())
ans = 0
for i in range(1, S):
    if S - i * 3 < 0:
        break
    ans += nCr(S - i * 3 + i - 1, i - 1)
print(ans % MOD)



Measured memory_bytes: 9524
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%10==n/100){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,h = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ans = 0
attck = max(ab)[0]
ULT = []
for a,b in ab:
    if b > attck:
        ULT.append(b)

ULT.sort(reverse=1)
# print(attck,ULT)
for ult in ULT:
    h -= ult
    ans += 1
    if h <= 0:
        h = 0
        break
# print(ans)
ans += h//attck+1 if h%attck else h//attck
print(ans)

Measured memory_bytes: 28560
#include<bits/stdc++.h>
using namespace std;
long long int mod = 1e9;

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
int h, w;
vector< vector<int> > c;
vector<string> s;
queue< pair<int, int> > q;

void func() {
  while(!q.empty()) {
    int nx = q.front().first;
    int ny = q.front().second;
    q.pop();
    for(int i=0; i<4; i++) {
      int tx = nx + dx[i];
      int ty = ny + dy[i];
      if(tx < 0 || ty < 0 || tx >= w || ty >= h) continue;
      if(c[ty][tx] <= c[ny][nx] + 1) continue;
      if(s[ty][tx] == '#') continue;
      c[ty][tx] = c[ny][nx] + 1;
      q.push({tx, ty});
    }
  }
}

int main(){
  cin >> h >> w;
  s.resize(h);
  for(int i=0; i<h; i++) cin >> s[i];
  c.resize(h, vector<int>(w, 1e9));
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if(s[i][j] == '#') {
        c[i][j] = 0;
        q.push({j, i});
      }
    }
  }
  func();

  int ans = 0;
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cerr << c[i][j] << " ";
      ans = max(ans, c[i][j]);
    }
    cerr << endl;
  }
  cout << ans << endl;

  return 0;
}


// EOF


Measured memory_bytes: 13456
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000000000000
#define mod 1000000007
#define endl '\n'
#define omarshagar                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;


int main()
{
    omarshagar
    int n,k;
    cin>>n>>k;
    int x;
    int arr[n+1]={};
    for(int i=0;i<n;i++)
    {
        cin>>x;
       arr[x]++;
    }
    priority_queue<int>pq;
    for(int i=0;i<=n;i++)
    {
        if(arr[i]!=0)
        {
            pq.push(arr[i]*-1);
        }

    }
    ll sum=0;
    while(pq.size()>k)
    {
        sum+=-1*pq.top();
        pq.pop();
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2168
#include <iostream>

#define ll long long int

using namespace std;

ll n;
ll s;
ll x[100005];
ll p[100005];
ll ans;

void get_ans(ll left, ll right) {
  while (x[left] < s && x[right] > s) {
    ans += x[right] - x[left];
    if (p[left] >= p[right]) {
      while (p[left] >= p[right] && right > left) {
	p[left] += p[right];
	right--;
      }
    }
    else {
      while (p[right] > p[left] && right > left) {
	p[right] += p[left];
	left++;
      }
    }
  }
  if (x[left] >= s) {
    ans += x[right] - s;
    return;
  }
  if (x[right] <= s) {
    ans += s - x[left];
    return;
  }
}

int main() {
  cin >> n >> s;
  for (ll i = 0; i < n; i++) {
    cin >> x[i] >> p[i];
  }
  ans = 0;
  get_ans(0, n - 1);
  cout << ans;
}


Measured memory_bytes: 1792
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int n, k, mod = 1e9 + 7;
ll memo[100010];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> k;
    memo[0] = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        vi diff(100010, 0);
        for (int have = k; have >= 0; have--) {
            int l = have + 1, r = have + min(a, k - have);
            if (l <= r) {
                diff[l] += memo[have];
                diff[l] %= mod;
                if (r + 1 <= k) {
                    diff[r + 1] -= memo[have];
                    if (diff[r + 1] < 0) diff[r + 1] += mod;

                }
            }
        }
        int pre = 0;
        for (int i = 0; i <= k; i++) {
            pre += diff[i];
            pre %= mod;
            memo[i] += pre;
            memo[i] %= mod;
        }
    }
    cout << memo[k] << endl;

    return 0;
}

Measured memory_bytes: 1528
def pow_k(x, n):
    """
    O(log n)
    """
    MOD = 10 ** 9 + 7
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= MOD
        x *= x
        x %= MOD
        n //= 2

    return K * x

def cmb(n, r):
	MOD = 10**9+7
	if n - r < r: r = n - r
	if r == 0: return 1
	if r == 1: return n

	numerator = [n - r + k + 1 for k in range(r)]
	denominator = [k + 1 for k in range(r)]

	for p in range(2,r+1):
		pivot = denominator[p - 1]
		if pivot > 1:
			offset = (n - r) % p
			for k in range(p-1,r,p):
				numerator[k - offset] /= pivot
				denominator[k] /= pivot

	result = 1
	for k in range(r):
		if numerator[k] > 1:
			result *= int(numerator[k])
			result %= MOD

	return result

n,a,b = map(int,input().split())
MOD = 10**9+7

ans = pow_k(2,n)-1

print((ans - cmb(n,a) - cmb(n,b))%MOD)


Measured memory_bytes: 27700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll N,M;char a[1001][1001];
ll dp[1001][1001];
ll MOD = 1000000007;
int main(){
      cin>>N>>M;
      for(ll i=0;i<N;i++){
            for(ll j=0;j<M;j++)cin>>a[i][j];
      }
      for(ll i=N-1;i>=0;i--){
            for(ll j=M-1;j>=0;j--){
                  if(i==N-1 && j==M-1)dp[i][j] =1;
                  else if(a[i][j]=='#')dp[i][j] = 0;
                  else{
                        if(i<N-1 && j<M-1)dp[i][j] = (dp[i+1][j]+dp[i][j+1])%MOD;
                        else if(i<N-1)dp[i][j] = (dp[i+1][j])%MOD;
                        else if(j<M-1)dp[i][j] = (dp[i][j+1])%MOD;
                  }
            }
      }
      cout<<dp[0][0]<<endl;
      return 0;
}


Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var list = new List<int>();
            for (var i = 0; i < 5; i++)
                list.Add(ReadInt());

            var ans = int.MaxValue;
            for (var i = 0; i < 5; i++)
            {
                var sum = list.Where((x, j) => j != i).Select(x => (int)Math.Ceiling((double)x / 10) * 10).Sum();
                ans = Math.Min(sum + list[i], ans);
            }
            Console.WriteLine(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CsharpSpiral {
	class Program {
		//https://qiita.com/NotFounds/items/7b166af69a6f52a332de
		static void Main(string[] args) {
            var sw = new StreamWriter( Console.OpenStandardOutput() ) { AutoFlush = false };
            Console.SetOut( sw );
            new Program().Solve(new ConsoleInput(Console.In,' '));
            Console.Out.Flush();
        }
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var A = cin.ReadIntArray( N );
			for (int i = 0; i < N; i++) {
				var tmp = A[i];
				var j = i-1;
				while (j >= 0 && A[j] > tmp) {
					A[j + 1] = A[j];
					j--;
				}
				A[j + 1] = tmp;
				Console.WriteLine(string.Join(" ",A));
			}
		}
	}
    class ConsoleInput {
        private readonly TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split( _separator );
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue( tmp[i] );
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse( Read ); } }
        public long ReadLong { get { return long.Parse( Read ); } }
        public double ReadDouble { get { return double.Parse( Read ); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for (long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}



Measured memory_bytes: 16404
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int root[100001];
bool marked[100001];

int getroot(int v) { return marked[v] ? v : root[v] = getroot(root[v]); }

int main(){
	int n, m;
	while(cin >> n >> m, n){
		for(int i=2;i<=n;i++) cin >> root[i];
		vector<bool> vb;
		vector<int>  vi;
		memset(marked, false, sizeof(marked));
		marked[1] = true;
		for(int i=0;i<m;i++){
			char c; int t; cin >> c >> t;
			if(c=='Q'){ vb.push_back(true); vi.push_back(t); }
			else {
				if(marked[t]) continue;
				vb.push_back(false); vi.push_back(t);
				marked[t] = true;
			}
		}
		long long ans = 0;
		reverse(vb.begin(), vb.end());
		reverse(vi.begin(), vi.end());
		for(int i=0;i<vb.size();i++){
			if(vb[i]) ans += getroot(vi[i]);
			else      marked[vi[i]] = false;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0