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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

struct BIT{
  ll bit[101010+1];

  void init(){
    memset(bit,0,sizeof(bit));
  }

  ll sum(int i){
    i++;
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }

  void add(int i,ll v){
    i++;
    while(i<=101010){
      bit[i]+=v;
      i+=i&-i;
    }
  }
};

struct RangeSumQuery{
  BIT bit0, bit1;

  RangeSumQuery(){}

  void init() {
    bit0.init();
    bit1.init();
  }

  ll sum(int from, int to) {
    return (bit0.sum(to)+bit1.sum(to)*to) - (bit0.sum(from)+bit1.sum(from)*from);
  }

  void add(int from, int to, ll value) {
    bit0.add(to, to * value);
    bit0.add(from, - from * value);
    bit1.add(from, value);
    bit1.add(to, -value);
  }
};


int main(){
	cin.sync_with_stdio(false);
  RangeSumQuery rsq;
  rsq.init();
  ll n,q;
  cin>>n>>q;
  while(q--){
    ll ty;
    cin>>ty;
    if(ty){
      ll i;
      cin>>i;
      i--;
      cout<<rsq.sum(i,i+1)<<endl;
    }else{
      ll s,t,x;
      cin>>s>>t>>x;
      s--;
      rsq.add(s,t,x);
    }
  }
	return 0;
}

Measured memory_bytes: 4804
#include<iostream>
#include<map>
#include<vector>
#include<string>
using namespace std;

int A, B;

vector<string> Bmx = {"...#", "...#", "...#", "####"};
vector<string> Bmn = {"...#", ".#.#", "...#", "####"};
vector<string> Bno = {"####", "####", "####", "####"};

vector<string> Amx = {"###.", "###.", "###.", "...."};
vector<string> Amn = {"###.", "#.#.", "###.", "...."};
vector<string> Ano = {"....", "....", "....", "...."};


vector<string> v(100);

int main() {
    cin >> A >> B;

    if(A >= B) B--;
    else A--;
    int subab = A - B;
    int subba = B - A;
    for(int i = 0; i < 25 * 25; i++) {
        if(A >= B) {
            if(B-- > 0){
                v[0 + 4 * (i % 25)] += Bmn[0];
                v[1 + 4 * (i % 25)] += Bmn[1];
                v[2 + 4 * (i % 25)] += Bmn[2];
                v[3 + 4 * (i % 25)] += Bmn[3];
            } 
            else if (subab-- > 0) {
                v[0 + 4 * (i % 25)] += Bmx[0];
                v[1 + 4 * (i % 25)] += Bmx[1];
                v[2 + 4 * (i % 25)] += Bmx[2];
                v[3 + 4 * (i % 25)] += Bmx[3];            
            } 
            else {
                v[0 + 4 * (i % 25)] += Bno[0];
                v[1 + 4 * (i % 25)] += Bno[1];
                v[2 + 4 * (i % 25)] += Bno[2];
                v[3 + 4 * (i % 25)] += Bno[3];
            }
        } else {
            if(A-- > 0){
                v[0 + 4 * (i % 25)] += Amn[0];
                v[1 + 4 * (i % 25)] += Amn[1];
                v[2 + 4 * (i % 25)] += Amn[2];
                v[3 + 4 * (i % 25)] += Amn[3];
            } 
            else if (subba-- > 0) {
                v[0 + 4 * (i % 25)] += Amx[0];
                v[1 + 4 * (i % 25)] += Amx[1];
                v[2 + 4 * (i % 25)] += Amx[2];
                v[3 + 4 * (i % 25)] += Amx[3];            
            } 
            else {
                v[0 + 4 * (i % 25)] += Ano[0];
                v[1 + 4 * (i % 25)] += Ano[1];
                v[2 + 4 * (i % 25)] += Ano[2];
                v[3 + 4 * (i % 25)] += Ano[3];
            }
        }
    }

    cout << 100 << " " << 100 << endl;
    for(auto s : v) cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
/* #region template */
use std::io::{stdin, stdout, Bytes, Read, Stdin, StdinLock, Stdout, StdoutLock, Write};
use std::str::FromStr;
#[allow(dead_code)]
struct Io<'a> {
    reader: Bytes<StdinLock<'a>>,
    writer: StdoutLock<'a>,
    in_buf: [u8; BUF_SIZE],
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn new(stdin: &'a Stdin, stdout: &'a Stdout) -> Io<'a> {
        Io {
            reader: stdin.lock().bytes(),
            writer: stdout.lock(),
            in_buf: [0; BUF_SIZE],
        }
    }
    fn r<T: FromStr>(&mut self) -> T {
        let mut count = 0;
        loop {
            match self.reader.next() {
                Some(Ok(b' ')) | Some(Ok(b'\n')) => break,
                Some(Ok(c)) => self.in_buf[count] = c,
                _ => panic!(),
            }
            count += 1;
        }

        let s = unsafe { std::str::from_utf8_unchecked(&self.in_buf[0..count]) };
        s.parse().unwrap_or_else(|_| panic!())
    }
    fn ru(&mut self) -> usize {
        self.r()
    }
    fn iter<'b, T>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter::new(self)
    }
    fn c<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        self.iter().take(n).collect()
    }
    fn cu(&mut self, n: usize) -> Vec<usize> {
        self.c(n)
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.writer, "{}", v).unwrap();
    }
    fn wn<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.writer, "{}", v).unwrap();
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T> {
    io: &'b mut Io<'a>,
    m: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a: 'b, 'b, T> IoIter<'a, 'b, T> {
    fn new(io: &'b mut Io<'a>) -> IoIter<'a, 'b, T> {
        IoIter {
            io,
            m: std::marker::PhantomData,
        }
    }
}
impl<'a, 'b, T: FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<Self::Item> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let mut io = Io::new(&stdin, &stdout);
    unsafe {
        solve(&mut io);
    }
}
/* #endregion */

const BUF_SIZE: usize = 1024;

static mut DP: [[bool; 2010]; 30] = [[false; 2010]; 30];
unsafe fn solve(io: &mut Io) {
    let n = io.ru();
    let a = io.cu(n);
    let q = io.ru();
    let m = io.cu(q);

    DP[0][0] = true;
    for i in 0..n {
        for j in 0..2001 {
            DP[i + 1][j] |= DP[i][j];
            if j + a[i] <= 2000 {
                DP[i + 1][j + a[i]] = DP[i][j];
            }
        }
    }
    for mi in m {
        if DP[n][mi] {
            io.w("yes");
        } else {
            io.w("no");
        }
    }
}



Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
main()
{
    int k;
    string s;string s2="...";
    cin>>k;
    cin>>s;
    if(s.size()<=k)
    cout<<s<<endl;
    else
    {
        int i;
        for(i=0;i<k;i++)
        cout<<s[i];
        cout<<s2<<endl;

    }
    
    
}

Measured memory_bytes: 3620
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> B(N);
    for (int i = 0; i < N; i++) cin >> B[i];
    vector<bool> selected(N, false);
    vector<int> ans;

    while (ans.size() < N) {
        int idx = 0;
        int selected_idx = -1;
        for (int i = 0; i < N; i++) {
            if (!selected[i] && idx + 1 == B[i]) selected_idx = i;
            if (!selected[i]) idx++;
        }

        if (selected_idx == -1) {
            cout << -1 << endl;
            return 0;
        } else {
            selected[selected_idx] = true;
            ans.push_back(B[selected_idx]);
        }
    }

    reverse(ans.begin(), ans.end());
    for (int a : ans) cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int x[5];
    rep(i,5) cin >> x[i];
    rep(i,5){
        if(x[i]==0) cout << i+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i =0;i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    ans = max(0, c-(a-b));
    cout << ans <<endl;
    return 0;
}


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

int main()
{
	int n,k,l[505],ans=0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int l;
		cin >> l;
		if (l >= k) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int MAX_N = 55, MOD = 1e9 + 7;

int n;
string s, t;

bool usedStates[MAX_N][4][4];
int dp[MAX_N][4][4];

int Solve(int colInd, int upColor, int downColor) {
	if(colInd == n) {
		return 1;
	}
	else if(usedStates[colInd][upColor][downColor]) {
		return dp[colInd][upColor][downColor];
	}
	
	bool colors[4] = {1, 1, 1, 1};
	colors[upColor] = 0;
	colors[downColor] = 0;
	
	int ans = 0;
	if(s[colInd] == t[colInd]) {
		for(int i = 1; i <= 3; i++) {
			if(colors[i]) {
				ans = (1ll * ans + 1ll * Solve(colInd + 1, i, i)) % MOD;
			}
		}
	}
	else {
		for(int i = 1; i <= 3; i++) {
			for(int j = 1; j <= 3; j++) {
				if(i == j || i == upColor|| j == downColor) {
					continue;
				}
				
				ans = (1ll * ans + 1ll * Solve(colInd + 2, i, j)) % MOD;
			}
		}
	}
	
	usedStates[colInd][upColor][downColor] = true;
	dp[colInd][upColor][downColor] = ans;
	
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> s >> t;
	
	cout << Solve(0, 0, 0) << endl;
	return 0;
}


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

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 

vector<bool> seen;
vector<int> ret;
int main() {
    ll N;
    cin >> N;

    seen.assign(N, false);
    ret.assign(N, 0);
    vector<vector<pair<ll, ll>>> path(N, vector<pair<ll, ll>>());

    for(ll i = 0; i < N-1; i++) {
        ll u, v, w;
        cin >> u >> v >> w;

        path[u-1].push_back(make_pair(v-1, w));
        path[v-1].push_back(make_pair(u-1, w));
    }

    queue<pair<ll, ll>> q;
    q.push(make_pair(0, 0));

    while(q.size() >= 1) {
        pair<ll, ll> p = q.front(); q.pop();
        ll c_point = p.first;
        ll c_dist = p.second;

        //cout << c_point << "," << c_dist << endl;

        if(c_dist % 2 == 0) ret[c_point] = 0;
        else ret[c_point] = 1;

        for(ll i = 0; i < path[c_point].size(); i++) {
            ll n_point = path[c_point][i].first;
            ll n_dist = path[c_point][i].second;

            if(seen[n_point] == true) continue;
            q.push(make_pair(n_point, c_dist + n_dist));
            seen[n_point] = true;
        }
    }

    for(ll i = 0; i < N; i++) {
        cout << ret[i] << endl;
    }

    
    return 0;    
}




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

using namespace std;
#define BUF (10007)
#define ll long long 
#define INF (1000000000)

int n,h;

int dp[BUF];
int a[BUF];
int b[BUF];

int main(void){
	cin >> h >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i] >> b[i];
	}

	for(int i=1;i<=h;i++){
		if(dp[i]==0) dp[i] = INF;
		for(int j=1;j<=n;j++){
			int k = i - a[j];
			if(k<0) k=0;
			dp[i] = min(dp[i],dp[k]+b[j]);
		}
	}
	
	cout << dp[h] << endl; 
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int js2(int n)
{
	int s=0;
	while(n!=0)
	{
		if(n%10==2)
			s++;
		n/=10;
	}
	return s;
}
int main()
{
	int n;
	scanf("%d",&n);
	printf("%d",js2(n));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n){cin>>a[i];} 
    rep(i, n){cin>>b[i];}
    rep(i, n){cin>>c[i];}
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    rep(i,n){
        int mid = b[i];
        ll a_num = a.end() - upper_bound(a.begin(), a.end(), mid, greater<int>());
        ll c_num = c.end() - upper_bound(c.begin(), c.end(), mid);
        //cout << a_num << c_num  << endl;
        ans += a_num * c_num;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1100
#define INF ((int)1e9+9)

int main(){
	int n, a[MAX], q, com, b, e, k;
	
	cin>>n;
	
	for(int i = 0; i < n; i++) cin>>a[i];
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>b>>e>>k;
		int count = 0;
		for(int j = b; j < e; j++)if(a[j] == k) count++;
		cout<<count<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int a[110],b[110];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{	
		cin>>b[i];
	}
	a[1]=b[1];a[n]=b[n-1];
	for(int i=2;i<n;i++)
	a[i]=min(b[i-1],b[i]);
	int sum=0;
	for(int i=1;i<=n;i++)
	sum+=a[i];
	cout<<sum;
	return 0;
}

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

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

const int N = 1000001;
const int MOD = 998244353;

const int oo = 1e9;



int n , a;

int main() {
  cin >> n;
  bool win = false;
  for (int a,i = 0; i < n; ++i){
    scanf("%d",&a);
    if(a&1)win = true;
  }
  if(win){
    puts("first");
  }else{
    puts("second");
  }
  return 0;
}

Measured memory_bytes: 384
fun main() {
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }

    var answer = 0
    for (i in 0 until n) {
        val (x, y) = readLine()!!.split(" ").map { it.toLong() }


        if (Math.sqrt((x * x + y * y).toDouble()) <= d.toDouble()) {
            answer += 1
        }
    }

    println(answer)
}


Measured memory_bytes: 63360
#include <iostream>
using namespace std;
int main() {
	while (1) {
		int n[5], ans = 0, m = 0;
		for (int i = 0; i < 5; i++) {
			int a, b;
			cin >> a >> b;
			if (a == 0 && b == 0) return 0;
			n[i] = a + b;
		}
		for (int i = 0; i < 5; i++) {
			if (m < n[i]) {
				m = n[i];
				ans = i;
			}
		}
		if (ans == 0) cout << "A " << m << endl;
		if (ans == 1) cout << "B " << m << endl;
		if (ans == 2) cout << "C " << m << endl;
		if (ans == 3) cout << "D " << m << endl;
		if (ans == 4) cout << "E " << m << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
#include <string>
#include <cstdint>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <unordered_map>

using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Int int_fast64_t

int main()
{
    FAST_IO;

    Int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;

    return 0;
}


Measured memory_bytes: 3608
import sys
import itertools
import math
input = sys.stdin.readline
#sys.setrecursionlimit(1e9)
N,M = map(int,input().split())

ab = [list(map(int,input().split())) for _ in range(M)]

graph=[[0]*8 for _ in range(8)]
def dfs(v,visited):
    if sum(visited) == N:
        return 1
    ret =0
    for i in range(N):
        if graph[v][i] == 1 and visited[i] == 0:
            visited[i]=1
            ret += dfs(i,visited)
            visited[i]=0
    return ret
def main():
    """code here"""

    for i in range(M):
        a=ab[i][0]
        b=ab[i][1]
        graph[a-1][b-1]=1
        graph[b-1][a-1]=1

    visited=[0]*N
    visited[0]=1
    print(dfs(0,visited))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 43868
def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    if M <= N:
        print(0)
        return
    X.sort()
    diff = [0] * (M-1)
    for i in range(M-1):
        diff[i] = X[i+1] - X[i]
    diff.sort()
    print(sum(diff[:M-N]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 52904
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];
        long sum = 0;
        long sum_odd = 0;
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            sum += A[i];
            if(i % 2 == 1)
                sum_odd += A[i];
        }
        sc.close();

        long[] c = new long[N];
        c[0] = sum - 2*sum_odd;

        for(int i = 1; i < N; i++){
            c[i] = 2*A[i-1] - c[i-1];
        }

        for(int i = 0; i < N; i++){
            System.out.print(c[i] + " ");
        }
    }
}

Measured memory_bytes: 65348
import itertools

n, k = map(int, input().split())
d = [i for i in range(10)]
[d.remove(int(x)) for x in input().split()]
n_len = len(str(n))

ans = -1
for x in itertools.product(d, repeat=n_len):
    v = int("".join([str(i) for i in list(x)]))
    # print(v)
    if v >= n:
        if ans < 0 or ans > v:
            ans = v

if ans < 0:
    for x in itertools.product(d, repeat=n_len+1):
        v = int("".join([str(i) for i in list(x)]))
        # print(v)
        if v >= n:
            if ans < 0 or ans > v:
                ans = v

print(ans)


Measured memory_bytes: 40048
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

typedef long long ll;

struct Cups{
	std::vector<int> S[3];
	int t, prev_from, prev_to;
	Cups(const std::vector<int> (&_S)[3], int _t, int _from, int _to)
		:t(_t), prev_from(_from), prev_to(_to){
		for(int i=0;i<3;i++){
			for(int j=0;j<_S[i].size();j++){
				S[i].push_back(_S[i][j]);
			}
		}
	}
};

ll toInt(const std::vector<int> (&S)[3]){
	ll res = 0;
	for(int i=0;i<3;i++){
		for(int j=0;j<S[i].size();j++){
			int elem = S[i][j];
			res |= i << 2 * elem;
		}
	}
	return res;
}

void dou(const std::vector<int> (&S)[3]){
	for(int i=0;i<3;i++){
		for(int j=0;j<S[i].size();j++){
			std::cout << S[i][j] << " ";
		}
		std::cout << std::endl;
	}
}

int main(){
	int n, m;
	while(std::cin >> n >> m, n){
		std::vector<int> S[3];
		for(int i=0;i<3;i++){
			int SN;
			std::cin >> SN;
			for(int j=0;j<SN;j++){
				int e;
				std::cin >> e;
				S[i].push_back(e-1);
			}
			std::sort(S[i].begin(), S[i].end(), std::greater<int>());
		}

		std::queue<Cups> q;
		q.push(Cups(S, 0, -1, -1));
	
		int res = -1;
		while(!q.empty()){
			Cups c = q.front();q.pop();
			std::vector<int> S[3] = c.S;
			int t = c.t, prev_from = c.prev_from, prev_to = c.prev_to;

			if(t > m){
				continue;
			}
			if(S[0].size() == n || S[2].size() == n){
				res = t;
				break;
			}

			for(int i=0;i<3;i++){
				for(int j=0;j<3;j++){//i -> j
					if(std::abs(i-j) != 1 || (j == prev_from && i == prev_to) ||
						 S[i].empty() || (!S[j].empty() && S[i][0] < S[j][0]))continue;
					std::vector<int> _S[3] = S;
					_S[j].push_back(_S[i][0]);
					_S[i].erase(_S[i].begin());
					std::sort(_S[j].begin(), _S[j].end(), std::greater<int>());
					q.push(Cups(_S, t+1, i, j));
				}
			}
		}

		std::cout << res << std::endl;
	}
}

Measured memory_bytes: 1220
from math import pi
from math import cos
from math import sqrt
a, b, h, m = map(int, input().split())
d = abs((m/60)*(2*pi)-(h/12)*(2*pi)-(m/60)*(pi/6))
ans = sqrt(abs(pow(a, 2) + pow(b, 2) - 2*a*b*cos(d)))
print(ans)

Measured memory_bytes: 9504
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize
    }
    // タップがn個あれば，口の数は (n-1)*(a-1) + a = na - n + 1
    // これがb以上になる最小の整数を取れば良いので，
    // na - n + 1 > b
    // n > (b-1)/a
    println!("{}", ((b - 1 + (a - 2)) / (a - 1)) as usize)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int n;
	string s;
	cin >> n >> s;
	if( s.size() > n ){
		for(int i = 0; i < n; i++)
			cout << s[i];
		cout << "...\n";
	}else{
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M;
    int A[12];
    int d[10]={0,2,5,5,4,5,6,3,7,6};
    cin >> N >> M;
    REP(i,M){
        cin >> A[i];
    }
    sort(A,A+M,greater<>());
    vector<int> dp(20000,-1);
    dp[0]=0;
    REP(i,N){
        REP(j,M){
            dp[i+d[A[j]]]=max(dp[i+d[A[j]]],dp[i]+1);
        }
    }
    /*REP(i,N+1){
        cout << dp[i] << " ";
    }cout << endl;*/
    
    int k = N;
    while(k>0){
        REP(i,M){
            if(k-d[A[i]]>=0 && dp[k]-dp[k-d[A[i]]]==1){
                cout << A[i];
                k-=d[A[i]];
                break;;
            }
        }
    }
    return 0;
}



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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

int f[N];

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,x,ans=0;
        cin>>n;
        for(int i=0;i<n;i++)cin>>x,f[x]++,ans+=x;
        int q;
        cin>>q;
        while(q--)
        {
            int b,c;
            cin>>b>>c;
            ans += f[b]*(c-b);
            f[c] += f[b];
            f[b] = 0;
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4424
n, x, y = gets.split.map(&:to_i)

dcounts = {}
1.upto(n-1) do |a|
  (a + 1).upto(n) do |b|
    d1 = b - a
    d2 = (x - a).abs + (y - b).abs + 1
    if d1 < d2
      dcounts[d1] ||= 0
      dcounts[d1]+= 1
    else
      dcounts[d2] ||= 0
      dcounts[d2]+= 1
    end
  end
end

1.upto(n-1) do |i|
  puts dcounts[i] || 0
end

Measured memory_bytes: 1916
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int a[100001];
int n, m;

int compare(const void *a, const void *b) {
	int an = *(int*)(a);
	int bn = *(int*)(b);
	if (an < bn) {
		return -1;
	}
	else if (an > bn) {
		return 1;

	}
	else {
		return 0;
	}
}

int inarray(int x) {
	void* ans = NULL;
	ans = bsearch(&x, a, m, sizeof(int), compare);
	if (ans != NULL) {
		return 1;
	}
	else {
		return 0;
	}
}

int main(void) {
	/*int p, q, r;
	scanf("%d %d %d", &p, &q, &r);
	int a, b, c;
	a = p + q;
	b = q + r;
	c = r + p;
	printf("%d\n", MIN(a, MIN(b, c)));*/
	/*
	int n;
	int w[101];
	scanf("%d", &n);
	scanf("%d", &w[0]);
	int first = w[0];
	int last = 0;
	for (int i = 1; i < n; i++) {
		scanf("%d", &w[i]);
		last += w[i];
	}

	int min = abs(first - last);
	for (int i = 1; i < n-1; i++) {
		first += w[i];
		last -= w[i];
		int temp = abs(first - last);
		if (min > temp) {
			min = temp;
		}
	}
	printf("%d\n", min);*/

	scanf("%d %d", &n, &m);
	long long int dp[100001];
	for (int i = 0; i < m; i++) {
		scanf("%d", &a[i]);
		a[i]--;
	}
	if (inarray(0)) {
		dp[0] = 0;
	}
	else {
		dp[0] = 1;
	}
	if (inarray(1)) {
		dp[1] = 0;
	}
	else {
		dp[1] = 1 + dp[0];
	}
	for (int i = 2; i < n; i++) {
		if (inarray(i)) {
			dp[i] = 0;
		}
		else {
			dp[i] = (dp[i - 1] + dp[i - 2])%1000000007;
		}
	}
	printf("%lld\n", dp[n - 1]);
	return 0;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input[] = br.readLine().split("\\s+");

			String str_A = input[0],str_B = input[1];

			BigInteger A = new BigInteger(input[0]);
			BigInteger B = new BigInteger(input[1]);
			BigInteger ans;

			ans = A.add(B);
			System.out.println(ans);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}




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

int main(){
    int n; cin>>n;
    int x[n],y[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    int p[10]={0,1,2,3,4,5,6,7,8,9};

    double sum=0;
    int divide=0;

    do{
        for(int i=0;i<n-1;i++) sum+=sqrt(pow(x[p[i+1]]-x[p[i]],2)+pow(y[p[i+1]]-y[p[i]],2));
        divide++;
    }while(next_permutation(p,p+n));

    cout<<fixed<<setprecision(7)<<sum/divide<<endl;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

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

int main() {
	int A,B,C; cin >> A >> B >> C;
	cout << min(B/A,C) << endl;
	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli temp1,temp2,t,x,y,b,temp,a,q,d,p,mx,n,k;
    string s ,sn;
    
    cin>>s>>sn;
    
    lli len =s.length();
    lli count=0;
    for(int i =0;i<len;i++)
    {
    	if(s[i]!=sn[i])count++;
    }
    cout<<count<<endl;
}

	

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N, M; cin >> N >> M;
    vector<ll> a(M);
    rep(i, M) cin >> a[i];
    ll sum =0;
    rep(i, M) sum += a[i];

    if(N < sum){
        cout << -1 << endl;
    }else{
        cout << N-sum << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

using namespace std;

#define ll long long

ll n , m;

vector<ll>dv;

int main()
{
    ll t;
    cin >> n >> t;
    ll ans = 1e9;
    for(int i = 1; i<=n; i++){
        ll a , b; cin >> a >> b;
        if(b <= t){
            ans = min(ans , a);
        }
    }
    if(ans == 1e9)printf("TLE\n");
    else printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n;
  while(cin>>n&&n){
    char c;
    vector<string>str[101];
    string str1;
    for(int i=0;i<n;i++){
      while(cin>>c&&c!='.'){
	if(c==':'||c==',')str[i].push_back(str1),str1.clear();
	else str1+=c;
      }
      str[i].push_back(str1),str1.clear();
    }


    int ff=1;
    while(ff){
      ff=0;
      for(int i=1;i<str[0].size();i++){
	for(int j=1;j<n;j++)
	  if(str[0][i]==str[j][0]){
	    str[0].erase(str[0].begin()+i);
	    for(int k=1;k<str[j].size();k++){
	      int f=0;
	      for(int l=1;l<str[0].size();l++)
		if(str[0][l]==str[j][k])f=1;
	      if(!f)str[0].push_back(str[j][k]),ff=1;
	    }
	  }
      }
    }
    cout<<str[0].size()-1<<endl;
  }
  return 0;
}    
    

Measured memory_bytes: 1300
N = int(input())
anslist = [0] * (N + 1)
for x in range(1,100 + 1):
  for y in range(1,100 + 1):
    for z in range(1,100 + 1):
      temp = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if temp <= N:
        anslist[temp] += 1

anslist.pop(0)

for i in anslist:
  print(i)

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

int main(){
  ll N;cin>>N;
  vll A(N);rep(i,N)cin>>A[i];
  ll cnt = 0;
  for(int i=1;i<N;++i){
    if(A[i-1]>A[i]){
      cnt += A[i-1] - A[i];
      A[i] = A[i-1];
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 4756
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  void run() {
    for (; ; ) {
      int N, Q;
      N = ni();
      Q = ni();

      if ( (N | Q) == 0 ) {
        break;
      }

      int[] nums = new int[ 101 ];
      int max = 0;
      for ( int i = 0; i < N; ++i ) {
        int M = ni();
        for ( int j = 0; j < M; ++j ) {
          int d = ni();
          max = Math.max(max, ++nums[ d ]);
        }
      }

      if ( max < Q ) {
        System.out.println("0");
      } else {
        for ( int i = 0; i < 101; ++i ) {
          if ( nums[ i ] == max ) {
            System.out.println(i);
            break;
          }
        }
      }
    }
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 61980
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int card[3][3];

int main() {
    fastio();

    forn(i, 3) forn(j, 3) cin >> card[i][j];

    int n;
    cin >> n;
    forn(i, n) {
        int a;
        cin >> a;
        forn(i, 3) forn(j, 3) {
            if (card[i][j] == a) card[i][j] = 0;
        }
    }

    bool ans = false;
    forn(i, 3) {
        bool temp = true;
        forn(j, 3) {
            temp &= card[i][j] == 0;
        }
        ans |= temp;
    }

    forn(j, 3) {
        bool temp = true;
        forn(i, 3) {
            temp &= card[i][j] == 0;
        }
        ans |= temp;
    }

    bool temp = true;
    forn(i, 3) {
        temp &= card[i][i] == 0;
    }
    ans |= temp;

    temp = true;
    forn(i, 3) {
        temp &= card[i][2 - i] == 0;
    }
    ans |= temp;

    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl

int main(){
	
	ios::sync_with_stdio(false);
	int N;
	cin>>N;
	vector<int> arr(N);
	REP(i,N){
		cin>>arr[i];
	}

	ll ok = 1,but = 1;
	
	if(arr[0] % 2 == 0){
		ok = 1;
		but = 2;
	}
	else{
		ok = 2;
		but = 1;
	}

	ll sum = 3;
	for(int i = 1; i < N; i++){
		ll buf_o = ok;
		ll buf_b = but;
		if(arr[i] % 2 == 0){
			ok = buf_b * 1 + buf_o * 3;
		}
		else{
			ok = buf_b * 2 + buf_o * 3;
		}
		sum *= 3;
		but = sum - ok;
	}

	cout<<ok<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

const int SIZE = 5;
int main() {
	int a[SIZE];
	int b;
	string yay = "Yay!";
	for (int i = 0; i < SIZE; i++) {
		cin >> a[i];
	}
	cin >> b;
	for (int i = 0; i < SIZE; i++) {
		for (int j = i; j < SIZE; j++) {
			if (i == j) { continue; }
			int c = abs(a[i] - a[j]);
			if (c > b) {
				yay = ":(";
			}
		}
	}
	cout << yay << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    string s; cin >> s;
    int n = s.size();
    int ans = 0;
    // rep(i,n/2+1){
    //     int j=n-1-i;
    //     char l = s.at(i);
    //     char r = s.at(j);
    //     if(l!=r) ans++;
    // }
    rep(i,n){
        int j=n-1-i;
        if (s[i]!=s[j] && i<j) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        double d[]=new double[n];
        double s=1,a=0;
        for (int i = 0; i < d.length; i++) {
			d[i]=sc.nextDouble();
			s*=d[i];
		}
        for (int i = 0; i < d.length; i++) {
        	a+=s/d[i];
        }
        

        out.println(s/a);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
    	if(a==p.a) return b-p.b;
        return -p.a+a;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21332
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
  int n, k, r, s, p, f;
  char a;
  string t;
  ll sum = 0;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;
  f = 1;
  for (int i = 0; i < k; i++) {
    a = t[i];

    sum += (a == 'r' ? p : a == 's' ? r : s);
    f = 0;
    for (int j = i + k; j < n; j += k) {
      if (a != t[j]) {
        a = t[j];
        sum += (a == 'r' ? p : a == 's' ? r : s);
        f = 0;
      } else {
        if (f) {
          sum += (a == 'r' ? p : a == 's' ? r : s);
          f = 0;
        } else {
          f = 1;
        }
      }
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int N,M;
int P[100000],Y[100000]; vector<int> yd[100001];
int main () {
  scanf("%d%d",&N,&M);
  rep(i,M)scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]);
  rep(i,N)sort(yd[i+1].begin(),yd[i+1].end());
  rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}

Measured memory_bytes: 7808
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int m   = sc.nextInt();
            int f   = sc.nextInt();
            int r   = sc.nextInt();
            if ( m == -1 && f == -1 && r == -1 ) break;
            if(m == -1 || f == -1){
            	System.out.println("F");
            }
            else if(m + f >= 80){
            	System.out.println("A");
            }
            else if(m + f >= 65){
            	System.out.println("B");
            }
            else if(m + f >= 50 || r >= 50){
            	System.out.println("C");
            }
            else if(m + f >= 30){
            	System.out.println("D");
            }
            else{
            	System.out.println("F");
            }
                    }
    }
}


Measured memory_bytes: 26300
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>k>>a>>b;
    ll tmp=k;
    if(a>=b)Cout(1+k);
    else{
        if(k<a+1){
            Cout(1+k);
        }
        else{
        ans+=b;
        k=k-(a+1);
        ll zou=b-a;
        ll sousa=k/2;
        ans+=zou*sousa;
        if(k%2==1)ans++;
        Cout(max(ans,tmp+1));
        }
    }
    return 0;
}


Measured memory_bytes: 256