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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

vector<int> zFunc(string s) {
    int n = (int) s.length();
    vector<int> z(n,0);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r) z[i] = min(r-i+1, z[i-l]);
        while (i+z[i] < n and s[z[i]] == s[i+z[i]]) ++z[i];
        if (i+z[i]-1 > r) l = i, r = i+z[i]-1;
    }
    return z;
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N; cin >> N;
    string S; cin >> S;

    string T = "";
    int ans = 0;
    FOR(i,0,N-1){
        T = S[N-1-i] + T;

        vector<int> z = zFunc(T);
        FOR(j,0,(int)T.length()-1) ans = max(ans, min(j,z[j]));
    }
    cout << ans << '\n';
}



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

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

  vector<long long> a(n + 1);
  a.at(0) = 2, a.at(1) = 1;
  for (int i = 2; i <= n; i ++) {
    a.at(i) = a.at(i - 1) + a.at(i - 2);
  }

  cout << a.at(n) << endl;
}


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

int main(){
  int N,K,x=1;
  cin >> N >> K;
  
  for(int i=0;i<N;i++){
  	if(x < K)
      x *= 2;
    else
    x+=K;   
  }
  cout << x;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

struct node{int key; node *p, *l, *r;};

node *nil, *root;

void preparse(node *root){
    if(root == nil) return;
    cout << " " << root->key;
    preparse(root->l);
    preparse(root->r);
}

void inparse(node *root){
    if(root == nil) return;
    inparse(root->l);
    cout << " " << root->key;
    inparse(root->r);
}

void insert(int k){
    node *y = nil;
    node *x = root;
    node *z;
    z = (node *)malloc(sizeof(node));
    z->key = k;
    z->l = nil;
    z->r = nil;
    while(x != nil){
        y = x;
        if(z->key < x->key) x = x->l;
        else x = x->r;
    }
    z->p = y;
    if(y == nil) root = z;
    else if(z->key < y->key) y->l = z;
    else y->r = z;
}

node * getminmum(node *x){
    while(x->l != nil) x = x->l;
    return x;
}

node * find(int k, node *cur){
   while(cur != nil && k != cur->key){
       if(k < cur->key) cur = cur->l;
       else cur = cur->r;
   }
   return cur;
}

node * getsuccess(node *x){
    if(x->r != nil) return getminmum(x->r);
    node *y = x->p;
    while(y != nil && x == y->r){
        x = y;
        y = y->p;
    }
    return y;
}



void deletenode(int k){
    node *y, *x;
    node *z = find(k, root);
    if(z->l == nil || z->r == nil) y = z;
    else y = getsuccess(z);
    if(y->l != nil) x = y->l;
    else x = y->r;
    if(x != nil) x->p = y->p;
    if(y->p == nil) root = x;
    else if(y == y->p->l) y->p->l = x;
    else y->p->r = x;
    if(y != z) z->key = y->key;
}



int main(){
    int n, d;
    string com;
    cin >> n;
    rep(i, n){
        cin >> com;
        if(com == "insert"){
            cin >> d;
            insert(d);
        }else if(com == "print"){
            inparse(root);
            cout << endl;
            preparse(root);
            cout << endl;
        }else if(com == "find"){
            cin >> d;
            if(find(d, root) != nil) cout << "yes" << endl;
            else cout << "no" << endl;
        }else if(com == "delete"){
            cin >> d;
            deletenode(d);
        }
    }
}


Measured memory_bytes: 21760
#include<iostream>
using namespace std;
int main() {
	int a;
	cin>>a;
	double result;
	if(a%2==0) {
		result=(a/2.0)/a;
	} else {
		result=(a+1)/2.0/a;
	}
		printf("%.10f",result);
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<string, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int q;
    cin >> q;
    while (q--)
    {
        string s, t;
        cin >> s >> t;
        int n = s.length(), m = t.length();
        s = "$" + s;
        t = "$" + t;
        vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
            {
                if (s[i] == t[j])
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                else
                {
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }
        cout << dp[n][m] << endl;
    }
}



Measured memory_bytes: 6924
x, n = map(int, input().split())
n_list = list(map(int, input().split()))

r_ascend = x
while r_ascend in n_list:
    r_ascend += 1

r_descend = x
while r_descend in n_list:
    r_descend -= 1

if abs(x - r_descend) <= abs(x - r_ascend):
    print(r_descend)
else:
    print(r_ascend)


Measured memory_bytes: 9180
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n;
double ans;
signed main() {
	cin >> n;
	rep(i, n) {
		double a;
		cin >> a;
		ans += (1.0 / a);
	}
	printf("%.10Lf\n", 1.0 / ans);
}


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

int main(void)
{
    string S;
    ll MOD = 2019;
    cin >> S;
    vector<int> m(2019, 0);
    vector<int> m2(2019, 0);
    ll total = 0;
    for(int i=0;i<S.size();i++){
        char c = S[i];
        int n = c - '0';
        // initialize
        for(int j=0;j<2019;j++){
            m2[j] = 0;
        }
        // update
        for(int j=0;j<2019;j++){
            if(m[j]){
                int r  = (j * 10 + n) % MOD;
                m2[r] += m[j];
                if (r==0){
                    total += m[j];
                }
            }
        }
        m2[n]++;
        for(int j=0;j<2019;j++){
            m[j] = m2[j];
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  string s,t;
  cin >> s >> t;

  string s1 = s + t.back();
  if(s1 == t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t; cin>>s>>t;
    if(s == t){cout<<"EQUAL"; return 0;}
    if(s.size() < t.size()){cout<<"LESS"; return 0;}
    if(s.size() > t.size()){cout<<"GREATER"; return 0;}
    for(int i=0; i<s.size(); i++){
        if(s.at(i) < t.at(i)){cout<<"LESS"; return 0;}
        if(s.at(i) > t.at(i)){cout<<"GREATER"; return 0;}
    }
}

Measured memory_bytes: 256
a, b = map(int, input().split())


def gcd(a, b):
    if a > b:
        a, b = b, a
    while a > 0:
        a, b = b % a, a
    return b


def lcm(a, b):
    return (a * b) // gcd(a, b)


print(lcm(a, b))


Measured memory_bytes: 9092
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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


int main(){
	vector<string> s;
	map<string,vector<int> > ma;
	string tmp;
	while(cin>>tmp){
		int t;
		cin>>t;
		ma[tmp].push_back(t);
		s.push_back(tmp);
	}
	sort(s.begin(),s.end());
	s.erase(unique(s.begin(),s.end()),s.end());
	rep(i,s.size()){
		cout<<s[i]<<endl;
		sort(ma[s[i]].begin(),ma[s[i]].end());
		rep(j,ma[s[i]].size()){
			if(j) cout<<" ";
			cout<<ma[s[i]][j];
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int res = 0;
  int num = 0;
  rep(i,n){
    if(s[i]=='D') res--;
    else res++;
    num = max(res, num);
  }
  cout << num << endl;
}


Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
list_of_red = list(map(int, input().split()))
list_of_green = list(map(int, input().split()))
list_of_colorless = list(map(int, input().split()))

list_of_green.sort(reverse=True)
list_of_red.sort(reverse=True)
list_of_colorless.sort(reverse=True)

max_of_red = list_of_red[:x]
max_of_green = list_of_green[:y]

temp = (max_of_red+max_of_green+list_of_colorless)
temp.sort(reverse=True)
ans = sum(temp[:x+y])
print(ans)

Measured memory_bytes: 23328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main () {
  int N;
  cin >> N;
  vector<string> s;
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    s.push_back(tmp);
  }

  int ans = 0;
  int isFirstA = 0;
  int isLastB = 0;
  int isBoth = 0;
  for (int i = 0; i < N; i++) {
    if (s[i][s[i].size()-1] == 'A') isFirstA++;
    if (s[i][0] == 'B') isLastB++;
    if (s[i][s[i].size()-1] == 'A' && s[i][0] == 'B') isBoth++;
    for (int j = 0; j < s[i].size() - 1; j++) {
      if (s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
    }
  }
  
  if (isFirstA == isLastB && isFirstA == isBoth && isBoth > 0) ans+= isBoth-1;
  else {
    ans+= min(isFirstA, isLastB);
  }
  if (ans < 0) ans = 0;
  //cout << isFirstA << "*" << isLastB << "*" << isBoth<< "**"; 

  cout << ans;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  lol a, b, c, A, B, C;
  cin >> a >> b >> c;
  rep(i, 100000000){
    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
      cout << i << '\n';
      return 0;
    }
    A = a / 2;
    B = b / 2;
    C = c / 2;
    a = B + C;
    b = A + C;
    c = A + B;
  }
  cout << "-1\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,n,a[100010];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  cout << a[0] << ' ';
  int x=2000000010,ans;
  for(i=1;i<n;i++){
    if(x>abs(a[0]-a[i]*2)){
      ans=a[i];
      x=abs(a[0]-a[i]*2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3928
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

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

int main() {
	string str;
	cin >> str;
	
	int anss = -1, anse = -1;
	REP(i, str.size() - 1) {
		if (str[i] == str[i + 1]) {
			anss = i + 1;
			anse = i + 2;
		}
		if (i + 2 < str.size() && str[i] == str[i + 2]) {
			anss = i + 1;
			anse = i + 3;
		}
	}
	
	cout << anss << " " << anse << endl;
	
	return 0;
}

Measured memory_bytes: 512
n = gets.to_i
x = gets.chomp
d = gets.to_i

i, c = 0, 0
while i < n && c < d
    if x[i] == "0"
        x[i] = "2"
        c += 1
    end
    i += 1
end
i -= 1
while i > -1 && c < d
    if x[i] == "1"
        x[i] = "0"
        c += 1
    end
    i -= 1
end
puts x.gsub("2", "1")


Measured memory_bytes: 6884
import java.util.*;

public class Main {
	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
      	int k = sc.nextInt();
      	int x = sc.nextInt();
      	int pos = k;
      	k *= -1;
      	k += 1;
      	while (k < pos) {
      		System.out.print(x + k + " ");
      		k++;
      	}
    }
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(10**6)

from bisect import bisect_left
from collections import deque
"""
行き ⇨ dp LIS計算とstack登録
帰り ⇨ stackをpop dp巻き戻し
"""

n = int(input())
As = list(map(int, input().split()))
edges = [[] for i in range(n)]
for i in range(n-1):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    edges[u].append(v)
    edges[v].append(u)


INF = 10**10
dp = []
pos = 0
ans = [0] * n
q = deque([])
def dfs(v,p):
    global pos
    # 行き
    a = As[v]
    ind = bisect_left(dp, a)
    if ind == len(dp): 
        dp.append(a)
        # 引数の1つ目はappendしたか
        q.append((True, -1, -1))
    else:
        # 更新
        tmp = dp[ind]
        dp[ind] = a
        q.append((False,ind,tmp))

    ans[v] = len(dp)
    for u in edges[v]:
        if u == p:continue
        dfs(u,v)
        # 帰り        
        isappend, ind, tmp = q.pop()
        if isappend:
            dp.pop()
        else:
            dp[ind] = tmp
        
    
dfs(0,-1)

print(*ans)

Measured memory_bytes: 235964
from collections import defaultdict
n = int(input())
A = [int(x) for x in input().split()]
even = A[0::2]
odd = A[1::2]
EC = defaultdict(int)
EC[0] = 0
OC = defaultdict(int)
OC[0] = 0
for e in even:
  EC[e] += 1
for o in odd:
  OC[o] += 1
E = sorted([[v, k] for k, v in EC.items()], reverse=True)
O = sorted([[v, k] for k, v in OC.items()], reverse=True)
if E[0][1] != O[0][1]:
  print(n - E[0][0] - O[0][0])
elif E[1][0] >= O[1][0]:
  print(n - E[1][0] - O[0][0])
else:
  print(n - E[0][0] - O[1][0])

#sample code.

Measured memory_bytes: 24896
package main;

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

func main() {

	var N, L int
	fmt.Scan(&N, &L)
	a := make([]int, N)
	S := readLine()
	l := strings.Split(S, " ")
	for i := 0; i < N; i++ {
		a[i], _ = strconv.Atoi(l[i])
	}

	mi := 0

	possible := false
	for l := 0; l < N - 1; l++ {
		if a[l] + a[l + 1] >= L {
			possible = true
			mi = l
		}
	}

	if !possible {
		fmt.Println("Impossible")
		return
	}
	fmt.Println("Possible")
	for l := 1; l <= mi; l++ {
		fmt.Println(l)
	}
	for l := N - 1; l > mi; l-- {
		fmt.Println(l)
	}

}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

using namespace std;
using LL = long long;
const int N = 1024;
const int INF = INT32_MAX - 1;
const double EPS = 1E-9;

int a[3][3];
int b[3][3];
int n, m;

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

#ifdef CF_DEBUG
    freopen("../cf/input.txt", "r", stdin);
#endif

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

    set<int> b;
    for (int i = 0; i < n; ++i) {
        int v;
        cin >> v;
        b.insert(v);
    }
    bool ok = false;
    for (int i = 0; i < 3; ++i) {
        if (b.find(a[i][0]) != b.end() && b.find(a[i][1]) != b.end() && b.find(a[i][2]) != b.end()) {
            ok = true;
            break;
        }
    }
    if (!ok) {
        for (int i = 0; i < 3; ++i) {
            if (b.find(a[0][i]) != b.end() && b.find(a[1][i]) != b.end() && b.find(a[2][i]) != b.end()) {
                ok = true;
                break;
            }
        }
    }
    if (!ok) {
        if (b.find(a[0][0]) != b.end() && b.find(a[1][1]) != b.end() && b.find(a[2][2]) != b.end()) {
            ok = true;
        }
    }
    if (!ok) {
        if (b.find(a[0][2]) != b.end() && b.find(a[1][1]) != b.end() && b.find(a[2][0]) != b.end()) {
            ok = true;
        }
    }

    if (ok)cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  //  int a;
    long long unsigned int a=0,x,total,total3,total5,total15;
   
    char s[10];
    // 整数の入力
  fgets(s,10,stdin);
  sscanf(s,"%llu\n",&a);
  total = ((1+a)*a/2);
  
  x = a/3;
//  printf("%llu ",total);
  total3 = ((3+3*x)*x/2);
  x=a/5;
 // printf("%llu ",total3);
  total5 = ((5+5*x)*x/2);
  x=a/15;
 // printf("%llu ",total5);
  total15 = ((15+15*x)*x/2);
  total = total - total3 - total5 + total15;
  printf("%llu",total);
  
}

Measured memory_bytes: 1772
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int top,S[1000];
void push(int x){
  S[++top]=x;
}
int pop(void){
  top--;
  return S[top+1];
}
int main(){
  int s[1000];
  int a,b;
  char ch[100];
  top=0;
  while(scanf("%s",ch)!=EOF){
    if(ch[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    } else if(ch[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    } else if(ch[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    } else {
      push(atoi(ch));
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 2744
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int main() {
	ll s;
	cin >> s;
	ll an = 0;
	ll ka = s;
	ll n = 0;
	while (ka > 0) {
		n++;
		ka /= 10;
	}
	n--;
	
	for (int bit = 0; bit < (1 << n); bit++) {
		ka = s;
		ll k = 10;
		rep(i, n) {
			if (bit & (1 << i)) {
				an += ka%k;
				ka /= k;
				k = 1;
			}
			k *= 10;
		}
		an += ka;
	}
	cout << an << endl;
}


Measured memory_bytes: 256
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
b = gets.chop.split.map(&:to_i)

ans=0


for i in 0..n-1 do

  ans += [a[i], b[i]].min
  b[i] = b[i] - [a[i], b[i]].min

  ans += [a[i+1], b[i]].min
  a[i+1] -= [a[i+1], b[i]].min

end

print ans


Measured memory_bytes: 21788
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll k, n, arr[N];

bool can(ll mid) {
  vector<int> vv;
  for (int i = 0; i < n; ++i)
    vv.push_back(arr[i] % mid);
  sort(vv.begin(), vv.end());
  int ptr1 = 0, ptr2 = n - 1;
  ll sum = 0, cost = 0;
  while(ptr1 <= ptr2) {
    if(sum <= 0) {
      cost += vv[ptr1];
      sum += vv[ptr1++];
    } else {
      sum -= (mid - vv[ptr2--]);
    }
  }
  if(cost <= k)
    return 1;
  return 0;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  ll sum = 0;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    sum += arr[i];
  }
  ll ans = 0;
  for (ll i = 1; i * i <= sum; ++i) {
    if(sum % i == 0) {
      if(can(i))
        ans = max(ans, i);
      if(can(sum / i))
        ans = max(ans, sum / i);
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> x;
    if(x == 25)
    {
        cout << "Christmas";
    }
    if(x == 24)
    {
        cout << "Christmas Eve";
    }
    if(x == 23)
    {
        cout <<"Christmas Eve Eve";
    }
    if(x == 22)
    {
        cout << "Christmas Eve Eve Eve";
    }
}


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

int main(){

 ull A,Ans=0;
 string B;
 cin>>A>>B;
 ull Aux=0;
 int i;

 if(B=="10.00")Aux=1000;
 else{
  Aux=((B[0]-'0')*100)+((B[2]-'0')*10)+((B[3]-'0')*1);
 }

 //cout<<Aux<<"\n";
 Ans=A*Aux;
 Ans/=100;
 cout<<Ans;
}


Measured memory_bytes: 3628
from bisect import bisect_left

s = input()
n = len(s)
s = s + s
t = input()
m = len(t)

ls = [[] for _ in range(26)]

for i in range(2*n):
    ls[ord(s[i])-97].append(i)

res = 0
flg = True
ind = -1
for i in range(m):
    if ls[ord(t[i])-97] == []:
        flg = False
        break
    nind = ls[ord(t[i])-97][bisect_left(ls[ord(t[i])-97],ind+1)]
    res += nind - ind 
    if nind >= n:
        nind -= n
    ind = nind
if flg:print(res)
else:print(-1)

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  int num = n;
  for (int i = 0; i < n; i++) cin >> m[i];

  int sum = accumulate(m.begin(), m.end(), 0);
  x -= sum;

  int minx = *min_element(m.begin(), m.end());

  num += x/minx;

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        List<Ten> ppl = new ArrayList<>();
        List<Ten> check = new ArrayList<>();
        int[] ans = new int[N];

        for(int i=0; i<N; i++){
            Ten point = new Ten(sc.nextInt(), sc.nextInt());
            ppl.add(point);
        }

        for(int i=0; i<M; i++){
            Ten point2 = new Ten(sc.nextInt(), sc.nextInt());
            check.add(point2);
        }

        for(int i=0; i<N; i++){
            double movePoint = Math.pow(10, 10);
            int answer = -1;
            for(int j=0; j<M; j++){
                double tmp = manhattan(ppl.get(i), check.get(j));
                if(tmp < movePoint){
                    movePoint = tmp;
                    answer = j+1;
                }
            }
            ans[i] = answer;
        }

        for(int i: ans){
            System.out.println(i);
        }
    }

    double manhattan(Ten point1, Ten point2){
        return Math.abs(point1.getX() - point2.getX()) + Math.abs(point1.getY() - point2.getY());
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

class Ten{
    private int x;
    private int y;

    Ten(int x, int y){
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <stdlib.h>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int X,Y;
  cin >> X >> Y;
  cout << X + Y/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

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

float v[50];

int main()
{
	int N;
	float ans = 0;

	cin >> N;
	rep(i, N) cin >> v[i];

	sort(v, v + N);
	ans = (v[0] + v[1]) / 2;
	rep(i, N - 2) ans = (ans + v[i + 2]) / 2;

	cout << ans << endl;

	return 0;
}


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

typedef long long int llint;

int main()
{
  int a, b;
  cin>> a >> b;

  a--, b--;

  char mas[101][101] = {};

  for(int i = 0; i < 50; i++) {
    for(int j = 0; j < 100; j++) {
      mas[i][j] = '#';
      mas[i + 50][j] = '.';
    }
  }
  
  for(int i = 0; i < 50; i += 2) {
    for(int j = 0; j < 100; j += 2) if(a) a--, mas[i][j] = '.';
  }
  
  for(int i = 99; i > 49; i -= 2) {
    for(int j = 0; j < 100; j += 2) if(b) b--, mas[i][j] = '#';
  }
  

  cout<< 100 << ' ' << 100 <<endl;

  for(int i = 0; i < 100; i++) cout<< mas[i] <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
 
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
const int INF = 1e9 + 5;
 
signed main() {
    FAST_IO;
 
    int n, k;
    cin >> n >> k;
    vector<int> stones(n);
    for (int i = 0; i < n; i++) cin >> stones[i];
 
    vector<int> dp(n, INF); // dp[i] : Minimum cost to reach stone i.
    dp[0] = 0; // Base case, we start on the first stone so cost to reach it is 0.
 
    for (int i = 0; i < n; i++) { // i represents the stone the frog is currently at.
        for (int j = i + 1; j <= i + k; j++) { // j represents a potential stone for the frog to jump to.
            if (j < n)
                // Storing the total minimum cost to reach stone j from stone i.
                dp[j] = min(dp[j], dp[i] + abs(stones[j] - stones[i]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 3988
/**
 * A - Colorful Transceivers
 */

#include <iostream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ((abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
//
// Created by karayuu on 2018-12-23.
//

int main() {
    double r;
    cin >> r;

    double s = r * r * M_PI;
    double l = 2 * r * M_PI;

    printf("%.6lf %.6lf\n", s, l);
}


Measured memory_bytes: 3184
import sys
from math import ceil
from operator import itemgetter as get

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

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

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nod(a, b):
    while b: 
        a, b = b, a % b
    return a
 
def calc(n, c, d):
    return n - n // c - n // d + n // (c * d // nod(c, d))   


def main():
    res, x = 0, []
    n, d = rinput()
    for i in range(n):
        x.append(rlinput())
     
    for o in range(n - 1):
        for u in range(o + 1, n):
            if ((sum((i - j) ** 2 for i, j in zip(x[o], x[u]))) ** 0.5).is_integer():
                res += 1
    print(res)
main() 

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
main(){
    int long long N;
    int long long a;
    int long long b;
    cin>>N;
    cin>>a;
    cin>>b;
    if(a+b>N+1) cout<<-1;
    else if(a*b<N) cout<<-1;
    else{
        int n[N]={};
        int b1;
        if(b!=1)
        b1=((N-a)%(b-1))+1;
        else 
        b1=1;
        int t;
        if(b!=1)
        t=(N-a)/(b-1);
        else t=0;
        for(int i=0;i<b*t;i++)
        n[i]=(i/b)*b+b-(i%b);
        for(int i=0;i<b1;i++)
        n[b*t+i]=b*t+b1-i;
        for(int i=(b*t+b1);i<N;i++)
        n[i]=i+1;
        for(int i=0;i<N-1;i++)
        cout<<n[i]<<" ";
        cout<<n[N-1];
        }
        return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
long long ans,n,a[200010],b;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	b=a[0];
	for (int i=1;i<n;i++){
		ans+=max((long long)0,b-a[i]);
		b=max(b,a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5180
s = int(input())

if s==1:
    print(4)
elif s==2:
    print(4)
else:
    no=1
    cnt=0
    if s==4:
        cnt+=1
    for i in range(1000000):
        no+=1
        if s%2==0:
            s=int(s/2)
        else:
            s=3*s+1
        if s==4:
            cnt+=1
        if cnt==2:
            break
    print(no)


Measured memory_bytes: 38384
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

L = [0]*N
R = [0]*N
for i in range(N):
    L[i] = i + 1 + A[i]
    R[i] = i + 1 - A[i]

cnt_L = Counter(L)
cnt_R = Counter(R)
ans = 0
for l, cnt in cnt_L.items():
    ans += cnt * cnt_R.get(l, 0)
print(ans)


Measured memory_bytes: 63312
#from collections import defaultdict

n = int(input())
cnt =[0]*1000000

l = list(map(int, input().split()))

for i in l:
    cnt[i] += 1
    
sums = sum(l)
    
m = int(input())

for i in range(m):
    a,b = map(int, input().split())
    
    diff = (b-a)*cnt[a]
    sums += diff
    print(sums)
    
    cnt[b] += cnt[a]
    cnt[a] = 0

Measured memory_bytes: 28636
import java.io.*; 
import java.lang.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
public static void main(String[] args){
try{
   BufferedReader reader =
                   new BufferedReader(new InputStreamReader(System.in));
        String b = reader.readLine();
     
    int n = b.length();
  	String ans = "";
  String x = "x";
  	for(int i=0;i<n;i++){
      ans = ans.concat(x);
     
    }
  System.out.println(ans);
}catch(Exception e){}
}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> h(n+1,0);
  int m=0;
  for(int i=1;i<=n;i++){
    cin>>h.at(i);
    m=max(m,h.at(i));
  }
  int c=0;
  for(int x=0;x<m;x++){
    for(int i=1;i<=n;i++)
      if(h.at(i-1)==0&&h.at(i)>0)
        c++;
    for(int i=1;i<=n;i++)
      if(h.at(i)>0)
        h.at(i)--;
  }
  cout<<c<<endl;
}

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

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

	int x,y;

	cin >> x >> y;

	for(int a=0;a<=x;a++)
	{
		int b = x - a;
		if(4*a + 2*b == y)
		{
			cout << "Yes" << '\n';
			return 0;
		}
	}

	cout << "No" << '\n';
	
    return 0;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;

const int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	int k;
	scanf("%d", &k);
	--k;
	printf("%d\n", a[k]);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,v,n,m,k;
  int V[107][107];
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d%d",&v,&m);
    if(m != 0){
      for(j = 0; j < m; j++){
	scanf("%d",&k);
	V[v-1][k-1] = 1;
      }
    }
  }

  for(i = 0; i < n; i++){
    j = 0;
    printf("%d",V[i][j]);
    for(j = 1; j < n; j++){
      printf(" %d",V[i][j]);
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main() {
    int a, b, c, ans;
    scanf("%d %d %d", &a, &b, &c);

    if (a == b) {
        if (a == c) ans = 1;
        else ans = 2;
    } else if (a == c) ans = 2;
        else if (b == c) ans = 2;
        else ans = 3;

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define fin for(int i=0;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
int m = 1e9+7;
int dp[2001];

int add(int x, int y){
	x += y;
	while(x >= m) x -= m;
	while(x < 0) x += m;
	return x;
}

int helper(int s){
    if(s == 0) return 1;
    if(s<3) return 0;
    int a =0;
    if(dp[s]!=-1) return dp[s];
    for(int i = 3;i<=s;i++){
        a = add(a,helper(s-i));
    }
    dp[s] = a;
    return a;
}

void solve(){
  int s;
  cin>>s;
  f(i,0,s+1) dp[i] = -1;
  cout<<helper(s);
 
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while(t--) solve();
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    long long n,a[111111];
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    long long num=1;
    rep(i,n){
        double c1=log10(num);
        double c2=log10(a[i]);
        if(c1+c2>18.0){
            cout<<-1<<endl;
            return 0;
        }
        num*=a[i];
        if(num>1000000000000000000){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<num<<endl;
}


Measured memory_bytes: 4712
#! /usr/bin/python3
# Contest with Drinks Easy

"""
    入力は全て整数である
    1≦N≦100
    1≦Ti≦105
    1≦M≦100
    1≦Pi≦N
    1≦Xi≦105
"""
test = False

N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = []
X = []

for _ in range(M):
    temp_P, temp_X = map(int, input().split())
    P.append(temp_P)
    X.append(temp_X)

if test:
    print('P =', P)
    print('X =', X)


def main():
    """
    飲まないときの時間を基準にして、飲んだ時の差分を引く。
    """
    default_time = sum(T)
    for i in range(M):
        dt = T[P[i] - 1] - X[i] # 速くなる時間
        print(default_time - dt) # かかる時間


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin>>N;
  int ans=N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  int mi=p[0];
  for(int i=1;i<N;i++){
    if(p[i]>mi){
      ans-=1;
    }
    else{
      mi=p[i];
    }
  }
  cout<<ans<<endl;
}  

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

int main(){
  int stu,pla,tmp;
  int ank[1111]={0};
  int num[1111];
  while(1){
    int cou[1111]={0};
    cin >> stu >> pla;
    if(stu == 0 && pla == 0)break;
    for(int i=0;i<stu;i++){
      for(int j=0;j<pla;j++){
	cin >> ank[j];
	if(ank[j] != 0){
	  cou[j]++;
	}
      }
    }
    for(int i=0;i<pla;i++){
      num[i] = i+1;
    }
    for(int i=0;i<stu;i++){
      for(int j=i+1;j<pla;j++){
	if(cou[i]<cou[j]){
	  tmp = cou[i];
	  cou[i] = cou[j];
	  cou[j] = tmp;
	  tmp = num[i];
	  num[i] = num[j];
	  num[j] = tmp;
	}
      }
    }
    for(int i=0;i<stu;i++){
      for(int j=i+1;j<pla;j++){
	if(cou[i] == cou[j]){
	  if(num[i]>num[j]){
	    tmp = cou[i];
	    cou[i] = cou[j];
	    cou[j] = tmp;
	    tmp = num[i];
	    num[i] = num[j];
	    num[j] = tmp;
	  }
	}
      }
    }
    for(int i=0;i<pla;i++){
      cout << num[i];
      if(i == pla-1){
	cout << endl;
      }
      else{
	cout << " ";
      }
    }
  }
}
  

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s,t;
    cin >> s >> t;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

LL a, b, ans = 1;

int main() {
	read(a), read(b);
	LL p = __gcd(a, b);
	for (int i = 2; 1ll * i * i <= p; ++i)
		if (p % i == 0) {
			for (; p % i == 0; p /= i);
			++ans;
		}
	if (p > 1) ++ans;
	write(ans);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int L = sc.nextInt();
		ArrayList<ArrayList<Integer>> cs = new ArrayList<>();
		for (int i = 0; i < N * M; ++i) {
			cs.add(new ArrayList<>());
		}
		for (int i = 0; i < M; ++i) {
			int D = sc.nextInt();
			int A = sc.nextInt() - 1;
			int K = sc.nextInt();
			int T = sc.nextInt();
			int start = D * N + A;
			cs.get(start).add((K << 16) | T);
		}
		int[][] dp = new int[L + 1][N * M + 1];
		for (int i = 0; i < N * M; ++i) {
			for (int j = 0; j < L; ++j) {
				for (int c : cs.get(i)) {
					int len = c >> 16;
					int t = c & 0xFFFF;
					dp[j + 1][i + len] = Math.max(dp[j + 1][i + len], dp[j][i] + t);
				}
			}
			for (int j = 0; j <= L; ++j) {
				dp[j][i + 1] = Math.max(dp[j][i + 1], dp[j][i]);
			}
		}
		int ans = 0;
		for (int i = 0; i <= L; ++i) {
			ans = Math.max(ans, dp[i][N * M]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 34368
typedef long long ll;
typedef unsigned long long ull;
/*
id: sadykhzadeh -> @Azer_Sadykhzadeh
Programming Language: (C++)
*/
#define qq2(x,y) cerr << (#x) << " = " << (x) << '\t' << (#y) << " = " << (y) << endl
#define qq(x) cerr << (#x) << " = " << (x) << endl
#define elif else if
#define pb push_back
#define ins insert
#define pow2(x) ((x)*(x))
#define mod(x, m) ((x) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define rus_lang setlocale(LC_ALL , "Russian")
#define F_READ ios_base::sync_with_stdio(false);cin.tie(0)
#define MOD 1000000007
#define line cerr << endl << endl << "========================" << endl
#define COUT(x) return cout << (x) << endl, 0;
#define stop return 0
using namespace std;
#include <bits/stdc++.h>
ll T1 = clock();
void timer(){rus_lang; ll T2(clock());cerr<<"Время: "<<(T2-T1)/1000.<<" секунд."<<endl;
cerr << "Автор: Азер Садыхзаде";}
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

int main(){
    set <ll> s;
    for(ll a = 1; a <= 9; a++){
        for(ll b = 1; b <= 9; b++){
            s.ins(a*b);
        }
    }
    ll n;
    cin >> n;
    for(set <ll> ::iterator it = s.begin(); it != s.end(); it++){
        if((*it) == n) return cout << "Yes" << endl, 0;
    }
    cout << "No";
}


Measured memory_bytes: 256
from sys import stdin

n, x, y = [int(x) for x in stdin.readline().rstrip().split()]
li = [0 for x in range(n - 1)]

for i in range(1, n):
    for j in range(i + 1, n + 1):
        if i >= y or j <= x:
            dis = j - i
        elif i <= x and j >= y:
            dis = j - y + x - i + 1
        elif i >= x and j <= y:
            dis = min(j - i, i + y - x + 1 - j)
        elif i >= x:
            dis = j - y + min(y - i, i - x + 1)
        else:
            dis = x - i + min(j - x, y + 1 - j)
        li[dis - 1] = li[dis - 1] + 1

for x in li:
    print(x)


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

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

    // E の累積和
    int arr_e[n] = {0};
    for (int i = 0; i < n; i++) {
        if (s.at(i) == 'E') {
            arr_e[i] = 1;
        }
    }
    int sum_e[n+1] = {0};
    for (int i = 0; i < n+1; i++) {
        if (i == 0) {
            continue;
        }
        sum_e[i] = sum_e[i-1] + arr_e[i-1];
    }
    // リーダーの位置を変えて向きを変える人数の最小値を調べる
    int ans = 1000000;
    for (int i = 0; i < n; i++) {
        int tmp = i - sum_e[i] + sum_e[n] - sum_e[i+1];
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3076
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN];
map<int,int> mp;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) 
    {
        scanf("%d",&a[i]);
        mp[a[i]]++;
    }
    if(n%3!=0)
    {
        if(mp.size()==1&&a[0]==0) puts("Yes");
        else puts("No");
    }
    else
    {
        bool f=true;
        if(mp.size()>3) f=false;
        int x=0;
        for(auto p:mp)
        {
            if(p.S%(n/3)!=0) f=false;
            for(int j=0;j<p.S/(n/3);j++) x^=p.F;
        }
        if(x!=0) f=false;
        if(f) puts("Yes"); else puts("No");
    }
    return 0;
}



Measured memory_bytes: 4224
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

long n,m;
vector<vector<long> > z;
long vis[10];
long cnt;
ll   ans;

void dfs( long curr )
{
    if(cnt==n) {
        ans++;
        return;
    }

    long i;
    for(i=0; i<(long)z[curr].size(); i++) {
        if(!vis[z[curr][i]]) {
            vis[z[curr][i]]=1;
            cnt++;
            dfs( z[curr][i] );
            vis[z[curr][i]]=0;
            cnt--;
        }
    }
    return;
}

int main(int argc, char* argv[])
{
    scanf("%ld%ld", &n, &m);

    z.resize(n);
    long i;
    for(i=0; i<m; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        z[a-1].push_back(b-1);
        z[b-1].push_back(a-1);
    }

    ans=0;
    vis[0]=1;
    cnt = 1;
    dfs( 0 );

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
  ll n;
  cin>>n;
  set<char>s;
  for(int i=0;i<n;i++)
  {
    char c;
    cin>>c;
    s.insert(c);
    
  }
  if(s.size()==3)
    cout<<"Three"<<endl;
  else
  {
    cout<<"Four"<<endl;
  }
  
    
}
return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] foodCount = new int[M];
        for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        }
        
        int howManyFoodAllGuysLike = 0;
        for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        }
        System.out.println(howManyFoodAllGuysLike);
    }
}


Measured memory_bytes: 23764