akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
ll a[22],b[22],c[22],ans,last;
/*======================================================================*/
int main()
{
  /*
	ios_base::sync_with_stdio(0);
	cin(tie);
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  ll t=read();
  forn(i,1,t+1)
  {
  	cin>>a[i];
  }
  forn(i,1,t+1)
  {
  	cin>>b[i];
  }
  forn(i,1,t)
  {
  	cin>>c[i];
  }
  forn(i,1,t+1)
  {
  	ans+=b[a[i]];
  	if(a[i]==last+1)
  	  ans+=c[a[i]-1];
  	last=a[i];
  }
  write(ans);
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n = I()
lst = ['a','b','c','d','e','f','g','h','i','j']
cnt = n
ans = []

def dfs(s,num,kinds):
    if num == n:
        ans.append(s)
        return
    for i in range(kinds+1):
        if lst[i] in s:
            dfs(s+lst[i],num+1,kinds)
        else:
            dfs(s+lst[i],num+1,kinds+1)
    return 

dfs('',0,0)

for i in ans:
    print(i)



Measured memory_bytes: 64604
s = input()
n = len(s)
# dp[i][j]:上からi桁目で13で割った余りがjの場合の数
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
        else:
            k = int(s[i])-0
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[n][5])

Measured memory_bytes: 96048
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//つねに10億7などの剰余をとる構造体
//参考: https://www.youtube.com/watch?v=L8grWxBlIZ4&t=9858
//参考: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
int mod  = MODA;
struct modint {
	ll x;
	modint (ll x):x(x%mod){}
	modint& operator+=(const modint a){
		(x += a.x ) %= mod;
		return *this;
	}
	modint& operator-=(const modint a){
		(x -= a.x ) %= mod;
		if (x < 0) x += mod;
		return *this;
	}
	modint& operator*=(const modint a){
		(x *= a.x ) %= mod;
		return *this;
	}
	modint& operator/=(modint a){ //除算のみO(log mod)なので注意。割る数が小さいならnCrのinvを使うこと
		ll exp = mod - 2;
		while(exp > 0){ 
			if(exp & 1) *this *= a.x;
			a *= a.x;
			exp >>= 1;
		}
		return *this;
	}
	modint operator+(const modint a) const{
		modint res(*this);
		return res+=a;
	}
	modint operator-(const modint a) const{
		modint res(*this);
		return res-=a;
	}
	modint operator*(const modint a) const{
		modint res(*this);
		return res*=a;
	}
	modint operator/(const modint a) const{
		modint res(*this);
		return res/=a;
	}
};
modint modpow(modint x, ll n){
	modint res=1;
	while(n > 0){
		if(n & 1) res = res * x.x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

int main() {
	modint ans = 1;
	int tmp;
	int n;
	cin >> n;
	REP1(i, n){
		ans *= i;
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
s, w = (0, 100 * A)
water_list = [False] * (6000)
sugar_list = [False] * (6000)
water_list[0] = True
sugar_list[0] = True
for i in range(F):
    water_list[i + A * 100] = water_list[i + A * 100] or water_list[i]
    water_list[i + B * 100] = water_list[i + B * 100] or water_list[i]
    sugar_list[i + C] = sugar_list[i + C] or sugar_list[i]
    sugar_list[i + D] = sugar_list[i + D] or sugar_list[i]

for wi in range(0, F + 1, 100):
    for si in range(F + 1):
        if si * 100 <= wi * E and si + wi <= F and water_list[wi] and sugar_list[si]:
            if si * (s + w) > s * (si + wi):
                s, w = (si, wi)
print('{} {}'.format(s + w, s))


Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        Input input = InputParser.perse(sn, 2);
        sn.close();

        Integer n = input.getInt(1, 1);
        List<Integer> p = input.getIntLine(2);

        int min = 200000;
        int count = 0;
        for(Integer e : p) {
            if (e <= min) {
                count++;
                min = e;
            }
        }
        System.out.println(count);
    }

    private static class InputParser {
        static Input perse(Scanner sn, int line) {
            Input result = new Input();
            while (line-- > 0) {
                String[] args = sn.nextLine().split(" ");
                result.addAll(args);
            }
            return result;
        }
    }

    private static class Input {
        private Map<Integer, Map<Integer, String>> inputs;
        private int now = 1;
        private int innerNext = 1;

        Input() {
            inputs = new HashMap<>();
            inputs.put(now, new HashMap<>());
        }

        void addAll(String[] args) {
            for (String str : args) {
                add(str);
            }
            next();
        }

        void add(String str) {
            inputs.get(now).put(innerNext++, str);
        }

        void next() {
            inputs.put(++now, new HashMap<>());
            innerNext = 1;
        }

        String getString(int i, int j) {
            return inputs.get(i).get(j);
        }

        int getInt(int i, int j) {
            return Integer.parseInt(getString(i, j));
        }

        double getDouble(int i, int j) {
            return Double.parseDouble(getString(i, j));
        }

        List<Integer> getIntLine(int i) {
            Map<Integer, String> m = inputs.get(i);
            Integer[] l = new Integer[m.size()];
            m.entrySet().stream().forEach(e -> {
                l[e.getKey() - 1] = Integer.parseInt(e.getValue());
            });
            return Arrays.asList(l);
        }

        List<Integer> getIntVerticalLine(int line, int start, int size) {
            List<Integer> list = new ArrayList<>();
            for(int i = start; i < start + size; i++) {
                list.add(getInt(i, line));
            }
            return list;
        }
    }
}


Measured memory_bytes: 70652
a, b, k = map(int, input().split())
if a<=k and b<k-a:
    print(0, 0)

elif a <= k:
    TAKA = 0
    AOKI = b-(k-a)
    print(TAKA, AOKI)
else:
    TAKA = a-k
    AOKI = b
    print(TAKA, AOKI)

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

int main()
{
    int n,k[100];
    cin >> n;

    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x, y;
	cin >> x >> y;

	int i = 0;
	while(x <= y) {
		x *= 2;
		i++;
	}
	cout << i << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        System.out.println(solve(N));
    }

    private static long solve(long N) {
        if (N%2 != 0) return 0;
        long ans = 0;

        for (long count=10; count<=N; count*=5) {
            ans += N/count;
        }

        return ans;
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
bool f[82][82][12810];
int n, m, w[82][82], b = 6400;
int main(){

    cin>>n>>m;
    int a;
    for(int i = 1;i <= n; i++){
        for(int j = 1;j <= m; j++){
            cin>>a;
            w[i][j] = a;
        }
    }
    for(int i = 1;i <= n; i++){
        for(int j = 1;j <= m; j++){
            cin>>a;
            w[i][j] -= a;
        }
    }
    
    f[1][1][w[1][1]+b] = f[1][1][-w[1][1]+b] = 1;
    //printf("w11=%d\n", w[1][1]);
    for(int i = 1;i <= n; i++){
        for(int j = 1;j <= m; j++){
            for(int k = 0;k <= 12800; k++){
                if(!f[i][j][k])continue;
                k -= b;
                int to1 = w[i+1][j] + k;
                int to2 = -w[i+1][j] + k;
                int to3 = w[i][j+1] + k;
                int to4 = -w[i][j+1] + k;
                //printf("i=%d j=%d k=%d to1=%d to2=%d to3=%d to4=%d\n", i, j, k + b, to1, to2, to3, to4);
                k += b;
                if(abs(to1) <= b)f[i+1][j][to1 + b] |= 1;
                if(abs(to2) <= b)f[i+1][j][to2 + b] |= 1;
                if(abs(to3) <= b)f[i][j+1][to3 + b] |= 1;
                if(abs(to4) <= b)f[i][j+1][to4 + b] |= 1;
            }
        }
    }
    int ans = 14111;
    for(int i = 0;i <= 12800; i++){
        if(f[n][m][i]){
            ans = min(ans, abs(i - b));
            //printf("i=%d\n", i);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 83072
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>=1&&a<=9&&b>=1&&b<=9)
	{
		cout<<a*b<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
struct STUDENT {
  int mid_res;
  int fin_res;
  int re_res;
};

int main(void) {
  struct STUDENT students[100000];

  int m, f, r;
  int i, num = 0;

  do {
    scanf("%d %d %d", &m, &f, &r);
    students[num].mid_res = m;
    students[num].fin_res = f;
    students[num].re_res = r;
    num++;
  } while (!(m == -1 && f == -1 && r == -1));

  // for (i = 0; i < num; i++) {
  //   printf("(%3d) (%3d) (%3d)\n", students[i].mid_res, students[i].fin_res, students[i].re_res);
  // }

  for (i = 0; i < num - 1; i++) {
    // printf("(%d)\n", i);
    int sum = students[i].mid_res + students[i].fin_res;
    if (students[i].mid_res == -1 || students[i].fin_res == -1) {
      printf("F\n");
    } else if (80 <= sum) {
      printf("A\n");
    } else if (65 <= sum) {
      printf("B\n");
    } else if (50 <= sum) {
      printf("C\n");
    } else if (30 <= sum) {
      if (50 <= students[i].re_res) {
        printf("C\n");
      } else {
        printf("D\n");
      }
    }else {
      printf("F\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>

#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2];
int R[MAX/2+2];
int count;
void merge(int A[],int n,int left,int mid,int right);
void mergesort(int A[],int n,int left,int right);

int main(){
  int A[MAX];
  int N,i;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  mergesort(A,N,0,N);
  
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1)printf(" ");    
  }
  printf("\n");
  printf("%d",count);
  printf("\n");
  return 0;
  
}
void merge(int A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1;
  int n2;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0,j=0;
  for(k=left;k<right;k++){
      count++;
      if(L[i]<=R[j]){

	A[k]=L[i];
	i++;
      }
      else{
	A[k]=R[j];
	j++;
      }
    }
  }

void mergesort(int A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}
  



Measured memory_bytes: 5704
l =int(input())
s =input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
A = r * g * b
B = 0
gapmax = (l - 3) // 2
for _ in range(gapmax+1):
  for i in range(l-2-2*_):
    c1, c2, c3 = s[i], s[i+1+_],s[i+2+2*_]
    if not (c1 == c2) and not (c1 == c3) and not (c2 ==c3):
      B += 1
      
print(A-B)

Measured memory_bytes: 9136
result=[]
n=gets.chomp.to_s
len=n.length-1

for i in 0..(2**len)-1
    plus=Array.new(len,0)
    ans=[]

    i=i.to_i
    for j in 0..len-1
       
        if (i&(1<<j))!=0
         plus[j]="+"
         else
         next
         end
    end
    
    for k in 0..n.length-1
    ans<<n[k]
    if plus[k]=="+"
    ans<<plus[k]
    end

    end
    
    
    result<<ans
end

answer=0

for i in 0..result.length-1
    v=0
    check=0
    for j in 0..result[i].length-1
    
        if result[i][j]=="+"
            v+=check.to_i
            check=0
        else
        check="#{check}#{result[i][j]}"
        end
    end
    if check!=0
        v+=check.to_i
    end

    answer+=v
end
p answer

Measured memory_bytes: 14864
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  if(count(all(A), 1) == 0) {
    cout << -1 << endl;
    return 0;
  }

  i64 now = 1;
  rep(i,0,N) {
    if(A[i] == now) {
      now++;
    }
  }
  cout << N - now + 1 << endl;
}


Measured memory_bytes: 1792
from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)

for i in a:
    d[i] += 1
    d[i-1] += 1
    d[i+1] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
print(d[0][1])

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

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		int x,y,b,p;
		cin >> x>>y>>b>>p;
		cout << min((double)(x*b+y*p), (5*x+y*2 + max(0,b-5)*x+ max(0, p-2)*y)*0.8) <<endl;
	}
	return 0;
}


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

P = []
for n in range(N):
  P.append(int(input()))

P.sort(reverse=True)

ans = 0
for i in range(len(P)):
  if i == 0:
    ans += int(P[0] / 2)
  else:
    ans += P[i]
    
print(ans)

Measured memory_bytes: 3060
using System;

namespace _0136
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] h = new int[6];
            for (int i = 0; i < n; i++)
            {
                double now = double.Parse(Console.ReadLine());
                if (now < 165)
                {
                    h[0]++;
                }
                else if (now < 170)
                {
                    h[1]++;
                }
                else if (now < 175)
                {
                    h[2]++;
                }
                else if (now < 180)
                {
                    h[3]++;
                }
                else if (now < 185)
                {
                    h[4]++;
                }
                else
                {
                    h[5]++;
                }
            }
            for (int j = 0; j < 6; j++)
            {
                Console.Write((j+1) +":");
                for (int i = 0; i < h[j]; i++)
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
}

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

typedef long long ll;

const int N = 1010;
const int K = 22;
const ll EAtxdy = 1000000007;

using namespace std;

ll n, k;
ll a[K], factorial[N];
ll dp[K][N];
ll combination[N][N];

inline ll read() {
	ll x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {
		if (c == '-') f = -1;
		c = getchar();
	}
	while (isdigit(c)) {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}

void init() {
	for (ll i = 0; i <= n; i++) {
		for (ll j = i; j <= n; j++) {
			if (i == 0) combination[j][i] = 1;
			else combination[j][i] = (combination[j - 1][i] + combination[j - 1][i - 1]) % EAtxdy;
		}
	}
}

signed main() {
	n = read(), k = read();
	init();
	for (ll i = 1; i <= k; i++) {
		a[i] = read();
	}
	dp[0][0] = 1;
	for (ll i = 0; i < k; i++) {
		for (ll j = 0; j <= n; j++) {
//			printf("%lld ", dp[i][j]);
			for (ll f = 0; f <= a[i + 1] && f + j <= n; f++) {
				dp[i + 1][j + f] = (dp[i + 1][j + f] % EAtxdy + dp[i][j] * combination[n - j][f] % EAtxdy * combination[n - f][a[i + 1] - f] % EAtxdy + EAtxdy) % EAtxdy;
			}
		}
//		puts("");
	}
	printf("%lld\n", dp[k][n] % EAtxdy);
	return 0;
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  for(;;){
    a-=d;
    c-=b;
    if(c<=0){
      cout<<"Yes";
      return 0;
    }else if(a<=0){
      cout<<"No";
      return 0;
    }
  }
}


Measured memory_bytes: 3632
import java.util.Random;
import java.util.Scanner;

public class Main 
{	
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);

		int[] n = new int[6];
		for(int i=0; i<6; i++)
		{
			n[i] = scanner.nextInt();
		}
		
		int q = scanner.nextInt();
		
		for(int i=0; i<q; i++)
		{
			int[] in = new int[2];
			in[0] = scanner.nextInt();
			in[1] = scanner.nextInt();
			
			for(;;)
			{
				Random random = new Random();
				int d = random.nextInt(4);
				
				int[] buf = new int[6];
				for(int j=0; j<6; j++)
				{
					buf[j] = n[j];
				}
					
				switch(d)
				{
					case 0:
						n[0] = buf[4];
						n[1] = buf[0];
						n[5] = buf[1];
						n[4] = buf[5];
						break;
					case 1:
						n[0] = buf[1];
						n[1] = buf[5];
						n[5] = buf[4];
						n[4] = buf[0];
						break;
					case 2:
						n[0] = buf[2];
						n[2] = buf[5];
						n[5] = buf[3];
						n[3] = buf[0];
						break;
					case 3:
						n[0] = buf[3];
						n[3] = buf[5];
						n[5] = buf[2];
						n[2] = buf[0];
						break;
				}
				if(in[0]==n[0] && in[1]==n[1])
				{
					System.out.println(n[2]);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 26276
import java.util.Scanner;

public class Main {
  public static String[] str = new String[3];

  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);

    str[0] = scn.next();
    str[1] = scn.next();
    str[2] = scn.next();

    int num = 0;

    while(num >= 0) {
      num = play(num);
    }

    num += 3;

    switch (num) {
      case 0:
        System.out.println("A");
        break;
      case 1:
        System.out.println("B");
        break;
      case 2:
        System.out.println("C");
        break;
      default:
        break;
    }
  }

  public static int play(int n) {
    if (str[n].length() == 0) {
      return n-3;
    }

    char nextPlayer = str[n].charAt(0);

    str[n] = str[n].substring(1, str[n].length());

    switch (nextPlayer) {
      case 'a':
        n = 0;
        break;
      case 'b':
        n = 1;
        break;
      case 'c':
        n = 2;
        break;
      default:
        break;
    }

    //System.out.printf("A:%s\tB:%s\tC:%s\t%c\t%d\n", str[0], str[1], str[2], nextPlayer, n);

    return n;
  }
}


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

int main() {
  string S;
  cin >> S;
  int plus = 0;
  int minus = 0;
  for (int i=0; i<S.size(); i++) {
    if (S.at(i)=='+') {
      plus++;
    }
    if (S.at(i)=='-') {
      minus++;
    }
  }
  int answer = plus-minus;
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br   = null;

	static {
		br   = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String	strPrime = null;
		int		nPrime   = 0;
		int		nMax     = 0;

		while ((strPrime = parseNum()) != null) {
			int	nSum = 0;

			nPrime = Integer.parseInt(strPrime);
			nMax   = 600 / nPrime - 1;
			nSum   = (nPrime * nPrime * nPrime * nMax * (nMax + 1) * (2 * nMax + 1)) / 6;

			System.out.println(nSum);
		}
	}

	private static String parseNum() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 16932
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=305;
int n,m,i,j,a[N][N],at[N],g[N],ans;bool ct[N];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
int main(){
	for (n=read(),m=read(),i=1;i<=n;i++)
		for (j=1;j<=m;j++) a[i][j]=read();
	for (ans=n,i=1;i<=n;i++) at[i]=1,g[a[i][1]]++;
	for (int turns=1;turns<=m;turns++){
		int x=0;
		for (i=1;i<=n;i++)
			if (g[a[i][at[i]]]>g[x]) x=a[i][at[i]];
		ans=min(ans,g[x]);ct[x]=1;
		for (i=1;i<=n;i++){
			g[a[i][at[i]]]--;
			for (;ct[a[i][at[i]]];at[i]++);
			g[a[i][at[i]]]++;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

static class Program
{
    static void Solve(IO io)
    {
        var n = io.I;
        var a = io.Is(n);

        var set = new HashSet<int>() { 1 };
        var next = 1;
        var cnt = 0;

        for (; next != 2; cnt++)
        {
            next = a[next - 1];

            if (!set.Add(next))
            {
                io.Write(-1);
                return;
            }
        }

        io.Write(cnt);
    }

    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO(In));
        Out.Flush();
    }
}

static class Extentions
{
}

class IO
{
    int idx;
    string[] input;

    public IO(TextReader reader)
    {
        input = reader.ReadToEnd().Split(new[] { " ", "\n", "\r" },
            StringSplitOptions.RemoveEmptyEntries);
    }

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

Measured memory_bytes: 23904
use proconio::input;

fn main() {
    input! {
        x: i32,
      	n: usize,
      	mut arr: [usize;n]
    };

  	let mut index = 0;
  	let mut min = x;
  	let mut temp_vec: Vec<i32> = Vec::with_capacity(101);
  
  	for i in 0..=101 {
  		temp_vec.push((i - x).abs());
  	}
  
	for i in 0..n {
      	temp_vec[arr[i]] = 201;
  	}
  	
    for i in 0..=101 {
    	if temp_vec[i] < min {
      		index = i;
          	min = temp_vec[i];
      	}
  	}
 	
    println!("{}", index);
}

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

int main()
{
    int n;
    cin >> n;
    int a1[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a1[i];
    }
    int m;
    cin >> m;
    int a2[m];
    for (int i = 0; i < m; i++)
    {
        cin >> a2[i];
    }
    cout << includes(a1, a1 + n, a2, a2 + m) << endl;
    return 0;
}


Measured memory_bytes: 4624
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n = read_line().split("").filter(|x| x != &"")
                        .map(|x|x.parse().unwrap()).collect::<Vec<i32>>();
    let sum:i32 = n.iter().sum();
    println!("{}",sum);
}

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

int dfs(vector<int> V, vector<int> C, int cost, int i) {
  if (i == V.size()) return cost;
  return max(dfs(V, C, cost, i + 1), dfs(V, C, cost + (V.at(i) - C.at(i)), i + 1));
}

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; ++i) cin >> V.at(i);
  for (int i = 0; i < N; ++i) cin >> C.at(i);
  cout << dfs(V, C, 0, 0) << endl;
  return 0;
}


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

typedef long long   ll;

vector< int > common_divisors;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b, k;
    
    cin >> a >> b >> k;
    
    for(int i = 1 ; i <= 100 ; i++){
        if(a % i == 0 && b % i == 0){
            common_divisors.push_back(i);
        }
    }
    
    cout << common_divisors[common_divisors.size() - k] << endl;
    
	return 0;
}


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

using namespace std;

int N, ans, a[100009], b[100009];
map < int, int > mp;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]), b[i] = a[i];
sort (b + 1, b + N + 1);
for (int i=1; i<=N; i++)
    mp[b[i]] = i;
for (int i=1; i<=N; i++)
    if (mp[a[i]] % 2 != i % 2)
        ans ++;
printf ("%d\n", ans / 2);
return 0;
}


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

int main() {
  int N;
  cin >> N;
  set<int> s;
  for (int i = 0; i < N; i++) {
    int r;
    cin >> r;
    if (s.find(r) == s.end())
      s.insert(r);
    else
      s.erase(s.find(r));
  }

  cout << s.size() << endl;

  return 0;
}

Measured memory_bytes: 4864
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort(key=lambda x:(x[1], x[0]))

ans = 0
pre_bridge = 0
for i in range(m):
    a, b = ab[i]
    if pre_bridge < a:
        ans += 1
        pre_bridge = b-1
print(ans)

Measured memory_bytes: 66968
n = int(input())
nums = list(map(int, input().split()))

nums1 = nums[0::2]
nums2 = nums[1::2]

bug1 = [0] * 100001
bug2 = [0] * 100001

for num in nums1:
    bug1[num] += 1

for num in nums2:
    bug2[num] += 1

max_v_1 = max(bug1)
max_i_1 = bug1.index(max_v_1)
max_v_2 = max(bug2)
max_i_2 = bug2.index(max_v_2)

if max_i_1 == max_i_2:
    bug1[max_i_1] = 0
    bug2[max_i_2] = 0
    sec_max_v_1 = max(bug1)
    sec_max_v_2 = max(bug2)
    print(n - max(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))
else:
    print(n - max_v_1 - max_v_2)

Measured memory_bytes: 14276
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  ll n,m; cin >>n >>m;
  vector<pair<ll,ll>>v(n); ll ans=0;
  for(int i=0; i<n; i++){
    ll a,b; cin >>a >>b;
    v[i].first=a; v[i].second=b;
  }
  sort(v.begin(),v.end());
  for(int i=0; i<n; i++){
    ans+=min(m,v[i].second)*v[i].first;
    m-=min(m,v[i].second);
    if(!m) break;
  }
  cout <<ans;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 4756
#include<stdio.h>
int main()
{
    char a[1000];
    int i,sum;
    while(1)
    {
        scanf("%s",&a);
        if(a[0]=='0')
        {
            return 0;
        }
        sum = 0;
        for(i=0;a[i]!='\0';i++)
        {
            sum+=a[i]-'0';
        }
        printf("%d\n",sum);
}
return 0;
    }



Measured memory_bytes: 2128
#!/usr/bin/env python

n = int(input())

# Eratosthenes' sieve
is_prime = [True for _ in range(100)]
is_prime[0] = is_prime[1] = False
for i in range(100):
    if not is_prime[i]:continue 
    for j in range(i*i, 100, i): 
        if not is_prime[j]: 
            is_prime[j] = False

factor = [0 for _ in range(100)]
for i in range(2, n+1):
    for j in range(2, 100):
        if is_prime[j]:
            while i%j == 0:
                factor[j] += 1
                i //= j

#print('is_prime =', is_prime)
#print('factor =', factor)

fs = []
for i in range(100):
    if factor[i] != 0:
        fs.append(factor[i])

#print('fs =', fs)

m = len(fs)
ans = [0 for _ in range(4)]
for i in range(m):
    for j in range(m):
        for k in range(m):
            if i!=j and j!=k and k!=i:
                if fs[i] >= 4 and fs[j] >= 4 and fs[k] >=2:
                    ans[0] += 1
#                    print('fs[{}] = {}, fs[{}] = {}, fs[{}] = {}'.format(i, fs[i], j, fs[j], k, fs[k]))
for i in range(m):
    if fs[i] >= 74: 
        ans[1] += 1
#        print('fs[{}] = {}'.format(i, fs[i]))
for i in range(m):
    for j in range(m):
        if i!=j:
            if fs[i] >= 2 and fs[j] >= 24: 
                ans[2] += 1
#                print('fs[{}] = {}, fs[{}] = {}'.format(i, fs[i], j, fs[j]))
for i in range(m):
    for j in range(m):
        if i!=j:
            if fs[i] >= 4 and fs[j] >= 14: 
                ans[3] += 1
#                print('fs[{}] = {}, fs[{}] = {}'.format(i, fs[i], j, fs[j]))

Ans = ans[0]//2 + ans[1] + ans[2] + ans[3]
print(Ans)

Measured memory_bytes: 9324
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
fn main() {
    use std::collections::HashSet;
    input! { n: usize, m: usize, a: [[usize1]; n] }
    let mut ret = (0..m).collect::<HashSet<usize>>();
    for arr in a {
        let set :HashSet<usize> = arr.iter().cloned().collect();
        ret = ret.intersection(&set).cloned().collect::<HashSet<usize>>();
    }
    println!("{}", ret.len());
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long

int main(void)
{
	int l, r, d, ans;
	scanf("%d %d %d", &l, &r, &d);
	ans = (r / d) - (l / d);
	if (l % d == 0)
		ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<map>
#include <iomanip>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define Yes(a) if(a)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, 0, n)cin >> s[i];
	sort(s);
	vector<int> x(n, 1);
	rep(i, 0, n - 1)if (s[i] == s[i + 1])x[i+1]+=x[i];
	int a = 0;
    rep(i, 0, n)a=max(a, x[i]);
	rep(i, 0, n)if (a == x[i])cout << s[i] << endl;


	return 0;
}

Measured memory_bytes: 15104
#include <stdio.h>


int main(void)
{
	int n, i, j,v;
	int A[100];

	/*???°?????\???*/
	 scanf("%d", &n);
	 for (i = 0; i < n; i++)
	 {
		 scanf("%d", &A[i]);
	 }

	 /**/
	 for (i = 0; i < n; i++)
	 {
		 v = A[i];
		 j = i - 1;

		 while (j >= 0 && A[j] > v)
		 {
			 A[j + 1] = A[j];
			 j--;
		 }
		 A[j + 1] = v;

		 for (j = 0; j < n; j++)
		 {
			 if (j != 0)
			 {
				 printf(" ");
			 }

			 printf("%d", A[j]);
		 }

		 printf("\n");
	 }
			

		
		return 0;
}

Measured memory_bytes: 1832
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF 99999999 
using namespace std;
 
int main()
{
    ll N,K; cin >> N >> K;
    ll ans = 0;
    for (int i = K; i <= N+1; i++)
    {
        ans += i*(N+1-i)+1;
        ans %= MOD;
    }
    cout << ans << endl;
    
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int sumh[101010], sumw[101010];

int main() {
    int N, W, H;
    cin >> N >> W >> H;
    rep(i, N) {
        int x, y, w;
        cin >> x >> y >> w;
        sumw[max(0, x-w)]++;
        sumw[min(W, x+w)]--;
        sumh[max(0, y-w)]++;
        sumh[min(H, y+w)]--;
    }

    for (int i=1; i<W; ++i) {
        sumw[i] += sumw[i-1];
    }
    for (int i=1; i<H; ++i) {
        sumh[i] += sumh[i-1];
    }

    bool ok1 = true;
    for (int i=0; i<W; ++i) {
        if (sumw[i] <= 0) {
            ok1 = false;
            break;
        }
    }

    bool ok2 = true;
    for (int i=0; i<H; ++i) {
        if (sumh[i] <= 0) {
            ok2 = false;
            break;
        }
    }
    
    cout << (ok1 ? "Yes" : (ok2 ? "Yes" : "No")) << endl;
}



Measured memory_bytes: 3876
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    string s,t;
    cin>>s>>t;

    int ans=0;
    rep(i,3){
        if(s[i]==t[i])++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//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() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x
//最大化問題最小化問題
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(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    string S;
    cin >> S;

    ll c = S.size();
    if(S[c-1]=='s')cout << S+"es" ;
    else cout << S + "s"; 

    //本文
    //出力
    //cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;

  vector<int >dp(n,INT_MAX),v(n,0);
  dp[0]=0;
  for(int i=0;i<n;i++)
     cin>>v[i];
  
    for(int i=0;i<n;i++)
    {
      for(int j=i+1;j<=i+k;j++)
      {if(j<n)
        dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
      }
    }   
    

cout<<dp[n-1];
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int H, W;

int Ch, Dh, Cw, Dw;
string S[1003];

int dis[1003][1003];

priority_queue < pair<int, pair<int, int> > > PQ;
int INF = 99999999;
int main(void) {

	cin >> H >> W;

	cin >> Ch >> Cw;
	cin >> Dh >> Dw;

	for (int i = 1; i <= H; i++) {
		cin >> S[i];
		S[i] = "#" + S[i] + "#";
	}

	for (int i = 0; i <= H + 1; i++) {
		S[0] += "#";
		S[H + 1] += "#";
	}

	for (int i = 0; i <= H + 1; i++) {
		for (int j = 0; j <= W + 1; j++) {
			dis[i][j] = INF;
		}
	}

	dis[Ch][Cw] = 0;
	PQ.push(make_pair(-0, make_pair(Ch, Cw)));

	pair<int, pair<int, int> > P;

	while (PQ.size()) {
		P = PQ.top(); PQ.pop();

		int d = -P.first;
		int x = P.second.first;
		int y = P.second.second;

		if (dis[x][y] != d) { continue; }

		if (x - 1 >= 1 && S[x - 1][y] == '.') { if (dis[x - 1][y] > dis[x][y]) { dis[x - 1][y] = min(dis[x - 1][y], dis[x][y]); PQ.push(make_pair(-dis[x - 1][y], make_pair(x - 1, y))); } }
		if (x + 1 <= H && S[x + 1][y] == '.') { if (dis[x + 1][y] > dis[x][y]) { dis[x + 1][y] = min(dis[x + 1][y], dis[x][y]); PQ.push(make_pair(-dis[x + 1][y], make_pair(x + 1, y))); } }
		if (y - 1 >= 1 && S[x][y - 1] == '.') { if (dis[x][y-1] > dis[x][y]) { dis[x][y - 1] = min(dis[x][y - 1], dis[x][y]); PQ.push(make_pair(-dis[x][y - 1], make_pair(x, y - 1))); } }
		if (y + 1 <= W && S[x][y + 1] == '.') { if (dis[x][y + 1] > dis[x][y]) { dis[x][y + 1] = min(dis[x][y + 1], dis[x][y]); PQ.push(make_pair(-dis[x][y + 1], make_pair(x, y + 1))); } }


		for (int i = x - 2; i <= x + 2; i++) {
			for (int j = y - 2; j <= y + 2; j++) {
				if (1 <= i && i <= H && 1 <= j && j <= W && S[i][j] == '.') {
					if (dis[i][j] > dis[x][y] + 1) {
						dis[i][j] = min(dis[i][j], dis[x][y] + 1);
						PQ.push(make_pair(-dis[i][j], make_pair(i, j)));
					}
				}
			}
		}

	}

	int ans=-1;
	if (dis[Dh][Dw] >= INF) { ans = -1; }
	else { ans = dis[Dh][Dw]; }

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		sc.close();

		if(A.length() > B.length()) {
			System.out.println("GREATER");
			return;
		}else if(A.length() < B.length()) {
			System.out.println("LESS");
			return;
		}else {
			for(int i = 0; i < A.length(); i++) {
				if(A.charAt(i) == B.charAt(i)) {
					if(i == A.length() - 1) {
						System.out.println("EQUAL");
						return;
					}else {
						continue;
					}
				}else {
					if(A.charAt(i) > B.charAt(i)) {
						System.out.println("GREATER");
						return;
					}else if(A.charAt(i) < B.charAt(i)) {
						System.out.println("LESS");
						return;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 21588
N = int ( input () )
l = input().split()
s = []
for i in range (N):
    a = int ( l[i] )
    o = 0
    while True:
        b = a%2
        if b == 0:
            a = a/2
            o += 1
        else:
            s.append (o)
            break
print ( min (s) )

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif


int main(void)
{
	ll n, a, b; cin >> n >> a >> b;

	cout << min(n * a, b);

	return 0;
}

Measured memory_bytes: 256
import math
N,Y = map(int,input().split())
ans = 0
a,b,c = 0,0,0
for i in range(N + 1):
  for j in range(i + 1,N + 2):
    if abs(Y - ans) > abs(Y - (1000 * i + 5000 * (j - i - 1) + 10000 * (N + 1 - j))):
      ans = (1000 * i + 5000 * (j - i - 1) + 10000 * (N + 1 - j))
      a,b,c = i, j - i - 1, N + 1 - j
if ans == Y:
  print(c,b,a)
else:
  print(-1,-1,-1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, g, b;
	cin >> r >> g >> b >> n;
	int ans = 0;
	for (int f = 0; f * r <= n; f++) {
		for (int s = 0; f * r + s * g <= n; s++) {
			ans += (n - f * r - s * g) % b == 0;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3156
//use rand::Rng;
//use std::cmp::Ordering;
//use std::io;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).expect("read_line error");

    let mut parts = s.split_whitespace().map(|s| s.parse::<i32>());
    match (parts.next(), parts.next(), parts.next()) {
        (Some(Ok(a)), Some(Ok(b)), Some(Ok(c))) => {
            if a + b + c >= 22 {
                println!("bust")
            } else {
                println!("win")
            }

        }
        // handle other problems: not enough numbers, numbers are invalid, etc
        _ => {}  // ignore invalid input
    }
}



Measured memory_bytes: 4352
n=gets.to_i
h=Hash.new(0)
a=gets.split.map &:to_i
a.each do |e|
  h[e]+=1
end
b=[0,0]
g=h.length
h.each do |e,v|
  vv=v
  if v>=3
    vv=v%2
    vv=2 if vv==0
  end
  if vv%3==0 || vv%3==1
    b[0]+=1
  else
    b[1]+=1
  end
end
if g==1
  p 1
else
p b[1]%2==0 ? g:g-1
end

Measured memory_bytes: 14604
//password1488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5+228;

signed main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    long double a, b, c;
    cin >> a >> b;
    c = a*b;
    string ss = to_string(c);
    for(auto i : ss){
        if(i=='.') break;
        cout<<i;
    }
}

Measured memory_bytes: 3852
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector <char> v;
vector<int> num;

int main(){
  int a ,b,c,k ,A,B,C;
  int ans;
  cin >> a>>b>>c>>k;
  A =a;
  B =b;
  C =c;

  for(int i= 0;i< k;i++){
    A = A*2;
    B = B*2;
    C = C*2;
  }
ans = max(A+b+c,a+B+c);
ans = max(ans,a+b+C);

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


Measured memory_bytes: 256