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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        boolean ok = true;
        for (int i = 0; i < M; i++) {
            int s = sc.nextInt();
            int c = sc.nextInt();
            int v = map.getOrDefault(s, -1);
            if (v == -1 || v == c) {
                map.put(s, c);
            } else {
                ok = false;
            }
        }
        if (!ok) {
            System.out.println(-1);
            return;
        }

        int[] d = new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = map.getOrDefault(i+1, -1);
        }
        if (N == 1) {
            System.out.println(d[0] == -1 ? 0 : d[0]);
            return;
        }

        // N > 1
        if (d[0] == 0) {
            System.out.println(-1);
            return;
        }
        if (d[0] == -1) {
            d[0] = 1;
        }
        for (int i = 1; i < N; i++) {
            if (d[i] == -1) {
                d[i] = 0;
            }
        }
        String ans = "";
        for (int i = 0; i < N; i++) {
            ans = ans+d[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
 
#define rep(n) for(int i=0; i<(n); i++)
#define pb(n) push_back((n))
 
//typedef long long ll;
 
using namespace std;

int main(){
	vector<pair<int,int> > v(101,pair<int,int>(0,1000));
	int i=0;
	while(1){
		int a,b;
		scanf("%d,%d",&a,&b);
		if(a==0&&b==0)break;
		v[i].first=b;
		v[i].second=a;
		i++;
	}
	sort(&v[0],&v[101]);
	reverse(&v[0],&v[101]);
	vector<int> r(101,0);
	int p=v[0].first;
	int rank=1;
	for(i=0; i<101; i++){
		if(p==v[i].first)r[v[i].second]=rank;
		else{
			rank++;
			p=v[i].first;
			r[v[i].second]=rank;
		}
	}
	while(scanf("%d",&i)!=EOF){
		cout<<r[i]<<endl;
	}
}

Measured memory_bytes: 1216
#abc133 c
a,b,c,d=map(int,input().split())

def gcd(x,y):
    if y==0:
        return x
    return gcd(y,x%y)


def lcm(x,y):
    return (x*y)//gcd(x,y)

e=lcm(c,d) #c,dの最小公倍数

def kosu(num):
    z=num
    nc=num//c
    nd=num//d
    ne=num//e
    return z-nc-nd+ne

ans=kosu(b)-kosu(a-1)

print(ans)

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	b := readInt()
	if a >= 13 {
		fmt.Println(b)
	} else if a >= 6 {
		fmt.Println(b / 2)
	} else {
		fmt.Println(0)
	}
}

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

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>

#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    ll a,b,c,d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

    if (a > 0 && d < 0) {
        printf("%lld\n", a*d);
    }
    else if (b < 0 && c>0) {
        printf("%lld\n", b*c);
    }
    else {
        ll ans = -LINF;
        if (b >= 0 && d >= 0) {
            ans = MAX(ans, b*d);
        }
        if (a <= 0 && c <= 0) {
            ans = MAX(ans, a*c);
        }
        printf("%lld\n", ans);
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N;

int main() {
	cin >> N;
	if (ceil(N / 1.08) == N / 1.08) {
		if (N / 1.08 < (N + 1) / 1.08) {
			cout << N / 1.08 << endl;
			return 0;
		}
	}
	else {
		if (ceil(N / 1.08) < (N + 1) / 1.08) {
			cout << ceil(N / 1.08) << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int64_t gcd(int64_t a, int64_t b){
	return (b > 0)? gcd(b, a % b) : a ;
}

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
        ret[i]++;
        n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main(void) {
    int64_t A, B;
    cin >> A >> B;
    int64_t G = gcd(A, B);
    auto P = prime_factor(G);
    cout << P.size()+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string kagi[256];
  string pass[256];
  int n,i,N,a=0,I,b=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>kagi[i];
  }
 
  cin>>N;
  for(i=0;i<N;i++){
    cin>>pass[i];
  }
  for(I=0;I<N;I++){
    for(i=0;i<n;i++){
      if(kagi[i]==pass[I]) {
	a++;
	break;
      }
      else b++;
    } 
    if(b==n) cout<<"Unknown "<<pass[I]<<endl;
    else if(a%2==0) cout<<"Closed by "<<pass[I]<<endl;
    else if(a%2!=0) cout<<"Opened by "<<pass[I]<<endl;
    b=0;
      
  }

  return 0;
}

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

int main() {
  
  int n, k;
  cin >> n >> k;
  
  vector<int> p(n);
  REP(i,n) cin >> p[i];
  
  sort(p.begin(), p.end());
  
  int ans = 0;
  
  REP(i,k) ans +=p[i];
  
  cout << ans << endl;
    

}


Measured memory_bytes: 3620
a, b = map(int, input().split())
num_count = b - a + 1
if a % 2 == 1:
    num_count -= 1
else:
    a = 0
if b % 2 == 0:
    num_count -= 1
else:
    b = 0
if (num_count / 2) % 2 == 1:
    n = 1
else:
    n = 0
print(int(a)^int(b)^int(n))


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

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

	for (int i = 0; i < M; ++i)
	{
		int A; cin >> A;
		N -= A;
	}

	if (N < 0) N = -1;
	cout << N;

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{
    constexpr int BLDG_NUM = 4;
    constexpr int FLOOR_NUM = 3;
    constexpr int ROOM_NUM = 10;
    int people_cnt[BLDG_NUM][FLOOR_NUM][ROOM_NUM] = {{{0}}};

    int data_num;
    cin >> data_num;
    for (int i = 1; i <= data_num; i++) {
        int bldg, floor, room, people;
        cin >> bldg >> floor >> room >> people;
        people_cnt[bldg - 1][floor - 1][room - 1] += people;
    }

    for (int i = 0; i < BLDG_NUM; i++) {
        if (i != 0) {
            cout << "####################" << endl;
        }
        for (int j = 0; j < FLOOR_NUM; j++) {
            for (int k = 0; k < ROOM_NUM; k++) {
                cout << " " << people_cnt[i][j][k];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1164
#create date: 2020-03-22 21:11

import sys
stdin = sys.stdin
from collections import Counter

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    c = Counter(a)
    s = 0
    for m in c.values():
        s += m*(m-1)//2
    for ai in a:
        print(s-(c[ai]-1))


if __name__ == "__main__":
    main()

Measured memory_bytes: 25492
#include <stdio.h>
int main(void) {
	int n, i, ans;
	scanf("%d", &n);
	ans = 0;
	for (i = 1; i <= n; i++) {
		if (i < 100000 && i >= 10000) {
			ans = ans + 1;
		}
		else if (i < 1000 && i >= 100) {
			ans = ans + 1;
		}
		else if (i < 10 && i >= 1) {
			ans = ans + 1;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
from fractions import gcd
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

lcm = a[0]
ans = 0
for num in a[1:]:
    lcm = lcm * num // gcd(lcm, num)

for num in a:
    ans += (lcm - 1) % num

print(ans)


Measured memory_bytes: 5408
#include <iostream>
using namespace std;
int n,i,j,a[2001];
int main()
{
    cin>>n;
    a[3]=1;
    a[4]=1;
    a[5]=1;
    for(i=6;i<=2000;i++)
    {
        a[i]=((a[i-2]+a[i-3])%1000000007+a[i-4]%1000000007)%1000000007;
    }
    cout<<a[n]<<endl;
    //system("pause");
    return 0;
}


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

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  char W = 'a';
  int X = 0, Y = 0, Z = 0;

  while (X <= A.size() && Y <= B.size() && Z <= C.size()) {
    if (W == 'a') {
      if (X < A.size()) W = A.at(X);
      else W = 'A';
      X++;
    }
    if (W == 'b') {
      if (Y < B.size()) W = B.at(Y);
      else W = 'B';
      Y++;
    }
    if (W == 'c') {
      if (Z < C.size()) W = C.at(Z);
      else W = 'C';
      Z++;
    }
  }

  cout << W << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	int d, t, s ;
	scanf ("%d%d%d", &d, &t, &s) ;
	
	if (t * s >= d)
		cout << "Yes" << endl ;
	else
		cout << "No" << endl ;

	return 0 ;
}

Measured memory_bytes: 3172
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b ] <- readInts
	print $ if
		| 13 <= a -> b
		| 6 <= a -> b `div` 2
		| otherwise -> 0

Measured memory_bytes: 380
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    string s;
    cin >> s;
    
    int l=s.length();
    int ans=0;
    
    int flag=0;
    ans+=s[0]-'0';
    for(int i=1; i<l; i++){
        
        if(s[i]=='9'){
            ans+=9;
        }else{
            if(flag==0){
                ans--;
                flag=1;
                ans+=9;
            }else{
                ans+=9;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
const int N=2e5+5;
int dp[N],n;
int main() {
    scanf("%d",&n);
    int ans=0,x;
    for(int i=1;i<=n;i++) scanf("%d",&x),dp[x]=dp[x-1]+1,ans=std::max(ans,dp[x]);
    printf("%d\n",n-ans);
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	int pro = 0;
	bool used[8]{};
	while(n--){
		int a;
		cin >> a;
		if(3200 <= a){
			pro++;
			continue;
		}
		used[a / 400] = true;
	}
	int mini = 0;
	for(int i = 0; i < 8; i++) mini += used[i];
	if(mini == 0){
		cout << 1 << ' ' << pro << endl;
		return 0;
	}
	cout << mini << ' ' << mini + pro << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		long a = scan.nextLong();
		String b = scan.next();
		b = b.replace(".", "");
		long f = Long.parseLong(b.substring(0, 1)) * a * 100;
		long s  = Long.parseLong(b.substring(1, 2)) * a * 10;
		long t = Long.parseLong(b.substring(2, 3)) * a;
		long temp = f + s + t; 
		// seisuu
		long ans =  (temp) /100;
		System.out.println(ans);
	}
}

Measured memory_bytes: 27020
use std::io::BufRead;

fn main() {
  let stdin = std::io::stdin();

  let table = &mut [0; 26];

  for line in stdin.lock().lines() {
    let line = line.unwrap();

    for c in line.as_bytes() {
      match *c {
        b'a' ... b'z' => { table[(c - b'a') as usize] += 1; }
        b'A' ... b'Z' => { table[(c - b'A') as usize] += 1; }
        _ => {}
      }
    }
  }

  for i in 0..26 {
    println!("{} : {}", (i + b'a') as char, table[i as usize]);
  }
}


Measured memory_bytes: 5028
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	string s;
	int p, n;
	cin >> n >> p >> s;
	if(p==2 || p==5) {
		ll ans = 0;
		for(int i = 0; i < n; i++) {
			if((s[i]-'0')%p==0) ans+=i+1;
		}
		cout << ans;
		return 0;
	}
	vector<int> mod(n), cnt(p);
	int a= 0, cur=1;
	ll ans = 0;
	cnt[0]=1;
	for(int i = n-1; ~i; i--) {
		a=(a+(s[i]-'0')*cur)%p;
		ans+=cnt[a];
		cnt[a]++;
		//cout <<ans << '\n';
		cur=cur*10%p;
	}
	cout << ans;


	return 0;
}


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

typedef long long ll;
const int maxn = 2e5;
int n, m, a[maxn + 3], b[maxn + 3], p[maxn + 3][3];
ll sum[maxn + 3];

struct node {
	int id, type, val;
	friend bool operator < (const node &a, const node &b) {
		return a.val < b.val;
	}
} x[maxn + 3];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d %d", &a[i], &b[i]);
		x[++m].id = i, x[m].type = 1, x[m].val = a[i];
		x[++m].id = i, x[m].type = 2, x[m].val = b[i];
	}
	ll A = 0, B = 0;
	for (int i = 1; i <= n; i++) {
		A += a[i], B += b[i];
	}
	ll ans = min(A, B);
	sort(x + 1, x + m + 1);
	for (int i = 1; i <= m; i++) {
		p[x[i].id][x[i].type] = i;
		sum[i] = sum[i - 1] + x[i].val;
	}
	for (int i = 1; i <= n; i++) {
		int l = p[i][1], r = p[i][2];
		if (l > r) {
			swap(l, r);
		}
		if (l - 1 >= n - 2) {
			ans = min(ans, sum[n - 2] + x[l].val + x[r].val);
		} else if (r - 2 >= n - 2) {
			ans = min(ans, sum[n - 1] + x[r].val);
		} else {
			ans = min(ans, sum[n]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 7168
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

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

  vector<int> a;
  int temp;
  for (int i=0; i<n; i++) {
    cin>>temp;
    a.push_back(temp-1);
  }

  vector<int> b;
  for (int i=0; i<n; i++) {
    cin>>temp;
    b.push_back(temp);
  }

  vector<int> c;
  for (int i=0; i<n-1; i++) {
    cin>>temp;
    c.push_back(temp);
  }

  int ans = 0;
  for (int i=0; i<n; i++) {
    ans += b[a[i]];
    if (i>0 && a[i-1] + 1 == a[i])
      ans += c[a[i-1]];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
S = input()
count = 0
for i in range(len(S)):
    if (i+1)%2 == 0:
        if S[i]=="L" or S[i]=="U" or S[i]=="D":
            count+=1
    else:
        if S[i]=="R" or S[i]=="U" or S[i]=="D":
            count+=1

if count==len(S):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    ll a=6;
    for(ll i=0;i<N;i++){
        while(true){
            ll j_max=sqrt(a);
            bool ok=true;
            for(ll j=2;j<=j_max;j++){
                if(a%j==0){
                    ok=false;
                    break;
                }
            }
            if(ok){
                printf("%d ",a);
                a+=5;
                break;
            }
            a+=5;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	int a[20000], b[20000];
	cin >> n;
	for(int i = 0; i < n; i++){
		a[i] = i * (n + 1) + 1;
		b[n - i - 1] = i * n + 1;
	}
	for(int i = 1; i <= n; i++){
		int p;
		cin >> p;
		a[p - 1] -= p - i;
	}
	for(int i = 0; i < n; i++){
		cout << a[i];
		if(i != n - 1) cout << ' ';
	}
	cout << endl;
	for(int i = 0; i < n; i++){
		cout << b[i];
		if(i != n - 1) cout << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100001;
int main()
{
  int n,t=0,i;
  long long m,a,res=0;
  long long s[N_MAX];
  cin >> n >> m;
  s[0]=0;
  for(i=0;i<n;i++){
    cin >> a;
    s[i+1]=(s[i]+a)%m;
  }
  sort(s,s+n+1);
  for(i=0;i<n;i++)
    if(s[i+1]==s[i]){
      t++;
      res+=t;
    }else{
      t=0;
    }
  cout << res << endl;
  return 0;
}

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

int main(void){
    int i, j, n, m, ans, b[100]={}, A[100][100]={};
    cin >> n >> m;
    for(i=0; i<n; i++){
        for(j=0; j<m; j++) cin >> A[i][j];
    }
    for(i=0; i<m; i++) cin >> b[i];
    //culc
    for(i=0;i<n;i++){
        ans=0;
        for(j=0;j<m;j++){
            ans += b[j]*A[i][j];
        }
        cout << ans << endl;;
    }
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int grid[1100][1100], cnt[1000105];
pii dp[1100][1100], pos[1002020];

void rec(int cx, int cy, int m){
    int val = grid[cx][cy];
    if(m<grid[cx+1][cy-1] && m<grid[cx+1][cy] && m<grid[cx+1][cy+1]){
        if(cnt[val]==0) dp[cx][cy].first = 1, dp[cx][cy].second = val;
        else dp[cx][cy].first = 0;
        return;
    }
    if(dp[cx][cy].first>-1) return;
    for(int i=cy-1;i<=cy+1;i++){
        if(grid[cx+1][i]<=m){
            rec(cx+1, i, m);
            if(dp[cx][cy].first<dp[cx+1][i].first){
                dp[cx][cy].first = dp[cx+1][i].first;
                dp[cx][cy].second = dp[cx+1][i].second;
            }
            else if(dp[cx][cy].first==dp[cx+1][i].first){
                dp[cx][cy].second = max(dp[cx][cy].second, dp[cx+1][i].second);
            }
        }
    }

    if(cnt[val]==0){
        dp[cx][cy].first++;
        if(dp[cx][cy].second==0) dp[cx][cy].second = val;
    }
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    for(int i=0;i<1100;i++) for(int j=0;j<1100;j++) grid[i][j] = 2000000;
    int cur = 2, x = 505, y =505, size = 1;
    grid[x][y] = 1;
    pos[1].first = x, pos[1].second = y;
    while(cur<=1000000){
        y++; size += 2;
        for(int i=0;i<size-1;i++) {
            grid[x-i][y] = cur, pos[cur].first = x - i, pos[cur].second = y, cur++;
        }
        x -= size - 2; y--;
        for(int i=0;i<size-1;i++) {
            grid[x][y-i] = cur, pos[cur].first = x, pos[cur].second = y - i, cur++;
        }
        y -= size - 2; x++;
        for(int i=0;i<size-1;i++) {
            grid[x+i][y] = cur, pos[cur].first = x + i, pos[cur].second = y, cur++;
        }
        x += size - 2; y++;
        for(int i=0;i<size-1;i++) {
            grid[x][y+i] = cur, pos[cur].first = x, pos[cur].second = y + i, cur++;
        }
        y += size - 2;
    }
    cnt[0] = cnt[1] = 1;
    for(int i=2;i<=1000000;i++){
        if(cnt[i]) continue;
        for(int j=2*i;j<=1000000;j+=i) cnt[j]++;
    }

    int N, M;
    while(true){
        scanf("%d%d", &M, &N);
        if(M==0) return 0;
        for(int i=1;i<=M;i++){
            int cx = pos[i].first, cy = pos[i].second;
            dp[cx][cy].first = -1;
            dp[cx][cy].second = 0;
        }
        int nx = pos[N].first, ny = pos[N].second;
        rec(nx, ny, M);
        printf("%d %d\n", dp[nx][ny].first, dp[nx][ny].second);
    }
}


Measured memory_bytes: 28360
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int m1 = in.nextInt();
            int d1 = in.nextInt();
            int m2 = in.nextInt();
            int d2 = in.nextInt();
            if (m1 != m2) {
                out.println(1);
            } else {
                out.println(0);
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    ll X;
    cin>>X;

    ll ans=0;
    ans+=((X/500)*1000);
    X=X%500;
    ans+=((X/5)*5);

    cout<<ans<<"\n";
   


}


Measured memory_bytes: 3600
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int s[n],t[n];
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s[i]=a;
        t[i]=a;
    }
    sort(t,t+n);
    int t1=t[n/2-1],t2=t[n/2];
    for(int i=0;i<n;i++){
        if(s[i]<=t1){
            cout<<t2<<endl;
        }
        else cout<<t1<<endl;
    }
}


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

using namespace std;

#define ll long long

int main() {
    int n, q, a, t, x, s;
    cin >> n >> q;
    vector<list<ll> > l(n);
    list<ll>::iterator it;
    while (q--) {
        cin >> a;
        switch (a) {
            case 0:
                cin >> t >> x;
                l[t].push_back(x);
                break;
            case 1:
                cin >> t;
                if (!l[t].empty()) {
                    for (it = l[t].begin(); it != l[t].end(); ++it) {
                        if (it == l[t].begin()) cout << *it;
                        else cout << " " << *it;
                    }
                    cout << endl;
                } else cout << endl;
                break;
            case 2:
                cin >> s >> t;
                l[t].splice(l[t].end(),l[s]);
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 18620
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int N; cin >> N;
	vector<string> W(N);
	rep(i, N)cin >> W[i];

	map<string, int> p;
	rep(i, N) {
		if (p[W[i]] == 1) {
			cout << "No" << endl;
			return 0;
		}
		p[W[i]]++;
	}
	rep(i, N - 1) {
		if (W[i][W[i].size() - 1] != W[i + 1][0]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())

x = [[0 for i in range(N + 1)] for j in range(N + 1)]

for i in range(M):
    l, r = map(int, input().split())
    x[l][r] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i - 1][j] + x[i][j - 1] - x[i - 1][j - 1]

for i in range(Q):
    p, q = map(int, input().split())

    ans = x[N][q] - x[p - 1][q]
    print(ans)

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

int main() {
  int n,s;
  cin>>n>>s;
  long long mod=998244353;
  long long a[n][s+1];
  for(int i=0;i<n;i++){
    for(int j=0;j<s+1;j++){
      a[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    if(i==0){
      a[0][0]=2;
      if(k<s+1)a[0][k]=1;
    }
    else{
      for(int j=0;j<s+1;j++){
        a[i][j]=2*a[i-1][j]%mod;
      }
      for(int j=0;j<s+1-k;j++){
        a[i][j+k]+=a[i-1][j];
        a[i][j+k]%=mod;
      }
    }
  }
  cout<<a[n-1][s]<<endl;
}

Measured memory_bytes: 73932
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	int h, w;
	cin >> h >> w;
	vstr a(h);
	vcin(a, h);

	rep(i, w + 2) {
		cout << '#';
	}
	cout << rt;

	rep(i, h) {
		cout << '#' << a[i] << '#' << rt;
	}

	rep(i, w + 2) {
		cout << '#';
	}
	cout << rt;

	please AC;
}


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

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

    int B[N - 1];
    int a = 100000;
    long long ans = 0;
    for (int i = 0; i < N - 1; i++) {
        cin >> B[i];
        if (a > B[i]) {
            ans += B[i];
        }
        else {
            ans += a;
        }
        a = B[i];
    }
    ans += B[N - 2];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
const int maxn=100010,MOD=998244353;
int N,a[maxn],vis[maxn],f[maxn];
int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++)
		a[i]=read(),vis[a[i]]++;
	if(a[1]!=0)
		return printf("0\n"),0;
	sort(a+1,a+1+N);
	if(vis[0]!=1)
		return printf("0\n"),0;
	f[1]=1;
	for(int i=2;i<=N;i++)
		f[i]=1LL*f[i-1]*vis[a[i]-1]%MOD;
	printf("%d\n",f[N]);
	return 0;
}


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

using namespace std;
#define ll long long
const int maxn=1e5+5;
int CalcBit(int num)//计算num的位数
{
int cnt=0;
while(num/10 !=0)
{
num=num/10;
cnt++;
}
cnt=cnt+1;//num的位数

return cnt;
}
int main()
{
    int n;
    int sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {

        if(CalcBit(i)%2!=0) sum++;
        else continue;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
// template version 1.8

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
const int INF=1e18;
const int MOD=1e9+7;
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}


int solve(){
  int h,w;cin>>h>>w;
  vector<vector<int>> m(h, vector<int>(w));
  rep(i, h){
    string s;cin>>s;
    rep(j,w){
      m[i][j]=(s[j]=='#'?1:0);
    }
  }
  dump_2d(m, h, w);

  vvi d(h, vi(w, INF));
  typedef pair<int, pii> CP; // (cost, pos)
  // queue<CP> q;
  PQ<CP> q;
  rep(i,h)rep(j,w){
    if (m[i][j]==1) q.push(CP(0LL, pii(i, j)));
  }
  while (!q.empty()){
    auto v = q.top(); q.pop();
    int cost = v.first;
    int x = v.second.first;
    int y = v.second.second;
    if (cost < d[x][y]){
      d[x][y] = cost;
      rep(i, 4){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if (0<= nx && nx <= h-1 && 0<=ny && ny <= w-1){
          q.push(mp(cost+1, mp(nx, ny)));
        }
      }
    }
  }
  dump_2d(d, h, w);
  int res=0;
  rep(i,h)rep(j,w){
    chmax(res, d[i][j]);
  }
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 115428
#include<bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
int n;
  cin>>n;
 string a,b,result="";
  cin>>a>>b;
  
  for(int i=0;i<n;i++){
    result+=a[i];
    result+=b[i];
  }
  cout<<result;
  return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve(price):
    change = 1000 - price
    total_coins = 0
    for coin in [500, 100, 50, 10, 5, 1]:
        coins, change = divmod(change, coin)
        total_coins += coins
    return total_coins


if __name__ == '__main__':
    while True:
        n = int(input())
        if n == 0:
            break
        else:
            print(solve(n))

Measured memory_bytes: 7568
n = int(input())
score = [0, 0]
for i in range(n):
    T, H= input().split()
    if T>H:
        score[0] += 3
    elif H>T:
        score[1] += 3
    elif T == H:
        score[0] += 1
        score[1] += 1
print (*score)


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

int a,b,sum,dif,tim;

int main(){
	cin >> a >> b;
	sum = a + b;
	dif = a - b;
	tim = a * b;
	if((sum > dif)&&(sum > tim)){
		cout << sum;
	}else{
		if(dif > tim){
			cout << dif;
		}else{
			cout << tim;
		}
	}
	cout << endl;
}

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

string dp[1 << 12][12];
string str[12];
int n;

int check(int s, int v){
	int i, ss;
	ss = s;
	for(i = 0; i < n; i++){
		if(!((s >> i) & 1)){
			if(dp[s][v].find(str[i]) != string::npos){
				ss = ss | (1 << i);
			}
		}
	}
	return ss;
}

string combine(string a, string b){
	int i, j;
//	cout << a << " : ";
	for(i = 1; i < a.length(); i++){
		if(b.length() < a.length() - i) continue;
		for(j = i; j <= a.length(); j++){
			if(a[j] != b[j - i]) break;
		}
		if(j == a.length()) break;
	}
//	cout << a.substr(0, i) << endl;
	return a.substr(0, i) + b;
}

void rec(int s, int v){
//	cout << s  << " : " << v << endl;
	int i, j;
	if(s == (1 << n) - 1) return;

	for(i = 0; i < n; i++){
		if(!((s >> i) & 1)){
			string comb;
//			cout << i  << " : " << dp[s][v] << " : " << str[i] << endl;
			comb = combine(dp[s][v], str[i]);
//			cout << comb << endl;
			if(dp[s | (1 << i)][i].length() == 0 || dp[s | (1 << i)][i].length() >= comb.length()){
				if(dp[s | (1 << i)][i].length() == comb.length() && dp[s | (1 << i)][i] < comb) continue;
				dp[s | (1 << i)][i] = comb;
				int next = check(s | (1 << i), i);
				if(next == (s | (1 << i)) || dp[next][i].length() == 0 || dp[next][i].length() > comb.length()){
					if(dp[next][i].length() == comb.length() && dp[next][i] < comb) continue;
					dp[next][i] = comb;
//					cout << "next & i:" << next << i << endl << "dp : " << dp[next][i] << endl;
					rec(next, i);
				}
			}
		}
	}
	return;
}


int main(void){
	int i, j;
	while(cin >> n, n){
		for(i = 0; i < (1 << n); i++){
			for(j = 0; j < n; j++){
				dp[i][j] = "";
			}
		}
		for(i = 0; i < n; i++){
			cin >> str[i];
			dp[1 << i][i] = str[i];
		}
		sort(str, str + n);
		/*
		for(i = 0; i < n; i++){
			cout << str[i] << endl;
		}
		*/
		dp[0][0] = "";
		for(i = 0; i < n; i++){
			dp[1 << i][i] = str[i];
			int next = check(1 << i, i);
			dp[next][i] = str[i];
//			cout << "start: " <<next << endl;
			rec(next, i);
		}
		int min = 0;
		for(i = 0; i < n; i++){
//			cout << "search : " << dp[(1 << n) - 1][i] << endl;
			if(dp[(1 << n) - 1][i] == "") continue;
			if(dp[(1 << n) - 1][min] == "") min = i;
			if(dp[(1 << n) - 1][min].length() >= dp[(1 << n) - 1][i].length()){ 
				if(dp[(1 << n) - 1][min].length() == dp[(1 << n) - 1][i].length() && dp[(1 << n) - 1][min] < dp[(1 << n) - 1][i]) continue;
				min = i;
			}
		}
		cout << dp[(1 << n) - 1][min] << endl; //cout << endl << endl;
	}
	return 0;
}

Measured memory_bytes: 2128
N = int(input())
A = list(map(int, input().split()))

# 方針:正負正...と負正負...の両方を試す
ans = 0
now = 0
for i in range(N):
    if i % 2 == 0:# 正にする
        if now+A[i] <= 0:
            ans += 1 - (now+A[i])
            now = 1
        else:
            now += A[i]
    else:
        if now+A[i] >= 0:
            ans += 1 + (now+A[i])
            now = -1
        else:
            now += A[i]
ans2 = 0
now = 0
for i in range(N):
    if i % 2 == 1:# 正にする
        if now+A[i] <= 0:
            ans2 += 1 - (now+A[i])
            now = 1
        else:
            now += A[i]
    else:
        if now+A[i] >= 0:
            ans2 += 1 + (now+A[i])
            now = -1
        else:
            now += A[i]

print(min(ans,ans2))

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


int main() {
  ll x;
  cin >> x;
  ll ans=0, n=100;
  while(n < x){
    n += n/100;
    ans++;
    if(n >= x) cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    int a[n];
    int count = 0;
    int flag = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] % 2 == 0) {
            count++;
            if(a[i] % 3 == 0 || a[i] % 5 == 0) {
                flag++;
            }
        }
    }
    if(flag == count) {
        cout << "APPROVED";
    }else {
        cout << "DENIED";
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k >> s;

  vector<int> v;

  char c = '1';
  int sum = 0;
  int ans = 0;
  REP(i, n) {
    if(s[i] == c) {
      sum++;
    } else {
      v.push_back(sum);
      c = s[i];
      sum = 1;
    }
  }
  v.push_back(sum);

  vector<int> v_sum(v.size() + 1, 0);
  FOR(i, 1, v.size() + 1) v_sum[i] = v_sum[i - 1] + v[i - 1];

  for(int l=0; l<v_sum.size(); l+=2) {
    int r = min((int)v_sum.size() - 1, l + k * 2 + 1);
    ans = max(ans, v_sum[r] - v_sum[l]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1272
N = int(input())

az = [chr(i) for i in range(97, 97+26)]

N = N - 1

tmp1 = 0
for i in range(1, 1000):
    tmp1 += 26 ** i
    if tmp1 > N:
        num = i
        tmp1 -= 26 ** i
        N -= tmp1
        break

tmp = [0 for _ in range(num)]
for i in range(num):
    tmp[i] = N%26
    N = N // 26

ans = ""
for i in range(len(tmp)):
    ans = az[tmp[i]] + ans

print(ans)

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

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<vector<int>> dp(N + 1, vector<int>(2));
    dp[0][0] = dp[0][1] = 1;
    for (int i = 1; i <= N; ++i)
    {
        dp[i][0] = min(dp[i - 1][0] * 2, dp[i - 1][1] * 2);
        dp[i][1] = min(dp[i - 1][0] + K, dp[i - 1][1] + K);
    }
    cout << min(dp[N][0], dp[N][1]) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
typedef long long int ll;
#define forn(i,e) for(ll i=0; i<e; i++)
#define fors(i , s ,e) for(ll i = s ; i < e ; i++)
#define endl "\n"
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PB push_back 
#define MP make_pair
#define F first
#define S second


int main()
{
ll n ; cin >> n ; 
ll sum = 0 ; 
fors(i , 1, n+1)
{
	ll n1 = n/i  ; 
	
	sum += (n1*((2*i) + ((n1-1)*i) )) /2 ;

}
cout << sum << endl ;
 

}
  



Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <time.h>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
//#define Graph vector<vector<int>>

#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

signed main() {
	int n;
	scanf("%d", &n);
	vector<int> num(n);
	REP(i, n) {
		int a;
		scnaf("%d", &num[i]);

	}
	int ans = 1;
	int bef = num[0];
	int zou = -1;
	rep(i, 1, n) {
		int cur;
		if (num[i] > bef) cur = 1;
		else if (num[i] < bef) cur = 0;
		else cur = zou;
		//if (bef == -1) cur = -1;
		if (zou != cur && zou != -1) {
			ans++;
			zou = -1;
			bef = num[i];
		}
		else zou = cur, bef = num[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640