akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		long[] kirei=new long[n];
		long[] oishi=new long[n];
		long[] ninki=new long[n];
		for(int i=0;i<n;i++){
			kirei[i]=sc.nextLong();
			oishi[i]=sc.nextLong();
			ninki[i]=sc.nextLong();
		}
		
		long[][]value = new long[8][n];
		long score=0;
		for(int i=0;i<8;i++){
			for(int j=0;j<n;j++){
				value[i][j]+=(i&4)==0?kirei[j]:-kirei[j];
				value[i][j]+=(i&2)==0?oishi[j]:-oishi[j];
				value[i][j]+=(i&1)==0?ninki[j]:-ninki[j];
			}
			Arrays.sort(value[i]);
			long sum=0;
			for(int j=0;j<m;j++){
				sum+=value[i][n-1-j];
			}
			score=Math.max(score,sum);
		}
		System.out.println(score);		
	}	
}


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

mt19937 rnd;
uniform_real_distribution<> dist01(0.0, 1.0);
double rnd01(){ return dist01(rnd);}

const double TIME_LIMIT = 1950;
double elapsed;
chrono::system_clock::time_point t_start;
void update_time(){
    auto t_now = chrono::system_clock::now();
    elapsed = chrono::duration_cast<chrono::milliseconds>(t_now - t_start).count();
}
bool timeover(){ return (elapsed > TIME_LIMIT);}

const int D = 365, T = 26;
int C[T], S[D][T];

int ans[D];
int opt = -1e9;

int calc_score(){
    int last[T];
    for(int i=0; i<T; i++) last[i] = -1;
    int res = 0;
    for(int i=0; i<D; i++){
        res += S[i][ans[i]];
        last[ans[i]] = i;
        for(int j=0; j<T; j++) res -= C[j] * (i-last[j]);
    }
    return res;
}

void try_update(){
    // pick random & update
    int d = rnd() % D;
    int bef = ans[d], aft = rnd() % T;
    ans[d] = aft;

    // calculate
    int score = calc_score();
    const int T = 100;
    double temp = T * (1 - elapsed/TIME_LIMIT);
    double prob = exp((score - opt) / temp);
    if(rnd01() < prob){
        opt = score;
    }else{
        // rollback
        ans[d] = bef;
    }
}

int main(){
    t_start = chrono::system_clock::now();
    // get input & initialize
    int _; cin >> _;
    for(int i=0; i<T; i++) cin >> C[i];
    for(int i=0; i<D; i++) for(int j=0; j<T; j++) cin >> S[i][j];

    for(int i=0; i<D; i++) ans[i] = i%T;
    opt = calc_score();

    // iterate
    int iter = 0;
    while(!timeover()){
        iter++;
        try_update();
        if(iter % 1000 == 0) update_time();
    }

    // output result
    for(int i=0; i<D; i++) cout << ans[i]+1 << endl;


    // output debug
    cerr << "score: " << opt << endl;
    cerr << "iter: " << iter << endl;
    update_time();
    cerr << "elapsed: " << elapsed << endl;
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >>k;
	VI a(n);
	rep(i,n) cin>>a[i];
	
	//if(k >n){cout <<"0\n";}
	vector<ll> sm(n+1);
	
	rep(i,n) sm[i+1] = sm[i] + a[i];
	
	map<ll, int> mp;
	rep(i, n){
		rep2(j,i+1,n+1){
			mp[sm[j] - sm[i]]++;
		}
	}
	vector<vector<int>> dt(sz(mp), vector<int>(63));
	vector<ll> vm;

	int c=0;
	for(auto x: mp){
		vm.push_back(x.first);
		rep(i, 62){
			if(x.first >>i &1) dt[c][i] += x.second;
		}
		c++;
	}

	vector<ll> e(63);
	VI ng(sz(dt));
	repr(i,62,0){
		int ki=0;
		rep(j, sz(dt)) if( !ng[j]) ki += dt[j][i];
		if(ki >= k){
			rep(j, sz(dt)) if( !dt[j][i] ) ng[j]=1;
		}
	}
	
	//for(auto x :ng) printf("%d, ",x); puts("");
	ll w = (1LL<<62) -1;
	repr(i, sz(ng)-1, 0){
		if(ng[i]==0) {
			w &= vm[i];
		}
	}
	ll ans =0;
	cout << w <<"\n";
	return 0;
}


Measured memory_bytes: 182516
n, s = map(int, input().split())
lis = list(map(int, input().split()))
lis.append(s)
lis.sort()


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


ans = lis[1] - lis[0]
for i in range(n):
    ans = gcd(ans, lis[i+1] - lis[i])

print(ans)


Measured memory_bytes: 14252
<?php
list($a, $b, $c) = ints();
if($c-$a-$b <= 0){echo "No";exit;}
echo ($c-$a-$b)*($c-$a-$b)-4*$a*$b>0 ? "Yes": "No";

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    string S;
    cin>>N>>S;

    //....#### or ........ or ########の形にしたい
    //.#.###.#について0~N-1までの境界をなぞって、境界の左を.に、右を#にする
    //必要なのは境界までの左の#の個数、右の.の個数
    //累積和で求める
    vector<int> ws(N,0),bs(N,0);
    int w=0,b=0;
    rep(i,N){
        if(S[i]=='.') w++;
        else b++;
        ws[i]=w;
        bs[i]=b;
    }
    int ans=N;
    rep(i,N){
        ans=min(ans,bs[i]+ws[N-1]-ws[i]);
    }
    //最初から... or ###の場合
    ans=min(ans,min(bs[N-1],ws[N-1]));
    cout<<ans<<endl;
}

Measured memory_bytes: 2180
#include<iostream>
#include<deque>
#include<algorithm>
#include<bitset>
#include<vector>
#include<cassert>
#define F first
#define S second

using namespace std;

class Pox
{
public:
  int visited;
  int cost;
  Pox(int visited = 0,int cost = 0):visited(visited),cost(cost){}
};
 
int main()
{ 
 
  short N;
  while(cin >> N,N)
    {
      int G[N+1][N+1];
      
      for(int i=1;i<=N;i++)
	{
	  for(int j=0;j<=N;j++)
	    {
	      cin >> G[i][j];
	    }
	}
         
      int mincost[(1<<17)-1];   
      for(int i=0;i< ((1<<17)-1) ;i++)
	mincost[i] = (1<<26);
      
      deque<Pox> deq;
      for(int i=1;i<=N;i++)
	{
	  deq.push_back(Pox((1<<i),G[i][0]));
	  mincost[(1<<i)] = G[i][0];
	}
       
 
      int ans = (1<<29);
      while(!deq.empty())
	{
	  Pox pox = deq.front(); deq.pop_front();
	  int visited = pox.visited;
	  int cost = pox.cost;	  
	  
	  if(ans <= cost)
	    continue;
	  
	  if(visited == (1<<(N+1))-2)
	    {
	      ans = min(ans,cost);
	      continue;
	    }
	  
	  for(int i=1;i<=N;i++)
	    {
	      if((visited>>i)&1)
		continue;
	      
	      for(int j=0;j<=N;j++)
		{
		  if(j == 0 || ( (visited>>j)&1 ))
		    {
		      int nvisited = visited|(1<<i);
		      if(mincost[nvisited] > cost + G[i][j])
			{
			  mincost[nvisited] = cost + G[i][j];
			  deq.push_front(Pox(nvisited,cost+G[i][j]));
			}
		    }
		}
	      
	      
	    }
	  
	  
	}
 
      cout << ans << endl;
 
    }
  return 0;
}

Measured memory_bytes: 1728
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    # N,M = [int(a) for a in input().split()]
    A = [int(a) for a in input().split()]
    res = [0] * N

    for i in range(1, N):
        joushi = A[i - 1]
        res[joushi - 1] += 1

    for a in res:
        print(a)

    # @lru_cache(None)
    # def f(i, j):
    #     if i < 0 or j < 0:
    #         return -INF
    #     if i == 0:
    #         return -INF
    #     if abs(j - i // 2 - 1) >= 2:
    #         return -INF
    #     if j == 0:
    #         return 0
    #     if j == 1:
    #         return max(A[:i])
    #     return max(A[i - 1] + f(i - 2, j - 1), f(i - 1, j))
    #
    # print(f(N, math.floor(N / 2)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 34012
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    string s; cin>>s;
    int n = s.size();
    int i, j;
    i = 0; j = n-1;
    int ans = 0;
    while(j - i > 0){
        if(s[i] != s[j]) ans++;
        i++; j--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 888
/** @Date    : 2017-05-13 20:40:15
  * @FileName: tmp.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoundEarlf@gmail.com)
  * @Link    : https://github.com/Lweleth
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;


int main()
{
	int n, m;
	while(cin >> n >> m)
	{
		int a, b;
		int s[50] = {0};
		for(int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			s[a]++, s[b]++;
		}
		for(int i = 0; i < n; i++)
		{
			printf("%d\n", s[i + 1]);
		}
	}
    return 0;
}

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

void fnInput(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

int fnRcsSch(int nTrgSu, int nTrgKin)
{
  vector<int> vnMoney{10000, 5000, 1000};

  int nCalKin;
  int i, j;
  for (i = 0; i <= nTrgSu; i++)
  {
    for (j = 0; j <= (nTrgSu - i); j++)
    {
      nCalKin = nTrgKin;

      nCalKin -= vnMoney[0] * i;
      nCalKin -= vnMoney[1] * j;
      nCalKin -= vnMoney[2] * (nTrgSu - i - j);
      if (!nCalKin)
        break;
    }
    if (!nCalKin)
      break;
  }
  if (!nCalKin)
    cout << i << " " << j << " " << (nTrgSu - i - j) << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

/*
int fnExhSch(int nTrgSu, int nTrgKin)
{
  vector<int> vnNumMoney(3);

  fnRcsSch(0, nTrgSu, nTrgKin, vnNumMoney);
  cout << vnNumMoney[0] << " " << vnNumMoney[1] << " " << vnNumMoney[2] << endl;
}
*/

int main()
{
  int nTrgSu, nTrgKin;
  
  fnInput(nTrgSu, nTrgKin);
  fnRcsSch(nTrgSu, nTrgKin);

  return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, ans = 0,a,x,y;
    ll s[4]={0};
    cin>>n;
    string t;
    while(n--){
        cin>>t;
        if(t=="AC"){
            s[0]++;
        }
        if(t=="WA"){
            s[1]++;
        }
        if(t=="TLE"){
            s[2]++;
        }
        if(t=="RE"){
            s[3]++;
        }
    }
    cout<<"AC "<<"x "<<s[0]<<endl;
    cout<<"WA "<<"x "<<s[1]<<endl;
    cout<<"TLE "<<"x "<<s[2]<<endl;
    cout<<"RE "<<"x "<<s[3]<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-3;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll N,K;
ll A[200010];

bool F(ll X){
   ll cnt = 0;
   rep(i,N){
      cnt += (A[i] + X - 1) / X - 1;
      //cout << ceil(A[i] / X) << ' ';
   }
   //cout << endl;
   return cnt <= K;
}

int main(){
   cin >> N >> K;
   ll M = 0;
   rep(i,N){
      cin >> A[i];
      M = max(M,A[i]);
   }
   if(K == 0){
      cout << M << endl;
      return 0;
   }
   ll l = 0,r = 1000000010;
   while(r-l>1){
      ll mid = (l+r) / 2;
      if(F(mid)) r = mid;
      else l = mid;
   }
   cout << r << endl;
}

Measured memory_bytes: 5124
numeroA, numeroB = [],[]
contadorCoord = 0
contador=1
numerosSTRa = input().split(" ")
for p in numerosSTRa:
    numeroA.append(int(p))


numerosSRTB = input().split(" ")
for j in numerosSRTB:
    numeroB.append(int(j))

for i in numeroB:
    contadorCoord+=i
    if contadorCoord <= numeroA[1]:
        contador+=1
print(contador)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
	//freopen("inp.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
  cin >> n;
  cout << 1ll * n * n;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

string s;

void solve(){
    cin >> s;
    int n = s.size();
    int sum = 0;
    rep(i,0,n)
        sum += s[i]-'0';
    cout << (sum%9 ? "No\n" : "Yes\n");
}

signed main(){
    Rushia_mywife
    solve();
}

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

int main() {
  int n,c;
  string s;
  cin >> n;
  cin >> s;
  c = 0;
  for (int i=0; i< n-2;i++){
    if (s[i] == 'A' && s[i+1] == 'B'){
      if (s[i+2] == 'C') c++;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
const int N=200005;
const int mod=1e9+7;
int a[N];
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    while(cin>>n){
        for(int i=1;i<=n;++i){
            cin>>a[i];
        }
        if(n&1){
            cout<<a[n];
            for(int i=n-2;i>=1;i-=2)
                cout<<" "<<a[i];
            for(int i=2;i<=n-1;i+=2)
                cout<<" "<<a[i];
            cout<<endl;
        }else{
            cout<<a[n];
            for(int i=n-2;i>=2;i-=2)
                cout<<" "<<a[i];
            for(int i=1;i<=n-1;i+=2)
                cout<<" "<<a[i];
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    vector<int> Y = X;
    sort(Y.begin(), Y.end());
    for (int i = 0; i < N; i++) {
        if (X[i] <= Y[N/2-1]) {
            cout << Y[N/2] << endl;
        } else {
            cout << Y[N/2-1] << endl;
        }
    }
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	
	vector<int> prime;
	bool prime_b[10001] = { false };
	FOR(i,2, 10001){
		if (!prime_b[i]){
			prime.push_back(i);
			for (int j = i * 2; j < 10001; j += i){
				prime_b[j] = true;
			}
		}
	}
	int n;
	while (cin >> n, n){
		vector<int> vi(1,1);
		FOR (i,2,10001){
			if (i>sqrt(n))break;
			if (n%i == 0){
				vi.push_back(i);
				if (n != i*i)
					vi.push_back(n / i);
			}
		}
		int sum = 0;
		REP(i, vi.size())
			sum += vi[i];
		if (n != 1){
			if (sum < n)
				cout << "deficient number" << endl;
			if (sum == n)
				cout << "perfect number" << endl;
			if (sum>n)
				cout << "abundant number" << endl;
		}else
			cout << "deficient number" << endl;
	}
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(std::string S, std::string T){
    int answer = INT_MAX;
    rep(i,0,S.size()-T.size()+1) {
        int count = 0;
        rep(j,0,T.size()) {
            if (S[i+j] != T[j]) count++;
        }
        answer = min(answer, count);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3596
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)

Gh=[[0]*W for i in range(H)]
for i in range(H):
    tmp=0
    s=0
    j=0
    while(j!=W):
        if S[i][j]=="#":
            Gh[i][j]==0
            for k in range(s,j):
                Gh[i][k]=tmp
            s=j+1
            j+=1
            tmp=0
        else:
            tmp+=1
            j+=1
    if s!=j:
        for k in range(s,j):
            Gh[i][k]=tmp
Gv=[[0]*W for i in range(H)]
for j in range(W):
    tmp=0
    s=0
    i=0
    while(i!=H):
        if S[i][j]=="#":
            Gv[i][j]==0
            for k in range(s,i):
                Gv[k][j]=tmp
            s=i+1
            i+=1
            tmp=0
        else:
            tmp+=1
            i+=1
    if s!=i:
        for k in range(s,i):
            Gv[k][j]=tmp
ans=0
for i in range(H):
    for j in range(W):
        ans=max(ans,Gh[i][j]+Gv[i][j]-1)
print(ans)


Measured memory_bytes: 126680
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7
int main()
{
	NeedForSpeed();
	int n; cin>>n; 
	bool pos = false;
	while(n)
	{
		int x = n%10;
		if(x==7) pos = true;
		n/=10;
	}		
	if(pos) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

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

  vector<double> a(N);

  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  double ans = 0;
  for(int i = 0; i < N-1; i++) {
    a.at(i+1) = a.at(i)*a.at(i+1)/(a.at(i)+a.at(i+1));
  }
  cout << fixed;
  cout << setprecision(8) << a.at(N-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

struct edge {
  int to;
  int dist;
};

vector<edge> G[100005];
bool canDo = true;
long pos[100005];
const long INFF = INF*INF;

void dfs(int idx, int p) {
  if(pos[idx] != INFF) {
    if (p != pos[idx]) {
      canDo = false;
    }
    return;
  }

  pos[idx] = p;

  for(auto i : G[idx]) {
    dfs(i.to, p+i.dist);
  }
}

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

  int n, m;
  cin >> n >> m;

  rep(i, m) {
    int l, r, d;
    cin >> l >> r >> d;

    G[l].push_back({r, d});
    G[r].push_back({l, -d});
  }

  rep(i, n+1) {
    pos[i] = INFF;
  }
  rep(i, n+1) {
    if (pos[i] == INFF) {
      dfs(i, 0);
    }
  }



  cout << (canDo?"Yes":"No") << endl;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, cnt = 0;
  cin >> n;
  vector<int> S(n);
  for (size_t i = 0; i < n; i++) {
    cin >> S.at(i);
  }

  cin >> q;
  vector<int> T(q);
  for (size_t i = 0; i < q; i++) {
    cin >> T.at(i);
  }

  for (auto t : T) {
    for (auto s : S) {
      if (t == s) {
        cnt++;
        break;
      }
    }
  }

  cout << cnt << endl;
}



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

int main(){
    bool cards[4][14];
    int n,rank;
    char suit;
    
    for ( int s = 0; s < 4; s++ )
        for(int r = 1; r <= 13; r++ )
            cards[s][r] = 0;
            
    cin >> n;
    for ( int i = 0; i < n; i++ ){
        cin >> suit >> rank;
        if ( suit == 'S' ) cards[0][rank] = 1;
        if ( suit == 'H' ) cards[1][rank] = 1;
        if ( suit == 'C' ) cards[2][rank] = 1;
        if ( suit == 'D' ) cards[3][rank] = 1;
    }
    
    for ( int s = 0; s < 4; s++ ){
        for ( int r = 1; r <= 13;  r++ ){
            if ( cards[s][r] ) continue;
            if ( s == 0) suit = 'S';
            if ( s == 1) suit = 'H';
            if ( s == 2) suit = 'C';
            if ( s == 3) suit = 'D';
            cout << suit << " " << r << endl;
        }
    }
    
    return 0;
}


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

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

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

    sort(y, y+n);
    for(int i = 0; i < n; i++){
        if(x[i] < y[n/2]){
            cout << y[n/2] << endl;
        }
        else {
            cout << y[n/2-1] << endl; 
        }
    }


}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <string.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int table[8][8];
void print()
{
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            cout << (table[i][j] == 2 ? 'Q' : '.');
        }
        cout << endl;
    }
    exit(0);
}
void dfs(int n)
{
    if(n == 8) print();
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            if(table[i][j]) continue; //置けない
            int tmp[8][8];
            for(int p = 0; p < 8; p++) for(int q = 0; q < 8; q++) tmp[p][q] = table[p][q];
            table[i][j] = 2;
            for(int k = 0; k < 8; k++)
            {
                int ny = i + dy[k];
                int nx = j + dx[k];
                while(ny >= 0 && nx >= 0 && ny < 8 && nx < 8)
                {
                    table[ny][nx] = 1;
                    ny += dy[k];
                    nx += dx[k];
                }
            }
            dfs(n + 1);
            for(int p = 0; p < 8; p++) for(int q = 0; q < 8; q++) table[p][q] = tmp[p][q];
        }
    }           
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) 
    {
        int r, c;
        cin >> r >> c;
        table[r][c] = 2;
        for(int j = 0; j < 8; j++)
        {
            int ny = r + dy[j];
            int nx = c + dx[j];
            while(ny >= 0 && nx >= 0 && ny < 8 && nx < 8)
            {
                table[ny][nx] = 1;
                ny += dy[j];
                nx += dx[j];
            }
        }
    }
    dfs(n);
    return 0;
}


Measured memory_bytes: 3168
x = input()
list = x.split()
[a, b, c] = list
a = int(a)
b = int(b)
c = int(c)

y = 0

if a == b and c % a == 0:
    y = y + 1
else:
    for i in range(a, b + 1):
        if c % i == 0:
            y = y + 1

print(y)


Measured memory_bytes: 5596
n, m = map(int, raw_input().split())
l = []
ac = set()
wa = {}
for i in range(m):
	a, b = raw_input().split()
	a = int(a)
	
	if a not in ac:
		if b == 'WA':
			if a in wa:
				wa[a] += 1
			else:
				wa[a] = 1
		else:
			ac.add(a)
ans = 0
for i in list(ac):
	if i in wa:
		ans += wa[i]
print len(ac), ans

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

int main() {

    string s;
    int n;
    cin >> s >> n;

    int on = 0;
    string front = "";
    string back = "";
    rep(i, n){
        int t;
        cin >> t;
        if(t == 1){
            on ^= 1;
        }
        else{
            int f; 
            string c;
            cin >> f >> c;
            if(on ^ (f == 1)){
                front += c;
            }
            else{
                back += c;
            }
        }
    }
    reverse(all(front));

    string ans = front + s + back;
    if(on){
        reverse(all(ans));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1348
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val a,b = sc.nextInt
    if(a >= 13){
        println(b)
    }else if(a >= 6){
        println(b/2)
    }else{
        println(0)
    }
  }
}

Measured memory_bytes: 25768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
string s, t, u;
int main() {
  cin >> n >> s;
  lli ans = 0;
  for (lli i=0; i<=s.size(); ++i) {
    t = s.substr(0, i);
    u = s.substr(i);
    bool flg_t[256], flg_u[256];
    fill(flg_t, flg_t+256, false);
    fill(flg_u, flg_u+256, false);
    for (char c : t) flg_t[c] = true;
    for (char c : u) if (flg_t[c]) flg_u[c] = true;
    ans = max(ans, (lli)count(flg_u, flg_u+256, true));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        for(int i = 0; i < n; i++) scan.nextInt();
        n -= k;
        System.out.println((n + k - 2) / (k - 1) + 1);
    }

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


Measured memory_bytes: 59024
#include <stdio.h>
int gcd(int , int);

int main(){
  int a, b, c, K;
  long sum = 0;
  int ans_1;
  scanf("%d", &K);

  for(a=1; a<=K; a++){
    for(b=1; b<=K; b++){
      ans_1=gcd(a, b);

      for(c=1; c<=K; c++){
        sum += gcd(ans_1, c);
      }
    }
  }
  printf("%ld", sum);
  return 0;
}

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


Measured memory_bytes: 1728
// Problem : E - Sequence Sum
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
    T f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, x, m;
int ans, cnt, sum[N];
int vis[N];

signed main()
{
    //File("");
    n = gi <int> (), x = gi <int> (), m = gi <int> ();
    if (n <= 1000000)
    {
    	int kk = x;
    	for (int i = 1; i <= n; i+=1)
    		ans += kk % m, kk = kk * kk % m;
    	printf("%lld\n", ans);
    	return 0;
    }
    vis[x] = 1;
    int now = x * x % m;
    sum[1] = x, cnt = 1;
    while (!vis[now]) 
    	++cnt, sum[cnt] = sum[cnt - 1] + now, vis[now] = cnt, now = now * now % m;
    int len = cnt + 1 - vis[now], qd = vis[now];
    if (n <= qd)
    {
    	int kk = x;
    	for (int i = 1; i <= n; i+=1)
    		ans += kk % m, kk = kk * kk % m;
    	printf("%lld\n", ans);
    	return 0;
    }
    int tmp = sum[cnt] - sum[qd - 1];
    ans = sum[qd - 1];
    n -= (qd - 1);
    int cs = n / len, ys = n % len;
    //cout << cs << ' ' << ys << endl;
    cout << ans + tmp * cs + sum[qd + ys - 1] - sum[qd - 1] << endl;
    //cout << len << ' ' << qd << endl;
    return 0;
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i,ans=0;
  for(i=1;i<=n;i++){
    if(n>=i*i){
      ans=i*i;
    }else{
      break;
    }
  }
  cout << ans;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int N = int.Parse(line[0]);
            int Y = int.Parse(line[1]);
            bool ans = false;
            for (int i=0; i<=N; i++)
            {
                for (int j = 0; i+j<=N; j++)
                {
                    if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y)
                    {
                        Console.WriteLine(i + " " + j + " " + (N - i - j));
                        ans = true;
                        break;
                    }
                }
                if (ans == true)
                {
                    break;
                }
            }
            if (ans == false)
            {
                Console.WriteLine("-1 -1 -1");
            }

        }
    }
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    int X[N];
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    int ans = pow(10, 10);
    int power = 0;
    for (int p = 0; p <= 100; p++) {
        power = 0;
        for (int x : X) {
            power += pow((x - p), 2);
        }
        ans = min(ans, power);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, b, e) for (auto i = b; i < e; ++i)

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

    vector<pair<int, int>> a(n);
    REP(i, 0, n) {
        cin >> a[i].first >> a[i].second;
        a[i].second--;
    }

    int64_t ans = 0;

    int pos = 0, t = 0, m = 0;

    vector<int> b;

    REP(i, 0, n) {
        t += abs(pos - a[i].second);
        if (a[i].first < t || m == d) {
            ans = -1;
            break;
        }

        t = a[i].first;
        pos = a[i].second;
        m++;

        b.push_back(t);

        if (i == n - 1) {
            REP(j, 0, b.size()) { ans += t + pos - b[j]; }
        } else {
            if (t + pos + a[i + 1].second <= a[i + 1].first) {
                REP(j, 0, b.size()) { ans += t + pos - b[j]; }

                b.clear();
                m = 0;
                t += pos;
                pos = 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4232
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

//! i番目までに存在する?の数
int Q[100005];
int A[100005];
int C[100005];

long long int modPow(int a, long long int p)
{
	//! a^pをbitからp =2^0+2^1+2^2...=q_0+q_2+...と分解し、
	//! a^(q_0+q_1+...)=(a^q_0 )*(a^q_1)*(a^q_3)...からO(logN)で計算する
	long long int n = 1, mul = a;
	for (; p > 0; p >>= 1, mul = (mul* mul) % MOD)
	{
		if ((p & 1) == 1)n = (n*mul) % MOD;
	}
	return n;
}

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

	REP(i, S.length())
	{
		switch (S[i])
		{
		case 'A':
			A[i]++;
			break;
		case 'C':
			C[i]++;
			break;
		case '?':
			Q[i]++;
			break;
		default:
			break;
		}
	}
	FOR(i, S.length(), 1)
	{
		A[i] += A[i - 1];
		C[i] += C[i - 1];
		Q[i] += Q[i - 1];
	}

	ll sum = 0;
	FOR(i, S.length() - 1, 1)
	{
		if (S[i] != 'B'&&S[i] != '?')continue;
		//! iの左側のaの数
		ll a = A[i - 1];
		//! iの右側のcの数
		ll c = C[S.length() - 1] - C[i];
		//! iの左側のQの数
		ll lq = Q[i - 1];
		//! iの右側のQの数
		ll rq = Q[S.length() - 1] - Q[i];

		ll left = (modPow(3, lq - 1)*lq + modPow(3, lq)*a) % MOD;
		ll right = (modPow(3, rq - 1)*rq + modPow(3, rq)*c) % MOD;
		sum += (left*right) % MOD;

		//sum += (((a*lq) % MOD)*((c*rq) % MOD)) % MOD;
		sum %= MOD;
	}
	cout << sum << endl;
	return 0;
}

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

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

    int ans = 0;
    for (int i = 0; i < 2; i++){
        if (a > b){
          ans += a;
          a -= 1;
       }
      else{
          ans += b;
          b -= 1;
      }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll n,m;
    cin >> n>>m;
    vector<ll> h(n,0);
    vector<bool> ans_v(n,true);
    REP(i,n) cin >>h[i];
    REP(i,m){
        ll a,b;
        cin >> a>>b;
        a--;
        b--;
        if(h[a]>h[b]){
            ans_v[b]=false;
        }else if(h[b]>h[a]){
            ans_v[a]=false;
        }else{
            ans_v[a]=false;
            ans_v[b]=false;
        }
    } 
    ll ans=0;
    REP(i,n){
        if(ans_v[i]==true) ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4048
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ws(n); cin >> ws;
    int mini = M;
    int l = 0, r = accumulate(ws.begin(), ws.end(), 0ll);
    for(int i = 0; i < n; i++){
        mini = min(mini, abs(l - r));
        l += ws[i];
        r -= ws[i];
    }
    cout << mini << '\n';
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<tuple>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;
//def lib
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define dRep(i,n0,n) for(int i=((int)n)-1;i>n0-1;i--)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define print(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007
//def end
typedef long long ll;
// lib
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int mfact(int x){int i=1;rep(j,x){i*=(j+1);} return i%mod;}
int modulo(int x){return x%mod;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
long long mfact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i%mod;}
long long modulo(long long x){return x%mod;}
int gcd(int x, int y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
ll gcd(ll x, ll y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
void say(bool x){if(x){cout<<"Yes"<<endl;}else {cout<<"No"<<endl;}return;}
//lib end
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1};
int main()
{
    int n;
    cin >> n;
    int a[n], b[n], flag=0, flag2=n-1;
    rep(i, n){
        cin >> a[i];
    }
    while(flag2 > -1){
        b[flag] = a[flag2];
        flag2 -= 2;
        flag++;
    }
    flag2 = n%2;
    while(flag2 < n){
        b[flag] = a[flag2];
        flag2 += 2;
        flag++;
    }
    rep(i, n-1){
        cout<<b[i]<<" ";
    }
    cout<<b[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 3712
n = (input())
if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9' :
    print('hon')
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print('pon')
elif n[-1] == '3':
    print('bon')
    

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

int main(){
    ll N,M,K; cin>>N>>M>>K;
    vector<ll> A(N),B(M);
    ll total=0;
    for (ll i = 0; i < N; i++){
        cin>>A[i];
    }
    for (ll i = 0; i < M; i++){
        cin>>B[i];
        total+=B[i];
    }
    ll ans=0;
    ll j=M;
    for (ll i = 0; i < N+1; i++){
       while(j>0&&total>K){
           j--;
           total-=B[j];
       }
       if(total>K) break;
       ans=max(ans,i+j);
       if(i==N) break;
       total+=A[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 6444
package main

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

type pair struct {
	status rune
	count  int
}

func solve() {
	n, k := getInt(), getInt()
	s := getRunes()

	chunks := make([]pair, 0)
	for i, cnt := 0, 0; i < n; i++ {
		cnt++
		if i == n-1 || s[i] != s[i+1] {
			chunks = append(chunks, pair{s[i], cnt})
			cnt = 0
		}
	}

	l, r := 0, 0
	ans := 0
	for k > 0 && r < len(chunks) {
		if chunks[r].status == '0' {
			k--
		}
		ans += chunks[r].count
		r++
		if k == 0 {
			ans += chunks[r].count
			r++
		}
	}

	now := ans
	for r < len(chunks) {
		if chunks[l].status == '0' {
			now -= chunks[l].count
			l++
		} else {
			now -= (chunks[l].count + chunks[l+1].count)
			l += 2
		}

		if r == len(chunks)-1 {
			now += chunks[r].count
			r++
		} else {
			now += chunks[r].count + chunks[r+1].count
			r += 2
		}

		ans = max(ans, now)
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

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

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

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

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

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


Measured memory_bytes: 6656
n, m = map(int, input().split())
ac = set()
npena = dict()
for i in range(m):
    np, res = input().split()
    if res == 'AC':
        ac.add(np)
    elif np not in ac:
        npena[np] = npena.get(np, 0) + 1
res2 = 0
for np in ac:
    res2 += npena.get(np,0)
print(len(ac), res2)

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




int main() {
	int A,B;
	cin >>A>>B;
	
	cout << max(max(A+B,A-B),A*B)<< endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int A, B, C;

void solve() { cout << min((B / A), C); }

int main(void)
{
  cin >> A >> B >> C;
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    /**
     * Product
     * @param 1 ≤ a,b ≤ 10000
     */
    public static void main(String...args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a * b % 2 == 0) {
                System.out.println("Even");
            } else {
                System.out.println("Odd");
            }
        }
    }
}

Measured memory_bytes: 21716