akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
ll MAX=9223372036854775807;

string f(int x){
	string s="000000";
	int i=5;
	while(x){
		s[i]=char('0'+x%10);
		x/=10;
		i--;
	}
	return s;
}

vi v[100001];

int main(){
    fast_io;
    int n,m;
    cin>>n>>m;
    int val[m],y[m];
    for (int i = 0; i < m; ++i)
    {
    	cin>>val[i]>>y[i];
    	v[val[i]].emplace_back(y[i]);
    }
    fo(i,0,100000) sort(v[i].begin(), v[i].end());
    map<int,string>ans;
    fo(i,0,100000){
    	int k=1;
    	string s=f(i);
    	for(auto j:v[i]){
    		ans[j]=s+f(k);
    		k++;
    	}
    }
    for (int i = 0; i < m; ++i)
    {
    	show(ans[y[i]]);
    }
    return 0;
}

Measured memory_bytes: 18688
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt();
        if(n == 1){
            System.out.println("Hello World");
        } else {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a + b);
        }
    }
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
const int maxn=100+5;
int a[maxn<<1];
int ans=0;
int n;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=(n<<1);i++)
	a[i]=read();
	sort(a+1,a+1+(n<<1));
	for(int i=1;i<=2*n;i+=2)
	{
		ans+=min(a[i],a[i+1]);
	}
	printf("%d",ans);
	return 0;
}

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

long long  n,k;
vector<long long> x,y;

long long solve();
long long cnt(long long l,long long r,long long d,long long u);

int main(){
    cin >> n >> k;
    x.resize(n);
    y.resize(n);
    for(int i = 0;i < n;++i)cin >> x[i] >> y[i];
    cout << solve() << endl;
    return  0;
}
long long solve(){
    long long ans = (long long)9e18;
    for(int i = 0;i < n;++i)
        for(int j = i;j < n;++j)
            for(int m = j;m < n;++m)
                for(int o = 0;o < n;++o){
                    long long  l,r,u,d;
                    l = min({x[i],x[j],x[m],x[o]});
                    r = max({x[i],x[j],x[m],x[o]});
                    d = min({y[i],y[j],y[m],y[o]});
                    u = max({y[i],y[j],y[m],y[o]});
                    if(cnt(l,r,d,u) >= k)ans = min(ans,(r- l) * (u - d));
                }
        return ans;
}
long long cnt(long long l,long long r,long long d,long long u){
    long long ans = 0;
    for(int i = 0;i < n;++i)
        if(x[i] >= l && x[i] <= r && y[i] >= d && y[i] <= u)++ans;
    return ans;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let n: usize = input();
    let ps: Vec<(i64, i64)> = input_lines_two(n);

    let mut sum = 0.;
    for i in 0..n - 1 {
        for j in i + 1..n {
            sum += ((ps[i].0 as f64 - ps[j].0 as f64).powi(2)
                + (ps[j].1 as f64 - ps[i].1 as f64).powi(2))
            .sqrt();
        }
    }

    let ans = sum * 2. / n as f64;
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

#define HASH_TBL_SIZE 1000001
int T[HASH_TBL_SIZE] = {0};

int h1(int k) {
    return k % HASH_TBL_SIZE;
}

int h2(int k) {
    // return h1(k);
    return 1 + k % (HASH_TBL_SIZE - 1);
}

int h(int k, int i) {
    return (h1(k) + i * h2(k)) % HASH_TBL_SIZE;
}

int strhash(char *str) {
    int i, val = 0;
    for (i=0;i<strlen(str);i++) {
        val *= 4;
        if (str[i] == 'A') {
            val += 1;
        } else if (str[i] == 'C') {
            val += 2;
        } else if (str[i] == 'G') {
            val += 3;
        } else if (str[i] == 'T') {
            val += 4;
        }
    }
    return val;
}

unsigned int BKDRHash(char *str) {
    unsigned int seed = 31; // 31 131 1313 13131 131313 etc..
    unsigned int hash = 0;

    while (*str) {
        hash = hash * seed + (*str++);
    }

    return (hash & 0x7FFFFFFF);
}

// return -1 when full
int insert(int T[], int k) {
    int i = 0, index = 0;
    for (i = 0; i < HASH_TBL_SIZE; i++) {
        index = h(k, i);
        if (T[index] == 0) {
            T[index] = k;
            return index;
        }
    }
    return -1;
}

int search(int T[], int k) {
    int i = 0, index = 0;
    for (i = 0; i < HASH_TBL_SIZE; i++) {
        index = h(k, i);
        if (T[index] == k) {
            return index;
        }
        if (T[index] == 0) {
            break;
        }
    }
    return -1;
}

int main() {
    int n, i, k;
    char cmd[100], str[100];
    for (i = 0; i < HASH_TBL_SIZE; i++) {
        T[i] = 0;
    }
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", cmd, str);
        k = strhash(str);
        if (cmd[0] == 'i') {
            insert(T, k);
        } else {
            if (search(T, k) == -1) {
                printf("no\n");
            } else {
                printf("yes\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 5592
mondaisu, teishutsusu = map(int, input().split())
kekka =[input().split() for i in range(teishutsusu)]
l = [0] * mondaisu
p = [0] * mondaisu
for n, a in kekka:
  if a == 'AC':
    l[int(n) - 1] = 1
  else:
    if l[int(n) - 1] == 0:
      p[int(n) - 1] += 1
for i in range(len(p)):
  if l[i] == 0:
    p[i] = 0  
      
print(sum(l), sum(p))

Measured memory_bytes: 33692
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ld pi = 3.14159265358;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll L = 1;
    ll H = N;
    for(ll i = 1;i * i <= N;i++){
        if(N % i == 0){
            L = i;
            H = N / i;
        }
    }
    ll ans = 0;
    //cout << L << " " << H << endl;
    while(H){
        H /= 10;
        ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3660
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
      Scanner scanner = new Scanner(System.in);
      int W= scanner.nextInt();
      int H = scanner.nextInt();
      int x = scanner.nextInt();
      int y = scanner.nextInt();
      int r = scanner.nextInt();
      if ((x-r>=0&&y-r>=0)&&(x+r<=W&&y+r<=H)) {
    	  System.out.println("Yes");
      }else {
    	  System.out.println("No");
      }
      scanner.close();
  }
}


Measured memory_bytes: 26432
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a.at(i);
    int ans = 0;
    int lamp = 1;
    for (int i = 0; i < N; i++) {
        lamp = a.at(lamp - 1);
        ans++;
        if (lamp == 2) break;
        else if (lamp == 1) {
            ans = -1;
            break;
        }
        else if (i == N - 1) ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include<string>
using namespace std;
int main(){
	int a,b,c,x,y;
	cin>>a>>b>>c;
	y=0;
	for(x=a; x>=a&&x<=b; x=x+1){
		if(c%x==0){
		y=y+1;
		}
	}
	cout<<y<<endl;
	return 0;
}



















Measured memory_bytes: 3112
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> v;
  for (int i = 100; i > 0; i--)
  {
    if (a % i == 0 && b % i == 0)
    {
      v.push_back(i);
    }
  }
  cout << v[k - 1] << "\n";
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep (i, h) cin >> s[i];
    int res = 0;
    rep (i, h) {
        rep (j, w) {
            if (s[i][j] == '#') continue;
            rep (k, h) {
                rep (l, w) {
                    if (s[k][l] == '#') continue;
                    if (i == k && j == l) continue;
                    pair<int, int> st, g;
                    st.first = i, st.second = j, g.first = k, g.second = l;
                    vector<vector<int> > maze(h, vector<int>(w, 1e7));
                    queue<pair<int, int> > q;
                    q.push(st);
                    maze[st.first][st.second] = 0;
                    bool reached = false;
                    while (!q.empty()) {
                        if (reached) break;
                        int x, y;
                        x = q.front().first, y = q.front().second;
                        q.pop();
                        rep (m, 4) {
                            int nx, ny;
                            nx = x + dx[m], ny = y + dy[m];
                            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                            if (s[nx][ny] == '#') continue;
                            if (maze[nx][ny] != 1e7) continue;
                            maze[nx][ny] = maze[x][y] + 1;
                            q.push(make_pair(nx, ny));
                            if (nx == g.first && ny == g.second) {
                                res = max(res, maze[nx][ny]);
                                reached = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
using namespace std;


int main(){
	int a[3];
	bitset<11> cards;
	while(cin>>a[0]>>a[1]>>a[2]){
		cards.reset();
		int sum=a[0]+a[1];
		int ans=0;
		cards[a[0]]=1;
		cards[a[1]]=1;
		cards[a[2]]=1;
		for(int i=1;i<11;i++){
			//cout<<cards[i];
			if(sum+i<=20&&cards[i]==0){
				ans++;
			}
		}
		//cout<<endl;
		//cout<<ans<<endl;
		if(ans*2>7){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
}

Measured memory_bytes: 1148
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		if (N == M) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	void calc() {
	}

	void showResult() {
	}
}


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

int main() {
  string x;
  for (;;) {
    cin >> x;
    if (x == "0")
      return 0;
    int sum = 0;
    for (int i = 0; i < x.size(); ++i)
      sum += (x[i] - '0') % 10;
    cout << sum << endl;
  }
}


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

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

	if(a*b>c*d)
		cout<<a*b<<endl;
	else if(a*b<c*d)
		cout<<c*d<<endl;
	else
		cout<<a*b<<endl;
}

Measured memory_bytes: 256
N = int(input())
tmp = [-1 for i in range(N + 1)]
tmp[0] = 0
s = [1]

for i in range(5):
    s.append(9** (i + 1))
for i in range(6):
    s.append(6** (i + 1))

for i in range(1, N+1):
    for j in range(N+1):
        if tmp[j] == i - 1:
            for k in range(12):
                a = j + s[k]
                if a <= N and tmp[a] == -1:
                    tmp[a] = i
    if tmp[N] > -1:
        break
print(i)

Measured memory_bytes: 44784
/*input
3
*/
#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;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    int k;
    cin>>k;
    REP(i,k) cout<<"ACL";
}


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


int main ()
{

 int A,B,a,b,c;
 cin >> A >> B;
 
 a=A*B;
 b=A+B;
 c=A-B;
 
 if(a>b && a>c)
 {
	  cout << a;
 }
 else if(b>c)
 {
	  cout << b;
 }
 else
 {
	 cout << c;
 }

	return 0;
}











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

#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'
typedef long long ll;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int MXN = 1e5 + 5;


int main(){FIO
   #ifndef  ONLINE_JUDGE
   freopen("in", "r", stdin);
   freopen("out", "w", stdout);
   #endif
   int n; cin>>n;
   if(n%1000)cout<<1000-n%1000<<endl;
   else cout<<0<<endl;

   return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int out=0;
	while(n--){
		string a;
		cin>>a;
		rep(i,a.size())if(a[i]==s[0]){
			bool h=true;
			loop(j,i,a.size())if(a[j]==s[1]){
				h=true;
				int b=j-i;
				rep(k,s.size())if(i+k*b<a.size()&&a[i+k*b]==s[k]);else{h=false;break;}
				if(h){out++;break;}
			}
			if(h)break;
		}
	}
	cout<<out<<endl;
}

Measured memory_bytes: 1208
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [10**9]*n
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        if (i+j <n):
            dp[i+j] = min(dp[i+j],dp[i] + abs(h[i]-h[i+j]))
print(dp[-1])


Measured memory_bytes: 52448
#include<iostream>
#include<cstdio>

int A[4];
int B[4];
int main()
{
  while(scanf("%d %d %d %d\n%d %d %d %d",&A[0],&A[1],&A[2],&A[3],&B[0],&B[1],&B[2],&B[3]) != EOF){
  int Hit = 0;
  int Blow = 0;
  for(int i = 0;i < 4;i++){
    for(int j = 0; j < 4;j++){
      if(A[i] == B[j]){
	if(i ==j){
	  Hit++;
	}else
	  Blow++;
      }
    }
  }
    printf("%d %d\n",Hit,Blow);
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
char s[100001];

int strlength(const char *s) {
	int length = 0;
	while (*s++)length++;
	return length;
}
int main() {
	cin >> s;
	int len = strlength(s);
	cout << s[0] << len - 2 << s[len - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n,m) for (int i = (int)(n); i < (int)(m); i++)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

typedef long long ll;

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

bool isR(string s);

int main()
{
    int H,N;
    cin >> H >> N;
    vector<int> v(N);
    rep(i,N)
    {
        cin >> v.at(i); 
    }
    int sum = accumulate(v.begin(),v.end(),0);
    if(H <= sum)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

int main() {
    int N;
    std::cin >> N;
    std::vector<int> a;
    a.reserve(3 * N);
    while(N--) {
        int x;
        std::cin >> x;
        a.push_back(x);
        a.push_back(x - 1);
        a.push_back(x + 1);
    }

    std::sort(begin(a), end(a));

    int ans = 0;
    int idx = 0;
    while (idx < a.size()) {
        int j = idx + 1;
        while(j < a.size() && a[idx] == a[j]) ++j;
        ans = std::max(ans, j - idx);
        idx = j;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;

class UF {
  vector<int> a;
public:
  UF(int n) : a(n) {
    for (int i = 0; i < n; ++i) a[i] = i;
  }
  int root(int i) {
    if (a[i] == i) return i;
    return a[i] = root(a[i]);
  }
  bool same(int i, int j) {
    return root(i) == root(j);
  }
  void unite(int i, int j) {
    int ri = root(i);
    int rj = root(j);
    a[ri] = rj;
  }
};


int n, m;
int x[100000];

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    --x[i];
  }
  
  UF uf(n);
  for (int j = 0; j < m; ++j) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    uf.unite(a, b);
  }
  
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (uf.same(i, x[i])) ++cnt;
  }
  cout << cnt << endl;
}

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

int main(void)
{
  char S[3]={'\0'};
  scanf("%s",&S);
  int count = 0;
  int a = strlen(S);
  for (int i=0;i<2;i++){
    if (S[i]!=S[i+1])
    count ++;
  }
if (count>=1)printf("Yes");
else printf("No");

    return EXIT_SUCCESS;
}

Measured memory_bytes: 128
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s) {

    int rec(int head) {
        int change = 0;
        for (int i = 0; i < s.length; i += 2) {
            if (s[i] != (head == 0 ? '0' : '1'))
                change++;

            if (i+1 < s.length && s[i+1] != (head == 0 ? '1' : '0'))
                change++;
        }
        return change;
    }

    return min(rec(0), rec(1));
}

void main() {
    string s = read!string;
    writeln(calc(s));
}



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

using namespace std;

typedef pair<int,int> P;
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};

int main(){
  int Tc,M,N;

  cin >> Tc;
  while(Tc--){
    vector<P> vec;
    for(int i = 0 ; i < 4 ; i++){
      vec.push_back(P(dx[i],dy[i]));
    }
    cin >> M >> N;
    vec.push_back(P(M,N));
    vec.push_back(P(-N,M));
    vec.push_back(P(-M,-N));
    vec.push_back(P(N,-M));
    int cnt = 0;

    for(int m = -200 ; m <= 200 ; m++){
      for(int n = -200 ; n <= 200 ; n++){
        if(m == n && m == 0) continue;
        int X = m*m + n*n;
        if(!((m*M+n*N) % X == 0 && (m*N-n*M)%X == 0)) continue;
        int Y = (m*M+n*N)/X;
        int Z = (m*N-n*M)/X;
        if((M*M+N*N)/X == Y*Y+Z*Z){
          bool ok = true;
          for(int i = 0 ; i < 8 ; i++){
            if(vec[i].first == m && vec[i].second == n){
              ok = false;
              break;
            }
          }
          if(ok) cnt++;
        }
      }
    }
   
    if(cnt == 0) cout << "P" << endl;
    else cout << "C" << endl;
  }

  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

struct dice
{
  vector<int> num;

  dice(int t[]) : num(7){
    for(int i=0;i<6;++i)num[i+1]=t[i];
  };
  int state(){return num[1];}
  int right(){return num[3];}

  void s()
  {
    vector<int> tmp(7);
    tmp[1] = num[5];
    tmp[2] = num[1];
    tmp[3] = num[3];
    tmp[4] = num[4];
    tmp[5] = num[6];
    tmp[6] = num[2];
    num = tmp;
  }
  void n()
  {
    vector<int> tmp(7);
    tmp[5] = num[1];
    tmp[1] = num[2];
    tmp[3] = num[3];
    tmp[4] = num[4];
    tmp[6] = num[5];
    tmp[2] = num[6];
    num = tmp;
  }
  void e()
  {
    vector<int> tmp(7);
    tmp[1] = num[4];
    tmp[2] = num[2];
    tmp[3] = num[1];
    tmp[4] = num[6];
    tmp[5] = num[5];
    tmp[6] = num[3];
    num = tmp;
  }
  void w()
  {
    vector<int> tmp(7);
    tmp[4] = num[1];
    tmp[2] = num[2];
    tmp[1] = num[3];
    tmp[6] = num[4];
    tmp[5] = num[5];
    tmp[3] = num[6];
    num = tmp;
  }
  void r()
  {
    vector<int>tmp(7);
    tmp[1]=num[1];
    tmp[2]=num[3];
    tmp[3]=num[5];
    tmp[4]=num[2];
    tmp[5]=num[4];
    tmp[6]=num[6];
    num = tmp;
  }

  void top(int val)
  {
    if(num[1]==val)
      return;
    else if(num[2]==val)
      n();
    else if(num[3]==val)
      w();
    else if(num[4]==val)
      e();
    else if(num[5]==val)
      s();
    else
    {
      n(); n();
    }
  }
  void front(int val)
  {
    if(num[2]==val)
      return;
    else if(num[3]==val)
      r();
    else if(num[4]==val)
    {
      r(); r(); r();
    }
    else if(num[5]==val)
    {
      r(); r();
    }
  }
};

int main()
{
  vector<dice>ds;
  int q;
  cin >> q;
  for(int i=0;i<q;++i)
  {
    int n[6];
    for(int i=0;i<6;++i)cin>>n[i];
    dice d(n);
    ds.push_back(d);
  }

  for(int a=0;a<q;++a)
  {
    for(int b=0;b<q;++b)
    {
      if(a==b)continue;
      for(int i=1;i<=6;++i)
      {
        for(int j=1;j<=6;++j)
        {
          int n[7];
          for(int i=0;i<6;++i)
            n[i]=ds[b].num[i+1];
          if(i==2)ds[b].n();
          else if(i==3)ds[b].w();
          else if(i==4)ds[b].e();
          else if(i==5)ds[b].s();
          else if(i==6)
          {
            ds[b].n();ds[b].n();
          }
          if(j==1)ds[b].s();
          else if(j==3)ds[b].r();
          else if(j==4)
          {
            ds[b].r(); ds[b].r(); ds[b].r();
          }
          else if(j==5)
          {
            ds[b].r(); ds[b].r();
          }
          else if(j==6)ds[b].n();
          bool tmp=true;
          for(int k=1;k<=6;++k)
          {
            if(ds[a].num[k]!=ds[b].num[k])
              tmp=false;
          }
          if(tmp)
          {
            cout<<"No"<<endl;
            return 0;
          }
          dice t(n);
          ds[b]=t;
        }
      }
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}



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

int main(){
    int N;
    long long A[200];

    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    long long cnt;
    bool flg=true;
    for(cnt=-1;flg;cnt++){
        for(int i=0;i<N;i++){
            if(A[i]&1){ flg=false; break; }
        }
        if(flg){
            for(int i=0;i<N;i++) A[i] >>= 1;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;
 
int main(){
 
  string s; int x,y;
  cin >> s >> x >> y;
  
  int step[10000] = {}; // 連続何歩歩く？　偶数インデックスにｘ方向、奇数にｙ方向
  int xsum = 0, ysum = 0; // x､y方向の総移動距離｡
  
  int turn = 0;
  REP(i,s.size()){
    if(s[i] == 'T') turn++;
    else{
      while(s[i] == 'F' && i < s.size()){
        step[turn]++;
        i++;
      }
      if(turn % 2 == 0) xsum += step[turn];
      else				ysum += step[turn];
      turn++;
    }
  }
  
//  debug(xsum);
 // debug(ysum);
  
  if(xsum % 2 != abs(x % 2) || ysum % 2 != abs(y % 2)){
    cout << "No" << endl; return 0;
  }
  
  // 		正方向にxがとる値をDPで求める，
  int X = (xsum + x)/2;  int Y = (ysum + y)/2;
    if(X < 0 || Y < 0){
    cout << "No" << endl; return 0;
  }
  
  int DPx[20000],DPy[20000];
  REP(i,20000) {
    DPx[i] = -1; DPy[i] = -1;
  }
  
  DPx[step[0]] = 0;  	// xははじめ正方向で固定		
  
  for(int i = 2; i < turn; i+=2){
    REP(j,X+1){
      if(DPx[j] != -1 && DPx[j] != i){
        if(DPx[j+step[i]] == -1)
          DPx[j+step[i]] = i;
      }
    }
  }
  
  // yも同様

  DPy[0] = 0;         // yはすべて右を選んだ時０になるので０を埋めておく。
  
  for(int i = 1; i < turn; i+=2){
    REP(j,Y+1){
      if(DPy[j] != -1 && DPy[j] != i){
        if(DPy[j+step[i]] == -1)
          DPy[j+step[i]] = i;
      }
    }
  }
  
//  REP(i,X+1) debug(DPx[i]);
//  REP(i,Y+1) debug(DPy[i]);
  
  if(DPx[X] == -1 || DPy[Y] == -1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  
  return 0;
}
  

  
  

Measured memory_bytes: 512
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

const int MAX_N = 1 << 20;
// セグメント木を持つグローバル配列
int n, dat[2 * MAX_N - 1];
// 初期化

int cti_mf(char s){
    int k=s-'a';
    return 1<<k;
}

void init(int n_)
{
    // 簡単のため、要素数を2のべき乗に
    n = 1;
    while (n < n_)
        n *= 2;
    // すべての値をINT_MAXに
    for (int i = 0; i < 2 * n - 1; i++)
        dat[i] = 0;
}
// k番目の値(0-indexed)をaに変更
void update(int k, char a)
{
    // 葉の節点
    k += n - 1;
    dat[k] = cti_mf(a);
    // 登りながら更新
    while (k > 0)
    {
        k = (k - 1) / 2;
        dat[k] = dat[k * 2 + 1]| dat[k * 2 + 2];
    }
}
// [a, b)の最小値を求める
// 後ろのほうの引数は、計算の簡単のための引数。
// kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
// したがって、外からはquery(a, b, 0, 0, n)として呼ぶ。
int query(int a, int b, int k, int l, int r)
{
    // [a, b)と[l, r)が交差しなければ、INT_MAX
    if (r <= a || b <= l)
        return 0;
    // [a, b)が[l, r)を完全に含んでいれば、この節点の値
    if (a <= l && r <= b)
        return dat[k];
    else
    {
        // そうでなければ、2つの子の最小値
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

        return vl|vr;
    }
}

int main(){
    int debug=0;
    int N;
    cin>>N;
    init(N);
    REP(i,N){
        char tmp;
        cin>>tmp;
        update(i,tmp);
    }

    int Q;
    cin>>Q;
    REP(i,Q){
        int p;
        cin>>p;
        if(p==1){
            int p2;
            char p3;
            cin>>p2>>p3;
            p2-=1;
            update(p2,p3);
        }
        if(p==2){
            int p2;
            int p3;
            cin>>p2>>p3;
            p2-=1;
            int ans=query(p2,p3,0,0,n);
            cout<<__builtin_popcount(ans)<<endl;
        }
    }
}

Measured memory_bytes: 6400
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int tmp,case_num = 1;
 
        while((tmp = sc.nextInt()) != 0){
            System.out.printf("Case %d: %d\n",case_num++, tmp);
        }
    }
}


Measured memory_bytes: 67508
a1, b1 = map(int,input().split())
a2, b2 = map(int,input().split())
a3, b3 = map(int,input().split())

r_city_list = [a1, b1, a2, b2, a3, b3]

if r_city_list.count(1) == 3 or r_city_list.count(2) == 3 or r_city_list.count(3) == 3 or r_city_list.count(4) == 3:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

map<pii, int> memo;
const int MOD = 1e9 + 7;
int func(int S, int X) {
    if (CONTAIN(memo, pii(S, X))) return memo[{S, X}];
    if (S == 0 && X == 0) return 1;
    int ret = 0;
    ret += func(S / 2, X / 2);
    if (S >= 1 && X >= 1) ret += func((S - 1) / 2, (X - 1) / 2);
    if (S >= 2) ret += func((S - 2) / 2, X / 2);
    return memo[{S, X}] = ret % MOD;
}
signed main() {
    int N;
    cin >> N;
    cout << func(N, N) << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
N=int(input(""))
l=input("").split()
L=[int(n) for n in l]
max=max(L)
min=min(L)
min_shohi=1000000
for P in range(min,max+1):
    shohi=0
    for x in L:
        shohi+=(x-P)**2
    if shohi<min_shohi:
        min_shohi=shohi
print(min_shohi)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll x0 = 0;
  rep(i, n) x0 += a[i] * ((i & 1) ? -1 : 1);
  x0 /= 2;
  cout << x0 * 2;
  for (int i = 0; i < n - 1; ++i) {
    x0 = (a[i] - x0);
    cout << " " << x0 * 2;
  }
  cout << endl;
}


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

int main(){
  int N;
  cin >> N;
  int S = 0, M = 0;
  for(int i = 0; i < N; i++){
    int p;
    cin >> p;
    S += p;
    M = max(M, p);
  }
  
  int ans = S - M/2;
  cout << ans << endl;
  
  return 0;
}

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

int main() {
	int h,w;cin>>h>>w;
  	vector<vector<char>> s(h+2,vector<char>(w+2,'.'));
  	for(int i=1;i<h+1;i++){
    	for(int j=1;j<w+1;j++){
        	cin>>s[i][j];
        }
    }
  	for(int i=1;i<h+1;i++){
    	for(int j=1;j<w+1;j++){
        	if(s[i][j]=='#'){
              if(s[i-1][j]!='#' && s[i][j-1]!='#' && s[i+1][j]!='#' && s[i][j+1]!='#'){
              	cout<<"No"<<endl;
                return 0;
              }
        	}
    	}
    }
  	  cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
"""
implementation of the Insertion Sort
"""
number_of_input = int(raw_input())

numbers = [int(x) for x in raw_input().split()]
print " ".join([str(x) for x in numbers])
for i in range(1, number_of_input):
    target = numbers[i]
    index = i - 1
    while index >= 0 and target < numbers[index]:
        numbers[index + 1] = numbers[index]
        index -= 1
    numbers[index + 1] = target
    print " ".join([str(x) for x in numbers])

Measured memory_bytes: 6424
from sys import stdin
import math
a=stdin.readline().split()

A=int(a[0])
B=int(a[1])
H=int(a[2])
M=int(a[3])

pos1=(30*H)+(M/2)
pos2=(6*M)
AA=abs(pos1-pos2)
if AA>180:
    AA=360-AA

ans=math.sqrt(A*A+B*B-2*A*B*(math.cos(AA*(math.pi)/180)))
print(ans)

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

int main() {
  int s = 0;
  rep(i, 3) {
    int a;
    cin >> a;
    s += a;
  }

  if (s >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
code = r"""
# distutils: language=c++
from libcpp.set cimport set
from libcpp.vector cimport vector
from cython.operator cimport dereference as deref, predecrement as dec
cdef int n = int(input()), i
cdef long c
cdef vector[long] a = [*map(int, input().split())]
cdef vector[long] l = [0] * n
for i in range(n): l[a[i] - 1] = i
cdef set[long] s = set[long]([-1, n])
cdef set[long].iterator it
for i in range(n):
    it = s.lower_bound(l[i])
    c += (deref(it) - l[i]) * (l[i] - deref(dec(it))) * (i + 1)
    s.insert(l[i])
print(c)
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 33392
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Map<Long,Long> drink = new TreeMap<Long,Long>();
		for(int i = 0; i < n; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			if(drink.containsKey(a)) {
				drink.put(a,drink.get(a)+b);
			}
			else {
				drink.put(a, b);
			}
		}
		long ans = 0;
		for(long key:drink.keySet()) {
			long temp = drink.get(key);
			if(m -temp<= 0) {
				ans += m*key;
				break;
			}
			else {
				ans += temp*key;
				m -= temp;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 68232
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

ll gcd(ll b, ll c){
    return c ? gcd(c, b % c) : b;
}

int main(){
    ll K;
    cin >> K;
    ll sum = 0;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                sum += gcd(gcd(i, j), k);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	var sol Solver
	sol.n = getNextInt(scanner)
	sol.m = getNextInt(scanner)
	sol.rr = make([]int, sol.n)
	for i := 0; i < sol.m; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		sol.rr[a]++
		sol.rr[b]++
	}

	for i := 0; i < sol.n; i++ {
		fmt.Fprintln(writer, sol.rr[i])
	}

	writer.Flush()
}

// Solver...
type Solver struct {
	n, m int
	rr   []int
}


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

int main() {
  string s;
  cin >> s;
  int len = s.length();
  int ans = len;
  for (int i = 0; i < len-1; i++) {
    if (s[i] != s[i+1]) {
      ans = min(ans, max(i+1, len-i-1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
import sys

N = int(input())

# n 円を引き出すための最小の引き出し回数

table = [i for i in range(0, N  + 1)]  # 1円ずつ引き出した場合

for base in (6, 9):  
  unit = base  # 引き出し単位
  while unit <= N:
    for i in range(unit, N + 1):
      table[i] = min(
        table[i],
        table[i - unit] + 1
      )
    
    unit *= base

print(table[N])    

Measured memory_bytes: 44912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    vector<int> x(3);
    rep(i, 3) cin >> x[i];
    sort(x.begin(), x.end());
    if(x[0]==x[1]) cout << x[2];
    else cout << x[0];
}


Measured memory_bytes: 256
## coding: UTF-8
N = int(input())
#N = 4
s = "abcdedcba" #よく更新する文字列
answer = ['a'] #回答となる文字列のリストを入れる場所 　初期値はN=1の['a']を入れておきます。

#文字列の中から辞書順で最大のアルファベットを検索するコード
def search_max(s):
    max = 'Z' #大文字の方が文字コードが若い。aよりも若いものを最大値として押さえておく
    for i in range(len(s)):
        if(s[i] > max):
            max = s[i]
    return max

#アルファベットに対して次の文字を返すコードではなく
#アルファベットに対して次の文字までのリストを返す
def next(p):
    list_alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
    alpha_index = -100
    for i in range(len(list_alpha)):
        if(p == list_alpha[i]):
            alpha_index = i
    #return list_alpha[alpha_index + 1]
    return list_alpha[:alpha_index+2]



#n文字の文字列（回答）が入ったリストを受け取ったら、その各文字列に対して1文字付け足して返す関数
def one_plus(l): 
    ret_list = [] #最終的に返すリスト
    for i in range(len(l)): #listの各要素に対して
        max_alpha = search_max(l[i]) #まずは要素の辞書順最大アルファベットを探す
        next_list = next(max_alpha) #次に入るアルファベット候補の羅列
        #print(next_list)
        for j in range(len(next_list)):
            ret_list.append(l[i] + next_list[j])
    return ret_list

for i in range(N-1):
    answer = one_plus(answer) #answerリストに1文字ずつ付け足して返す
#print(answer)

for i in range(len(answer)):
    print(answer[i]) #1行ずつ出力

'''
def sum(n):
    if n < 1:
        return n
    return n + sum(n-1)

si = sum(100)
print("1から100の合計は", si, "です")
'''
#print(search_max(s))
#print(next('a'))
#print(next('c'))
#print(one_plus(["aa", 'ab']))

Measured memory_bytes: 12988
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using Int = long long;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N+1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    int l = 1;
    Int cnt = 0, xo = 0, sum = 0;
    for (int r = 1; r <= N; r++) {
        xo ^= A[r];
        sum += A[r];
        while (xo != sum) {
            xo ^= A[l];
            sum -= A[l];
            l++;
        }
        cnt += r - l + 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

result = -1
for i in range(n):
  a_sum = sum(a[0:i+1])
  result = max(result, a_sum + sum(b[i:]))
  
print(result)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long  A,B,K,a,b;
  cin >> A >> B >> K;
  if(K%2==0){
    for(int i=0;i<K/2;i++){
      if(A%2==1){A--;}
      B+=A/2; A=A/2; 
      if(B%2==1){B--;}
      A+=B/2; B=B/2; 
    }
  }
  else{
    for(int i=0;i<(K-1)/2;i++){
      if(A%2==1){A--;}
      B+=A/2; A=A/2; 
      if(B%2==1){B--;}
      A+=B/2; B=B/2; 
    }
    if(A%2==1){A--;}
    B+=A/2; A=A/2; 
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256