akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)

#define vll    vector<ll>
#define vvll   vector<vector<ll>>
#define all(x) (x).begin(),(x).end()

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

	vector<int> d;
	for (int i = 1; i * i <= M; i++)
	{
		if (M % i == 0)
		{
			d.push_back(i);
			if(i != M / i) d.push_back(M / i);
		}
	}

	sort(all(d));

	auto itr = lower_bound(all(d), N);

	if (itr != d.end())
	{
		cout << M / *itr << endl;
	}
	else
	{
		cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Scanner;

public class Main {

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

        String s = sc.next();



//        if (date.equals(LocalDate.of(2019, 4, 30))) {
//            System.out.println("Heisei");
//        } else if (date.isBefore(LocalDate.of(2019, 4, 30))) {
//            System.out.println("Heisei");
//        } else {
//            System.out.println("TBD");
//        }

        int y = Integer.parseInt(s.substring(0, 4));
        int m = Integer.parseInt(s.substring(5, 7));
        int d = Integer.parseInt(s.substring(8, 10));

        if (y == 2019 && m == 4 && d == 30) {
            System.out.println("Heisei");
            return;
        }

        if (y > 2019) {
            System.out.println("TBD");
            return;
        }
        if (y == 2019 && m > 4) {
            System.out.println("TBD");
            return;
        }
        System.out.println("Heisei");

    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int x12 = x2 - x1;
		int y12 = y2 - y1;
		int x3 = x2 - y12;
		int y3 = y2 + x12;
		int x4 = x3 - x12;
		int y4 = y3 - y12;
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
	}
}


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

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

int main(){
	int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> color(9, 0);
  int wild = 0;
  rep(i, n){
    if(a[i] < 3200) color[a[i] / 400]++;
    else wild++;
  }

  int cn = 0;
  rep(i, 8){
    if(color[i]) cn++;
  }

  int mn;
  mn = max(1, cn);

  int mx;
  mx = cn + wild;

  cout << mn << " " << mx << endl;

	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
struct Trie {
	Trie *next[2];
	Trie() {
		next[0] = next[1] = NULL;
	}
	void insert(char *s) {
		if (*s == '\0') return;
		if (this->next[*s - '0'] == NULL)
			this->next[*s - '0'] = new Trie();
		this->next[*s - '0']->insert(s + 1);
	}
};
vector<LL> item;
LL L;
char s[100001];
void dfs(Trie *t, int d) {
	int cnt = 0;
	if (t->next[0] != NULL) {
		dfs(t->next[0], d + 1);
		cnt++;
	}
	if (t->next[1] != NULL) {
		dfs(t->next[1], d + 1);
		cnt++;
	}
	if (cnt == 1) item.push_back(L - d);
}
int main() {
	int N;
	cin >> N >> L;
	Trie t;
	for (int i = 0; i < N; i++) {
		cin >> s;
		t.insert(s);
	}
	dfs(&t, 0);
	LL g = 0;
	for (int i = 0; i < item.size(); i++) {
		int k = 0;
		while (item[i] % 2 == 0) {
			item[i] /= 2;
			k++;
		}
		g ^= (1LL << k);
	}
	if (g == 0) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
}

Measured memory_bytes: 9336
def smaller(x, y):
	if x < y: return x
	return y

N, M = map(int, input().split())
coins = list(map(int, input().split()))
dp = []
for i in range(0, N+1):
	dp.append(100000)
dp[0] = 0
for i in range(0, N):
	for j in range(0, M):
		if i+coins[j] <= N:
			dp[i+coins[j]] = smaller(dp[i]+1, dp[i+coins[j]])
print(dp[N])


Measured memory_bytes: 7376
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

// ?????? N ??????????????°?????????????????¢???????????§
// Verified: AOJ DPL_3_C: Largest Rectangle in a Histogram

int histArea(vector<int> h) {
    // ??????
    int N = h.size();
    h.push_back(0); N++;

    // height, position
    int ans = 0;
    stack<pii> S;
    rep(i,0,N+1) {
        if(S.empty()) S.push(pii(h[i], i));

        if     (S.top().first < h[i])
            S.push(pii(h[i], i));
        else if(S.top().first > h[i]) {
            int lastpos = 0;
            while(!S.empty() && S.top().first >= h[i]) {
                lastpos = S.top().second;
                chmax(ans, S.top().first * (i-lastpos));
                S.pop();
            }
            S.push(pii(h[i], lastpos));
        }
    }
    return ans;
}

// ?????§????????¢?????? (?¶??????????????????????????????£?????§??????????????¢?????¢????????§)
// ??? dp_003_histogram.cpp ????????????????????§??¨??????
// 0 -> ?¶??????????????????? 1 -> ?±??????????????????????
// Verified: AOJ DPL_3_B: Largest Rectangle

int maxRectangle(vector< vector<int> > board) {
    int H = board.size(), W = board[0].size();
    vector< vector<int> > sum(H, vector<int>(W));
    rep(i,0,H) rep(j,0,W) {
        if(board[i][j] == 1) continue;
        sum[i][j] = (i > 0 ? sum[i-1][j] : 0) + 1;
    }
    int ret = 0;
    rep(i,0,H) chmax(ret, histArea(sum[i]));
    return ret;
}

signed main() {
    int H, W;
    while(cin >> H >> W, H || W) {
        char c;
        vector< vector<int> > board(H, vector<int>(W));
        rep(i,0,H) rep(j,0,W) {
            cin >> c;
            if(c == '*') board[i][j] = 1;
            else board[i][j] = 0;
        }
        cout << maxRectangle(board) << endl;
    }
    return 0;
}

Measured memory_bytes: 8696
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

// struct path
// {
//     pair<ll, ll> f;
//     pair<ll, ll> t;
// };

// struct cmp
// {
//     bool operator() ( path a, path b ) const
//     { return std::make_pair(a.f,a.t) > std::make_pair(b.f,b.t) ; }
// };


void solve()
{
    string x;
    cin>>x;
    ll n = x.size();
    if(x[n-1]=='2' || x[n-1]=='4' || x[n-1]=='5' || x[n-1]=='7' ||x[n-1]=='9')
    {
        cout<<"hon"<<endl;
    }
    else if(x[n-1]=='0' || x[n-1]=='1' || x[n-1]=='6' || x[n-1]=='8')
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"bon"<<endl;
    }
    
}   

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3616
// use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

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

    let mut x: Vec<i64> = x;
    x.sort();

    let mut d: Vec<(i64, usize)> = vec![];

    for i in 1..m {
        d.push(((x[i - 1] - x[i]).abs(), i))
    }
    d.sort_by(|a, b| b.0.cmp(&a.0));

    let mut p = vec![0, m];

    let z = if n > m { m } else { n };
    for i in 0..z - 1 {
        p.push(d[i].1);
    }
    p.sort();

    let mut result = 0;

    for i in 0..p.len() - 1 {
        result += x[p[i + 1] - 1] - x[p[i]];
    }

    println!("{}", result);
}


Measured memory_bytes: 6112
from collections import Counter

n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
if k < len(Counter(a).keys()):
    kv = Counter(a).most_common()
    for i in range(1, len(Counter(a).keys()) - k + 1):
        ans += kv[-i][1]

print(ans)


Measured memory_bytes: 50220
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
isok = (([a,b,c,d,e].max() - [a,b,c,d,e].min()) <= k)

if isok
puts "Yay!"
else
puts ":("
end

Measured memory_bytes: 1788
from collections import defaultdict
s = input()
t = input()
n = len(s)
sd = defaultdict(lambda: -1)
td = defaultdict(lambda: -1)
u, v = [0] * len(s), [0] * len(t)

for i in range(n):
    sc = s[i]
    if sd[sc] != -1:
        u[i] = sd[sc]
    else: 
        u[i] = i
        sd[sc] = i
    
    tc = t[i]
    if td[tc] != -1:
        v[i] = td[tc]
    else: 
        v[i] = i
        td[tc] = i
    
    if u[i] != v[i]:
        print("No")
        break
else: print("Yes")



Measured memory_bytes: 7216
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
#define debug puts
#define setp cout << fixed << setprecision(15)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int N=3e5+5;
const int MOD=998244353;
 
int main(void){
    FAST_IO;
    int n;
    cin >> n;
    vector<int> l(n+1),r(n+1);
//    cout << a[0]<<endl;
    for(int i=1;i<=n;i++){
        int a,b;
        cin >> a >>b;
        l[i]=a,r[i]=b;
    }
    sort(l.rbegin(),l.rend());
    sort(r.begin(),r.end());
    ll ans=0;
    for(int i=0;i<=n;i++){
        if(l[i]>r[i]){
            ans+=2*(l[i]-r[i]);
        }
    }
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <iterator>
#include <algorithm>

typedef long long lint;

using namespace std;

void showIntArray(lint a[], lint n);

int main() {
  vector<int> p;
  int tmp_p, tmp_q, tmp_r;
  cin >> tmp_p >> tmp_q >> tmp_r;
  p.push_back(tmp_p);
  p.push_back(tmp_q);
  p.push_back(tmp_r);
  sort(p.begin(), p.end());
  cout << p[0] + p[1] << endl;
  return 0;
}

void showIntArray(lint a[], lint n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  ll a,b,c,d;
  ll dp[3010][3010]={0};
  string s;
  
  cin >> a >> b >> c >> d;
  dp[a][b]=1;
  for(i=a;i<=c;i++){
    for(j=b;j<=d;j++){
      dp[i][j]+=i*dp[i][j-1]%MOD2;
      dp[i][j]+=j*dp[i-1][j]%MOD2;
      dp[i][j]-=(i-1)*(j-1)*dp[i-1][j-1]%MOD2;
      if(dp[i][j]<0) dp[i][j]+=MOD2;
      dp[i][j] %= MOD2;
    }
  }
  cout << dp[c][d] << endl;
  
  return 0;
}

Measured memory_bytes: 74372
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m;
int a[50],b[50],c[50],d[50];
int inf=1000000000;
int main(){
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> a[i] >> b[i];
  for(int i=0;i<m;i++)cin >> c[i] >> d[i];

  for(int i=0;i<n;i++){
    int ans=inf;
    int x;
    for(int j=0;j<m;j++){
      if(ans>abs(a[i]-c[j])+abs(b[i]-d[j])){
	ans=abs(a[i]-c[j])+abs(b[i]-d[j]);
	x=j;
      }
    }
    printf("%d\n",x+1);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n;
    cin >> n;
    int h[n+2];
    h[n+1] = 0;
    h[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }

    int minN = 0;
    int count = 0;
    int flag = 0;
//    for(int i = 0; i < n+2; i++){
//        cout << h[i] << " ";
//    }
    for(int i = 0; i <= n; i++){
        if(h[i] < h[i+1]){
            minN = min(minN, h[i]);
            flag = 1;
        }
        if(h[i] > h[i+1] && flag){
            count += (h[i]-minN);
            minN = h[i];
            flag = 0;
        }
    }

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	const m = 2019
	var exgcd func(a, b int) (gcd, x, y int)
	exgcd = func(a, b int) (gcd, x, y int) {
		if b == 0 {
			return a, 1, 0
		}
		gcd, y, x = exgcd(b, a%b)
		y -= a / b * x
		return
	}
	invM := func(a int) int { _, x, _ := exgcd(a, m); return (x%m + m) % m }

	var s []byte
	Fscan(bufio.NewReader(_r), &s)
	cnts := [m]int{0: 1}
	ans, v := 0, 0
	ten := 1
	for _, b := range s {
		b -= '0'
		v = (v*10 + int(b)) % m
		w := v * invM(ten) % m
		ans += cnts[w]
		cnts[w]++
		ten = ten * 10 % m
	}
	Fprint(_w, ans)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll X,Y,Z; cin >>  X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;


    return 0;
}


Measured memory_bytes: 256
/*
 © 2020-06-27 07:00:49 Franco1010 All Rights Reserved
*/

#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli x; cin >> x;
  cout << x + x *x + x* x * x << ENDL;
  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  string s; cin >> s;
  bool ok = 1;
  rep(i, s.size()) {
    if (i % 2 == 0 && s[i] == 'L') {
      ok = 0;
    }
    if (i % 2 == 1 && s[i] == 'R') {
      ok = 0;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;

  int i = 0;
  while(1){
    if(s[i] == '1'){
      k--;
      if(k == 0) {
        cout << 1 << endl;
        return 0;
      }
    }
    else{
      cout << s[i] << endl;
      return 0;
    }
    ++i;
  }
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    ll a[N];
    for(ll i = 0; i < N; i++) cin >> a[i];
    ll sum[N + 1] = {};
    for(ll i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];
    ll ans = 1145148931919810;
    for(ll i = 2; i <= N - 2; i++){
        ll mid1 = sum[i] / 2, mid2 = (sum[N] + sum[i]) / 2;
        ll po = lower_bound(sum, sum + i, mid1) - sum;
        ll yo = lower_bound(sum + i, sum + N, mid2) - sum;
        ll dis[] = {-1, 0, 1};
        for(ll j = 0; j < 3; j++){
            for(ll k = 0; k < 3; k++){
                ll pos1 = po + dis[j], pos2 = yo + dis[k];
                if(!(0 < pos1 && pos1 < i && i < pos2 && pos2 < N)) continue;
                vector<ll> tmp = {sum[pos1], sum[i] - sum[pos1], sum[pos2] - sum[i], sum[N] - sum[pos2]};
                sort(tmp.begin(), tmp.end());
                ans = min(ans, tmp[3] - tmp[0]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	string O,E;
	cin >> O >> E;
	
	for(int i=0; i<E.length(); i++){
		cout << O[i] << E[i];
	}
	
	if(O.length()!=E.length()){
		cout << O[O.length()-1] ;
	}
	cout << endl;
}

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

int main() {
  int n,m,i;
  cin>>n>>m;
  long long int a[n],b[n],c[m],d[m];
  for(i=0;i<n;i++)
    cin>>a[i]>>b[i];
  for(i=0;i<m;i++)
    cin>>c[i]>>d[i];
  
  long long int l[n]={},ans=0;
  
  for(i=0;i<n;i++){
    l[i]=500000001;
    for(int j=0;j<m;j++){
      if(abs(a[i]-c[j])+abs(b[i]-d[j]) < l[i]){
        l[i]=abs(a[i]-c[j])+abs(b[i]-d[j]);
        ans=j+1;}
        
    }
  cout<<ans<<endl;
    ans=0;
  }
  
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int P,Q,R;
  cin >> P >> Q >> R;
  cout << min(P+Q,min(Q+R,R+P)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

int main() {
    ll H, W;
    cin >> H >> W;

    vector<string> C(H);
    REP(i, H) {
        cin >> C[i];
    }

    REP(i, H) {
        cout << C[i] << endl << C[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

/*
int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	return 0;
}

*/

//problem - M

/* int main() {

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

int n, k;
cin >> n >> k;
vector<int> a(n + 1, 0);
for (int i = 1; i <= n; i++)
	cin >> a[i];
vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));

for (int i = 0; i <= k; i++)
	dp[1][i] = (i <= a[1]) ? 1 : 0;

for (int i = 2; i <= n; i++) {
	for (int j = 0; j <= k; j++) {
		if (j == 0)
			dp[i][j] = dp[i - 1][j];
		else
			dp[i][j] = (mod + dp[i][j - 1] + dp[i - 1][j] - ((j - 1 - a[i]) >= 0 ? dp[i - 1][j - 1 - a[i]] : 0) ) % mod;
	}
}


cout << dp[n][k] << endl;
return 0;
} */

// problem - N

//long long dp[402][402];
//long long  sum[402];
#define inf (1ll)<<60

long long solve(vector<long long> &a, vector<vector<long long>> &dp, vector<long long> &sum, int i, int j) {

	if (i == j)
		return 0;
	if (dp[i][j] != -1)
		return dp[i][j];
	//long long _min = 400ll * 1000000007;
	long long _min = inf;
	for (int k = i; k < j; k++) {
		_min = min(_min, sum[j] - sum[i - 1] + solve(a, dp, sum, i, k) + solve(a, dp, sum, k + 1, j));
	}
	return dp[i][j] = _min;
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	vector<long long> a(n + 1, 0);
	vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, -1));
	vector<long long> sum(n + 1, 0);
	//memset(dp, sizeof dp, -1);
	//memset(sum, sizeof sum, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}
	cout << solve(a, dp, sum, 1, n) << endl;
	return 0;
}




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

using namespace std;
int main()
{
    long long int a,b,c,d,x,y,z,s;
    cin>>a>>b>>c>>d;
    x=((c*d)/__gcd(c,d));
    if(a%c==0){
        y=b/c-a/c+1;}
    else if(a%c!=0){
        y=b/c-a/c;
    }
    if(a%d==0){
        z=b/d-a/d+1;}
    else if(a%d!=0){
        z=b/d-a/d;
    }
    if(a%x==0)
    {s=b/x-a/x+1;}
    else if(a%x!=0){
        s=b/x-a/x;
    }
    cout<<b-a-y-z+s+1;
    }



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

// typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
typedef pair<ll, ll> P;
// --------------------------------------
ll N, M;
priority_queue<P, vector<P>, greater<P>> que;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> M;
  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    que.push(make_pair(a, b));
  }

  ll sum = 0;
  ll ans = 0;
  while(sum < M) {
    P pp;
    ll a, b;
    pp = que.top();
    que.pop();
    a = pp.first;
    b = pp.second;

    if(b < M - sum) {
      ans += a * b;
      sum += b;
    } else {
      ll c;
      c = M - sum;
      ans += a * c;
      sum += c;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  ll R[N+1];
  R[0] = 0;
  map<ll,ll> mp;
  mp[0]++;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    R[i+1] = R[i] + A[i];
    mp[R[i+1]]++;
  }
  ll ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
     ll num = itr->second;
     ans += (num * (num - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15872
l = list(input().split())
c = 0
for i in l:
 l[c] = int(i)
 c+=1

k = min(l[3],l[4])
money = min((l[0]+l[1])*k, l[2]*2*k)

if l[3]>l[4]:
 m = l[3]-l[4]
 money += min(l[0], l[2]*2)*m
else:
 m = l[4]-l[3]
 money += min(l[1], l[2]*2)*m

print(money)

Measured memory_bytes: 38512
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto A = new long[][](3);
	foreach (i; 0..3)
		A[i] = RDA;

	auto N = RD;
	bool[long] set;
	foreach (i; 0..N)
	{
		auto b = RD;
		set[b] = true;
	}

	bool ans;
	foreach (i; 0..3)
	{
		if (set.get(A[i][0], false) && set.get(A[i][1], false) && set.get(A[i][2], false))
			ans = true;
		if (set.get(A[0][i], false) && set.get(A[1][i], false) && set.get(A[2][i], false))
			ans = true;
	}
	if (set.get(A[0][0], false) && set.get(A[1][1], false) && set.get(A[2][2], false))
		ans = true;
	if (set.get(A[0][2], false) && set.get(A[1][1], false) && set.get(A[2][0], false))
		ans = true;

	writeln(ans ? "Yes" : "No");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {
    val n = StdIn.readInt
    val as = StdIn.readLine.split(' ').toSeq.map(_.toLong)
    val x0 = as.foldLeft(0l)((acc, a) => a - acc)
    val xs = as.foldLeft(Vector(x0))((acc, a) => acc :+ a * 2l - acc.last).dropRight(1)
    val output = xs.mkString(sep = " ")
    println(output)
  }

}


Measured memory_bytes: 75604
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: "List[int]"):
    b = 1
    def mul(x: "List"):
        r = 1
        for i in x:
            r *= i

        return r
    
    u = 0
    for i in range(N):
        t = [A[j] for j in range(N) if j != i] 
        u += mul(t)

    print(mul(A)/u)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

using namespace std;
#define M 1005
#define N 15
#define ll long long
int arr[N];


int main()
{
    int n;
    cin>>n;
    double ans = ceil(n / 2.0);
    ans = ans / n;
    printf("%.6f\n",ans);

    return 0;
}
/*
2 3
10 1
1
15 1
2
30 2
1 2
*/


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

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void calc(int n, int a, int b) {
    while (true) {
        if (a + 1 < b) { // to right
            a++;
        }
        else if (a > 1) { // to left
            a--;
        }
        else {
            writeln("Borys");
            break;
        }

        if (a < b - 1) { // to left
            b--;
        }
        else if (b + 1 < n) { // to right
            b++;
        }
        else {
            writeln("Alice");
            break;
        }
    }
}

void main() {
    auto nab = readints;
    int n = nab[0], a = nab[1], b = nab[2];

    calc(n, a, b);
}

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



int main(){
        int n, k;
        cin >> n >> k;
        int count = 0;
        unordered_map<int,int> m;
        while(k--) {
                int d;
                cin >> d;
                for(int i = 0; i < d; i++) {
                        int temp;
                        cin >> temp;
                        m[temp]++;
                }
        }
        for(int i = 1; i <= n; i++) {
                if(m.find(i) == m.end()) count++;
        }
        cout << count << endl;
}


Measured memory_bytes: 3256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;


int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    
    int count = 0;
    for (int i = 1; i < N - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1])
            || (p[i - 1] > p[i] && p[i] > p[i + 1])) {
            count++;
        }
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;
int main() {
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
} 


Measured memory_bytes: 3576
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
#define debug(x) (cout << "#x = " << (x) << endl)
#define lowbit(x) (x & -x)
#define Set(x, i) memset(x, i, sizeof x)
#define R register
#define For( i, j, k ) for(R int i = (j); i <= (k); ++i)
#define Rep( i, j, k ) for(R int i = (j); i >= (k); --i)
#define Cross( i, j, k ) for(R int i = (j); i; i = (k))
typedef long long ll;
using namespace std;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	#define dd ch = getchar()
	inline ll read() {
		ll x = 0; bool f = 0; char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x); putchar (' '); }

	inline void wln ( ll x ) { write(x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x); wln (y); }

}

using namespace IO;

namespace Cesare {
	
	int main() {
		ll A = read(), B = read();
		return wln(max(0ll, A - 2 * B)), 0;
	}
	
}

int main()
{
	return Cesare :: main();
}

/*

*/



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
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); }
// *max_element(all(d));
int solve(){ 
  int d[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << d[k - 1] << endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
S=input()

def count(color_num,S):
    ans=0
    for i in range(len(S)):
        if i%2==0 and S[i]!=color_num:
            ans+=1
        elif i%2==1 and S[i]==color_num:
            ans+=1
    return ans

case_w=count('1',S)
case_b=count('0',S)

print(min(case_b,case_w))

Measured memory_bytes: 3316
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

n = int(input())
A = [int(input()) for _ in range(n)]

cnt = 0
G = [1]
for i in range(100):
    if n < 3*G[i] + 1:
        break
    G.append(3*G[i] + 1)
G.reverse()
m = len(G)

for i in range(m):
    insertionSort(A, n, G[i])
    
print(m)
print(" ".join(map(str, G)))
print(cnt)
print("\n".join(map(str, A)))


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

class Cube {
public:
  int face[6];
  Cube() {}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}    
  
  void roll(int i, int j, int k, int l) {
    int t = face[i];
    face[i] = face[j];
    face[j] = face[k];
    face[k] = face[l];
    face[l] = t;
  }
  
};

bool eq(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    if (c1.face[i] != c2.face[i]) return false;
  }
  return true;

}

bool equal(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) {
      if(eq(c1,c2)) return true;
      c1.roll_z();
    }
    if(i % 2 == 0) c1.roll_y();
    else c1.roll_x();
  }
  return false;

}

int main() {
  int n = 0;
  cin >> n;
  
  Cube c[1000];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) cin >> c[i].face[j];
  }

  int flag = 1;

  for (int i = 0; i < n-1; i++) {
    for (int j = i+1 ; j < n; j++) {
      if (equal(c[i],c[j])) flag = 0;
    }
  }
  
  if (flag == 1) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,b,f;
	cin>>n>>b;
	int a[n],i=0;
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	f=lower_bound(a,a+n,b)-a;
	cout<<n-f<<endl;
	return 0;
}

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

int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=c-a;
  int y=d-b;
  cout<<(c-y)<<endl;
cout<<(d+x)<<endl;
  cout<<(a-y)<<endl;
  cout<<(b+x)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char b[2];
  scanf("%s",&b);
  if(strcmp(b,"A")==0)
    puts("T");
  else if(strcmp(b,"T")==0)
    puts("A");
  else if(strcmp(b,"G")==0)
    puts("C");
  else
    puts("G");
  return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
a=[list(map(int,input().split())) for i in range(N)]
b=[list(map(int,input().split())) for i in range(M)]
for i in range(N):
    l=[]
    for j in range(M):
        l.append(abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]))
    print(l.index(min(l))+1)

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define XOR(x, y) (((x) && (y)) || ((!(x)) && (!(y))))

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRESICE_COUT std::cout << std::setprecision(15) << std::fixed

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  READ(s);

  // main procedure
  unordered_map<char, int> char_count;
  for (size_t i = 0; i < s.size(); i++)
  {
    char_count[s[i]]++;
  }

  int odd_char_num = 0;
  for (auto &&p : char_count)
  {
    if (p.second%2 == 1) {
      odd_char_num++;
    }
  }

  int ans = odd_char_num / 2;

  // output
  WRITE_N(ans);

  return 0;
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)                                                             \
  sort(x.begin(), x.end());                                                    \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y)                                                           \
  cerr << "(" << #x << ", " << #y << ") = "                                    \
       << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }

  map<int, int> mm;

  rep(i, n) {
    if (v[i] <= 399) {
      mm[0]++;

    } else if (v[i] <= 799) {
      mm[1]++;

    } else if (v[i] <= 1199) {
      mm[2]++;
    } else if (v[i] <= 1599) {
      mm[3]++;

    } else if (v[i] <= 1999) {
      mm[4]++;
    } else if (v[i] <= 2399) {
      mm[5]++;

    } else if (v[i] <= 2799) {

      mm[6]++;

    } else if (v[i] <= 3199) {
      mm[7]++;

    } else {
      mm[8]++;
    }
  }

  int isum = 0;

  rep(i, 8) {
    if (mm[i] != 0) { isum++; }
  }
  debug(isum);

  if (isum == 0) {
    cout << 1 << " " << mm[8] << endl;
  } else {
    cout << isum << " " << isum + mm[8] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  cin>>n;
  rep(i,2){
    if(n[i]=='9'){
      cout<<"Yes"<<'\n';
      return(0);
    }
  }
  cout<<"No"<<'\n';
  return(0);
}


Measured memory_bytes: 256
/**
*    created: 31.05.2020 21:51:44
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 3632
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 2e5+9;
const ll mod = 1e9+7;

int a[maxn];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		if (a[i] > i)
			return cout << "-1\n", 0;
	int ind = 0;
	while (ind < n - 1 && a[ind] == a[ind + 1] - 1) ind++;
	for (int i = 0; i < n; i++)
		if (a[i] == i && i > ind)
			return cout << "-1\n", 0;
	for (int i = 1; i < n; i++)
		if (a[i] - a[i - 1] > 1)
			return cout << "-1\n", 0;
	ll ans = 0;
	ind = n - 1;
	while (true) {
		ans += a[ind];
		while (ind != 0 && a[ind - 1] == a[ind] - 1) ind--;
		if (ind == 0) break;
		ind--;
	}
	cout << ans << "\n";
}



Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int n,k,a[233],tot;char str[233];
int main(){
	scanf("%s",str+1);
	n=strlen(str+1);
	scanf("%d",&k);
	for(int i=1,j=0;i<=n;++i){
		++j;
		if(str[i]!=str[i+1])
			a[++tot]=j,j=0;
	}
	long long ans=0;
	if(tot==1)printf("%lld\n",1ll*n*k/2);
	else if(str[1]!=str[n]){
		for(int i=1;i<=tot;++i)ans+=a[i]/2;
		printf("%lld\n",ans*k);
	}else{
		for(int i=2;i<tot;++i)ans+=a[i]/2;
		ans*=k;ans+=1ll*(a[1]+a[tot])/2*(k-1);
		ans+=a[1]/2;ans+=a[tot]/2;
		printf("%lld\n",ans);
	}
	return 0;
}


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

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

// [解法1] bit全探索
// void solve() {
//   std::string s;
//   std::cin >> s;
//   // check(SIZE(s));
//   int total = 0;
//   for (int i = 0; i < (1 << (SIZE(s) - 1)); i++) {
//     std::bitset<10> b(i);
//     // check(b);
//     b.set(SIZE(s) - 1);
//
//     int sum = 0;
//     int count = 1;
//     for (int j = 0; j < SIZE(s); j++) {
//       // check(j);
//       if (b.test(j)) {
//         // check(count);
//         // check(s.substr(j + 1 - count, count));
//         sum += std::stoll(s.substr(j + 1 - count, count));
//         count = 1;
//       } else {
//         count++;
//       }
//     }
//     // check(sum);
//     total += sum;
//     // cout("");
//   }
//   cout(total);
// }

// [解法2] 端から入れるかどうか決めていく再帰で深さ優先探索
void dfs(int i, std::string s, int next, int sofar, int &total);
void solve() {
  std::string s;
  std::cin >> s;
  int total = 0;
  dfs(0, s, 0, 0, total);
  cout(total);
}
void dfs(int i, std::string s, int next, int sofar, int &total) {
  if (i == SIZE(s) - 1) {
    total += sofar + next*10 + stoll(s.substr(i, 1));
    return;
  }
  // (i+1)文字目の後に+を入れない
  // インデックス(i)を動かし、
  // そこまでの合計(sofar)はそのままで保留している部分(next)を伸ばす
  dfs(i+1, s, next*10 + stoll(s.substr(i, 1)), sofar, total);
  // (i+1)文字目の後に+を入れる
  // インデックス(i)を動かし、
  // そこまでの合計(sofar)に保留している部分(next)を足す
  dfs(i+1, s, 0, sofar + next*10 + stoll(s.substr(i, 1)), total);
}


Measured memory_bytes: 256
d = input()
d = d.split()
a = int(d[0])
b = int(d[1])
c = int(d[2])
k = int(d[3])
f = 0
if a < k:
    f = f + a
    k = k - a
    if b < k:
        k = k - b
        f = f - k
    else:
        f = f
else:
    f = k
print(f)

Measured memory_bytes: 9076
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
total = 0

for i in range(N) :
    if A[i] >= B[i]:
        total += B[i]
    elif A[i] + A[i+1] >= B[i]:
        total += B[i]
        A[i+1] = A[i] + A[i+1] - B[i]
    elif A[i] + A[i+1] < B[i] :
        total += A[i] + A[i+1]
        A[i+1] = 0

print(total)


Measured memory_bytes: 18476