akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
  int n, m;
  int l[100100], r[100100];
  cin >> n >> m;
  int maxl = 0;
  int minr = 99999999;
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i];
    maxl = max(maxl, l[i]);
    minr = min(minr, r[i]);
  }
  int ans = minr - maxl + 1;
  if (ans < 0) {
    ans = 0;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define sz(a) (int)(a).size()
using namespace std;
using ll=long long;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b ;
    cout << ( max( a+b , max(a - b , a * b) ) )<< '\n';
    return 0;
}













Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(n: str):
    a = []
    for c in n:
        a.append("1" if c == "9" else "9")
    print("".join(a))

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = str(next(tokens))  # type: int
    solve(n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int i,n;
    int a[1000];
    int min=1000;int max=0;

    scanf("%d",&n);

    for(i=0;i<n;i++){
    	scanf("%d",&a[i]);
    	if(a[i]<min) min=a[i];
    	if(a[i]>max) max=a[i];
    }

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


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
using namespace std;

int main(void) {
	string S;
	cin >> S;
	bool answer = true;
	if (S[0] != 'A') answer = false;
	if ('A' <= S[1] && S[1] <= 'Z') answer = false;
	if ('A' <= S[S.length() - 1] && S[S.length() - 1] <= 'Z') answer = false;

	int CCount = 0;
	for (int i = 2; i < S.length() - 1; i++) {
		if (S[i] == 'C') CCount++;
		if ('A' <= S[i] && S[i] <= 'Z' && S[i] != 'C') answer = false;
	}
	if (CCount != 1) answer = false;
	if (answer) {
		printf("AC");
	} else {
		printf("WA");
	}
	return 0;
}



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

class DisjointSet{
public:
  vector<int> rank,p; //rankが木の高さ
                      //pは親(根)
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;i++)makeSet(i);
  }

  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }

  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }

  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }

  void link(int x, int y){
    //木が低い方を高い方に合併
    if(rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;

      if(rank[x]==rank[y]){
	rank[y]++;
      }
    }
  }

  int findSet(int x){
    //再帰を使って根を返す
    if(x!=p[x]){p[x] = findSet(p[x]);}
    return p[x];
  }
};


int main(){
  int n,a,b,q,t;

  cin >>n>>q;
  DisjointSet ds = DisjointSet(n);

  for(int i=0;i<q;i++){
    cin >>t>>a>>b;
    if(t==0)ds.unite(a,b);
    else if(t==1){
      if(ds.same(a,b))cout <<1<<endl;
      else cout <<0<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    ll x=t*s;
    if(x>=d)
    {
        cout<<"Yes"<<endl;
    }
    else{
    cout<<"No"<<endl;
    }


}


Measured memory_bytes: 3672
/**
 *   author: sahushivam
 *   created: 16 February 2020 (Sunday)  17:43:38
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

void solve(){
    map<string,int> mp;
    int maxi=0;
    int n; cin>>n;
    for(int i=0;i<n;i++)
    {
        string s; cin>>s;
        mp[s]++;
        maxi=max(maxi,mp[s]);
    }
    for(auto i: mp)
    {
        if(i.second==maxi)
            cout<<i.first<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

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

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    std::set<int> as;
    for (int i = 0; i < n; i++)
    {
        std::cin >> a[i];
        as.insert(a[i]);
    }

    std::sort(a.begin(), a.end());
    int ans = 0;
    std::vector<int> am;
    if (as.size() > k)
    {
        for (auto itr = as.begin(); itr != as.end(); itr++) {
            int num = std::upper_bound(a.begin(), a.end(), *itr) - std::lower_bound(a.begin(), a.end(), *itr);
            am.push_back(num);
        }

        std::sort(am.begin(), am.end());

        for (int i = 0; i < as.size() - k; i++) {
            ans += am[i];
        }
    }

    std::cout << ans << "\n";
}

Measured memory_bytes: 14372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 1000000000
typedef long long ll;

ll gcd(ll C,ll D){
    ll tmp;
    if(C>D){tmp=C;C=D;D=tmp;}
    if(D%C==0)return C; 
    return gcd(C,D%C);
}

int main(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    ll X,Y,ans;
    ll cn=INF,cd=INF;
    if(gcd(C,D)>1){
        if(D%C==0||C%D==0){ //CD 2,8とか
            ll cn = min(C,D);
            ll cd = max(C,D);
            X=(A/cn);
            Y=(B/cn);
            if(A%cn==0) ans=(B-A+1)-(Y-X+1);
            else ans=(B-A+1)-(Y-X);    
        }else{              //CD 6 8とか
            cd = C*D/gcd(C,D);
            X=(A/C)+(A/D)-(A/cd);
            Y=(B/C)+(B/D)-(B/cd);
            if(A%cn==0||A%cd==0) ans=(B-A+1)-(Y-X+1);
            else ans=(B-A+1)-(Y-X); 
        }
    }else{                  //CD 3 5とか
        //互いに素
        X=(A/C)+(A/D)-(A/C/D);
        Y=(B/C)+(B/D)-(B/C/D);
        if(A%C==0||A%D==0) ans=(B-A+1)-(Y-X+1);
        else ans=(B-A+1)-(Y-X);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    LL a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k % 2){
        cout << b-a << endl;
    }else{
        cout << a-b << endl;
    }
    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
D = [[] for i in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    D[p-1].append((y, i))
ans = [None]*M
for i, d in enumerate(D):
    d.sort()
    for k, (y, j) in enumerate(d):
        ans[j] = "%06d%06d" % (i+1, k+1)
print(*ans, sep='\n')

Measured memory_bytes: 37456
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int n = scan.nextInt();
		List<Integer> p = new ArrayList<Integer>();
		for(int i=0;i<n;i++) {
			int a = scan.nextInt();
			p.add(a);
		}
		
		
		
		for(int i=0;i<100;i++) {
			if(!p.contains(x-i)) {
				System.out.println(x-i);
				break;
			}else if(!p.contains(x+i)){
				System.out.println(x+i);
				break;
			}
			
		}
		
	}	
	
	
	
}
 


Measured memory_bytes: 36036
#include<iostream>
#include<math.h>
using namespace std;
int main() {
  long N,min=1000000000001;
  int i;
  cin >> N;
  for(i=1;i<pow(N,0.5)+1;i++)if(N%i == 0) {
    if(min > i+N/i)min = i+N/i;
  }
  cout << min-2 << endl;
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        t: i32,
        ct:[(i32,i32); n],
    }
    let mut ct = ct;
    ct.sort();
    let mut check = true;
    for i in 0..n {
        if ct[i].1 <= t {
            puts!("{}\n", ct[i].0);
            check = false;
            break;
        }
    }
    if check {
        puts!("TLE");
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 2288
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);	
	ll h, n;
	cin >> h >> n;
	ll sum = 0;
	for(int i=0; i<n; ++i){
		ll x; cin >> x;
		sum += x;
	}
	if(sum>=h)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 998244353;// 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<LL>>g;
vector<edge>edges;
vector<Pll>v;
map<Pll, Pll>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
void gcd_comvolution(std::vector<LL> &a) {
	int n = a.size();
	for (int k = 1; k < n; ++k) {
		for (int i = k * 2; i < n; i += k) {
			a[k] += a[i];
			while (a[k] >= MOD)
				a[k] -= MOD;
		}
	}
}
void inv_gcd_comvolution(std::vector<LL> &a) {
	int n = a.size();
	for (int k = n - 1; k >= 1; --k) {
		for (int i = k * 2; i < n; i += k) {
			a[k] -= a[i];
			while (a[k] < 0)
				a[k] += MOD;
		}
	}
}
LL modpow(LL a, LL n = MOD - 2) {
	LL r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % MOD, a = a * a%MOD, n >>= 1;
	return r;
}
int main() {
	cin >> n;
	vector<LL>v(1000010);
	rep(i, n) {
		LL x;
		cin >> x;
		a[i] = x;
		v[x] += x;
		v[x] %= MOD;
	}
	gcd_comvolution(v);
	rep(i, v.size()) {
		v[i] = v[i] * v[i];
		v[i] %= MOD;
	}
	inv_gcd_comvolution(v);
	rep(i, v.size()) {
		ans += (v[i] * modpow(i)) % MOD;
		ans %= MOD;
	}
	rep(i, n) {
		ans -= a[i];
		while (ans < 0)ans += MOD;
	}
	cout << (ans * modpow(2))%MOD << endl;
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans = n;
    rep(i, n){
        if(s[i] == s[i+1]){
            ans -= 1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
x, y = [0] * n, [0] * n
for i in range(n):
	x[i], y[i] = map(int, input().split())

dists = [[0] * n for _ in range(n)]
for i in range(n):
	for j in range(n):
		dists[i][j] = ((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** (1 / 2)

ans = sum([sum(d) for d in dists]) / n
print(ans)

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

#define ll long long;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int x, res;
  for (int i = 1; i <= 5; ++i) {
    cin >> x;
    if (x != i) {
      res = i;
    }
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e5+10;

int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
vector<int> value;
int n;
cin>>n;
for(int i=0;i<n;i++){
    int v;
    cin>>v;
    value.push_back(v);
}
sort(value.begin(), value.end());

int q;
cin>>q;

for(int i=1;i<=q;i++){
    int k;
    cin>>k;
    pair<vector<int>::iterator, vector<int>::iterator> bound;
    bound=equal_range(value.begin(), value.end(), k);
    printf("%d %d\n",
           bound.first-value.begin(), bound.second-value.begin());
}

#ifdef LOCAL
fin.close();
#endif // LOCAL
}



Measured memory_bytes: 3500
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

struct UnionFind {
    vector<int> rank, parent, size;

    // +1 for 1-indexed nodes
    UnionFind(int n) : rank(n + 1, 0), parent(n + 1), size(n + 1, 1) {
        iota(parent.begin(), parent.end(), 0); // parent is itself
    }
    int root(int x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }
        return parent[x];
    }
    bool isSame(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) { return link(root(x), root(y)); }
    bool link(int x, int y) {
        if (x == y)
            return false;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        } else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
        return true;
    }
    int getSize(int x) { return size[root(x)]; }
};

int main() {
    int n;
    cin >> n;
    vl x(n), y(n);
    map<int, int> cnt;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        y[i] += 200000;
        cnt[x[i]] = 0;
        cnt[y[i]] = 0;
    }
    int c = 0;
    for (auto &p : cnt)
        cnt[p.first] = c++;
    UnionFind uf(c);
    for (int i = 0; i < n; ++i) {
        uf.unite(cnt[x[i]], cnt[y[i]]);
    }
    map<int, pair<set<int>, set<int>>> rect;
    for (int i = 0; i < n; ++i) {
        rect[uf.root(cnt[x[i]])].first.insert(cnt[x[i]]);
        rect[uf.root(cnt[x[i]])].second.insert(cnt[y[i]]);
    }
    ll ret = -n;
    for (auto &p : rect) {
        ret += p.second.first.size() * p.second.second.size();
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 12416
import collections
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(M)]

G = [set() for i in range(N)]

for a, b in ab:
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

ans = 0
for a, b in ab:
    a -= 1
    b -= 1
    q = collections.deque([0])
    r = [1]*N
    r[0] = 1
    while(q):
        x = q.popleft()
        for y in G[x]:
            if (x == a and y == b) or (x == b and y == a):
                continue
            else:
                if r[y]:
                    r[y] = 0
                    q.append(y)
    if sum(r) > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3316
while True:
    W,H=map(int,input().split())
    if(H==0 and W==0):
        break
    for j in range(W):
        for i in range(H):
            if(j == 0 or i == 0 or H-1 == i or W-1 == j):
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] g = new boolean[n][n];
        int [] a = new int[m];
        int [] b = new int[m];
        for (int i = 0 ; i < m ; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            g[a[i]][b[i]] = true;
            g[b[i]][a[i]] = true;
        }

        int answer = 0;
        for (int i = 0 ; i < m ; i++) {
            g[a[i]][b[i]] = false;
            g[b[i]][a[i]] = false;
            boolean[] v = new boolean[n];
            dfs(0, n, g, v);
            boolean bridge = false;

            for (int j = 0; j < n ; j++) {
                if (!v[j]) {
                    bridge = true;
                    break;
                }
            }
            if (bridge) {
                answer++;
            }
            g[a[i]][b[i]] = true;
            g[b[i]][a[i]] = true;
        }
        System.out.println(answer);

    }

    private static void dfs (int i, int n, boolean[][] g, boolean[] v) {
        v[i] = true;
        for (int j = 0 ; j < n ; j++) {
            if (!g[i][j]) {
                continue;
            }
            if (v[j]) {
                continue;
            }
            dfs(j,n,g,v);
        }
        return;
    }

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a;
  string s;
  cin >> a >> s;
  string t = s.substr(0, 1) + s.substr(2, 2);
  ll b = stoll(t);
  cout << a * b / 100 << endl;
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [A[i] - B[i] for i in range(N)]
C.sort(reverse=True)

if sum(A) < sum(B):
    print(-1)
    exit()

ans = sum([1 for i in range(N) if C[i] < 0])
temp = sum([C[i] for i in range(N) if C[i] < 0])
if(not temp):
    print(0)
    exit()

for item in C:
    ans += 1
    temp += item
    if temp >= 0:
        break
print(ans)


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


#undef int
int main()
{
#define int long long int
  
  int n;
  cin>>n;
  int gc = 0;
  for(int i=0;i<n;i++){
  	int c;
  	cin>>c;
  	gc = __gcd(c,gc);
  }
  
  cout<<gc;

return 0;
}

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

#define N 100000

int main() {
	static char s[N + 1];
	int n, i, cnt;

	scanf("%s", s);
	n = strlen(s);
	cnt = 0;
	for (i = 0; i < n - 1; i++)
		if (s[i] != s[i + 1])
			cnt++;
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(int argc, char *argv[]){

	long long int x, a, b, y;
	cin >> x >> a >> b;

	y = a - b;

	if (y >= 0){
		cout << "delicious" << endl;
		return 0;
	}
	y = 0 - y;

	if(x >= y){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn argsort<T: std::cmp::Ord + std::marker::Copy>(v: &Vec<T>) -> Vec<usize> {
    let mut sort_v = Vec::new();
    for i in 0..v.len() {
        sort_v.push((v[i], i));
    }
    sort_v.sort();
    sort_v.iter().map(|x| x.1).collect::<Vec<usize>>()
}

fn argsort_map<T: std::cmp::Ord + std::marker::Copy>(v: &Vec<T>) -> Vec<usize> {
    let mut sort_v = Vec::new();
    for i in 0..v.len() {
        sort_v.push((v[i], i));
    }
    sort_v.sort();
    sort_v.iter().map(|x| x.1).collect::<Vec<usize>>()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, k) = (v[0], v[1]);
    let mut x = vec![0; n];
    let mut y = vec![0; n];

    for i in 0..n {
        let v = read_vec::<i64>();
        x[i] = v[0];
        y[i] = v[1];
    }
    let sorted_y_indexes = argsort(&y);

    let mut ans = std::i64::MAX;
    for i in 0..n {
        for j in i + 1..n {
            let mut i = i;
            let mut j = j;
            if x[i] > x[j] {
                std::mem::swap(&mut i, &mut j);
            }
            let x1 = x[i];
            let x2 = x[j];
            assert!(x1 <= x2);

            let mut usable_point_indexes = Vec::new();
            for l in 0..n {
                let idx3 = sorted_y_indexes[l];
                if x[idx3] >= x1 && x[idx3] <= x2 {
                    usable_point_indexes.push(idx3);
                }
            }
            assert!(usable_point_indexes.len() >= 2);
            if usable_point_indexes.len() < k {
                continue;
            }

            for l in 0..usable_point_indexes.len() - k + 1 {
                let y1 = y[usable_point_indexes[l]];
                let y2 = y[usable_point_indexes[l + k - 1]];
                ans = min(ans, (x2 - x1) * (y2 - y1));
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val memberCount: Int = readLine()!!.trim().toInt()
    val members: List<String> = readLine()!!.trim().map {it.toString()}.subList(0, memberCount)

    val wRuisekiwa: Array<Int> = Array(memberCount + 1) {0}
    val eRuisekiwa: Array<Int> = Array(memberCount + 1) {0}

    members.forEachIndexed {index, member ->
        if (member == "W") {
            wRuisekiwa[index + 1] = wRuisekiwa[index] + 1
            eRuisekiwa[index + 1] = eRuisekiwa[index]
        } else {
            wRuisekiwa[index + 1] = wRuisekiwa[index]
            eRuisekiwa[index + 1] = eRuisekiwa[index] + 1
        }
    }

    // println(wRuisekiwa.toList())
    // println(eRuisekiwa.toList())

    var minTurnMemberCount: Int = memberCount

    members.forEachIndexed { index, member ->
        val turnMemberCount: Int = wRuisekiwa[index] + (eRuisekiwa[memberCount] - eRuisekiwa[index + 1])

        if (turnMemberCount < minTurnMemberCount) {
            minTurnMemberCount = turnMemberCount
        }
    }

    println(minTurnMemberCount)

}

Measured memory_bytes: 67892
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            long a = in.nextLong();
            long b = in.nextLong();
            if (a > b || (n == 1 && a != b)) {
                out.println(0);
                return;
            }
            long l = a * (n - 1) + b;
            long r = a + b * (n - 1);
            long ans = r - l + 1;
            if (ans < 0) {
                ans = 0;
            }
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
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 PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

long factorial(long n) {
    if (n == 1) return 1;
    else return n * factorial(n-1);
}

int main() {
    int d;
    cin >> d;
    cout << factorial(d) << endl;
    return 0;
}

Measured memory_bytes: 1160
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


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

    if(400<=X && X<600){
        cout << 8 << endl;
        return 0;
    }else if(600<=X && X<800){
        cout << 7 << endl;
        return 0;
    }else if(800<=X && X<1000){
        cout << 6 << endl;
        return 0;
    }else if(1000<=X && X<1200){
        cout << 5 << endl;
        return 0;
    }else if(1200<=X && X<1400){
        cout << 4 << endl;
        return 0;
    }else if(1400<=X && X<1600){
        cout << 3 << endl;
        return 0;
    }else if(1600<=X && X<1800){
        cout << 2 << endl;
        return 0;
    }else if(1800<=X && X<2000){
        cout << 1 << endl;
        return 0;
    }
}




Measured memory_bytes: 3672
nums = list(map(int, input().split()))
while nums != [0,0]:
    count = 0
    for n3 in range(3, nums[0]+1):
        for n2 in range(2, n3):
            for n1 in range(1, n2):
                if n1+n2+n3 == nums[1]:
                    count += 1
    print(count)
    nums = list(map(int, input().split()))


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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    vector<pair<string,int>> pl(n); rep(i,n){ cin>>pl[i].first>>pl[i].second; }
    string x; cin>>x;

    int ans = 0; bool on = false;
    rep(i,n){
        if(on)ans += pl[i].second;
        if(pl[i].first == x)on = true;
    }
    cout<<ans<<endl; return 0;
}


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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto P = aryread();
    auto uf = UnionFind(N + 1);
    foreach (i; 0 .. M)
    {
        long X, Y;
        scan(X, Y);
        uf.unite(X, Y);
    }
    long ans;
    foreach (i; 0 .. N)
        ans += (uf.find(i + 1) == uf.find(P[i]));
    writeln(ans);
}

alias UnionFind = UnionFindImpl!long;
struct UnionFindImpl(T)
{
    T[] _rank, _data, _size;
    this(long n)
    {
        _rank = new long[](n);
        _size = new long[](n);
        _size[] = 1;
        _data = iota!T(n).array();
    }

    T find(T x)
    {
        if (_data[x] == x)
            return x;
        T r = _data[x] = this.find(_data[x]);
        return r;
    }

    void unite(T x, T y)
    {
        T rx = this.find(x), ry = this.find(y);
        if (rx == ry)
            return;
        _size[rx] = _size[ry] = (_size[rx] + _size[ry]);
        if (_rank[rx] == _rank[ry])
        {
            _data[rx] = ry;
            _rank[ry]++;
        }
        else if (_rank[rx] < _rank[ry])
            _data[rx] = ry;
        else
            _data[ry] = rx;
    }

    T size(T x)
    {
        return _size[this.find(x)];
    }
}


Measured memory_bytes: 8508
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = 1000000007;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  I n, k;
  cin >> n >> k;
  V a(n);
  VIN(n,a);
  vector<P> an(n);
  REP(i,n){
    an.at(i).first = 0;
    an.at(i).second = 0;
  }
  REP(i,n){
    REP(j,n){
      if (i < j && a.at(i) > a.at(j)){
        an.at(i).second++;
      }
      if (i > j && a.at(i) > a.at(j)){
        an.at(i).first++;
      }
    }
  }
  unsigned long long t=0;
  REP(i,n){
    unsigned long long tmp = 0;
    unsigned long long tmp2 = 0;
    tmp = (k + 1)*k/2LL % MOD;
    tmp = tmp * an.at(i).second % MOD;
    tmp2 = (k - 1)*k/2LL % MOD;
    tmp2 = tmp2 * an.at(i).first % MOD;
    t += tmp + tmp2;
    t %= MOD;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int main(void){
    ll w,h;
    P p[200000];
    ll c=0,a,b,e=0;
    cin>>w>>h;
    for(int i=0;i<w+h;i++){
        ll x;
        cin>>x;
        p[i]=P(x, i);
    }
    sort(p, p+w+h);
    a=w+1;
    b=h+1;
    for(int i=0;i<w+h&&e<w*h+w+h;i++){
        if(p[i].second<w){
            e+=b;
            a--;
            c+=b*p[i].first;
        }else{
            e+=a;
            b--;
            c+=a*p[i].first;
        }
    }
    cout << c << endl;
    //cout << e << endl;
}


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

#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define maxn 410

typedef long long ll;
using namespace std;
const ll oo = 1e18;

int n, A[maxn];
ll F[maxn][maxn], pre[maxn];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	FOR(i, 1, n) cin >> A[i];
	pre[0] = 0;
	FOR(i, 1, n)
        pre[i] = pre[i-1] + A[i];
    FORD(i, n, 1) {
        F[i][i] = 0;
        FOR(j, i+1, n) {
            F[i][j] = oo;
            FOR(k, i, j-1)
                F[i][j] = min(F[i][j], F[i][k] + F[k+1][j]);
            F[i][j] += pre[j] - pre[i-1];
        }
    }
    cout << F[1][n];
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb             push_back
#define conv(a)        bitset<30>(a).to_string() ;
#define mxpq           priority_queue <int>
#define mnpq           priority_queue<int,vector<int>,greater<int>>
#define S(v)           sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define print          printf("%.16f\n", ans)
#define inf            LLONG_MAX
#define mini           LLONG_MIN
#define T              int tc;cin>>tc;while(tc--)
#define MSET(tabl,i)   memset(tabl, i, sizeof(tabl))
#define int            long long 
#define MAXN           10000001
#define M              1000000007
#define fio            cin.sync_with_stdio(false) ; cin.tie(0);cout.tie(0) ;
#define endl           "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;
 
 
void Xarr(){
     
       int n ; cin>>n ;
       int ans=1 ;
       bool b=true ;
       bool z=false ;
       for(int i=0;i<n;i++){
           int x; cin>>x ;
           if(x==0){
                z=true ;
                continue ;
           }
           if(b==false) continue ;
           int p=1e18 ;
           if(ans>p/x){
               b=false ;
           }
           ans=ans*x ;
       }
       if(z){
            cout<<0<<endl ;
            return ;
       }
       if(b==false) ans=-1 ;
       cout<<ans<<endl ;
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
int32_t main(){
 
    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    #ifndef ONLINE_JUDGE
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif
    
    cout << setprecision(9) << fixed;
     clock_t z = clock();
     
     Xarr();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
 
     return 0;
 
}

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

int main() {
  char c;
  std::cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    std::cout << "vowel\n";
  } else {
    std::cout << "consonant\n";
  }
}


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

using namespace std;

int main(){
    int H,W,N,sum=0;
    cin >> H >> W >> N;

    for(int i=0;i<min(H,W);i++){
        sum += max(H,W);
        if(N<=sum){
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);		
		long money = a.nextLong();
		long b = 100;
		int num = 0;
		for(long i = b; i <= money; i++) {
			long risi = b / 100;
			b = b + risi;
			i = b;
			num++;

		}
		System.out.println(num);
		
	}
}

Measured memory_bytes: 35848
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	int cnt = 0;
	rep(i, m) {
		cin >> a[i];
		if (a[i] & 1) cnt++;
	}
	if (cnt == 0) {
		rep(i, m) cout << a[i] << ' ';
		cout << endl;
		cout << m + 1 << endl;
		cout << 1 << ' ';
		rep(i, m) {
			if (i == m - 1) cout << a[i] - 1 << ' ';
			else cout << a[i] << ' ';
		}
		cout << endl;
	}
	else if (cnt == 1) {
		vector<int> b;
		rep(i, m) if (a[i] & 1) b.pb(a[i]);
		rep(i, m) if (!(a[i] & 1)) b.pb(a[i]);
		rep(i, m) cout << b[i] << ' ';
		cout << endl;
		vector<int> ans;
		if (b[0] > 1) ans.pb(b[0] - 1);
		for (int i = 1; i < m; i++) ans.pb(b[i]);
		ans.pb(1);
		cout << ans.size() << endl;
		for (int i : ans) cout << i << ' ';
		cout << endl;
	}
	else if (cnt == 2) {
		vector<int> b;
		int idx = -1;
		rep(i, m) {
			if (a[i] & 1) {
				b.pb(a[i]); idx = i + 1; break;
			}
		}
		rep(i, m) if (!(a[i] & 1)) b.pb(a[i]);
		for (int i = idx; i < m; i++) if (a[i] & 1) b.pb(a[i]);
		rep(i, m) cout << b[i] << ' ';
		cout << endl;
		vector<int> ans;
		if (b[0] > 1) ans.pb(b[0] - 1);
		for (int i = 1; i < m - 1; i++) ans.pb(b[i]);
		ans.pb(b[m - 1] + 1);
		cout << ans.size() << endl;
		for (int i : ans) cout << i << ' ';
		cout << endl;
	}
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std; 
 
// Macroes
#define REP(inc, bgn, end) for (int inc = bgn; inc < (end); inc++)

typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
const int inf = 1001001001;


// declaration

int a[12][12];

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    REP(i,0,n) {
        cin >> c[i];
        REP(j,0,m) cin >> a[i][j];
    }

    int ans = inf;
    REP(s,0,1<<n) {
        int cost = 0;
        vector<int> d(m);
        REP(i,0,n) {
            if (s>>i&1) {
                cost += c[i];
                REP(j,0,m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        REP(j,0,m) if (d[j] < x) ok = false;
        if (ok) chmin(ans, cost);
    }
    if (ans == inf) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3636
A = list(input())
B = list(input())
C = list(input())

a1 = A.pop(0)
while True:
    if len(A) == 0 and a1 == 'a':
        print('A')
        break
    if len(B) == 0 and a1 == 'b':
        print('B')
        break
    if len(C) == 0 and a1 == 'c':
        print('C')
        break
    
    if a1 == 'a':
        a1 = A.pop(0)
    elif a1 == 'b':
        a1 = B.pop(0)
    else:
        a1 = C.pop(0)


    

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int t,n;
int board[200][200];

int di[6]={1,1,0,0,-1,-1};
int dj[6]={0,1,-1,1,-1,0};

/*
void dfs(int i,int j,int turn){
	if(turn==t+1)return;
	board[i][j]=2;
	cnt++;
	rep(d,6){
		int ni=i+di[d],nj=j+dj[d];
		if(ni<0||nj<0||ni>=200||nj>=200||board[ni][nj]!=0)continue;
		dfs(ni,nj,turn+1);
	}
}*/

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>t>>n;
		if(t==0&&n==0)break;
		memset(board,0,sizeof(board));
		rep(i,n){
			int x,y;
			cin>>x>>y;
			x+=100; y+=100;
			board[y][x]=1;
		}
		int sx,sy;
		cin>>sx>>sy;
		sx+=100; sy+=100;
		int res=0;
		queue<PPI> que;
		que.push(PPI(P(sy,sx),0));
		board[sy][sx]=2;
		while(!que.empty()){
			int i=que.front().fi.fi,j=que.front().fi.se,turn=que.front().se; que.pop();
			res++;
			rep(d,6){
				int ni=i+di[d],nj=j+dj[d];
				if(ni<0||nj<0||ni>=200||nj>=200||board[ni][nj]!=0)continue;
				if(turn<t){
					board[ni][nj]=2;
					que.push(PPI(P(ni,nj),turn+1));
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3376
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#define P 998244353
#define N_MAX 10000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}

//kの倍数
int main(int argc, char const *argv[]) {
  init();
  ll n, ans = 0;std::cin >> n;
  vector<ll> num(1000001, 0);
  for(int i=0;i<n;i++){
    ll a;scanf("%lld", &a);
    num[a]++;
  }
  vll dat(1000001, 0);

  //kの倍数 O(10^6 log 10^6)
  for(ll k=1;k<=1000000;k++){
    ll s = 0, minus = 0;
    for(ll x=k;x<=1000000;x+=k){
      s = (s + (num[x]*x)%P)%P;
      minus = (minus + (x*x*num[x])%P)%P;
    }
    ll tmp = (inv[2]*((s*s)%P - minus + P)%P)%P;
    dat[k] = tmp;
  }

  for(ll k=1000000;k>0;k--){
    for(ll x=2*k;x<=1000000;x+=k) dat[k] = (dat[k] - dat[x] + P)%P;
    ans = (ans + pp(inv[k], dat[k]))%P;
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> h(N);
  REP(i, N) cin >> h[i];
  //足場iにたどり着くまでの最小コスト
  vector<int> cost(N);
  cost[0] = 0;
  cost[1] = abs(h[1] - h[0]);
  for(int i = 2; i < N; i++) {
    cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]),
                  cost[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << cost[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,k;
  cin>>n>>k;
  long long a[n];
  REP(i,n){
    cin>>a[i];
  }
  long long s[n],ps[n];
  REP(i,n){
    if(i==0){
      s[i] = a[i];
      ps[i] = max(0LL,a[i]);
    }else{
      s[i] = s[i-1] + a[i];
      ps[i] = ps[i-1] + max(0LL,a[i]);
    }
  }
  
  long long ans = 0;
  long long mid;
  long long temp;
  REP(i,n-k+1){
    if(i==0){
      mid = max(0LL,s[i+k-1]);
    }else{
      mid = max(0LL,s[i+k-1]-s[i-1]);
    }
    temp = mid;
    
    if(i==0){
      ;
    }else{
      temp += ps[i-1];
    }
    
    temp += ps[n-1] - ps[i+k-1];
    ans = max(ans,temp);
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define mod 1000000007
#define inf 999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll index=0;
    ll ans=0;
    while(index<n)
    {
        ll low=index;
        while(low<n && s[low]==s[index])
            low++;
        ans++;
        index=low;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A_list = list(map(int, input().split()))
A_total = sum(A_list)
A_popular = []
for i in range(N):
    if A_list[i] >= A_total/(4*M):
        A_popular.append(A_list[i])
if len(A_popular) >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060