akhauriyash/Code-Regression huggingface dataset:
/* ファイル名：ITP1_10_C.c	*/
/* 内容：n 人の学生を含むクラスで試験を行った。それぞれ学生のの得点の標準偏差を求める。	*/

/* include	*/
#include <stdio.h>
#include <math.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:それぞれ学生のの得点の標準偏差を求める	*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	int n;				/* 学生の人数	*/
	int score[1000];	/* 各学生の点数	*/
	
	/* 処理	*/
	double ave;			/* 全学生の点数の平均	*/
	double dev_2[1000];	/* 全学生の偏差の2乗	*/
	double dev_2_ave;	/* 全学生の偏差の2乗の平均	*/
	int i;				/* ループ用変数			*/
	/* 出力	*/
	double a;			/* 標準偏差				*/
	
	/* 無限ループ	*/
	while(1){
		scanf("%d",&n);/* 学生の人数を取得	*/
		
		/* 学生の人数が0の場合	*/
		if(n == 0){
			break;	/* 処理を終了する	*/
		}
		else{
			/* 処理を続行する	*/
		}
		
		/* 処理変数初期化	*/
		ave = 0;
		dev_2_ave = 0;
		
		/* 各学生の点数を取得*/
		for(i = 0; i < n; i++){
			scanf("%d",&score[i]);/* 各学生の点数を取得	*/
			
			ave = ave + score[i];/* 平均の算出の為に、点数を合計しておく	*/
		}
		
		ave = ave / n;	/* 平均の算出	*/
		
		/* 全学生の偏差の2乗を算出	*/
		for(i = 0; i < n; i++){
			dev_2[i] = pow(score[i] - ave, 2);/* 全学生の偏差の2乗を算出	*/
			
			dev_2_ave = dev_2_ave + dev_2[i];/* 平均の算出の為に、偏差の2乗を合計しておく	*/
		}
		
		dev_2_ave = dev_2_ave / n;	/* 偏差の2乗の平均の算出	*/
		
		a = sqrt(dev_2_ave);		/* 標準偏差を算出			*/
		
		
		/* 結果の出力	*/
		printf("%lf\n",a);			/* 標準偏差を出力			*/
	}
	
	return 0;
}



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

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

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

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

int main() {
	int a[11];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	sort(a,a+10);
	for(int i=9;i>=7;i--){
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  int i=n;
  int s=0;
  while(i>=1){
    s+=i%10;
    i/=10;
    }
  if(n%s==0){
    cout<<"Yes"<<endl;
    }
  else{
    cout<<"No"<<endl;
    }
  return 0;
  }

    

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  for (int i=0;i<K;i++) {
    if (A>=B) {
      B*=2;
    } else if (B>=C) {
      C*=2;
    } else {
      break;
    }
  }
  if (A<B && B<C) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt()*100;
		int g = sc.nextInt()*10;
		int b = sc.nextInt();
		int ans = r + g + b;
		if (ans % 4 == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		sc.close();
	}

}

Measured memory_bytes: 23380
import java.util.Scanner;


public class Main {

	char[][] makeSpiral(int n){
		char[][] pattern=new char[n][n];
		int dir=0;
		int x=0,y=n-n%2;
		int[] dx={0,1,0,-1};
		int[] dy={-1,0,1,0};
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j){
				pattern[i][j]=' ';
			}
		}
		int notTurn=2;
		boolean end=false;
		while(!end){

			if(n%2==0||notTurn<2){
				x+=dx[dir];
				y+=dy[dir];
			}
			--notTurn;
			
			switch(dir){
			case 0:
				if(y<=0||(y!=1&&pattern[x][y-2]=='#')){
					if(notTurn>0){
						end=true;
					}
					else{
						dir=1;
						notTurn=2;
					}
				}
				break;
			case 1:
				if(x>=n-1||(x!=n-2&&pattern[x+2][y]=='#')){
					if(notTurn>0){
						end=true;
					}
					else{
						dir=2;
						notTurn=2;
					}
				}
				break;
			case 2:
				if(y>=n-1||(y!=n-2&&pattern[x][y+2]=='#')){
					if(notTurn>0){
						end=true;
					}
					else{
						dir=3;
						notTurn=2;
					}
				}
				break;
			case 3:
				if(x<=0||(x!=1&&pattern[x-2][y]=='#')){
					if(notTurn>0){
						end=true;
					}
					else{
						dir=0;
						notTurn=2;
					}
				}
				break;
			}
			pattern[x][y]='#';
		}
		return pattern;
	}
	
	void io(){
		Scanner s=new Scanner(System.in);
		int setnum=s.nextInt();
		for(int i=0;i<setnum;++i){
			int n=s.nextInt();
			char[][] pattern=makeSpiral(n);
			
			if(i>0)System.out.println();
			for(int y=0;y<n;++y){
				for(int x=0;x<n;++x){
					System.out.print(pattern[x][y]);
				}
				System.out.println();
			}
		}
		s.close();
	}

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

}

Measured memory_bytes: 12000
<?php
    $line_a ="";
    while($line = trim(fgets(STDIN))){
        $line_a = $line_a.$line;
    }
    $line = str_split($line_a);
    // $line = str_split((fgets(STDIN)));
    $A = array_fill(65,122,0);
    // var_dump($A);
    foreach($line as $char){
        $ACS = ord($char);
        if(65<=$ACS && $ACS<=122){
            if($ACS<=90){
                $A[$ACS+32] += 1;
            }else{
                $A[$ACS] += 1;
            }
            // echo $ACS."\n";
        }
        
    }
    // var_dump($A);
    
    
    
    for ( $i = 97; $i <= 122; $i++ ){
	    print chr($i)." : ".$A[$i]."\n";
    }
?>


Measured memory_bytes: 9376
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N = int(input())
N = factorization(N)
count = 0

if N[0][0] == 1:
    print(0)
else:
    for i in range(0,len(N)):
        t = 0
        for j in range(1,N[i][1]+1):
            t += j
            if N[i][1] == t:
                count += j
                break
            elif N[i][1] < t:
                count += j-1
                break
            else:
                pass
    print(count)
            
        

Measured memory_bytes: 9504
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int, readline().split())
A = list(map(int,readline().split()))
MOD = 10**9 +7
B = []
C = []
for a in A:
    if a >= 0:
        B.append(a)
    else:
        C.append(-a)

ans = 1
if len(B) == 0 and K % 2 == 1:
    C = sorted(C)
    for i in range(K):
        ans *= -C[i]
        ans %= MOD
    print(ans)
    sys.exit()
      
negs_p = 0
non_negs_p = 0
B = sorted(B,reverse = True)
C = sorted(C,reverse = True)

for i in range(K):
    if negs_p == len(C):
        non_negs_p += 1
    elif non_negs_p == len(B):
        negs_p += 1
    elif C[negs_p] > B[non_negs_p]:
        negs_p += 1
    else:
        non_negs_p += 1
        
if N == K or negs_p % 2 == 0:
    for i in range(non_negs_p):
        ans = ans * B[i] % MOD
    for i in range(negs_p):
        ans = ans * -C[i] % MOD
    print(ans)
    sys.exit()

if negs_p % 2 == 1:
    if negs_p == len(C) or non_negs_p == 0:
        negs_p -= 1
        non_negs_p += 1 
        for i in range(non_negs_p):
            ans = ans * B[i] % MOD
        for i in range(negs_p):
            ans = ans * -C[i] % MOD
    elif non_negs_p == len(B) or negs_p == 0:
        negs_p += 1
        non_negs_p -= 1 
        for i in range(non_negs_p):
            ans = ans * B[i] % MOD
        for i in range(negs_p):
            ans = ans * -C[i] % MOD
    else:
        a,b,c,d = C[negs_p],C[negs_p-1],B[non_negs_p],B[non_negs_p-1]
        if a*b > c*d:
            negs_p += 1
            non_negs_p -= 1
        else:   
            negs_p -= 1
            non_negs_p += 1
        for i in range(non_negs_p):
            ans = ans * B[i] % MOD
        for i in range(negs_p):
            ans = ans * -C[i] % MOD
print(ans) 
    
    
    
        
        
        

Measured memory_bytes: 27832
let rec sum_of_digits x res =
  if x = 0 then res else
  sum_of_digits (x/10) (res+x mod 10)

let solve n a b =
  let rec count m res =
    if m > n then res else
    let s = sum_of_digits m 0 in
    count (m+1) (res + if a <= s && s <= b then m else 0)
  in
  count 1 0

let () =
  Scanf.scanf "%d %d %d\n" @@ fun n a b -> 
  Printf.printf "%d\n" @@ solve n a b

Measured memory_bytes: 384
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from math import ceil

n = ni()
csf = nan(n - 1)

ans = []
for i in range(n - 1):
    c, s, f = csf[i]
    cur = s + c
    for j in range(i + 1, n - 1):
        nc, ns, nf = csf[j]
        cur = max(ceil(cur / nf) * nf, ns) + nc
    ans.append(cur)
ans.append(0)

print(*ans, sep="\n")

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

bool is_prime[200000];
int cnt[50001];
vector<int> primes;

void calc_prime(int n){
	for(int i = 0; i <= n; ++i)
		is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; ++i){
		if(is_prime[i]){
			primes.push_back(i);
			for(int j = i * 2; j <= n; j += i)
				is_prime[j] = false;
		}
	}
}

int main() {
	calc_prime(50000);
	for(int i = 0; i < primes.size(); ++i){
		for(int j = i; j < primes.size(); ++j){
			if(primes[i] + primes[j] > 50000)
				break;
			cnt[primes[i] + primes[j]]++;
		}
	}
	int n;
	while(cin >> n && n){
		cout << cnt[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1516
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define ls id << 1
#define rs id << 1 | 1
using namespace std;
typedef long long ll;
int n, k;
const int N = 100050;
const ll mod = 1e9 + 7;
ll ans = 1;
struct edge
{
    int v, nxt;
} e[N << 1];
int col[N];
int dep[N];
int head[N], ecnt;
ll a[N];
int f[N], son[N];
void ad(int u, int v)
{
    e[++ecnt].v = v;
    e[ecnt].nxt = head[u];
    head[u] = ecnt;
}

void dfs1(int u, int fa)
{
    for (int i = head[u]; i; i = e[i].nxt)
    {
        int v = e[i].v;
        if (v == fa)
            continue;
        f[v] = u;
        son[u]++;
        dep[v] = dep[u] + 1;
        dfs1(v, u);
    }
}
void dfs2(int u, int fa, ll val)
{
    int t = son[u], nv = k;
    t--;
    a[u] = val;
    for (int i = head[u]; i; i = e[i].nxt)
    {
        int v = e[i].v;
        if (v == fa)
            continue;
        if (dep[v] <= 1)
        {
            dfs2(v, u, --nv);
        }
        else
        {
            dfs2(v, u, k - 2 - t);
            t--;
        }
    }
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        ad(x, y), ad(y, x);
    }
    dfs1(1, 0);
    dfs2(1, 0, k);
    for (int i = 1; i <= n; ++i)
    {
        ans *= a[i];
        ans %= mod;
    }
    printf("%lld\n", ans);
    // system("pause");
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int func(string s,string t){
    int res=0;
    for(char c='a';c<='z';c++){
        if(count(ALL(s),c) and count(ALL(t),c)) res++;
    }
    return res;
}

signed main()
{
    int N; cin>>N;
    string s; cin>>s;

    int ans=0;
    for(int i=1;i<=N-1;i++){
        int tmp=func(s.substr(0,i),s.substr(i));
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

m = 0.006
candidate_num = 0

for i in range(N):
  if abs(T - m*H[candidate_num] - A) > abs(T - m * H[i] - A):
    candidate_num = i
print(candidate_num+1)  

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


int main(){

    string s; cin >> s;
    if((!(s.size() % 2) && s[0] == s[s.size() - 1]) || ((s.size() % 2) && s[0] != s[s.size() - 1])) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
vector<P> G[800];
int p[800];
int d[800];
int cnt[800];
int dfs1(int v, int par) {
	cnt[v] = 1;
	for (P e : G[v]) {
		if (e.first != par) cnt[v] += dfs1(e.first, v);
	}
	return cnt[v];
}
P dfs2(int v, int par) {
	int sum = 0;
	int maximal = 0;
	for (P e : G[v]) {
		if (e.first == par) continue;
		if (cnt[e.first] > 1) {
			sum += e.second * 3;
			P p = dfs2(e.first, v);
			sum += p.first;
			maximal = max(maximal, p.second + e.second);
		}
		else {
			sum += e.second;
		}
	}
	return P(sum, maximal);
}
int main() {
	int n;
	while (cin >> n, n) {
		for (int i = 1; i < n; i++) {
			cin >> p[i];
			p[i]--;
		}
		for (int i = 1; i < n; i++) {
			cin >> d[i];
		}
		for (int i = 0; i < n; i++) G[i].clear();
		for (int i = 1; i < n; i++) {
			G[i].emplace_back(p[i], d[i]);
			G[p[i]].emplace_back(i, d[i]);
		}
		int ans = 1 << 30;
		for(int i = 0; i < n; i++) {
			dfs1(i, -1);
			P p = dfs2(i, -1);
			ans = min(ans, p.first - p.second);
		}
		cout << ans << endl;
	}
}


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

bool IsPalin(string& s, int start, int end) {
  for (int i = start, j = end - 1; i < j; ++i, --j) {
  	if (s[i] != s[j]) {
  	  return false;
  	}
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  
  int n = s.size();
  if (IsPalin(s, 0, n) && IsPalin(s, 0, n / 2) && IsPalin(s, n / 2 + 1, n)) {
  	printf("Yes\n");
  } else {
  	printf("No\n");
  }
  return 0;
}

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

long long int ans,dp[1010][1010],h,w,i,j;
string s[1010];

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>h>>w;
	for (i=1;i<h+1;i++) cin>>s[i];
	dp[1][1]=1;
	for (i=1;i<h+1;i++) dp[i][0]=0;
	for (i=1;i<w+1;i++) dp[0][i]=0;
	for (i=1;i<h+1;i++)
	for (j=1;j<w+1;j++)
	if (i+j>2) if (s[i][j-1]=='#') dp[i][j]=0;else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
	cout<<dp[h][w];
}



Measured memory_bytes: 9216
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int main() {
    int N, A, B;
    cin>>N>>A>>B;
    
    ll nums[100009];
    rep(i,N){
        ll x; cin >> x;
        nums[i] = x;
    }
    
    sort(nums,nums+N);
    
    unsigned long long lb=-1, ub=1e19;
    while( ub-lb > 1 ){
        unsigned long long mid = (ub+lb)/2;
        unsigned long long Bd = mid*B;
        int idx = upper_bound(nums,nums+N,Bd) - nums;
        ll cnt = mid;
        for(int i=idx; i<N; i++){
            cnt -= ceil(1.0*(nums[i]-Bd)/(A-B));
            if(cnt<0) break;
        }
        if(cnt>=0){
            ub = mid;
        }else{
            lb = mid;
        }
    }
    cout<<ub<<endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int n,m;
  cin >> n;
  map<string, int> s,t;
  REP(i,n){
    string str;
    cin >> str;
    s[str]++;
  }
  cin >> m;
  REP(i,m){
    string str;
    cin >> str;
    t[str]++;
  }

  int ans=0;
  for(auto &v: s){
    ans=max(ans, v.second - t[v.first]);
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<math.h>

int main()
{
    int e;
    while (1)
    {
        cin >> e;
        if (e == 0)
            break;
        int x, y ,m;
        int min = e;
        for (int i = 0; i*i*i <= e; i++)
        {
            y = sqrt(e - i*i*i);
            x = e - i*i*i - y*y;
            m = x + y + i;
            if (m < min)
                min = m;
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    deque<char> dq;
    string s;
    cin >> s;
    for(ll i = 0; i < s.size(); i++){
        if(s[i]== '0')
        dq.push_back(s[i]);
        if(s[i] == '1')
        dq.push_back(s[i]);
        if(s[i] == 'B' && dq.empty());
        if(s[i] == 'B' && !dq.empty()){
            dq.pop_back();
        }
    }
    ll k = dq.size();
    for(ll i = 0; i < k; i++){
        char ans = dq.front();
        dq.pop_front();
        cout << ans;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,a,n,l[1000],ans,sum;


int main(void){
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    for(int i=0;i<n+1;i++){
        sum+=l[i];
        ans++;
        if(sum>x)break;
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int a,b,c,k,i=0,j,n,x,y;
   cin>>a>>b>>c;
    cin>>k;
    bool ok=true;
    while(b<=a){
        b*=2;
        i+=1;
    }
        while(c<=b){
         c*=2;
         i+=1;
        }
    //cout<<i<<" "<<b<<" "<<c<<endl;
    if(i<=k)
        cout<<"Yes";
    else
        cout<<"No";
       /* cin>>n;
        long long int sum=0;
        long long int A[n+1];
        x=1000;
        result=1000;
        for(i=1;i<=n;i++){
            cin>>A[i];
        }
        for(i=1;i<=n;i++){

        }*/
    return 0;
}


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

int main(){
	while(1){
		long n, k;
		long s[100001]; //i番目までの和
		s[0]=0;
		
		scanf(" %ld %ld", &n, &k);
		if(n==0) break;
		for(long i=0; i<n; ++i){
			int a;
			scanf(" %d", &a);
			s[i+1] = s[i]+a;
		}
		
		long max=-1500000000;
		for(int i=1; i+k<=n; ++i){
			long tmp=s[i+k]-s[i];	
			if(tmp>max) max=tmp;
		}
		
		printf("%ld\n", max);
	}
}

Measured memory_bytes: 1968
s = input()
l = len(s)
cnt = 0
ls = []
ls.append(0)
ls.append(0)
for i in range(l):
    ls.append(int(s[i]))
for i in range(l+1):#下から回す
    if 6<= ls[-i-1] or (ls[-i-1] ==5 and ls[-i-2] >=5):
        ls[-i-1] = 10 -ls[-i-1] #おつりを代入
        ls[-i-2] += 1 #繰り上がり
print(sum(ls))


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

using namespace std;


int digitsSum(int n) {
    int res = 0;
    while (n > 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}


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

    int ans = 1000000;
    for (int a = 1; a < n; ++a) {
        ans = min(ans, digitsSum(a) + digitsSum(n - a));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
open Batteries
open Printf

let ($) g f x = g (f x)

module MyList = struct
  include List
  let foldl = fold_left
  let foldli = fold_lefti
  let foldr = fold_right
  let foldri = fold_righti
  
  let flatmap = concat_map

  let zipf = map2
  let zipfi = map2i
end

module L = MyList

let swap = Tuple2.swap

let atoi = int_of_string
let itoa = string_of_int
let atof = float_of_string
let ftoa = string_of_float
let ctoi = int_of_char
let itoc = char_of_int

let stocl = String.to_list
let cltos = String.of_list
let spsp s = String.split_on_char ' ' s

module MyString = struct
  include String

  let soc = split_on_char

  let map' f s = L.map f (stocl s)
  let mapi' f s = L.map f (stocl s)

  let zipf f a b = L.zipf f (stocl a) (stocl b)
  let zipfi f a b = L.zipfi f (stocl a) (stocl b)

  let mkstr f sep ls =
    L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)
end

module S = MyString

module MySet = struct
  include Set

  let fold' f s z = fold f z s
end

module St = MySet

module MyMap = struct
  include Map

  let apply = find
  let apply_or = find_default
end

module Mp = MyMap


let rds () = read_line ()

let rdi () = atoi @@ rds ()

let rdhs () = spsp @@ rds ()
let rdhi () = rdhs () |> L.map atoi

let rdi2 () = match rdhi () with
  | a::b::_ -> (a, b)
  | _ -> (0, 0)

let rdi3 () = match rdhi () with
| a::b::c::_ -> (a, b, c)
| _ -> (0, 0, 0)

let rdi4 () = match rdhi () with
| a::b::c::d::_ -> (a, b, c, d)
| _ -> (0, 0, 0, 0)

let rdi5 () = match rdhi () with
| a::b::c::d::e::_ -> (a, b, c, d, e)
| _ -> (0, 0, 0, 0, 0)

let rdv n rdf =
  let rec rdv' n =
    if n <= 0 then []
    else (
      let s = rdf () in
      s::(rdv' (n - 1))
    )
  in rdv' n

let rdvi n = rdv n rdi
let rdvi2 n = rdv n rdi2
let rdvi3 n = rdv n rdi3
let rdvi4 n = rdv n rdi4

let puts s = print_endline s
let putyn b = puts (if b then "Yes" else "No")
let puti i = puts @@ itoa i

let set_power ls =
  let rec set_power' ls pls =
    match ls with
    | [] -> pls
    | hd::tl -> set_power' tl (L.flatmap (fun p -> [p; hd::p]) pls)
  in set_power' ls [[]]


let rdhf () = rdhs () |> L.map atof
let rdf4 () = match rdhf () with
| a::b::c::d::_ -> (a, b, c, d)
| _ -> (0., 0., 0., 0.)


module Graph = struct

  type 'a t = { nb : (int, int St.t) Mp.t; vdt : (int, 'a) Mp.t }

  let nothing = { nb = Mp.empty; vdt = Mp.empty }

  let add_edge (e : int * int) g =
    let (v1, v2) = e in
    let nbvs = g.nb |> Mp.apply_or St.empty v1 in
    let nb1 = g.nb |> Mp.add v1 (nbvs |> St.add v2) in
    { g with nb = nb1 }

  let add_uedge e g =
    add_edge e (add_edge (swap e) g)

  let from_edges es =
    es |> L.foldl (fun g e -> add_edge e g) nothing

  let from_uedges es =
    es |> L.foldl (fun g e -> add_uedge e g) nothing


end

module G = Graph


let _ =
  let t = rds () in
  let spt = stocl t in
  let rec pdpd sl = function
    | [] -> sl
    | h::'?'::t when h <> '?' -> 
      if h = 'P' then pdpd ('D'::h::sl) t else pdpd ('D'::h::sl) t
    | h::t when h = '?' -> pdpd ('D'::sl) t 
    | h::t -> pdpd (h::sl) t
  in
  let sl = L.rev @@ pdpd [] spt in
  let result = cltos sl in
  puts result
;;


Measured memory_bytes: 19592
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll N;
ll twopow[30], tenpow[1000000], ninepow;

ll mypow(ll a, ll b) {
  ll ans = 1;
  ll tmp;
  ll two;
  while(b>0) {
    two = 1;
    tmp = a;
    while(2*two<b) {
      two *= 2;
      tmp *= tmp;
      tmp %= mod1;
    }
    b -= two;
    ans *= tmp;
    ans %= mod1;
  }
  return ans;
}

struct SegmentTree {
  vector<pair<ll, ll> > Tree[20];

  void init() {
    ll len;
    for(int i=0;i<20;++i) {
      Tree[i].resize((1<<i));
      len = twopow[19-i];
      for(int j=0;j<Tree[i].size();++j) {
        Tree[i][j] = mp((tenpow[len]-1+mod1)*ninepow%mod1, 0);
      }
    }
    return;
  }

  void eval(int pos1, int pos2) {
    if(Tree[pos1][pos2].se==0) return;
    if(pos1+1<20) {
      Tree[pos1+1][2*pos2].se = Tree[pos1][pos2].se;
      Tree[pos1+1][2*pos2+1].se = Tree[pos1][pos2].se;
    }
    ll len = twopow[19-pos1];
    Tree[pos1][pos2].fi = (tenpow[len]-1+mod1)*ninepow%mod1*Tree[pos1][pos2].se%mod1;
    Tree[pos1][pos2].se = 0;
    return;
  }

  void update(int ql, int qr, ll x, int pos1=0, int pos2=0, int sl=0, int sr=(1<<19)) {
    eval(pos1, pos2);
    if(qr<=sl || sr<=ql) return;
    if(ql<=sl && sr<=qr) {
      Tree[pos1][pos2].se = x;
      eval(pos1, pos2);
      return;
    }
    update(ql, qr, x, pos1+1, 2*pos2, sl, (sl+sr)/2);
    update(ql, qr, x, pos1+1, 2*pos2+1, (sl+sr)/2, sr);
    ll len = twopow[19-(pos1+1)];
    Tree[pos1][pos2].fi = (Tree[pos1+1][2*pos2].fi*tenpow[len]%mod1+Tree[pos1+1][2*pos2+1].fi)%mod1;
  }

  ll getans(int ql, int qr, int pos1=0, int pos2=0, int sl=0, int sr=(1<<19)) {
    eval(pos1, pos2);
    if(qr<=sl || sr<=ql) return 0;
    if(ql<=sl && sr<=qr) return Tree[pos1][pos2].fi*tenpow[N-sr]%mod1;
    return (getans(ql, qr, pos1+1, 2*pos2, sl, (sl+sr)/2)+getans(ql, qr, pos1+1, 2*pos2+1, (sl+sr)/2, sr))%mod1;
  }

  void check() {
    for(int i=16;i<20;++i) {
      for(int j=0;j<(1<<(i-16));++j) {
        cout<<"("<<Tree[i][j].fi<<","<<Tree[i][j].se<<")"<<" ";
      }
      cout<<endl;
    }
  }
};

int main() {
  twopow[0] = 1;
  for(int i=1;i<30;++i) twopow[i] = twopow[i-1]*2%mod1;
  tenpow[0] = 1;
  for(int i=1;i<1000000;++i) tenpow[i] = tenpow[i-1]*10%mod1;
  ninepow = mypow(9, mod1-2);
  ll Q;
  cin>>N>>Q;
  ll L, R, D;
  SegmentTree tree;tree.init();
  ll ans[Q];
  for(int i=0;i<Q;++i) {
    cin>>L>>R>>D;
    L--;
    tree.update(L, R, D);
    ans[i] = tree.getans(0, N);
  }
  for(int i=0;i<Q;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 29080
#include <stdio.h>
#include <iostream>

using namespace std;

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

int main() {
    int N, M;
    cin >> N >> M;

    int A[M];
    REP(0, i, M) {
        A[i] = 0;
    }

    REP(0, i, N) {
        int K;
        cin >> K;

        REP(0, j, K) {
            int x;
            cin >> x;
            x--;
            A[x]++;
        }
    }

    // REP(0, i, M) {
    //     cout << A[i] << endl;
    // }

    int cnt = 0;
    REP(0, i, M) {
        // cout << A[i] << endl;
        if (A[i] == N) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

typedef long long ll;
const ll INF=0x3f3f3f3f;
const int N=1e5+5;

int main()
{
    long long int n,i,a,b,max1,ans=0,ci=0;
    int flag=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        if(flag==0&&a>b)
        {
             max1=b;
             flag=1;
        }
        if(a==b)ci++;
        ans+=a;
        if(a>b)
        {
            if(b<max1)
            max1=b;
        }
    }
    if(ci==n)
    {
        printf("0\n");
    }
    else
    {
        ans-=max1;
       cout<<ans<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    int a[100010];
    cin >> n >> x;

    long long int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n-1; i++){
        if(a[i] + a[i+1] >= x){
            int diff = (a[i] + a[i+1]) - x;
            ans += diff;
            if(a[i+1] >= diff){
                a[i+1] -= diff;
            }
            else{
                a[i+1] = 0;
               // a[i]=a[i]-(diff-a[i+1]);
            }
        }
    }
   // if(a)
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
program walk_on_multiplication_table
    implicit none
    integer(8):: n
    integer(8)::a,b, i
    read*, n

    do i=1, nint(sqrt(dble(n)))
        if (mod(n,i) == 0) then
            a = i
            b = n/i
        end if
    end do

    print*, a+b-2

end program walk_on_multiplication_table

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

#define endl '\n'
#define LL long long
#define MP make_pair
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define FORR(i, a, b) for(int i = b - 1; i >= a; --i)
#define EB emplace_back
#define ST first
#define ND second
#define S size()
#define RS resize

using VI = vector<int>;
using VVI = vector<VI>;
using PI = pair<int, int>;
using VPI = vector<PI>;
using VVPI = vector<VPI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

int main()
{ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N, W;
    cin >> N >> W;
    VLL dp(W + 1);
    REP(x, N)
    {
        int w;
        LL v;
        cin >> w >> v;
        FORR(i, w, W + 1)
            dp[i] = max(dp[i], dp[i - w] + v);
    }
    cout << dp[W];
}
        

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

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

int main(){
	int l;
	while(cin >> l && l){
		int m = -1;
		int a, b;
		rep(i, 12){
			cin >> a >> b;
			l -= (a - b);
			if(m == -1 && l <= 0){
				m = i;
			}
		}
		if(m >= 0) cout << m + 1 << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

const double EPS = 1e-5;

double dp[51][5000];
int X, Y, Z, V[4];
int ev[51], val[51];

int main(){
    while(cin >> X >> Y >> Z, X||Y||Z){
        for(int i = 0; i < X; i++){
            cin >> V[i];
        }
        fill(ev, ev+51, 0);
        for(int i = 0; i < Z; i++){
            int a, b, c;
            cin >> a >> b >> c;
            ev[a] = b, val[a] = c;
        }
        for(int i = 0; i <= Y; i++){
            fill(dp[i], dp[i]+5000, 0);
        }
        dp[0][0] = 1;
        for(int i = 0; i < Y; i++){
            for(int j = 0; j < 5000; j++){
                for(int k = 0; k < X; k++){
                    if(abs(dp[i][j])==0) continue;
                    int nx = min(Y, i + V[k]), mn = j;
                    if(ev[nx] == 2) mn += val[nx];
                    else if(ev[nx] == 3) mn = max(0, j-val[nx]);
                    else if(ev[nx] == 1) nx = min(Y, nx + val[nx]);
                    dp[nx][mn] += dp[i][j] / X;
                }
            }
        }
        double ans = 0;
        for(int i = 0; i < 5000; i++) ans += i * dp[Y][i];
        printf("%d\n", (int)(ans+EPS));
    }
    return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>

typedef long long LL;

const int MAXN = 2000;
const int MOD = 998244353;

int n, m;
LL frac[MAXN << 1 | 1], iFrac[MAXN << 1 | 1];

inline int read() {
  register int x = 0;
  register char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}

inline int fPow(int x, int y) {
  int res = 1, base = x;
  while (y > 0) {
    if (y & 1) res = 1LL * res * base % MOD;
    base = 1LL * base * base % MOD;
    y >>= 1;
  }
  return res;
}

inline int C(int x, int y) {
  return 1LL * frac[x] * iFrac[x - y] % MOD * iFrac[y] % MOD;
}

inline int A(int x, int y) {
  if (x < 0 || y < 0) return 0;
  return C(x + y - 1, y);
}

int main() {
  m = read();
  n = read();
  frac[0] = 1;
  for (int i = 1; i <= n + m - 1; ++i) frac[i] = 1LL * frac[i - 1] * i % MOD;
  iFrac[n + m - 1] = fPow(frac[n + m - 1], MOD - 2);
  for (int i = n + m - 2; i >= 0; --i) iFrac[i] = 1LL * iFrac[i + 1] * (i + 1) % MOD;
  int tot = A(m, n);
  for (int i = 2; i <= std::min(m + 1, 2 * m); ++i) {
    int res = tot;
    for (int j = 1; j <= i / 2; ++j) {
      res = (res + 1LL * (j % 2 ? -1 : 1) * A(m, n - 2 * j) * C(i / 2, j) + MOD) % MOD;
    }
    printf("%d\n", res);
  }
  for (int i = m + 2; i <= 2 * m; ++i) {
    int res = tot;
    for (int j = 1; j <= (2 * m - i) / 2 + 1; ++j) {
      res = (res + 1LL * (j % 2 ? -1 : 1) * A(m, n - 2 * j) * C((2 * m - i) / 2 + 1, j) + MOD) % MOD;
    }
    printf("%d\n", res);
  }
  return 0;
}


Measured memory_bytes: 3792
##入力は以下の形式で標準入力から与えられる。
##S
a_s = gets.chomp.split("").sort.uniq
#p a_s

##英小文字からなる文字列 Sが与えられます． Sに現れない英小文字であって，
##最も辞書順（アルファベット順）で小さいものを求めてください．
##ただし， Sにすべての英小文字が現れる場合は，代わりに None を出力してください．
a_dic = 'abcdefghijklmnopqrstuvwxyz'.split("")
#p a_dic

if a_s == a_dic
  check = false
else
  check = true
  not_exist_ch = ''
  a_dic.each_index do |idx|
    if a_dic[idx] != a_s[idx]
      not_exist_ch = a_dic[idx]
      break
    end
  end
end

##制約
##1 ≤ |S| ≤ 10^5 (|S|は文字列 Sの長さ)
##Sは英小文字のみからなる．

##Sに現れない英小文字であって，最も辞書順で小さいものを出力せよ．
##ただし， Sにすべての英小文字が現れる場合は，代わりに None を出力せよ．

if check
  puts "#{not_exist_ch}"
else
  puts 'None'
end

Measured memory_bytes: 8440
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long n = sc.nextLong();
    static long k = sc.nextLong();
    static long h[] = new long[(int)n];
    static long dp[] = new long[(int)n];
    public static void main(String[] args) {
        //初期化
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
            dp[i] = 2147483647;
        }
        dp[0] = 0;
        for (int i = 0; i < n; i++){
            for (int j = 1; j <= k; j++){
                if (i + j < n)
                    dp[i + j] = chmin(dp[i + j], dp[i] + Math.abs(h[i + j] - h[i]));
            }
        }
        System.out.println(dp[(int)n - 1]);
    }
    public static long chmin(long a, long b){
        if (a > b){
            return b;
        } else {
            return a;
        }
    }
}


Measured memory_bytes: 51220
N, L = map(int, input().split())
*A, = map(int, input().split())
for i, (a1, a2) in enumerate(zip(A, A[1:])):
    if a1 + a2 >= L:
        print('Possible')
        print(*([j+1 for j in range(i)]+[j+1 for j in range(N-2, i, -1)]+[i+1]), sep='\n')
        break
else:
    print('Impossible')

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

int main(){
    int a[5];
    int ans = 0;
    int min_num = 10;
    for (int i =0; i < 5; i++) {
        cin >> a[i];
        ans += a[i];
        int r = a[i] % 10;
        if (r != 0){
            ans += 10 - r;
            min_num = min(min_num, r);
        }
        
    }
    ans -= 10 - min_num;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e9
#define MOD 1000000007
 
bool cmp(pll a, pll b)
{
 
    return a.ff > b.ff;
}
 
int main()
{
 
    ll n, k;
    cin >> n >> k;
    ll tmp = 0;
    vector<pll> v;
    for(ll i = 0; i < n; i++)
    {
 
        ll x, y;
        cin >> x >> y;
        v.pb(mp(y, x));
    }
    sort(all(v), cmp);
    map< ll, ll > m;
    ll tp  =0;
    for(ll i = 0; i < k; i++)
    {
 
        tmp+=v[i].ff;
        if(m[v[i].ss] == 0) tp++;
        m[v[i].ss]++;
    }
    //cout << "ANS " << tmp << endl;
    ll ans = tmp + tp*tp;
    //cout << ans << endl;
    ll l = k-1, r = k;
    while(1)
    {
 
        if(l < 0 || r >= n) break;
        while(l >= 0 && m[v[l].ss]==1) l--;
        if(l < 0) break;
        m[v[l].ss]--;
        tmp-=v[l].ff;
 
        while(r < n && m[v[r].ss]>0) r++;
        if(r >= n) break;
        m[v[r].ss]++;
        tmp+=v[r].ff;
        tp++;
 
        ll xx = tmp+tp*tp;
 
        ans = max(ans, xx);
      l--;
      r++;
    }
    cout << ans;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = int.Parse(Console.ReadLine());
            string an;
            if(q < 1000) { an = "ABC"; }
            else { an = "ABD"; }
            Console.Write(an);
        }
    }
}

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

using namespace std;

int main(){

    string s;
    int lose = 0;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='x')
            lose++;
    }
    if(lose>=8)
        printf("NO\n");
    else
        printf("YES\n");

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    if(n<6){
        cout<<n<<endl;
        return 0;
    }

    int q=0,r=0;//9,6
    int ans = IINF;

    while((9*q)<=n){
        r = (n-(9*q)) / 6;
        
        int m = 0;
        
        if(q+r > 0)
            m = n % (9*q+6*r);

        if(m < 6 && (9*q)+(6*r)+m==n){
            int cnt9 = 0;
            int cnt6 = 0;

            int tmp = q;
            FORR(i,1,6){ //9^5 = 59049
                cnt9 += tmp / (int)pow(9,i);
                tmp %= (int)pow(9,i);
            }
            cnt9 += tmp;

            tmp = r;
            FORR(i,1,7){ //6^6 = 46656
                cnt6 += tmp / (int)pow(6,i);
                tmp %= (int)pow(6,i);
            }
            cnt6 += tmp;

            ans = min(ans, cnt9+cnt6+m);
        }
        q++;
    }
    cout << ans << endl;
    return 0;
}

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

const int mod = 10007;

int n;
int a[1010];

int dp[1010][8];

int dfs(int i=0, int key=1)
{
  if (i == n) return 1;

  int &ret = dp[i][key];
  if (ret != -1) return ret;

  ret = 0;
  for (int j = 1; j < 8; j++){
    if (!(j >> a[i] & 1)) continue;
    bool f = false;
    for (int k = 0; k < 3; k++){
      if ((j >> k) & (key >> k)) f = true;
    }
    if (f){
      ret += dfs(i + 1, j) % mod;
    }
  }

  return ret % mod;
}

int main()
{
  memset(dp, -1, sizeof(dp));

  cin >> n;
  for (int i = 0; i < n; i++){
    char c;
    cin >> c;
    if (c == 'J') a[i] = 0;
    if (c == 'O') a[i] = 1;
    if (c == 'I') a[i] = 2;
  }

  cout << dfs() << endl;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll A,B;
  cin>>A>>B;
  if(A<B) {
    cout<<0<<endl;
  }
else {
  cout<<10<<endl;
}
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n, k;
    int count = 0;
    cin >> n >> k;
    vector<int> height(n);
    for (int i = 0; i < n; i++) {
        cin >> height.at(i);
    }
    for (int i = 0; i < n; i++) {
        if (height.at(i) >= k) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD = 1000000009;
const int INF = INT_MAX / 3;

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main() {
	string s;
	cin >> s;
	const string x = "CODEFESTIVAL2016";
	int cnt = 0;
	REP(i, 16)
		cnt += (x[i] != s[i]);
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int T;
  cin >> T;
  while(T--) {
    int x,y,z;
    cin >> x >> y >> z;
    int ans=0;
    int d=min(x,min(y,z));
    ans+=d;
    x-=d;
    y-=d;
    d=min(x/2,y);
    ans+=d;
    x-=d*2;
    y-=d;
    ans+=x/3;
    pr(ans);
  }
}

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


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

using namespace std;

typedef pair<int, int> P;



ll count_AC(string s, ll n){
	ll cnt = 0;
	REP(i, s.size()-1){
		if (s.substr(i, 2) == "AC"){
			cnt += 1;
		}
	}
	return cnt;
}

int main(){
	ll n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	ll l, r;
	vector<ll> cnt(n,0);
	FOR(i, 1, n){
		cnt[i] = cnt[i-1] + count_AC(s.substr(i-1, 2), n); 
	}
	REP(i, q){
		cin >> l >> r;
		ll cnt_r = cnt[r-1];
		ll cnt_l;
		if (l == 1){
			cnt_l = 0;
		} else if (s[l-1] == 'C' && s[l-2] == 'A') {
			cnt_l = cnt[l-2] + 1;
		} else { cnt_l = cnt[l-2];}
		cout << cnt_r - cnt_l << endl;
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)

int main(){
fast ;
int t,n ;
t = 1 ;
while(t--){
	cin >> n ;
	int a[n],dp[n+1] ;
	for(int i=0;i<n;i++)
	cin >>  a[i] ;
	dp[0] = 0 ;
	dp[1] = abs(a[0]-a[1]) ;
	for(int i=2;i<n;i++)
	dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2])) ;
	cout << dp[n-1] << endl ;
}

}



Measured memory_bytes: 1024
/*
                IftekharMd.Shishir
                Dept. of Information and Communication Engineering
                University of Rajshahi
*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

#define ll  long long
#define ull  unsigned long long
#define ld  long double
#define f(i,n)  for(i=0;i<n;i++)
#define F(i,n)  for(i=n-1;i>=0;i--)
#define fa(i,a,b)  for(i=a;i<=b;i++)
#define Fa(i,a,b)  for(i=a;i>=b;i--)
#define printArray(i,a,n)  f(i,n)cout<<a[i]<<" "; cout<<endl;
#define printSet(a)  for(auto setData:a) cout<<setData<<" ";cout<<endl;
#define printMap(a)  for(auto mapData:a) cout<<mapData.first<<" "<<mapData.second<<endl;
#define printVector(a)  for(auto vectorData:a)cout<<vectorData<<" ";cout<<endl;
#define printLinkedList()  temp=head;while(temp){cout<<temp->data<<" ";temp=temp->post;} cout<<endl;

#define pb(x)  push_back(x)
#define all(a)  a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()

#define bs  binary_search
#define lb  lower_bound
#define ub  upper_bound
#define mp  make_pair
#define TxtIO  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define TxtTest freopen("C:/Users/Iftekhar/Documents/what/input.txt", "r", stdin);
#define FastIO  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
#define TestCase  ll t;cin>>t;while(t--)
#define points(x)  fixed<<setprecision(x)
#define scd(a,x,y)  a/__gcd(x,y);
#define nl  cout<<endl;
#define done  return 0

const ld PI= 3.14159265358979323846264338327950288;  //2*acos(0.0);
const long long MOD= 1000000007;
const long long MAX = 32000;

// stringstream demo(str);  demo >> x;
// stringstream demo;  demo << x;  name=demo.str();

using namespace __gnu_pbds;
using namespace std;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main()
{
        FastIO;
        //TxtTest;
        ll n,k,i,x,sum=0,alice=0,bob=0;
        cin>>n;
        vector<ll> a(n);
        f(i,n) cin>>a[i];
        sort(rall(a));
        f(i,n){
                if(i%2==0) alice+=a[i];
                else bob+=a[i];
        }
        sum=alice-bob;
        cout<< sum <<endl;
        done;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long x,y;
	while(cin>>x>>y){
		long long cnt=0;
		if(x==0&&y==0)break;
		if(x<y)swap(x,y);
		while(true){
			if(y==0)break;
			x=x%y;
			swap(x,y);
			cnt++;
		}
		cout<<x<<" "<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
long long a[200000];
int n,k;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	for(int i=0;i<n-k;++i){
		if(a[i]>=a[i+k]){
			cout<<"No"<<endl;
		}
		else{
			cout<<"Yes"<<endl;
		}
	}
}

Measured memory_bytes: 5072
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());
		long[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();
		long ans = 1;
		long lev = 1000000000000000000L;
		boolean zeroFlg = false;
		for (int i = 0; i < line.length; i++) {
			if (line[i] == 0) {
				zeroFlg = true;
			}
		}

		if (zeroFlg == false) {
			for (int i = 0; i < line.length; i++) {
				if (line[i] <= lev / ans) {
					ans *= line[i];
				}else {
					ans = -1;
					break;
				}
			}
			System.out.println(ans);
		}else {
			System.out.println(0);
		}

	}
}


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

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    string s,c; cin >> s;
    int cnt = 1;
    for (int i=0; i<s.size()-1; i++){
        if (s[i] != s[i+1] ) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512