akhauriyash/Code-Regression huggingface dataset:
using System;

class _0039
{
    enum Rome { I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, M = 1000 };
    public static void Main()
    {
        string str;
        int sum;
        while ((str = Console.ReadLine()) != null)
        {
            sum = 0;
            for (int i = 0; i < str.Length; i++)
            {
                if (i != str.Length - 1 && Arabia(str[i + 1]) > Arabia(str[i])) sum += -Arabia(str[i]);
                else sum += Arabia(str[i]);
            }
            Console.WriteLine(sum);
        }
    }
    static int Arabia(char rome)
    {
        switch (rome)
        {
            case 'I': return 1;
            case 'V': return 5;
            case 'X': return 10;
            case 'L': return 50;
            case 'C': return 100;
            case 'D': return 500;
            case 'M': return 1000;
        }
        return 0;
    }
}

Measured memory_bytes: 5544
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
map<int, int> mp;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    int ai;
    cin >> ai;
    mp[ai - 1]++;
    mp[ai]++;
    mp[ai + 1]++;
  }

  int ans = 0;
  for (auto v : mp) {
    ans = max(ans, v.second);
  }

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

Measured memory_bytes: 4736
#include <cstdio>

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

	int a[100001];
	int num;
	int i, j;

	for (i = 0; i < 100001; i++) {
		a[i] = 0;
	}

	for (i = 0; i < n; i++) {
		scanf("%d", &num);
		a[num]++;
	}


	long long sum;
	for (i = 0, sum = 0; i < 100001; i++) {
		sum += a[i] * i;;
	}

	int q;
	scanf("%d", &q);

	int b[q], c[q];

	for (i = 0; i < q; i++) {
		scanf("%d%d", &b[i], &c[i]);
	}

	for (i = 0; i < q; i++) {
		sum = sum + (c[i] - b[i]) * a[b[i]]; 
		a[c[i]] += a[b[i]];
		a[b[i]] = 0;
		printf("%lld\n", sum);
	}


	return 0;
}

Measured memory_bytes: 2880
#include <iostream>                                             
#include <cstdio>                                               
#include <cmath>                                                
using namespace std;                                            
                                                                
int main() {                                                    
  double n, x[1001], y[1001];                                   
  double sum, d, p, max=0;                                      
  cin >> n;                                                     
  for (int i=0; i<n; i++) {                                     
    cin >> x[i];                                                
  }                                                             
  for (int i=0; i<n; i++) {                                     
    cin >> y[i];                                                
  }                                                             
  int i;                                                        
  for (p=1; p<4; p++) {                                         
    for (i=0,sum=0; i<n; i++) {                                 
      sum += pow(fabs(x[i]-y[i]),p);                            
      if (max<fabs(x[i]-y[i])) {                                
        max = fabs(x[i]-y[i]);                                  
      }                                                         
    }                                                           
    d = pow(sum,1.0/p);                                         
    printf("%.6f\n", d);                                        
  }                                                             
  printf("%.6f\n", max);                                        
  return 0;                                                     
}                                                               
                                                                
                                                                
                               

Measured memory_bytes: 3416
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = scan!(i64, i64);
    if a + b >= 10 {
        println!("error")
    } else {
        println!("{}", a + b)
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
string a,b;
vector<int> zzz[26],zz[26][26],z[26][26][26],s;

void PRE(){
	string t;cin>>t;
	for(int i=0;i<t.size();i++)s.push_back(t[i]-'a');
	for(int i=0;i<t.size();i++){
		zzz[s[i]].push_back(i);
		if(i)zz[s[i-1]][s[i]].push_back(i-1);
		if(i>1)z[s[i-2]][s[i-1]][s[i]].push_back(i-2);
	}
}//???????????´?????????

int Xsolve(){
	int INF=114514;vector<int> x;
	for(int i=0;i<a.size();i++)x.push_back(a[i]-'a');
	if(x.size()==1)
		return zzz[x[0]].size()?zzz[x[0]][0]:INF;
	if(x.size()==2)
		return zz[x[0]][x[1]].size()?zz[x[0]][x[1]][0]+1:INF;
	if(x.size()==3)
		return z[x[0]][x[1]][x[2]].size()?z[x[0]][x[1]][x[2]][0]+2:INF;
	for(int i=0;i<z[x[0]][x[1]][x[2]].size();i++){
		int k=z[x[0]][x[1]][x[2]][i],w=x.size()-1;
		if(k+w<s.size()){
			bool ok=true;
			for(int j=k+3;j<=k+w;j++)if(s[j]!=x[j-k])ok=false;
			if(ok)return k+w;
		}
	}
	return INF;
}//????????????????????????
int Ysolve(){
	int INF=-1;vector<int> x;
	for(int i=0;i<b.size();i++)x.push_back(b[i]-'a');
	if(x.size()==1)
		return zzz[x[0]].size()?zzz[x[0]][zzz[x[0]].size()-1]:INF;
	if(x.size()==2)
		return zz[x[0]][x[1]].size()?zz[x[0]][x[1]][zz[x[0]][x[1]].size()-1]:INF;
	if(x.size()==3)
		return z[x[0]][x[1]][x[2]].size()?z[x[0]][x[1]][x[2]][z[x[0]][x[1]][x[2]].size()-1]:INF;
	for(int i=z[x[0]][x[1]][x[2]].size()-1;i>=0;i--){
		int k=z[x[0]][x[1]][x[2]][i],w=x.size()-1;
		if(k+w<s.size()){
			bool ok=true;
			for(int j=k+3;j<=k+w;j++)if(s[j]!=x[j-k])ok=false;
			if(ok)return k;
		}
	}
	return INF;
}//????????????????????????

int main(){
	PRE();
	int m;cin>>m;
	while(m--){
		cin>>a>>b;
		int l=Xsolve(),r=Ysolve();
		if(r!=-1&&l!=114514&&r>=l-a.size()+1&&l+1<=r+b.size())
			cout<<r-l+b.size()+a.size()-1<<endl;
		else cout<<"0"<<endl;
	}
	return 0;
}

Measured memory_bytes: 9996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int h=sc.nextInt();
		int w=sc.nextInt();
		int ans=H*W-h*W-w*H+w*h;
		System.out.println(ans);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  int n = s.size();
  char old = s[0];
  int len = 1;
  vecint cnt(n);
  FOR(i,1,n) {
    if (s[i] != old) {
      if (s[i] == 'L') {
        cnt[i] += len/2;
        cnt[i-1] += (len+1)/2;
      } else {
        cnt[i-len] += (len+1)/2;
        cnt[i-len-1] += len/2;
      }
      len = 1;
    } else {
      ++len;
    }
    old = s[i];
  }
  cnt[n-len] += (len+1)/2;
  cnt[n-len-1] += len/2;
  REP(i,n) {
    if (i) cout<<' ';
    cout<<cnt[i];
  }
  cout<<endl;
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
using ll = long long int;

using namespace std;

int main() {
  int N;
  cin >> N;
  double ans = 0.0;
  REP(i, N) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY")
      ans += x;
    else
      ans += x * 380000.0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
fn read_spc<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    snuke();
}

fn snuke() {
    let whn: Vec<i64> = read_spc();
    let mut w = whn[0];
    let w0 = whn[0];
    let mut h = whn[1];
    let h0 = whn[1];
    let n = whn[2];
    let mut xya: Vec<Vec<i64>> = vec![];
    for i in 0..n {
        let xya_i: Vec<i64> = read_spc();
        xya.push(xya_i);
    }
    let mut x1 = 0;
    let mut x2 = w;
    let mut y3 = 0;
    let mut y4 = h;
    for xya_i in xya {
        let x = xya_i[0];
        let y = xya_i[1];
        let a = xya_i[2];
        match a {
            1 => x1 = max_i64(x1, x),
            2 => x2 = min_i64(x2, x),
            3 => y3 = max_i64(y3, y),
            _ => y4 = min_i64(y4, y)
        }
    }
    w = max_i64(0, x2 - x1);
    h = max_i64(0, y4 - y3);
    println!("{}", w * h);
}

fn max_i64(n: i64, m: i64) -> i64 {
    let diff = n - m;
    match diff {
        diff if diff < 0 => m,
        _                => n
    }
}

fn min_i64(n: i64, m: i64) -> i64 {
    let diff = n - m;
    match diff {
        diff if diff > 0 => m,
        _                => n
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int M = 55;
int n,m,cnt;
char s[M][M];
int main()
{
    memset(s,0,sizeof(s));
    scanf("%d%d",&n,&m);
    getchar();
    for (int i = 0; i < n; i++)
        scanf("%s",s[i]);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cnt = 0;
            if(s[i][j] == '.')
            {
                if(s[i][j+1] == '#')
                    cnt++;
                if(s[i][j-1] == '#')
                    cnt++;
                if(s[i+1][j] == '#')
                    cnt++;
                if(s[i-1][j] == '#')
                    cnt++;
                if(s[i+1][j+1] == '#')
                    cnt++;
                if(s[i+1][j-1] == '#')
                    cnt++;
                if(s[i-1][j+1] == '#')
                    cnt++;
                if(s[i-1][j-1] == '#')
                    cnt++;
                s[i][j] = cnt + '0'; 
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
            printf("%c",s[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from itertools import combinations

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def main():
    N, M, X = map(int, input().split())
    C = [0] * N
    A = [0] * N
    for i in range(N):
        C[i], *A[i] = map(int, input().split())

    min_price = INF
    for r in range(1, N + 1):
        for comb in combinations(range(N), r):
            skills = [sum(A[i][j] for i in comb) for j in range(M)]
            if all(s >= X for s in skills):
                total_price = sum(c for i, c in enumerate(C) if i in comb)
                if min_price > total_price:
                    min_price = total_price

    if min_price < INF:
        print(min_price)
    else:
        print(-1)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i,j;
    int n;
    cin>>n;
    VI v(3);
    cin>>v[0]>>v[1]>>v[2];
    int y=v[0]+v[1]+v[2];
    vector<char> ans;
    string s[n+1];
    for(i=0;i<n;i++) cin>>s[i];
    s[n]="AB";
    for(i=0;i<n;i++){
        if(v[s[i][0]-'A']==0&&v[s[i][1]-'A']==0){
            cout<<"No"<<endl;
            return 0;
        }
        else if(v[s[i][0]-'A']==0){
            ans.pb(s[i][0]);
            v[s[i][0]-'A']++;
            v[s[i][1]-'A']--;
        }
        else if(v[s[i][1]-'A']==0){
            ans.pb(s[i][1]);
            v[s[i][0]-'A']--;
            v[s[i][1]-'A']++;
        }
        else{
            if(s[i+1][0]==s[i][0]){
                ans.pb(s[i][0]);
                v[s[i][0]-'A']++;
                v[s[i][1]-'A']--;
            }
            else if(s[i+1][0]==s[i][1]){
                ans.pb(s[i][1]);
                v[s[i][1]-'A']++;
                v[s[i][0]-'A']--;
            }
            else if(s[i+1][1]==s[i][0]){
                ans.pb(s[i][0]);
                v[s[i][0]-'A']++;
                v[s[i][1]-'A']--;
            }
            else if(s[i+1][1]==s[i][1]){
                ans.pb(s[i][1]);
                v[s[i][1]-'A']++;
                v[s[i][0]-'A']--;
            }
        }

        
        //cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<endl;
    }
    cout<<"Yes"<<endl;
    for(i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 6896
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
//typedef long long int LL;
//typedef __int64 LL;

int cnt[200];
int can[200];
int n;

int check(int mx) {
	if (cnt[mx] < 2) return 0;
	if (mx & 1) {
		for (int i = 1; i <= (mx + 1) / 2; i++) {
			int now = mx - i + 1;
			if (cnt[now] < 2) return 0;
			cnt[now] -= 2;
		}

		for (int i = 1; i < (mx + 1) / 2; i++) {
			int now = mx - i + 1;
			can[now] = 1;
		}
	}
	else {
		for (int i = 1; i <= mx / 2; i++) {
			int now = mx - i + 1;
			if (cnt[now] < 2) return 0;
			cnt[now] -= 2;
			can[now] = 1;
		}
		if (cnt[mx / 2] < 1) return 0;
		cnt[mx / 2]--;
	}

	for (int i = 1; i <= n - 1; i++) {
		if (can[i] == 0 && cnt[i] > 0) {
			return 0;
		}
	}
	return 1;
}

int main()
{
	int d;
	int mx = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &d);
		cnt[d]++;
		mx = MAX(mx, d);
	}

	if (check(mx)) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
static class Program
{
    static void Main(string[] args)
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        //入力
        var list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        var list2 = Console.ReadLine().Split(' ').Select(int.Parse);
   
        if(list[0] <= list2.Sum()){
          Console.WriteLine("Yes");
        }else{
          Console.WriteLine("No");
        }

        Console.Out.Flush();
    }

}

Measured memory_bytes: 18272
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 303;
int n , u[N] , d[N] , l[N] , r[N];
int dir[N][N];

void match() {
  vector<pii> remain;
  rep(i,0,n) {
    int s = u[i] + d[i];
    if(s > n) {
      puts("NO");
      exit(0);
    }
    remain.pb(mp(-(n - s) , i));
  }
  sort(all(remain));
  rep(i,0,n) {
    int s = l[i] + r[i];
    if(s > n) {
      puts("NO");
      exit(0);
    }
    rep(j,0,s) {
      remain[j].fi++;
      if(remain[j].fi > 0) {
        puts("-1");
        exit(0);
      }
      dir[i][remain[j].se] = 1;
    }
    inplace_merge(remain.begin() , remain.begin() + s , remain.end());
  }
  rep(i,0,n) rep(j,0,n) {
    dir[i][j] = dir[i][j] ? (--l[i] >= 0 ? 0 : 2) : (--u[j] >= 0 ? 1 : 3);
  }
  //rep(i,0,n) rep(j,0,n)
    //printf("%d%c",dir[i][j]," \n"[j == n - 1]);
}

int used[N][N] , instack[N][N];
int dx[4] = {0 , -1 , 0 , 1};
int dy[4] = {-1 , 0 , 1 , 0};
bool dfs(int i,int j) {
  if(used[i][j]) return false;
  if(instack[i][j]) {
    instack[i][j] = false;
    return true;
  }
  instack[i][j] = true;
  int d = dir[i][j];
  for(int ni=i+dx[d],nj=j+dy[d];;ni+=dx[d],nj+=dy[d]) {
    if(ni < 0 || ni >= n || nj < 0 || nj >= n)
      break;
    if(dfs(ni , nj)) {
      dir[ni][nj] = d;
      if(instack[i][j]) {
        instack[i][j] = false;
        return true;
      } else {
        return dfs(i , j);
      }
    }
  }
  used[i][j] = true;
  instack[i][j] = false;
  printf("%c%d\n","LURD"[dir[i][j]],(dir[i][j] & 1 ? j : i) + 1);
  return false;
}

int main(){
  scanf("%d",&n);
  rep(i,0,n) scanf("%d",u+i);
  rep(i,0,n) scanf("%d",d+i);
  rep(i,0,n) scanf("%d",l+i);
  rep(i,0,n) scanf("%d",r+i);
  match();
  rep(i,0,n) rep(j,0,n)
    dfs(i,j);
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main() {
  long int N, i, j, k;
  long int count = 0;
  cin >> N;

  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      if(i*j < N){
        //cout << i << " " << j << endl;
        count++;
        //break;
      }else{
        break;
      }
      /*for (k = 1; k <= N; k++) {
        if(i*j+k == N){
          count++;
        }
      }*/
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main() {
	int siz[7],time,pro1,pro2;
	for (int abc = 1; abc < 7; abc++) {
		cin >> siz[abc];
	}
	cin >> time;
	int whele1, whele2;
	for (int abc = 0; abc < time; abc++) {
		cin >> pro1>>pro2;
		for (whele1 = 1; pro1 != siz[whele1]; whele1++);
		for (whele2 = 1; pro2 != siz[whele2]; whele2++);
		switch (whele1) {
		case 1:
			switch (whele2) {
			case 2:
				cout << siz[3] << endl;
				break;
			case 3:
				cout << siz[5] << endl;
				break;
			case 5:
				cout << siz[4] << endl;
				break;
			case 4:
				cout << siz[2] << endl;
				break;
			}
			break;
		case 2:
			switch (whele2) {
			case 3:
				cout << siz[1] << endl;
				break;
			case 1:
				cout << siz[4] << endl;
				break;
			case 4:
				cout << siz[6] << endl;
				break;
			case 6:
				cout << siz[3] << endl;
				break;
			}
			break;
		case 3:
			switch(whele2) {
			case 5:
				cout << siz[1] << endl;
				break;
			case 1:
				cout << siz[2] << endl;
				break;
			case 2:
				cout << siz[6] << endl;
				break;
			case 6:
				cout << siz[5] << endl;
				break;
			}
			break;
		case 4:
			switch (whele2) {
			case 1:
				cout << siz[5] << endl;
				break;
			case 5:
				cout << siz[6] << endl;
				break;
			case 6:
				cout << siz[2] << endl;
				break;
			case 2:
				cout << siz[1] << endl;
				break;
			}
			break;
		case 5:
			switch (whele2) {
			case 1:
				cout << siz[3] << endl;
				break;
			case 3:
				cout << siz[6] << endl;
				break;
			case 6:
				cout << siz[4] << endl;
				break;
			case 4:
				cout << siz[1] << endl;
				break;
			}
			break;
		case 6:
			switch (whele2) {
			case 2:
				cout << siz[4] << endl;
				break;
			case 4:
				cout << siz[5] << endl;
				break;
			case 5:
				cout << siz[3] << endl;
				break;
			case 3:
				cout << siz[2] << endl;
				break;
			}
			break;
		}
	}
	cin >> pro2;
	return 0;
}

Measured memory_bytes: 1160
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    st = [LS() for _ in range(n)]
    x = S()
    f = False
    r = 0
    for s,t in st:
        if f:
            r += int(t)
        if s == x:
            f = True

    return r


print(main())





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

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


    for(int i = 0; i < n;i++){
        int minj = i;
        for(int j = i; j < n; j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        if(a[i] != a[minj]){
            int tmp = a[minj];
            a[minj] = a[i];
            a[i] = tmp;
            cnt++;
        }
    }


    for(int i = 0; i < n-1; i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3116
N = gets.chop.to_i
A = gets.chop.split(' ').map(&:to_i)

flag = true
A.each do |i|
  if i % 2 == 1
    next
  else
    if i % 3 == 0 || i % 5 == 0
      next
    else
      flag = false
      break
    end
  end
end

puts flag ? 'APPROVED' : 'DENIED'


Measured memory_bytes: 1788
package main

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

func main() {
	scanner := makeScanner(1024)
	ab := eGetInts(scanner)
	a, b := ab[0], ab[1]
	if a%2 == 0 || b%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int pow_int(int a, int n)
{
    int i;
    int ans = 1;
    for(i = 0;i < n;++i){
        ans *= a;
    }
    return ans;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int i,j;
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<ll> p(n);
    for(i = 0;i < n;++i){
        cin >> x.at(i);
        cin >> y.at(i);
        cin >> p.at(i);
    }
    int bit = 0;

    vector<vector<int>> xmiti((1 << n), vector<int>(15, 0));
    vector<vector<int>> ymiti((1 << n), vector<int>(15, 0));
    for(bit = 0;bit < (1ll << n);++bit){
        set<int> yy;
        set<int> tt;
        for(i = 0;i < n;++i){
            if(bit & (1 << i)){
                yy.insert(x.at(i));
                tt.insert(y.at(i));
            }
        }
        yy.insert(0);
        tt.insert(0);
        vector<int> yoko;
        vector<int> tate;
        for(auto xx:yy){
            yoko.push_back(xx);
        }
        for(auto xx:tt){
            tate.push_back(xx);
        }

        for(i = 0;i < n;++i){
            int xa = lower_bound(all(yoko), x.at(i)) - yoko.begin();
            int ya = lower_bound(all(tate), y.at(i)) - tate.begin();
            int xd, yd;

            if(xa >= yoko.size()){
                xd = abs(x.at(i) - yoko.back());
            }else if(xa == 0){
                xd = abs(x.at(i) - yoko.front());
            }else{
                xd = min(abs(x.at(i) - yoko.at(xa)), abs(x.at(i) - yoko.at(xa-1)));
            }

            if(ya >= tate.size()){
                yd = abs(y.at(i) - tate.back());
            }else if(ya == 0){
                yd = abs(y.at(i) - tate.front());
            }else{
                yd = min(abs(y.at(i) - tate.at(ya)), abs(y.at(i) - tate.at(ya-1)));
            }

            xmiti.at(bit).at(i) = xd;
            ymiti.at(bit).at(i) = yd;
        }
    }
    
    vector<ll> ans(n+1, (1ll << 60));

    int INF = pow_int(3, n);
    for(bit = 0;bit < INF;++bit){
        int waru = INF/3;
        int tmpbit = bit;
        int m = 0;
        int bit1 = 0;
        int bit2 = 0;
        for(i = 0;i < n;++i){
            int tmp = tmpbit/waru;
            tmpbit -= tmp*waru;
            waru /= 3;

            if(tmp) ++m;
            if(tmp == 1) bit1 += (1 << i);
            else if(tmp == 2) bit2 += (1 << i);
        }

        ll tmpans = 0;
        for(i = 0;i < n;++i){
            ll xd = xmiti.at(bit1).at(i);
            ll yd = ymiti.at(bit2).at(i);
            tmpans += p.at(i)*min(xd, yd);
        }
        ans.at(m) = min(ans.at(m), tmpans);
    }

    for(i = 0;i <= n;++i){
        cout << ans.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 9752
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val h, w = sc.nextInt()
    val map = Array.fill(h)(sc.next()).map(_.toCharArray)

    def nextPoint(i: Int, j: Int): List[(Int, Int)] = {
      val a = List((i, j + 1), (i + 1, j), (i, j - 1), (i - 1, j))
      a.filter { case (a, b) => 0 <= a && a < h && 0 <= b && b < w }
    }

    var flag = true

    for {
      i <- 0 until h
      j <- 0 until w
    } {
      if (map(i)(j) == '#') {
        flag = flag && nextPoint(i, j).exists {
          case (a, b) => map(a)(b) == '#'
        }
      }
    }

    val ans = if (flag) "Yes" else "No"
    println(ans)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 29556
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[]A = new int[N+1];
        int[]ans=new int[N+1];
        A[0]=0;
        for(int i=2;i<=N;i++){
            A[i]=sc.nextInt();
        }
        for(int i=2;i<=N;i++){
            ans[A[i]]++;
        }
        for(int i=1;i<=N;i++){
            System.out.println(ans[i]);
        }
}
}

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

using namespace std;

typedef long long int lli;

int main() {
    int n, m, l, r;

    cin >> n >> m;
    int ll = 1, rr = n;
    for (int i=0; i<m; i++) {
        cin >> l >> r;
        if (ll < l) ll = l;
        if (r < rr) rr = r;
    }

    if (ll <= rr) cout << rr-ll + 1 << endl;
    else cout << 0 << endl;

    return 0;
}


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

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

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    string s;
    cin >> s;
    vector<char> v;
    for(char c:s){
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    auto uniq=std::unique(v.begin(),v.end());
    v.erase(uniq,v.end());

    string t="abcdefghijklmnopqrstuvwxyz";

    for(int i=0;i<t.length();i++){
        auto rslt=std::binary_search(v.begin(),v.end(),(char)t[i]);
        if(!rslt){
            cout << t[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    string st[100];
    for(int i=0;i<h;i++){
        cin>>st[i];
    }
    for(int i=0;i<h;i++){
        cout<<st[i]<<endl<<st[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = str(input())

x = N[len(N)-1]

if x == str(2)or x == str(4)or x == str(5) or x == str(7)or x == str(9):
    print("hon")
elif x == str(0) or x == str(1) or x == str(6) or x == str(8):
    print("pon")
else:
    print("bon")


          


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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1LL * MX * MX;

int n;
long long pref[N];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%lld", &pref[i]);
		pref[i] += pref[i - 1];
	}
	
	long long ans = INF;
	for(int i = 1; i < n; ++i)
		ans = min(ans, abs(pref[n] - pref[i] - pref[i]));
	printf("%lld\n", ans);
	return 0;
}

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

int changenum(int hand,int ten,int one){
    int Calc;
    if(hand == 9) hand = 1;
    else hand = 9;
  
    if(ten == 9) ten = 1;
    else ten = 9;
  
   if(one == 9) one = 1;
   else one = 9;
  
  Calc = hand*100 + ten*10 + one;
  
  return Calc;
}

int n ,A, hand, ten, one;
int main(){
  int Calc;
   cin >> n;
    
  hand = n/100;
  A = n - hand*100;
  ten = A/10;
  one = A - ten*10; 
  
 Calc = changenum(hand,ten,one);
  
  cout << Calc << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int h,a;
  cin>>h>>a;
  cout<<(h+a-1)/a<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        while(N != 0) {
            if(N % 10 == 7) {
                System.out.println("Yes");
                return;
            }
            N /= 10;
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 35848
N, M = map(int, input().split())
num = ['0'] * N
s1 = False
error = False

for i in range(M):
    s, c = input().split()
    if num[int(s)-1] in ['0', c]:
        num[int(s)-1] = c
        if s == '1':
            s1 = True
    else:
        error = True
        break

if N != 1 and not s1:
    num[0] = '1'
if (N != 1 and num[0] == '0') or error:
    print(-1)
else:
    if N != 1 and not s1:
        num[0] = '1'
    print(''.join(num))


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

using namespace std;

int sticks[10]={0,2,5,5,4,5,6,3,7,6};

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a[m],dp[n+3];
    for(int i=0;i<m;i++)
        scanf("%d",a+i);
    sort(a,a+m,greater<int>());
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<m;i++)
    {
        for(int j=sticks[a[i]];j<=n;j++)
        dp[j]=max(dp[j],dp[j-sticks[a[i]]]+1);
    }

    while(n){

        for(int i=0;i<m;i++){
            if(n-sticks[a[i]]>=0&&dp[n]==dp[n-sticks[a[i]]]+1){
                printf("%d",a[i]);
                n-=sticks[a[i]];
                break;
            }
        }

    }

    return 0;
}

Measured memory_bytes: 256
#coding:utf-8

from heapq import *

def score(input_list):
    s = sum(input_list[:N])
    score_list = [s]
    l = input_list[:N]
    heapify(l)

    for val in input_list[N:2 * N]:
        s -= heappushpop(l, val)
        s += val
        score_list.append(s)

    return score_list

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split(" ")))
    B = list(map(lambda x : -x, reversed(A)))

    max_score = 0
    left_score = score(A)
    right_score = reversed(score(B))
    score_list = map(lambda x,y : x + y, left_score, right_score)
    print (max(score_list))



Measured memory_bytes: 38748
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    int n; cin >> n;
    ll ans = 1;
    rep(i,n) {
        ans *= 10;
        ans %= MOD;
    }
    ll cnt = 1;
    rep(i,n) {
        cnt *= 9;
        cnt %= MOD;
    }
    cnt *= 2;
    cnt %= MOD;
    ll cnt2 = 1;
    rep(i,n) {
        cnt2 *= 8;
        cnt2 %= MOD;
    }
    cout << (ans - cnt + MOD + cnt2) % MOD << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  map<int,vi> mp;
  rep(i,N) {
    int t,d;
    cin >> t >> d;
    mp[t].push_back(d);
  }
  vi ones;
  vi others;
  for(auto x: mp) {
    sort(rng(x.second));
    reverse(rng(x.second));
    rep(i,sz(x.second)) {
      if(i == 0) {
        ones.push_back(x.second[i]);
      } else {
        others.push_back(x.second[i]);
      }
    }
  }
  sort(rng(ones));
  sort(rng(others));
  reverse(rng(ones));
  reverse(rng(others));
  ll ans = 0;
  srep(i,1,sz(ones)+1) {
    if(i>K) break;
    if(K-i > sz(others)) continue;
    ll b = 1l * i*i;
    ll a = 0;
    rep(j,i) {
      a += ones[j];
    }
    rep(j,K-i) {
      a += others[j];
    }
    ans = max(ans,a+b);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 11772
// agc034_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    
    string S;
    cin >> S;

    REPN(i, A, C){
        if (S[i] == '#' && S[i+1] == '#') {
            print("No");
            return 0;
        }
    }

    REPN(i, B, D){
        if (S[i] == '#' && S[i+1] == '#') {
            print("No");
            return 0;
        }
    }

    if (C < D) {
        print("Yes");
        return 0;
    }

    REPN(i, B, D+1){
        if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
            print("Yes");
            return 0;
        }
    }

    print("No");

    return 0;
}


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

using namespace std;

const int N = 5e5 + 10;

typedef long long ll;

ll n, q, a[N], st[N], tp;
ll sum[N], res[N];

void solve(ll vl, ll num) {
  int ind = upper_bound(st + 1, st + tp + 1, vl) - st - 1;
  if (!ind) {
    res[vl] += num;
  } else {
    sum[ind] += (vl / st[ind]) * num;
    solve(vl % st[ind], num);
  }
}

int main() {
  scanf("%lld %lld", &n, &q);
  st[++tp] = n;
  for (int i = 1; i <= q; i++) {
    scanf("%lld", &a[i]);
    while (tp && a[i] <= st[tp]) {
      tp--;
    } 
    st[++tp] = a[i];
  }
  sum[tp] = 1;
  for (int i = tp; i > 1; i--) {
    sum[i - 1] += (st[i] / st[i - 1]) * sum[i];
    solve(st[i] % st[i - 1], sum[i]);
  }
  res[st[1]] += sum[1];
  for (int i = n; i >= 1; i--) {
    res[i] += res[i + 1];
  }
  for (int i = 1; i <= n; i++) {
    printf("%lld\n", res[i]);
  }
  return 0;
}

Measured memory_bytes: 14720
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn = 100005;
char s[maxn];

int main()
{
    while(cin>>s)
    {
        int flag;
        int len = strlen(s);
        if(s[0] == s[len-1])
        {
            if(len%2)
                flag = 0;
            else
                flag = 1;
        }
        else
            flag = len%2;
        if(flag)
            cout<<"First"<<endl;
        else
            cout<<"Second"<<endl;
    }
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;

  while (1) {
    if (n <= 0) {
      cout << ans << endl;
      return 0;
    }
    if (ans == 0) {
      ans++;
      n -= k;
    }
    else {
      ans++;
      n -= (k - 1);
    }
  }
}


Measured memory_bytes: 3632
#coding: utf-8

a, b, c, d = (int(x) for x in input().split()) 

ret = a * c
ret = max(ret, a*d)
ret = max(ret, b*c)
ret = max(ret, b*d)

if a <= 0 and b >= 0:
    ret = max(ret, 0)
if c <= 0 and d >= 0:
    ret = max(ret, 0)

print(ret)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  int a, ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> a;
    ans += min(abs(a), abs(K - a));
  }
  cout << 2 * ans << endl;
  return 0;
}


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

int main() {
	ll n,p,ans=0;
	vector<int>a,d;
	cin>>n>>p;
	for(int i=0;i<p;i++){
		int z;
		cin>>z;
		a.push_back(z);
	}
	sort(a.begin(),a.end());
	for(int i=1;i<p;i++){
		d.push_back(a[i]-a[i-1]);
	}
	sort(d.begin(),d.end());
	for(int i=0;i<p-1-(n-1);i++){
		ans+=d[i];
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
using namespace std;
int in(double data)
{
	if (data - (int)data != 0.000000000000000000000000)
	{
		int temp = (int)data;
		return ++temp;
	}
	else
	{
		return (int)data;
	}
}
int main()
{
	int h = 0, w = 0;
	int n = 0;
	cin >> h >> w >> n;
	int h_result = in(n / double(h));
	int w_result = in(n / double(w));
	if (h_result > w_result)
	{
		cout << w_result;
	}
	else
	{
		cout << h_result;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

class Point
{
public:
    int x, y, depth;
    Point(): x(0), y(0), depth(0){}
    Point(int x0, int y0, int d0): x(x0), y(y0), depth(d0){}
};


int search(std::vector<std::vector<char> > s, int sx, int sy, int tx, int ty)
{
    int H = s.size();
    int W = s[0].size();

    std::vector<std::vector<int> > d(H, std::vector<int>(W, -1));
    std::deque<Point> q;
    q.push_front(Point(sx, sy, 0));

    while(!q.empty()){
        int x = q.back().x;
        int y = q.back().y;
        int depth = q.back().depth;
        q.pop_back();

        if(x<0 || x>=H || y<0 || y>=W) continue;
        if(s[x][y] == '#') continue;
        if(d[x][y] != -1) continue;

        d[x][y] = depth;

        q.push_front(Point(x-1, y, depth+1));
        q.push_front(Point(x+1, y, depth+1));
        q.push_front(Point(x, y-1, depth+1));
        q.push_front(Point(x, y+1, depth+1));
    }

    return d[tx][ty];
}

int main()
{
    int H, W;
    scanf(" %d %d", &H, &W);
    std::vector<std::vector<char> > s(H, std::vector<char>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++) scanf(" %c", &s[i][j]);
    }

    std::vector<std::vector<int> > d;
    int min = search(s, 0, 0, H-1, W-1);
    if(min == -1){
        std::cout << -1 << std::endl; return 0;
    }

    int count = 0; // count black
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(s[i][j] == '#') count++;
        }
    }
    std::cout << H*W-count-min-1 << std::endl;
}

Measured memory_bytes: 256