akhauriyash/Code-Regression huggingface dataset:
D, G = map(int, input().split())
G = int(G / 100)
pc = [list(map(int, input().split())) for _ in range(D)]

N = 10 ** 9
for bit in range(2 ** D):
    S = 0
    c = 0
    A = True
    a = -1
    for i in range(D - 1, -1, -1):
        if bit & (1 << i):
            S += (i + 1) * pc[i][0] + int(pc[i][1] / 100)
            c += pc[i][0]
        elif A:
            a = i
            A = False
    if a != -1:
        for i in range(1, pc[a][0]):
            if S >= G:
                break
            S += a + 1
            c += 1
    if S >= G:
        N = min(N, c)

print(N)

Measured memory_bytes: 3064
n,k = map(int,input().split())
arr = list(map(int,input().split()))

import collections

arr2 = collections.Counter(arr)

sm = list(arr2.items())

sm.sort(key=lambda x : x[1],reverse=True)

ans = 0

if len(sm) > k:
    for j in sm[k:]:
        ans += j[1]

print(ans)


Measured memory_bytes: 39348
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1LL<<32
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;


int main(void) {
    ll n, i;
    cin >> n >> i;
    cout << n-i+1 << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    ll N; cin >> N;
    vector<P> S;
    rep(i,N){
        ll X,L; cin >> X >> L;
        S.pb({X-L,X+L});
    }
    
    sort(ALL(S));
    
    stack<P> sk;
    sk.push(S[0]);
    
    rep(i,N){
        ll end = sk.top().second;
        ll nows = S[i].first, nowe = S[i].second;
        
        if(nowe <= end){
            sk.pop();
            sk.push(S[i]);
        }else if(nows >= end){
            sk.push(S[i]);
        }
    }
    
    print(sz(sk));
    
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

ll p[1001] = {};

void prime(ll a) {
    ll i = 2;
    while (a > 1) {
        while (a % i == 0) {
            p[i]++;
            a /= i;
        }
        i++;
    }
}

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

    repll2(i, n) {
        prime(i);
    }

    ll ans = 1;

    repll2(i, n) {
        if (p[i] != 0) ans = (ans * (p[i] + 1)) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#%% D
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
a_dic = {}
for i, row in enumerate(A):
    for j, a in enumerate(row):
        a_dic[a] = (i, j)

dist = [0] * (H * W + 1)
for i in range(1, H * W - D + 1):
    px, py = a_dic[i]
    nx, ny = a_dic[i + D]
    dist[i + D] = abs(nx - px) + abs(ny - py)

for i in range(1, H * W - D + 1):
    dist[i + D] += dist[i]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(dist[r] - dist[l])

Measured memory_bytes: 25136
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int main() {
    int n, k; cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    uint32_t sum = 0;
    for(int i = 0; i < k; i++) {
        sum += v[i];
    }
    cout << sum;
   
}

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

using namespace std;
typedef long long ll;

int main() {
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;
    int ans = t2 - t1 - k;
    if (ans < 0) ans = 0;
    cout << ans << "\n";
}


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

using namespace std;

int main(void){
	int K,S;
	int ans = 0;
	cin >> K >> S;
	for(int i =0;i<=K;i++)for(int j=0;j<=K;j++){
		if( (i+j)<=S && (S-(i+j))<=K)ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
def main():
  from collections import deque
  n,k,*t=map(int,open(0).read().split())
  e=[set()for _ in[0]*n]
  for a,b in zip(t[::2],t[1::2]):
    e[a-1]|={b-1}
    e[b-1]|={a-1}
  c,q=k,deque([0])
  while q:
    v,i=q.pop(),1
    for w in e[v]:
      c=c*(k-i-(v>0))%(10**9+7)
      e[w]-={v}
      q.append(w)
      i+=1
  print(c)
main()

Measured memory_bytes: 49620
use proconio::{fastout, input};

use num::bigint::ToBigInt;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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

    let mut ans = 1.to_bigint().unwrap();
    for e in &a {
        ans *= (*e).to_bigint().unwrap();
        if ans > 1e18.to_bigint().unwrap() {
            if *a.iter().min().unwrap() == 0 {
                ans = 0.to_bigint().unwrap();
            } else {
                ans = -1.to_bigint().unwrap();
            }
            break;
        }
    }
    println!("{}", ans);
}


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

struct edge {
    int to, i;
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    a.emplace_back(0, 0); a.emplace_back((int) 1e9 + 10, 0);
    sort(a.begin(), a.end());
    int sz = a.size() - 1;
    vector<int> req(sz, 0);
    for (int i = 0; i < a.size()-1; i++) {
        if (a[i].second != a[i+1].second) req[i] = 1;
    }
    vector<vector<edge>> e(sz);
    for (int i = 0; i < m; i++) {
        int l, r; cin >> l >> r;
        l = lower_bound(a.begin(), a.end(), make_pair(l, 0)) - a.begin();
        r = lower_bound(a.begin(), a.end(), make_pair(r+1, 0)) - a.begin();
        e[l-1].push_back({r-1, i+1});
        e[r-1].push_back({l-1, i+1});
    }
    vector<int> v, visit(sz, 0);
    function<int(int, int)> search = [&](int curr, int prev){
        int ret = req[curr];
        visit[curr]++;
        for (auto &ev: e[curr]) {
            if (ev.to == prev) continue;
            if (!visit[ev.to]) {
                int p = search(ev.to, curr);
                if (p > 0) {
                    v.emplace_back(ev.i);
                    ret ^= 1;
                }
            }
        }
        return ret;
    };
    
    for (int i = 0; i < sz; i++) {
        int p;
        if (!visit[i]) p = search(i, -1);
        if (p % 2) {
            cout << -1 << "\n";
            return 0;
        } 
    }
    cout << v.size() << "\n";
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
        if (i) cout << " ";
        cout << v[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 16752
import sys
input = sys.stdin.readline
from itertools import chain

def readlines(*xy):
    for n in xy:
        yield sorted(map(int, input().split()), reverse=True)[:n]

def main():
    x, y, a, b, c = map(int, input().split())
    apples = sorted(chain(*readlines(x,y,c)), reverse=True)
    print(sum(apples[:x+y]))


main()




Measured memory_bytes: 22576
N = int(input())
count_1 = 0
for i in range(1,N+1,2):
  count_2 = 0
  for j in range(1,i+1,2):
    if i % j == 0:
      count_2 += 1
  if count_2 == 8:
    count_1 += 1
print(count_1)  

Measured memory_bytes: 9176
#include<stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    if(N>=65 && N<=90){
        printf("1\n");
    }else if(N>=97 && N<=122){
        printf("2\n");
    }else{
        printf("0\n");
    }
    return 0;
}




Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);
  string s,t;
  cin >> s >> t;
  int max = s.size();
  int count=0;
  for(int i=0; i < max; i++){
    if(s[i]!=t[i]) count++;
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3792
using System;
using System.Linq;
namespace _4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int d = x[0] / x[1];
            int r = x[0] % x[1];
            string f = (1.0* x[0]/x[1]).ToString("f12");
            Console.WriteLine(d + " " + r + " " + f);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 1000000
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int main() {

	LL n,i, arr[100], ans = 1000, buyp = INF, sellp = 0, j;
	cin>>n;

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

	for(i = 1; i < n; i++) {

		if(arr[i] > arr[i-1]) {

			LL nstk = ans/arr[i-1];
			ans = ans % arr[i-1];

			ans += (nstk * arr[i]);
		}
	 }

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

Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main(){
    string S;
    cin >> S;

    cout << (S.at(0)!=S.at(1)&&S.at(1)!=S.at(2)&&S.at(0)!=S.at(2)?"Yes":"No") << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int k,a,b;
	cin>>k>>a>>b;
	if((a+k-1)/k*k<=b) cout<<"OK";
	else cout<<"NG";
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToList();
            
            var ans = 1 ;
            var now = a[0];
            var change = 0;

            for(int i = 1; i < n; i++)
            {
                if(change == 0)
                {
                    if(now < a[i])
                    {
                        change = 1;
                    }
                    else if(now > a[i])
                    {
                        change = -1;
                    }
                }
                else if(change == 1)
                {
                    if(now > a[i])
                    {
                        ans++;
                        change = 0;
                    }
                }
                else if(change == -1)
                {
                    if(now < a[i])
                    {
                        ans++;
                        change = 0;
                    }
                }
                now = a[i];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 38564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> asum(n+1);
    rep(i, n) {
        cin >> a[i];
        if ( i == 0 ) asum[0] = abs(a[i]);
        else          asum[i] = asum[i-1] + abs(a[i] - a[i-1]);
    }
    asum[n] = asum[n-1] + abs(0 - a[n-1]);
    rep(i, n) {
        int tmp_num = 0;
        if ( i == 0 ) {
            tmp_num = abs(a[1] - 0);
            cout << ( asum[n] - asum[i+1] ) + tmp_num << endl;
        }
        else if ( i == n - 1 ) {
            tmp_num = abs(0 - a[n-2]);
            cout << tmp_num + asum[i-1] << endl;
        }
        else {
            tmp_num = abs(a[i+1] - a[i-1]);
            cout << ( asum[n] - asum[i+1] ) + tmp_num + asum[i-1] << endl;
        }
    }
    return 0;
}


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


Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
int main() {
	string S;
	cin >> S;
	bool h = true;
	for (int i = 0; i < (int)(S.length()); i++) {
		if (h) {
			if (S[i] != 'h') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (S[i] != 'i') {
				cout << "No" << endl;
				return 0;
			}
		}
		h = !h;
	}
	
	if (h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
B = set()

for i in list(range(1, N+1))[::-1]:
  tmp = i
  cnt = 0
  while tmp <= N:
    if tmp in B:
      cnt += 1    
    tmp += i

  if cnt % 2 != A[i-1]:
    B.add(i)

len_b = len(B)
if len_b == 0:
  print(0)
else:
  print(len_b)
  print(*sorted(list(B)))

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

// 一行取って、一番初めのTを習得
template <class T> int streamvar(std::istream& in, T& var)
{
    string s;
    if (!in) {
        return 1;
    }
    getline(in, s);
    istringstream is(s);
    is >> var;
    if (is.fail()) 
        return 1;
    return 0;
}
// 一行取って、T vectorに格納する
template <class T> int streamvec(std::istream& in, std::vector<T> &v)
{
    v.clear();
    string s;

    if (!in) 
        return 1;
    getline(in, s);
    if (in.fail()) 
        return 1;
    istringstream is(s);
    while (1) {
        T tmp;
        is >> tmp;
        if (is.fail())
            break;
        v.push_back(tmp);
    }
    return 0;
}

#define EPS 1e-6
int main(void)
{
    vector<int> v;
    while (!streamvec(cin, v)) {
        double det = v[0] * v[4] - v[3] * v[1];
        double x = v[4] * v[2] - v[1] * v[5];
        double y = -v[3] * v[2] + v[0] * v[5];
        printf("%.3f %.3f\n", round(x/det*1000)/1000+EPS, round(y/det*1000)/1000+EPS);
    }
    return 0;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, l, r;
    int ans=0;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> l >> r;
        ans += r - l + 1;
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
 
/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
const int mod = (int)1e9 + 7 ;
const int inf = (int)1e9 ;
/************************************************************/

 
signed main(){
	string s ; cin >> s ;
	int len = s.size() ;
	int mx = 0 ;
	for( int i = 0 ; i < len ; i++ ){
		int cnt = 0 ;
		if( s[i] == 'R' ){
			cnt = 1 ;
			int j = i + 1 ;
			while( j < len && s[j] == 'R' ){
				cnt++ ;
				j++ ;
			}
			i = j - 1 ;
			mx = max( mx, cnt ) ;
		}
	}
	cout << mx ;
	return 0 ;
}
  


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}
int rate(int num) {
	if (num <= 399) return 0;
	if (num <= 799) return 1;
	if (num <= 1199) return 2;
	if (num <= 1599) return 3;
	if (num <= 1999) return 4;
	if (num <= 2399) return 5;
	if (num <= 2799) return 6;
	if (num <= 3199) return 7;
	return 8;
}


int main() {
	int n; cin >> n;
	vector<int> a(n),score(9);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		score[rate(a[i])]++;
	}
	int minz=0, maxx;
	for (int i = 0; i < 8; i++) {
		if (score[i] != 0) minz++;
	}
	maxx =score[8] + minz;
	if (minz == 0) minz = 1;
	cout << minz << " " << maxx;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

typedef complex<double> P;

int main()
{
  int n;
  int i;

  while(1){
    cin>>n;
    if(n==-1)break;
    P p(1,0);
    rep(i,n-1){
      P t=p;
      t*=P(0,1);//90????????¢
      t=t/abs(t);
      p=p+t;
    }
    cout<<p.real()<<endl;
    cout<<p.imag()<<endl;
  }

}

Measured memory_bytes: 3100
# Aizu Problem 0058: Orthogonal
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, x4, y4 = [float(_) for _ in line.split()]
    scalar_product = (x2 - x1) * (x4 - x3) + (y2 - y1) * (y4 - y3)
    print("YES" if abs(scalar_product) < 1e-10 else "NO")

Measured memory_bytes: 7520
#include <cstdio>

void rotate90(int*);


int main() {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    int vec[2] = {x2 - x1, y2 - y1};
    int p1[2] = {x1, y1};
    int p2[2] = {x2, y2};

    rotate90(vec);
    int p3[2] = {p2[0]+vec[0], p2[1]+vec[1]};
    rotate90(vec);
    int p4[2] = {p3[0]+vec[0], p3[1]+vec[1]};

    printf("%d %d %d %d\n", p3[0], p3[1], p4[0], p4[1]);

    return 0;
}


void rotate90(int* v) {
    int x, y;
    x = v[0];
    y = v[1];
    v[0] = -y;
    v[1] = x;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const long long INF = 1LL << 60;
const ll inf = 1e9;
const long long MOD = 1000000007;

const int MAX_V = 1000000;

//辺を表す構造体（行先、容量、逆辺）
struct edge { int to, cap, rev; };

vector<vector<edge>> G(MAX_V);        //グラフの隣接リスト表現
int level[MAX_V];                     //ｓからの距離
int iter[MAX_V];                      //どこまで調べ終わったか

//fromからtoへ向かう容量capの辺をグラフに張る
void add_edge(int from, int to, int cap) {
    edge F, T;
    F.to = to; F.cap = cap; F.rev = G[to].size();
    G[from].push_back(F);

    T.to = from; T.cap = 0; T.rev = G[from].size() - 1;
    G[to].push_back(T);
}

//sからの最短経路をBFSで調べる
void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        rep(i, G[v].size()) {
            edge& e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

//増加パスをdfsで調べる
int dfs(int v, int t, int f) {
    if (v == t)return f;
    for (int& i = iter[v]; i < G[v].size(); i++) {
        edge& e = G[v][i];                  //辺の容量を更新するのでアドレスをもっておく
        if (level[v] < level[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;                 //使った分容量を減らす
                G[e.to][e.rev].cap += d;    //使った分逆辺の容量を増やす
                return d;
            }
        }
    }
    return 0;
}

//sからｔへの最大流を求める
int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        bfs(s);
        if (level[t] < 0)return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, inf)) > 0) {
            flow += f;
        }
    }
}


int main() {
    int n;
    cin >> n;
    vector<P> v1(n), v2(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v1[i] = P(a, b);
    }
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v2[i] = P(a, b);
    }
    rep(i, n) {
        rep(j, n) {
            if (v1[i].first < v2[j].first && v1[i].second < v2[j].second) {
                add_edge(i, j+n, 1);
            }
        }
    }
    rep(i, n) {
        add_edge(n * 2, i, 1);
        add_edge(n + i, n * 2 + 1, 1);
    }
    cout << max_flow(n * 2, n * 2 + 1) << endl;
    return 0;
}

Measured memory_bytes: 34640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string s = Console.ReadLine();
            Console.WriteLine("2018" + s.Substring(4));

            //Console.Out.Flush();

        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}


Measured memory_bytes: 11092
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE UndecidableInstances #-}

module Main where

import Control.Category hiding (id, (.))
import Control.Monad
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as BS
import Data.IORef
import Data.List as List
import Data.Maybe
import Data.Set as Set
import qualified Data.Vector.Unboxing as U
import qualified Data.Vector.Unboxing.Mutable as UM
import GHC.Generics

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readIntList :: BS.ByteString -> [Int]
readIntList = Prelude.map readInt . BS.words

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = readIntList <$> BS.getLine

-- data Point = Pt {-# UNPACK #-} !Int {-# UNPACK #-} !Int
--   deriving (Generic)
--   deriving (U.Unboxable) via U.Generics Point

-- ptX :: Point -> Int
-- ptX (Pt x y) = x

-- ptY :: Point -> Int
-- ptY (Pt x y) = y

data Item = Item
  { price :: {-# UNPACK #-} !Int,
    idx :: {-# UNPACK #-} !Int
  }
  deriving (Eq)

instance Ord Item where
  compare item0 item1 = compare (price item0) (price item1) <> compare (idx item0) (idx item1)

divideItem :: Item -> Item
divideItem Item {price = price, idx = idx} = Item {price = price `div` 2, idx = idx}

divideItems :: Set Item -> Set Item
divideItems s = Set.insert (divideItem . findMax $ s) . deleteMax $ s

sumItems :: Set Item -> Int
sumItems = sum . fmap price . toList

main :: IO ()
main = do
  [n, m] <- getIntList
  as <- getIntList
  let items0 = Set.fromList . fmap (\(idx, a) -> Item {price = a, idx = idx}) $ zip [0 ..] as
      items1 = List.foldl' (\items _ -> divideItems items) items0 [1 .. m]
  print . sumItems $ items1

Measured memory_bytes: 25140
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[25];
int t[25];
signed main(){
    int x;
    cin>>x;
    int l=0;
    int ans=0;
    while(x){
        l++;
        t[l]=x%10;
        x/=10;
    }
    for(int i=1;i<=l;i++){
        a[i]=t[l-i+1];
    }
    for(int i=1;i<=l;i++){
        for(int j=1;i+j-1<=l;j++){
            int sum=0;
            for(int k=j;k<=i+j-1;k++){
                sum*=10;
                sum+=a[k];
            }
            if(i+j-1==l || j==1){
                for(int k=1;k<=l-i-1;k++){
                    sum*=2;
                }
                ans+=sum;
            }
            else{
                for(int k=1;k<=l-i-2;k++){
                    sum*=2;
                }
                ans+=sum;
            }
        }
    }
    cout<<ans;
    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int h, w;
    char s[102], n[102];

    scanf("%d %d", &h, &w);
    for(int i = 0; i < w + 2; i++) s[i] = '#';
    s[w+2] = '\0';

    printf("%s\n", s);

    for(int i = 0; i < h; i++){
        scanf("%s", n);
        printf("%c%s%c\n", '#', n, '#');
    }
    printf("%s\n", s);

    return 0;
}

Measured memory_bytes: 1736
package main

import (
	"fmt"
	"math"
	"strings"
)

func main() {
	var S string
	fmt.Scan(&S)

	strs := strings.Split(S, "")
	m := map[string]int{}

	for i := 0; i < len(S); i++ {
		m[strs[i]]++
	}
	for i := 0; i < len(S); i++ {
		if m[strs[i]] != 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) > abs(a[j]) }


Measured memory_bytes: 640
n=int(input())
d=[]
s1=input()
s2=input()

i=0
while i<n:
    if s1[i]==s2[i]:
        i+=1
        d.append(1)
    else:
        i+=2
        d.append(0)
l=len(d)
if d[0]==0:
    ans=6
else:
    ans=3
for i in range(1,l):
    if d[i-1]==1:
        ans*=2
        ans=ans%1000000007
    elif d[i]==0:
        ans*=3
        ans=ans%1000000007
print(ans)


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int64 n,m;
  scanf("%lld%lld",&n,&m);
  if(n>m){
    int64 swap=n;
    n=m;
    m=swap;
  }
  if(m==1){
    printf("1\n");
  } else if(n==1){
    printf("%lld\n",m-2);
  } else {
    printf("%lld\n",(n-2)*(m-2));
  }
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 205100;

template <typename T>
void read(T &x) {
    x = 0; char c = getchar();
    while (!isdigit(c)) c=getchar();
    for (;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^48);
}

int x, y, n, res, st;
int d[N], sum[N], u[N], cnt[N];
inline int to(int x) {return 1 << x;}
int main() {
    read(n);
    for (int i = 1;i < n; i++) {
        int x, y, a; read(x), read(y), read(a);
        u[x] ^= a, u[y] ^= a;
    }
    for (int i = 0;i < n; i++) cnt[u[i]]++;
    int all = to(15);
    for (int i = 1;i < all; i++) d[i] = d[i>>1] + (i & 1);
    for (int i = 1;i < all; i++) d[i]--;
    for (int i = 1;i <= 15; i++) res += cnt[i] / 2, st |= (cnt[i] & 1) << (i-1);
    for (int i = 1;i < all; i++) 
        for (int j = 0;j < 15; j++) 
            if (i & to(j)) sum[i] ^= (j + 1);
    for (int i = 1;i < all; i++) {
        if (sum[i] != 0) continue;
        for (int j = (i - 1) & i; j; j = (j - 1) & i) 
            if (sum[j] == 0) d[i] = min(d[i], d[j] + d[i ^ j]);
    }
    cout << res + d[st] << endl;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
using namespace std;
int field[12][12];
void island(int x,int y,int h);
int main(){
	for(;;){
		for(int i=0; i<12; i++){
			for(int j=0; j<12; j++){
				if(scanf("%1d",&field[i][j]) == EOF){goto end;}
			}
		}
		int x = 1;
		for(int i=0; i<12; i++){
			for(int j=0; j<12; j++){
				if(field[i][j] == 1){island(i,j,++x);}
			}
		}
		cout <<x-1<<endl;
	}
	end:;
	return 0;
}
void island(int x,int y,int h){
	field[x][y] = h;
	if(x>0){if(field[x-1][y] == 1){island(x-1,y,h);}}
	if(y>0){if(field[x][y-1] == 1){island(x,y-1,h);}}
	if(x<11){if(field[x+1][y] == 1){island(x+1,y,h);}}
	if(y<11){if(field[x][y+1] == 1){island(x,y+1,h);}}
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    if(a<=x&&x<=a+b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
// I totally forgot the casse that all n people's rates are more than 3200 and then the minimal colors are one.
// if you try to output the length of counter, it will bi wrong. (the above case is the only countercase).

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

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

  map<string, int> counter;

  int exception = 0;

  for(int i=0;i<n;i++) {
    int rate;
    cin >> rate;
    if(rate<400) counter["gray"]++;
    else if(rate<800) counter["brown"]++;
    else if(rate<1200) counter["green"]++;
    else if(rate<1600) counter["skyBlue"]++;
    else if(rate<2000) counter["blue"]++;
    else if(rate<2400) counter["yellow"]++;
    else if(rate<2800) counter["orange"]++;
    else if(rate<3200) counter["red"]++;
    else exception++;
  }
  if(counter.size()==0) {
    cout << 1 << " ";
  } else {
    cout << counter.size() << " ";
  }
  

  cout << counter.size() + exception << endl;

}

Measured memory_bytes: 256
// Problem : C - Tsundoku
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

template <class T> int binser(T const &ref, long long key)
{
    int low = 0;
    int high = ref.size() - 1;

    while (low < high)
    {
        int mid = low + (high - low) / 2;
        if (ref[mid] == key)
            return mid;
        else if (ref[mid] > key)
            high = mid - 1;
        else
            low = mid + 1;
    }
    return ref[low] > key && low != 0 ? low - 1: low;
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for (auto &e : a)
        cin >> e;
    for (auto &e : b)
        cin >> e;

    vector<long long int> A, B;
    A.push_back(0);
    A.push_back(a[0]);
    B.push_back(0);
    B.push_back(b[0]);

    for (int t = 1; t < n; t++)
        A.push_back(A[A.size() - 1] + a[t]);

    for (int t = 1; t < m; t++)
        B.push_back(B[B.size() - 1] + b[t]);

    int ans = 0;
    for (int a = 0; a < n+1 && k >= A[a]; a++)
    {
    	//int it = upper_bound(B.begin(), B.end(), k - A[a]) - B.begin();
    	//it--;
        ans = max(ans, a + binser(B, k - A[a]));
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 9156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	string s;
	cin >> s;
	int n = s.size() / 2;
	string cent = "";
	string back = "";
	REP(i,n) {
		cent += s[i];
		back += s[s.size() - 1 - i];
	}
	if (s.size() % 2 == 1) {
		if ((cent + s[n] + back == s) && (cent == back))cout << "Yes";
		else cout << "No";
	}
	else {
		if ((cent + back == s) && (cent == back))cout << "Yes";
		else cout << "No";
	}

	return 0;
}

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

int main(){
    string s;
    int K;
    cin >> s >> K;
    set<string> st;
    for(int i=0; i<s.size(); i++){
        for(int j=1; j<=5; j++){
            if(i+j > s.size()) continue;
            st.insert(s.substr(i, j));
        }
    }
    int cnt = 1;
    for(auto x : st){
        if(cnt == K){
            cout << x << endl;
            return 0;
        }
        cnt++;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

struct UnionFind
{
    vector<int> par, rank;

    UnionFind(int N) : par(N), rank(N)
    {
        rep(i, N) par[i] = i, rank[i] = 0;
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        if (rank[rx] < rank[ry])
        {
            par[rx] = ry;
        }
        else
        {
            par[ry] = rx;
            if (rank[rx] == rank[ry])
                rank[rx]++;
        }
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


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

    UnionFind tree(N);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        tree.unite(A, B);
    }

    vector<int> cnt(N);
    rep(i, N) {
        cnt[tree.root(i)]++;
    }

    sort(cnt.rbegin(), cnt.rend());
    //rep(i, N) cout << cnt[i] << endl;

    cout << cnt[0] << endl;
    return 0;
}

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

int main(void){

    int N; cin>>N;
    double sum=0;
    for (int i = 0; i < N; ++i) {
        double tmp; cin>>tmp;
        sum += (1.0/tmp);
    }
    double ans = 1.0/(sum);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long K = sc.nextLong();

		long ans = (K%2 == 0) ? A-B : B-A;
		if(Math.abs(ans) > Math.pow(10, 18)) {
			System.out.println("Unfair");
		}else {
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main(){
     
        int N, k;
        cin >> N >> k;
        int h[N];
     
        for(int i = 0; i < N; i++){
     
            cin >> h[i];
        }
     
        int* dystruct = new int[N];
     
        dystruct[0] = 0;
    	dystruct[1] = abs(h[0] - h[1]);
        int mini;
        for(int i = 2; i < N; i++){
     
            mini = dystruct[i-1] + abs(h[i-1] - h[i]);
    		for(int j = 2; j <= k && j <= i; j++){
     
    			mini = min(mini, dystruct[i-j] + abs(h[i-j] - h[i]));
    		}
            dystruct[i] = mini;
        }
     
        cout<<dystruct[N-1]<<"\n";
     
        return 0;
    }

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main () {


    string o, e, res = "";
    cin >> o >> e;

    for (int i = 0; i < o.size(); i++){
        res += o[i];
        if (i < e.size()){
            res += e[i];
        }
    }



    cout << res << endl;


// aattccooddeerrbreeggiunlnaerrccoonntteesstt
// aattccooddeerrbreeggiunlnaerrccoonntteesstt
// aattccooddeerrbreeggiunlnaerrccoonntteesstt
// aattccooddeerrbreeggiunlnaerrccoonntteesstt

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cstdlib>
#include<cassert>
using namespace std;




int main(){
    while(1){
    
    int x,y,s;
    cin>>x>>y>>s;
        if(x==0 && y==0 && s==0){break;}
    x+=100;
    y+=100;
    int ans=0;
    for(int i=s-1;i>0;i--){
        if(i*x/100<=s){
            for(int t=i;t>0;t--){
                if(i*x/100+t*x/100==s){
                    ans=max(ans,i*y/100+t*y/100);
                }
            }
        }
    }
    
    cout<<ans<<endl;
    
    }
    
    return 0;
}



Measured memory_bytes: 3064
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
else:
  l = list(map(int, input().split()))
  
  ze = [0 for i in range(101)]
  
  for i in range(n):
    ze[abs(x-l[i])] += 1
    
  if ze[0] == 0:
    print(x)
  else:
    for i in range(1, 101):
      if ze[i] < 2:
        if x-i not in l:
          print(x-i)
          sys.exit()
        else:
          print(x+i)
          sys.exit()


Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

vector<bool> seen;
vector<int> d;
vector<int> f;
#define pi 3.141592653589793


int main(int argc,char **argv){
  int n,k; cin>>n>>k;

  map<int,int> mp;
  vector<pair<int,int>> vec;
  rep(i,0,n){
    int ai;cin>>ai;
    mp[ai]+=1;
  }

  for(auto p:mp){
    int k,v;
    k=p.first; v=p.second;
    vec.push_back(make_pair(v,k));
  }

  sort(all(vec));

  int col=mp.size();
  int ans=0;

  if(k>=col){
    cout<<ans<<endl;
    return 0;
  }

  int i=0;
  while(k<col){
    ans+=vec[i].first;
    col--;
    i++;
  }

  cout<<ans<<endl;
  }

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

using namespace std;

int main() {
    double a;
    int n;
    cin >> n;
    vector<double> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> a;
        vec.at(i) = a;
    }
    for (int j = 0; j < n; ++j) {
        vec.at(j) = 1 / vec.at(j);
    }
    double amount = 0;
    for (double k : vec) {
        amount += k;
    }
    cout << 1 / amount << endl;
}


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

constexpr int INF = (1 << 30) - 1;

int main()
{
	int N, K;
	int X[100005];

	cin >> N >> K;
	
	for ( int i = 0; i < N; i++ ) {
		cin >> X[i];
	}
	
	K--;
	int minv = INF;
	for ( int i = K; i < N; i++ ) {
		int l = X[i - K], r = X[i];
		if ( r <= 0 ) minv = min(minv, -l);
		else if ( l >= 0 ) minv = min(minv, r);
		else minv = min(minv, min(-l * 2 + r, -l + r * 2));	
	}

	cout << minv << endl;

	return ( 0 );
}


Measured memory_bytes: 640
#include <iostream>

int main()
{
	int A; std::cin >> A;
	int B; std::cin >> B;
	int C; std::cin >> C;
	int D; std::cin >> D;
	int ans = (A*B>=C*D ? A*B : C*D);
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int mod = 1e9 + 7;

  int N;
  string s;
  cin >> N;
  cin >> s;

  map<char, ll> m;
  for (char c : s) {
    if (m.count(c) == 0) {
      m[c] = 1;
    } else {
      m[c]++;
    }
  }

  int result = 1;
  for (auto it = m.begin(), end = m.end(); it != end; ++it) {
    result = (result * (1 + it->second)) % mod;
  }
  result -= 1;

  cout << result % mod << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e9 + 7;
ll inf = 1e9 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}





int main() {
    ll t = 1;
    //cin >> t;
    while (t--) {
        string s;
        cin >> s;
        ll sum = 0;
        for (auto w : s) {
            sum += (w - '0');
        }
        if (sum % 9 == 0) {
            cout << "Yes";
        }
        else {
            cout << "No";
        }
        
    }
}

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

int main(){
  int n;
  while(cin>>n,n){
    int ans=0;
    for(int i=1;i*i<=n;i++){
      if(i*i == n){
	ans++;
      }
      for(int j=i;i*i+j*j<=n;j++){
	if(i*i + j*j == n){
	  ans++;
	}
	for(int k=j;i*i+j*j+k*k<=n;k++){
	  if(i*i + j*j + k*k == n){
	    ans++;
	  }
	  for(int l=k;i*i+j*j+k*k+l*l<=n;l++){
	    if(i*i + j*j + k*k + l*l == n ){
	      ans++;
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160