akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from math import ceil

def is_stackable(k,p,w):
    if max(w) > p:
        return False
    s = w[0]
    count = len(w)
    for i in range(1, len(w)):
        if s + w[i] <= p:
            s += w[i]
            count -= 1
        else:
            s = w[i]
    return k >= count

def main():
    n,k = map(int, stdin.readline().split())
    w = [int(line) for line in stdin.readlines()]
    
    left = max(max(w), ceil(sum(w)/k))
    right = (max(w) * ceil(n/k)) + 1
    while True:
        mid = int((left + right) / 2)
        if is_stackable(k, mid, w):
            if not is_stackable(k, mid - 1, w):
                print(mid)
                break
            right = mid
        else:
            if is_stackable(k, mid + 1, w):
                print(mid + 1)
                break
            left = mid + 1

main()


Measured memory_bytes: 15968
using System;
using System.Collections.Generic;

namespace ITP1_1_A
{
    class Program
    {
        static private List<int> matrixA = new List<int>();
        static private List<int> matrixB = new List<int>();
        static private List<long> matrixC = new List<long>();
        static private int input_A_Row;
        static private int input_A_Column;
        static private int input_B_Row;
        static private int input_B_Column;

        static void Main(string[] args)
        {
            InputInforMatrix();
            InputMatrix(input_A_Row, input_A_Column, matrixA);
            InputMatrix(input_B_Row, input_B_Column, matrixB);
            CalculateMatrix(input_A_Row, input_A_Column, matrixA, input_B_Row, input_B_Column, matrixB, matrixC);
            OutputMatrix(matrixC, input_A_Row, input_B_Column);
        }

        static void InputInforMatrix()
        {
            string[] num = Console.ReadLine().Split();
            input_A_Row = int.Parse(num[0]);
            input_A_Column = int.Parse(num[1]);
            input_B_Row = int.Parse(num[1]);//input_B_Row=input_A_Column
            input_B_Column = int.Parse(num[2]);
        }

        static void InputMatrix(int row, int column, List<int> matrix)
        {
            for (int i = 0; i < row; i++)
            {
                string[] num = Console.ReadLine().Split();
                for (int j = 0; j < column; j++)
                {
                    matrix.Add(int.Parse(num[j]));
                }
            }
        }
        static void CalculateMatrix(int firstMatrixRow, int firstMatrixColumn, List<int> firstMatrix, int secondMatrixRow, int secondMatrixColumn, List<int> secondMatrix, List<long> answerMatrix)
        {
            if (firstMatrixColumn != secondMatrixRow) return;
            for (int iniA = 0; iniA < firstMatrixRow * firstMatrixColumn; iniA += firstMatrixColumn)
            {
                for (int iniB = 0; iniB < secondMatrixColumn; iniB++)
                {
                    long sum = 0;
                    for (int i = 0; i < input_A_Column; i++)
                    {
                        sum += firstMatrix[iniA + i] * secondMatrix[i * secondMatrixColumn + iniB];
                    }
                    answerMatrix.Add(sum);
                }
            }
        }
        static void OutputMatrix(List<long> matrix, int row, int column)
        {
            for (int i = 0; i < row * column; i++)
            {
                Console.Write(matrix[i]);
                if (i % column == column - 1)
                {
                    Console.WriteLine();
                }
                else
                {
                    Console.Write(" ");
                }
            }
        }
    }
}



Measured memory_bytes: 18552
#include<iostream>
using namespace std;
int main() {
	int a, b,count=0;
	cin >> a >> b;
	for (int i = 1; i <= a; i++) {
		for (int j = 1; j <= 31; j++) {
			if (i == j)count++;
			if (i == a&&j == b)break;
		}
	}
	cout << count << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    if(a < b){
    ll tmp = a;
    a = b;
    b = tmp;
    }
    ll r = a % b;
    while(r!=0){
    a = b;
    b = r;
    r = a % b;
    }
    
    ll juge = 0;
    ll ans = 1;
    ll num = sqrt(b);
    ll numm = b;
    for(ll i = 2; i <= num; i++){
        while(b % i == 0){
            juge = 1;
            b /= i;
        }
        if(juge == 1){ 
            ans ++; juge = 0;
            if(IsPrime(b)){
                ans++;
                b /=b;
            }
    
        }
    }
    
    if(IsPrime(numm)) ans++;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
//Binomial Coefficients

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<double, ll>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    sort(range(a),greater<int>());
    vector<p>c;
    rep(i,1,n){
        double x = fabs(a[i]-(double)a[0]/2);
        c.pb(mp(x,a[i]));
    }
    sort(range(c));
    cout<<a[0]<<spa<<c[0].second<<nnn;
    return 0;
}

Measured memory_bytes: 6068
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vector<pair<ll,ll>>pll(n);
  for(int i=0;i<n;i++){
    cin>>pll[i].F;
    pll[i].S=i+1;
  }
  sort(ALL(pll));
  set<ll>se;
  se.insert(n+1);
  se.insert(0);
  ll ans=0;
  for(int i=0;i<n;i++){
    auto lb = se.lower_bound(pll[i].S);
    ll ri = *lb;
    lb--;
    ll le = *lb;
    ans += pll[i].F*(ri-pll[i].S)*(pll[i].S-le);
    se.insert(pll[i].S);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12800
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private void execute() throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] b = sc.nextLine().split(" ");
        int[] a = new int[n];
        a[0] = Integer.parseInt(b[0]);
        for (int idx = 0; idx < (n - 1); idx++) {
            int bValue = Integer.parseInt(b[idx]);
            a[idx + 1] = bValue;
            if (bValue < a[idx]) {
                a[idx] = bValue;
            }
        }
        int maxTotal = 0;
        for (int i : a) {
            maxTotal += i;
        }
        System.out.println(maxTotal);
    }

    public static void main(String[] args) {
        try {
            new Main().execute();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}


Measured memory_bytes: 21716
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int r=sc.nextInt();
			int c=sc.nextInt();
			if(r==0&&c==0)break;
			if(r%2!=0&&c%2!=0)System.out.println("no");
			else System.out.println("yes");
		}
	}
}

Measured memory_bytes: 20860
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
cnt = 0
flg = 0
ans = 'No'

for i in range(n):
  if cnt>0:
    if (x[i]==y[i]) and (flg == 1):
      cnt+=1
      flg = 1
      if cnt>=3:
        ans = 'Yes'
        break
    else:
      cnt = 0
      flg = 0
  elif (x[i]==y[i]) and (cnt==0):
    cnt+=1
    flg = 1
    if cnt>=3:
      ans = 'Yes'
      break
  
  else:
    flg = 0
    cnt = 0

print(ans)
  
  
  

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
 
using Graph=vector<vector<int>>;
 
pair<int,int> dfs(int v,int pre,Graph& g,vector<int> &l,vector<int> &r,vector<int>& vp){
    int lres=-1e9;
    int rres=1e9;
    if(vp[v]!=-1) lres=rres=vp[v];
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=pre){
            auto lr=dfs(g[v][i],v,g,l,r,vp);
            int lret=lr.first-1;
            int rret=lr.second+1;
            lres=max(lret,lres);
            rres=min(rret,rres);
            if(rres<lres){
                throw "No";
            }
        }
    }
    l[v]=lres,r[v]=rres;
    return make_pair(lres,rres);
}
void rdfs(int v,int pre,Graph& g,vector<int> &l,vector<int> &r,int ln,int rn){
    l[v]=max(l[v],ln);
    r[v]=min(r[v],rn);
    if(r[v]<l[v]){
        throw "No";
    }
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=pre){
            rdfs(g[v][i],v,g,l,r,l[v]-1,r[v]+1);
        }
    }
    return;
}
 
void check(int v,int pre,int odd,vector<int>& l,vector<int> &r,Graph& g){
    if(l[v]&1!=odd){
        if(r[v]!=l[v]){
            l[v]=l[v]+1;
        }
        else{
            throw "NoC";
        }
    }
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=pre){
            check(g[v][i],v,odd^1,l,r,g);
        }
    }
}
int main(){
    int n;
    cin>>n;
    Graph g(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int k;
    cin>>k;
    vector<int> vp(n,-1);
    vector<int> l(n);
    vector<int> r(n);
    int to=-1;
    for(int i=0;i<k;i++){
        int v,p;
        cin>>v>>p;
        v--;
        to=v;
        vp[v]=p;
    }
    try{
        
        dfs(0,-1,g,l,r,vp);
        rdfs(0,-1,g,l,r,-1e9,1e9);
        check(to,-1,vp[to]&1,l,r,g);
        printf("Yes\n");
        for(int i=0;i<n;i++){
            printf("%d\n",l[i]);
        }
    }catch(...){
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 18560
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    s = insr()
    t = insr()
    c = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            c = c + 1
    print(c)
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1],1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 68124
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := make([]int, n+2)
	for i := 1; i <= n; i++ {
		a[i] = nextInt()
	}

	s := 0
	for i := 1; i < n+2; i++ {
		s += abs(a[i] - a[i-1])
	}

	for i := 1; i <= n; i++ {
		puts(s + abs(a[i+1]-a[i-1]) - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]))
	}
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 3840
/*======================
 * Author : ylsoi
 * Problem : AGC02E
 * Algorithm : SG
 * Time : 2018.6.2
 * ===================*/
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<climits>
using namespace std;
void File(){
    freopen("AGC02E.in","r",stdin);
    freopen("AGC02E.out","w",stdout);
}
template<typename T>bool chkmax(T &_,T __){return _<__ ? (_=__,1) : 0;}
template<typename T>bool chkmin(T &_,T __){return _>__ ? (_=__,1) : 0;}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define MREP(i,x) for(register int i=beg[x];i;i=E[i].last)
#define mem(a) memset(a,0,sizeof(a))
#define inf INT_MAX
const int maxn=1e5+10;
int n,a[maxn],SG[1010][1010];
bool cmp(int _,int __){return _>__;}
bool judge(int x,int y){return x<=n && y<=a[x];}    
int main(){
    scanf("%d",&n);
    REP(i,1,n)scanf("%d",&a[i]);
    sort(a+1,a+n+1,cmp);
    int px=1,py=1,step1=0,step2=0;
    while(judge(px+1,py+1))++px,++py;
    while(judge(px+step1,py))++step1;
    while(judge(px,py+step2))++step2;
    if(step1%2==0 || step2%2==0)puts("First");
    else puts("Second");
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
		String t = sc.next();
		int len = s.length();
		int count = 0;

		for(int i = 0; i < len; i++) {
			char a = s.charAt(i);
			char b = t.charAt(i);
			if(a != b) {
				count++;
			}
		}
		System.out.println(count);
    }
}

Measured memory_bytes: 40968
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    string S;
    cin >> N >> S;
    if(N % 2 == 0){
        if(S.substr(0, N/2) == S.substr(N/2)) puts("Yes");
        else puts("No");
    }else{
        puts("No");
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define emb emplace_back
#define em emplace
#define ii pair<int,int>
#define iii pair<int ,ii>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define allc(x) x.begin(),x.end(),cmp
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
const int INF = 0x3f3f3f3f;
const int MXN = 1e5 + 5;

long long w[MXN][2];
long long dp[MXN];

int main(){
    int n , m;
    scanf("%d %d",&n,&m);
    for(int i = 1 ; i <= n ; i++){
        scanf("%lld %lld",&w[i][0] ,&w[i][1]);
    }
    for(int i = 1 ; i <= n ; i++){
        for(int j = m ; j >= w[i][0] ; j--){
            dp[j] = max(dp[j] , dp[j - w[i][0]] + w[i][1]);
        }
    }
    printf("%lld",dp[m]);
}

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

using namespace std;

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

    char input;
    for (int i = 1; i <= n; i++)
    {
        cin >> input;
        if (i == k)
        {
            input = putchar(tolower(input));
        } else {
            cout << input;

        }
        
    }
}


Measured memory_bytes: 256
// B - Theater
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	int ans = 0;
	rp(i, 0, N){
		int l,r; cin>>l>>r;
		ans += r - l + 1;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int ans = 0;
    rep(i,k) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
from collections import deque

N=int(input())
E=[[] for _ in range(N+1)]
P=[]

for a in range(1,N+1):
    S=input()
    for b in range(1,N+1):
        if S[b-1]=="1":
            E[a].append(b)

            if a<b:
                P.append((a,b))

M=-1
for a in range(1,N+1):
    Q=deque([a])
    T=[0 for i in range(N+1)]
    T[a]=1
    while Q:
        v=Q.popleft()
        for w in E[v]:
            if T[w]==0:
                T[w]=T[v]+1
                Q.append(w)

    F=True
    for (u,v) in P:
        F&=(abs(T[u]-T[v])==1)

    if F:
        M=max(M,max(T))

print(M)


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

using namespace std;
using ll = long long;

const int nax = 3005;
ll dp[nax][nax];

signed main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    // dp[0][n - 1]
    for (int L = n - 1; L >= 0; L--) {
        for (int R = L; R < n; R++) {
            if (L == R) {
                dp[L][R] = a[L];
            } else {
                dp[L][R] = max(a[L] - dp[L + 1][R], a[R] - dp[L][R - 1]);
            }
        }
    }
    printf("%lld\n", dp[0][n - 1]);
    return false;
}

Measured memory_bytes: 70016
// D - Walk and Teleport
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// #define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

// template<class T> void vprn(T &v, string s, string m, string e){
// 	cout<<s;
// 	for(int i=0;i<v.size();i++)
// 	// if(v[i]==COSTMAX) cout<<"∞"<<m;
// 	// else cout<<v[i]<<m;
// 		cout<<v[i]<<m;
// 	cout<<e;
// }

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

	// if(a>=b){
	// 	ote(b*(n-1));
	// 	return 0;
	// }

	vector<ll> x(n+1); for(ll i=1; i<n+1; i++) cin>>x[i];

	vector<ll> dp(n+1);
	// cout<<"xi,xj)\t";vprn(dp,"",",\t","\n");//

	for(ll i=1; i<n; i++){
		dp[i+1] = dp[i] + min(b, (x[i+1]-x[i])*a);
		// cout<<x[i]<<","<<x[i+1]<<")\t";vprn(dp,"",",\t","\n");//
	}

	ote(dp[n]);
}

Measured memory_bytes: 1792
import sys
mod = 10**9+7
def main():
    n,m=map(int,input().split(' '))
    if m > 0:
        aaa = set(map(int,sys.stdin))
    else:
        aaa = set()

    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in aaa else 0
    for i in range(2,n+1):
        if i in aaa:
            continue
        dp[i] = dp[i-1]+dp[i-2]

    print(dp[n]%mod)

main()

Measured memory_bytes: 460020
#include <cstdio>

using namespace std;
typedef long long LL;

const int N=1e5+10,Node=N*70;

int n,m;
LL Q[N],app[N],P[N];

struct Bit
{
	#define lowbit(x) ((x)&(-(x)))
	LL v[N];
	
	void Add(int set,LL value)
	{
		for (;set;set-=lowbit(set))
			v[set]+=value;
	}
	
	LL Query(int set)
	{
		LL ret=0;
		for (;set<N;set+=lowbit(set))
			ret+=v[set];
		return ret;
	}
}bit;

void Init()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i) scanf("%lld",&Q[i]);
}

int find(int l,int r,LL val)
{
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (P[mid]>val) r=mid-1;
		else l=mid+1;
	}
	return r;
}

void Solve()
{
	int top=1; P[top]=n; 
	for (int i=1;i<=m;++i)
	{
		while (top && Q[i]<=P[top]) top--;
		P[++top]=Q[i];
	}
	app[top]=1;
	for (int i=top;i>=1;--i)
	{
		LL l=P[i];
		while (l>P[1])
		{
			int pos=find(1,i-1,l);
			app[pos]+=app[i]*(l/P[pos]);
			l%=P[pos];
		}
		bit.Add(l,app[i]);
	}
	for (int i=1;i<=n;++i) printf("%lld\n",bit.Query(i));
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 4736
// inputに入力データ全体が入る
function Main(input) {
	ans = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	s = input[0].split(' ').map((n) => (parseInt(n)))

	//sort 
	// s.sort()
	s.sort(function(a,b) {return b - a})
	for (i = 2; i > 0; i--) {
		ans += Math.abs( s[i] - s[i - 1] )
	}



	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 7372
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        double sum=0;
        for (int i = 0; i < n; i++) {
            double x=sc.nextDouble();
            char c=sc.next().charAt(0);
            if(c=='J'){
                sum+=x;
            }else {
                sum+=(x*380000.0);
            }
        }
        out.println(sum);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int A,B,C;
cin >> A >> B >> C;
if (A == B) cout << C << endl;
else if (A == C) cout << B << endl;
else cout << A << endl;





return 0;
}

Measured memory_bytes: 256
class Dice
  def initialize(a,b,c,d,e,f)
    @top   = a
    @down  = b
    @right = c
    @left  = d
    @up    = e
    @back  = f
  end
  attr_accessor :top,:down,:right,:left,:up,:back
  def move(dice,m)
    top=@top
    down=@down
    right=@right
    left=@left
    up=@up
    back=@back

    if m=="S"
      @top=  up
      @down= top
      @right=right
      @left= left
      @up=   back
      @back= down
    elsif m=="W"
      @top=  right
      @down= down
      @right=back
      @left= top
      @up=   up
      @back= left
    elsif m=="N"
      @top=  down
      @down= back
      @right=right
      @left= left
      @up=   top
      @back= up
    elsif m=="E"
      @top=  left
      @down= down
      @right=top
      @left= back
      @up=   up
      @back= right
    end
  end
  def printDice
#    puts "top:#{@top}  down:#{@down}  right:#{@right}  lefr:#{@left} up:#{@up} back:#{@back}"
     puts @right
  end
end

n=gets.to_i
dices=[]
n.times do
  a,b,c,d,e,f=gets.split.map(&:to_i)
  dices<<Dice.new(a,b,c,d,e,f)
end
flag =  0
flag2 = 0
n.times do |i|
  1000.times do
    random = Random.new
    ran=random.rand(1..4)
    if ran == 1
      dices[i].move(dices[i],"W")
    elsif ran==2
      dices[i].move(dices[i],"E")
    elsif ran==3
      dices[i].move(dices[i],"S")
    elsif ran==4
      dices[i].move(dices[i],"N")
    end
    n.times do |j|
      next if i==j
      if dices[i].top   == dices[j].top   &&
         dices[i].down  == dices[j].down  &&
         dices[i].left  == dices[j].left  &&
         dices[i].right == dices[j].right &&
         dices[i].up    == dices[j].up    &&
         dices[i].back  == dices[j].back
        flag=1
        flag2=1
        break
      end
    end
    break if flag2==1
  end
end
if flag==1
  puts "No"
elsif flag==0
  puts "Yes"
end


Measured memory_bytes: 15248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<int> A;
vector<int> B;
vector<int> C;
//=============================
void input()
{
    cin >> N;
    A.resize(N);
    rep(i, N)
    {
        cin >> A[i];
    }
}
//=============================
void func() {}
//=============================
void solve()
{
    sort(A.rbegin(), A.rend());

    int a = 0;
    int b = 0;
    int state = 0;
    rep(i, N - 1)
    {
        if (state == 1)
        {
            state = 2;
        }
        else if (A[i] == A[i + 1])
        {
            if (state == 0)
            {
                a = A[i];
                state = 1;
            }
            else if (state == 2)
            {
                b = A[i];
                state == 3;
                break;
            }
            else
            {
                break;
            }
        }
    }
    cout << a * b << endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NK[0]; var K = NK[1];
            var H = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            Console.WriteLine(H.OrderByDescending(n => n).Skip(K).Sum(n=>n));
        }
    }
}


Measured memory_bytes: 33808
# include <iostream>
#include <math.h>
#include <string>

using namespace std;

typedef long long ll;

#define INF 100000000


int main() {
	ll n;
	ll* A;

	cin >> n;
	A = new ll[n];

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

	ll min_height = A[0];
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		if (A[i] > min_height) {
			min_height = A[i];
			continue;
		}

		sum += min_height - A[i];
	}

	cout << sum;
}


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

using namespace std;


int main(void) {
    int n;
    while (scanf("%d", &n), n) {
        int a[110][110] = {};
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                scanf("%d", &a[i][j]);
        
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                a[i][n] += a[i][j];
        
        for (int j = 0; j <= n; j++)
            for (int i = 0; i < n; i++)
                a[n][j] += a[i][j];
        
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++)
                printf("%5d", a[i][j]);
            puts("");
        }
    }

    return 0;
}


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

int main() {
   double n,d;
   cin >> n >> d;
   d *= d;
   double x, y;
   int cnt = 0;
   for(int i = 0; i < n; i++) {
       cin >> x >> y;
       if (x * x + y * y <= d) cnt++;
   }
   cout << cnt << endl;
   return 0;
}

Measured memory_bytes: 3768
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


set<long long> get_divisors(long long a)
{
	set<long long> res;
	long long ora = a;
	for (long long i = 2; i * i <= ora && i <= a; i++)
	{
		if (a % i == 0)
		{
			res.insert(i);
			while (a % i == 0)
				a /= i;
		}
	}
	if (a > 1)
		res.insert(a);
	return res;
}

int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	long long a, b;
	cin >> a >> b;
	vi res;
	set<long long> sa = get_divisors(a), sb = get_divisors(b);
	set_intersection(all(sa), all(sb), back_inserter(res));
	cout << sz(res) + 1;
	return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N;
  cin>>N;
  vector<LL> a(N);
  vector<LL> xor_minus_1(N);
  vector<LL> hoge(N);

  LL xor_sum = 0;
  REP(i, N)
  {
    cin >> a[i];
    xor_sum ^= a[i];
    xor_minus_1[i] = (a[i] ^ (a[i] - 1));
    hoge[i] = ((a[i] ^ (a[i] - 1))+1)/2;
  }

  BACKSORT(xor_minus_1);
  BACKSORT(hoge);

  LL cnt = 0;

  REP(i,xor_minus_1.size()){
    if(hoge[i]<=xor_sum&&xor_sum<hoge[i]*2){
      xor_sum ^= xor_minus_1[i];
      cnt++;
    }
  }

  if(xor_sum==0){
    cout << cnt << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 2560
import java.util.Scanner;
 
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 = sc.nextInt();
		int d = sc.nextInt();
 
		long bc = (long)b*c;
		long bd = (long)b*d;
		long ad = (long)a*d;
		long ac = (long)a*c;
		
		long ans = Math.max(bc, Math.max(bd, Math.max(ad, ac)));
		System.out.println(ans);
	}
 
}

Measured memory_bytes: 27108
from collections import defaultdict
N = int(input())
dic1 = defaultdict(int)
x = ord("a")
for i in range(N):
    s = input()
    ls = [0]*26
    for j in range(10):
        ind = ord(s[j])-x
        ls[ind] += 1
    ls = tuple(ls)
    dic1[ls] += 1
ans = 0
for k in dic1.keys():
    x = dic1[k]
    ans += x*(x-1)//2
print(ans)

Measured memory_bytes: 126168
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <utility>
#define FR first
#define SE second

using namespace std;

typedef pair<int,int> pr;

int num[250005];
int ans[250005];
pr a[505];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
  	int x;
  	scanf("%d",&x);
  	a[i]=pr(x,i);
  	ans[x]=i;
  }
  sort(a+1,a+n+1);
  for(int i=1;i<=n;i++) {
  	int x=a[i].SE,tot=0;
  	for(int j=1;j<=n*n;j++)
  	  if (!ans[j]) num[++tot]=j;
  	int p=lower_bound(num+1,num+tot+1,a[i].FR)-num-1;
  	if (p<x-1) {
  		puts("No");
  		return 0;
	  }
	for(int j=1;j<x;j++) ans[num[j]]=x;
  }
  for(int i=n;i>0;i--) {
  	int x=a[i].SE,tot=0;
  	for(int j=1;j<=n*n;j++)
  	  if (!ans[j]) num[++tot]=j;
  	int p=lower_bound(num+1,num+tot+1,a[i].FR)-num;
  	if (tot-p+1<n-x) {
  		puts("No");
  		return 0;
	  }
	for(int j=1;j<=n-x;j++) ans[num[tot-j+1]]=x;
  }
  puts("Yes");
  for(int i=1;i<=n*n;i++) printf("%d ",ans[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 3072
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N = I()
L = LI2(N)
A = [i[0] for i in L]
B = [i[1] for i in L]
A.sort()
B.sort()
if N%2==0:
    medA = (A[N//2-1]+A[N//2])
    medB = (B[N//2-1]+B[N//2])
    print((medB-medA)+1)
else:
    medA = A[(N-1)//2]
    medB = B[(N-1)//2]
    print(medB-medA+1)


Measured memory_bytes: 50068
from collections import defaultdict
import numpy as np
from itertools import permutations, combinations
n=int(input())
d=defaultdict(int)
def factorization(n):
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i==0:
            while temp%i==0:
                d[i]+=1
                temp //= i

    if temp!=1:
        d[temp]+=1
for i in range(2,n+1):
    factorization(i)
d=np.array(list(d.values()))
ans=0
ans+=len(d[d>=74])
d1=d[d>=2]
d2=d[d>=4]
for x,y in permutations(d1,2):
    if y>=24:
        ans+=1
for x,y in permutations(d2,2):
    if y>=14:
        ans+=1
ans1=0
for x,y,z in permutations(d1,3):
    if y>=4 and z>=4:
        ans1+=1
print(ans+ans1//2)

Measured memory_bytes: 12504
N = int(input())
point = 0
not10 = float('inf')
for i in range(N):
	s = int(input())
	point += s
	if s % 10 != 0:
		not10 = min(not10,s)


if point % 10 == 0:
	if not10 != float('inf'):
		point -= not10
	else:
		point = 0

print(point)


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DBannedK solver = new DBannedK();
        solver.solve(1, in, out);
        out.close();
    }

    static class DBannedK {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            HashMap<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                if (map.containsKey(a[i])) {
                    map.put(a[i], map.get(a[i]) + 1);
                } else {
                    map.put(a[i], 1);
                }
            }
            long sum = 0;
            for (int e : map.values()) {
                sum += (long) e * (e - 1) / 2;
            }
            long[] ans = new long[n];
            for (int i = 0; i < n; i++) {
                int v = map.get(a[i]);
                out.println(sum - v + 1);
            }
        }

    }
}



Measured memory_bytes: 99856
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std; //
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<b && b<c){
    cout<<"Yes"<<endl;
}
    else {
    cout<<"No"<<endl;
    }
 
return 0;
}

Measured memory_bytes: 1156
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {
      val in = StdIn.readLine().split(" ").map(s => s.toInt)
      println((in(0) to in(1)).filter(p => in(2) % p == 0).length)
 }
}

Measured memory_bytes: 43816
#include <stdio.h>

int main()
{
    int a,b;

    scanf("%d %d", &a, &b);

        if (a < b)
        {
            for(int cnt=0; cnt<b; cnt++)
            {

                printf("%d", a);

            }
        }
        else
        {
            for(int cnt=0; cnt<a; cnt++)
            {

                printf("%d",b);

            }
            
            
        }
        
        printf("\n");
        


    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

bool dp[10000100];

int main()
{
	int N;
	while (cin >> N){
		long ans(0);
		dp[0] = dp[1] = true;
		for (int i = 2; i*i <= N; ++i){
			if (!dp[i]){
				for (int j = 2*i; j <= N; j += i)
					dp[j] = true;
			}
		}
		for (int i = 2; i <= N; ++i){
			ans += !dp[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2132
n=int(input())
sp=[]
for i in range(n):
    temp=list(map(str,input().split())) + [i+1]
    temp[1]=int(temp[1])
    sp.append(temp)
sp=sorted(sp,key=lambda x:(x[0],x[1]))

que=[]
prev_rest=sp[0][0]
for i in range(n):
    if prev_rest != sp[i][0]:
        que=sorted(que,key=lambda x:(x[0],x[1]))
        for j in range(len(que)):
            ans_list=que.pop()
            print(ans_list[2])
    que.append(sp[i])
    prev_rest = sp[i][0]
que=sorted(que,key=lambda x:(x[0],x[1]))
for j in range(len(que)):
    ans_list=que.pop()
    print(ans_list[2])

Measured memory_bytes: 3064
n=int(input())
a = list(map(int,input().split()))
for i in range(n):
    cnt=0
    while a[i]%2==0:
        a[i]=a[i]//2
        cnt+=1
    a[i]=cnt
x=y=0
for i in range(n):
    if a[i]==0:
        x+=1
    elif a[i]>1:
        y+=1
if len(a)%2==1:
    if x > y+1:
        print("No")
    else:
        print("Yes")
elif len(a)%2==0:
    if x > y:
        print("No")
    else:
        print("Yes")




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

int max(int a,int b)
{
    if(a>=b)
    return a;
    return b;
    
}
int main() {
    
     int n1,n2;
     string s1;
     string s2;
     
     cin>>s1;
     cin>>s2;
  	n1=s1.length();
  	n2=s2.length();
  
    int dp[n1+1][n2+1];
     
     for(int i=0;i<=n1;i++)
     {
         for(int j=0;j<=n2;j++)
         {
             if(i==0 || j==0)
             dp[i][j]=0;
             else if(s1[i-1]==s2[j-1])
                 dp[i][j]=dp[i-1][j-1]+1;
             else 
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
             
         }
     }
     
   int i,j;
  i=n1;
  j=n2;
  
  char ans[dp[n1][n2]];
  //ans[dp[n1][n2]]='\0';
  
  int index=dp[n1][n2];
  while(i>=0&&j>=0)
  {
    
    if(s1[i-1]==s2[j-1])
    {
      ans[index-1]=s1[i-1];
      index--;
      i--;
      j--;
    }
      
    else if(dp[i-1][j]>dp[i][j-1])
    i--;
    else
      j--;
  }
  
  for(int i=0;i<dp[n1][n2];i++)
    cout<<ans[i];

	return 0;
}

Measured memory_bytes: 35456
s = input()
prev = s[0]
cnt = 1

line = []
for v in s[1:]:
    if v != prev:
        line.append(cnt)
        prev = v
        cnt = 1
    else:
        cnt += 1
line.append(cnt)

result = [0] * len(s)
position = 0
for i in range(0, len(line), 2):
    position += line[i]
    result[position - 1] = (line[i] + 1) // 2 + line[i + 1] // 2
    result[position] = line[i] // 2 + (line[i + 1] + 1) // 2
    position += line[i + 1]
print(*result)


Measured memory_bytes: 48732
s = gets.chomp
cnt = 0
ac = 0
i = 0
while i < s.length-1
  bcc = 0
  if s[i] == "A"
    ac += 1
  elsif s[i, 2] == "BC"
    bcc = 1
    k = 2
    while i+k <= s.length-2 && s[i+k, 2] == "BC"
      bcc += 1
      k += 2
    end
    cnt += ac*bcc
  else
    ac = 0
  end
  if bcc == 0
    i += 1
  else
    i = i+bcc*2
  end
end
puts cnt


Measured memory_bytes: 2172
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10

# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque 

def inp():
    return int(input())
def inps():
    return input().rstrip()
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------
s = inps()
if s[-1] == "s":
  s += "es"
else:
  s += "s"
print(s)

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int n;cin>>n;
    vector<int>a1(n+2),a2(n+2),aa1(n+2),aa2(n+2);

    rep(i,n){
        cin>>a1[i+1];
    }
    rep(i,n){
        cin>>a2[i+1];
    }

    for(int i=1;i<n+1;i++){
        aa1[i]=a1[i]+aa1[i-1];
    }
    for(int i=n;i>0;i--){
        aa2[i]=a2[i]+aa2[i+1];
    }

    int ans=0;
    rep(i,n){
        ans=max(ans,aa1[i+1]+aa2[i+1]);
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
 
int cnt_digits(ll n){
	int digits=0;
	while(n>0){
		n/=10;
		digits++;
	}
	return digits;
}

int main(){

	ll n;
	cin >> n;
	int ans=cnt_digits(n);
	for(ll i=1; i*i<=n; i++){
		if(n%i!=0){
			continue;
		}
		const ll b=n/i;
		const int cur=max(cnt_digits(i), cnt_digits(b));
		if(ans>cur){
			ans=cur;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n;
    R(n);
    FOR(i,1,9){
        if(i*111>=n){
            W(i*111);
            return 0;
        }
    }
    W(1111);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    string S;
    cin >> N >> S;
    
    int need_left = 0;
    int pointer = 0;
    rep(i, S.size()) {
        if (S[i] == '(') ++pointer;
        else {
            if (pointer == 0) ++need_left;
            else--pointer;
        }
    }

    int need_right = pointer;

    string ans = "";
    rep(i, need_left) ans += '(';
    ans += S;
    rep(i, need_right) ans += ')';
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}
/*void set_levels(int cur, int dont){
	level[cur] = level[dont] + 1;
	parent[cur] = dont;
	for(int i = 0; i < vec[cur].size(); i++){
		if(vec[cur][i] != dont) set_levels(vec[cur][i], cur);
	}
}*/
ll fact[2000005];
ll komb(ll a, ll b){
	a++;
	ll payda = (fact[a]*fact[b]) % mod;
	return (fact[a+b] * (exp(payda, mod - 2))) % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll r1, c1, r2, c2; cin>>r1>>c1>>r2>>c2;
	fact[0] = 1;
	for(ll i = 1; i < 2000005; i++){
		fact[i] = fact[i-1] * i % mod;
	}
	ll res = 0;
	ll u = 0;
	for(ll i = min(r1, r2); i <= max(r1, r2); i++){
		res += komb(i, max(c1,c2));
		res -= komb(i, min(c1,c2)-1);
		if(res < 0) res += mod;
		res %= mod;
	}
	//(r, r)..(r+n, r) -> (r+n+1, r+1);
	//(r, r)..(r+m, r)
	cout<<res;
}


Measured memory_bytes: 15872
#include <cstdio>
#include <cstring>

int main(void)
{
  int n,i,sum1=0,sum2=0;
  char cards1[101],cards2[101];

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%s %s", cards1, cards2);

    if(strcmp(cards1,cards2)>0) sum1=sum1+3;
    if(strcmp(cards1,cards2)<0) sum2=sum2+3;
    if(strcmp(cards1,cards2)==0) sum1++,sum2++;
  }

  printf("%d %d\n", sum1, sum2);

  return 0;
}


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

int main() {
  int n, m, a;
  vector<int> num(103);
  
  cin >> n >> m;
  
  rep(i, m * 2){
    cin >> a;
    num.at(a)++;
  }
  
  rep(i, n){
    cout << num.at(i + 1) << endl;
  }
  
  
  
}


Measured memory_bytes: 3580