akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;

using ll = long long;
using boost::irange;

#define PI 3.14159

int main(){
    int N;

    cin >> N;

    vector<ll> X(720, 0), Y(720, 0);

    ll x, y;
    double ip;
    for (int i : irange(0, N)){
        cin >> x >> y;

        for (int j : irange(0, 720)){
            ip = cos(j * PI / 360) * x + sin(j * PI / 360) * y;
            if (ip > 0.0) {
                X[j] += x;
                Y[j] += y;
            }
        }
    }

    double r;
    double r_max = 0;
    for (int i : irange(0, 720)) {
        r = sqrt(X[i] * X[i] + Y[i] * Y[i]);
        if (r > r_max) r_max = r;
    }

    cout << std::fixed;
    cout << std::setprecision(15) << r_max << endl;

    return 0;


}

Measured memory_bytes: 512
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashSet, BTreeSet, BinaryHeap, HashMap};
#[allow(unused_imports)]
use std::io::{stdin, stdout, Write, BufReader, BufWriter};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
 
 
fn main() {
    let mut heights = vec![vec![vec![std::i64::MAX]; 101]; 101];
    let n = read::<usize>();
    for _ in 0..n {
        let vec = read_vector::<i64>();
        let (x, y, h) = (vec[0], vec[1], vec[2]);
        for i in 0..101 {
            for j in 0..101 {
                if heights[i][j][0] == -1 {
                    continue;
                }
                let height = h + (i as i64 - x).abs() + (j as i64 - y).abs();
                if h == 0 {
                    heights[i][j].push(height);
                } else if heights[i][j][0] == std::i64::MAX {
                    heights[i][j][0] = height;
                } else if heights[i][j][0] != height {
                    heights[i][j][0] = -1;
                }
            }
        }
    }
 
    let mut cand = vec![];
    for i in 0..101 {
        'outer: for j in 0..101 {
            if heights[i][j][0] == -1 {
                continue;
            }
            for k in 0..heights[i][j].len() {
                if heights[i][j][0] > heights[i][j][k] {
                    continue 'outer;
                }
            }

            cand.push((i, j));
        }
    }
 
    if cand.len() == 1 {
        let (i, j) = (cand[0].0, cand[0].1);
        println!("{} {} {}", i, j, heights[i][j][0]);
        return;
    }
    
}
 
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}
 
#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}
 
#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();
 
    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(line
            .trim()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect());
        line.clear();
    }
 
    return matrix;
}

Measured memory_bytes: 14588
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>

using namespace std;

int get_num(char& input) {
	if (input == '0') return 0;
	if (input == '1') return 1;
	if (input == '2') return 2;
	if (input == '3') return 3;
	if (input == '4') return 4;
	if (input == '5') return 5;
	if (input == '6') return 6;
	if (input == '7') return 7;
	if (input == '8') return 8;
	if (input == '9') return 9;
	return 0;
}

int main()
{
	int D, G;
	cin >> D >> G;
	vector<int> problem_num;
	vector<int> bonus_num;
	for (int i = 0; i < D; i++) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		problem_num.push_back(tmp1);
		bonus_num.push_back(tmp2);
	}

	vector<int> fullscore;
	for (int i = 0; i < D; i++) {
		fullscore.push_back((i + 1) * 100 * problem_num[i] + bonus_num[i]);
	} // 各問題完答時のスコア

	int min_problem_num = 100 * 10;

	for (int i = 0; i < (1 << D); i++) { // 各問題の組み合わせをビット探索
		int tmp_problem_num = 0;
		int tmp_total = 0;
		int highest_unused = 0;
		for (int j = 0; j < D; j++) {
			if (i & (1 << j)) {
				tmp_total += fullscore[j];
				tmp_problem_num += problem_num[j];
			}
			else {
				highest_unused = max(highest_unused, j);
			}
		}
		int suppli_num = 0;
		if ((G - tmp_total) > 0) {
			suppli_num = (G - tmp_total) / (highest_unused * 100+100);
			if (((G - tmp_total) % (highest_unused * 100 + 100)) != 0) suppli_num += 1;
		}
		if (problem_num[highest_unused] < suppli_num) continue;
		tmp_problem_num += suppli_num;
		if (min_problem_num > tmp_problem_num) { // スコア更新
			min_problem_num = tmp_problem_num;
		}
	}
	cout << min_problem_num << endl;
	return 0;

}


Measured memory_bytes: 256
#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)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
ll  MOD = (1e9+7);
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;
    vector<Abel> dat;
    /* [1, n] */
    BIT(int n) : dat(n+1, UNITY_SUM) {}
    void init(int n) { dat.assign(n+1, UNITY_SUM); }
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i=a; i<(int)dat.size(); i+=i & -i)
            dat[i] = dat[i] + x;
    }
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i=a; i>0; i-=i & -i)
            res = res + dat[i];
        return res;
    }
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b-1) - sum(a-1);
    }
};

// aoj http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) { cin >> a[i]; b[i] = a[i]; }
    sort(ALL(b));
    map<int, int> m;    // val -> index
    rep(i, n) m[b[i]] = i+1;
    BIT<int> bit(n+1);
    ll ans = 0;
    rep(i, n) {
        ans += i - bit.sum(m[a[i]]);
        bit.add(m[a[i]], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14664
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N;
    cin>>N;
    vector<int> p(N),p2(N);
    rep(i,N){cin>>p[i];p2[i]=p[i];}
    sort(ALL(p));
    int count=0;
    rep(i,N){if(p[i]!=p2[i]){
        count++;
    }}
    
    if(count==2||count==0)
    Out("YES");
    else
    Out("NO");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

char buf[100000+10];
int cs[100000+10];

int main(void) {
  int n, nQuery;
  scanf("%d%d%s", &n, &nQuery, buf);
  REP(i, n) {
    cs[i+1] = cs[i];
    if(buf[i] == 'A' && buf[i+1] == 'C') {
      cs[i+1]++;
    }
  }
  
  REP(iQuery, nQuery) {
    int bg, ed;
    scanf("%d%d", &bg, &ed);
    --bg;
    int res;
    if(ed-bg < 2) {
      res = 0;
    } else {
      res = cs[ed-1] - cs[bg];
    }
    printf("%d\n", res);
  }
  return 0;
}


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

using namespace std;

vector < int > v;
int main()
{
    int k , x;
    cin >> k >> x;
    for(int i = x - k + 1 ; i <= x ; i++)  v.push_back(i);
    for(int i = x + 1 ; i < x + k ; i++)    v.push_back(i);

    for(int i = 0 ; i < v.size() ; i++)
    {
        if(i) cout << ' ' ;
        cout << v[i];
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#define ALLRANGE(x) x.begin(), x.end()
using namespace std;

int main(){
  char x, y;
  cin >> x >> y;
  if (x>y) cout << ">" << endl;
  else if (x<y) cout << "<" << endl;
  else if (x=y) cout << "=" << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    string s, t;
    cin >> s >> t;
    int cnt = 0 ;
    for (int i = 0; i < 3; i++){
	  cnt += s[i] == t[i];	
	}
    cout << cnt << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 4000;
#define int long long
int a[maxn], p;
int inv[maxn]{1,1};
int po[maxn]{1};
inline int form(int i){return (i % p + p) % p;}
vector<int> operator * (const vector<int> &a, vector<int> b){
	vector<int> res(a.size() + b.size() - 1ul, 0);
	for(int i = 0;i < a.size();++i){
		for(int j = 0;j < b.size();++j){
			res[i+j] = form(res[i+j] + a[i] * b[j]);
		}
	}
	return res;
}
vector<int> fun{0, 1}, r;
int getv(int i){
	int ci = i, res = r[0];
	for(int j = 1;j < r.size();++j){
		res = form(res + ci * r[j]);
		ci = form(ci * i);
	}
	return res;
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> p;
	for(int i = 0;i < p;++i)cin >> a[i];
	// 
	for(int i = 2;i < p;++i)inv[i] = (p-p/i) * inv[p % i] % p;
	// 
	r.resize(p);	
	r[0] = a[0];
	for(int i = 1;i < p;++i){
		for(int j = 1;j < p;++j)po[j] = form(po[j-1] * i);
		int ls = 0, v = 1;
		for(int j = 0;j < p;++j)ls = form(ls + r[j] * po[j]);
		for(int j = 0;j < i;++j)v = form(v * form(i-j));
		int sc = form(inv[v] * form(a[i] - ls));
		for(int i = 0;i < fun.size();++i)r[i] = form(r[i] + sc * fun[i]);
		fun = fun * vector<int>{-i, 1};
	}
	for(int i = 0;i < p;++i)cout << r[i] << " \n"[i==p-1];
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());
        if(r < 1200)System.out.println("ABC");
        else if(r < 2800) System.out.println("ARC");
        else System.out.println("AGC");
        
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define inf 100000000
using namespace std;

struct data {
  long long t, c, now;
};
bool operator<(const data &l, const data &r) {
  if(l.c != r.c) return l.c > r.c;
  return l.t > r.t;
}

long long n;
long long a[1005][1005] = {0};
long long dist[1005][1005] = {0};
long long nextr[1005] = {0};
priority_queue<data> pq;

long long solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n - 1; ++j) {
      cin >> a[i][j];
      --a[i][j];
    }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int i = 0; i < n; ++i)
    if(a[a[i][0]][0] == i) {
      pq.push({i, 1, 1});
      dist[i][0] = 1;
      nextr[i] = 1;
    }
  long long ans = 0;
  while(!pq.empty()) {
    data now = pq.top();
    pq.pop();
    if(now.now == n - 1 || nextr[now.t] != now.now)
      continue;
    long long rival = a[now.t][now.now];
    if(a[rival][nextr[rival]] == now.t) {
      data nextp = now;
      dist[now.t][now.now] = dist[rival][nextr[rival]] =
          nextp.c = max(now.c + 1,
                        1 + dist[rival][nextr[rival] - 1]);
      nextr[now.t] = ++nextp.now;
      pq.push(nextp);
      nextp.t = rival;
      nextp.now = ++nextr[rival];
      pq.push(nextp);
    }
  }
  for(int i = 0; i < n; ++i)
    if(dist[i][n - 2] == 0)
      return -1;
    else
      ans = max(ans, dist[i][n - 2]);
  return ans;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,s.length()){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n, k;
    cin >> n >> k;
    bool have[n] = {false};
    int d, a;
    for (int i = 0; i < k; i++){
        cin >> d;
        for (int j = 0; j < d; j++){
            cin >> a;
            have[a-1] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) if (!have[i]) ans++;
    cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3620
S = input()
if S[0] == "R" and S[1] == "R" and S[2] == "R":
    print(3)
    exit()

if S[0] == "R" and S[1] == "R":
    print(2)
    exit()

if S[1] == "R" and S[2] == "R":
    print(2)
    exit()

if "R" in S:
    print(1)
    exit()

print(0)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  //BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}
  BipartiteMatching(int n){
    graph=vector<vector<int>>(n);
    alive=vector<int>(n,1);
    used=vector<int>(n,0);
    match=vector<int>(n,-1);
    timestamp=0;
  }
  
  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};
int main() {
  int X, Y, E;
  cin >> X >> Y >> E;
  BipartiteMatching bm(X + Y);
  for(int i = 0; i < E; i++) {
    int a, b;
    cin >> a >> b;
    bm.add_edge(a, X + b);
  }
  cout <<  bm.bipartite_matching() << endl;
}


Measured memory_bytes: 3288
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n==25)
    {
        printf("Christmas\n");
    }
    else  if(n==24)
    {
        printf("Christmas Eve\n");
    }
     else  if(n==23)
    {
        printf("Christmas Eve Eve\n");
    }
     else  if(n==22)
    {
        printf("Christmas Eve Eve Eve\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<queue>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 10050, maxe = 2005000, inf = 1e9;
struct node {
	int to;
	int w;
	int c;
	int next;
};
node edge[maxe];
int head[maxn];
int ip;
void init()
{
	memset(head, -1, sizeof(head));
	ip = 0;
}
void addedge(int u, int v, int w, int c)
{
	edge[ip].to = v;
	edge[ip].c = c;
	edge[ip].w = w;
	edge[ip].next = head[u];
	head[u] = ip++;
}
int cost[maxn], dis[maxn], vis[maxn];
queue<int>q;
void spfa(int s, int n)
{
	while (!q.empty())
		q.pop();
	for (int i = 1; i <= n; i++)
		dis[i] = cost[i] = inf;
	memset(vis, 0, sizeof(vis));
	dis[s] = 0, cost[s] = 0, vis[s] = 1;
	q.push(s);
	while (q.size())
	{
		int u = q.front();
		q.pop();
		vis[u] = 0;
		for (int i = head[u]; i != -1; i = edge[i].next)
		{
			int to = edge[i].to, val = edge[i].w;
			if (dis[to] > dis[u] + val || (dis[to] == dis[u] + val&&cost[to] > edge[i].c))
			{
				dis[to] = dis[u] + val;
				cost[to] = edge[i].c;
				if (!vis[to])
				{
					q.push(to);
					vis[to] = 1;
				}
			}
		}
	}
}
int main()
{
	int n, m, u, v, w, c;
	while (scanf("%d %d", &n, &m),m,n)
	{
		init();
		for (int i = 0; i < m; i++)
		{
			scanf("%d %d %d %d", &u, &v, &w, &c);
			addedge(u, v, w, c);
			addedge(v, u, w, c);
		}
		spfa(1, n);
		int ans = 0;
		for (int i = 1; i <= n; i++)
			ans += cost[i];
		printf("%d\n", ans);
	}
	return 0;
}


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

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

   int A,B,C; cin>>A>>B>>C;
   if(A==B and C!=A or A==C and B!=A or B==C and A!=B) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


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

int main() {
	char c; cin >> c;
	switch (c) {
	case 'A':
		cout << 'T' << endl;
		break;
	case 'C':
		cout << 'G' << endl;
		break;
	case 'G':
		cout << 'C' << endl;
		break;
	case 'T':
		cout << 'A' << endl;
		break;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define REP(i,b,n) for(i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int cup[] = {1, 0, 0};

int main()
{
	char p, q;
	
	while(cin >> p, !cin.eof())
	{
		char c;
		cin >> c;
		cin >> q;
		
		swap(cup[(int)(p - 'A')], cup[(int)(q - 'A')]);
	}
	
	FOR(i, 0, 3)
	{
		if( cup[i] )
		{
			cout << (char)('A' + i) << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A = []; B = []
for i in range(N):
  a,b = map(int,input().split())
  A.append(a);B.append(b)

A.sort();B.sort()
if N%2 == 0:
  MIN = A[N//2-1]+A[N//2] #Medianの二倍
  MAX = B[N//2-1]+B[N//2]
  ans = MAX-MIN+1
else:
  MIN = A[N//2] #Medianの二倍
  MAX = B[N//2]
  ans = MAX-MIN+1
print(ans)

Measured memory_bytes: 25260
import java.util.Scanner;

/**
 * https://abc048.contest.atcoder.jp/tasks/abc048_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		sc.close();
		long s = (a/x+(a%x==0 ? 0:1))*x;
		long e = (b/x)*x;
		long ans = e>=s ? (1+(e-s)/x) : 0;
		System.out.println(ans);

	}

}


Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int univ[4][3][10]={{{}}},n,b,f,r,v;
  cin >> n;
  for(int i=0; i<n; i++) {
      cin >> b >> f >> r >> v;
      univ[b-1][f-1][r-1]+=v;
  }
  for(int i=0; i<4; i++) {
      for(int j=0; j<3; j++) {
          for(int k=0; k<10; k++) {
              cout << " " << univ[i][j][k];
          }
          cout << endl;
      }
      if(i<3) {
          cout << "####################" << endl;
      }
  }
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get() {}template<class H, class...T>void get(H&h, T&...t) { cin >> h; get(t...); }
template<class T>void geti(T&a) { for (auto&_ : a)cin >> _; }
template<class T>void getii(T&a) { for (auto&_ : a)geti(_); }
void put(string d) {}template<class H, class...T>void put(string d, H&h, T&...t) { cout << h; if (sizeof...(t))cout << d; put(d, t...); }
template<class T>void puti(T&a, string d = " ") { bool f = 1; for (auto&_ : a)cout << (exchange(f, 0) ? "" : d) << _; cout << endl; }
template<class T>void putii(T&a, string d = " ") { for (auto&_ : a)puti(_, d); }
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)


int main() {
    int n;
    cin >> n;
    vi v(n, 0);
    geti(v);
    int s = 0;
    rep(i, n-1) {
        int minj = i;
        range(j, i, n) {
            if (v[minj] > v[j]) {
                minj = j;
            }
        }
        if (minj != i) {
            swap(v[i], v[minj]);
            s++;
        }
    }
    puti(v);
    cout << s << endl;
}



Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const ll mod = 1000000007;
int main(){
  ll n;
  cin >> n;
  vector<pair<ll, ll> > cnt1(100010, make_pair(0, 0)), cnt2(100010, make_pair(0, 0));
  vector<ll> v(n);
  rep(i, n) cin >> v[i];


  for(ll i = 0; i < n; ++i){

    if(i % 2 == 0) {
      cnt1[v[i]].first++;
      cnt1[v[i]].second = v[i];
    } else {
      cnt2[v[i]].first++;
      cnt2[v[i]].second = v[i];
    }
  }

  sort(cnt1.begin(), cnt1.end());
  sort(cnt2.begin(), cnt2.end());
  reverse(cnt1.begin(), cnt1.end());
  reverse(cnt2.begin(), cnt2.end());


  //rep(i, 15) cout << cnt1[i].first << " ";


  ll num1, num2 = - 1;
  if(cnt1[0].second == cnt2[0].second){
    if(cnt1[0].first + cnt2[1].first < cnt1[1].first + cnt2[0].first ){
      num1 = cnt1[1].second;
      num2 = cnt2[0].second;
    } else {
      num1 = cnt1[0].second;
      num2 = cnt2[1].second;
    }
  } else {
    num1 = cnt1[0].second;
    num2 = cnt2[0].second;
  }
  /*
  cout << endl;
  cout << num1 << " " << num2 <<endl;
  */

  ll ans = 0;
  for(ll i = 0; i < n; ++i){
    if(i % 2 == 0){
      if(num1 != v[i])  ans++;
    } else {
      if(num2 != v[i])  ans++;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 4096
#include <iostream>
#include <cmath>

using namespace std;

int main() {

    int N = 0;
    cin >> N;

    int last = 100000;
    int current = 0;
    int sum = 0;
    
    for (int i = 0; i < N - 1; i++) {
        cin >> current;        
        sum += min(last, current);
        last = current;
    }
    sum += min(last, 100000);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int selectionSort(int X[],int  N){
  int i,j,k,cn=0,sm;

  for(i=0;i<N-1;i++){
    sm = i;
    for(j=i;j<N;j++){
	  if(X[j]< X[sm]){
	    sm = j;
	  }
	}
	  k = X[i];
	  X[i] = X[sm];
	  X[sm] = k;
	  if( i != sm) {
	    cn++;
	  }
	}
	return cn;
    }


int main(){
  int A[100],Num,i,mv;

  scanf("%d",&Num);

  for(i=0;i<Num;i++){
    scanf("%d",&A[i]);
  }

  mv = selectionSort(A,Num);

  for(i=0;i<Num;i++){
    if(i>0){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",mv);

  return 0;
}



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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


signed main() {
  int sq[200];
  int N = 200;
  Rep(i, N) sq[i] = i*i;

  vector<Pip> mae;
  Rep(i, N) Rep(j, N) mae.pb(Pip(sq[i]+sq[j], Pii(i, j)));
  sort(All(mae));

  int n;
  while ( cin >> n, n ) {
    int ans = 0;
    map<int, bool> m;
    Rep(i, (int)mae.size()) {
      if ( n - mae[i].fr >= 0 ) {
	vector<Pip>::iterator tmp = lower_bound(mae.begin()+i, mae.end(), Pip(n-mae[i].fr, Pii(0, 0)));
	for (  vector<Pip>::iterator j = tmp; (*j).fr == n-mae[i].fr; j++ ) {	  
	  int use[4] = {mae[i].sc.fr, mae[i].sc.sc, (*j).sc.fr, (*j).sc.sc};	  
	  sort(use, use+4);
	  if ( !m[use[0]*200*200*200 + use[1]*200*200 + use[2]*200 + use[3]] ) ans++;
	  m[use[0]*200*200*200 + use[1]*200*200 + use[2]*200 + use[3]] = true;
	}
      }
    }

    cout << ans << endl;
  }
}

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

namespace {
    const int INPUT_NUM = 3;
}
int main() {
    std::vector<int> input;

    for(int i = 0; i < INPUT_NUM; ++i) {
        int temp;
        std::cin >> temp;
        input.push_back(temp);
    }
    std::sort(input.begin(), input.end());

    int answer = 0;

    for(int i = 1; i < INPUT_NUM; ++i) {
        answer += std::abs(input[i] - input[i-1]);
    }

    std::cout << answer << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define ll long long

bool pairCompare(const pair<int, int> & f, const pair<int, int> & s)
{
    return f.first < s.first;
}

int main()
{
    int ans;
    string s;

    cin >> s;

    int cnt0 = 0;
    int cnt1 = 0;
    rep(i, s.size()) {
        if (s[i] == '0')
            ++cnt0;
        else
            ++cnt1;
    }
    ans = min(cnt0, cnt1) * 2;
    cout << ans << endl;
    return(0);
}


Measured memory_bytes: 3760
#define ll long long int
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
using namespace std;
const int y = 1000;
const int INF = y * y * y;
const int M = y * y * y + 7;
int main() {
	int n, m;
	cin >> n >> m;
	vector <string> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector <vector <int>> dp(n+1, vector <int>(m+1));
	dp[1][1] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (i != 1 || j != 1) { if (a[i - 1][j - 1] != '#') dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])%M; }
		}
	}
	cout << dp[n][m];
} 

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

int main(void) {
  long long int N, K;
  cin >> N >> K;

  long long prev = LLONG_MAX;
  while (prev > N) {
    prev = N;
    if (N > K) {
      N %= K;
    } else {
      N = abs(N - K);
    }
  }
  cout << prev << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int h, w, n, x, y;
string s[2];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w >> n >> x >> y >> s[0] >> s[1];
  int lh=0, rh=h-1, lw=0, rw=w-1;
  x--; y--;
  FORR(i, n-1, 0){
    switch(s[1][i]){
      case 'U':
        rh++;
        break;
      case 'D':
        lh--;
        break;
      case 'L':
        rw++;
        break;
      case 'R':
        lw--;
        break;
      default:
        break;
    }
    maxs(lh, 0);
    mins(rh, h-1);
    maxs(lw, 0);
    mins(rw, w-1);
    switch(s[0][i]){
      case 'U':
        lh++;
        break;
      case 'D':
        rh--;
        break;
      case 'L':
        lw++;
        break;
      case 'R':
        rw--;
        break;
      default:
        break;
    }
    if(rh<lh || rw<lw){
      cout << "NO" << endl;
      return 0;
    }
  }
  if(lh<=x && x<=rh && lw<=y && y<=rw){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 920
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();

        String s1 = s.substring(0, 2);
        String s2 = s.substring(2, 4);
        int i1 = Integer.parseInt(s1);
        int i2 = Integer.parseInt(s2);

        String result = (i1 > 0 && i1 <= 12) ? (i2 > 0 && i2 <= 12) ? "AMBIGUOUS" : "MMYY"
                : (i2 > 0 && i2 <= 12) ? "YYMM" : "NA";
        System.out.println(result);
    }
}

Measured memory_bytes: 21972
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    var N = parseInt(input[0], 10);
    var ans=0;
    for (var i = 1; i <= N; i++) {
       if (String(i).length%2==1) {
       	    ans=ans+1
       }
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 11084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VI b(n - 1);
    REP(i,n-1) b[i] = in();
    VI a(n);
    REP(i,n){
        a[i] = 1e9;
        if (i < n -1) chmin(a[i], b[i]);
        if (i > 0) chmin(a[i], b[i - 1]);
    }
    int ans = 0;
    REP(i,n) ans += a[i];
    cout << ans << endl;

    return 0;
}


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

int main()
{
    long long n,m,i,j,k,x=0,y=0,z;
    cin>>n;
    char s[100000][10];
    long long a[n+5];
    long long b[n+5];
    long long c[n+5];
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        c[i]=i;
    }
    for(i=1; i<=n; i++)
    {
        cin>>b[i];
    }
    //long long c[9]={1,2,3,4,5,6,7,8};
    long long an1=0,an2=0;
    do
    {
        int ok=0,ok1=0;
        x++;
        for(i=1; i<=n; i++)
        {
            if(a[i]!=c[i])
            {
                ok=1;
            }
            if(b[i]!=c[i])
            {
                ok1=1;
            }
        }
        if(ok==0){
            an1=x;
        }
        if(ok1==0){
            an2=x;
        }
    }while(next_permutation(c+1,c+1+n));
    cout<<abs(an1-an2)<<endl;
}


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



int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}

long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}




int main(void){
    int price[4];
    long long n;
    unsigned long long min = 10000000000000000;
    int mini;
    unsigned long long ans = 0;
    for (int i = 0; i < 4; i++){
        scanf("%d", &price[i]);
    }
    scanf("%lld", &n);
    n *= 4;
    for (int i = 0; i < 3; i++){
        if (min > price[i]*(int)pow(2, 3-i)){
            min = price[i]*(int)pow(2, 3-i);
            mini = i;
        }
    }
    if (min > price[3]){
        ans = (unsigned long long)n/8*price[3]+(n%8)/(int)pow(2, mini)*price[mini];
    }else{
        ans = (unsigned long long)n/(int)pow(2, mini)*price[mini];
    }

    printf("%llu\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

///////////////////////////////////////////////////////////////////////////
int a[100005] = {};

int main(){
	int n,g = 0,k = 0;
	cin >> n;
	rep(i,0,n){
	    cin>> a[i];
	    if(a[i]%2 == 0)g++;
	    else k++;
	}
	
    if(k%2 == 0){
        cout << "YES" << endl;
    }else{
        cout <<"NO" << endl;
    }
	
	return 0;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> map(h, vector<char>(w));
  
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> map[i][j];
    }
  }
  
  const int dx[8] = {-1,0,1,-1,1,-1,0,1};
  const int dy[8] = {-1,-1,-1,0,0,1,1,1};
  
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(map[i][j] == '#') continue;
      
      int count = 0;
      for(int d=0; d<8; d++){
        const int ni = i+dy[d];
        const int nj = j+dx[d];
        
        if(ni<0 || ni >=h) continue;
        if(nj<0 || nj >=w) continue;
        if(map[ni][nj] == '#') count++;
      }
      char a = '0';
      a += count;
      map[i][j] = a;
    }
  }
  
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cout << map[i][j];
    }
    cout << endl;
  }
      
      
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
struct edge {int to, cost;};
vector <edge> G[100010];
using P = pair<int , int>;
int V;
int d[100010];

void dijkstra(int s){
    priority_queue <P, vector<P>, greater<P> > que;
    fill(d, d + V, 1000000000);
    d[s] = 0;
    que.push(P(0 , s));
    
    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first)  continue;
        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

signed main(){
	int m;
	while(cin >> V >> m, V){
		int a, b, c;
		rep(i, m){
			cin >> a >> b >> c;
			a--; b--;
			G[a].push_back({b, c});
			G[b].push_back({a, c});
		}
		struct add{int kokkara, kokomade;};
		vector <add> karen;
		rep(i, V){
			rep(j, G[i].size()){
				int va = G[i][j].to;
				rep(k, G[va].size()){
					if(G[va][k].to == i)continue;
					karen.push_back({i, G[va][k].to});
				}
			}
		}
		dijkstra(0);
		int mini = d[V - 1];
		rep(i, karen.size()){
			G[karen[i].kokkara].push_back({karen[i].kokomade, 0});
			dijkstra(0);
			G[karen[i].kokkara].pop_back();
			mini = min(mini, d[V - 1]);
		}
		cout << mini << endl;
		rep(i, V)
			G[i].clear();
	}
}

Measured memory_bytes: 5564
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007



void solve()
{
  string S;
  cin>>S;
  int K;
  cin>>K;
  char c;
  int n;
  while(true)
  {
    static int i  = 0;
    if(S[i] != '1')
    {
      c = S[i];
      n = i;
      break;
    }
    i++;
  }
  if(n< K)
  cout<<c<<endl;
  else
  {
    cout<<1<<endl;
  }
  
}

int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}

int main(void){
	ll N,M,a,b,c;
	map<ll,ll> A;
	cin>>N>>M;
	REP(i,N){
		cin>>a;
		A[-a]++;
	}
	REP(i,M){
		cin>>b>>c;
		A[-c]+=b;
	}
	
	ll sum=0,new_score;
 	for(auto itr = A.begin(); itr != A.end(); ++itr) {
	 new_score=-itr->first;
		sum+=new_score*min(itr->second,N);
		N-=itr->second;
		if(N<=0) break;
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 12800
def main():
    # アルメリアさんを参考にした いや全然わからん
    from itertools import accumulate
    from bisect import bisect_left
    import sys
    input = sys.stdin.buffer.readline
    N, Q = (int(i) for i in input().split())
    A = [0] + [int(i) for i in input().split()]

    cum = [0] + [a for a in accumulate(A[1:])]
    cum_e = [e for e in accumulate(A[(1 if N & 1 else 0)::2])]

    def binary_search(x):
        ng = 0
        ok = N
        while ok - ng > 1:
            mid = ng + (ok - ng) // 2
            if A[mid] < x:
                ng = mid
            else:
                upper = N - mid + 1
                lower = mid - bisect_left(A, max(1, 2*x-A[mid])) + 1
                if upper > lower:
                    ng = mid
                else:
                    ok = mid
        return ok
    # print(cum, cum_e)
    for query in range(Q):
        x = int(input())
        ok = binary_search(x)
        ans = cum[N] - cum[ok-1]
        t = N - (N-ok+1)*2
        # print(ok, t)
        if t > 0:
            ans += cum_e[t//2]
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73900
function Main(input) {
    var args = input.trim().split(' ').map(function(val) {
        return Number(val);
    });
    var sum = args[0] + args[1] + args[2];
    if(sum >= 22) {
        console.log('bust');
    } else {
        console.log('win');
    }
    
}
 
/*  var input = `13 7 2`;
Main(input);
 */ 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  ll x = 0;
  bool hari = true;
  for (int i = 60; i >= 0; i--) {
    int count = 0;
    for (auto a : v) count += a >> i & 1;
    if (count * 2 > n) {
      if (k >> i & 1 == 1) hari = false;
    } else if (!hari || k >> i & 1 == 1)
      x |= 1ll << i;
  }

  ll ans = 0;
  for (auto a : v) ans += a ^ x;
  cout << ans << endl;
}


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	k, _ := strconv.Atoi(Scanner())
	n, _ := strconv.Atoi(Scanner())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(Scanner())
	}
	m := a[0] + k - a[len(a)-1]
	for i := 0; i < n-1; i++ {
		d := a[i+1] - a[i]
		if d > m {
			m = d
		}
	}
	fmt.Println(k - m)
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

const int mod=1e9+7;

signed main()
{
    int H,W; cin>>H>>W;
    vector<string> a(H);
    for(int i=0;i<H;i++){
        cin>>a[i];
    }
    
    vector<vector<int> > dp(H,vector<int>(W));
    dp[0][0]=1;
    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
        if(i+1<H and a[i+1][j]=='.'){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=mod;
        }
        if(j+1<W and a[i][j+1]=='.'){
            dp[i][j+1]+=dp[i][j];
            dp[i][j+1]%=mod;
        }
    }
    cout<<dp[H-1][W-1]<<endl;
}


Measured memory_bytes: 9216
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
import numpy as np
# from copy import deepcopy
#from collections import deque

#import numba
#import math

def run():
    N = int(input())
    A = list(map(int, sysread().split()))
    NN = 10 ** 6 + 1
    A = sorted(A)
    checks = np.array([True] * NN)
    ret = 0
    for i, a in enumerate(A[:-1]):
        if checks[a] and a != A[i+1]:
            ret += 1
        if checks[a]:
            checks[a:NN+1:a] = False
    if checks[A[-1]]:
        ret += 1


    print(ret)

if __name__ == "__main__":
    run()

Measured memory_bytes: 51584
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    string s;
    cin >> N >> s;
    int count = 0;
    for(int i = 0; i <= N -3;i++){
        if(s.substr(i,3) == "ABC") count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


int d, t, s;

int main()
{
	scanf("%d%d%d", &d, &t, &s);
	int rd = t * s;
	if (d <= rd) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
		

	return 0;
}


Measured memory_bytes: 1660