akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
     
int main() {
   int N, M;
   int A[M];
   int count = 0;

   scanf("%d %d", &N, &M);
   for(int i = 0; i < M; i++) {
      scanf("%d", &A[i]);
      count += A[i];
   }
   if(count > N) {
      printf("-1\n");
   }else {
      printf("%d\n", N - count);
   }
   return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
	if(a<b)	gcd(b,a);
	if(b==0)	return a;
	return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
	ll x=(a/gcd(a,b))*b; 
	return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
	if(x==0){
		return 0;
	}
	if(n==0){
		return 1;
	}
	ll ans;
	if(n%2==0){
		ll smallAns = power(x,n/2,m);
		ans = (smallAns*smallAns)%m;		
	} else {
		ll smallAns = power(x,n-1,m);
		ans = x;
		ans = (ans*smallAns)%m;
	}
	// for negative values also
	return (ans+m)%m;
	
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }
 
// void rec(int n){
//     if(){
//         return;
//     }
    
//     return;
// }
 
int solve() {fastio
    long long int x,ans;
    cin>>x;
    long long int z = x%500;
    ans = ((x/500)*1000);
    ans += ((z/5)*5);
    cout<<ans;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio
    
 	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	
	string s;
	cin>>s;
	cout<<s[0]<<s.size()-2<<s[s.size()-1];
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N (200009)
#define LL long long
#define MOD (1000000007)
using namespace std;

LL inv[N],fac[N],facinv[N];
LL h,w,a,b;

void Init()
{
	fac[0]=facinv[0]=inv[1]=1;
	for (int i=1; i<=200000; ++i)
	{
		if (i!=1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		fac[i]=fac[i-1]*i%MOD; facinv[i]=facinv[i-1]*inv[i]%MOD;
	}
}

LL C(LL n,LL m)
{
	if (n<m) return 0;
	return fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;
}

int main()
{
	Init();
	cin>>h>>w>>a>>b;
	LL ans=C(h+w-2,h-1);
	for (int i=1; i<=b; ++i)
		ans=(ans-C(h-a-1+i-1,i-1)*C(a-1+(w-i),a-1)%MOD)%MOD;
	cout<<(ans+MOD)%MOD;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    int len = s.size();
    vector<int> res;
    rep(i, len){
        if(s[i]=='0'){
            res.push_back(0);
        }else{
            if(s[i]=='1'){
                res.push_back(1);
            }else{
                if(!res.empty()){
                    res.pop_back();
                }
            }
        }
    }
    int rlen = res.size();
    rep(i, rlen){
        cout << res[i];
    }
    cout << endl;
    return 0;
}

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

int main(){

  cin.tie(0);
  ios::sync_with_stdio(0);

  long long n;
  long long ans = 1;

  cin >> n;

  for(int i = 1; i <= n; i++){
    ans = ans * i % 1000000007;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
while True:
    m,nmin,nmax = map(int,input().split())
    if m == 0:
        exit()
    P = []
    for i in range(m):
        P.append(int(input()))
    max_diff = -1
    ans = -1
    for i in range(nmin-1,nmax):
        if max_diff <= P[i] - P[i+1]:
            max_diff = P[i] - P[i+1]
            ans = i + 1
    print(ans)


Measured memory_bytes: 5620
N,K=map(int, input().split())
X=list(map(int, input().split()))
import numpy as np

ans=np.inf
for L in range(0,N-K+1):
  R=L+K-1
  ans=min(ans, X[R]-X[L]+min(abs(X[R]),abs(X[L])))
  #print(R,L)
  
print(ans)


Measured memory_bytes: 16444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e6 +9;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9+7;
#define w first
#define v second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;

ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll val[N];
ll adj[N][2];
ll ans = 0;
multiset<ll> l,r;
map<ll,bool> cnbf;
map<ll,int> ct;
void dfs(ll v){
     if(adj[v][0]!=-1){
          l.insert(val[v]);
          dfs(adj[v][0]);
          auto e = l.find(val[v]);
          l.erase(e);
     }
     if(adj[v][1]!=-1){
          r.insert(val[v]);
          dfs(adj[v][1]);
          auto e = r.find(val[v]);
          r.erase(e);
     }
     ll ul = inf;
     ll ll = 0;
     if(l.size() ){
          ul = *l.begin();
         
     }
     if(r.size()){
          ll = *r.rbegin();
          // cout<<ll<<'\n';
     }
          // cout<<v<<" "<<ul<<" "<<ll<<'\n';

     if(val[v]>=ll && val[v]<=ul){
          cnbf[val[v]] = 1;
     }


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

     ll q = 1;
     // cin>>q;
     while(q--){
          ll n,W;cin>>n>>W;
          pii a[n];
          for(int i = 0;i<n;i++){
               cin>>a[i].w>>a[i].v;
          }
          ll dp[n][W+1];
          memset(dp,0,sizeof(dp));
          for(int i = 0;i<n;i++){
               if(i==0){
                    dp[i][a[i].w]=a[i].v;
               }
               else
               for(int w= 1;w<=W;w++){
                    if(a[i].w>w){
                         dp[i][w]=dp[i-1][w];
                    }
                    else if(a[i].w<w){
                         dp[i][w] = max(dp[i-1][w],dp[i-1][w-a[i].w]+a[i].v);
                    }
                    else{
                         dp[i][w]=max(dp[i-1][w],a[i].v);
                    }
               }
          }
          // for(int i = 0;i<n;i++){
          //      for(int w = 0;w<=W;w++){
          //           cout<<dp[i][w]<<" ";
          //      }
          //      cout<<'\n';
          // }
          ll ans = 0;
          for(int i = 0;i<=W;i++){
               ans=max(dp[n-1][i],ans);
          }
          cout<<ans<<'\n';

     }
}         

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

int main() {
	int n; cin >> n;
	int L = n / 100;
	int R = n % 100;

	if (1 <= L && L <= 12) {
		if (1 <= R && R <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		if (1 <= R && R <= 12) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> [Int] -> Int
solve bN as = cost
  where
  vA = VU.fromListN bN as
  acc = VU.scanl' (+) 0 vA

  cost = runST $ do
    vec <- VM.replicateM (bN+1) (VUM.replicate bN (-1))
    calc vec bN 0

    where
      calc vec 1 _ = return 0
      calc vec len i = do
        v <- VM.read vec len
        val <- VUM.read v i
        if val >= 0 then return val
          else do
          newVal <- top <$> mapM f [1 .. len-1]
          VUM.write v i newVal
          return newVal
        where
          top lst = (minimum lst) + (acc VU.! (i+len)) - (acc VU.! i)
          f k = (+) <$> calc vec k i <*> calc vec (len-k) (i+k)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN]:remLines1 = remLines0
      bN = readBInt bs_bN
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents

-------------------------------------------------------------------------------

inp1 = "4\n10 20 30 40\n"
inp2 = "5\n10 10 10 10 10\n"
inp3 = "3\n1000000000 1000000000 1000000000\n"
inp4 = "6\n7 6 8 6 1 1\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
tv4 = tmain $ B.pack inp4
test1 = tv1 == 190
test2 = tv2 == 120
test3 = tv3 == 5000000000
test4 = tv4 == 68
alltest = test1 && test2 && test3 && test4



Measured memory_bytes: 6524
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
#define mod 1000000007
ll power(ll x,ll p){ll a=1;while(p>0){if(p%2==0){x*=x;p/=2;}else{a*=x;p--;}}return a;}
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 0, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll k) { ll a = 1, b = 1; rep(i, 0, k) { a = a * (n - i + 1) % mod; b = b * i % mod; }return a * mpower(b, mod - 2) % mod; }

const double PI = 3.14159265358979323846;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
int main() {
	int W, H, N, x, y, a;
	int mx, Mx = 0, my, My = 0;
	scanf("%d%d%d", &W, &H, &N);
	mx = W, my = H;
	rep(i, 0, N) {
		scanf("%d%d%d", &x, &y, &a);
		if (a == 1)Mx = max(Mx, x);
		if (a == 2)mx = min(mx, x);
		if (a == 3)My = max(My, y);
		if (a == 4)my = min(my, y);
	}
	if ((mx - Mx) > 0 && (my - My) > 0)printf("%d\n", (mx - Mx)* (my - My));
	else puts("0");
	return 0;
}

Measured memory_bytes: 128
X, Y = list(map(int, input().strip().split()))

mod = 10**9+7

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

if X>0 and Y>0 and (2*X - Y)%3 == 0 and (2*Y - X)% 3==0 and 2*Y >= X and Y <= 2*X: 
    m = int((2*X - Y)/ 3)
    n = int((2*Y - X)/ 3)
    
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    for i in range( 2, m+n + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
    ret = cmb(m+n, m, mod)
else:
    ret = 0
print(ret)


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


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

    int X;
    cin >> X;
    int ans=1;
    int x;
    for(int i=2;i<X;i++){
        for(int j=2;j<12;j++){
            x=pow(i,j);
            if(x<=X) ans=max(ans,x);
            else break;
        }
    }
    cout << ans << endl;

}

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

int main() {
  int a, b;
  string s;
  cin >> a >> b;
  cin >> s;
  bool flag = true;
  for (int i = 0; i < s.size(); i++) {
    if (i != a) {
      if (s[i] < '0' || s[i] > '9') {
        flag = false;
      }
    }
    else {
      if (s[i] != '-') {
        flag = false;
      }
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        List<Integer> list = new ArrayList<>(Arrays.asList(1,2,3));
        List<Integer> remove = new ArrayList<>();

        int a = Integer.parseInt(br.readLine());
        int b = Integer.parseInt(br.readLine());
        Collections.addAll(remove, a,b);
        
        list.removeAll(remove);

        for (Integer integer : list) {
          System.out.println(integer);
        }
      }

    }
}

Measured memory_bytes: 20692
#include<bits/stdc++.h>
using namespace std;
bool isprime(int n)
{
  if(n % 2 == 0)
    return false;
  
  for(int i = 3;i<sqrt(n);i+=2)
  {
    if(n % i == 0)
      return false;
  }
  return true;
}
void printprime(int n)
{
  for(int i=n; ;i++)
  {
	if(isprime(i))
    {
      cout<<i;
    	break;
    }
  }
}
int main()
{
  int n;
  cin>>n;
  if(n==2)
    cout<<"2";
  else  
  	printprime(n);

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int a[30];
int main()
{
	int n, m, total = 0;
	scanf("%d%d", &n, &m);
	for(int i = 0, k; i < n; ++i)
	{
		scanf("%d", &k);
		for(int j = 0, l; j < k; ++j)
		{
			scanf("%d", &l);
			++a[l - 1];
		}
	}
	for(int i = 0; i < m; ++i)
	{
		total += a[i] == n;
	}
	printf("%d\n", total);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int total = a + b + c;
		int max = Math.max(a, Math.max(b,c));

		System.out.println(total - max + max * 10);

	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
ll sum1[maxn],sum2[maxn];
ll max1[maxn],max2[maxn],max3[maxn],max4[maxn];
ll x[maxn],v[maxn];
int main()
{
    ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;
    ll c;
    ll ans=-LL_INF;
    cin>>n>>c;
    x[n+1]=c;
    for(int i=1;i<=n;i++)
        cin>>x[i]>>v[i];
    for(int i=1;i<=n;i++)
        sum1[i]=sum1[i-1]+v[i]-(x[i]-x[i-1]);
    for(int i=n;i>=1;i--)
        sum2[i]=sum2[i+1]+v[i]-(x[i+1]-x[i]);
    for(int i=1;i<=n;i++)
        max1[i]=max(max1[i-1],sum1[i]-x[i]);
    for(int i=n;i>=1;i--)
        max2[i]=max(max2[i+1],sum2[i]-(c-x[i]));
    for(int i=1;i<=n;i++)
        max3[i]=max(max3[i],sum1[i]);
    for(int i=1;i<=n;i++)
        max4[i]=max(max4[i],sum2[i]);
    ans=max(ans,max3[n]);
    ans=max(ans,max4[1]);
    for(int i=1;i<=n;i++)
        ans=max(ans,max4[i]+max1[i-1]);
    for(int i=1;i<=n;i++)
        ans=max(ans,max3[i]+max2[i+1]);
    cout<<ans<<endl;
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>
int main(){
  int i,j=0,x,count=0,g,n[100];
  scanf("%d",&g);
  for(i=0;i<g;i++)scanf("%d",&n[i]);
  for(j=0;j<g-1;j++){
    for(i=g-1;i>j;i--){
      if(n[i]<n[i-1]){
	x = n[i-1];
	n[i-1] = n[i];
	n[i] = x;
	count++;
      }}
  }
  for(i=0;i<g;i++){
        printf("%d",n[i]);
        if(i<g-1)printf(" ");
}
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 604
# coding=utf-8
import math


def divide_segment(left, right):
    """divide segment

    Args:
        left: left edge coordinate
        right: right edge coordinate

    Returns:
        divided points
    """
    delta_x_quarter = (right[0] - left[0]) / 3.0
    delta_y_quarter = (right[1] - left[1]) / 3.0

    delta_x_quarter_rotated = (delta_x_quarter - math.sqrt(3) * delta_y_quarter) / 2.0
    delta_y_quarter_rotated = (math.sqrt(3) * delta_x_quarter + delta_y_quarter) / 2.0

    s = [left[0] + delta_x_quarter, left[1] + delta_y_quarter]
    t = [left[0] + delta_x_quarter * 2.0, left[1] + delta_y_quarter * 2.0]
    u = [s[0] + delta_x_quarter_rotated, s[1] + delta_y_quarter_rotated]

    return s, t, u


def make_coch_curve(depth, left, right):
    """make coch curve with depth iteration_number between point left, right
    each vertices positions are printed

    Args:
        depth: depth
        left: left edge point
        right: right edge point

    Returns:
        None
    """
    print("{0:2.8f} {1:2.8f}".format(left[0], left[1]))
    if depth == 0:
        print("{0:2.8f} {1:2.8f}".format(right[0], right[1]))
    else:
        make_coch_curve_recursively(depth-1, left, right)


def make_coch_curve_recursively(depth, left, right):
    """recursion part of coch curve

    Args:
        depth: depth
        left: left edge coordinate
        right: right edge coordinate

    Returns:
        None
    """
    # get coordinate of divided points
    s, t, u = divide_segment(left, right)

    if depth == 0:
        print("{0:2.8f} {1:2.8f}".format(s[0], s[1]))
        print("{0:2.8f} {1:2.8f}".format(u[0], u[1]))
        print("{0:2.8f} {1:2.8f}".format(t[0], t[1]))
        print("{0:2.8f} {1:2.8f}".format(right[0], right[1]))
    else:
        make_coch_curve_recursively(depth - 1, left, s)
        make_coch_curve_recursively(depth - 1, s, u)
        make_coch_curve_recursively(depth - 1, u, t)
        make_coch_curve_recursively(depth - 1, t, right)


def main():
    depth = int(input().strip())
    make_coch_curve(depth, left=[0.0, 0.0], right=[100.0, 0.0])


if __name__ == '__main__':
    main()

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

int c[33], s[444][33];
int main() {
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    stringstream ss[2500];
    int M = -1e9, tt;
    for(int a = 0; a < 50; a++) {
        for(int b = 0; b < 50; b++) {
            int r = 0, l[33] = {};
            for(int i = 0; i < d; i++) {
                auto m = 0.;
                int t = 0;
                for(int j = 0; j < 26; j++) {
                    double p = s[i][j];
                    p += c[j] * (i + 1 - l[j]) * .02 * a;
                    for(int k = 1; k < 10; k++)
                        if(i + k < d)
                            p -= s[i + k][j] * (10 - k) * .001 * b;
                    if(p > m)
                        m = p, t = j;
                }
                ss[a * 50 + b] << t + 1 << '\n';
                l[t] = i + 1;
                r += s[i][t];
                for(int j = 0; j < 26; j++)
                    r -= c[j] * (i + 1 - l[j]);
            }
            if(r > M)
                M = r, tt = a * 50 + b;
        }
    }
    cout << ss[tt].str();
    cerr << M << endl;
    return 0;
}


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

using namespace std;

int main(){
  long long n, r=0, g=0, b=0, sm=0;
  string s;
  cin >> n >> s;
  for(long long i=0;i<n;i++){
    if(s[i]=='R')r++;
    if(s[i]=='G')g++;
    if(s[i]=='B')b++;
  }
  long long r_cnt=0, g_cnt=0, b_cnt=0;
  for(long long i=0;i<n;i++){
    if(s[i]=='R'){
      r_cnt++;
      sm += g_cnt*(b-b_cnt);
      sm += b_cnt*(g-g_cnt);
    }
    if(s[i]=='G'){
      g_cnt++;
      sm += r_cnt*(b-b_cnt);
      sm += b_cnt*(r-r_cnt);
    }
    if(s[i]=='B'){
      b_cnt++;
      sm += r_cnt*(g-g_cnt);
      sm += g_cnt*(r-r_cnt);
    }
  }
  for(int i=0;i<n-2;i++){
    for(int k=i+2;k<n;k++){
      if((i+k)%2==0 && s[i]!=s[k] && s[i]!=s[(i+k)/2] && s[k]!=s[(i+k)/2]){
        sm--;
      }
    }
  }
  cout << sm << endl;
}



Measured memory_bytes: 3580
//abc150_a.cpp
//Thu Feb  6 21:53:05 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int k,x;
	cin >> k >> x;

	if (k*500>=x){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
//	printf("%.4f\n",ans);
}

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

namespace ABC136A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ABC = Console.ReadLine().Split(' ');
            int A = int.Parse(ABC[0]);
            int B = int.Parse(ABC[1]);
            int C = int.Parse(ABC[2]);
            Console.WriteLine(Math.Max(0,C - (A - B)));
        }
    }
}


Measured memory_bytes: 27472
#include <iostream>
#include <set>
#include <cmath>
#include <tuple>
#include <vector>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	ll a,b,x;
	std::cin >> a >> b >> x;
	ll ans = b/x;
	if (a%x==0) ans = ans-a/x+1;
	else ans = ans-a/x;
	std::cout << ans << std::endl;
	return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	int ans = 0;
	int cnt_BA = 0;
	int cnt_A = 0;
	int cnt_B = 0;
	string A;

	for (int i = 0; i < N; i++)
	{
		cin >> A;
		for (int j = 1; j < A.size(); j++) {
			if (A[j - 1] == 'A'&&A[j] == 'B') {
				ans++;
			}
		}
		if (A[0] == 'B' && A[A.size() - 1] == 'A') {
			cnt_BA++;
		}
		else if (A[0] == 'B') {
			cnt_B++;
		}
		else if (A[A.size()-1] == 'A') {
			cnt_A++;
		}
	}
	if (cnt_A + cnt_B == 0 && cnt_BA > 0) {
		ans += cnt_BA - 1;
	}
	else {
		ans += cnt_BA + min(cnt_A, cnt_B);
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
    string S;
    int count1=0,count2=0,ans;
    cin >> S;

    for(int i=0;i<S.length();i++){
        if(i%2==1){
            if(S[i]=='1'){
                count1++;
            }else if(S[i]=='0'){
                count2++;
            }
        }else{
             if(S[i]=='0'){
                count1++;
            }else if(S[i]=='1'){
                count2++;
            }
        }
    }
    ans = min(count1,count2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

B = []
for i in range(m):
    B.append(int(input()))

C = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        C[i] += A[i][j]*B[j]

for i in range(n):
    print(C[i])



Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	long long A, B;
	int K;
	cin >> A >> B >> K;
	for(int cnt = 0; cnt < K; cnt++){
		if(cnt % 2 == 0){
			if(A % 2 == 1 ){
				A -= 1;
			}
			int temp = A / 2;
			A = temp;
			B += temp;
		}else{
			if(B % 2 == 1){ 
				B -= 1;
			}
			int temp = B / 2;
			A += temp;
			B = temp;
		}
	}
	cout << A << " " << B << endl;
	
	return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; ++i){
    cin >> vec.at(i);
  }
  int ans=1001001001;
  for(int i=1; i<101; ++i){
    int nans=0;
    for(int j=0; j<n; ++j){
      nans += abs(vec.at(j)-i)*abs(vec.at(j)-i);
    }
    ans = min(ans, nans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
dx, dy = abs(x1 - x2), abs(y1 - y2)

if x1 <= x2 and y1 <= y2:
    x3, y3 = x2-dy, y2+dx
    x4, y4 = x1-dy, y1+dx
elif x1 <= x2 and y1 >= y2:
    x3, y3 = x2+dy, y2+dx
    x4, y4 = x1+dy, y1+dx
elif x1 >= x2 and y1 >= y2:
    x3, y3 = x2+dy, y2-dx
    x4, y4 = x1+dy, y1-dx
elif x1 >= x2 and y1 <= y2:
    x3, y3 = x2-dy, y2-dx
    x4, y4 = x1-dy, y1-dx    
    
print(x3, y3, x4, y4)

Measured memory_bytes: 3064
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        a: [isize; n],
    }

    let mut map: HashMap<isize, usize> = HashMap::new();

    let mut count = 0;
    for (i, na) in a.iter().enumerate() {
        if let Some(n) = map.get(&(i as isize - *na)) {
            count += n;
        }
        let counter = map.entry(i as isize + *na).or_insert(0);
        *counter += 1;
    }

    println!("{}", count);
}


Measured memory_bytes: 11752
from operator import itemgetter
N = int(input())

A = [[0] * 2 for i in range(N)]
for i in range(N):
  A[i] = list(map(int, input().split()))
  
A.sort(key=itemgetter(1))

now = 0
for a in A:
  now += a[0]
  if now > a[1]:
    print('No')
    exit(0)
    
print('Yes')

Measured memory_bytes: 53656
def main():
  a,b = map(int,input().split())
  ans = check(a,b)
  print(ans)
  
def check(n,m):
    num = ""
    if n < m:
        for i in range(m):
            num = str(num) + str(n)
        return num
    elif n > m:
        for i in range(n):
            num = str(num) + str(m)
        return num
    else:
        for i in range(n):
            num = str(num) + str(m)
        return num

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll N;
  cin>>N;
ll A[N];
for(ll i=0;i<N;i++){ 
  cin>>A[i];
}
ll ans=1000;//金
ll num=0;//株
ll min=A[0];
ll max=A[0];
int flag=-1;
  
for(ll i=1;i<N;i++){
  if(A[i-1]<A[i]){//価値上昇
  max=A[i];
    if(flag==-1){
      num=ans/A[i-1];
      ans=ans-A[i-1]*num;
     //cout<<num<<"up"<<i<<endl;
    }
  flag=1;
  }
  
  if(A[i-1]>A[i]){//価値下降
    min=A[i];
      if(flag==1){
        ans=ans+A[i-1]*num;
        num=0;
        //      cout<<ans<<"down"<<i<<endl;
      }
    flag=-1;
  }
  
  
  
    
  }
  
  ans=ans+A[N-1]*num;
  
cout<<ans<<endl;

  
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	ll ret=0;
	ll B=0;
	FORR(c,S) {
		if(c=='B') B++;
		else ret+=B;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main()
{
	int n;
	cin>>n;
	char ch[n];
	int i;
	for(i=0;i<n;i++){
		cin>>ch[i];
	}
	int val[n];
	int x=0;
	for(i=0;i<n;i++){
		if(ch[i]=='I'){
			x++;
			//val[i]=x;
		}
		else{
			x--;
			//val[i]=x;
		}
		val[i]=x;
	}
	sort(val,val+n);
	//cout<<val[n-1]<<endl;
	if(val[n-1]<0){
		cout<<"0"<<endl;
	}
	else{
		cout<<val[n-1]<<endl;
	}
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#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 H, W; cin >> H >> W;
	char C[H][W];
	rep(i, H) { rep(j, W)cin >> C[i][j]; }

	for (int i = 0; i < H; i++) {
		for (int k = 0; k < 2; k++) {
			for (int j = 0; j < W; j++) {
				cout << C[i][j];
			}
			cout << endl;
		}
	}
}

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

int main(){
    vector<vector<ll> > combination(51, vector<ll>(51));
    rep(i,51){
        rep(j,51){
            combination[i][j] = 0;
        }
    }
    rep(i,51){
        combination[i][0] = 1;
        combination[i][i] = 1;
    }
    for (ll i = 2; i <= 50; i++){
        for (ll j = 1; j < i; j++){
            combination[i][j] = combination[i - 1][j - 1] + combination[i - 1][j];
        }
    }
    
    ll N, B;
    double A;
    cin >> N >> A >> B;
    ll A2 = ll(A + 0.5);
    vector<double> v1(N);
    rep(i,N) cin >> v1[i];
    vector<ll> v2(N);
    rep(i,N) v2[i] = ll(v1[i] + 0.5);
    sort(all(v2));
    sort(all(v1));
    map<ll,ll> mp;
    rep(i,N) mp[v2[i]]++;
    double ans = 0;
    rep(i,A2) ans += v1[N - 1 - i];
    cout << setprecision(15) << ans / A << endl;
    bool same = true;
    rep(i,A2 - 1){
        if (v2[N - i - 1] != v2[N - i - 2]) same = false;
    }
    if (!same){
        ll ans_sub = 0;
        for (ll i = 0; i < A2; i++){
            if (v2[N - i - 1] == v2[N - A2]) ans_sub++;
        }
        cout << combination[mp[v2[N - A2]]][ans_sub] << endl;
    }
    else{
        ll ans2 = 0;
        for (ll i = A2; i <= B; i++){
            if (v2[N - i] == v2[N - 1]) ans2 += combination[mp[v2[N - A2]]][i];
        }
        cout << ans2 << endl;
    }
}

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

#define ___ ios::sync_with_stdio(0),  cin.tie(0);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int p[31];

int main(){___
  int n;  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i){
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i){
    for (int j = 0; j < 31; ++j){
      if(a[i]&(1<<j)){
        p[j]++;
      }
    }
  }

  for (int i = 0; i < n; ++i){
    ll ans = 0;
    for (int j = 0; j < 31; ++j){
      if( ((a[i]&(1<<j)) and p[j]&1^1) or ( !(a[i]&(1<<j)) and p[j]&1 )){
        ans += (1<<j);
      }
    }
    cout << ans << " ";
  }
  cout << "\n";
  return 0;
}

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


int main() {
    int N;
    cin >> N;
    string w;
    vector<string> W;
    for (int i = 0; i < N; i++)
    {
        cin >> w;
        for (int j = 0; j < W.size(); j++)
        {
            if(w == W[j]){
                cout << "No" << endl;
                return 0;
            }
        }
        if(i!=0){
            if(w[0] != W[i-1][W[i-1].size()-1]){
                cout << "No" << endl;
                return 0;
            }
        }
        W.push_back(w);
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

	int n;
	cin>>n;
	int a[n];
     long long int ans=0;

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

	for(int i=1;i<n;i++){
             
		if(a[i]<a[i-1]){
		
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}

	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 4416
#include <math.h>

#include <algorithm>  //sort,二分探索,など
#include <array>
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <map>            //map(辞書)s
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())  // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ansl = (a + d - 1) / d;
  int answ = (c + b - 1) / b;
  if (ansl >= answ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll MOD = 1000000007;
const long long INF = 1LL << 60;
//cout<<fixed<<setprecision(10);

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;}

signed main()
{   
    //gearup;
    ll x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(all(p),greater<ll>());
    sort(all(q),greater<ll>());
    rep(i,x) r.push_back(p[i]);
    rep(i,y) r.push_back(q[i]);
    sort(all(r),greater<ll>());

    ll res = 0;
    rep(i,x+y) res += r[i];
    cout << res << endl;
}


Measured memory_bytes: 6128
n = int(input())
s_list = []
import collections

for i in range(n):
    s_list.append(input())

s_dict = collections.Counter(s_list)
maxv = max(s_dict.values())

keys = [k for k,v in s_dict.items() if v == maxv]
keys.sort()
for i in range (len(keys)):
    print(keys[i])

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

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

using namespace std;

const int MAX_Z=1e3+5;
const int MAX_N=2*1e2+5;
const long long  INF=1e15+7;
long long G[2][MAX_N][MAX_N];
int z[MAX_Z];
long long dp[MAX_Z][MAX_N];
int main(){
	int n,m;
	while(cin>>n>>m && n>0&&m>0){
	rep(l,2)rep(i,MAX_N)rep(j,MAX_N)G[l][i][j]=(i!=j)?INF:0;
	rep(i,MAX_Z)rep(j,MAX_N)dp[i][j]=INF;
	for(int i=0;i<m;i++){
		int x,y,t;
		char s;
//		scanf("%d%d%d%c",&x,&y,&t,&s);
		cin>>x>>y>>t>>s;
		if(s=='L')G[0][x][y]=G[0][y][x]=min(G[0][x][y],(long long)t);
		else G[1][x][y]=G[1][y][x]=min(G[1][x][y],(long long)t);
	}
	int r;
	cin>>r;
	for(int i=0;i<r;i++){
		cin>>z[i];
	}
	rep(l,2)rep(k,n)rep(i,n)rep(j,n)G[l][i+1][j+1]=min(G[l][i+1][j+1],G[l][i+1][k+1]+G[l][k+1][j+1]);
	dp[0][z[0]]=0;
	rep(i,r-1){
		rep(j,n){
			rep(k,n){
				if(k==j)dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][k+1]+G[0][z[i]][z[i+1]]);
				else{
					dp[i+1][j+1]=min(dp[i+1][j+1],
							dp[i][k+1]+G[0][z[i]][k+1]+G[1][k+1][j+1]+G[0][j+1][z[i+1]]);
				}
			}
		}
	}
	long long ans=INF;
	rep(i,n)ans=min(ans,dp[r-1][i+1]);
	cout<<ans<<endl;
	}
}

Measured memory_bytes: 5300
#include <iostream>
using namespace std;
int p[300000];
int main()
{
    int n, t;
    cin>>n;
    for(int i=1;i<n;i++)
    {
        cin>>t;
        p[t]++;
    }
    for(int i=1;i<=n;i++)
        cout<<p[i]<<endl;
    return 0;
}


Measured memory_bytes: 4336
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')] * N 
dp[0] = 0
for i in range(0, N):
    for j in range(1, K + 1):
        if i + j >= N:
            break
        dp[i + j] = min(dp[i] + abs(h[i] - h[i + j]), dp[i + j])
print(dp[N-1])

Measured memory_bytes: 55264
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

bool IsReverse(string str)
{
    rep(i, str.size()/2)
        if(str[i] != str[str.size()-i-1])
            return false;
    
    return true;
}

int main()
{
    int res = 0;
    string str;
    while(cin >> str)
        res += IsReverse(str);
    
    cout << res << endl;
}

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

int main(){
    long long H;
    cin >> H;
    long long k = 1;
    long long ans = 0;
    while(H > 0){
        H = H/2;
        ans += k;
        k *= 2;
    }
    cout << ans << endl;
}

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

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

int main()
{
	long long a,b;
	cin>>a>>b;
	long long c=gys(a,b);
	cout<<a*b/c;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

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

    int ans = -1;
    if (a <= 9 && b <= 9) ans = a * b;

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

Measured memory_bytes: 256
// AOJ 1042
#include<iostream>
#include<sstream>
#include<string>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int main()
{
	std::string s;
	while( std::getline( std::cin, s ), s != "END OF INPUT" )
	{
		int cnt = 0;
		bool fl = false;

		rep( i, s.size() )
		{
			if( fl && s[i] == ' ' )
				std::cout << char(cnt+'0');
			else if( !fl && s[i] == ' ' )
				std::cout << char(cnt+'0'), cnt = 0, fl = true;
			else
				++cnt, fl = false;
		}
		
		std::cout << cnt << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;
    int ans=0;
    for(int i=0;i<(int)s.size()/2;i++)if(s[i]!=s[s.size()-i-1])ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def rozwiaz(lista):
    if len(lista)==1:
        return 0
    if len(lista)==2:
        return abs(lista[0]-lista[-1])
    wynik_1 = abs(lista[0]-lista[1])+rozwiaz(lista[1:])
    wynik_2 = abs(lista[0]-lista[2])+rozwiaz(lista[2:])
    if wynik_1 < wynik_2:
        return wynik_1
    else:
        return wynik_2

def rozwiaz(lista):
    prawy, lewy = 0, abs(lista[-1] - lista[-2])
    while len(lista) > 2:
        prawy, lewy = lewy, min(prawy + abs(lista[-1] - lista[-3]),
                                lewy + abs(lista[-2] - lista[-3]))
        lista.pop()
    return lewy
    
def frog_1():
    N = wczytaj_liste()[0]
    wysokosci = wczytaj_liste()
    wynik = rozwiaz(wysokosci)
    print(wynik)
    
    
frog_1()

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

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

ll f(ll a, ll b) {
  return !a ? -b : 2 * a * (b / a) + f(b % a, a); 
}

int main() {
  ll n, x; 
  cin >> n >> x; 
  cout << n + f(n - x, x) << endl; 
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string S;

void solve(){
    cin >> S;
    ll k=0;
    rep(i,S.length()){
        k+=S[i]-'0';
        k%=9;
    }
    if(k%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int a[100];
int main()
{
    for(int i=0;i<4;i++)
        scanf("%d",&a[i]);
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) printf("YES\n");
    else printf("NO\n");
    return 0;
}


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

int N, M;
vector<P> pref[100005];
string ans[100005];

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int p, y; cin >> p >> y;
        pref[p-1].push_back(P(y, i));
    }

    for(int i=0;i<N;i++){
        sort(pref[i].begin(), pref[i].end());
        for(int j=0;j<pref[i].size();j++){
            P it = pref[i][j];
            string strp = to_string(i+1), strj = to_string(j+1);
            for(int k=0;k<6-strp.size();k++) ans[it.second] += '0';
            ans[it.second] += strp;
            for(int k=0;k<6-strj.size();k++) ans[it.second] += '0';
            ans[it.second] += strj;
        }
    }

    for(int i=0;i<M;i++) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 12416