akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=1; i<=n; i++){
    cin >> a[i];
  }
  ll sum=0;

  ll sum_1=0;
  for(int i=1; i<=n; i++){
    sum += a[i];
    if(i%2 == 0){
      if(sum>=0){
        sum_1 += sum+1;
        sum = -1;
      }
    }else{
      if(sum<=0){
        sum_1 += abs(sum)+1;
        sum = 1;
      }
    }
  }
  sum = 0;
  ll sum_2=0;
  for(int i=1; i<=n; i++){
    sum += a[i];
    if(i%2 != 0){
      if(sum>=0){
        sum_2 += sum+1;
        sum = -1;
      }
    }else{
      if(sum<=0){
        sum_2 += abs(sum)+1;
        sum = 1;
      }
    }
  }
  cout << min(sum_1,sum_2) << endl;
  return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <sstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;

int main()
{
    int sum = 0, n;
    cin>>n;
    for(int i = 1; i <= n; i++)
    {
        sum += i;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main(){
	int X;
	char command[10];
	int A,B,N;

	scanf("%d %d %d",&X,&A,&B);
	scanf("%d",&N);

	for(int i=0;i<N;i++){
		scanf("%s",command);
		if(strcmp(command,"nobiro")==0){
			X+=A;
		}else if(strcmp(command,"tidime")==0){
			X+=B;
		}else{
			X=0;
		}
		if(X<0){
			X=0;
		}
	}

	printf("%d\n",X);

	return 0;
}


Measured memory_bytes: 2132
////////////////////////////////////////////////////
//                                                //
//  For her who keeps the fire kindling in me...  //
//                                                //
////////////////////////////////////////////////////

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
// import java.util.Scanner;
// import java.util.Arrays;
// import java.util.ArrayList;
// import java.util.Collections; 
// import java.util.StringTokenizer;
import java.util.*;
import java.lang.Math;
import java.awt.Point;

import java.awt.geom.*;

class Main {

    public static void main(String args[]) {
        try {
            FastReader s = new FastReader();
            BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
            int i, j, k, v, x, y, t, n, key, size, poster, minglob, minloc, beg, end, begl, endr, ind, max, l, r;// doub, b;
            long ans, f, ansmin, count, mincount;
            boolean flag;

            double a, b;
            a  = s.nextDouble();
            b = s.nextDouble();
            
            

            w.write((int)Math.ceil((b-1)/(a-1)) + "\n");
            w.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

// ========================================### FAST IO
// ###=========================================//
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

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

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}
// ====================================================================================================//

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;
 
int main() {
	uint N, K, R, S, P;
	cin >> N >> K >> R >> S >> P;
	
	string T;
	cin >> T;
	
	ull ans = 0;
	vector<ull> dpR(N);
	vector<ull> dpS(N);
	vector<ull> dpP(N);
	
	for(uint i=0; i<K; i++) {
		char c = T[i];
		dpR[i] = (c == 's') ? R : 0;
		dpS[i] = (c == 'p') ? S : 0;
		dpP[i] = (c == 'r') ? P : 0;
		
		ull tmp = max(dpR[i], max(dpS[i], dpP[i]));
		//cout << i << " " << dpR[i] << " " << dpS[i] << " " << dpP[i] << endl;
		
		for(uint j=i+K; j<N; j+=K) {
			c = T[j];
			uint r = (c == 's') ? R : 0;
			uint s = (c == 'p') ? S : 0;
			uint p = (c == 'r') ? P : 0;
			dpR[j] = max(dpP[j-K], dpS[j-K]) + r; 
			dpS[j] = max(dpR[j-K], dpP[j-K]) + s;
			dpP[j] = max(dpR[j-K], dpS[j-K]) + p;
			tmp = max(tmp, max(dpR[j], max(dpS[j], dpP[j])));
			//cout << j << " " << dpR[j] << " " << dpS[j] << " " << dpP[j] << endl;
		}
		
		ans += tmp;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 2816
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	a := readInt64()
	b := readInt64()
	x := readInt64()

	n := b/x - a/x
	if a%x == 0 {
		n++
	}
	println(n)
}


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

int main(void){
  while(1){
    int N;
    int n[200];
    int d[200];
    pair<int,int> pos[200];
    int left;
    int right;
    int bottom;
    int top;

    cin >> N;

    n[0] = 0;

    for(int i = 1 ; i < N ; i++){
      cin >> d[i];
      cin >> n[i];
    }

    if(N == 0){return 0;}

    if(N == 1){
      cout << 1 << " " << 1 << endl;
    }else{
      pos[0] = make_pair(0,0);
      for(int i = 1 ; i < N ; i++){
        switch(n[i]){
          case 0:
            pos[i] = make_pair(pos[d[i]].first - 1 , pos[d[i]].second);
            break;
          case 1:
            pos[i] = make_pair(pos[d[i]].first , pos[d[i]].second - 1);
            break;
          case 2:
            pos[i] = make_pair(pos[d[i]].first + 1 , pos[d[i]].second);
            break;
          case 3:
            pos[i] = make_pair(pos[d[i]].first , pos[d[i]].second + 1);
            break;
        }
      }

      int xmax = -256;
      int xmin = 256;
      int ymax = -256;
      int ymin = 256;

      for(int i = 0 ; i < N ; i++){
        int xtmp = pos[i].first;
        int ytmp = pos[i].second;
        if(xmax < xtmp){ xmax = xtmp; }
        if(xmin > xtmp){ xmin = xtmp; }
        if(ymax < ytmp){ ymax = ytmp; }
        if(ymin > ytmp){ ymin = ytmp; }
      }

      cout << xmax - xmin + 1 << " " << ymax - ymin + 1 << endl;
    }
  }

}

Measured memory_bytes: 2996
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
Mod = 1000000007



def main(): #startline-------------------------------------------
    S = input()
    keep = "A"
    ans = 0
    for i in S:
        if keep == "A":
            keep = i
        elif keep == i:
            ans += 1
            keep = ("0" if i == "1" else "1")
        else:
            keep = i
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================




def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

Measured memory_bytes: 5424
if __name__ == "__main__":
    N, K, S = map(int, input().split())
    for _ in range(K):
        print(S, end=" ")
    if S == 10**9:
        for _ in range(N-K):
            print(S-1, end=" ")
    else:
        for _ in range(N-K):
            print(S+1, end=" ")
    print()


Measured memory_bytes: 9296
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	printf("%d %d %d\n",a,b,c);
	
return 0;
}

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

const long long delta = 924844033, maxn = 4005;

long long pat_chos[maxn][maxn];
void calc_pat_chos(){
    for(long long i = 0; i < maxn; i++)
        pat_chos[i][0] = pat_chos[i][1] = 1;
    pat_chos[0][1] = 0;

    for(long long i = 2; i < maxn; i++)
        for(long long j = 1; j < maxn; j++)
            pat_chos[i][j] = (pat_chos[i - 1][j] + pat_chos[i - 2][j - 1]) % delta;
}

long long dp[maxn][maxn];
long long fact[maxn];

void nap(vector<long long> &v){
    dp[0][0] = true;
    for(long long i = 1; i <= (long long)(v.size()); i++){
        for(long long x = 0; x <= v[i - 1]; x++)
            for(long long sm = x; sm < maxn; sm++)
                dp[i][sm] = (dp[i][sm] + dp[i - 1][sm - x] * pat_chos[v[i - 1]][x]) % delta;
    }
    fact[0] = 1;
    for(long long i = 1; i < maxn; i++)
        fact[i] = (fact[i - 1] * i) % delta;
}

void solve(long long n, long long k){

    vector<long long> v;
    for(long long i = 0; i < k; i++){
        v.push_back(n / k - 1 + (i < (n % k)));
        v.push_back(n / k - 1 + (i < (n % k)));
    }
    //assert(v.size() <= n);
    nap(v);
    long long ans = 0;
    for(long long i = 0; i <= n; i++)
        if(i & 1ll)
            ans =(ans + delta - ((fact[n - i] * dp[v.size()][i]) % delta))% delta;
        else
            ans =(ans + ((fact[n - i] * dp[v.size()][i]) % delta))% delta;
    cout << ans << endl;
}

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    calc_pat_chos();
    long long n, k;
    cin >> n>> k;

    solve(n, k);

}


Measured memory_bytes: 254028
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

template<class T>
struct BIT{
    vector<T> data;
    int size;
    BIT(int sz){
        init(sz);
    }
    void init(int sz){
        size=sz;
        data.assign(++size,0);
    }
    T sum(int k){
        T ans=0;
        while(k>0){
            ans+=data[k];
            k-=k&(-k);
        }
        return ans;
    }
    // data[r:l]の合計
    T sum(int r,int l){
        if(r>l) swap(r,l);
        return sum(l)-sum(r-1);
    }
    void add(int k,T x){
        while(k<=size){
            data[k]+=x;
            k+=k&(-k);
        }
    }
};


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

    int N;
    ll D,A;
    cin>>N>>D>>A;
    vector<P> V(N);
    for(int i=0;i<N;i++){
        cin>>V[i].first>>V[i].second;
    }
    sort(V.begin(),V.end());
    V.push_back(P(INF,0));
    BIT<ll> b(N+1);
    ll ans=0;
    //cout<<1<<endl;
    for(int i=0;i<N;i++){
        ll sum=b.sum(i+1,N+1);
        //cout<<i<<" "<<sum<<endl;
        //if(i==8) cout<<b.sum(8)<<endl;
        V[i].second-=sum;
        if(V[i].second<=0) continue;
        int num=(int)(upper_bound(V.begin(),V.end(),P(V[i].first+2*D+1,-1))-V.begin());
        //cout<<num<<endl;
        b.add(num,(V[i].second+A-1)/A*A);
        ans+=(V[i].second+A-1)/A;
        //cout<<i<<" "<<ans<<endl;
    }
    //cout<<b.sum(8)<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,G=0;
    int L[114514];
    cin >> N;
    REP(i,N){
        cin >> L[i];
        G+=L[i];
    }
    sort(L,L+N);
    Yes(L[N-1]<G-L[N-1]);
    
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL);
typedef long long li;
const int N = 1e6 + 10;

int dp[N] , a[N];

int main(){

	/*#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
	#endif*/
  	
 	int n;
 	cin>>n;
 	int a[n];
 	int sum = 0;
 	for(int i = 0 ; i < n ; ++i){
 		cin>>a[i];
 		sum+=a[i];
 	}

 	int mx = *max_element(a,a+n);

 	sum-=mx;

 	if(sum>mx)
 		cout<<"Yes\n";
 	else cout<<"No\n";


}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define N 4097


typedef struct{
  double i,j ;
}Point;

Point data[N], tmp[N];
int size;

void kochCurve(Point a, Point b, int n, int p){
  Point o = (Point){(b.i-a.i)/3.0, (b.j-a.j)/3.0};
  Point s = (Point){o.i+a.i, o.j+a.j};
  Point u = (Point){s.i + o.i / 2.0 - sqrt(3.0) * o.j / 2.0, s.j + sqrt(3.0) * o.i / 2.0 + o.j / 2.0};
  Point t = (Point){(b.i-a.i)*2.0/3.0+a.i, (b.j-a.j)*2.0/3.0+a.j};
  if(p == n) return;
  kochCurve(a, s, n, p+1);
  data[size++] = s;
  kochCurve(s, u, n, p+1);
  data[size++] = u;
  kochCurve(u, t, n, p+1);
  data[size++] = t;
  kochCurve(t, b, n, p+1);
}

main(){
  int z, n;
  scanf("%d", &n);
  data[size++] = (Point){0.0, 0.0};
  kochCurve(data[0], (Point){100.0, 0.0}, n, 0);
  data[size++] = (Point){100.0, 0.0};
  for(z=0;z<size;z++) printf("%.8f %.8f\n", data[z].i, data[z].j);
  return 0;
}



Measured memory_bytes: 2020
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll n;
    cin >> n;
    ll ans = 0;

    for (int i = 1; i <= n; i++){
        if(i < 10 || (i >= 100 & i < 1000) || (i >= 10000 & i < 100000)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  str s; cin >> s;
  while(1)
  {
    s.pop_back();
    s.pop_back();
    str t;
    t = s.substr(0, s.size() / 2);
    if(s == t + t) fin(s.size());
  }
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
    
using namespace std;
bool sortin(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first < b.first); 
} 
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll de(ll N) 
{ 
  
    // To store the binary number 
    ll B_Number = 0; 
    ll cnt = 0; 
    while (N != 0) { 
        int rem = N % 2; 
        ll c = pow(10, cnt); 
        B_Number += rem * c; 
        N /= 2; 
  
        // Count used to store exponent value 
        cnt++; 
    } 
  
    return B_Number; 
} 
  
  
int main(){
    IOS;
ll n,k;
cin>>n;string a="";
while(n>0){
    if(n%26==0){ a=a+'z';n=n-26;}
    else a=a+(char)('a'+n%26-1);
   n=n/26;
}
reverse(a.begin(),a.end());
cout<<a;
    return 0;}

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

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

const int MOD = 1000000007;
const ll MAX = 1000000000000000000;


int main() {
  int n;
  cin >> n;
  bool not_ok = false;
  ll sum = 1;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
    sum *= a[i];
    if(a[i] == 0){
      cout << 0 << endl;
      return 0;
    }
    if(sum <= 0 || sum > MAX){
      not_ok = true;
    }
  }
  if(not_ok){
    cout << -1 << endl;
  }else{
    cout << sum << endl;
  }
}

Measured memory_bytes: 4048
#include<stdio.h>

int _min(int a,int b){return a<b?a:b;}

int main(){
	
	long long ans=0;
	int a,b,c,x,y,i;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(c*2<a+b){
		i=_min(x,y);
		ans+=i*c*2;
		x-=i;
		y-=i;
	}
	if(c*2<a)a=c*2;
	if(c*2<b)b=c*2;
	ans+=x*a+y*b;
	printf("%lld",ans);
	return 0;
}
	
		
	

Measured memory_bytes: 128
def is_pairwise():
    MAX_A = 10**6 + 1
    C = [0] * MAX_A
    for a in A: C[a] += 1
    if sum(C[2::2]) > 1: return False
    for i in range(3, MAX_A, 2):
        if sum(C[i::i]) > 1: return False
    return True

def solve():
    from functools import reduce
    from math import gcd
    if is_pairwise(): return 0
    if reduce(gcd, A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


Measured memory_bytes: 127520
#include <stdio.h>

int main() {
	int N;
	scanf("%d",&N);
	int A[N], B[N], C[N-1];
	for (int i = 0; i < N; i++) {
		scanf("%d",&A[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d",&B[i]);
	}
	for (int i = 0; i < N-1; i++) {
		scanf("%d",&C[i]);
	}

	int sum = 0, tmp1, tmp2;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			tmp1 = A[i];
			sum += B[tmp1-1];
		}
		else {
			tmp2 = A[i];
			sum += B[tmp2-1];
			if (tmp2 == tmp1 + 1) {
				sum += C[tmp1-1];
			}
			tmp1 = tmp2;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

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

int main() {

    vector<vector<int>> c(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    vector<int> a(3);
    vector<int> b(3);

    // a_0 = 0 と仮定しても問題ない
    a[0] = 0;

    // a_0 = 0 から b_0, b_1, b_2 を求める
    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];

    // b_0 から a_1, a_2 を求める
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    bool can = true;
    rep(i, 3) rep(j, 3) {
        if (c[i][j] != a[i] + b[j]) {
            can = false;
            break;
        }
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
  int N, Q, A, B, C;
  map<int, int> mp;
  cin >> N;

  ll calc = 0;
  rep(i, N) {
    cin >> A;
    mp[A]++;
    calc += A;
  }

  cin >> Q;
  vector<ll> ans(Q);
  rep(i, Q) {
    cin >> B >> C;
    calc += (C - B) * mp[B];
    ans[i] = calc;
    mp[C] += mp[B];
    mp[B] = 0;
  }

  rep(i, Q) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 8356
//shan61916
#include <bits/stdc++.h>
	using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;

int main(){
 IOS
#ifdef SHAN
	freopen("input.txt" , "r" , stdin);
#endif
	ll n,k ;
	cin>>n>>k ;
    vector<ll> a(n) ;
    for(ll i=0;i<n;i++)cin>>a[i] ;
    vector<ll> dp(n,0) ;
    	dp[0]=0 ;
    	for(ll i=1;i<n;i++)
    	{
    		ll ans= INT_MAX ;
    	  for(ll j=1;j<=k;j++)
    	  {
    	  	if((i-j)>=0)
    	  	{
    	  	 	ll x=  dp[i-j]+abs(a[i]-a[i-j]) ;
    	  	 	 ans=min(ans,x) ;	
    	  	}    
    	  }
    	 // cout<<ans<<endl ;
    	  dp[i]=ans ;
    		//cout<<ans<<" for "<<i<<endl ;
    	}
   cout<<dp[n-1] ;
	return 0;
}      // good night.

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
    int N,X,Y; cin >> N >> X >> Y;
    X--;Y--;
    if(X>Y) swap(X,Y);
    unordered_map<int,int> map;
    for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
        int res;
        if(i<=X && j>=Y) res=j-i-(Y-X)+1;
        else if(i<=X && j<Y && j>=X) res=min(j-i,X-i+1+Y-j);
        else if(i>X && j>=Y && i<=Y) res=min(j-i,i-X+1+j-Y);
        else if(i>X && j<Y) res=min(j-i,i-X+1+Y-j);
        else if((i<X && j<X) || (i>Y && j>Y)) res=j-i;
        //if(res==1) cout << i << " " << j << endl;
        map[res]++;
      }
    }
    for(int k=1;k<=N-1;k++){
      cout << map[k] << endl;
    }

}


Measured memory_bytes: 384
// 投票

#include <iostream>
using namespace std;

#define MAX_INDEX 1000
int main() {
    int num_sports;
    int num_members;
    int array_costs[MAX_INDEX] = {};
    int array_criteria[MAX_INDEX] = {};
    int array_votes[MAX_INDEX] = {};

    cin >> num_sports >> num_members;

    for (int i = 0; i < num_sports; i++) {
        cin >> array_costs[i];
    }

    for (int i = 0; i < num_members; i++ ) {
        cin >> array_criteria[i];
    }

    int max_votes = 0;
    int max_sports;
    for (int i = 0; i < num_members; i++) {
        for (int j = 0; j < num_sports; j++ ) {
            if (array_costs[j] <= array_criteria[i]) {
                array_votes[j]++;
                if (max_votes < array_votes[j]) {
                    max_votes = array_votes[j];
                    max_sports = j;
                }
                break;
            }
        }
    }
    cout << max_sports + 1 << "\n";
    return 0;
}


Measured memory_bytes: 3112
#pragma GCC optimize(2)
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e7+5+5e6;
using namespace std;
const ll INF=1e15+7;
const ll mod=1e9+7;
ll n,m,p;
int A[100][100];
int B[100][100];
int dx[2]={0,1};
int dy[2]={1,0};
bool dp[81][81][25605];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
        for(int k=1;k<=m;k++) scanf("%d",&A[i][k]);
    for(int i=1;i<=n;i++)
        for(int k=1;k<=m;k++) scanf("%d",&B[i][k]);
    dp[1][1][A[1][1]-B[1][1]+12800]=1;
    dp[1][1][B[1][1]-A[1][1]+12800]=1;
    for(int i=1;i<=n;i++)
    {
        for(int k=1;k<=m;k++)
        {
            if(i==1&&k==1) continue;
            for(int j=0;j<=25600;j++)
            {
                int temp1=A[i][k]-B[i][k];
                int temp2=B[i][k]-A[i][k];
                if(dp[i-1][k][j-temp1]||dp[i-1][k][j-temp2]) dp[i][k][j]=1;
                if(dp[i][k-1][j-temp1]||dp[i][k-1][j-temp2]) dp[i][k][j]=1;
            }
        }
    }
    int s=12800,e=12800;
    while(1)
    {
        if(dp[n][m][s]||dp[n][m][e]) break;
        e++;
        s--;
    }
    printf("%d\n",e-12800);
    return 0;
}


Measured memory_bytes: 162304
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll h, w, k; cin >> h >> w >> k;
    string mat[h];
    rep(i, h){
        cin >> mat[i];
    }

    ll ans = 0;
    ll maxb = pow(2, h + w);
    bool rows[h], cols[w];
    rep(b, maxb){
        ll btemp = b;
        rep(i, h){
            rows[i] = (btemp % 2 == 1) ? true : false;
            btemp >>= 1;
        }
        rep(i, w){
            cols[i] = (btemp % 2 == 1) ? true : false;
            btemp >>= 1;
        }

        // rep(i, h){
        //     cout << rows[i] << " ";
        // }
        // rep(i, w){
        //     cout << cols[i] << " ";
        // }
        // cout << endl;

        ll cnt = 0;
        rep(i, h){
            if(rows[i] == false) continue;

            rep(j, w){
                if(cols[j] == false) continue;

                if(mat[i][j] == '#') cnt++;
            }
        }

        if(cnt == k) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3960
// AOJ 2600: Koto Distance
// 2017.10.31 bal4u@cc

#include <stdio.h>

int width[100002], height[100002];

char buf[32], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int check(int *a, int sz)
{
	int s, x;
	for (s = 0, x = 0; x < sz; x++) {
		s += a[x];
		if (s <= 0) return 0;
	}
	return 1;
}

int main()
{
	int n, w, h, x, y, k, t;

	fgets(p=buf, sizeof(buf), stdin);
	n = getint(), p++, w = getint(), p++, h = getint();

	while (n--) {
		fgets(p=buf, sizeof(buf), stdin);
		x = getint(), p++, y = getint(), p++, k = getint();

		t = x - k; if (t < 0) t = 0;
		width[t]++;
		t = x + k; if (t > w) t = w;
		width[t]--;

		t = y - k; if (t < 0) t = 0;
		height[t]++;
		t = y + k; if (t > h) t = h;
		height[t]--;
	}

	puts(check(width, w) || check(height, h) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 2444
#include <bits/stdc++.h>
using namespace std;
# define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mod 1000000007 ;
typedef long long ll;

void IO()
{
	#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
	#endif 
}
vector<bool> used(200000);
vector<int> adj[200000];
vector<int> a,b;
void bfs(int i)
{	
queue<int> q;
	q.push(i);
	used[i] = 1;
	a.push_back(i);
	while(!q.empty())
	{	i = q.front();
		q.pop();
		for(auto vertex:adj[i])
		{	
			if(used[vertex]==-1)
			{
				used[vertex] = used[i]^1;
				if(used[vertex]==1) a.push_back(vertex);
				else b.push_back(vertex);
				q.push(vertex);
			}
			if(used[vertex]==used[i]){
				cout<<-1;
				exit(0);
			}
	
			}


	}
}
int dp[4000][4000];
// string ans = "";
// int LCS(string x,string y,int n,int m)
// {
// if(n==0 | m==0) return dp[n][m] = 0;
// if(dp[n][m]!=-1) return dp[n][m];
 
// if(x[n-1] == y[m-1] )
// 	return dp[n][m] = 1 + LCS(x,y,n-1,m-1);
// return dp[n][m] = max(LCS(x,y,n-1,m),LCS(x,y,n,m-1));

// }
void solve()
{

string x,y;
cin>>x>>y;
int n = x.size(), m = y.size();
// memset(dp,-1,sizeof(dp));	
for(int i = 0;i<m;i++)
dp[0][i] = 0 ;
for(int i = 0;i<n;i++)
	dp[i][0] = 0 ;
for(int i = 1;i<=n;i++)
for(int j = 1;j<=m;j++)
{
	
    if(x[i-1] == y[j-1])
		dp[i][j] = dp[i-1][j-1] + 1;
	else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
	
}
string ans = "";
int i = n,j = m;	 
while(i>0 & j>0){
if(x[i-1] == y[j-1])
{
	ans = x[i-1] + ans;
	i--;j--;
}
else {
	if(dp[i-1][j] >= dp[i][j-1])
		i--;
	else j--;
}

}

cout<<ans<<endl;

}
int main()
{
	IO();
	fast;
	// int t;cin>>t;while(t--)
	
	solve();	

		

	return 0;
}





Measured memory_bytes: 55156
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    ll m1 = -1,m2 = -1;
    double den = 0;
    rep(aa,31){
        rep(bb,31){
            rep(cc,101){
                rep(dd,101){
                    ll water = aa*a*100+bb*b*100;
                    ll sugar = cc*c+dd*d;
                    if (water + sugar > f || sugar > e*water/100) continue;
                    double k = sugar;
                    double n = 100.0*k/(k+water);
                    if (chmax(den,n)){
                        m1 = sugar+water;
                        m2 = sugar;
                    }
                }
            }
        }
    }
    if (m1 == -1){
        cout << 100*a << " " << 0 << endl;
    }
    else{
        cout << m1 << " " << m2 << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N){
    cin >> a.at(i);
  }
  int alice = 0;
  int bob = 0;
  rep(i, N){
    int max_index = 0;
    rep(j,a.size()){
      if(a.at(j)>a.at(max_index)) {
        max_index = j;
      }
    }
    if(i%2 == 0) alice += a.at(max_index);
    else bob += a.at(max_index);
    a.at(max_index) = a.at(a.size()-1);
    a.pop_back();
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
const long long mod = 1000000007;

long long kC2(long long k){
	return k * (k-1)/2 % mod;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> b(n,0);
	long long ans = 0;

	for(int i=0; i<n; i++) {
			int a;
			cin >> a;
			b[i] = a;
	}

	long long first_cnt=0;
	for (int i=0; i<n; i++) {
		for (int j=0; j<i; j++) {
			if (b[i] < b[j]) first_cnt++;
		}
	}

 	long long asc_num_cnt=0;
	sort(b.begin(), b.end());
	for (int i=0; i<n; i++) {
		for (int j=0; j<i; j++) {
			if (b[i] > b[j]) asc_num_cnt++;
		}
	}

	ans = (first_cnt*k + asc_num_cnt*(kC2(k)))%mod;

	cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll A,B,N;
    cin >> A >> B >> N;
    ll waru = min(N,B-1);
    cout << (A*waru)/B-A*(waru/B) << "\n";
}

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

int main() {
    int N;
    cin >> N;
    int d[110];
    

    for(int i = 0; i < N; ++i) {
        cin >> d[i];
    }
    
    set<int> values;
    for(int i = 0;i < N; ++i) {
        values.insert(d[i]);
    }

    cout << values.size() << endl;
}


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

typedef long long int ll;


double dp[310][310][310];
bool calc[310][310][310];
ll arr[310];
ll n;

double go(ll a, ll b, ll c){
    if(a + b + c == 0)  return 0;
    if(calc[a][b][c] == true)   return dp[a][b][c];
    calc[a][b][c] = true;
    double aa = 0, bb = 0, cc = 0;
    if(a){
        aa = ((double)(a)/(double)(n))*(go(a-1,b,c)+1);
    }
    if(b){
        bb = ((double)(b)/(double)(n))*(go(a+1,b-1,c)+1);
    }
    if(c){
        cc = ((double)(c)/(double)(n))*(go(a,b+1,c-1)+1);
    }
    double zeros = n-(a+b+c);
    double sum = (zeros/n)+aa+bb+cc;
    return dp[a][b][c] = sum / ((double)(1.0)-(zeros/n));
}
int main(){
    ll a = 0,b=0,c= 0;
    scanf("%lld",&n);

    for(int i = 0; i < n; i++){
        scanf("%lld",arr+i);
        if(arr[i] == 1)     a++;
        if(arr[i] == 2)     b++;
        if(arr[i] == 3)     c++;
    }
    double ans = go(a,b,c);
    printf("%.10f\n",ans);
}


Measured memory_bytes: 256256
#include<stdio.h>
#include<string.h>

#define M 1100000
#define L 14

char H[M][L];

int getChar(char ch){
	if(ch == 'A')return 1;
	else if(ch == 'C')return 2;
	else if(ch == 'G')return 3;
	else if(ch == 'T')return 4;
	return 0;
}

long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for(i = 0;i < strlen(str);i++){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){return key % M;}
int h2(int key){ return 1 + (key % (M-1));}
int h(int k,int i){
	return (h1(k) + i*h2(k)) % M;
}

int find(char str[]){
	long long key = getKey(str),i,j;
	for(i=0;;i++){
		j = h(key,i);
		if(strcmp(H[j],str)==0){
			return 1;
		}else if(strlen(H[j])==0){
			return 0;
		}
	}
	return 0;
}

int insert(char str[]){
	long long key = getKey(str),i=0,j;
	for(i=0;;i++){
		j = h(key,i);
		if(strcmp(H[j],str)==0){
			return 1;
		}else if(strlen(H[j])==0){
			strcpy(H[j],str);
			return 0;
		}
	}
	return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i=0;i<M;i++)H[i][0] = '\0';
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%s %s",com,str);
		if(com[0] == 'i'){
			insert(str);
		}else{
			if(find(str)){
				printf("yes\n");
	    	}else{
				printf("no\n");
	    	}
		}
    }
    return 0;
}


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

long floorSum(long n, long m, long a, long b)
{
    long ans;
    if (m <= a)
    {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (m <= b)
    {
        ans += n * (b / m);
        b %= m;
    }
    long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0)
        return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floorSum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

void main()
{
    auto T = readln.chomp.to!int;
    while (T--) {
        auto nmab = readln.split.to!(long[]);
        writeln(floorSum(nmab[0], nmab[1], nmab[2], nmab[3]));
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  ll a[N];
  ll S[N+1];
  S[0] = 0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    S[i+1] = S[i] + a[i];
  }
  ll ans = 1e15;
  for(int i=1; i<N; i++){
    ans = min(ans, abs(S[N]-2*S[i]));    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    if k <= (n - 1) * (n - 2) // 2:
        t = n - 1 + ((n - 1) * (n - 2)) // 2 - k
        print(t)
        cnt = 0
        for i in range(2, n + 1):
            print(1, i)
            cnt += 1
        for i in range(2, n + 1):
            for j in range(i + 1, n + 1):
                if cnt == t:
                    exit()
                print(i, j)
                cnt += 1
    else:
        print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 44016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(void){
	int a, b;
	cin >> a >> b;
	vector<int> calc(3);
	calc[0] = a+b;
	calc[1] = a-b;
	calc[2] = a*b;
	sort(calc.begin(),calc.end());
	cout << calc[2] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] c = new int[a];
        sc.nextLine();
        for(int i = 0;i<a;i++){
            c[i] = sc.nextInt();
        }
        Arrays.sort(c);
        int answer = 0;
        for(int i = 0;i<b;i++){
            answer += c[a-1-i];
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21716
#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> 

using namespace std;

#define _int64 long long

char s[600000];
int dp[600000][3];
vector<int> a;

int main()
{
  int i,j,n,cnt,tmp;
  scanf("%d",&n);
  scanf("%s",s);
  cnt=0;
  a.clear();
  for (i=0;i<n;i++)
  {
    if (s[i]=='1') cnt++;
    else
    {
      if (cnt>0) a.push_back(cnt);
      a.push_back(0);
      cnt=0;
    }
  }
  if (cnt>0) a.push_back(cnt);
  memset(dp,-1,sizeof(dp));
  dp[0][0]=0;
  for (i=0;i<a.size();i++)
  {
    for (j=0;j<3;j++)
      if (dp[i][j]!=-1)
      {
        if (dp[i+1][0]<dp[i][j])
          dp[i+1][0]=dp[i][j];
        if ((i+2<a.size())&&(a[i]>0)&&(a[i+1]==0)&&(a[i+2]>0))
        {
          if (j==0)
          {
            tmp=dp[i][j]+a[i]+1-1;
            if (a[i+2]>1)
            {
              if (tmp>dp[i+2][1]) dp[i+2][1]=tmp;
            }
            else
            {
              if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            }
            tmp=dp[i][j]+1+a[i+2]-1;
            if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            if (a[i+2]>1)
            {
              tmp=dp[i][j]+1+a[i+2]-1-1;
              if (tmp>dp[i+2][2]) dp[i+2][2]=tmp;
            }
          }
          if (j==1)
          {
            tmp=dp[i][j]+a[i]-1+1-1;
            if (a[i+2]>1)
            {
              if (tmp>dp[i+2][1]) dp[i+2][1]=tmp;
            }
            else
            {
              if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            }
            tmp=dp[i][j]+1+a[i+2]-1;
            if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            if (a[i+2]>1)
            {
              tmp=dp[i][j]+1+a[i+2]-1-1;
              if (tmp>dp[i+2][2]) dp[i+2][2]=tmp;
            }
          }
          if (j==2)
          {
            tmp=dp[i][j]+1+1-1;
            if (a[i+2]>1)
            {
              if (tmp>dp[i+2][1]) dp[i+2][1]=tmp;
            }
            else
            {
              if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            }
            tmp=dp[i][j]+1+a[i+2]-1;
            if (tmp>dp[i+3][0]) dp[i+3][0]=tmp;
            if (a[i+2]>1)
            {
              tmp=dp[i][j]+1+a[i+2]-1-1;
              if (tmp>dp[i+2][2]) dp[i+2][2]=tmp;
            }
          }
        }
      }
  }
  printf("%d\n",dp[a.size()][0]);
  return 0;
}

Measured memory_bytes: 9840
li1 = list(map(int,input().split()))
li2 = list(map(int,input().split()))
li3 = list(map(int,input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
A = li1+li2+li3

hit = []
for i in b:
    if i in A:
        hit.append(A.index(i)+1)

if (1 in hit and 2 in hit and 3 in hit)\
or (4 in hit and 5 in hit and 6 in hit)\
or (7 in hit and 8 in hit and 9 in hit)\
or (1 in hit and 4 in hit and 7 in hit)\
or (2 in hit and 5 in hit and 8 in hit)\
or (3 in hit and 6 in hit and 9 in hit)\
or (1 in hit and 5 in hit and 9 in hit)\
or (3 in hit and 5 in hit and 7 in hit):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
from heapq import heappop, heappush

h, w = map(int, input().split())
a = [['#'] * (w+2)] + [['#'] + list(input()) + ['#'] for _ in range(h)] + [['#'] * (w+2)]

MOD = 10 ** 9 + 7

#for x in a: print(x)

dp = [[0 for _ in range(w+1)] for _ in range(h+1)]
dp[1][1] = 1
for i in range(1, h+1):
    for j in range(1, w+1):
        if a[i-1][j] == '#' and a[i][j-1] == '#':
            continue
        elif a[i-1][j] == '#':
            dp[i][j] = dp[i][j-1]
        elif a[i][j-1] == '#':
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD

print(dp[h][w])

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

using namespace std;

int s[15][15];

int p[15];

int state[15];

int main(){
	int N, M;
	scanf("%d%d", &N, &M);
	
	memset(s, 0, sizeof(s));
	for(int i = 0; i < M; i ++){
		int k;
		scanf("%d", &k);
		for(int j = 0; j < k; j ++){
			int x;
			scanf("%d", &x);
			s[i][x-1] = 1;
		}
	}
	
	for(int i = 0; i < M; i ++){
		scanf("%d", &p[i]);
	}
	
	int ans = 0;
	for(int i = 0; i < (1<<N); i ++){
		memset(state, 0, sizeof(state));
		for(int j = 0; j < N; j ++){
			if(i & (1<<j)){
				state[j] = 1;
			}
		}

		bool legit = true;
		for(int j = 0; j < M; j ++){
			int temp = 0;
			for(int k = 0; k < N; k ++){
				if(state[k] && s[j][k]){
					temp += s[j][k];
				}
			}
			if(temp % 2 != p[j]){
				legit = false;
				break;
			}
		}
		ans += legit;
	}
	printf("%d", ans);
	
	return 0;
}


Measured memory_bytes: 256