akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
//		int c = Integer.parseInt(sa[1]);
		Map<Integer, TreeMap<Integer, Obj>> map = new HashMap<Integer, TreeMap<Integer, Obj>>();
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.s = Integer.parseInt(sa[0]) - 1;
			o.t = Integer.parseInt(sa[1]);
			o.c = Integer.parseInt(sa[2]);
			TreeMap<Integer, Obj> map2 = map.get(o.c);
			if (map2 == null) {
				map2 = new TreeMap<Integer, Obj>();
				map.put(o.c, map2);
			}
			map2.put(o.s, o);
		}
		br.close();

		for (Integer k1 : map.keySet()) {
			TreeMap<Integer, Obj> map2 = map.get(k1);
			Integer[] k2 = map2.keySet().toArray(new Integer[0]);
			for (int i = 0; i < k2.length - 1; i++) {
				Obj o1 = map2.get(k2[i]);
				Obj o2 = map2.get(k2[i + 1]);
				if (o1.t == o2.s + 1) {
					o2.s = o1.s;
					map2.remove(k2[i]);
				}
			}
		}

		int[] cnt = new int[100001];
		for (Integer k1 : map.keySet()) {
			TreeMap<Integer, Obj> map2 = map.get(k1);
			for (Integer k2 : map2.keySet()) {
				Obj o = map2.get(k2);
				cnt[o.s]++;
				cnt[o.t]--;
			}
		}
		for (int i = 1; i < cnt.length; i++) {
			cnt[i] += cnt[i - 1];
		}

		int ans = 0;
		for (int i = 1; i < cnt.length; i++) {
			ans = Math.max(ans, cnt[i]);
		}
		System.out.println(ans);
	}

	static class Obj implements Comparable<Obj>{
		int s, t, c;

		public int compareTo(Obj o) {
			return s - o.s;
		}
	}
}


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

using namespace std;

const int N = 1e5 + 5;

typedef long long ll;

const ll mod = 1e9 + 7;

ll n, a[N];

ll check(ll x) {
    for (int i = 1; i <= n; i++) {
        x -= (x % a[i]);
    }
    return x;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll l = 1, r = 1e18;
    while (r - l > 1) {
        ll md = (l + r) >> 1;
        if (check(md) > 2) {
            r = md;
        } else {
            l = md;
        }
    }
    ll L = 0, R = 1e18;
    while (R - L > 1) {
        ll md = (L + R) >> 1;
        if (check(md) >= 2)
            R = md;
        else
            L = md;
    }
    if (check(R) != 2) {
        cout << -1;
        return 0;
    }
    cout << R << " " << l;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

void solve()
{
  ll a,b;
  cin>>a>>b;
  ll k=__gcd(a,b);
   cout<<(a*b)/k<<endl;
}

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

        solve();

    return 0;
}



Measured memory_bytes: 3552
#include <stdio.h>

int main(){

int a,b;

char op;

while(1){

scanf("%d %c %d",&a,&op,&b);

if(op == '+')

printf("%d\n",a+b);

else if(op == '-')

printf("%d\n",a-b);

else if(op == '*')

printf("%d\n",a*b);

else if(op == '/')

printf("%d\n",a/b);

else if(op == '?')

break;

}

return 0;

}

Measured memory_bytes: 600
#include "bits/stdc++.h"

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

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

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }


int main() {
	setc;

	lint n,k,x,y;cin>>n>>k>>x>>y;
	if(n<=k) co(n*x);
	else co(k*x+(n-k)*y);
	gc();
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d %d", &n, &m);
    char arr[n][m+1];
    int i,j;
    for(i=0;i<n;i++)
    {
        scanf("%s", arr[i]);
    }
    int flag;
    int k;
    for(i=0;i<n;i++)
    {
        flag=0;
        for(j=0;j<m;j++)
        {
            if(arr[i][j]=='#')
            flag=1;
        }
        if(flag==0)
        {
            for(k=0;k<m;k++)
            arr[i][k]='0';
        }
    }
    for(j=0;j<m;j++)
    {
        flag=0;
        for(i=0;i<n;i++)
        {
            if(arr[i][j]=='#')
            flag=1;
        }
        if(flag==0)
        {
            for(k=0;k<n;k++)
            arr[k][j]='0';
        }
    }
    for(i=0;i<n;i++)
    {
        flag=0;
        for(j=0;j<m;j++)
        {
            if(arr[i][j]!='0')
            {
                printf("%c",arr[i][j]);
                flag=1;
            }
        }
        if(flag==1)
        printf("\n");
    }
}

Measured memory_bytes: 128
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int r = int.Parse(input[0]);
            int D = int.Parse(input[1]);
            int x_2k = int.Parse(input[2]);
            for (int i = 1; i <= 10; i++)
            {
                x_2k = r * x_2k - D;
                Console.WriteLine(x_2k.ToString());
            }
        }
    }
}


Measured memory_bytes: 11092
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    a += b
    c += d
    ans = ["Left", "Right"]
    if a == c:
        print("Balanced")
        return
    print(ans[a < c])
    return

#B
def B():
    n, a, b = LI()
    ans = 0
    for i in range(1, n + 1):
        if a <= sum(list(map(int, list(str(i))))) <= b:
           ans += i
    print(ans) 
    
    return

#C
def C():
    x, y = LI()
    ans = 0
    while x <= y:
        ans += 1
        x *= 2
    print(ans)
    return

# D
# 解説AC
# 実はi,i+1番目を順にみて文字が異なるなら
# max(i,n-k)文字を入れ替えればいいのである
def D():
    s = S()
    ans = inf
    n = len(s)
    for i in range(n - 1):
        if s[i] != s[i + 1]:
            ans = min(ans, max(i + 1, n - i - 1))
    print(ans if ans != inf else n )
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 50032
#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

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

  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  while (k--) {
    vector<int> b(n + 1);
    for (int i = 0; i < n; ++i) {
      int l = i - a[i], r = i + a[i];
      l = max(l, 0);
      r = min(r, n - 1);

      b[l]++;
      b[r + 1]--;
    }
    bool br = true;
    for (int i = 0; i < n; ++i) {
      a[i] = b[i];
      if (i > 0) a[i] += a[i - 1];
      br &= a[i] == n;
    }

    if (br) break;
//    cout << "-------\n";
//    for (int i = 0; i < n; ++i) {
//      cout << a[i] << ' ';
//    }
//    cout << endl;
  }


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


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

ll solve() {
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    while ( Y >= X ) {
        Y >>= 1;
        ans++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

string K;

int main(){
  
  cin>>K;
  if(K == "ABC"){
    cout<<"ARC"<<endl;
  }else{
      cout<<"ABC"<<endl;
  }
  
  
}


Measured memory_bytes: 3656
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn solve() {
    let (n, a, b) = get!(i64, i64, i64);
    println!("{} {}", min(a, b), max(a+b-n, 0));
}


Measured memory_bytes: 8572
#include<iostream>
#include<vector>
#include<cstdlib>
#include <cmath>

#define INF 100000000
template<class T> inline bool chmax(T& a, T b)
{ if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b)
{ if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main(){
  int i=0,j,k,n,d,a[100];
  string s,t;
  cin >>s>>t;

  if(s[0]==t[0])i++;
  if(s[1]==t[1])i++;
  if(s[2]==t[2])i++;

  cout << i << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string s;
	int n, k;
	cin>>n>>k>>s;
	if(s[k-1]<97)
	s[k-1]+=32;
	else
	s[k-1]-=32;
	for(int i=0;i<n;i++)
	cout<<s[i];
} 

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const a = parseInt(input.split(' ')[0])
    const b = parseInt(input.split(' ')[1])
    if(a * b % 2 === 0){
        console.log('Even')
    }else{
        console.log('Odd')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
object Main extends App {

  import scala.io.StdIn._

  val Array(v, e) = readLine.trim.split(' ').map(_.toInt)
  val circles = readLine.trim.split(' ').map(_.head)
  val edges = Array.tabulate(v){_ ⇒ Nil: List[Int]}
  for (_ ← 0 until e){
    val Array(s, t) = readLine.trim.split(' ').map(_.toInt)
    edges(s) ::= t
    edges(t) ::= s
  }
  for (i ← 0 until v){
    if (circles(i) == '?'){
      circles(i) = edges(i).map(j ⇒ circles(j)).filterNot(_ == '?').let(a ⇒ ('a' to 'z').find(c ⇒ !a.contains(c))).get
    }
  }
  println(circles.mkString)
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 299764
//https://www.youtube.com/watch?v=8LusJS5-AGo
//https://www.geeksforgeeks.org/0-1-knapsack-problem-dp-10/
#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)

#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
#define MOD 10000007
const int INF = 1e18L + 5;
using namespace std;

/*bool sortBySec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/******************************************/


int32_t main()
{

  int n,m;
  cin>>n>>m;

  int cnt = 0;
  int sum = 1;
  while(sum<m)
  {
      cnt++;
      sum=sum+(n-1);
  }
 cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
int main ()
{
     long long h,sum = 1;
     cin >> h;
     while(sum <= h)
     {
         sum *= 2;
     }
     cout << sum - 1 << endl;
     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L
const int mxN = 1e9 + 7;


int main() {

    int a, p;
    cin >> a >> p;
    int total = a * 3 + p;
    cout << total / 2;

    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

struct Fraq {
	ll x, y;

	Fraq operator * (Fraq const& f) const {
		return {x * f.x, y * f.y};
	}
};

int main() {
	Fraq a, b;
	rd(a.x);
	a.y = 1;

	int xx, yy;
	scanf("%d.%d", &xx, &yy);
	b = {xx * 100 + yy, 100};

	Fraq c = a * b;	
	printf("%lld\n", c.x/c.y);
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
vector<int> oya(1e5 + 10);
vector<int> rnk(1e5 + 10);
void init(int n) {
  for (int i = 0; i < n; i++) {
    oya[i] = i;
    rnk[i] = 0;
  }
}
int find(int x) {
  if (oya[x] == x) return x;
  return oya[x] = find(oya[x]);
}
void unite(int x, int y) {
  x = find(x); y = find(y);
  if (x == y) return;
  if (rnk[x] < rnk[y]) {
    oya[x] = y;
  } else {
    oya[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}
bool same(int x, int y) {
  return find(x) == find(y);
}
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  struct town { int i; long long x, y; };
  int n; cin >> n;
  vector<town> t(n);
  for (int i = 0; i < n; i++) {
    t[i].i = i;
    cin >> t[i].x >> t[i].y;
  }
  struct edge { int from, to; long long cost; };
  vector<edge> e;
  sort(t.begin(), t.end(), [](auto a, auto b) { return a.x < b.x; });
  for (int i = 0; i < n - 1; i++) {
    e.push_back(edge{t[i].i, t[i + 1].i, min(abs(t[i + 1].x - t[i].x), abs(t[i + 1].y - t[i].y))});
  }
  sort(t.begin(), t.end(), [](auto a, auto b) { return a.y < b.y; });
  for (int i = 0; i < n - 1; i++) {
    e.push_back(edge{t[i].i, t[i + 1].i, min(abs(t[i + 1].x - t[i].x), abs(t[i + 1].y - t[i].y))});
  }
  sort(e.begin(), e.end(), [](auto a, auto b) { return a.cost < b.cost; });
  init(n);
  long long res = 0;
  for (auto i : e) {
    if (same(i.from, i.to)) continue;
    res += i.cost;
    unite(i.from, i.to);
  }
  cout << res << '\n';
  return 0;
}

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

int main(){
    
    int n;
    double ans = 0;

    std::cin >> n;

    for(int i = 0; i < n; i++){
        double x;
        std::string u;
        std::cin >> x >> u;
        
        if(u == "JPY"){
            ans += x;
        }else{
            ans += x * 380000.0;
        }
    }

    std::cout << ans << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}

int main() {
    int x; cin >> x;
    cout << x + pow(x,2) + pow(x,3);
}




Measured memory_bytes: 4112
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

ll q , w , e , z ;


int main()
{
	speed;

     ll n , m ;
     cin >> n >> m ;
     ll u = (n * m) / __gcd(n,m);
     cout << u << endl;



	time;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> P;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end(), greater<P>())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int main(void) {
  int N;
  vector<P> reds;
  vector<P> blues;
  cin >> N;
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    reds.push_back(P(x, y));
  }
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    blues.push_back(P(x, y));
  }

  sort(reds.begin(), reds.end());
  sort(blues.begin(), blues.end());

  int count = 0;
  for (P blue : blues) {
    int index = -1;
    int maxVal = -1;

    for (int i = 0; i < reds.size(); i++) {
      P red = reds[i];
      if (red.first > blue.first) break;
      if (red.second > blue.second) continue;

      if (red.second >= maxVal) {
        maxVal = red.second;
        index = i;
      }
    }

    if (index == -1) continue;

    reds.erase(reds.begin() + index);
    count++;
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a.sort()

# 整数0から配列のmax値までの入れ物を用意しでデフォルト0
# 配列内の数字は +1
# 配列内の数字の倍数値は +2（倍数値 = 元の数値で割られてしまう）
# 結果、どの配列内の数値の倍数にもなっていない 値が 1 のデータの数が答えとなる
max_a = max(a)
i_list = [0] * (max_a + 1)

for i in a:
    i_list[i] += 1
    if i_list[i] == 1:

        # 自身の値は除くため開始値は2倍したものからスタート
        for j in range(2*i, max_a + 1, i):
            i_list[j] += 2

print(i_list.count(1))


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

#define ASORT(arr, n)          sort(arr,arr+n)
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for (int i=0; i<n; i++)
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI                  acos(-1.0)

using namespace std;

typedef long long              ll;
typedef unsigned long long     ull;
typedef vector<int>            vi;

const double eps = 1e-9;


int main()
{
  fastIO();

	ll a , x;
	for(int i=0; i<5; i++)
	{
		cin>>a;
		if(a== 0 )
		{
			x = i;
			continue;
		}
			
		}
cout<<x+1<<'\n';

 return 0;
 }


Measured memory_bytes: 3528
import sys
sys.setrecursionlimit(10**7)

N = int(input())
ad = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int,input().split())
    u -= 1
    v -= 1
    ad[u].append((v, w))
    ad[v].append((u, w))

color = [-1] * N

def dfs(v=0, pv=-1, d=0):
    color[v] = d % 2
    for nv, nw in ad[v]:
        if nv == pv:
            continue
        nd = d + nw
        dfs(nv, v, nd)
        
dfs()
for c in color:
    print(c)

Measured memory_bytes: 90672
#include <iostream>
                                    #include <iomanip>
                                    #include <sstream>
                                    #include <cstring>
                                    #include <vector>
                                    #include <deque>
                                    #include <queue>
                                    #include <set>
                                    #include <map>
                                    #include <valarray>
                                    #include <iterator>
                                    #include <functional>
                                    #include <limits>
                                    #include <algorithm>
                                    #include <numeric>
                                    #include <cmath>
                                    #include <cassert>
                                    #include <unordered_map>
                                    #include <unordered_set>
                                    #include <stack>
                                    using namespace std;
                                    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
                                     #define trace(x) cerr << #x << ": " << x << " " << endl;
                                 
                                    typedef int64_t ll;
                                 
                                    #define endl '\n'
                                    #define int ll
                                    ll mod=1e9+7;
                                    ll mod1=1e9+5;
                                    
                                    ll power(ll a,ll b)
                                    {
                                        if(b==0) return 1;
                                        else if(b%2==0)
                                            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
                                        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
                                    }
                                
                                    
                                int32_t main()
                                {
                                    IOS
                                 

                                
                                string s;
                                cin>>s;
                                int n=s.length();
                                int ans=0;
                                for(int i=0;i<n/2;i++)
                                {
                                    if(s[i]!=s[n-i-1])
                                        ans++;
                                }
                                cout<<ans;

                                }                       


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>

#define BASE_NUM 1000000007UL
#define MAX 200000UL
uint64_t test(uint64_t a, uint64_t b, uint64_t h, uint64_t w);
int main(void) {
    int h,w,a,b;

    char str[32];
    char *p;
    int i,cnt = 0;
   
    
    p = fgets(str, 32, stdin);
    for(i=0;i<32;i++){
        if(str[i] == ' '){
            str[i] = '\0';
            if(cnt == 0) {
                h = atoi(p);
                p = &str[i+1];
            } else if (cnt == 1) {
                w = atoi(p);
                p = &str[i+1];
            } else {
                a = atoi(p);
                p = &str[i+1];
                b = atoi(p);
                break;
            }
            cnt++;
        }
    }

    printf("%lu\n", test(a,b,h,w));
//struct timespec start ,end;
//
//    printf("%lu\n", test(1,1,2,3));
//    printf("%lu\n", test(3,4,10,7));
//    printf("%lu\n", test(99999,99999,100000,100000));
//clock_gettime(CLOCK_REALTIME, &start);
//  printf("%lu\n", test(44444,55555,100000,100000));
//clock_gettime(CLOCK_REALTIME, &end);

// printf("%lu sec\n", end.tv_sec - start.tv_sec);

    return 0;     
}

uint64_t *fac;
uint64_t *finv;

uint64_t powerb(uint64_t a, uint64_t b) {
    uint64_t res = 1;
    while(b > 0){
        if(b & 1) res = (res * a) % BASE_NUM;
        a = (a * a) % BASE_NUM;
        b >>= 1;
    }
    return res;
}
void arrinit() {
    uint64_t i;

    fac = malloc(sizeof(uint64_t) * (MAX+1));
    finv = malloc(sizeof(uint64_t) * (MAX+1));
    
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    
    for(i=1U;i<=MAX;i++){
        fac[i] = (fac[i-1] * i) % BASE_NUM;
//        finv[i] = powerb(fac[i], BASE_NUM - 2UL) % BASE_NUM;
    }

    finv[MAX] = powerb(fac[MAX], BASE_NUM-2UL);
    for(i=MAX-1;i>1;i--){
        finv[i] = (finv[i+1] * (i+1UL)) % BASE_NUM;
    }
    
}

void arrfini() {
    free(fac);
    free(finv);
}

uint64_t ncrb(uint64_t n, uint64_t r, uint64_t base) {
    return ((((fac[n] % base) * (finv[r] % base)) % base) * (finv[n-r] % base)) % base;
}

uint64_t test(uint64_t l1, uint64_t l2, uint64_t s1, uint64_t s2) {
    uint64_t *arr;
    uint64_t i,j;
    uint64_t range;
    uint64_t h1,h2;
    uint64_t ret = 0;

    arrinit();

    range = s2 - l2;
    arr = malloc(sizeof(uint64_t) * 2 * range);

    h1 = l1;
    h2 = s1 - l1;
    for(i=0,j=(s2-1);i<range;i++,j--){
        arr[i] = ncrb(h1+i-1,i,BASE_NUM) % BASE_NUM;
        arr[range*2-i-1] = ncrb(h2+j-1,j, BASE_NUM) % BASE_NUM;
//if(i == 40000) {
//    printf("ncr %lu %lu -> %lu\n", h1+i-1,i, arr[i]);
//    printf("ncr %lu %lu -> %lu\n", h2+j-1,j, arr[range*2-i-1]);
//}
    }
    
    for(i=0;i<range;i++) {
        ret += (arr[i] * arr[range*2-i-1]) % BASE_NUM;
    }

    arrfini();
    free(arr);

    return ret % BASE_NUM;
}


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

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


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
#define MOD (1e9+7)
typedef pair < ll, ll> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}


ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
std::vector<int> Eratosthenes(const int N)//素数列挙
{
	std::vector<bool> is_prime(N + 1);
	for (int i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<int> P;
	for (int i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (int j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

double R;
int main()
{
	cin >> R;
	double ans = (double)2 * R * PI;
		printf("% .6f", ans);
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)
#define forall(it, c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

template <typename T> inline void read(T &x) {
	x = 0; bool f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	for (;  isdigit(c); c = getchar()) x = x * 10 + (c & 15);
	if (!f) x = -x;
}

const int maxn = 5e3 + 5;
int n;
bool hav[maxn * maxn];
int dis[maxn * maxn];
int que[maxn * maxn * 3], lb, rb;

void bfs() {
	while (lb < rb) {
		int u = que[lb ++];
		if (u >= n) {
			if (dis[u - n] > dis[u] + hav[u]) {
				dis[u - n] = dis[u] + hav[u];
				if (hav[u]) que[rb ++] = u - n;
				else que[-- lb] = u - n;
			}
		}
		if (u + n < n * n) {
			if (dis[u + n] > dis[u] + hav[u]) {
				dis[u + n] = dis[u] + hav[u];
				if (hav[u]) que[rb ++] = u + n;
				else que[-- lb] = u + n;
			}
		}
		if (u % n) {
			if (dis[u - 1] > dis[u] + hav[u]) {
				dis[u - 1] = dis[u] + hav[u];
				if (hav[u]) que[rb ++] = u - 1;
				else que[-- lb] = u - 1;
			}
		}
		if ((u + 1) % n) {
			if (dis[u + 1] > dis[u] + hav[u]) {
				dis[u + 1] = dis[u] + hav[u];
				if (hav[u]) que[rb ++] = u + 1;
				else que[-- lb] = u + 1;
			}
		}
	}
}

int main() {
	read(n);
	rep(i, n * n) hav[i] = 1;
	rep(i, n * n) dis[i] = 0x3f3f3f3f;
	lb = rb = maxn * maxn;
	rep(i, n - 1) que[rb ++] = i, dis[i] = 0;
	rep(i, n - 1) que[rb ++] = (i + 1) * n - 1, dis[(i + 1) * n - 1] = 0;
	rep(i, n - 1) que[rb ++] = (i + 1) * n, dis[(i + 1) * n] = 0;
	rep(i, n - 1) que[rb ++] = (n - 1) * n + i + 1, dis[(n - 1) * n + i + 1] = 0;
	bfs();
	int ans = 0;
	rep(i, n * n) {
		int u; read(u); -- u;
		ans += dis[u];
		hav[u] = 0;
		lb = rb = maxn * maxn;
		que[rb ++] = u;
		bfs();
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6388
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a=0,n,t,data[100],sum[100];
  cin>>t;
  for(int i=0;i<t;++i){
    cin>>n;
    for(int j=0;j<n;++j)
      cin>>data[j];
    for(int j=0;j<n-1;++j)
      sum[j]=data[j]-data[j+1];
    sort(sum,sum+(n-1));
    cout<<(sum[0]>0?a:abs(sum[0]))<<" "<<(sum[n-2]>0?sum[n-2]:a)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3160
#include<iostream>
using namespace std;
string t[3];

void solve(){
  for(int i=0;i<3;i++){
    if(t[i][0]==t[i][1]&&t[i][1]==t[i][2]&&t[i][0]!='+'){cout<<t[i][0]<<endl;return;}
    if(t[0][i]==t[1][i]&&t[1][i]==t[2][i]&&t[0][i]!='+'){cout<<t[0][i]<<endl;return;}
    
  }
  if(t[0][0]==t[1][1]&&t[1][1]==t[2][2]&&t[1][1]!='+'){cout<<t[0][0]<<endl;return;}
  if(t[0][2]==t[1][1]&&t[1][1]==t[2][0]&&t[1][1]!='+'){cout<<t[0][2]<<endl;return;}
  cout<<"NA"<<endl;
}


int main(){
  while(cin>>t[0]&&t[0]!="0"){
    for(int i=1;i<3;i++)cin>>t[i];
    solve();
  }
  return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000

int top, S[MAX];

void push(int x){
    S[++top] =x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top=0;
    char s[100];
    
    while(scanf("%s", s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(s[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else{
            push(atoi(s));
        }
    }
    
    printf("%d\n",pop());
    
    return 0;
}


Measured memory_bytes: 2148
#include<stdio.h>
int main(){
    int i, n, a, b, c;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d%d%d", &a, &b, &c);
        if(a*a+b*b==c*c||b*b+c*c==a*a||c*c+a*a==b*b)puts("YES");
        else puts("NO");
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=1000000007;
using P=pair<ll,ll>;
ll sum1[3005];ll sum2[3005];
ll N,M;
string s;
ll dp[3005][3005];
int main(){
  cin>>N>>M>>s;
  vector<ll>A(N);
  for(ll i=0;i<N;i++)
    A[i]=s[i]-'0';
  vector<P>C(M);
  for(int i=0;i<M;i++){
  ll l,r;cin>>l>>r;P p(l,r);
    C[i]=p;
  }vector<ll>A1(N);vector<ll>A2(N);
  for(ll i=0;i<N;i++){A1[i]=A[i];A2[i]=A[i];}
  for(ll i=0;i<M;i++){
    ll l=C[i].first;ll r=C[i].second;
  sort(A1.begin()+l-1,A1.begin()+r);
     sort(A2.begin()+l-1,A2.begin()+r);
    reverse(A2.begin()+l-1,A2.begin()+r);
    }for(ll i=1;i<=N;i++){
  sum1[i]=sum1[i-1]+A1[i-1];
    sum2[i]=sum2[i-1]+A2[i-1];
  }dp[0][0]=1;
  for(ll i=1;i<=N;i++)
    for(ll j=sum1[i];j<=sum2[i];j++){
      dp[i][j]=dp[i-1][j];
      if(0<=j-1)
        dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
    }cout<<dp[N][sum1[N]]<<endl;
  return 0;
}

Measured memory_bytes: 16176
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int n = scn.nextInt();
        int m = scn.nextInt();
        int x = scn.nextInt();
        int[] line = new int[n];
        Arrays.fill(line,0);
        for(int i=0;i<m;i++){
            int buf = scn.nextInt();
            line[buf]++;
        }
        int rCost = 0;
        int lCost = 0;
        for(int i=0;i<n;i++){
            if(line[i]==1&&i<x){
                rCost++;
            }else if(line[i]==1){
                lCost++;
            }
        }
        System.out.println(Math.min(rCost,lCost));
    }
}


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

using namespace std;

int main(void) {
  
  long long X;
  cin >> X;

  long long year = 0;
  long long now = 100;
  while (now < X) {
    now = now * 1.01;
    year++;
  }
  cout << year << endl;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int dfs(const auto& G, auto cur, auto pre, auto K) {
  int res = K<0;
  for(auto nex: G[cur]) if(nex != pre) res += dfs(G, nex, cur, K-1);
  return res;
}
int main() {
  int N, K;
  cin >> N >> K;
  Graph G(N);
  for(auto i=1; i<N; ++i) {
    int A, B;
    cin >> A >> B;
    --A; --B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  auto res = N+1;
  for(auto u=0; u<N; ++u) {
    if(K&1) for(auto v: G[u]) res = min(res, dfs(G, u, v, K/2) + dfs(G, v, u, K/2));
    else    res = min(res, dfs(G, u, u, K/2));
  }
  cout << res << endl;
}


Measured memory_bytes: 512
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
t=[]
u=c.most_common()
v=u[0][1]
t.append(u[0][0])
for i in range(1,len(c)):
  a=u[i][1]
  if v>a:
    break
  else:
    t.append(u[i][0])
t.sort()
for i in t:
  print(i)


Measured memory_bytes: 47668
N, L = map(int,input().split())
a_list = list(map(int,input().split()))

def equal_or_over_idx():
    for i in range(N-1):
        if a_list[i]+a_list[i+1] >=L:
            return i
    return -1

idx = equal_or_over_idx()
if idx == -1:
    print("Impossible")
else:
    print("Possible")
    for i in range(idx):
        print(i+1)
    for i in range(N-1,idx,-1):
        print(i)

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

const int ma = 7368792;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,m;
    while(cin>>n>>m){
        if(n==0)break;
        static bool ok[ma]={};
        for(int i=0;i<ma;i++)ok[i]=false;
        while(m){
            if(ok[n]){
                n++;
                continue;
            }
            for(int i=n;i<ma;i+=n)ok[i]=1;
            n++;
            m--;
        }
        while(n<ma && ok[n])n++;
        cout << n << "\n";
    }
}


Measured memory_bytes: 10328
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }


    vector<ll> dp(n,INF);

    rep(i,n){
        if(i==0){
            dp.at(i) = 0;
            continue;
        }
        if(i==1){
            chmin(dp.at(i), dp.at(i-1) + abs(vec.at(i) - vec.at(i-1)));
            continue;
        }

        chmin(dp.at(i), dp.at(i-1) + abs(vec.at(i) - vec.at(i-1)));
        chmin(dp.at(i), dp.at(i-2) + abs(vec.at(i) - vec.at(i-2)));
        
    }

    cout << dp.at(n-1) << endl;
    
}


Measured memory_bytes: 1792
from itertools import product

N = int(input())
f_lst = [list(map(int, input().split())) for i in range(N)]
p_lst = [list(map(int, input().split())) for i in range(N)]

ret = -10 ** 18
for p in product([0, 1], repeat=10):
    if sum(p) == 0:
        continue
    t = 0
    for i in range(N):
        cnt = 0
        for j in range(10):
            if p[j]:
                cnt += f_lst[i][j]
        t += p_lst[i][cnt]
    ret = max(ret, t)
print(ret)


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>


int main (void){
        int N;
        int x[100001],y[100001],t[100001];
        int dif_x,dif_y,dif_time,dif;
        x[0]=0,y[0]=0,t[0]=0;
        scanf("%d",&N);
        for (int i = 1; i <= N; i++) {
                scanf("%d %d %d",&t[i],&x[i],&y[i]);
        }

        for (int i = 1; i <= N; i++) {
                dif_x=x[i]-x[i-1];
                dif_y=y[i]-y[i-1];
                dif_time=t[i]-t[i-1];
                if (dif_x<0) {
                        dif_x*=-1;
                }
                if (dif_y<0) {
                        dif_y*=-1;
                }
                dif=dif_x+dif_y;
                if (dif>dif_time) {
                        printf("No");
                        return 0;
                }
                if ((dif_time-dif)%2==1) {
                        printf("No");
                        return 0;
                }
        }
        printf("Yes");
        return 0;
}

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	if (!((b-a)&1)) {
		cout << ((b-a)>>1ll);
		return 0;
	}
	cout << min(a-1, n-b) + 1 + ((b-a)>>1ll);
	return 0;
}


Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


n,k = gi
a = gi
db = array n+1,0
a.each do |aa|
  db[aa] += 1
end

db.select!{|t| t > 0 }
db.sort!

c = 0

while db.size > k
  c += db.shift
end

puts c


Measured memory_bytes: 18128
#include <stdio.h>
#define SWAP(type,a,b) { type temp = a; a = b; b = temp; }
#define H 500001

void Max_Heapify( int *A, int heap, int i){
  int l = i*2;
  int r = i*2 + 1;
  int largest;

  if(l <= heap && A[l] > A[i]){
    largest = l;
  }else{
    largest = i;
  }

  if(r <= heap && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    SWAP(int, A[i] , A[largest]);
    Max_Heapify(A, heap, largest);
  }
}

void buildMaxHeap(int *A, int heap){
  int i;
  for(i = heap/2; i > 0; i--){
    Max_Heapify(A, heap, i);
  }
}


int main(){

  int A[H], heap, i;

  A[0] = 0;

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

  buildMaxHeap(A, heap);

  for(i = 1; i <= heap; i++){
    printf(" %d", A[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();

		if ( a < 9 && b < 9) {
			System.out.println("Yay!");
		}
		else {
			System.out.println(":(");
		}

		sc1.close();
	}

}

Measured memory_bytes: 21460