akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

int cost[300][301][301]={};
// [idx_l][h_l][h_r]

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> vec(h);
  rep(i,h) cin>>vec[i];

  // cost calc O(W*H*H)
  rep(i,w-1){
    // 左からi番目とi+1番目の山について
    for(int d=0; d<h; d++){
      int now=0;
      for(int l=0; l+d<h; l++){
        int r = l+d;
        if(vec[l][i]==vec[r][i+1]) now++;
        cost[i][l+1][r+1] = now;
      }
    }
    for(int d=1; d<h; d++){
      int now=0;
      for(int r=0; r+d<h; r++){
        int l = r+d;
        if(vec[l][i]==vec[r][i+1]) now++;
        cost[i][l+1][r+1] = now;
      }
    }
  }

  // Result calc O(W*H*H)
  long res = 0;
  rep(i, w-1){
    // iとi+1番目を崩すコスト
    vector<vector<long> > dp(h+1, vector<long>(h+1, INF));
    dp[h][h]=0;
    for(int l=h; l>=0; l--){
      for(int r=h; r>=0; r--){
        if(l>0) dp[l-1][r] = min(dp[l-1][r], cost[i][l][r]+dp[l][r]);
        if(r>0) dp[l][r-1] = min(dp[l][r-1], cost[i][l][r]+dp[l][r]);
      }
    }
    res += dp[0][0];
  }

  cout<<res<<endl;

  return 0;
}


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

using namespace std;
int MOD = 1e9+7;
int main()
{
    int n, w;
    cin >> n >> w;
    char grid[n][w];
    int dp[n][w];
    memset(dp, 0, sizeof dp);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < w; j++)
            cin >> grid[i][j];
    dp[0][0] = 1;
    for(int j = 1; j < w; j++){
        if(grid[0][j] == '.')
            dp[0][j] = dp[0][j-1];
    }
    for(int i = 1; i < n; i++){
        if(grid[i][0] == '.')
            dp[i][0] = dp[i-1][0];
    }
    for(int i = 1; i < n; i++){
        for(int j = 1; j < w; j++){
            if(grid[i][j] == '.'){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
            }
        }
    }

    cout << dp[n-1][w-1] << "\n";
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

Int GetDigit(Int num) {
	Int digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

int main() {

	Int N;
	cin >> N;

	Int ans = 0;
	for (Int i = 1; i <= N; i++) {
		if (GetDigit(i) % 2 == 1)ans++;

	}
	cout << ans << endl;

}

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

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

#define N 2

void gauss(double a[N][N+1]){
  int i,j,k,l,pivot;
  double x[N];
  double p,q,m,b[1][N+1];

  rep(i,N){
    m = 0;
    pivot = i;

    REP(l,i,N) if(fabs(a[l][i]) > m){
      m = fabs(a[l][i]);
      pivot = l;
    }

    if(pivot != i) rep(j,N+1){
      b[0][j] = a[i][j];
      a[i][j] = a[pivot][j];
      a[pivot][j] = b[0][j];
    }
  }

  rep(k,N){
    p = a[k][k];
    a[k][k] = 1;

    REP(j,k+1,N+1) a[k][j] /= p;
    REP(i,k+1,N){
      q = a[i][k];
      REP(j,k+1,N+1) a[i][j] -= q * a[k][j];
      a[i][k] = 0;
    }
  }

  for(i=N-1; i>=0; i--){
    x[i] = a[i][N];
    for(j=N-1; j>i; j--){
      x[i] -= a[i][j] * x[j];
    }
  }

//  rep(i,N) printf("%lf",x[i]);
  printf("%.3lf %.3lf\n", x[0], x[1]);
}

int main(){
  int i,j;
  double a[N][N+1];

  while(scanf("%lf %lf %lf %lf %lf %lf",&a[0][0],&a[0][1],&a[0][2],&a[1][0],&a[1][1],&a[1][2]) != EOF){
    gauss(a);
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int min(int a, int b){
  return (a > b)?b:a;
}

int main(){
  int n, i = 0, j = 0, k = 0;
  scanf("%d", &n);
  int dp[n + 1][n + 1], p[n + 1];
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= n; j++) {
      if(i == j)dp[i][j] = 0;
      else dp[i][j] = 1e9;
    }
  }
  int tmp;
  for (i = 0; i < n - 1; i++) {
    scanf("%d %d", &p[i], &tmp);
  }
  scanf("%d %d", &p[n - 1], &p[n]);
  
  for (k = 1; k <= n; k++) {
    for (i = 0; i + k <= n; i++) {
      int end = i + k - 1;
      for (j = 1; j < k; j++) {
        dp[i][end] = min(dp[i][end], dp[i][end - j] + dp[end - j + 1][end] + p[i]*p[end - j + 1]*p[end + 1]);
      }
    }
  }
  printf("%d\n", dp[0][n - 1]);
  return 0;
}



Measured memory_bytes: 2052
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

vector<vector<int> > to;
bool flag[100100];
int dp[100100];

int dfs(int v){
  if(dp[v]!=0) return dp[v];
  int depth=0;
  for(int i=0;i<to[v].size();i++){
    int nv=to[v][i];
    chmax(depth,dfs(nv)+1);
  }
  return dp[v]=depth;
}

int main(){
  int N,M;
  cin >> N >> M;
  to.resize(N,vector<int>(0));
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--; b--; flag[b]=1;
    to[a].push_back(b);
  }
  vector<int> from(0);
  rep(i,N){
    if(!flag[i]){
      from.push_back(i);
    }
  }
  int ans=0;
  for(auto c:from){
    if(dfs(c)>ans) ans=dfs(c);
  }
  cout << ans << endl;
}

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

int main(){
  string s;
  cin >> s;
  int ans[26]={};
  bool flag = true;
  for(int i=0;i<s.size();i++){
      ans[s[i]-'a']++;
  }
  for(int k=0;k<s.size();k++){
      if(ans[k]>1){
          flag = false;
          break;
      }
  }
  if(flag) cout << "yes" << endl;
  else cout << "no" << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab=sorted(ab,key=lambda x:x[0])
res=0
c=0
for a,b in ab:
    if c+b<=m:
        c+=b
        res+=a*b
    else:
        res+=a*(m-c)
        break
print(res)

Measured memory_bytes: 65496
#include <stdio.h>

#define SIEVE_SIZE 32768

int sieve_idx;
char sieve[SIEVE_SIZE];

void reset_prime_generator() {
    int i;
    sieve_idx = 2;
    sieve[0] = sieve[1] = 0;
    for (i = 2; i < SIEVE_SIZE; i++) {
        sieve[i] = 1;
    }
}

int next_prime() {
    int i, j, dj;
    if (sieve_idx < 3) {
        return sieve_idx++;
    }
    for (i = sieve_idx; i < SIEVE_SIZE; i+=2) {
        if (sieve[i] == 1) {
            sieve_idx = i + 2;
            for (dj = i*2, j = i+dj; j < SIEVE_SIZE; j += dj) {
                sieve[j] = 0;
            }
            return i;
        }
    }
    return 0;
}

int main() {
    int n, i, p;

    scanf("%d", &n);

    reset_prime_generator();

    printf("%d:", n);
    while (n > 1) {
        p = next_prime();
        if (!p) {
            printf(" %d", n);
            break;
        }
        while (n % p == 0) {
            printf(" %d", p);
            n = n / p;
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 632
using System;
using System.Text;

namespace CGL_1_A_Projection
{
	class Program
	{
		static void Main ( string[] args )
		{
			int inputCount = int.Parse (Console.ReadLine ());

			StringBuilder output = new StringBuilder (inputCount * 2);

			for (int lp = 0; lp < inputCount; lp++)
			{
				int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

				Vector2 segment1 = new Vector2 (inputNum[0], inputNum[1]) - new Vector2 (inputNum[2], inputNum[3]);
				Vector2 segment2 = new Vector2 (inputNum[4], inputNum[5]) - new Vector2 (inputNum[6], inputNum[7]);

				if (Vector2.IsParallel (segment1, segment2))
				{
					output.Append (2);
				}
				else if (Vector2.IsOrthogonal (segment1, segment2))
				{
					output.Append (1);
				}
				else
				{
					output.Append (0);
				}

				output.AppendLine ();
			}

			Console.Write (output);
		}
	}

	class Vector2
	{
		public Vector2 ( decimal x, decimal y )
		{
			this.X = x;
			this.Y = y;
		}

		public decimal X { private set; get; }
		public decimal Y { private set; get; }

		public static Vector2 operator - ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X - ob2.X, ob1.Y - ob2.Y);
		}

		public decimal Length ()
		{
			return X * X + Y * Y;
		}
		public Vector2 Normalize ()
		{
			decimal length = this.Length ();
			return new Vector2 (X / length, Y / length);
		}
		public static decimal DotProduct ( Vector2 ob1, Vector2 ob2 )
		{
			Vector2 normalize1 = ob1.Normalize ();
			Vector2 normalize2 = ob2.Normalize ();

			return normalize1.X * normalize2.X +
				normalize1.Y * normalize2.Y;
		}
		public static decimal CrossProduct ( Vector2 ob1, Vector2 ob2 )
		{
			return ob1.X * ob2.Y - ob1.Y * ob2.X;
		}

		public static bool IsOrthogonal ( Vector2 ob1, Vector2 ob2 )
		{
			return DotProduct (ob1, ob2) == 0;
		}
		public static bool IsParallel ( Vector2 ob1, Vector2 ob2 )
		{
			return CrossProduct (ob1, ob2) == 0;
		}
	}
}

Measured memory_bytes: 9476
S = input()

S = S.split()

L = int(S[0])
R = int(S[1])
min = 2 * (10**10)

flg = 0

for i in range(L, R, 1):
    if flg ==0:
        for j in range(i+1, R+1, 1):
            mod = (i*j) % 2019
            if mod < min:
                min = mod
                if min == 0:
                    flg = 1
                    break
    else:
        break

print(min)


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

int main()
{
    string s;
    while(cin>>s)
    {
        int l=s.size();
        int cnt=0;
        for(int i=0;i<l/2;i++)
        {
            if(s[i]!=s[l-i-1])
            {
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

bool used[15];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	llint a, b;
	cin >> a >> b;
	used[a] = used[b] = true;
	
	for(int i = 1; i <= 3; i++){
		if(!used[i]){
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
from heapq import *
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    aa=LI()
    aa.sort()
    print(abs(aa[0]+aa[3]-aa[2]-aa[1]))

main()



Measured memory_bytes: 6028
#include<stdio.h>

int n=0, dp[100005][3];

int max(int a,int b)
{
int c=a>b?a:b;
return c;
}

int hol(int i,int j,int a[][3])
{
if(i==n)
return 0;

if(dp[i][j]==-1)
{
dp[i][j] = a[i][j];

if(j==0)
dp[i][j]+=max(hol(i+1,1,a),hol(i+1,2,a));
if(j==1)
dp[i][j]+=max(hol(i+1,0,a),hol(i+1,2,a));
if(j==2)
dp[i][j]+=max(hol(i+1,1,a),hol(i+1,0,a));
}

return dp[i][j];

}

int main()
{
scanf("%d",&n);
int a[n+5][3];

for(int i=0;i<n;i++)
{
scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
dp[i][0]=-1, dp[i][1]=-1, dp[i][2]=-1;
}

int m= max(hol(0,0,a),max(hol(0,2,a),hol(0,1,a)));

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

return 0;
}


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

string S, T;

int main(){
    cin >> S;
    cin >> T;
    int n_s = S.size();
    int n_t = T.size();
    int t_index = n_t-1;
    int free_n = 0;
    bool is_ok = false;
    if(n_s < n_t){
        printf("UNRESTORABLE\n");
    }else{
        for(int i=n_s-1;i>=0;i--){
            int j;
            for(j=0;j<n_t;j++){
                if(S[i+j]!=T[j] && S[i+j]!='?') break;
            }

            if(j==n_t){
                for(int j=i+n_t-1;j>=i;j--){
                    S[j] = T[j-i];
                }
                is_ok = true;
                break;
            }
        }
        if(is_ok){
            for(auto &c:S){
                if(c=='?'){
                    printf("a");
                }else{
                    printf("%c", c);
                }
            }
            printf("\n");
        }else{
            printf("UNRESTORABLE\n");
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,i,k,ds;
  cin >> n;
  k=n;
  while (k){
    ds+=k%10;
    k/=10;
  }
  if (n%ds==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
Alist = list(map(int,input().split()))
Data = []
for i in range(N):
    Data.append([1,Alist[i]])
for i in range(M):
    b,c = map(int,input().split())
    Data.append([b,c])
Data.sort(key=lambda x:x[1],reverse=True)

count = 0
ans = 0
for i in range(M+N):
    b,c = map(int,Data[i])
    if count + b < N:
        ans += b * c
        count += b
    else:
        ans += (N-count) * c
        break
print(ans)


Measured memory_bytes: 37708
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	string red;
	string green;
	string shita;

	while(cin >> red, red != "-") {
		cin >> green;
		cin >> shita;
		shita += ' ';

		int rpos = 0, gpos = 0, spos = 0;
		string out;
		char c = green[gpos];
		gpos++;

		while(true) {
			if(c == shita[spos]) {
				c = red[rpos];
				rpos++;
				spos++;
			} else {
				out += c;
				if(out.size() == green.size()) {
					break;
				}
				c = green[gpos];
				gpos++;
			}
		}

		cout << out << endl;
	}

	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
template<class T> void chmax(T& a, T b) { if(a < b) a = b; }

vector<pair<char, int>> runlength(string s) {
    int n = s.size();
    vector<pair<char, int> > res;
    char pre = s[0];
    int cnt = 1;
    for(int i = 1; i < n; i++){
        if(pre != s[i]){
            res.push_back({ pre, cnt });
            pre = s[i];
            cnt = 1;
        }
        else cnt++;
    }
    res.push_back({pre, cnt});
    return res;
}

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    auto run = runlength(s);

    int m = run.size();
    int ans = 0, sum = 0, l = 0, z = 0;
    for(int r = 0; r < m; r++){
        sum += run[r].second;
        if(run[r].first == '0') z++;
        while(k < z){
            sum -= run[l].second;
            if(run[l].first == '0') z--;
            l++;
        }
        chmax(ans, sum);
    }
    cout << ans << endl;

}


Measured memory_bytes: 1656
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut sseq = vec![vec![]; n];
    let mut cnts = vec![100; 26];
    for i in 0..n {
        sseq[i] = read::<String>().chars().collect::<Vec<char>>();
        for j in 0..26 {
            cnts[j] = std::cmp::min(
                cnts[j],
                sseq[i]
                    .iter()
                    .filter(|&&c| (c as u8 - 'a' as u8) as usize == j)
                    .count(),
            );
        }
    }
    for i in 0..26 {
        for _ in 0..cnts[i] {
            let c = ('a' as u8 + i as u8) as char;
            print!("{}", c);
        }
    }
    println!("");
}


Measured memory_bytes: 4352
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W,N=map(int,input().split())
d={}
for i in range(N):
    a,b=map(int,input().split())
    for j in range(-1,2):
        if not 1<a+j<H:
            continue
        for k in range(-1,2):
            if not 1<b+k<W:
                continue
            t=(a+j,b+k)
            if t in d:
                d[t]+=1
            else:
                d[t]=1
l=[0]*10
for i in d.values():
    l[i]+=1
l[0]=(H-2)*(W-2)-sum(l)
print(*l,sep="\n")

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1e9+7
#define MOD 1e9+7
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
   
    int n,m;cin>>n>>m;
    vi in(n,0);
    int x,y;
    vvi to(n);
    rep(i,m){
        cin>>x>>y;
        in[y-1]++;
        to[x-1].push_back(y-1);
    }

    queue<int> que;
    vi dp(n,-1);
    rep(i,n){
        if(in[i]==0){
            que.push(i);
            dp[i]=0;
        }
    }

    int a;
    while(!que.empty()){
        a=que.front();que.pop();
        rep(i,to[a].size()){
            dp[to[a][i]] = max(dp[a]+1,dp[to[a][i]]);
            // cerr<<"dp["<<to[a][i]<<"] = "<<dp[to[a][i]]<<endl;
            in[to[a][i]]--;
            if(in[to[a][i]]==0){
                que.push(to[a][i]);
            }
        }
    }

    int ans=0;
    rep(i,n){
        ans = max(ans,dp[i]);
    }

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

Measured memory_bytes: 6528
import copy
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
c = a.count(max(a))
a_2 = copy.copy(a)
t = max(a)

if c > 1:
    for i in range(n):
        print(t)
else:
    a_2.remove(t)
    t_2 = max(a_2)
    for i in a:
        if i == t:
            print(t_2)
        else:
            print(t)


Measured memory_bytes: 91008
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
const double PI = 3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;
typedef pair<int, int> P;
const int mod = 1e9 + 7;

struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint &operator+=(const mint a)
    {
        (x += a.x) %= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        (x -= mod - a.x) %= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t % 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        fact[0] = 1;
        for (int i = 1; i < n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] + ifact[n - k];
    }
};

ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

ll gcd(vector<ll> a)
{
    ll ans = 0;
    for (ll i = 0; i < a.size(); ++i)
    {
        ans = gcd(ans, a[i]);
    }
    return ans;
}

ll ppow(int v ,int n){
    ll rel =1;
    rep(i,n){
        rel*=v;
        rel%=mod;
    }
    return rel;
}
int main(){
    int n;cin >> n;
    ll ans = (ll)ppow(10,n)%mod ;
    ans -=2*ppow(9,n);
    ans%=mod;
    if(ans<0)ans+=mod;
    ans %mod;
    ans += ppow(8,n);
    ans%= mod;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> sum(n + 1);
	rep(i, n) sum[i + 1] = sum[i] + a[i];
	rep(i, n + 1) {
		sum[i] %= m;
	}
	map<ll, ll> mp;
	rep(i, n + 1) {
		mp[sum[i]]++;
	}
	ll ans = 0;
	for (auto& c : mp) {
		ll tmp = c.second*(c.second - 1) / 2;
		if (tmp == 0) continue;
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5376
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

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

	final long MODULO = 924844033L;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<Integer>[] g = new ArrayList[2 * n];
		for (int i = 0; i < 2 * n; ++i)
			g[i] = new ArrayList<>();
		for (int i = 0; i < n; ++i) {
			for (int di = -k; di <= k; di += 2 * k) {
				int nj = i + di;
				if (!(0 <= nj && nj < n)) {
					continue;
				}
				g[i].add(nj + n);
				g[nj + n].add(i);
			}
		}
		for (int i = 0; i < n; ++i) {
			if (vis[i])
				continue;
			++cnt[dfs(i, -1, g)];
		}
		long[][][] dp2 = new long[1 + cnt.length][1 + cnt.length][2];
		// #get,sz,bool
		dp2[1][1][1] = 1;
		dp2[0][1][0] = 1;

		for (int sz = 2; sz < cnt.length; ++sz) {
			for (int get = 0; get <= sz; ++get) {
				if (get + 1 <= sz) {
					dp2[get + 1][sz][1] += dp2[get][sz - 1][0];
					if (dp2[get + 1][sz][1] >= MODULO)
						dp2[get + 1][sz][1] -= MODULO;
				}
				dp2[get][sz][0] += dp2[get][sz - 1][0] + dp2[get][sz - 1][1];
				if (dp2[get][sz][0] >= MODULO)
					dp2[get][sz][0] -= MODULO;
			}
		}
		long[] dp = new long[n + 1];
		dp[0] = 1;
		for (int sz = 1; sz < cnt.length; ++sz) {
			if (cnt[sz] == 0)
				continue;
			for (int t = 0; t < cnt[sz]; ++t) {
				long[] ndp = Arrays.copyOf(dp, dp.length);
				for (int get = 1; get <= sz; ++get) {
					for (int cur = n - get; cur >= 0; --cur) {
						ndp[cur + get] += (dp2[get][sz][0] + dp2[get][sz][1]) % MODULO * dp[cur] % MODULO;
						ndp[cur + get] %= MODULO;
					}
				}
				dp = Arrays.copyOf(ndp, dp.length);
			}
		}
		long[] fac = new long[n + 1];
		fac[0] = 1;
		for (int i = 1; i < fac.length; ++i) {
			fac[i] = fac[i - 1] * i % MODULO;
		}

		long res = 0;
		for (int i = 1; i < dp.length; ++i) {
			res += fac[n - i] * dp[i] * (int) (Math.pow(-1, (i + 1) % 2)) % MODULO;
			res %= MODULO;
		}
		long ans = (fac[n] - res + MODULO) % MODULO;
		System.out.println(ans);

	}

	long[] cnt = new long[2000];
	boolean[] vis = new boolean[4001];

	int dfs(int cur, int par, ArrayList<Integer>[] g) {
		vis[cur] = true;
		int ret = 0;
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			if (vis[dst])
				throw new AssertionError();
			ret += dfs(dst, cur, g) + 1;
		}
		return ret;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 228180
const M: i64 = 1000_000_007;

fn main() {
    proconio::input! {
        n: usize,
        mut k: usize,
        mut a: [i64; n],
    }

    let mut r = 1;
    if k == n {
        let mut m = false;
        for i in 0..k {
            m ^= a[i] < 0;
            r = r * a[i].abs() % M;
        }
        if m {
            r = M - r;
        }
    } else {
        let mut p = Vec::new();
        let mut z = 0;
        let mut m = Vec::new();

        a.sort();
        for i in 0..n {
            if a[i] > 0 {
                p.push(a[i]);
            } else if a[i] == 0 {
                z += 1;
            } else {
                m.push(a[i].abs());
            }
        }

        let mut plen = p.len();
        let mlen = m.len();
        if k > plen + mlen {
            r = 0;
        } else {
            if plen == 0 {
                if k > mlen {
                    r = 0;
                } else {
                    if k % 2 == 1 {
                        if z > 0 {
                            r = 0;
                        } else {
                            for i in 0..k {
                                r = r * m[mlen - 1 - i] % M;
                            }
                            r = M - r;
                        }
                    } else {
                        for i in 0..k {
                            r = r * m[i] % M;
                        }
                    }
                }
            } else {
                if k % 2 == 1 {
                    plen -= 1;
                    r = r * p[plen] % M;
                    k -= 1;
                }
                if plen > 0 {
                    let mut pi = plen;
                    if mlen >= 2 {
                        let mut mi = 0;
                        while k >= 2 && pi >= 2 && mi <= mlen - 2 {
                            if m[mi] * m[mi + 1] >= p[pi - 1] * p[pi - 2] {
                                r = r * (m[mi] * m[mi + 1] % M) % M;
                                mi += 2;
                                k -= 2;
                            } else {
                                r = r * p[pi - 1] % M;
                                pi -= 1;
                                k -= 1;
                            }
                        }
                        while k >= 2 && mi <= mlen - 2 {
                            r = r * (m[mi] * m[mi + 1] % M) % M;
                            mi += 2;
                            k -= 2;
                        }
                    }
                    while k > 0 {
                        r = r * p[pi - 1] % M;
                        pi -= 1;
                        k -= 1;
                    }
                } else {
                    for i in 0..k {
                        r = r * m[i] % M;
                    }
                }
            }
        }
    }
    println!("{}", r);
}


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

const int N = 1e5 + 5;

long long dp[N];
int w[105], v[105];

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

    int n, W;
    cin >> n >> W;
    int sumv = 0;
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        sumv += v[i];
    }
    for (int i = 0; i < N; i++) dp[i] = 2 * W;
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = N - 1; j >= v[i]; j--) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
    }
    int ans = 0;
    for (int i = sumv; i >= 0; i--) {
        if (dp[i] <= W) {
            ans = i;
            break;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4424
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

vector<pair<int,int>> G[1000000];
vector<int> color(1000000,0);

void dfs(int v, int p, int k, int c){

    for (pair<int,int> i: G[v]) {
        if(i.first==p) continue;
        color[i.second]=(c+1) % k;
        dfs(i.first,v,k,color[i.second]);
        (c += 1) %= k;
    }

}

int main(void){

    int N; cin>>N;
    for (int i = 0; i < N-1; ++i) {
        int a,b; cin>>a>>b;
        a--;b--;
        G[a].push_back(make_pair(b,i));
        G[b].push_back(make_pair(a,i));
    }
    int maxjisuu = 0;
    for (int i = 0; i < N; ++i) {
        maxjisuu = max(maxjisuu, (int)G[i].size());
    }

    dfs(0,-1, maxjisuu, 1); // 始点、　前の点、　マックス次数、　カラー
    cout<<maxjisuu<<endl;
    for (int i = 0; i < N-1; ++i) {
        cout<<color[i]+1<<endl;
    }


}

Measured memory_bytes: 33152
#include<stdio.h>

main(){
  
  int n,i,min,t,max,t0;
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
   
    scanf("%d",&t);
   
    if(i==0) t0 = t;

    if(i == 1) max = t - t0;
    else if (max < t - min) max = t - min;

 
    if(i == 0) min = t;
    else if (min > t) min = t;

    
  }
  
  printf("%d\n",max);

    return 0;
    
} 

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

using namespace std;

typedef long long ll;

struct SegmentTree{
  ll data[500010];
  int sz;
  void init(int n){
    sz = 1;
    while(sz < n) sz *= 2;
    memset(data, 0LL, sizeof(data));
  }
  void update(int k, ll x){
    k += sz - 1;
    data[k] = x;
    while(k > 0){
      k = (k - 1) / 2;
      data[k] = max(data[2*k+1], data[2*k+2]);
    }
  }
  ll at(int k){
    return data[k+sz-1];
  }
  ll query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return data[k];
    ll left = query(a, b, 2*k+1, l, (l+r)/2);
    ll right = query(a, b, 2*k+2, (l+r)/2, r);
    return max(left, right);
  }
  ll query(int a, int b){
    return query(a, b, 0, 0, sz);
  }
  int size(){
    return sz;
  }
};

int main()
{
  SegmentTree tree;  
  int n;
  cin >> n;
  tree.init(n);
  ll maxcost = 0;
  for(int i = 0; i < n; i++){
    ll x; cin >> x;
    ll cost = tree.query(1, x+1);
    tree.update(x, cost + x);
    maxcost = max(maxcost, tree.at(x));
  }
  cout << ((ll)n+1LL)*n/2LL - maxcost << endl;
  return 0;
}

Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  bool nazo=false;
 for(int i=0;i<S.size()-1;i++){
 	if(S.at(i)==S.at(i+1)){
    	nazo=true;
    }
 }
  if(nazo){
  cout<<"Bad";
  }
  else{
  cout<<"Good";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n,sum=0;;
int a[200000];
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(i==0)sum+=abs(a[i]);
        else sum+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n-1]);
    rep(i,n){
        int x,y,z;
        if(i==0){
            x=0;y=a[0];z=a[1];
        }
        else if(i==n-1){
            x=a[n-2];y=a[n-1];z=0;
        }
        else{
            x=a[i-1];y=a[i];z=a[i+1];
        }
        if(y<x){
            y=x+(x-y);
            z=x+(x-z);
        }
        if(y<=z)cout<<sum<<endl;
        else if(x<=z&&z<=y){
            cout<<sum-2*(y-z)<<endl;
        }
        else cout<<sum-2*(y-x)<<endl;
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n - 1; i++)
    {
        int k;
        cin >> k;
        mp[k]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << mp[i] << endl;
    }
}

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

#define MAX_XY 16

int X, Y;
int field[MAX_XY][MAX_XY];
int way[MAX_XY][MAX_XY];

int main() {
	while (cin >> X >> Y, X || Y) {
		memset(field, 0, sizeof(field));
		memset(way, 0, sizeof(way));
		for (int i = 0; i < X; i++) {
			cin >> field[0][i];
			if (field[0][i] == 1) {
				way[0][i] = 0;
			} else {
				way[0][i] = 1;
			}
		}

		for (int i = 1; i < Y; i++) {
			for (int j = 0; j < X; j++) {
				cin >> field[i][j];
			}
		}

		for (int i = 0; i < Y-1; i++) {
			for (int j = 0; j < X; j++) {
				if (field[i][j] == 2) {
				   	if (field[i+2][j] != 1) {
						way[i+2][j] += way[i][j];
					}
				} else {
					if (1 <= j && field[i+1][j-1] == 0) {
						way[i+1][j-1] += way[i][j];
					}
					if (j < X-1 && field[i+1][j+1] == 0) {
						way[i+1][j+1] += way[i][j];
					}
					if (field[i+1][j] != 1) {
						way[i+1][j] += way[i][j];
					}
				}
			}
		}

//		for (int i = 0; i < Y; i++) {
//			for (int j = 0; j < X; j++) {
//				cout << way[i][j] << ' ';
//			}
//			cout << endl;
//		}

		int cnt = 0;
		for (int i = 0; i < X; i++) {
			cnt += way[Y-1][i];
		}
		for (int i = 0; i < X; i++) {
			if (field[Y-2][i] == 2) cnt += way[Y-2][i];
		}

		cout << cnt << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t A,B,C,X,Y;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> A>>B>>C>>X>>Y;

	int64_t min = A * X + B * Y;

	auto c_num = std::min(X, Y);
	X -= c_num; Y -= c_num;
	min = std::min(min,  C * c_num * 2 + A * X + B * Y );

	c_num += std::max(X, Y);
	min = std::min(min, C * c_num * 2);

	out << min << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
while True:
    n=int(input())
    if n == 0 : break
    a,b,c=0,1001,-1
    for i in range(n):
        m=int(input())
        b=min(b,m)
        c=max(c,m)
        a+=m
    print((a-b-c)//(n-2))


Measured memory_bytes: 5600
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
#include <set>

using namespace std;

char f[52][52];
bool visited[52][52];
int w,h;

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

int bfs(int y, int x){
    deque<pair<int,int> > q;
    set<char> s;
    int ret=1;
    q.push_back(make_pair(y,x));
    visited[y][x] = true;

    int tx, ty, nx, ny;
    while(!q.empty()){
        ty = q.front().first;
        tx = q.front().second;
        q.pop_front();
        for(int i=0;i<4;i++){
            ny = ty + dy[i];
            nx = tx + dx[i];

            if(f[ny][nx] == -1){
                //do nothing
            }else if(f[ny][nx] == 'W'){
                s.insert('W');
            }else if(f[ny][nx] == 'B'){
                s.insert('B');
            }else{
                if(!visited[ny][nx]){
                    visited[ny][nx] = true;
                    q.push_back(make_pair(ny,nx));
                    ret++;
                }
            }
        }
    }
    if(s.size() == 2 || s.size() == 0){
        return -1;
    }else{
        if(s.find('W') != s.end()){
            return ret+10000;
        }else{
            return ret;
        }
    }
}

int main(){
    while(cin >> w >> h){
        if((w|h) == 0) break;
        memset(f, -1 , sizeof(f));
        memset(visited, false, sizeof(visited));

        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin >> f[i][j];
            }
        }
        int bl=0,wh=0,tmp;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if(!visited[i][j] && f[i][j] == '.'){
                    tmp = bfs(i,j);
                    if(tmp != -1){
                        if(tmp > 10000){
                            wh += tmp%10000;
                        }else{
                            bl += tmp;
                        }
                    }
                }
            }
        }
        cout << bl << " " << wh << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

vector<bool> Eratosthenes(int n) {
    vector<bool> prime(n + 1, true);
    prime[0] = false;
    if (n >= 1) prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i]) continue;
        for (int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

int main() {
    int n;
    cin >> n;
    vector<bool> prime = Eratosthenes(600000);
    rep(i, 0, 600000) {
        if (prime[i] && i >= n) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
	int s,i,j,k,n,m;
	s=0;
	int A[100][3]={};
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			for(k=j+1;k<n;k++){
				if(i+j+k+3==m) s++;
			}
		}
	}
	printf("%d\n",s);
	s = 0;
	}
	return 0;
}

Measured memory_bytes: 600
n,x = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
b = Marshal.load(Marshal.dump(a))
a[0] = [a[0], x].min

(n-1).times do |i|
	a[i+1] -= [ a[i] + a[i+1] - x , 0].max
end

puts (b.inject(:+) - a.inject(:+))


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

#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

ll N, M;

ll F(ll A){
ll countA = 0;

while(A > 0){
A /=10;
countA++;}
return countA;
}


int main(){
ll K;cin >> K;
ll n = F(K), Ans = n;
ll k = (7*(pow(10, n) - 1)/9);
ll num = k%K;
ll m = pow(10, n - 1)*7;

if(num == 0){cout << Ans;exit(0);}

rep(i, n, 1000000){
  
    Ans++;

    m*=10;m%=K;

    num = (num + m)%K;

    if(num == 0){cout << Ans;exit(0);}

}
cout << -1;
}

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

int main() {
    
    int N;
    cin >> N;
    
    int ans = 0;
    
    for(int i=1; i<=N; i+= 2)
    {
        int divisor = 0;
        
        for(int j=1; j*j<=i; j++)
        {
            if(i % j)
                continue;
            
            divisor++;
            
            if(j * j != i)
                divisor++;
        }
        
        ans += (divisor == 8);
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin>>N;
   int ans = 0;
   for(int i = 1;i<=N;i++){
       int A;
       cin>>A;
       if(A%2==1){
           ans++;
       }
    }
   if((ans)%2==0){
       cout<<"YES"<<endl;
   }else{
       cout<<"NO"<<endl;
   }
}
       


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstdio>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int i,n,m;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>s;
        cout<<s<<'\n'<<s<<'\n';
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,t;
    cin>>n>>t;
    vector<ll> v;
    for(ll i=0;i<n;i++){
        ll k;
        cin>>k;
        v.pb(k);
    }
    ll ans=0;
    for(ll i=0;i<n-1;i++){
        if(v[i]+t>v[i+1]){
            ans+=v[i+1]-v[i];
        }
        else{
            ans+=t;
        }
    }
    ans+=t;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2420
using System;
using System.Linq;

namespace ABC158
{
    class C
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = a[0];
            var B = a[1];

            for (int i = 1; i <= 1000; i++)
            {
                if ((int)(i * 0.08) == A && (int)(i * 0.10) == B) { Console.WriteLine(i); return; }
            }
            Console.WriteLine(-1);

        }
    }
}


Measured memory_bytes: 13396
#長さ 4 の英大文字からなる文字列 S が与えられます。
#S がちょうど 2 種類の文字からなり、かつ現れる各文字はちょうど 2 回ずつ現れているかどうかを判定してください。

a = set(input())
print("Yes" if len(a) == 2 else "No")

Measured memory_bytes: 38256
//0337
#include <iostream>
using namespace std;
int main(void){
    int E,Y;
    cin >> E >> Y;
    if(E==0){
        if(Y>=1868&&Y<=1911){
            Y=Y-1867;
            cout << "M"<<Y<<endl;
        }
        else if(Y>=1912&&Y<=1925){
            Y=Y-1911;
            cout << "T"<<Y<<endl;
        }
        else if(Y>=1926&&Y<=1988){
            Y=Y-1925;
            cout << "S"<<Y<<endl;
        }
        else if(Y>=1989&&Y<=2016){
            Y=Y-1988;
            cout << "H"<<Y<<endl;
        }
    }
    if(E==1){
        Y=Y+1867;
        cout << Y << endl;
    }
    if(E==2){
        Y=Y+1911;
        cout << Y << endl;
    }
    if(E==3){
        Y=Y+1925;
        cout << Y << endl;
    }
    if(E==4){
        Y=Y+1988;
        cout << Y << endl;
    } 
    
}



Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=100005;

int n,k,pos,ans;
int a[N];

int main(){
	int i;
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++)
		if (a[i]==1) pos=i;
	if (pos>1){
		for (i=1;i<=n;i++)
			if (i*k-i+1>=pos){
				pos=i*k-i+1;
				ans=i;
				break;
			}
	}
	if (pos>=n) printf("%d\n",ans);
	else{
		pos=n-pos+1;
		for (i=1;i<=n;i++)
			if (i*k-i+1>=pos){
				printf("%d\n",ans+i);
				return 0;
			}
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
    
    int n,flag;
    int count = 0;
    
    cin >> n;
    
    int a[n];
    
    for (int h = 0; h < n; h ++) {
        
        cin >> a[h];
        
    }
    
    flag = 1;
    
    while(flag) {
        
        flag = 0;
        
        for (int i = n-1; i > 0; i --) {
            
            if (a[i] < a[i-1]) {
                
                int k = a[i];
                
                a[i] = a[i-1];
                
                a[i-1] = k;
                
                flag = 1;
                
                count += 1;
                
            }
        }
    }
    
    for (int j = 0; j < n; j ++) {
        
        if (j == n-1) {
            
            cout << a[j] << endl;
            
        } else {
            
            cout << a[j] << " ";
            
        }
        
    }
    
    cout << count << endl;
    
    return 0;
    
}


Measured memory_bytes: 3088
#include <iostream>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932384626433832795028841971
using namespace std;

int main(){
    
    long long max,min,sum,sum2,num;
    max = -1000001;
    min =  1000001;
    sum = 0;
    sum2 = 0;
    cin >> num;
    
    for(int ii=0;ii<num;ii++){
        int val;
        
        cin >> val;
        
        if(max < val){
            max = val;
        }
        if(min > val){
            min = val;
        }
        
        if( sum < 2000000000){
            sum += val;
        }
        else{
            sum2 += val;
        }
    }
    
    cout << min << " " << max << " " << sum + sum2 << endl;
    
    return 0;
}

Measured memory_bytes: 1168
#include <stdio.h>
#define maxn 200010
int n,k,a[maxn];
int judge(int x){
    int i,cnt=0;
    for(i=1;i<=n;i++)
        cnt+=(a[i]-1+x)/x-1;//(a[i]-1+x)/x用来统计原木分割的段数((a[i]-1+x)/x此种写法是常见技巧)，切割次数=段数-1
    if(cnt>k)return 0;//切割次数过多
    else return 1;//切割次数小于等于k
}
int main(){
    int i,l,r,mid;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)scanf("%d",&a[i]);
    l=0,r=1000000000;
    while(l+1<r){
        mid=(l+r)/2;
        if(judge(mid))r=mid;
        else l=mid;
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 2504
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 2e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll tree[4*N];

ll query(int node, int start, int end, int l, int r) {
  if(start > r || end < l)
    return 0;
  if(start >= l && end <= r)
    return tree[node];
  int mid = (start + end) / 2;
  ll p1 = query(node * 2, start, mid, l, r);
  ll p2 = query(node * 2 + 1, mid + 1, end, l, r);
  return max(p1, p2);
}

ll arr[N], val[N];

void update(int node, int start, int end, int idx, ll val) {
  if(start == end) {
    tree[node] = max(tree[node], val);
    return;
  }
  int mid = (start + end) / 2;
  if(idx <= mid)
    update(node * 2, start, mid, idx, val);
  else
    update(node * 2 + 1, mid + 1, end, idx, val);
  tree[node] = max(tree[node * 2], tree[node * 2 + 1]);
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 0; i < n; ++i)
    cin >> arr[i];
  for (int i = 0; i < n; ++i)
    cin >> val[i];
  for (int i = 0; i < n; ++i) {
    ll cur = query(1, 1, N, 1, arr[i]) + val[i];
    ans = max(ans, cur);
    update(1, 1, N, arr[i], cur);
  }
  cout << ans;
  return 0;
}


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

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    int kk = k;
    while(k<=1000){
        if(a<=k && k<=b){
            cout<<"OK"<<endl;
            return 0;
        }
        k += kk;
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3632