akhauriyash/Code-Regression huggingface dataset:
<?php
$a=explode(" ",trim(fgets(STDIN)));
$i=0;
$ans=0;
while($i<3){
 if($a[$i]==5||$a[$i]==7){
  $ans+=$a[$i];
 }else{
  break;
 }
 ++$i;
}
echo ($ans==17)?"YES":"NO";

Measured memory_bytes: 4728
N = int(input())
now = [0, 0, 0] # t x y
for i in range(N):
    next = [int(i) for i in input().split()]
    if abs(next[1] - now[1]) + abs(next[2] - now[2]) > next[0] - now[0]:
        print("No")
        exit()
    if (abs(next[1] - now[1]) + abs(next[2] - now[2])) % 2 != (next[0] - now[0]) % 2:
        print("No")
        exit()
print("Yes")



Measured memory_bytes: 3064
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def do():
    n,m,k=INTM()
    uf=UnionFind(n)
    fri=[[] for i in range(n)]
    blo=[[] for i in range(n)]
    for i in range(m):
        a,b=INTM()
        a-=1
        b-=1
        fri[a].append(b)
        fri[b].append(a)
        uf.union(a,b)
    for i in range(k):
        c,d=INTM()
        c-=1
        d-=1
        blo[c].append(d)
        blo[d].append(c)

    ans=[]

    for i in range(n):
        blos=0
        for j in blo[i]:
            if uf.same(i,j):
                blos+=1
        
        ans.append(uf.size(i)-1-len(fri[i])-blos)
    
    print(*ans)




if __name__=='__main__':
    do()

Measured memory_bytes: 48328
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

signed main() {
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vector<ll> s(n);
  REP(i, n) cin >> s[i];
  sort(all(s), greater<ll>());
  vector<vector<ll>> dp(n+1, vector<ll>((x+1)));
  dp[0][x] = 1;
  REP(i, n) {
    REP(j, x+1) {
      dp[i+1][j%s[i]] += dp[i][j];
      dp[i+1][j%s[i]] %= mod;
      dp[i+1][j] += dp[i][j] * (n-i-1);
      dp[i+1][j] %= mod;
    }
  }
  ll ans = 0;
  REP(i, x) {
    ans += dp[n][i] * i;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 158592
def main():
  n, mods = 0, [1]+[0]*2019
  for i, j in enumerate(reversed(input())):
    n = (n+int(j)*pow(10, i, 2019))%2019
    mods[n] += 1
  print(sum([i*(i-1)//2 for i in mods]))
main()

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

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

    int n;
    cin >> n;
    cout << fixed << setprecision(10);
    cout << (double)((n + 1) / 2) / n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#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
	    string s;
	    cin>>s;
	    ll ar[200100];
	    ar[0]=1;
	    for(ll i=1;i<=200001;i++)
	    {
	    	ar[i]=ar[i-1]*10%2019;
	    }
	    ll dp[s.length()+1];
	    dp[0]=s[s.length()-1]-'0';
	    map<ll,ll>m;
	    m[0]+=1;
	    m[dp[0]]+=1;
	    for(ll i=1;i<s.length();i++)
	    {
	    	dp[i]=((s[s.length()-i-1]-'0')*ar[i]+dp[i-1])%2019;
	    	m[dp[i]]+=1;
	    }
	    ll sum=0;
	    for(auto i=m.begin();i!=m.end();i++)
	    {
	    	sum=sum+(i->second)*(i->second-1)/2;
	    }
	    cout<<sum;
}

Measured memory_bytes: 6860
import heapq
X, Y, a, b, c = map(int, input().split())
p = list(map(lambda x: -int(x), input().split()))
q = list(map(lambda x: -int(x), input().split()))
r = list(map(lambda x: -int(x), input().split()))
p.sort()
q.sort()
t = p[:X] + q[:Y] + r

heapq.heapify(t)

ans = 0
for _ in range(X+Y):
    ap = heapq.heappop(t)
    ans -= ap

print(ans)

Measured memory_bytes: 23456
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;


int main() {
	int n, y;
	cin >> n >> y;
	int sen, gosen, jisen;
	sen = gosen = jisen = -1;
	for (jisen = 0; jisen <= n && jisen * 10000 <= y; jisen++) {
		int sgy = y - jisen * 10000;
		int sgn = n - jisen;
		if ((sgn * 5000 - sgy) % 4000 == 0 && (sgn * 5000 - sgy) / 4000 >= 0 && (sgn * 5000 - sgy) / 4000 <= sgn) {
			sen = (sgn * 5000 - sgy) / 4000;
			gosen = sgn - sen;
			break;
		}
	}

	if (gosen < 0) cout << "-1 -1 -1" << endl;
	else printf("%d %d %d\n", jisen, gosen, sen);

	return 0;
}

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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;

#define int ll
const int mod = 1e9+7;

int n, ans = 1;

string s;

int cnt[26];

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n >> s;

	for(int i = 0; i < n; ++i)
	{
		++cnt[s[i]-'a'];
	}

	for(int i = 0; i < 26; ++i)
	{
		ans *= cnt[i]+1;
		ans %= mod;
	}

	ans += mod;
	ans--;
	ans %= mod;

	cout << ans << endl;
}

Measured memory_bytes: 1020
#include "bits/stdc++.h"
using namespace std;
int main() {
	string S, T;
	cin >> S;
	bool flip[100000];
	for (int i = 0; i < S.size(); i++) S[i] -= '0';
	int l = 0, r = S.size() + 1;
	while ((r - l) > 1) {
		int m = (l + r) / 2;
		int sum = 0;
		memset(flip, 0, sizeof(flip));
		T = S;
		for (int i = 0; i + m <= T.size(); i++) {
			if ((T[i] + sum) % 2 == 1) flip[i] = 1, sum++;
			if (i + 1 >= m) sum -= flip[i + 1 - m];
			T[i] = 0;
		}
		for (int i = T.size() - m + 1; i < T.size(); i++) {
			(T[i] += sum) %= 2;
			if (i + 1 >= m) sum -= flip[i + 1 - m];
		}
		bool OK = 1;
		for (int i = 0; i < m; i++) {
			if (T[i]) {
				OK = 0;
				break;
			}
		}
		if (OK) l = m; else r = m;
	}
	cout << l << endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int A[110000], B[110000];

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	int ans = 0;
	long long int S1 = 0, S2 = 0;
	vector<long long int> v;
	
	for(int i = 0; i < N; i++){
		cin >> B[i];
		if(B[i] < A[i]){
			v.push_back(B[i] - A[i]);
			S2 += A[i] - B[i];
		}else if(B[i] > A[i]){
			ans += 1;
			S1 += B[i] - A[i];
		}
	}
	
	if(S1 > S2){
		cout << -1 << endl;
		return 0;
	}
	
	sort(v.begin(), v.end());
	
	for(int i = 0; i < v.size(); i++){
		if(S1 <= 0){
			break;
		}
		S1 += v[i];
		ans += 1;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2424
#include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;
int main(){
    int n,w,a,t,r,i;
    t=r=a=w=0;
    cin>>n;
    char s[n][4];
    for(i=0;i<n;i++){
        scanf("%s",s[i]);
        if(s[i][0]=='A'){
            a++;
        }
        else if(s[i][0]=='W'){
            w++;
        }
        else if(s[i][0]=='T'){
            t++;
        }
        else{r++;}
    }
    printf("AC x %d\n",a);
    printf("WA x %d\n",w);
    printf("TLE x %d\n",t);printf("RE x %d\n",r);}

Measured memory_bytes: 4200
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int a = sc.nextInt();
                int b = sc.nextInt();
                String s = sc.next();
                sc.close();
                for(int i = 0 ; i < n ; i++){
                        if(s.charAt(i) == 'c'){
                                System.out.println("No");
                        }else if(s.charAt(i) == 'a'){
                                if(a + b > 0){
                                        a--;
                                        System.out.println("Yes");
                                }else{
                                        System.out.println("No");
                                }
                        }else{
                                if(a + b > 0 && b > 0){
                                        System.out.println("Yes");
                                        b--;
                                }else{
                                        System.out.println("No");
                                        b = 0;
                                }
                        }
                }
        }
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

typedef long long ll;
typedef pair<ll,ll> P;

int main()
{
	ll n,a,b;cin >> n >> a >> b;
	if(a == 1)
	{
		if(b != n)
		{
			cout << -1 << endl;
			return 0;
		}
		else
		{
			REP(i,n)
			{
				cout << n - i << ' ';
			}
			cout << endl;
			return 0;
		}
	}
	if(b == 1)
	{
		if(a != n)
		{
			cout << -1 << endl;
			return 0;
		}
		else 
		{
			REP(i,n)
			{
				cout << i+1 << ' ';
			}
			cout << endl;
			return 0;
		}
	}
	
	if(a+b-1 <= n && a*b >= n)
	{
		REP(i,a)
		{
			cout << n - a + i + 1 << ' ';
		}
		n -= a;
		int now = n;
		//cout << now << endl;
		REP(i,b-1)
		{
			int tmp = n / (b-1);
			if(i < n % (b-1))tmp++;
			REP(j,tmp)
			{
				cout << now - tmp + j + 1 << ' ';
			}
			now -= tmp;
		}
		cout << endl;
		return 0;
	}
	else
	{
		cout << -1 << endl;
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 2176
import math

N=int(input())

criterion=math.sqrt(N)
divisor=[]
for i in range(2,int(criterion+1)):
    if N%i==0:
        times=0
        while True:
            times+=1
            N//=i
            if (N%i)!=0:
                divisor.append((i,times))
                break

if N>criterion:
    divisor.append((N,1))

ans=0
for i in range(len(divisor)):
    num=1
    times=1
    while True:
        num+=1
        if  divisor[i][1]<times+num:
            ans+=num-1
            break
        times+=num

print(ans)

Measured memory_bytes: 9220
import fractions
from functools import reduce
N=int(input())
L = [int(input()) for i in range(N)]
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm(*L))


Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  
  int k;
  string s;
  cin>>k;
  cin>>s;
  
  for(int i=0;i<min(k,(int)s.size());i++) cout<<s[i];
  if( (int)s.size() > k ) cout<<"...";
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 3608
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h,w=parseMap(split(readline()))
    s=["" for i in 1:h]
    black_h=Vector{Int}()
    black_w=Vector{Int}()
    for i in 1:h
        s[i]=chomp(readline())
    end
    for i in 1:h
        if '#' in s[i]
            push!(black_h,i)
        end
    end
    for i in 1:w
        for j in 1:h
            if '#'==s[j][i]
                push!(black_w,i)
            end
        end
    end
    for i in 1:h
        if i in black_h
            for j in 1:w
                if j in black_w
                    print(s[i][j])
                end
            end
            print("\n")
        end
    end
end
main()

Measured memory_bytes: 169396
#include<stdio.h>
#include<string.h>
int main(void){
char s[99];
  scanf("%s",&s);
 int c1=1;
  for(int i=0;i<(strlen(s)-1)/2;i++){
    if(s[i]!=s[strlen(s)-1-i])c1=0;
  }
  
  int c2=1;
  for(int i=0;i<(strlen(s)-1)/4;i++){
	if(s[i]!=s[((strlen(s)-1)/2)-1-i])c2=0;
  }
 
  int c3=1;
  for(int i=(strlen(s)-1)/2+1;i<3*(strlen(s)-1)/4+1;i++){
    if(s[i]!=s[strlen(s)-1-i])c3=0;
  }
  if(c1!=0&&c2!=0&&c3!=0){printf("Yes");
         return 0;
        }
  
  printf("No");
}

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

// Recursive eq:  
// minCost(i) = min(minCost(i-1) + |h(i-1) - h(i)|, minCost(i-2) + |h(i-2) - h(i)|)
// If you observe, minCost(i-1) needs minCost(i-2)
// i.e. subproblems are overlapping
// Hence we need a DP solution to optimize it.
// Top-down(memoization): we can just use cache to store cost incurred for index i
// Bottom-up(iterative, preffered): dp[i] = min(dp[i-1]+|h(i-1) - h(i)|, dp[i-2]+|h(i-2) - h(i)|)
// dp[1] = 0
int main() {
  int n; cin >> n;
  int dp[n], h[n];
  for(int i = 0; i < n; i++) cin >> h[i];

  dp[0] = 0;
  for(int i = 1; i < n; i++) {
    int twoStepCost = i > 1 ? dp[i-2] + abs(h[i-2]-h[i]) : INT_MAX;
    int oneStepCost = dp[i-1] + abs(h[i-1]-h[i]);  
  	dp[i] = min(oneStepCost, twoStepCost); 
  } 
  
  cout << dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
typedef struct _Date
{
	int year,month,day;

}Date;
int GetDay(const Date* d1, const Date* d2);
int main(void)
{
	Date d1, d2;
	while(1)
	{
		scanf("%d %d %d %d %d %d",
			&d1.year, &d1.month, &d1.day,
			&d2.year, &d2.month, &d2.day);
		if(d1.year<0 || d1.month<0 || d1.day<0 ||
			d2.year<0 || d2.month<0 || d2.day <0)
			break;
		printf("%d\n", GetDay(&d1, &d2));
	}
	return 0;
}


// Sub
int IsLeapYear(int y);
int GetMDay(int y, int m);
int GetDay(const Date* d1, const Date* d2)
{
	int dayCnt = 0;
	int y = d1->year,
		m = d1->month,
		d = d1->day;
	
	while(!(y==d2->year && m==d2->month && d==d2->day))
	{
		d++; dayCnt++;
		if(d>GetMDay(y,m)){m++; d=1;}
		if(m>12){y++; m=1;}
	}
	return dayCnt;
}
int IsLeapYear(int y)
{
	     if(y%400 == 0)return 1;
	else if(y%100 == 0)return 0;
	else if(y%4   == 0)return 1;
	return 0;
}
int GetMDay(int y, int m)
{
	const int mday[13]={0, 31,28,31,30,31,30,31,31,30,31,30,31};
	
	if(m==2 && IsLeapYear(y))
		return mday[2]+1;

	return mday[m];
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    int H, W, D; cin >> H >> W >> D;
    vector<vector<int>> A(H, vi(W));
    rep(i, H) { rep(j, W) { cin >> A[i][j]; } }
    int Q; cin >> Q;
    vi L(Q), R(Q); rep(i, Q) { cin >> L[i] >> R[i]; }

    map<int, pair<int, int>> G;
    rep(i, H) { rep(j, W) { G[A[i][j]] = make_pair(i, j); } }

    vl suma(H * W + 1);
    for (int i = (H * W - D + 1); i <= H * W; i++) {
        suma[i] = 0;
    }
    for (int i = (H * W - D); i >= 1; i--) {
        suma[i] += suma[i + D];
        ll a = abs(G[i].first - G[i + D].first) + abs(G[i].second - G[i + D].second);
        suma[i] += a;
    }

    // rep(i, H * W + 1) {
    //     cout << "i: " << i << ", suma[i]: " << suma[i] << endl;
    // }

    rep(i, Q) {
        cout << suma[L[i]] - suma[R[i]] << endl;
    }
}

Measured memory_bytes: 10588
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        a: i64,
        b: i64,
        k: i64
    }
    if k <= a { println!("{} {}", a - k, b); }
    else if k <= a + b { println!("{} {}", 0, a + b - k); }
    else { println!("{} {}", 0, 0); }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    while(true){
        ll n;
        cin>>n;
        if(n == 0){
            return 0;
        }
        vector<ll> w(n);
        for(ll i=0;i<n;++i){
            cin>>w[i];
        }

        vector<vector<ll>> dp(n+10, vector<ll> (n+10, 0));
        vector<vector<bool>> ok(n+10, vector<bool>(n+10, false));
        for(ll len=1;len<=n;++len){
            for(ll left=0;left<n-len;++left){

                ll right = left + len;
                for(ll mid=left;mid<right;++mid){
                    if(ok[left][mid] and ok[mid+1][right]){
                        ok[left][right] = true;
                    }
                }
                if(len == 1){
                    if(abs(w[left] - w[right]) <= 1){
                        ok[left][right] = true;
                    }
                }
                if(ok[left][right]){
                    ll x = left - 1;
                    ll y = right + 1;
                    while(true){
                        if(x < 0 or x >= n or y < 0 or y >= n)break;
                        if(abs(w[x] - w[y]) >= 2)break;
                        ok[x][y] = true;
                        x--;
                        y++;
                    }
                }
            }
        }

        for(ll i=0;i<n;++i){
            for(ll j=i+1;j<n;++j){
                if(ok[i][j]){
                    dp[i][j] = j - i + 1;
                }
            }
        }
        for(ll i=0;i<n;++i){
            for(ll j=i+1;j<n;++j){
                for(ll k=i;k<j;++k){
                    dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j]);
                }
            }
        }
        ll ans = dp[0][n-1];
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

int main() {
    ll N;
    cin>>N;
    ll ans=INF;
    for(ll i=1ll;i<=sqrt(N)+1;i++){
        if(N%i==0){
            ans=min(ans,i+N/i-2);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
 
high_list = list(map(int, input().split()))
check_list = [1]*N
 
for i in range(M):
  a_, b_ = map(int, input().split())
  if high_list[a_-1] < high_list[b_-1]:
    check_list[a_-1] = 0
  elif high_list[a_-1] > high_list[b_-1]:
    check_list[b_-1] = 0
  elif high_list[a_-1] == high_list[b_-1]:
    check_list[a_-1] = 0
    check_list[b_-1] = 0
 
print(sum(check_list))

Measured memory_bytes: 20112
#include <iostream>
#include <vector>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
  string S;
  cin >> S;

  int n = S.length()-1;
  ll answer = 0;

  for (int bit = 0; bit < (1<<n); ++bit){
    ll sumTemp = 0;
    int left = 0;
    for(int i = 0; i < n; ++i){
      if(bit&(1<<i)){
        sumTemp += stoll(S.substr(left, i - left + 1));
        left = i + 1;
      }
    }
    sumTemp += stoll(S.substr(left));
    answer += sumTemp;

  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> PII;
int a,b;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define MAX(a,b) a>b? a:b
#define MIN(a,b) a>b? b:a

int main(){
int k,s,cnt=0;
  cin>>k>>s;
  REP(i,k+1)REP(j,k+1){
  if(s-(i+j)>=0&&i+j+k>=s)cnt++;
  }
  cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>

int w, h;
char farm[102][102];
int dx[] = { 0, 1, 0, -1 }, dy[] = { -1, 0, 1, 0 };
int ans;

void dfs( int x, int y )
{
	char c = farm[x][y];
	farm[x][y] = '.';
	
	for( int i = 0; i < 4; i++ ){
		int ix = x + dx[i];
		int iy = y + dy[i];
		
		if( ix >= 1 && ix <= w && iy >= 1 && iy <= h && farm[ix][iy] == c ){
		 	dfs( ix, iy );
		}
	}
	
 	return;
}

int main()
{
	while( std::cin >> h >> w, h | w ){
		for( int i = 1; i <= h; i++ ){
			for( int j = 1; j <= w; j++ ){
				std::cin >> farm[j][i];
			}
		}
		
		for( int i = 1; i <= h; i++ ){
			for( int j = 1; j <= w; j++ ){
				if( farm[j][i] == '@' || farm[j][i] == '#' || farm[j][i] == '*' ){
				 	dfs( j, i );
					ans++;
				}
			}
		}
		
		std::cout << ans << std::endl;
		ans = 0;
	}

 	return 0;
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;

int n;
char hv[3005];
vector<int> G[3005];
int siz[3005], dsum[3005], mds[3005];

void dfs(int v, int par)
{
	siz[v] = hv[v] == '1';
	dsum[v] = 0;
	rep(i, G[v].size()) {
		int u = G[v][i];
		if(u == par) continue;
		dfs(u, v);
		siz[v] += siz[u];
		dsum[v] += dsum[u];
	}
	
	mds[v] = dsum[v] % 2;
	rep(i, G[v].size()) {
		int u = G[v][i];
		if(u == par) continue;
		if(mds[u] > dsum[v] - dsum[u]) mds[v] = mds[u] - dsum[v] + dsum[u];
	}
	
	if(par != -1) {
		dsum[v] += siz[v];
		mds[v] += siz[v];
	}
}

bool check(int v)
{
	dfs(v, -1);
	return mds[v] == 0;
}

int main()
{
	scanf("%d%s", &n, hv + 1);
	rep(i, n - 1) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	int ans = INF;
	rep1(i, n) if(check(i)) ans = min(ans, dsum[i] / 2);
	printf("%d\n", ans == INF ? -1 : ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n; cin >> n;
    vector<pair<int, int> > p(n + 1);
    p[0] = {0, 0};
    for(int i = 1; i <= n; i++) cin >> p[i].first >> p[i].second;
    sort(p.begin() + 1, p.end());
    for(int i = 1; i <= n; i++) p[i].second += p[i - 1].second;
    


    int ans = 0;
    int minVal = INF;
    

    for(int r = 1; r <= n; r++){
        //[1, r] の中の最小値を探す
        minVal = min(minVal, p[r - 1].second - p[r].first);
        
        ans = max(ans, p[r].second - p[r].first - minVal);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 10760
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


vector<int> G[100000];
vector<int> ans;

void dfs(int pos, vector<bool>& used){
    ans.pb(pos);
    
    int c=0;
    for(auto e:G[pos]){
        if(used[e]==false){
            used[e] = true;
            c++;
            dfs(e,used);
        }
    }
    if(c==0)throw 1;
}

int main(){
    int v,e;
    cin>>v>>e;
    
    
    rep(i,e){
        int s,t;
        cin>>s>>t;
        s--,t--;
        G[s].pb(t);
        G[t].pb(s);
    }
    
    vector<bool> used(v,false);
    try{
        used[0]=true;
        dfs(0,used);
    }catch(int e){}

    reverse(all(ans));
    int res = *(ans.end()-1);
    ans.erase(ans.end()-1);
    try{
        dfs(res,used);
    }catch(int e){}
    
    cout<<ans.size()<<endl;
    assert(ans.size()>=2);
    rep(i,ans.size()){
        assert(ans[i]>=0 && ans[i]<v);
        if(i)cout<<" ";
        cout<<ans[i]+1;
    }
    cout<<endl;
}

Measured memory_bytes: 12536
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  ll n, a, b; cin >> n >> a >> b;
  if(a > b){
    cout << 0 << endl;
    return 0;
  }else if(a == b){
    cout << 1 << endl;
    return 0;
  }else if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  cout << (n - 2)*(b - a) + 1 << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int a, b, c, i, x = 0;
	
	scanf("%d%d%d", &a, &b, &c);
	for(i = a; i <= b; i++) {
		if((c % i) == 0) x++;
	}
	
	printf("%d\n", x);
	
	return 0;
}




Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define VI vector <int>
#define ss second
#define pii pair<int, int>
#define pci pair<char, int>
#define mii map<int, int>
#define mci map<char, int>
#define setbits(n) __builtin_popcount(n)
#define fill(a,b) memset(a, b, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265
const long long N=1e9;

int lcm(ll a, ll b){
    ll g=__gcd(a, b);
    return a/g*b;
}

int main(){
    IOS;
	int t;
	t=1;
// 	cin>>t;
	while (t--){
	    int n;
	    cin>>n;
	    string s="ACL";
	    while (n--) cout<<s;
	}
	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll N;
  cin>>N;
  ll sum=0;
  rep(i,N+1){
    if(i%3!=0&&i%5!=0)sum+=i;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

int main() {
    //freopen("input1.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;

    vector<int> vec(n);

    for (int i=0; i<n; i++)
        cin >> vec[i];

    vector<bool> dp(k+1, false);

    for (int i=1; i<=k; i++){
        for (int j=0; j<n; j++){
            if (i-vec[j]<=k && i-vec[j]>=0 && dp[i-vec[j]]==false)
                dp[i] = true;
        }
    }

    if (dp[k])
        cout << "First";
    else
        cout << "Second";

    return 0;
}

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

using namespace std;

int main(){

  int N, T, A;
  cin >> N;
  cin >> T;
  cin >> A;
  vector<int> H(N, 0);
  double target;
  int result;
  int ans;
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }

  target = (T - A) / 0.006;
  
  for (int i = 0; i < N; ++i) {
    if (abs(target - H[i]) < abs(target - result)) {
      result = H[i];
      ans = i + 1;
    }
  }
  cout << ans << endl;
}

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

int main(){
    LL N;
    cin >> N;
    vector<LL> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i] -= i+1;
    }
    sort(A.begin(),A.end());
    
    LL med;
    if(A.size()%2){
        med = A[A.size()/2];
    }
    else{
        med = (A[A.size()/2]+A[A.size()/2-1]) / 2;
    }
    LL sum=0;
    for(int i=0; i<N; i++){
        sum += abs(A[i]-med);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<sstream>
using namespace std;

void rot(string& s) {
	const char a = s[s.length()-1];
	s.pop_back();
	s.insert(s.begin(), a);
}

int main() {
	string s,t;
	cin >> s >> t;


	bool check = false;
	for (int i = 0; i < s.length()&&check == false; i++) {
		if (s == t) check = true;
		rot(s);
	}

	//if (check == true) cout << "Yes" << endl;
	//else cout << "No" << endl;
	cout << (check == true ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val inputs = readLine()!!.split(" ").map { it.toInt() }

    val counter = IntArray(n)
    for (v in inputs) {
        counter[v] += 1
    }

    // 必要なものが揃っているか & 余計なものが存在しないか を確認する必要がある
    // これ実装結構面倒では？
    if (n % 2 == 0) {
        // 偶数の場合

        for (i in 0 until counter.size) {
            // 不要な値が入っている場合
            if (i % 2 == 0 && counter[i] != 0) {
                println(0)
                return
            }

            // 必要な値が入っていない場合
            if (i % 2 == 1 && counter[i] != 2) {
                println(0)
                return
            }
        }
    } else {
        // 奇数の場合
        for (i in 0 until counter.size) {
            // 不要な値が入っている場合
            if (i % 2 == 1 && counter[i] != 0) {
                println(0)
                return
            }

            // 必要な値が入っていない場合
            // WA: 0 については別途処理が必要（中心なので１になる）
            if (i % 2 == 0 && counter[i] != 2) {
                if ((i == 0 && counter[i] != 1) || (i != 0 && counter[i] != 2)){
                    println(0)
                    return
                }
            }
        }
    }

    // 成立する場合 個数が 0 ではない部分の数だけ 2 をかけて mod を計算
    var ans = 1
    for (v in counter) {
        if (v == 2) {
            ans = ans * 2 % (1e9 + 7).toInt()
        }
    }

    println(ans)
}

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

//Matrix Vector Multiplication

int main(){
	int n, m;
	int A[100][100], b[100];

	cin >> n >> m;

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


	// read b
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}

	// calc and print
	int sum;
	for(int i = 0; i < n; i++){
		sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * b[j];
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;

int main() {
    int h, n; cin >> h >> n;
    vector<pair<int, int>> arr(n);
    vector<pair<double, int>> v(n);
    rep(i, n) {
        int a, b; cin >> a >> b;
        arr[i] = { a, b };
    }

    long long dp[n + 1][h + 1];
    rep(i, n + 1) {
        rep(j, h + 1) {
            dp[i][j] = 1e15;
        }
    }
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, h + 1) {
            long long tmp = max(0, j - arr[i].first);
            dp[i + 1][j] = min(dp[i + 1][j],
                               min(dp[i][j], dp[i + 1][tmp] + arr[i].second));
        }
    }

    cout << dp[n][h] << endl;
}


Measured memory_bytes: 78464
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define int64 long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

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

void solve() {
    string S;
    cin >> S;

    int ans = 0;
    rep(i, S.size() / 2) {
        if (S[i] != S[S.size()-i-1]) ans++;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cout.precision(20);
    cout << fixed;

    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  int H,W; cin>>H>>W;
  string tmp;
  rep(i,0,H){
    rep(j,0,W){
      cin>>tmp;
      if(tmp=="snuke"){
        cout<<char('A'+j)<<1+i;
        break;
      }
    }
  }
  
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int r,d,x,p;
    long long int n=10;
    cin>>r>>d>>x;
    while(n--)
    {
         p=(r*x)-d;
         cout<<p<<endl;
         x=p;
    }
}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

vector<pair<int,int>> G[MAX];

int used[MAX];
int ans[MAX];
int N;

void solve(int node, int dis){//cout<<"node "<<node<<" "<<N<<endl;
	if(used[node]) return ;
	
	used[node] = true;
	
	ans[node] = dis%2;
	
	for(int i = 0; i < G[node].size(); i++){
		solve(G[node][i].first, dis + G[node][i].second);
	}
	return;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int u, v, w;
	
	cin>>N;

	for(int i = 0; i < N-1; i++){
		cin>>u>>v>>w;
		// cout<<i<<" "<<N<<endl;
		G[u].push_back(make_pair(v,w));
		G[v].push_back(make_pair(u,w));
	}

	
	//cout<<"N = "<<N<<endl;
	solve(1, 0);
	
	//cout<<"N = "<<N<<endl;
	for(int i = 1; i <= N; i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<string>
using namespace std;
const int N = 2e5 + 10;
string q[N];
string ADD(string, string);
string MULTIPLE(string, string);
string ADD(string a, string b)
{
	string res = "";
	int carryitem = 0;
	int nowitem = 0;
	int a_len = a.length(), b_len = b.length();
	if (a_len < b_len)
	{
		swap(a, b);
		a_len = a.length();
		b_len = b.length();
	}
	for (int i = a_len - b_len; i > 0; --i)
	{
		b = '0' + b;
	}
	for (int i = a_len - 1; i >= 0; --i)
	{
		nowitem = a[i] + b[i] - 2 * '0' + carryitem;
		carryitem = nowitem / 10;
		nowitem %= 10;
		res = static_cast<char>(nowitem + '0') + res;
	}
	if (carryitem)
	{
		res = static_cast<char>(carryitem + '0') + res;
	}
	return res;
}
string MULTIPLE(string a, string b)
{
	string res = "";
	int a_len = a.length(), b_len = b.length();
	if (a_len < b_len)
	{
		swap(a, b);
		a_len = a.length();
		b_len = b.length();
	}

	for (int i = b_len - 1; i >= 0; --i)
	{
		string tmp = "";
		for (int j = 0; j < b[i] - '0'; j++)
		{
			tmp = ADD(tmp, a);
		}
		for (int k = 0; k < b_len - i - 1; k++)
		{
			tmp += '0';
		}
		res = ADD(res, tmp);
	}
	return res;
}

int main()
{
	int n;
	cin >> n;
	string res = "1";
	int flag = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> q[i];
		if (q[i] == "0")
		{
			flag = 1;
			break;
		}
	}
	if (flag != 1)
	{
		for (int i = 0; i < n; i++)
		{
			res = MULTIPLE(res, q[i]);
			if (res != "1000000000000000000" && res.length() >= 19)
			{
				flag = 2;
				break;
			}
		}
	}
	if (flag == 1)
		cout << 0;
	else if (flag == 2)
	{
		cout << -1;
	}
	else cout << res;
	return 0;
}

Measured memory_bytes: 14428
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll N,Q,x;
ll A[100010];


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> Q;
    REP(i,N) cin >> A[i];
    REP(i,Q){
        cin >> x;
        ll sum = 0, ans = 0;
        int r = 0;
        REP(l,N){
            while(r < N && sum + A[r] <= x) sum += A[r++];
            ans += r - l;
            if(r==l) ++r;
            else sum -= A[l];
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

	int N, K;
	cin >> N >> K;

	vector<vector<int>> v(10);
	FOR(i, 0, N) {
	    int C, G;
	    cin >> C >> G;
	    G--;
	    v[G].emplace_back(C);
	}

	vector<vector<int>> memo(10);
	FOR(kind, 0, 10) {
	    sort(RALL(v[kind]));
	    vector<int> cul(v[kind].size() + 1, 0);
	    FOR(i, 0, v[kind].size()) {
	        cul[i + 1] = cul[i] + v[kind][i];
        }
        memo[kind] = cul;
    }
    
    vector<vector<int>> dp(11, vector<int>(N + 1, -INF));
	dp[0][0] = 0;
	FOR(kind, 0, 10) {
        FOR(i, 0, dp[0].size()) {
            if (dp[kind][i] == -INF) {
                continue;
            }
            int num = v[kind].size();
            FOR(j, 0, num + 1) {
                int price = memo[kind][j] + max(0, j - 1) * j;
                // use
                dp[kind + 1][i + j] = max(dp[kind + 1][i + j], dp[kind][i] + price);
            }
        }
    }

    int ans = 0;
    FOR(i, 0, K + 1) {
        ans = max(ans, dp[10][i]);
    }
    print(ans);

	return 0;
}


Measured memory_bytes: 3316
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();
		if(a < b) {
			System.out.println("a < b");
		} else if(a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 25828
# coding: utf-8

if __name__ == '__main__':

    n, a, b = map(int, input().split())
    total = 0

    for i in range(1, n + 1):

        sum = 0
        remainder = i

        while(remainder > 0):
            sum += remainder % 10
            remainder //= 10

        if (a <= sum and sum <= b):
            total += i

    print(total)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<char, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll bit[1000010];
int kai[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		(t += bit[i]) %= mod;
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 1000005)
	{
		(bit[i] += x) %= mod;
		i += i & -i;
	}
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 1000005; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}

ll N, H, D;
ll ans;

void solve() {
	cin >> N >> H >> D;
	kaijo();
	ll nu = 0;
	rep(i, N) {
		(nu += kai[i + 1]) %= mod;
	}

	add(0, kai[N]);
	for (int i = 1; i <= H; i++) {
		ll num;
		if (i > D) {
			num = nu * (mod + sum(i) - sum(i - D - 1)) % mod;
		}
		else {
			num = sum(i) * nu % mod;
		}

		if (i == H) {
			if (i > D) {
				ans = (mod + sum(i) - sum(i - D - 1)) % mod;
			}
			else {
				ans = sum(i);
			}
		}
		add(i, num);
	}

	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}
////////////////////////////////////////////////////////////////////////////////////////////jagfhaoi;sd;joi;asdfjzasdi;lfjoi;ernjsdoivcnoizvdfnvdfnon/////////////////////////////////////////////////////////
////////////////////jgoiadhsjgoi;vsjvgfonhjasoivhoivhno

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const int MAXN = 201+5;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int a, b;
	cin >> a >> b;
	int maxi = max(a,b);
	int mini = min(a,b);
	string ans= "";
	for(int i=0; i<maxi; i++){
		cout << mini ;
	}
	cout << ans << endl;
	return 0;
}







Measured memory_bytes: 3580