akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE
  ScopedTypeVariables, BangPatterns, TupleSections, ExplicitForAll,
  LambdaCase, MultiWayIf, Unsafe, RecordWildCards, FlexibleContexts, CPP,
  NoMonomorphismRestriction, GADTs,
  RankNTypes, EmptyDataDecls, EmptyCase, ViewPatterns #-}


import Data.Bits
import Data.List
import Data.Maybe
import Data.Tuple
import Data.Ord
import Data.Int
import Data.Word
import Data.Function
import Data.STRef
import Data.IORef
import System.IO
import Control.Applicative
import Control.Monad
import Control.Monad.Primitive
import Control.Monad.State.Strict
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.DeepSeq
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap (IntMap)
import qualified Data.IntMap.Strict as IMS
import qualified Data.IntMap.Lazy as IML
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Primitive as VP
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM

main :: IO ()
main = do
  n <- read <$> getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'!')) <$> BS.getLine
  print $ VU.foldl' gcd 0 as


rInt :: StateT BSL.ByteString Maybe Int
rInt = StateT $ BSL.readInt . BSL.dropWhile (<'!')

#define D(f,r,d) f::Integral a=>a->d;f=fromIntegral;r::String->d;r=read
#define C(f,r,g,h,d) D(f,r,d);g,h::RealFrac a=>a->d;g=floor;h=ceiling
C(_toInteger_,readInteger,floorInteger,ceilInteger,Integer)
C(toInt,readInt,floorInt,ceilInt,Int)
C(toI8,readI8,floorI8,ceilI8,Int8)
C(toI16,readI16,floorI16,ceilI16,Int16)
C(toI32,readI32,floorI32,ceilI32,Int32)
C(toI64,readI64,floorI64,ceilI64,Int64)
C(toWord,readWord,floorWord,ceilWord,Word)
C(toW8,readW8,floorW8,ceilW8,Word8)
C(toW16,readW16,floorW16,ceilW16,Word16)
C(toW32,readW32,floorW32,ceilW32,Word32)
C(toW64,readW64,floorW64,ceilW64,Word64)
D(toDouble,readDouble,Double)
D(toFloat,readFloat,Float)
#undef D
#undef C


#define N(f,g,a,m)\
  f :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> e -> m (a i e); f=A.newArray;\
  g :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> m (a i e); g=A.newArray_
#define C(a,m)
N(newIOA,newIOA_,IOArray,IO)
N(newSTA,newSTA_,STArray s,ST s)
#undef C
#define C(a,m) MArray (a) e (m), 
N(newIOUA,newIOUA_,IOUArray,IO)
N(newSTUA,newSTUA_,STUArray s,ST s)
#undef C
#undef N



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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,k;cin>>n>>k;
  vector<int> t(n);
  vector<int> d(n);
  int i;
  rep(i,n)cin>>t[i]>>d[i];
  rep(i,n)t[i]--;
  vector<pair<int,int>> ps(n);
  rep(i,n)ps[i]=make_pair(d[i],t[i]);
  vector<int> pushed(n,0);
  sort(all(ps));
  reverse(all(ps));
  ll kans=0;
  priority_queue<int,vector<int>,greater<int>> pq;
  priority_queue<pair<int,int>> npick;
  rep(i,k)
  {
    if(pushed[ps[i].second]>0)
    {
      pq.push(ps[i].first);
    }
    pushed[ps[i].second]++;
    kans+=ps[i].first;
  }
  for(i=k;i<n;i++)npick.push(ps[i]);
  ll kcount=0;
  rep(i,n)if(pushed[i]>0)kcount++;
  ll ans=kans+kcount*kcount;
  while(!npick.empty()&&!pq.empty())
  {
    pair<int,int> pnum=npick.top();
    npick.pop();
    int a=pnum.first;
    int b=pnum.second;
    if(pushed[b]>0)continue;
    pushed[b]=1;
    int dnum=pq.top();
    pq.pop();
    kans=kans-dnum+a;
    kcount++;
    ll cans=kans+kcount*kcount;
    ans=max(ans,cans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3356
n=int(input())
V=list(map(int,input().split()))
O=[]
E=[]
for i in range(n//2):
    O.append(V[2*i])
    E.append(V[2*i+1])
O.sort()
E.sort()
CO=[]
CE=[]
no=O[0]
co=0
ne=E[0]
ce=0
for i in range(n//2):
    if O[i]==no:
        co+=1
    else:
        CO.append([co,no])
        co=1
        no=O[i]
    if E[i]==ne:
        ce+=1
    else:
        CE.append([ce,ne])
        ce=1
        ne=E[i]
CO.append([co,no])
CE.append([ce,ne])

CO=list(reversed(sorted(CO)))
CE=list(reversed(sorted(CE)))

if CO[0][1]==CE[0][1]:
    if len(CO)==1 and len(CE)==1:
        print(n//2)
    elif len(CO)==1:
        print(n-CO[0][0]-CE[1][0])
    elif len(CE)==1:
        print(n-CO[1][0]-CE[0][0])
    else:
        print(n-max(CO[0][0]+CE[1][0],CO[1][0]+CE[0][0]))
else:
    print(n-CO[0][0]-CE[0][0])

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

int main()
{
    int n ;
    scanf("%d",&n) ;
    int a[n] , cur = 1 ;
    for(int i = 0 ; i < n ; ++i) scanf("%d",&a[i]) ;
    for(int i = 0 ; i < n ; ++i)
    {
        if(a[i]==cur) ++cur ;
    }
    if(cur==1) puts("-1") ;
    else printf("%d\n",n-cur+1) ;
}


Measured memory_bytes: 1024
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20

def bfs(x):
  if visited[x] == 2:
    return None
  if visited[x] == 1:
    return edges[x]
  if plst[x] == 0:
    edges[x] = x
    visited[x] = 1
    return x

  visited[x] = 2
  ret = bfs(x + plst[x])
  if ret != None:
    edges[x] = ret
    visited[x] = 1
  return ret

def search():
  cost = [INF] * n
  cost[0] = 0
  que = []
  heappush(que, (0, 0))
  while que:
    score, pos = heappop(que)
    for dice in range(1, 7):
      new_pos = pos + dice
      if new_pos >= n - 1:
        print(score + 1)
        return
      
      if edges[new_pos] == None:
        continue
      
      new_pos = edges[new_pos]
      if new_pos >= n - 1:
        print(score + 1)
        return
      
      if cost[new_pos] > score + 1:
        cost[new_pos] = score + 1
        heappush(que, (score + 1, new_pos))
  else:
    print("Miss!!")

n = int(input())
plst = [int(input()) for _ in range(n)]
edges = [None for _ in range(n)]
visited = [0] * n
for i in range(n):
  bfs(i)
search()



Measured memory_bytes: 92564
dic = {}
dic[0] = 1
N, M = map(int, input().split())
for i in range(N):
  for j, a in enumerate(list(map(int, input().split()))):
    if j == 0:
      continue
    if dic.get(a):
      dic[a] += 1
    else:
      dic[a] = 1
cnt = 0
for i in dic.keys():
  if i == 0:
    continue
  if dic[i] == N:
    cnt += 1
print(cnt)

Measured memory_bytes: 38496
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,k;
	cin >> a >> b >> k;
	if(k>=a+b)
		cout << "0 0"<<endl;
	else if(k>=a)
		cout <<"0 "<< b+a-k << endl;
	else
		cout <<a-k <<" "<< b << endl;
	return 0;

}

Measured memory_bytes: 256
r,c = map(int,input().split(" "))
sumall = [0]*(c+1)
for i in range(r):
    x = list(map(int,input().split(" ")))
    sumx = sum(x)
    for j in range(c):
        sumall[j] += x[j]
        # print(sumall)
    sumall[c] += sumx
    newl = " ".join(map(str,x))
    print(newl + " " + str(sumx))
lastl = " ".join(map(str,sumall))
print(lastl)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	long long c[n];
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		c[i] = a-i;
	}
	sort(c, c+n);
	if (n%2 == 1) {
		long long sum = 0;
		long long s = c[n/2];
		for (int i = 0; i < n; i++) {
			sum += abs(c[i]-s);
		}
		cout << sum << endl;
	} else {
		long long s = c[n/2-1];
		long long t = c[n/2];
		long long minsum = -1;
		for (long long m = s; m <= t; m++) {
			long long sum = 0;
			for (int i = 0; i < n; i++) {
				sum += abs(c[i]-m);
			}
			if (minsum == -1)
				minsum = sum;
			else if (minsum > sum)
				minsum = sum;
		}
		cout << minsum << endl;
	}
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
  return 0;
}


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

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



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

// INT VS LL

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

    // string s;
    int n, k;
    cin >> n >> k;
    vector<bool> bad(10);
    for (int i = 0; i < k; ++i) {
    	int foo;
    	cin >> foo;
    	bad[foo] = true;
    }

    for (int i = n; true; ++i) {
    	string s = to_string(i);
    	bool good = true;
    	for (auto c: s) {
    		good &= !bad[c - '0'];
    	}
    	if (good) {
    		cout << i << endl;
    		return 0;
    	}

    }
    assert(false);
    return 0;

    // int len = s.size();
    // int ten_pw = 1;
    // for (int i = 0; i < len - 1; ++i) ten_pw *= 10;
    // for (int i = 0; i < (int) s.size(); ++i) {
    // 	int cur = (s[i] - '0');
    // 	if (bad(cur)) {
    // 		if (cur == 9) {

    // 		}
    // 		else {
    // 			for (int d = 0; d < 10; ++d) {
    // 				if (bad[d]) continue;
    // 				// should I change to D
    // 				if (!bad[d]) {
    // 					ans += (d * ten_pw * (len - i));
    // 					break;
    // 				}
    // 			}
    // 			int x 
    // 		}
    // 	}
    // 	ten_pw /= 10;
    // }

    return 0;
}

/*
8382 
i = 0
ans += 2000
d * 1000
*/

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
  string S;
  cin>>S;
  int i;
  for(i=0;i<S.size();++i)
  {
    if(S[i]=='L'&&i%2==0) 
    {
      cout<<"No"<<endl;
      break;
    }
    if(S[i]=='R'&&i%2!=0) 
    {
      cout<<"No"<<endl;
      break;
    }
  }
  if(i==S.size()) cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
// review
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9+7;

ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}

ll n, a, b;

ll fact(ll n, ll x) {
  ll res = 1;
  for (ll i = 0;i < x;i++) {
    res = res * (n - i) % MOD;
  }
  return res;
}

void solve() {
  ll power = mod_pow(2, n) - 1 + 2 * MOD;
  ll numeratorA = fact(n, a);
  ll numeratorB = fact(n, b);
  ll denominatorA = fact(a, a);
  ll denominatorB = fact(b, b);
  ll nCa = numeratorA * mod_inv(denominatorA) % MOD;
  ll nCb = numeratorB * mod_inv(denominatorB) % MOD;
  cout << ((power - nCa - nCb) % MOD) << endl;
}

int main() {
  cin >> n >> a >> b;
  solve();
}


Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

MAXN = 20

L = read()
Lb = [int(L & (1 << b) > 0) for b in range(MAXN)]

edges = []
for i in range(MAXN-2):
  edges.append((MAXN-1-i, MAXN-i, 0))
  edges.append((MAXN-1-i, MAXN-i, 1 << i))

def dec(bs):
  return sum(b * (1 << i) for i, b in enumerate(bs))

for i in range(MAXN-2):
  if Lb[i] == 1:
    w = dec(Lb[i+1:]) * 2**(i+1)
    edges.append((1, MAXN-i, w))

head = dec(Lb[MAXN-2:])
for bb in range(head):
  edges.append((1, 2, bb * 2**(MAXN-2)))

N = 20
M = len(edges)
print(N, M)
for u, v, w in edges:
  print(u, v, w)

Measured memory_bytes: 38384
#!/usr/bin/env python3
import sys


def solve(A: "List[int]"):
    ret = max(A) - min(A)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [ int(next(tokens)) for _ in range(3) ]  # type: "List[int]"
    solve(A)

if __name__ == '__main__':
    main()


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


}

Measured memory_bytes: 1752
package main

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

func solve() {
	n := getInt()
	as := getIntSlice(n)

	cSum := make([]int, n+1)
	for i := 1; i < n+1; i++ {
		cSum[i] = cSum[i-1] + as[i-1]
	}

	ans := pow(10, 14) + 1
	for i := 1; i < n; i++ {
		x := cSum[i]
		y := cSum[n] - cSum[i]
		ans = min(ans, abs(x-y))
	}

	fmt.Fprintln(wr, ans)
}

func pow(a, b int) int {
	ret := 1
	for i := 0; i < b; i++ {
		ret *= a
	}
	return ret
}

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

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

// -----------------------------------------

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

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N, x;
	const string ok = "Yes", ng = "No";
	cin >> N >> x;
	if(x == N*2-1 || x == 1) {
		cout << ng << endl;
		return 0;
	}
	if(N == 2) {
		cout << ok << endl;
		for(int i = 0; i < 2*N-1; i++) {
			cout << i+1 << endl;
		}
		return 0;
	}

	vector<int> a, b;
	a.resize(4);
	if(x == 2) {
		a[0] = x+1;
		a[1] = x;
		a[2] = x-1;
		a[3] = x+2;
	}
	else {
		a[0] = x-1;
		a[1] = x;
		a[2] = x+1;
		a[3] = x-2;
	}
	for(int i = 0; i < 2*N-1; i++) {
		if(x == 2) {
			if(!(x-1 <= i+1 && i+1 <= x+2))
				b.push_back(i+1);
		}
		else {
			if(!(x-2 <= i+1 && i+1 <= x+1))
				b.push_back(i+1);
		}
	}

	cout << ok << endl;
	for(int i = 0; i < N-3; i++) {
		cout << b[i] << endl;
	}
	for(int i = 0; i < 4; i++)
		cout << a[i] << endl;
	for(int i = N-3; i < b.size(); i++) {
		cout << b[i] << endl;
	}

	return 0;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int N, T;
	int c[100], t[100];
	cin >> N >> T;
	int ans = inf;
	for(int i = 0; i < N; i++){
		cin >> c[i] >> t[i];
		if(t[i] <= T && c[i] < ans){
			ans = c[i];
		}
	}

	if(ans == inf) cout << "TLE" << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.readline

n = int(input())
note = dict()
ans = 0
for i in range(n):
    s = "".join(sorted(sys.stdin.readline()))
    if s in note.keys():
        ans += note[s]
        note[s] += 1
    else:
        note[s] = 1

print(ans)

Measured memory_bytes: 17808
import java.awt.geom.*;
import java.io.*;
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			long n = sc.nextLong();
			if(n == 0) break;
			int count = 0;
			for(;;){
				count += n / 5;
				n = n / 5;
				if(n == 0) break;
			}
			System.out.println(count);
		}
	}

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

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



int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m);
    ll sum=0;
    rep(i,m){
        cin>>a[i];
        sum+=a[i];
    }
    ll ans=(sum<=n)?n-sum:-1;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
int cnt[200010];

signed main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a; cin >> a;
		cnt[a]++;
	}
	for (int i = 1; i <= n; i++)cout << cnt[i] << endl;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

vector<ll>wt;
vector<ll>val;

ll kp(ll W,ll n){
    ll k[2][W+1];
    for(ll i=0;i<=1;i++){
        for(ll w=0;w<=W;w++){
            if((w==0)||(i==0)){
                k[i][w]=0;
            }
            else if(wt[i-1]>w){
                k[i][w]=k[i-1][w];
            }
            else if(wt[i-1]<=w){
                k[i][w]=max(k[i-1][w],val[i-1]+k[i-1][w-wt[i-1]]);
            }
        }
    }
    for(ll i=2;i<=n;i++){
        for(ll w=0;w<=W;w++){
            k[0][w]=k[1][w];
        }
        for(ll w=0;w<=W;w++){
            if(w==0){
                k[1][w]=0;
            }
            else if(wt[i-1]>w){
                k[1][w]=k[0][w];
            }
            else if(wt[i-1]<=w){
                k[1][w]=max(k[0][w],val[i-1]+k[0][w-wt[i-1]]);
            }
        }
    }
    return k[1][W];
    }


int main(){
    ll n,w;
    cin>>n>>w;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        wt.push_back(a);
        val.push_back(b);
    }
    cout<< kp(w,n)<<endl;
    return 0;

    }


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

using namespace std;

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

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

  int n = 1;
  for (int i = 0; i < N; ++i) {
    n = min(n * 2, n + K);
  }
  cout << n << endl;

  return 0;
}

Measured memory_bytes: 256
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};


// abcde
fn read_string() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_string();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_string();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_string();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();    
    (
        elems[0].parse().ok().expect("failed to parse"), 
        elems[1].parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"), 
        elems[1].parse().ok().expect("failed to parse"),
        elems[2].parse().ok().expect("failed to parse"),
    )
}

fn main() {

    let n: usize = read_as_primitive();
    let mut xs: Vec<i64> = read_as_collection();
    xs.sort();
    let ans = if xs[n - 1] < xs[0..n-1].iter().sum() {"Yes"} else {"No"};
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,t,v,len[20],p[MAXN],Fl[1<<18],Fr[1<<18],S,a[MAXN];
vector<int>L[20],R[20];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),v=read(),t=log2(v)+1,S=(1<<t)-1;
	Rep(i,1,n)p[i]=read();
	Rep(i,0,t){
		len[i]=i?len[i-1]/2:v;
		for(int l=1,r;l<=n;l=r+1){
			for(r=l;r<n&&p[r+1]-p[r]<=len[i];r++);
			L[i].pb(l),R[i].pb(r);
		}
	}
	Rep(sta,0,S)Fr[sta]=n+1,Fl[sta]=0;
	Rep(i,1,t)Fl[1<<i-1]=(*R[i].begin()),Fr[1<<i-1]=(*--L[i].end());
	Rep(sta,1,S)Rep(j,1,t)if(~sta>>(j-1)&1){
		int t=sta|(1<<j-1),pos;
		pos=upper_bound(L[j].begin(),L[j].end(),Fl[sta]+1)-L[j].begin()-1;
		assert(pos>=0&&pos<R[j].size()),Fl[t]=max(Fl[t],R[j][pos]);
		pos=lower_bound(R[j].begin(),R[j].end(),Fr[sta]-1)-R[j].begin();
		assert(pos>=0&&pos<L[j].size()),Fr[t]=min(Fr[t],L[j][pos]);
	}
	Rep(s,0,S){
		int ed=upper_bound(L[0].begin(),L[0].end(),Fl[s]+1)-L[0].begin()-1,st=lower_bound(R[0].begin(),R[0].end(),Fr[S^s]-1)-R[0].begin();
		if(st<=ed)a[st]++,a[ed+1]--;
	}
	for(int i=0;i<L[0].size();i++){
		a[i]+=a[i-1];
		Rep(j,L[0][i],R[0][i])puts(a[i]?"Possible":"Impossible");
	}
	return 0;
}




Measured memory_bytes: 9268
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

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

double const pi=3.1415926535;

int printint(int n){
	cout<<n<<endl;
	return 0;
}

int prints(string s){
	cout<<s<<endl;
	return 0;
}

int main(){
	int n,k;
	int num=1;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		2*num >= num+k ? num+=k : num*=2;
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256
// A - Tenki

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

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

	int ans = 0;
	for (int i=0; i<3; i++) {
		if (S[i] == T[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

  int n, h;
  cin >> n;
  int res = 0, tmp = 0;
  int prev = 0;
  if (n > 1) {
    while (n--) {
      cin >> h;
      if (h <= prev) 
        ++tmp;
      else {
        res = max(res, tmp);
        tmp = 0;
      }
      prev = h;
    }
    res = max(res, tmp);
  }
  cout << res << endl;

  return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string B = Console.ReadLine();

            if(A.Length != B.Length)
            {
                if (A.Length > B.Length) Console.WriteLine("GREATER");
                else Console.WriteLine("LESS");

                return;
            }

            if(A.Equals(B))
            {
                Console.WriteLine("EQUAL");
                return;
            }

            string[] sort = new string[2] { A, B };
            Array.Sort(sort);

            if (sort[0].Equals(B))
            {
                Console.WriteLine("GREATER");
            }
            else if (sort[0].Equals(A))
            {
                Console.WriteLine("LESS");
            }
        }
    }
}


Measured memory_bytes: 13408
N,K = map(int,input().split())

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

gr = [0] * (K+1)

for i in range(K+1):

    mex = [0] * (N+1)
    for j in a:
        if i-j >= 0:
            mex[gr[i-j]] = 1

    for k in range(N+1):
        if mex[k] == 0:
            gr[i] = k
            break

if gr[-1] == 0:
    print ("Second")
else:
    print ("First")


Measured memory_bytes: 49756
function Main(input) {
  let args = input
    .trim()
    .split(" ")
    .map((x) => parseInt(x, 10));
  let a = args[0];
  let b = args[1];
  let c = args[2];

  let ans = 0;
  for (let x = a; x <= b; x++) {
    if (c % x === 0) {
      ans++;
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15404
# Walking Takahashi

def main(x, k, d):
    q, r = divmod(x, d)

    h = 0
    if -(r - d) < r:
        h = d - r
    else:
        h = -r
    q = (x + h) // d

    if k < abs(q):
        if x < 0:
            return -(x + k * d)
        else:
            return x - k * d

    rk = k - q
    if rk % 2 == 0:
        return abs(h)
    else:
        if 0 < h:
            return abs(h - d)
        else:
            return abs(h + d)


X, K, D = list(map(int, input().split()))
r = main(X, K, D)
print(r)


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

using namespace std;

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

    int n;
    cin >> n;

    struct Restaurant {
        string city;
        int score, id;
        bool operator<(const Restaurant &rhs) {
            return (this->city < rhs.city) ||
                (this->city == rhs.city && this->score >= rhs.score);
        }
    };

    vector<Restaurant> rs(n);
    for (int i = 0; i < n; ++i) {
        cin >> rs[i].city >> rs[i].score;
        rs[i].id = i + 1;
    }

    sort(rs.begin(), rs.end());

    for (const auto &r : rs)
        cout << r.id << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







int main() {
    ll n;
    cin >> n;
    ll sum = 0, mx = 0;
    REP(i, n){
        ll l;
        cin >> l;
        sum += l;
        mx = max(mx, l);
    }
    if(sum - mx > mx){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;
using ll = long long;
const ll INF = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    map<int, vector<int>> p = {};
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        p[a].push_back(b);
    }

    bool flag = false;
    for (int i = 0; i < p[1].size(); i++) {
        int c = p[1][i];
        for (int j = 0; j < p[c].size(); j++) {
            if (p[c][j] == N) {
                flag = true;
                break;
            }
        }
    }

    cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n;
ll a,b,mi=INF,sum;
bool flg=true;

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

	cin>>n;
	REP(i,n) {
		cin>>a>>b;
		if(a!=b) flg=false;
		sum+=a;
		if(a>b) mi=min(mi,b);
	}
	if(flg) cout<<0<<endl;
	else cout<<sum-mi<<endl;

	return 0;
}


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

public class ACBC1124_A
{
    public static void Main()
    {
        string line = Console.ReadLine();
        switch(line)
        {
            case "SUN":
                Console.WriteLine(7);
                break;
            case "MON":
                Console.WriteLine(6);
                break;
            case "TUE":
                Console.WriteLine(5);
                break;
            case "WED":
                Console.WriteLine(4);
                break;
            case "THU":
                Console.WriteLine(3);
                break;
            case "FRI":
                Console.WriteLine(2);
                break;
            case "SAT":
                Console.WriteLine(1);
                break;
        }
    }
}

Measured memory_bytes: 13152
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int C(vector<int>& v,int md){
	int len = 0;
	int ret = 1;
	FOR(i,sz(v)){
		if(md < v[i]) return INF;
		if(len + v[i] <= md) len += v[i];
		else {ret++; len = v[i];}
	}

	return ret;
}

int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vector<int> v(m); FOR(i,m) cin>>v[i];
		int l = 1, r = INF;
		while(r-l!=1){
			int md = (r+l)/2;
			if(C(v,md) <= n) r = md;
			else l = md;
		}
		cout << r << endl;
	}
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int dp[100005][3];
int abc[100005][3];

void Main() {

    rep(i, 100005) {
        rep(j, 3) {
            dp[i][j] = 0;
        }
    }

    int n;
    cin >> n;

    rep(i, n) {
        int a, b, c;
        cin >> a >> b >> c;
        abc[i][0] = a;
        abc[i][1] = b;
        abc[i][2] = c;
    }

    rep(i, 3) {
        dp[0][i] = 0;
    }
    for (int i = 0; i < n; ++i) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k)continue;
                chmax(dp[i + 1][j], dp[i][k] + abc[i][j]);
            }
        }
    }
    cout << max({ dp[n][0], dp[n][1], dp[n][2] }) << endl;


}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

class Main{
    public static void main(String args[]){
	int a;
	int b;
	int c;
	Scanner scan = new Scanner(System.in);
	a = scan.nextInt();
	b = scan.nextInt();
	c = scan.nextInt();
	if(a == 5 && b == 7 && c ==5){
	    System.out.println("YES");
	}else if(a == 7 && b == 5 && c ==5){
	    System.out.println("YES");
	}else if(a == 5 && b == 5 && c == 7){
	    System.out.println("YES");
	}else{
	    System.out.println("NO");
	}
    }
}

Measured memory_bytes: 9044
n,m = map(int,input().split())
a = [[1,int(i)] for i in input().split()]
bc = [[int(i) for i in input().split()] for j in range(m)]
x = a+bc
x.sort(key=lambda y:y[1])
total = 0
ans = 0
for i in reversed(range(n+m)):
    if total >= n:
        break
    else:
        ans += x[i][1]*min(n-total,x[i][0])
        total += x[i][0]
print(ans)

Measured memory_bytes: 97176
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e+18
int va=10e8+7;
ll val[200007]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
   // cin>>t;
    while(t--){
        ll a,b,ans;
        cin>>a>>b;
        ans=a*b;
        cout<<ans<<endl;
    }
 return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
const double EPS = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int  maxn = 1e5 + 100;
const int  maxm = 300;
int cost[5];
double now[5];
int main()
{
        now[1] = 0.250, now[2] = 0.50, now[3] = 1.0, now[4] = 2.0;
        for (int i = 1; i <= 4; i++)
        {
                cin >> cost[i];
        }
        for (int i = 2; i <= 4; i++)
                for (int j = 1; j < i; j++)
                {
                        int cur = (int)(now[i] / now[j]) * cost[j];
                        cost[i] = min(cost[i], cur);
                }
        double sum;
        ll anser = 0;
        cin >> sum;
        while (sum > 0)
        {
                for (int i = 4; i >= 1; i--)
                {
                        if (now[i] <= sum)
                        {
                                sum -= now[i];
                                anser += cost[i];
                                break;
                        }
                }
        }
        cout<<anser<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n, k, i;
  scanf("%d", &n);
  char s[n], a;
  scanf("%s", s);
  scanf("%d", &k);
  a=s[k-1];
  for(i=0;i<n;i++){
    if(s[i]!=a){
      s[i]='*';
    }
  }
  printf("%s", s);
  return 0;
}


Measured memory_bytes: 128
fn main() {
    proconio::input! {
        s : String,
        t : String
    };
    let a = s.as_bytes();
    let b = t.as_bytes();
    let mut dp = vec![vec![0; t.len()+1]; s.len()+1];
    for i in (0..s.len()).rev() {
        for j in (0..t.len()).rev() {
            dp[i][j] = dp[i+1][j+1] + if a[i] == b[j] { 1 } else { 0 };
            dp[i][j] = dp[i][j].max(dp[i][j+1]);
            dp[i][j] = dp[i][j].max(dp[i+1][j]);
        }
    }
    let mut x = 0;
    let mut y = 0;
    while x < s.len() && y < t.len() {
        if a[x] == b[y] && dp[x][y] == dp[x+1][y+1] + 1 {
            print!("{}", a[x] as char);
            x += 1;
            y += 1;
        } else if dp[x][y] == dp[x+1][y+1] {
            x += 1;
            y += 1;
        } else if dp[x][y] == dp[x][y+1] {
            y += 1;
        } else {
            x += 1;
        }
    }
    println!("");
}


Measured memory_bytes: 37304
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 100005
#define maxm 1000006
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
long long s;
pii ans[4];
int main()
{
    ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
    //freopen(Task".inp", "r",stdin);
    //freopens(Task".out", "w",stdout);
    cin >> s;
    ans[2].F = 1e9;
    ans[3].S = (s - 1) / ans[2].F + 1;
    ans[3].F = 1;
    ans[2].S = 1ll*ans[2].F*ans[3].S - s;
    FOR(i,1,3) cout << ans[i].F << ' ' << ans[i].S << ' ';
    return 0;
}


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

s_list = []
for _ in range(n):
  s = input()
  s_list.append(s)

print('AC x', str(s_list.count('AC')))
print('WA x', str(s_list.count('WA')))
print('TLE x', str(s_list.count('TLE')))
print('RE x', str(s_list.count('RE')))



Measured memory_bytes: 16168
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
      
      	boolean flag = false;
      	for(int i = a; i <= b; i++){
          if(i % k == 0) flag = true;
        };

      	if(flag){
          System.out.println("OK");
        }else{
          System.out.println("NG");
        };
	}
}

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

public class Main {
	static final long INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		long sum = 0;
		int cntMax = n;
		int cntMin = 0;
		long max = 0;
		long min = 0;
		for(int i = 0; i < k; i++) {
			max += cntMax;
			min += cntMin;
			cntMax--;
			cntMin++;
		}		
		sum += (max - min + 1) % INF;
		//out.println(sum);
		
		for(int r = k + 1; r <= n + 1; r++) {
			max += cntMax;
			min += cntMin;
			sum += (max - min + 1) % INF;	
			//out.println(sum);
			cntMax--;
			cntMin++;
		}
		out.println(sum % INF);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




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

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

    if (a * b % 2) {
        cout << "Odd" << endl;
    } else {
        cout << "Even" << endl;
    }
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') s[i] = '9';
		else s[i] = '1';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val numbers = readLine()!!.split(" ").map { it.toInt() }
    val odd = mutableMapOf<Int,Int>()
    val even = mutableMapOf<Int,Int>()
    numbers.indices.forEach {
        if(it%2==0) {
            even[numbers[it]] = (even[numbers[it]]?:0) + 1
        } else {
            odd[numbers[it]] = (odd[numbers[it]]?:0) + 1
        }
    }
    var ans = itemCount
    val oddList = odd.toList().sortedByDescending { it.second }
    val evenList = even.toList().sortedByDescending { it.second }
    if(oddList.first().first == evenList.first().first) {
        ans = itemCount - oddList.first().second - if(evenList.size <= 1) 0 else evenList[1].second
        ans = Math.min(ans,itemCount - evenList.first().second - if(oddList.size <= 1) 0 else oddList[1].second)
    } else {
        ans = itemCount - oddList.first().second - evenList.first().second
    }
    println(ans)
}

Measured memory_bytes: 61032
import itertools
N = int(input())
ans = 0
for k in range(3,len(str(N))+1):
    for ptn in itertools.product((3,5,7), repeat=k):
        if (3 not in ptn) or (5 not in ptn) or (7 not in ptn):
            continue
        a = int(''.join(list(map(str,ptn))))
        if a <= N:
            ans += 1
print(ans)

Measured memory_bytes: 3060
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

/* We need to count
 * the components if only walk.
 * then find wich components are connected
 * by magic, then find shortest path
 * of inter components.
 */
const int INF=1e9;
void solve() {
    cini(h);
    cini(w);
    cini(ch);
    cini(cw);
    cini(dh);
    cini(dw);
    cinas(s,h);

    ch--;
    cw--;
    dh--;
    dw--;

    vvi dp(h, vi(w, INF));
    dp[ch][cw]=0;

    const vi dx={ 0, 1, 0, -1 };
    const vi dy={ 1, 0, -1, 0 };
    priority_queue<pair<int,pii>> q;
    q.push({0,{ch,cw}});
    while(q.size()) {
        auto [i,j]=q.top().second;
        int prio=-q.top().first;
        q.pop();
        if(prio!=dp[i][j])
            continue;

        for(int ii=0; ii<4; ii++) {
                if(i+dx[ii]>=0 && i+dx[ii]<h && j+dy[ii]>=0 && j+dy[ii]<w && s[i+dx[ii]][j+dy[ii]]=='.' && dp[i][j]<dp[i+dx[ii]][j+dy[ii]]) {
                    dp[i+dx[ii]][j+dy[ii]]=dp[i][j];
                    q.push({-dp[i+dx[ii]][j+dy[ii]],{i+dx[ii],j+dy[ii]}});
                }
        }

        for(int ii=-2; ii<=2; ii++) {
            for(int jj=-2; jj<=2; jj++) {
                if(i+ii>=0 && i+ii<h && j+jj>=0 && j+jj<w && s[i+ii][j+jj]=='.' && dp[i][j]+1<dp[i+ii][j+jj]) {
                    dp[i+ii][j+jj]=dp[i][j]+1;
                    q.push({-dp[i+ii][j+jj],{i+ii,j+jj}});
                }
            }
        }
    }

    if(dp[dh][dw]==INF)
        cout<<-1;
    else
        cout<<dp[dh][dw]<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 12668
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        long count = 1;
        for(int i=0;i<N;i++){
            long A = long.Parse(Console.ReadLine());
            count = count/gcd(count,A)*A;
        }
        sb.Append(count+"\n");
    }
    long gcd(long a,long b){
        if(b == 0){
            return a;
        }
        else{
            return gcd(b,a%b);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define int long long
#define endl "\n"
#define print_array(name,n) for(int o=0;o<n;o++) cout<<name[o]<<" "

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int h,a;
    cin>>h>>a;
    int count = 0;
    while(h>0){
    	h = h-a;
    	count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
K = int(input())
L = 0
if K % 7 == 0:
  L = 9*K//7
else:
  L = 9*K
ans = -1
a = 10
for i in range(1,L+1,1):
  if a % L == 1:
    ans = i
    break
  a = (a % L) * 10 

print(ans)

Measured memory_bytes: 8944