akhauriyash/Code-Regression huggingface dataset:
#include <cmath>

class point2d {
public:
	double x, y;
	point2d() : x(0), y(0) {};
	point2d(double x_, double y_) : x(x_), y(y_) {};
	bool operator==(const point2d& p) { return x == p.x && y == p.y; }
	bool operator!=(const point2d& p) { return x != p.x || y != p.y; }
	point2d& operator+=(const point2d& p) { x += p.x; y += p.y; return *this; }
	point2d& operator-=(const point2d& p) { x -= p.x; y -= p.y; return *this; }
	point2d& operator*=(const double v) { x *= v; y *= v; return *this; }
	point2d operator+(const point2d& p) const { return point2d(*this) += p; }
	point2d operator-(const point2d& p) const { return point2d(*this) -= p; }
	point2d operator*(const double v) const { return point2d(*this) *= v; }
	double norm() const { return x * x + y * y; }
	double abs() const { return std::sqrt(x * x + y * y); }
	double dot(const point2d& p) const { return x * p.x + y * p.y; }
	double cross(const point2d& p) const { return x * p.y - y * p.x; }
};

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct crossing {
	double place; int sky;
};
bool operator<(const crossing& c1, const crossing& c2) {
	return c1.place < c2.place;
}
int main() {
	int T;
	cin >> T;
	while (T--) {
		point2d S, G; int N;
		cin >> S.x >> S.y >> G.x >> G.y >> N;
		vector<point2d> rs(N), rg(N); vector<int> own(N), sky(N);
		for (int i = 0; i < N; ++i) {
			cin >> rs[i].x >> rs[i].y >> rg[i].x >> rg[i].y >> own[i] >> sky[i];
		}
		vector<crossing> dats;
		for (int i = 0; i < N; ++i) {
			if (((G - S).cross(rs[i] - S) > 0) != ((G - S).cross(rg[i] - S) > 0)) {
				double t1 = (G - S).dot(rs[i] - S) / (G - S).abs(), h1 = (G - S).cross(rs[i] - S) / (G - S).abs(); h1 = abs(h1);
				double t2 = (G - S).dot(rg[i] - S) / (G - S).abs(), h2 = (G - S).cross(rg[i] - S) / (G - S).abs(); h2 = abs(h2);
				double pl = (h2 * t1 + h1 * t2) / (h1 + h2);
				pl /= (G - S).abs();
				if (0 <= pl && pl <= 1) {
					dats.push_back(crossing{ pl, own[i] ^ sky[i] });
				}
			}
		}
		sort(dats.begin(), dats.end());
		int cnt = 0;
		for (int i = 1; i < dats.size(); ++i) {
			if (dats[i].sky != dats[i - 1].sky) {
				++cnt;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


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

int main(){
  int i,N;
  char suji[9];
  int n; cin >> N;
  int cnt = 1;
  while( N > 0 ){
    N--;
    cin >> n;
    int k = 10;
    cout << "Case" << " " << cnt << ":" << endl;
    cnt++;
    while( k > 0 ){
      k--;
      int s = n*n;
      for( i = 1; i <= 8; i++ ) suji[i] = '0'; 

      int amari_zan = 10,wari_zan = 1,tmp;
      for( i = 8; i >= 1; i-- ){
	tmp = s % amari_zan;
	tmp /= wari_zan;
	suji[i] = tmp + '0';
	amari_zan *= 10;
	wari_zan *= 10;
      }
      int kakeru = 1000;
      n = 0;
      for( i = 3; i <= 6; i++ ){
	n += ( suji[i] - '0' )  * kakeru;
	kakeru /= 10;
      }

      cout << n << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
def bisect_right_descending(a, x, lo=0, hi=None):
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x > a[mid]: hi = mid
        else: lo = mid+1
    return lo


n = int(input())

b = []

for i in range(n):
    a = int(input())
    c = bisect_right_descending(b,a)
    if c==len(b):
        b.append(a)
    else:
        b[c]=a

print(len(b))

Measured memory_bytes: 52312
use std::io;
use std::cmp::min;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let x: i64 = input.next();
    let y: i64 = input.next();
    let mut a: i64 = i64::max_value();
    if x <= y {
        a = min(a, y - x);
    }
    if x <= -y {
        a = min(a, -y - x + 1);
    }
    if -x <= y {
        a = min(a, y + x + 1);
    }
    if -x <= -y {
        a = min(a, -y + x + 2);
    }
    println!("{}", a);
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int 
#define pb push_back
#define xx first
#define yy second

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t;
	t=1;
	while(t--)
	{
		ll x;
		cin>>x;
		cout<<(x>=30 ? "Yes" : "No");
	}
}

Measured memory_bytes: 3584
n, k = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i)

exps = ps.map do |v|
  v * 0.5 + 0.5
end
 
max = 0
 
i = 0
j = k
memo = exps[i...j].reduce(:+) - exps[j-1]
while j <= ps.size do
  sum = memo + exps[j-1]
  memo = sum - exps[i]
  if sum > max
    max = sum
  end
  i += 1
  j += 1
end
 
puts max

Measured memory_bytes: 16524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int n,i,b[200],sum=0;
	cin >> n;
	for(i=1;i<n;i++){
		cin >> b[i];
	}
	for(i=1;i<=n;i++){
		if(i==1) sum+=b[1];
		else if(i==n) sum+=b[n-1];
		else sum+=min(b[i-1],b[i]);
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

#define loop(i, n) for (int i = 0; i < (int)n; i++)

bool check_diff(char a, char b, char c) {
    if (a != b && b != c && c != a) return true;
    else return false;
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    ll r = 0, g = 0, b = 0;
    loop(i, n) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'G') g++;
        else b++;
    }
    ll same = 0;
    loop(i, n) {
        for (int k = i + 1; k < n; k++) {
            if ((k - i) % 2 != 0) continue;
            if(check_diff(s[i], s[k], s[(i + k) / 2])) {
                same++;
            }
        }
    }
    cout << r * g * b - same << endl;
}

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

int main () {
    int n, m;
    cin >> n;
    map<string, int> cnt;
    for (int i = 0; i < n; ++i) {
        string tmp;
        cin >> tmp;
        ++cnt[tmp];
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        string tmp;
        cin >> tmp;
        --cnt[tmp];
    }

    map<string, int>::iterator it;
    it = cnt.begin();
    vector<pair<string, int> > res;
    for (it; it != cnt.end(); ++it) {
        res.push_back({it->first, it->second});
    }

    int ans = 0;
    for (int i = 0; i < res.size(); ++i) {
        ans = max(ans, res[i].second);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
INF = float('inf')
from bisect import bisect_left
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
def f(x, s, t):
  result = INF
  i = bisect_left(s, x)
  if i > 0:
    j = bisect_left(t, s[i - 1])
    if j > 0:
      result = min(result, (x - s[i - 1]) + (s[i - 1] - t[j - 1]))
    if j < len(t):
      result = min(result, (x - s[i - 1]) + (t[j] - s[i - 1]))
  if i < len(s):
    j = bisect_left(t, s[i])
    if j > 0:
      result = min(result, (s[i] - x) + (s[i] - t[j - 1]))
    if j < len(t):
      result = min(result, (s[i] - x) + (t[j] - s[i]))
  return result
for i in range(q):
  x = int(input())
  print(min(f(x, s, t), f(x, t, s)))


Measured memory_bytes: 12092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

template<class T>
struct StronglyConnectedComponents {
private:
    int n, k;
    vector<vector<int>> g, rg;
    vector<bool> used;
    vector<int> vs;
    vector<T> cmp;
    
    void dfs(int v) {
        used[v] = true;
        for(auto &u : g[v]) {
            if (!used[u]) dfs(u);
        }
        vs.push_back(v);
    }
    
    void rdfs(int v, int k) {
        used[v] = true;
        cmp[v] = k;
        for(auto &u : rg[v]) {
            if (!used[u]) rdfs(u, k);
        }
    }
    
public:
    StronglyConnectedComponents() {}
    StronglyConnectedComponents(int _n) {
        n = _n;
        g.resize(n);
        rg.resize(n);
        used.resize(n, false);
        cmp.resize(n);
    }
    
    void add_edge(int from, int to) {
        g[from].push_back(to);
        rg[to].push_back(from);
    }
    
    vector<T> query() {
        fill(used.begin(), used.end(), false);
        vs.clear();
        for(int i = 0; i < n; i++) {
            if (!used[i]) dfs(i);
        }
        fill(used.begin(), used.end(), false);
        k = 0;
        for(int i = vs.size() - 1; i >= 0; i--) {
            if (!used[vs[i]]) rdfs(vs[i], k++);
        }
        return cmp;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    StronglyConnectedComponents<ll> scc(n);
    rep(i, m) {
        ll s, t;
        cin >> s >> t;
        scc.add_edge(s, t);
    }
    vector<ll> ans = scc.query();
    ll q;
    cin >> q;
    rep(i, q) {
        ll u, v;
        cin >> u >> v;
        cout << ((ans[u] == ans[v]) ? 1 : 0) << endl;
    }
    return 0;
}



Measured memory_bytes: 4620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n, x, y;
    cin >> n >> x >> y;

    vector<int> ans(n);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int d = min(j - i, abs(i - x) + 1 + abs(y - j));
            ans[d]++;
        }
    }
    for (int i = 1; i < n; i++) cout << ans[i] << endl;

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = 0
for i in range(n):
    if a[i] < b[i]:
        x += (b[i] - a[i])//2
    else:
        x -= (a[i] - b[i])
if x < 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 4596
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    a: usize,
    b: usize
    }
    let ans = if a < 2 * b {0} else {a - 2 * b};
    println!("{}", ans);
}


Measured memory_bytes: 2172
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, q = map(int, input().split())
    s = input()

    ans = [0] * (n + 1)
    pre = ''
    sum = 0
    for i, w in enumerate(s):
        if pre == 'A' and w == 'C':
            sum += 1
        ans[i+1] = sum
        pre = w
    
    for i in range(q):
        l, r = map(int, input().split())
        print(ans[r] - ans[l])

if __name__ == '__main__':
    main()



Measured memory_bytes: 6380
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
        int[] c = new int[n - 1];
        for (int i = 0; i < n; i++) {
          a[i] =  sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
          b[i] =  sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
          c[i] =  sc.nextInt();
        }
        int sum = 0;
        int lastV = - 1;
        for(int i = 0; i < n; i++) {
          sum += b[a[i] - 1];
          if (a[i] == lastV + 1) {
            sum += c[lastV - 1];
          }
          lastV = a[i];
        }
    
		// 出力
		System.out.println(sum);
	}
}

Measured memory_bytes: 23764
#include <iostream>

long long n,m;
int main(){
  std::cin>>n>>m;
  
  if(n<2&&m<2)
    std::cout<<1<<std::endl;
  else if(n<2)
    std::cout<<m-2<<std::endl;
  else if(m<2)
    std::cout<<n-2<<std::endl;
  else
    std::cout<<(n-2)*(m-2)<<std::endl;
  return 0;
}


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

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;

    int ans = 2000000000;
    if(x <= y)   ans = min(ans,y-x);
    if(-x <= y)  ans = min(ans,y+x+1);
    if(-x <= -y) ans = min(ans,x-y+2);
    if(x <= -y)  ans = min(ans,-y-x+1);
    cout << ans << endl;

}





Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
 
 
int main() {
    int divisor = 1000000007;
    string S;
    char ch[] = {'A', 'B', 'C'};
    cin >> S;
    int l = S.size();
    vector<vector<ll> > data(l + 1, vector<ll>(4, 0));
    data[l][3] = 1;
    data[l][2] = 0;
    data[l][1] = 0;
    data[l][0] = 0;

    for (int i = l - 1; i >= 0; i--) {
        if (S[i] == '?') {
            data[i][3] = (3 * data[i + 1][3]) % divisor;
        } else {
            data[i][3] = data[i + 1][3] % divisor;
        }
        for (int j = 0; j <= 2; j++) {
            if (S[i] == '?') {
                data[i][j] = (3 * data[i + 1][j] + data[i + 1][j + 1]) % divisor;
            } else if (S[i] == ch[j]) {
                data[i][j] = (data[i + 1][j] + data[i + 1][j + 1]) % divisor;
            } else {
                data[i][j] = data[i + 1][j] % divisor;
            }
        }
    }
    cout << data[0][0] << endl;
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ANS(ans) cout << ans << endl;


int
main()
{
  int H, W; cin >> H >> W;
  int h, w; cin >> h >> w;

  ANS((H-h)*(W-w));

  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;


const int MAX = 150001;  
int main(){
    int n;
    cin >> n;
    string arr [] = {"AC", "WA", "TLE", "RE"};
    unordered_map <string , int> m;
    for (int i = 0; i < 4; ++i) m[arr[i]] = 0;
    for (int i = 0; i < n; ++i){
        string s; cin >> s;
        m[s]++;
    }
    for (int i = 0; i < 4; ++i){
        cout << arr[i] << " x "  << m[arr[i]] << endl;
    }   
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;


int main() {

	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (0 <= x - r && 0 <= y - r && W >= x + r && H >= y + r) cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 3092
s = input()
lon = len(s)
lis = list(s)
ans = 10000
#print(lis)
for i in s:
    cnt=0
    lef = []

    ind = [j for j, x in enumerate(lis) if x==i]
    pre=0
    for ma in ind:
        lef.append(ma-pre)
        pre = ma+1
    lef.append(lon-ma-1)
    ans_ten = max(lef)
    ans = min(ans,ans_ten)

print(ans)

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

int i,j,k,m,n,a,b;

int main(){
	scanf("%d%d",&a,&b);
	if(a%2==0 || b%2==0){
		printf("No");
	}
	else 
		printf("Yes");
	return 0;
}

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

using Edges=vector<int>;
using Graph=vector<Edges>;
const int HALF=20;
int dp0[1<<HALF];
int vs0[HALF];
int dp1[1<<HALF];
int vs1[HALF];
int solve(Graph& g,vector<int>& b){
    int n=g.size();
    if(n==1){
        return b[0];
    }
    int half=n/2;
    int rest=n-half;
    const int INF=1e6;
    for(int i=0;i<half;i++){
        vs0[i]=0;
        for(int j=0;j<g[i].size();j++){
            if(g[i][j]<half) vs0[i]|=(1<<g[i][j]);
        }
    }
    for(int i=1;i<(1<<half);i+=2){
        int vs=0;
        int val=0;
        for(int j=0;j<half;j++){
            if((1<<j)&i){
                val+=b[j];
                vs|=vs0[j];
            }
            if(vs&i) val=-INF;
            dp0[i]=val;
        }
    }

    
    for(int i=0;i<rest;i++){
        vs1[i]=0;
        for(int j=0;j<g[i+half].size();j++){
            if(g[i+half][j]>=half) vs1[i]|=(1<<(g[i+half][j]-half));
        }
    }
    for(int i=0;i<(1<<rest);i++){
        bool isok=true;
        int vs=0;
        int val=0;
        for(int j=0;j<rest;j++){
            if((1<<j)&i){
                val+=b[j+half];
                vs|=vs1[j];
            }
            if(i&vs) val=-INF;
            dp1[i]=val;
        }
    }
    for(int i=0;i<(1<<rest);i++){
        for(int j=0;j<rest;j++){
            dp1[i|(1<<j)]=max(dp1[i|(1<<j)],dp1[i]); 
        }
    }

    vector<int> vs01(half,0);
    for(int i=0;i<half;i++){
        for(int j=0;j<g[i].size();j++){
            if(g[i][j]>=half) vs01[i]|=(1<<(g[i][j]-half));
        }
    }
    int res=0;
    for(int i=1;i<(1<<half);i+=2){
        int opn=(1<<rest)-1;
        for(int j=0;j<half;j++){
            if(i&(1<<j)) opn&=~vs01[j];
        }
        res=max(res,dp0[i]+dp1[opn]);
    }
    return res;
}

int main(){
    //ios_base::sync_with_stdio(false);
    int n;
    while(cin>>n,n){
        vector<string> a(n);
        vector<int> b(n);
        vector<int> c(n);
        vector<vector<string>> d(n);
        for(int i=0;i<n;i++){
            cin>>a[i]>>b[i]>>c[i];
            d[i].assign(c[i],"");
            for(int j=0;j<c[i];j++){
                cin>>d[i][j];
            }
        }

        map<string,int> dic;
        for(int i=0;i<n;i++) dic[a[i]]=i;
        Graph g(n);
        for(int i=0;i<n;i++){
            for(int j=0;j<c[i];j++){
                int v=dic[d[i][j]];
                g[i].push_back(v);
            }
        }
        cout<<solve(g,b)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 11516
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

g_comb_table ={}
def Comb(n, k):
    global g_comb_table
    if (n, k) in g_comb_table:
        return g_comb_table[(n, k)]
    if n == k or k == 0:
        g_comb_table[(n, k)] = 1
        return 1L
    elif k == 1:
        g_comb_table[(n, k)] = n
        return n
    g_comb_table[(n, k)] = Comb(n-1, k-1) + Comb(n-1, k)
    return g_comb_table[(n, k)]



def count(dig, msd, msd_bound):
    if msd < msd_bound:
        return int(3 ** max(0, (dig - 3))) * max(0, (dig - 1)) * max(0, (dig - 2)) * max(0, (dig - 3))
    else:
        return int(3 ** max(0, (dig - 3))) * max(0, (dig - 2)) * max(0,(dig - 1)) * max(0, (dig - 2))


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    S = "0753"
    already = set([])
    count = 0
    for s1 in S:
        for s2 in S:
            for s3 in S:
                for s4 in S:
                    for s5 in S:
                        for s6 in S:
                            for s7 in S:
                                for s8 in S:
                                    for s9 in S:
                                        s = s1+s2+s3+s4+s5+s6+s7+s8+s9
                                        s = s.strip()
                                        if (len(s) == 0): continue;
                                        i = int(s1+s2+s3+s4+s5+s6+s7+s8+s9)
                                        s = str(i)
                                        if i <= N and i not in already:
                                            if ("7" in s) and ("3" in s) and ("5" in s) and ("0" not in s):
                                                count += 1
                                                already.add(i)


##    dig = int(math.log(N, 10)) + (0 if N % 10 == 0 else 1)
##    msd = N / (10**(dig - 1))
##    if msd < 5:
##        las = 1
##    elif msd < 7:
##        las = 2
##    else:
##        las = 3
##    C1 = Comb(dig, 3)
##    top7 = count(dig, msd, 7)
##    top5 = count(dig, msd, 5)
##    top3 = count(dig, msd, 3)
    print  count

    #for i in range(dig):


if __name__ == '__main__':
    main()


Measured memory_bytes: 5996
fun main(args: Array<String>) {
    val (n, y) = readLine()!!.split(" ").map(String::toInt)
    for (a in 0..n) {
        for (b in 0..(n - a)) {
            val c = n - a - b
            if (10000 * a + 5000 * b + 1000 * c == y) {
                println("$a $b $c")
                return
            }
        }
    }
    println("-1 -1 -1")
}

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

using namespace std;

int main()
{
    int N, M, a, b;
    cin >> N >> M;
    int L[M], R[M], d[M], g[N+1];
    long long K[N+1], MM=-20000000000000;
    vector <pair<int,int>> D[N+1];
    vector <int> T;
    for (int i = 0; i < M; i++)
    {
        cin >> L[i] >> R[i] >> d[i];
        D[L[i]].push_back({R[i], d[i]});
        D[R[i]].push_back({L[i], d[i]*-1});
    }
    for (int i = 0; i <= N; i++)
    {
        g[i] = 1;
        K[i] = MM;
    }
    for (int i = 1; i <= N; i++)
    {
        if (g[i] == 1)
        {
            g[i] = 0;
            T.push_back(i);
            K[i] = 0;
            for (int y = 0; y < T.size(); y++)
            {
                a = T[y];
                for (int u = 0; u < D[a].size(); u++)
                {
                    b = D[a][u].first;
                    if (K[a] != MM && K[b] != MM && K[a] + D[a][u].second != K[b])
                    {
                        cout << "No";
                        return 0;
                    }
                    K[b] = K[a] + D[a][u].second;
                    if (g[b] == 1)
                    {
                        g[b] = 0;
                        T.push_back(b);
                    }
                }
            }
            T.clear();
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main() {
  int K, S, cnt = 0;
  cin >> K >> S;
  rep(x, K + 1) rep(y, K + 1) {
    int z = S - x - y;
    if(z >= 0 && z <= K)
      cnt++;
  }
  cout << cnt << endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    vvi candy(2, vi(n));
    rep(i, 2) rep(j, n) std::cin >> candy[i][j];
    rep(i, n-1) candy[0][i+1] += candy[0][i];
    drep(i, n-1) candy[1][i] += candy[1][i+1];
    int ans = 0;
    rep(i, n) {
        chmax(ans, candy[0][i]+candy[1][i]);
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n,d;
    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++){
        double x,y;
        cin>>x>>y;
        double t=sqrt(x*x+y*y);
        if(t<=d)ans++;
    }
    cout<<ans<<endl;
}

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

int main(){
    int a, b;
    int cnt = 0;
    cin >> a >> b;
    for (a; a<=b; a++){
        if (a%10==0) continue;
        if (a/10000 == a%10 && a/1000%10 == a/10%10){
            //cout << a << endl;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#下手にlist作って呼び出すよりも、逐次計算するほうが早い？
n, d = map(int, input().split())
ans = 0
d = d ** 2

for i in range(n):
    x, y = map(int, input().split())
    if d >= x ** 2 + y ** 2:
        ans += 1

print(ans)

Measured memory_bytes: 9016
#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)->sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int cnt = 1;
    int sign = 0;
    REP(i, n - 1) {
        int diff = a[i + 1] - a[i];
        if (diff == 0) continue ;
        if (sign) {
            if (sign * diff < 0) {
                sign = 0;
                cnt++;
            }
        } else {
            if (diff > 0) sign = 1;
            else sign = -1;
        }
    }

    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 640
n = int(input())
for r_1 in range(n//4 + 1):
    sum_4 = r_1 * 4
    for r_2 in range(n//7 + 1):
        sum_7 = r_2 * 7
        if sum_4 + sum_7 == n:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 2940
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

class Point{
public:
	int x,y;
	Point(){}
	Point(int X,int Y):x(X),y(Y){}
};

class Circle{
public:
	Point c;
	int r;
	Circle(){}
	Circle(const Point &C,int R):c(C),r(R){}
};

#define sq(x) (x)*(x)
int dist2(const Point &p,const Point &q){
	return sq(p.x-q.x)+sq(p.y-q.y);
}

bool cover(const Circle &c,const Point &p){
	return dist2(p,c.c)<sq(c.r);
}

bool cover(const Circle &c1,const Circle &c2){
	return c1.r>=c2.r && dist2(c1.c,c2.c)<sq(c1.r-c2.r);
}

bool peri_intersect(const Circle &c1,const Circle &c2){
	int d2=dist2(c1.c,c2.c);
	return sq(c1.r-c2.r)<=d2 && d2<=sq(c1.r+c2.r);
}

int dp[1002];
vector<int> adj[1002];

int dfs(int u){
	if(~dp[u]) return dp[u];
	int res=0;
	rep(i,adj[u].size()){
		int v=adj[u][i];
		res=max(res,dfs(v)+1);
	}
	return dp[u]=res;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		Point s,t; scanf("%d%d%d%d",&s.x,&s.y,&t.x,&t.y);
		Circle c[1000];
		vector<int> S,T;
		rep(i,n){
			scanf("%d%d%d",&c[i].c.x,&c[i].c.y,&c[i].r);
			bool bs=cover(c[i],s);
			bool bt=cover(c[i],t);
			if(bs^bt){
				if(bs) S.push_back(i);
				if(bt) T.push_back(i);
			}
		}

		rep(u,n+2) adj[u].clear();
		rep(i,S.size()){
			int u=S[i];
			rep(j,S.size()){
				int v=S[j];
				if(u!=v && cover(c[v],c[u])) adj[u].push_back(v);
			}
			adj[n].push_back(u);
			adj[u].push_back(n+1);
		}
		rep(i,S.size()) rep(j,T.size()) {
			int u=S[i],v=T[j];
			if(u!=v && !peri_intersect(c[u],c[v])) adj[u].push_back(v);
		}
		rep(i,T.size()){
			int u=T[i];
			rep(j,T.size()){
				int v=T[j];
				if(u!=v && cover(c[u],c[v])) adj[u].push_back(v);
			}
			adj[n].push_back(u);
			adj[u].push_back(n+1);
		}
		adj[n].push_back(n+1);

		rep(u,n+2) dp[u]=-1;
		rep(u,n+2) dfs(u);

		printf("%d\n",*max_element(dp,dp+n+2)-1);
	}

	return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 210

int main() {
  int N, Q;
  string title[SIZE], author[SIZE], date[SIZE];

  scanf("%d", &N);

  for (int i = 0; i < N; i++) {
    cin >> title[i] >> author[i] >> date[i];
  }

  cin >> Q;

  for (int i = 0; i < Q; i++) {
    string q1, q2, q3, q4;
    cin >> q1 >> q2 >> q3 >> q4;
    for (int j = 0; j < N; j++) {
      bool ok = true;


      ok &= q1 == "*" || title[j].find(q1) != string::npos;
      ok &= q2 == "*" || author[j].find(q2) != string::npos;
      ok &= q3 == "*" || q3 <= date[j];
      ok &= q4 == "*" || date[j] <= q4;

      if (ok) {
        cout << title[j] << endl;
      }
    }

    if (i + 1 < Q) cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3312
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

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

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

const ll inf = INT_MAX;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int main(){

	int h, w;
	cin >> h >> w;
	rep(i,h){
		string str;
		cin >> str;
		rep(i,2){
			cout << str << endl;
		}
	}
	return 0;
}


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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 3e5 + 5;

int cnt = 0;
pr ans[MAXN];

int main(){
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	int cr = n - a, cl; 
	ans[++cnt] = make_pair(n - a + 1, n);
	up (i, 2, b) {
		if (cr <= 0) return 0 * puts("-1");
		cl = cr;
		while (cr - cl + 1 < a && cl - 1 > (b - i)) {
			cl--; 
			if (cl <= 0) return 0 * puts("-1");
		}
		ans[++cnt] = make_pair(cl, cr);
		cr = cl - 1;
	}
	if (cr != 0) return 0 * puts("-1");
	up (o, 1, cnt) up (i, ans[o].fi, ans[o].se) printf("%d ", i);
	puts("");
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (A == B && B == C) {
        cout << -1 << endl;
        return 0;
    }
    
    int ans = 0;
    while (true) {
        ++ans;
        int a = 0;
        int b = 0;
        int c = 0;
        b += A / 2;
        c += A / 2;
        a += B / 2;
        c += B / 2;
        a += C / 2;
        b += C / 2;
        A = a;
        B = b;
        C = c;
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,x,ans=0;cin>>n>>x;
  int d[n+1],l[n];
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  d[0]=0;
  for(int i=0;i<n;i++){
    d[i+1]=d[i]+l[i];
    if(d[i+1]<=x){ans++;}
  }
  cout << ans+1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int H_MAX=101;
int W_MAX=8;
int p = 1000000007;
typedef long long ll;
int main()
{
  int h,w,k,i,j;
  ll c[W_MAX]={1,1,2,3,5,8,13,21},d[H_MAX][W_MAX];
  cin >> h >> w >> k;
  k--;
  fill(d[0],d[0]+w,0);
  d[0][0]=1;
  for(i=0;i<h;i++)
    for(j=0;j<w;j++){
      d[i+1][j]=d[i][j]*c[j]*c[w-j-1];
      if(j>0)
        d[i+1][j]+=d[i][j-1]*c[j-1]*c[w-j-1];
      if(j<w-1)
        d[i+1][j]+=d[i][j+1]*c[j]*c[w-j-2];
      d[i+1][j]%=p;
    }
  cout << d[h][k] << endl;
  return 0;
}

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




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k;
    cin >> n >> k;
    int height[n],dp[n];
    for(int i = 1; i <= n; i++){
        cin >> height[i];
        dp[i] = INF;
        
    }
    
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= min(i - 1 , k); j++){
            dp[i] = min(dp[i], dp[i - j] + abs(height[i] - height[i - j]));
        }
    }
    
    cout << dp[n] << endl;
	return 0;
}


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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;

int32_t main()
{	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a,b,c,k;
	cin>>a>>b>>c>>k;

	if(a+b>=k)
		cout<<min(a,k)<<'\n';
	else
	{
		cout<<min(a,k)-(1*(k-(a+b)))<<'\n';
	}

	return 0;
}	

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

int main(){
    int a1,a2,a3;
    int b1, b2, b3;
    int max =0;
    cin >> a1 >> a2 >> a3;
    
    b1 = abs(a1-a2);
    b2 = abs(a1-a3);
    b3 = abs(a2-a3);
    if(b1 >= b2 && b1 >=b3) max =b1;
    if(b2 >= b1 && b2 >=b3) max =b2;
    if(b3 >= b1 && b3 >=b2) max =b3;
    cout << (b1 + b2 + b3 -max) <<endl;
    
    return 0;
}


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

int main() {
  int A, B, H, M;
  double angle, ans, rad;
  cin >> A >> B >> H >> M;
  
  if((30 * H) >= (6 * M)){
    angle = (30 * H + 0.5 * M) - (6 * M);
  } else {
    angle = (6 * M) - (30 * H + 0.5 * M);
  }
  
  if (angle >= 180){
    angle = 360 - angle;
  }
  
  rad = angle * (M_PI / 180);
  ans = sqrt((A * A) + (B * B) - (2 * A * B * cos(rad)));
  
  cout << setprecision(20) << ans << endl;
}


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

const int  maxn=200008;
int n,m; 
int a[maxn];
int main(){
  cin>>n>>m;
  for (int i=1;i<=n;i++)
    scanf("%d",&a[i]);
  int dis=0;
  int ans=0;
  int mx=a[n];
  for (int i=n-1;i>=1;i--)
    {
     
    
      if ((mx-a[i])>dis)
        {
          dis=mx-a[i];
          ans=1;
          continue;
        } 
      
      if (mx-a[i]== dis) 
        {
          ans++;
          continue;
        }
      
      if (a[i]>mx) mx=a[i];
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
using namespace std;
#define Maxn 100000
vector<int> G[Maxn+5];
int fa[30][Maxn+5];
int depth[Maxn+5];
int n,q;
struct Edge{
	int to,color,cost;
};
vector<Edge> edge[Maxn+5];
struct Query{
	int color,cost,t,qid;
};
vector<Query> query[Maxn+5];
int dis[Maxn+5];
int cnt[Maxn+5];
int sum[Maxn+5];
int ans[Maxn+5];
int lca(int u,int v){
	if(depth[u]>depth[v]){
		swap(u,v);
	}
	for(int k=0;k<30;k++){
		if(((depth[v]-depth[u])>>k)&1){
			v=fa[k][v];
		}
	}
	if(u==v){
		return u;
	}
	for(int k=29;k>=0;k--){
		if(fa[k][u]!=fa[k][v]){
			u=fa[k][u];
			v=fa[k][v];
		}
	}
	return fa[0][u];
}
void dfs_1(int v,int p,int d){
	fa[0][v]=p;
	depth[v]=d;
	int to;
	for(int i=0;i<(int)G[v].size();i++){
		to=G[v][i];
		if(to==p){
			continue;
		}
		dfs_1(to,v,d+1);
	}
}
void dfs_2(int now,int from){
	Edge e;
	for(int i=0;i<(int)edge[now].size();i++){
		e=edge[now][i];
		if(e.to==from){
			continue;
		}
		dis[e.to]=dis[now]+e.cost;
		dfs_2(e.to,now);
	}
}
void dfs_3(int now,int from){
	int dx;
	for(int i=0;i<(int)query[now].size();i++){
		Query que=query[now][i];
		dx=que.cost*cnt[que.color]-sum[que.color];
		ans[que.qid]+=dx*que.t;
	}
	Edge e;
	for(int i=0;i<(int)edge[now].size();i++){
		e=edge[now][i];
		if(e.to==from){
			continue;
		}
		cnt[e.color]++;
		sum[e.color]+=e.cost;
		dfs_3(e.to,now);
		cnt[e.color]--;
		sum[e.color]-=e.cost;
	}
}
void init(int V){
	dfs_1(0,-1,0);
	for(int k=0;k+1<30;k++){
		for(int v=0;v<V;v++){
			if(fa[k][v]<0){
				fa[k+1][v]=-1;
			}
			else{
				fa[k+1][v]=fa[k][fa[k][v]];
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&q);
	int a,b,c,d;
	Edge e;
	for(int i=0;i<n-1;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		a--,b--;
		e.to=b;
		e.color=c;
		e.cost=d;
		edge[a].push_back(e);
		e.to=a;
		edge[b].push_back(e);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	init(n);
	dis[0]=0;
	dfs_2(0,-1);
	int x,y,u,v;
	Query que;
	for(int i=0;i<q;i++){
		scanf("%d%d%d%d",&x,&y,&u,&v);
		u--,v--;
		ans[i]=dis[u]+dis[v]-(dis[lca(u,v)]<<1);
		que.color=x;
		que.cost=y;
		que.t=1;
		que.qid=i;
		query[u].push_back(que);
		query[v].push_back(que);
		que.t=-2;
		query[lca(u,v)].push_back(que);
	}
	dfs_3(0,-1);
	for(int i=0;i<q;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}


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

using namespace std;
using ll = long long;
int main(){
    ll n,w;
    cin>>n>>w;
    vector<pair<ll,ll>> a(n);
    for(auto &b : a)cin>>b.first>>b.second;
    vector<ll> dp(100050);
    ll ret = 0;
    for(int i=0;i<n;++i){
        ll weight = a[i].first;
        ll value = a[i].second;
        for(int j=w;j>=0;--j){
            if(j+weight<=w) dp[j+weight] = max(dp[j+weight],dp[j]+value);
        }
    }
    for(int i=0;i<=w;++i){
        ret = max(ret,dp[i]);
    }
    cout << ret << endl;
return 0;
}

Measured memory_bytes: 1024
n, m = gets.chomp.split.map(&:to_i)
lanes = Array.new(n){[]}
m.times{
    a, b = gets.chomp.split.map(&:to_i)
    case a
    when 0
        puts lanes[b - 1].shift
    when 1
        min = lanes.map{|ar| ar.length}.min
        i = lanes.index{|ar| ar.length == min}
        lanes[i] << b
    end
}


Measured memory_bytes: 8872
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	long long int a = 0, b = 0, c = 0, memo = 1, s[50] = {};
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		s[str[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (s[i] % 2 != 0) { cout << "No"; return 0; }
	}
	cout << "Yes";
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (tmp, k) = readLine()!!.split(" ").map { it.toLong() }
  val n = tmp.toInt()
  val a = readLine()!!.split(" ").map { it.toInt()-1 }.toIntArray()
  val count = LongArray(n) { -1L }
  var v = 0
  var c = 0L
  while (true) {
    if (count[v] >= 0) break
    count[v] = c
    v = a[v]
    c++
    if (c == k) {
      println(v+1)
      return
    }
  }
  val period = c-count[v]
  val rem = (k-count[v])%period
  for (i in count.indices) {
    if (count[i]-count[v] == rem) {
      println(i+1)
      return
    }
  }
}

Measured memory_bytes: 64264
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>

#include <set>
#include <utility>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int l[m+5], r[m+5];
    for (int i = 0; i < m; i++){
        int bl, br;
        cin >> bl >> br;
        if (bl < br){
            l[i] = bl; r[i] = br;
        }
        else{
            l[i] = br; r[i] = bl;
        }
    }
    int min = 1;
    int max = n;
    // int res = max - min+1;
    for (int i = 0; i < m; i++){
        if (l[i]>min){
            min = l[i];
        }
        if (r[i]<max){
            max = r[i];
        }
        if (max - min+1 < 1) break;
    }
    if (max - min+1 > 0){
    cout  << max - min+1;}
    else{
        cout << 0;
    }

}
    // for (int i = 0; i < ; i++){
        
        //         if(!(i+offset < n)) break;
        // int c = i + offset;
        // if(n/c == n%c){
        //     res += i;
        //     offset += 
        // }
    // }


Measured memory_bytes: 1024
///http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A
#include <bits/stdc++.h>
using namespace std;

int main(){

    int a, b;
    cin >> a >> b;
    cout << a/b << " " << a%b << " " << fixed << setprecision(5) << (double)a/b << endl;
    
    return 0;
}



Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define ipair pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[1000001],cnt[1000001];

int32_t main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2)
  {
    return cout<<"No",0;
  }
  int j=n/2;
  for(int i=0;i<n/2;i++)
  {
    if(s[i]!=s[j])
    {
      return cout<<"No",0;
    }
    j++;
  }
  return cout<<"Yes",0;
}


Measured memory_bytes: 256
import datetime as dt
S = input()
pre = int(S[0:2])
aft = int(S[2:4])

# yymm
try:
    dt.date(int(pre), int(aft), 1)
    flg_yymm = 1
except:
    if int(pre) == 0 and int(aft) >= 1 and int(aft) <= 12:
        flg_yymm = 1
    else:
        flg_yymm = 0
# mmyy
try:
    dt.date(int(aft), int(pre), 1)
    flg_mmyy = 1
except:
    if int(aft) == 0 and int(pre) >= 1 and int(pre) <= 12:
        flg_mmyy = 1
    else:
        flg_mmyy = 0

if flg_yymm == 1 and flg_mmyy == 1:
    print("AMBIGUOUS")
elif flg_yymm == 1 and flg_mmyy == 0:
    print("YYMM")
elif flg_yymm == 0 and flg_mmyy == 1:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3440
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        System.out.println(c + " " + a + " " + b);
    }
}


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

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

int N;

int main()
{
    cin >> N;
    long long int ans = 0;
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        ans += (tmp - 1);
    }
    cout << ans << endl;
}


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

using namespace std;



int main() {

	long long n, weight;
	cin >> n >> weight;

	long long w[n + 1];
	long long v[n + 1];


	for (long long i = 1; i <= n ; i++) cin >> w[i] >> v[i];

	long long ans[weight + 1][n + 1];
	memset(ans, 0, sizeof(ans));


	for (long long i = 1; i <= weight; i++) {
		for (long long j = 1; j <= n; j++) {
			ans[i][j] = ans[i][j - 1];

			if (w[j] <= i) {
				ans[i][j] = max(ans[i - w[j]][j - 1] + v[j], ans[i][j]);
			}
		}
	}

	cout << ans[weight][n] << endl;
	return 0;

}

Measured memory_bytes: 82484
#include <stdio.h>
int a,b;
char str[21];
char d[]="0123456789";
bool pd(char s[])
{
	int i;
	for(i=0;s[i]!='\0';i++)
		if(i!=a&&!(s[i]>='0'&&s[i]<='9'))
			return true;
	return false;
}
int main()
{
	scanf("%d %d",&a,&b);
	getchar();
	gets(str);
	if(str[a]!='-'||pd(str)) printf("No\n");
		else printf("Yes\n");
}

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

int main(){
    long long color[3][31];
    long long D[31][31];

    for(int i=0; i<3; i++){
        for(int j=0; j<31; j++){
            color[i][j]=0;
        }
    }

    int N, C;
    cin >> N >> C;
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            cin >> D[i+1][j+1];
        }
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            int c;
            cin >> c;
            color[(i+j)%3][c]++;
        }
    }
    long long ans =pow(10,12);

    //0がi,1がj,2がk
    for(int i=1; i<=C; i++){
        for(int j=1; j<=C; j++){
            if(j==i) continue;
            for(int k=1; k<=C; k++){
                if(k==i || k==j) continue;
                long long dif =0;
                for(int l=1; l<=C; l++){
                    dif +=D[l][i]*color[0][l];
                    dif +=D[l][j]*color[1][l];
                    dif +=D[l][k]*color[2][l];
                }
                ans = min(ans, dif);
            }
        }
    }

    cout << ans <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int N = int.Parse(line[0]);
            int A = int.Parse(line[1]);
            int B = int.Parse(line[2]);

            if(N * A < B)
            {
                Console.WriteLine(N * A);
            }
            else
            {
                Console.WriteLine(B);
            }
        }
    }
}

Measured memory_bytes: 13140