akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
int main() {
  int n;
  cin >> n;
  int block[n] = {0};
  for (int i = 0; i < n; i++) {
    cin >> block[i];
  }

  int breakCnt = 0;
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    if (block[i] == cnt) {
      cnt++;
    } else {
      breakCnt++;
    }
  }

  if (breakCnt > 0 && cnt == 1) {
    cout << -1 << endl;
  } else {
    cout << breakCnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (M1, D1) = readInputLine().split(" ").map { it.toInt() }
    val (M2, D2) = readInputLine().split(" ").map { it.toInt() }
    
    println(M2 - M1)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37912
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int nx[4] = {1,0,-1,0};
int ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    PRINT(max({a+b,a-b,a*b}));
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <iomanip>
int main()
{
    int a;
    int b;
    std::cin >> a;
    std::cin >> b;

    std::cout << a/b << "\n";
    std::cout << a%b << "\n";
    std::cout << std::fixed << std::setprecision(5) << (double)a/b << "\n";

    return 0;
}


Measured memory_bytes: 3284
S = list(str(input()))
 
if(S[0]==S[1] and S[2]==S[3] and S[0]!=S[2] or S[0]==S[2] and S[1]==S[3] and S[0]!=S[1] or S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
# -*- coding:utf-8 -*-

def gcd(a,b):
    big,small=max(a,b),min(a,b)
    while big%small!=0:
        big,small=small,big%small
    return small

def lcm(a,b):
    return int(a*b/gcd(a,b))
 
def main():
    while True:
        try:
            IN=input()
            val=IN.split()
            g=gcd(int(val[0]),int(val[1]))
            l=lcm(int(val[0]),int(val[1]))

            print(g,l)
        except:
            break
if __name__ == '__main__':
    main()

Measured memory_bytes: 7660
# -*- coding: utf-8 -*-

# See:
# http://drken1215.hatenablog.com/entry/2018/06/08/210000
max_value = 500050
mod = 10 ** 9 + 7

fac = [0 for _ in range(max_value)]
finv = [0 for _ in range(max_value)]
inv = [0 for _ in range(max_value)]


def com_init():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1

    for i in range(2, max_value):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod


def com(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    n, k = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    com_init()
    ans = 0

    # See:
    # https://www.youtube.com/watch?v=1oLDDdWRu6Y&feature=youtu.be
    for index, ai in enumerate(a):
        now = com(index, k - 1)
        ans += now * ai

    for index, ai in enumerate(a[::-1]):
        now = com(index, k - 1)
        ans -= now * ai

    print(ans % (10 ** 9 + 7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 67956
function Main(input) {
	var input = input.trim().split(" ");
	var a = Number(input[0]);
	var b = Number(input[1]);
	var arg = b - a;
	var sum = 0;
	for(var i = 0;i<=arg;i++){
		sum += i;
	}
	console.log(sum - b);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
from math import floor, ceil
H, W = map(int, input().split())

ans = float('inf')
for h in range(1, H+1):
    A = h * W
    B = floor((H-h) / 2) * W
    C = ceil((H-h) / 2) * W
    B2 = (H-h) * floor(W / 2)
    C2 = (H-h) * ceil(W / 2)
    ans = min(ans, max([A, B, C]) - min([A, B, C]))
    ans = min(ans, max([A, B2, C2]) - min([A, B2, C2]))

for w in range(1, W+1):
    A = H * w
    B = floor((W-w) / 2) * H
    C = ceil((W-w) / 2) * H
    B2 = (W-w) * floor(H / 2)
    C2 = (W-w) * ceil(H / 2)
    ans = min(ans, max([A, B, C]) - min([A, B, C]))
    ans = min(ans, max([A, B2, C2]) - min([A, B2, C2]))

print(ans)

Measured memory_bytes: 44632
#include<stdio.h>
#include<map>

using namespace std;

map<int, int> mp;

int n, cnt;

int main(void) {
	map<int, int> ::iterator i;
    int t;
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%d", &t);
        mp[t]++;
    }

    for (i = mp.begin(); i != mp.end(); i++) {
    	int a = (*i).first;
    	int b = (*i).second;
        if(b>=a) cnt += (b-a);
        else cnt += b;
	}
    printf("%d", cnt);

    return 0;
}

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

public class Hello
{
    public static void Main()
    {
        hoge();
        //System.Console.ReadLine();
    }

    public static void hoge()
    {
        System.Console.ReadLine();
        var a = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var count = 0;
        for(int i = 0; i < a.Length; i++)
        {
            if((i + 1) % 2 == 1 && a[i] %2 == 1)
            {
                count++;
            }
        }

        System.Console.WriteLine(count);

    }

}

Measured memory_bytes: 28008
package main

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

var height, width int
var grid [][]rune //0-indexed

var dp [][]int // dp[i][j] = i,jから出発してh,wにたどり着くまでの経路数

var mh = []int{1, 0}
var mw = []int{0, 1}

var mod = newModInt(1e9 + 7)

func routes(h, w int) int {
	if dp[h][w] != -1 {
		return dp[h][w]
	}

	r := 0
	for i := 0; i < 2; i++ {
		ph, pw := h+mh[i], w+mw[i]
		if ph >= height || pw >= width {
			continue
		} else if grid[ph][pw] == '#' {
			continue
		}
		r = mod.add(r, routes(ph, pw))
	}

	dp[h][w] = r
	return r
}

func main() {
	height, width = readI(), readI()
	grid = make([][]rune, height)
	for i := 0; i < height; i++ {
		grid[i] = readR()
	}

	// dp init
	dp = make([][]int, height)
	for i := 0; i < height; i++ {
		dp[i] = make([]int, width)
		for j := 0; j < width; j++ {
			dp[i][j] = -1
		}
	}
	dp[height-1][width-1] = 1

	fmt.Println(routes(0, 0))

}

// Modular arithmetic utils
type modInt struct {
	modNum int
}

func newModInt(mod int) *modInt {
	m := modInt{modNum: mod}
	return &m
}

func (m modInt) mod(a int) int {
	a %= m.modNum
	if a < 0 {
		return a + m.modNum
	}
	return a
}

func (m modInt) pow(base, exponent int) int {
	res := 1
	for exponent > 0 {
		if exponent&1 == 1 {
			res = m.mod(res * base)
		}
		base = m.mod(base * base)
		exponent >>= 1
	}
	return res
}

func (m modInt) inv(a int) int {
	return m.pow(a, m.modNum-2)
}

// a + b
func (m modInt) add(a, b int) int {
	return m.mod(a + b)
}

func (m modInt) sub(a, b int) int {
	return m.mod(a - b)
}

func (m modInt) mul(a, b int) int {
	return m.mod(a * b)
}

func (m modInt) div(a, b int) int {
	return m.mul(a, m.inv(b))
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

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


Measured memory_bytes: 15116
/**
     **author : _KMS_
     **created : 07-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6,MOD=2e9;
typedef long long ll;
string p,s;
int tot;
int k;
map<string,int>mp;
ll cnt;
int main() {
      
   ios::sync_with_stdio(false);
   cin.tie(0);
  ll a,b,x;
  cin>>a>>b>>x;
  if(a>b)swap(a,b);
  if(a==0){cnt=1;a++;}
  cnt+=(b/x)-((a-1)/x);
  cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
    int X, i;
    int flag;//割り切れたら1に立てる。

    scanf("%d",&X);

    //Xから1つずつ数を大きくして判定
    //ルートの数まで割れるかを試す
    do{
        flag=0;
        for(i=2; i<=sqrt(X); i++)//素数かどうか判定するループ文
        {
            if(X%i == 0){
                flag++;
            }
        }
        if(flag > 0) X++;
    }while(flag != 0);

    printf("%d\n",X);


    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if((x - a) * (x - a) < (x - b) * (x - b))
    cout << "A" << endl;
    else 
    cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define wh(t) while(t--)
#define fi(n) for(long long i = 0; i < n; i++)
#define fj(n) for(long long j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){
	ll a = 1;
	while(n > 0){
		if(n & 1) a = (a * x)%M;
		x = (x * x) % M;
		n = n>>1;
	}
	return a;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		ll n;
		cin >> n;
		vll a(n);
		fi(n)
			cin >> a[i];
		vll L(n);
		vll R(n);
		fi(n){
			L[i] = i+a[i];
			R[i] = i-a[i];
		}
		sort(R.begin(), R.end());
		ll count = 0;
		fi(n){
			ll j = lower_bound(R.begin(), R.end(), L[i]) - R.begin();
			ll jj = upper_bound(R.begin(), R.end(), L[i]) - R.begin();
			if(j != n && R[j] == L[i]){
				count = count + jj-j;
			}
		}
		cout << count;
	}
	return 0;
}

Measured memory_bytes: 7948
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int n; cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	
	int m = 0;
	int ans = 1;
	rep(i, n-1){
		if(m == 0){
			if(a[i] < a[i+1]){
				m = 1;
			}else if(a[i] > a[i+1]){
				m = 2;
			}
		}else if(m == 1){
			if(a[i] > a[i+1]){
				m = 0;
				ans++;
			}
		}else if(m == 2){
			if(a[i] < a[i+1]){
				m = 0;
				ans++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int ans = 0;
    if(K == 0) {cout << N * N << endl; return 0;}
    REP(i, 1, N) {
        int cnt1 = N/i;
        int cnt2 = max(0LL, i - K);
        ans += cnt1 * cnt2;
        int num = N % i;
        ans += max(0LL, num - K + 1);
        //cout << i << " " << num << " " << ans << endl;
    }
    cout  << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int main (){
	long int NNN;
	cin >> NNN;
	if(NNN==0){
		cout << "0" << endl;
		return 0;
	}
	string ans = "";
	while(NNN!=0){
		if(NNN%2==0){
			NNN = -1 * NNN/2;
			ans = "0" + ans;
		}
		else{
			NNN = -1 * (NNN - 1) / 2;
			ans = "1" + ans;
		}
	}	
	cout << ans << endl;
	return 0;
}


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

string S;
int N;

int main(){
    cin>>N;
    cin>>S;
    int ans=0;
    for(int i=0;i<N-2;i++){
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    cout<<(n-2)*180<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a==1){
        ans+=300000;
        if(b==1){
            ans+=400000;
        }
    }else if(a==2){
        ans+=200000;
    }else if(a==3){
        ans+=100000;
    }
    if(b==1){
        ans+=300000;
    }else if(b==2){
        ans+=200000;
    }else if(b==3){
        ans+=100000;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>


int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A')
			cout << "T";
		if (s[i] == 'T')
			cout << "A";
		if (s[i] == 'G')
			cout << "C";
		if (s[i] == 'C')
			cout << "G";
	}
	cout << endl;

	return 0;
}

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

typedef long long int64;
int64 n, a, b;

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

	int64 l = n / (a + b);
	int64 r = n % (a + b);

	int64 ans = l * a + min(r, a);

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

main(){
  long double a,b,c,d;
  while(cin>>a>>b>>c>>d){
    if(abs(a+1)<EPS && abs(b+1)<EPS && abs(c+1)<EPS && abs(d+1)<EPS)break;
    a*=M_PI/180;
    b*=M_PI/180;
    c*=M_PI/180;
    d*=M_PI/180;
    long double the=acos(cos(M_PI/2-a)*cos(M_PI/2-c)+sin(M_PI/2-a)*sin(M_PI/2-c)*cos(d-b+2*M_PI));
    printf("%.0Lf\n",the*6378.1);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
  int a,b;
  cin>>a>>b;
  if(a>=10||b>=10){
    cout<<-1<<endl;
  }else cout<<a*b<<endl;
}



Measured memory_bytes: 256
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = sorted([list(map(int,input().split())) for _ in range(M)],key = lambda x: x[1], reverse = True)
change = 0

for i in range(M):
    for j in range(change,min(change+BC[i][0],N)):
        if(A[j]<BC[i][1]):
            A[j] = BC[i][1]
    change += BC[i][0]
print(sum(A))

Measured memory_bytes: 33640
#include<stdio.h>
int main(void) {
	char a[101], b[101];
	scanf("%s %s", a, b);
	char s[1000];
	int cnt = 0;
	for (int i = 0; b[i] != '\0'; i++) {
		s[i] = b[i];
		cnt++;
	}
	for (int i = 0; a[i] != '\0'; i++) {
		s[cnt] = a[i];
		cnt++;
	}
	for (int i = 0; i < cnt; i++) {
		printf("%c", s[i]);
	}
	printf("\n");
	return 0;
}

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

int main(){
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));
  for(int i = 0;i < d;i++){
    for(int j = 0;j < 26;j++){
      cin >> s.at(i).at(j);
    }
  }
  vector<int> day(26,0);

  for(int i = 0;i < d;i++){
    int ans = 0;
    ll ansc = 0;
    for(int j = 0;j < 26;j++){
      ll now = c[j] * (i - day[j] + 1);
      if(now > ansc){
        ans = j; 
    }else if(now == ansc){
      if(c[ans] < c[j]){
        ans = j;
      }
    }
    day[j] = i;  
  }
    cout << ans + 1 << endl;

  }
} 

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

int main(){
  long long n,k;
  cin>>n>>k;
  n%=k;
  long long a=abs(n-k);
  long long ans=min(a,n);
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b);

int main(void)
{
    int n=0,k=0;
    long int count=0;
    long int H[200000]={};
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) scanf("%ld",&H[i]);
    qsort(H,n,sizeof(long int),asc);
    for(int i=0;i<n-k;i++) count+=H[i];
    printf("%ld",count);
    return 0;
}

int asc(const void *a, const void *b){
    long *A = (long *)a;
    long *B = (long *)b;
    if (*A > *B) return 1;
    if (*A < *B) return -1;
    return 0;
}


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

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

	int max= atoi((a + b).c_str())+ atoi((c).c_str());
	if (atoi((b + a).c_str())+ atoi((c).c_str()) > max) {
		max = atoi((b + a).c_str()) + atoi((c).c_str());
	}
	if (atoi((a + c).c_str()) + atoi((b).c_str()) > max) {
		max = atoi((a + c).c_str()) + atoi((b).c_str());
	}
	if (atoi((c + a).c_str()) + atoi((b).c_str()) > max) {
		max = atoi((c + a).c_str()) + atoi((b).c_str());
	}
	if (atoi((c + b).c_str()) + atoi((a).c_str()) > max) {
		max = atoi((c + b).c_str()) + atoi((a).c_str());
	}
	if (atoi((b + c).c_str()) + atoi((a).c_str()) > max) {
		max = atoi((b + c).c_str()) + atoi((a).c_str());
	}
	cout << max << endl;
	


	return 0;
}

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

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    for (int i = 0; i < h; i++)
    {
        cin >> a[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
            {
                row[i] = true;
                col[j] = true;
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        if (row[i])
        {
            for (int j = 0; j < w; j++)
            {
                if (col[j])
                {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
    int n; cin >> n;
    rep2(i,9) rep2(j,9){
        if (i*j == n) {
            cout << "Yes" << endl;
            return 0;
        }    
    }
    cout << "No" << endl;
}

/*
g++ b.cpp
./a.out

oj d https://atcoder.jp/contests/abc170/tasks/abc170_d
oj t
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
struct edge{ int to, time, cost; };
const double esp = 1e-9;
const int infi = (int)1e+9;
const ll infll = (ll)1e+17;

int n;

int main(){
	while (std::cin >> n, n){
		++n;
		std::vector<int> s, s2;
		rep(i, n){
			int h;
			std::cin >> h;
			s.push_back(h);
		}
		rep(i, n){
			s2 = s;
			s2.erase(s2.begin() + i, s2.begin() + i + 1);
			bool f = true;
			int k = s2[1] - s2[0];
			rep(j, n - 2){
				if (s2[j + 1] - s2[j] != k)f = false;
			}
			if (f){
				std::cout << s[i] << std::endl;
				break;
			}
		}
	}
	return 0;
}

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

int main(){
    int a,b; cin >> a >> b;
    if(a >= b*2) cout << a-b*2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	char tmp;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[100005] = {};
	ll z[100005] = {};
	string s;

	//IntStack yStack;
	//charStack Stack;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	sort(x, x + n);
	
	for (int i = 0; i < n; i++)
	{
		a = x[i];
		if (a==b)
		{
			d = c;
			c = a;
			a = 0;
			b = 0;
		}
		else
		{
			b = a;
			a = x[i];
		}

	}
	cout << d*c << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;
	
	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 8064
n=gets.chomp.to_i
a = []
n.times do |i|
 a << gets.chomp.to_i
end
g = 0
k = 0
a.each do |i|
  if i % 2 == 0
     g += 1
  else
     k += 1
  end
end
if k == 0
  puts "second"
  exit
else
  puts "first"
end

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

const int N = 1000 + 20;
int n, k, a[N];

int main() {
	cin >> n >> k;
  	for (int i = 0; i < n; i++)
      	cin >> a[i];
  	sort(a, a + n);
  	int ans = 0;
  	for (int i = 0; i < k; i++)
      	ans += a[i];
  	return cout << ans << "\n", 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }



int main()
{
	string s;
	cin >> s;
	int c[256] = { 0 };
	for (int i = 0; i < s.size(); ++i)
		++c[s[i]];
	int odd = 0;
	for (int i = 'a'; i <= 'z'; ++i)
		if (c[i] & 1)
			++odd;
	if (odd > 1 || odd > 0 && s.size() % 2 == 0)
	{
		cout << 0 << endl;
		return 0;
	}

	int remain = s.size() / 2;
	for (int i = 'a'; i <= 'z'; ++i)
		c[i] /= 2;

	ll combi[33][33];
	CLEAR(combi, 0);
	for (int i = 0; i <= 30; ++i)
		combi[i][0] = 1;
	for (int i = 1; i <= 30; ++i)
		for (int j = 1; j <= i; ++j)
			combi[i][j] = combi[i - 1][j - 1] + combi[i - 1][j];

	ll res = 1;
	for (int i = 'a'; i <= 'z'; ++i)
	{
		res *= combi[remain][c[i]];
		remain -= c[i];
	}
	cout << res << endl;
}

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

int main() {
    int X, Y; cin >> X >> Y;
    int ans = 0;
    if (X == 1) {
        ans += 300000;
    }
    if (X == 2) {
        ans += 200000;
    }
    if (X == 3) {
        ans += 100000;
    }
    if (Y == 1) {
        ans += 300000;
    }
    if (Y == 2) {
        ans += 200000;
    }
    if (Y == 3) {
        ans += 100000;
    }
    if (X == 1 && Y == 1) {
        ans += 400000;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()

if a <= 0 <= b:
	print("Zero")
elif b < 0:
	print("Positive" if (b-a+1)%2 == 0 else "Negative")
else:
	print("Positive")


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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int l = s.length();
  if ((s[0] == s[l-1]) ^ (l % 2 == 0)) {
    cout << "Second";
  } else {
    cout << "First";
  }
  cout << endl;
}


Measured memory_bytes: 512
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=205;
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    cout<<(1<<m)*(100*(n-m)+1900*m)<<endl;

    return 0;
}


Measured memory_bytes: 256
def longest_common(x, y):
    cost = [0]
    for c in y:
        for i in range(len(cost) -1, -1, -1):
            index = x.find(c, cost[i]) + 1
            if index:
                if i + 1 < len(cost):
                    cost[i + 1] = min(cost[i + 1], index)
                else:
                    cost.append(index)
    return len(cost)  - 1
            

n = int(input())
for _ in range(n):
    x = input()
    y = input()
    print(longest_common(x, y))

Measured memory_bytes: 6728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n,m;
cin >> n>>m;
ll a[n] = {};
rep(i, n)
{
    cin >> a[i];
}
pair<ll, ll> p[m];
rep(i,m){
    ll aa,bb;
    cin >> aa>>bb;
    p[i].first=(-1)*bb;
    p[i].second=aa;
}
sort(p,p+m);
ll sum=0;
vector<ll> v;
rep(i,m){
    if(sum+p[i].second<n){
        rep(j,p[i].second){
            v.push_back((-1)*p[i].first);
        }
        sum+=p[i].second;
        }
    else{
        rep(j,n-sum){
            v.push_back((-1)*p[i].first);
        }
        break;
    }
}
rep(i,n){
    v.push_back(a[i]);
}
sort(v.rbegin(), v.rend());
rep(i,n){
    ans+=v[i];
}
cout << ans << endl;
return 0;
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    for(int i = k; i < n; i++) {
        if(a[i-k] < a[i]) {
            cout << "Yes" << endl;
        }else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4416
n = int(input())#奇数
p = [0] + list(map(float,input().split()))
ans = 0
#dp[i][j] = i番目までのコインで表がj枚になる確率
'''dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i])
ans = dp[n][n//2+1]+...+dp[n][n]
'''
dp = [[0]*(n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  dp[i][0] = dp[i-1][0]*(1-p[i])
for i in range(1,n+1):
  for j in range(1,i+1):
    dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i])
for j in range(n//2+1,n+1):
  ans += dp[n][j]
print(ans)

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll X;
    cin >> X;

    ll p = X;
    bool f = true;
    if (X == 2) _PR(2);
    else {
        if(X % 2 == 0) ++p;
        while(1) {
            f = true;
            for(ll i=2; i*i<=p; ++i) {
                if(p % i == 0) {
                    f = false;
                    break;
                }
            }
            if(f) { _PR(p); break; }
            p += 2;
        }
    }    

    return 0;
}

/*



*/

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
def modpow(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

def modinv(a,mod):
    return modpow(a,mod - 2,mod)


one = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i] > A[j]:
            one+=1
two = 0
AA = A+A
for i in range(N*2):
    for j in range(i+1,N*2):
        if AA[i] > AA[j]:
            two+=1
two -= one*2
MOD = 10**9+7

print((one*K%MOD + two*(((K-1)*(K)//2)))%MOD)




Measured memory_bytes: 42476
#include <stdio.h>

int main(void) {
	int n, x;
	int i, j, k, ans;
	
	while (scanf("%d %d", &n, &x), n || x) {
		ans = 0;
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x) ans++;
				}
			}
		}
		
		printf("%d\n", ans);
	}
	return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int money = 700;

	for (int i = 0; i < s.size(); i++)
	{
		if (s.at(i) == 'o')
		{
			money += 100;
		}
	}

	cout << money << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

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

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

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c, k := readInt(), readInt(), readInt(), readInt()

	ans := 0
	d := k - a
	if d > 0 {
		ans = a
		d -= b
		if d > 0 {
			if d-c >= 0 {
				ans -= c
			} else if d-c == 0 {
				ans -= c
			} else {
				ans -= d
			}
		}
	} else if d == 0 {
		ans = a
	} else {
		ans = k
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1756
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
arr = []
while l = $stdin.gets do
  if lc == 0
  else
    arr << l.chomp.to_i
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p arr
end

puts arr.uniq.size


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <cassert>
using namespace std;
typedef long long LL;
const int M = 1e6 + 5;
const int N = 1e5 + 5;
const LL mod = 1e9 + 7;
const int MAX = 5e5 + 5;
const int MAXV = 100000 + 5;
const LL INF = (1LL << 62);
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.);
LL inv[N + 5];
LL nv[N + 5];
LL pw(LL n,LL m){
    LL ret = 1;
    while(m){
        if(m&1)ret = ret * n % mod;
        n = n * n % mod;
        m >>= 1;
    }
    return ret;
}
void init(){
    nv[0] = 1;
    for(int i = 1; i <= N; i++){
        nv[i] = nv[i - 1] * i % mod;
    }
    inv[N] = pw(nv[N],mod - 2);
    for(int i = N - 1; i >= 0; i--){
        inv[i] = inv[i + 1] * (i + 1) % mod;
    }
}
LL C(int n,int m){
    if(n < m)return 0;
    return nv[n] * inv[m] % mod * inv[n - m] % mod;
}
int num[N + 5];
int vis[N + 5];

int main() {
#ifdef local
    freopen("input", "r", stdin);
//    freopen("w", "w", stdout);
//    freopen("input", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    init();
    int l = 0,r = 0;
    int n;
    cin>>n;
    for(int i = 1; i <= n + 1; i++){
        cin>>num[i];
        if(vis[num[i]]){
            l = vis[num[i]] - 1;
            r = n - i + 1;
        }
        vis[num[i]] = i;
    }
    for(int i = 1; i <= n + 1; i++){
        LL ans = C(n + 1,i);
        if(l + r >= i - 1){
            ans -= C(l + r,i - 1);
        }
        ans %= mod;
        ans = (ans + mod)%mod;
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3584
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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

const int N = 3005;
const int MOD = int(1e9)+7;
const int INF = int(2e9)+5;
const ll INF64 = 1e18;

ll a[N],presum[N],dp[N][N];

int main () {
    int n;cin>>n;
    memset(dp,0,sizeof(dp));
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        presum[i] = presum[i-1] + a[i];
        dp[i][i] = a[i];
    }
    for (int l=1;l<=n-1;l++) {
        for (int i=1;i<n-l+1;i++) {
            int j = i + l;
            ll x = a[j] + presum[j-1] - presum[i-1] - dp[i][j-1];
            ll y = a[i] + presum[j] - presum[i] - dp[i+1][j];
            dp[i][j] = max(x,y);
        }
    }
    ll ans = dp[1][n];
    cout<<2*ans-presum[n]<<endl;
    return 0;
}

Measured memory_bytes: 70784
import math
if __name__ == '__main__':
    def manh(x, y):
        d = 0
        for i, j in zip(x, y):
            d += abs(int(i)-int(j))
        return d

    def uqurid(x, y):
        d = 0
        for i, j in zip(x, y):
            d += abs(int(i)-int(j))**2
        return math.sqrt(d)

    def minco(x, y):
        p = 3
        d = 0
        for i, j in zip(x, y):
            d += abs(int(i)-int(j))**p
        return d**(1/p)

    def ebis(x, y):
        d = 0
        for i, j in zip(x, y):
            d = max(d, abs(int(i)-int(j)))
        return d

    n = int(input())
    x = input().split()
    y = input().split()

    print(manh(x, y))
    print(uqurid(x, y))
    print(minco(x, y))
    print(ebis(x, y))



Measured memory_bytes: 5708
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;
#define MAX_N (100010)
int n;
int m;
int q;
vector<int> G[MAX_N];
int id[MAX_N];
int cur_id;

void bfs( int cur ) {
    queue< int > Q;
    Q.push( cur );
    id[cur] = cur_id;
    while ( !Q.empty() ) {
	int v = Q.front(); Q.pop();
	for ( int i = 0; i < G[v].size(); i++ ) {
	    int next = G[v][i];
	    if ( id[next] == -1 ) {
		id[next] = cur_id;
		Q.push( next );
	    }
	}
    }

    return;
}

int main()
{
    scanf("%d %d", &n, &m);

    for ( int i = 0; i < m; i++ ) {
	int s, t;
	scanf("%d %d", &s, &t);
	G[s].push_back( t );
	G[t].push_back( s );
    }

    for ( int i = 0; i < n; i++ ) id[i] = -1;
    cur_id = 0;    

    for ( int i = 0; i < n; i++ ) {
	if ( id[i] == -1 ) { 
	    bfs( i );
	    cur_id++;
	}
    }

    scanf("%d", &q);


    for ( int i = 0; i < q; i++ ) {
	int s, t;
	scanf("%d %d", &s, &t);
	if ( id[s] == id[t] ) printf("yes\n");
	else printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 6900
#include <stdio.h>

int main(){
  int n,u,k,v,G[100][100];
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0) printf(" ");
      printf("%d",G[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 640
def bubble_sort(input_list):
    total_number = len(input_list)
    flag = True
    finished = 0

    while flag:
        flag = False
        for i in range(total_number-1-finished):
            if input_list[i] > input_list[i+1]:
                input_list[i], input_list[i+1] = input_list[i+1], input_list[i]
                flag = True
        finished += 1
        
    return(input_list)

def main():
    n, k = map(int, input().split())
    p_ = list(map(int, input().split()))
    p = bubble_sort(p_)
    
    sum = 0
    for i in range(k):
        sum += p[i]
    print(sum)

if __name__ == "__main__":
    main()

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

int main(){
  int a,b;
  cin>>a>>b;
  int s=0;
  if(a>=b){
    for(int i=0;i<a;i++){
      s=s+b*pow(10,i);
    } 
  }
  else{
     for(int i=0;i<b;i++){
      s=s+a*pow(10,i);
     }
  }
  cout<<s<<endl;
  
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main(){
    int N;
    cin>>N;
    map<int,int> m;
    for(int i = 2; i <= N; i++){
        int t = i;
        for(int j = 2; j*j<=i; j++){
            while(t%j==0){
                t/=j;
                m[j]++;
            }
        }
        if(t!=1) m[t]++;
    }
    ll ans = 1;
    for(auto x:m){
        ans = (ans * (x.second+1))%mod;
    }
    cout<<ans<<endl;
} 

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

using ll=long long;
using P=pair<int, int>;
const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    int N, M; cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    for(int i=0; i<M; i++){
        cin >> k[i];
        s[i].resize(k[i]);
        for(int j=0; j<k[i]; j++){
            cin >> s[i][j];
        }
    }
    vector<int> p(M);
    for(int i=0; i<M; i++) cin >> p[i];
    int ans=0;
    for(int bits=0; bits<(1<<N); bits++){
        vector<bool> s_on(N, false);
        bool ok=true;
        for(int i=0; i<N; i++){
            if((bits>>i) & 1){
                s_on[i]=true;
            }
        }
        for(int i=0; i<M; i++){
            int sum=0;
            for(int j=0; j<k[i]; j++){
                if(s_on[s[i][j]-1]) sum++;
            }
            if(sum%2 != p[i]) ok=false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

int main(void) {

	lli N;
	cin >> N;

	lli sum = 0;
	string res;

	if (N > 0) {

		for (lli i = 0; i < 40; i++) {
			if (i % 2 == 0)
				sum += (1LL << i);
			if (sum >= N)
				break;
		}

	}
	else if(N < 0){
		N *= -1;

		for (lli i = 0; i < 40; i++) {
			if (i % 2 == 1)
				sum += (1LL << i);
			if (sum >= N)
				break;
		}

	}
	else {
		COUT(0);
		return 0;
	}

	lli sub = sum - N;

	for (int i = 0; i < 40; i++) {
		if (((sum xor sub) >> i) == 0)
			break;
		res = (((sum xor sub) >> i) & 1 ? "1" : "0") + res;
	}

	COUT(res);

	return 0;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
tree = [[] for _ in range(n)]

for _ in range(n-1):
    a, b = map(lambda x:int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

visited = set()
stack = [0]
while stack:
    i = stack.pop()
    visited.add(i)
    for j in tree[i]:
        if not j in visited:
            counter[j] += counter[i]
            stack.append(j)
print(' '.join(map(str, counter)))

Measured memory_bytes: 166284
#include <iostream>
#include <map>

using namespace std;

map<string,char> n;
map<char,string> m;

void init1(){
  n["101"] = ' ';
  n["000000"] = '\'';
  n["000011"] = ',';
  n["10010001"] = '-';
  n["010001"] = '.';
  n["000001"] = '?';
  n["100101"] = 'A';
  n["10011010"] = 'B';
  n["0101"] = 'C';
  n["0001"] = 'D';
  n["110"] = 'E';
  n["01001"] = 'F';
  n["10011011"] = 'G';
  n["010000"] = 'H';
  n["0111"] = 'I';
  n["10011000"] = 'J';
  n["0110"] = 'K';
  n["00100"] = 'L';
  n["10011001"] = 'M';
  n["10011110"] = 'N';
  n["00101"] = 'O';
  n["111"] = 'P'; 
  n["10011111"] = 'Q';
  n["1000"] = 'R';
  n["00110"] = 'S'; 
  n["00111"] = 'T';
  n["10011100"] = 'U';
  n["10011101"] = 'V';
  n["000010"] = 'W';
  n["10010010"] = 'X';
  n["10010011"] = 'Y';
  n["10010000"] = 'Z';
}

void init2(){
  m['A'] = "00000";
  m['B'] = "00001";
  m['C'] = "00010";
  m['D'] = "00011";
  m['E'] = "00100";
  m['F'] = "00101";
  m['G'] = "00110";
  m['H'] = "00111";
  m['I'] = "01000";
  m['J'] = "01001";
  m['K'] = "01010";
  m['L'] = "01011";
  m['M'] = "01100";
  m['N'] = "01101";
  m['O'] = "01110";
  m['P'] = "01111";
  m['Q'] = "10000";
  m['R'] = "10001";
  m['S'] = "10010";
  m['T'] = "10011";
  m['U'] = "10100";
  m['V'] = "10101";
  m['W'] = "10110";
  m['X'] = "10111";
  m['Y'] = "11000";
  m['Z'] = "11001";
  m[' '] = "11010";
  m['.'] = "11011";
  m[','] = "11100";
  m['-'] = "11101";
  m['\''] = "11110";
  m['?'] = "11111";
}

int main(){
  string str;

  init1();
  init2();

  while(getline(cin,str)){
    string s = "";
    for(int i = 0 ; i < (int)str.size() ; i++){
      s += m[str[i]];
    }
    
    string ans = "";
    for(int i = 0 ; i < (int)s.size() ; i++){
      for(int j = 3 ; j <= 8 ; j++){
	string ss = s.substr(i,j);
	if(n[ss]){
	  ans += n[ss];
	  i += j;
	  i--;
	  break;
	}
      }
    }
    
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
int main(){
    int ans = 0, l, a, b, c, s1;
    scanf("%d %d %d", &s1, &a, &b);
    for(int i = 0; i <= s1; ++i){
        int k = 0;
        k += i % 10;
        k += (i % 100) / 10;
        k += (i % 1000) / 100;
        k += (i % 10000) / 1000;
        k += i / 10000;
        if(k >= a && k <= b)ans += i;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128