akhauriyash/Code-Regression huggingface dataset:
S = input()
fore = S[0:2]
back = S[2:4]
yymm_flag = False
mmyy_flag = False
if int(fore) > 12:
  yymm_flag = True
  mmyy_flag = False
  if int(back) > 12:
    yymm_flag = False
  elif int(back) <= 12 and int(back) != 0:
    yymm_flag = True
  elif int(back) == 0:
    yymm_flag = False
    mmyy_flag = False
elif int(fore) <= 12 and int(fore) != 0:
  yymm_flag = False
  mmyy_flag = True
  if int(back) > 12:
    mmyy_flag = True
  elif int(back) <= 12 and int(back) != 0:
    yymm_flag = True
  elif int(back) == 0:
    yymm_flag = False
    mmyy_flag = True
elif int(fore) == 0:
  if int(back) > 12:
    yymm_flag = False
    mmyy_flag = False
  elif int(back) <= 12 and int(back) != 0:
    yymm_flag = True
  elif int(back) == 0:
    yymm_flag = 0
    mmyy_flag = 0
if yymm_flag == True and mmyy_flag == False:
  print("YYMM")
elif yymm_flag == False and mmyy_flag == True:
  print("MMYY")
elif yymm_flag == True and mmyy_flag == True:
  print("AMBIGUOUS")
else:
  print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;

map <ll,ll> mp;
ll INF=1e13;
int main(){
    ll n;
    cin>>n;
    ll min=INF;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll k=i+(n/i);
            if(k<min){
                min=k;
            }
        }
    }
    cout<<min-2<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static long MOD = 1000000007l;

	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] city = new int[n + 1];
		for (int i = 0; i < n; i++) {
			city[i] = sc.nextInt();
		}
		sc.close();
		city[n] = x;
		Arrays.sort(city);
		int[] sa = new int[n];
		for (int i = 0; i < n; i++) {
			sa[i] = city[i + 1] - city[i];
		}
		if (n!=1)
			System.out.println(gcd(sa));
		else
			System.out.println(city[1] - city[0]);
	}

	public static final int gcd(final int[] param) {
		final int len = param.length;
		int g = gcd(param[0], param[1]); // gcd(a, b) は以前作ったもの
		for (int i = 1; i < len - 1; i++) {
			g = gcd(g, param[i + 1]); // gcd(a, b) は以前作ったもの
		}
		return g;
	}

	public static final int gcd(int a, int b) {
		// a > b にする(swap)
		if (a < b) {
			a = a ^ b;
			b = a ^ b;
			a = a ^ b;
		}
		// ユークリッドの互除法
		int r = -1;
		while (r != 0) {
			r = a % b;
			a = b;
			b = r;
		}

		return a; // b には r=0 の値が入るため、a を返す
	}
}


Measured memory_bytes: 46660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  ll N,M; cin >> N >> M;
  priority_queue<pll> pque;
  for(ll i=0;i<N;i++){
    ll a; cin >> a;
    pque.push(make_pair(a,1));
  }
  for(ll i=0;i<M;i++){
    ll b,c; cin >> b >> c;
    pque.push(make_pair(c,b));
  }
  ll cnt = 0;
  ll ans = 0;
  while(cnt<=N){
    pll p = pque.top(); pque.pop();
    if(cnt+p.second<=N){
      cnt += p.second;
      ans += p.second*p.first;
      continue;
    }else{
      ans += p.first*(N-cnt);
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7432
import functools
import numpy as np

n, X = map(int, input().split())
x = list(map(int, input().split()))


def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a % b)


if n > 1:
    if abs(x[0]-X) == 0:
        ans = euclid(abs(x[1]-X), abs(x[2]-X))
    elif abs(x[1]-X) == 0:
        ans = euclid(abs(x[0]-X), abs(x[2]-X))
    else:
        ans = euclid(abs(x[0]-X), abs(x[1]-X))

    for xi in x[2:]:
        ans = euclid(ans, abs(xi-X))
        if ans == 1:
            break

else:
    ans = abs(x[0] - X)

print(ans)


Measured memory_bytes: 23136
S = gets.chomp
ops = ['+', '-']
ops.product(ops).product(ops).each do |(op1, op2), op3|
  expr = S.dup
  expr.insert(1, op1)
  expr.insert(3, op2)
  expr.insert(5, op3)
  #p expr: expr, result: eval(expr)
  if eval(expr) == 7
    puts "#{expr}=7"; exit
  end
end
raise


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(b < a){
            System.out.println(a - 1);
        }else{
            System.out.println(a);
        }
        
    }

}


Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>

using namespace std;

int N,row=0,col=0;

char NS[]={'N',0,'A'},EW[]={'n',0,'a'};

int main(){
    scanf("%d\n",&N);
    for(int i=0;i<N;i++){
        auto c=getchar();
        if (c>='A'&&c<='M') row++;
        else if (c>='N'&&c<='Z') row--;
        else if (c>='a'&&c<='m') col++;
        else col--;
    }

    printf("%d\n",abs(row)+abs(col));
    for(int i=0;i!=row;i+=row/abs(row)) putchar((NS+1)[row/abs(row)]);
    for(int i=0;i!=col;i+=col/abs(col)) putchar((EW+1)[col/abs(col)]);

    putchar('\n');

    return 0;
}


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

int main()
{
    int m,n,ln=0,flag=0,z=0;
    scanf("%d %d",&m,&n);
    char a[m][52],b[n][52];
    for(int i=0;i<m;i++)
        scanf("%s",a[i]);
    for(int i=0;i<n;i++)
        scanf("%s",b[i]);
    for(int x=0;x<=m-n;x++)
    {int ans=0,k=0;
       begain: while(a[x][ans]==b[z][ans])
        {
            ans++;
            if(b[z][ans]=='\0')
            {
                k=1;z++;
                flag++;
                break;
            }
        }
        if(ans<m-n)
        {
            ans++;
            goto begain;
        }
        if(k==0)
        {flag=0;z=0;}
        if(flag==n)
        {
            ln=1;
            break;
        }

    }
    if(ln==1)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
    int l, r, d, cont=0;
    scanf("%d %d %d", &l, &r, &d);
    for(int i = l; i <= r; ++i){
        if(i%d==0)
            cont++;
    }
    printf("%d\n", cont);


    return 0;
}

Measured memory_bytes: 1736
object Main extends App {
	val temp = scala.io.StdIn.readLine
	val N = temp.split(" ")(0).toInt
	val P = temp.split(" ")(1).toInt
	val a = scala.io.StdIn.readLine.split(" ").map(_.toLong % 2L)

	def con(x: Long, y: Long): Long = {
		if(x==y || y==0L) 1L
		else con(x, y-1L)*(x-y+1L)/y
	}

	def pow(x : Long): Long = {
		if(x==0L) 1L
		else 2L*pow(x-1L)
	}

	var t = 0L // 0
	var z = 0L // 1

	for(i<- a){
		if(i==0L) t = t + 1L
		else z = z + 1L
	}

	var test = pow(t)
	var sum = 0L

	if(P==0){
		var q = 0L
		while(z >= q){
			sum = sum + con(z,q)
			q = q + 2L
		}
		test = test*sum
	}else{
		var q = 1L
		while(z >= q){
			sum = sum + con(z,q)
			q = q + 2L
		}
		test = test*sum
	}


	println(test)

}

Measured memory_bytes: 25620
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n;
    cin >> n;
    int counter=0;
    map<string,int> mp;
    {
        string s;
        while (cin >> s)
        {
            mp[s]++;
            counter =  max(counter,mp[s]);
        }
        
    }
    for (auto &&e : mp)
    {
        if (e.second == counter)
        {
            cout << e.first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    int N, Y;
    cin >> N >> Y;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if (i * 10000 + j * 5000 > Y) continue;
            if ((Y - (i * 10000 + j * 5000)) % 1000 != 0) continue;
            int k = (Y - (i * 10000 + j * 5000)) / 1000;
            if (i + j + k == N) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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

bool isMonth(string s) {
  if (s == "01" ||
      s == "02" ||
      s == "03" ||
      s == "04" ||
      s == "05" ||
      s == "06" ||
      s == "07" ||
      s == "08" ||
      s == "09" ||
      s == "10" ||
      s == "11" ||
      s == "12") {
    return true;
  }

  return false;
}

int main() {
  string s;
  cin >> s;

  string s1 = s.substr(0, 2);
  string s2 = s.substr(2, s.size());

  if (isMonth(s1) && isMonth(s2)) {
    cout << "AMBIGUOUS" << endl;
    return 0;
  }

  if (isMonth(s1) && !isMonth(s2)) {
    cout << "MMYY" << endl;
    return 0;
  }
  
  if (!isMonth(s1) && isMonth(s2)) {
    cout << "YYMM" << endl;
    return 0;
  }

  cout << "NA" << endl;

  return 0;
}


Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::*;

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

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

fn main() {
  let (hight, wide) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };

  let n: usize = read();
  let a: Vec<usize> = read_vec();
  let mut grid: Vec<Vec<usize>> = vec![vec![0; wide]; hight];

  let mut h: usize = 0;
  let mut w: i64 = 0;
  let mut add: i64 = 1;
  let mut color_num = a[0];
  let mut color = 0;

  for h in 0..hight {
    if add == 1 {
      for w in 0..wide {
        if color_num == 0 {
          color += 1;
          color_num = a[color];
        }

        grid[h][w] = color+1;
        color_num -= 1;
      }
      add = -1;
    } else {
      for w in (0..wide).rev() {
        if color_num == 0 {
          color += 1;
          color_num = a[color];
        }

        grid[h][w] = color+1;
        color_num -= 1;
      }

      add = 1;
    }
  }

  for i in 0..hight {
    for j in 0..wide {
      print!("{} ", grid[i][j]);
    }
    println!("");
  }
}


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

int main(){
    int n, a[4];
    rep(i,4) a[i] = 0;
    vector<string> s(4);
    s[0] = "AC";
    s[1] = "WA";
    s[2] = "TLE";
    s[3] = "RE";
    cin >> n;
    rep(i,n){
        string t;
        cin >> t;
        rep(j,4){
            if(t == s[j]) a[j]++;
        }
    }
    rep(i,4){
        cout << s[i] << " " << "x" << " " << a[i] << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
	int X, Y, A, B, C;
	vector<int> p, q, r;
	cin >> X >> Y >> A >> B >> C;
	p.reserve(A);
	q.reserve(B);
	r.reserve(C);
	int tmp;
	rep (i, A) {
		cin >> tmp;
		p.push_back(tmp);
	}
	rep(i, B) {
		cin >> tmp;
		q.push_back(tmp);
	}
	rep(i, C) {
		cin >> tmp;
		r.push_back(tmp);
	}
	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());
	sort(r.begin(), r.end(), greater<int>());

	int a = X-1;
	int b = Y-1;
	int c = 0;

	char target;
	while (1) {
		if ((a < 0 && b < 0) || c >= C) break;
		if (b < 0 || (a >= 0 && p[a] < q[b])) {
			tmp = p[a];
			target = 'a';
		} else {
			tmp = q[b];
			target = 'b';
		}
		if (tmp < r[c]) {
			if (target == 'a') a--;
			else b--;
			c++;
		} else {
			break;
		}
	}
	ll ans = 0;
	rep(i, a+1){
		ans += p[i];
	}
	rep(i, b+1){
		ans += q[i];
	}
	rep(i, c){
		ans += r[i];
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1408
N,K=map(int,input().split())
A=list(map(int,input().split()))
dic={}
goto=A[0]
for i in range(K):
    tmp=goto
    goto=A[tmp-1]
    if not tmp in dic:
        dic[tmp]=i
    else:
        bef=dic[tmp]
        loop=i-bef
        rem=K-1-i
        rem=rem%loop
        for j in range(rem):
            tmp=goto
            goto=A[tmp-1]
        break

print(tmp)

Measured memory_bytes: 32188
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[][] x = new int[N][2];
    for (int i = 0; i < N; i++) {
      x[i][0] = scanner.nextInt();
      x[i][1] = scanner.nextInt();
    }

    double res = 0.d;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        int dx = x[i][0] - x[j][0];
        int dy = x[i][1] - x[j][1];
        res += Math.sqrt(dx * dx + dy * dy);
      }
    }
    System.out.println(res * 2 / N);
  }
}


Measured memory_bytes: 22100
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp
{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head,tail,n=0;

void enqueue(P x)
{
  Q[tail]=x;
  if(tail==LEN)
    {
      tail=0;
    }
  else
    {
      tail++;
    }
}

P dequeue()
{
  if(head==LEN+1)
    {
      head=1;
    }
  else
    {
      head++;
    }
  return Q[head-1];
  
}

int main()
{
  int elaps=0,c=0;
  int i,q=0;
  P u;
  scanf("%d %d", &n, &q);
  head=1;
  tail=n+1;
  P t[n+1];
  for ( i=1;i<=n;i++)
    {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  while(head!=tail)
    {
      u=dequeue();
      Q[head-1].t=u.t-q;
      if(Q[head-1].t<=0)
	{
	  c+=u.t;
	  Q[head-1].t=c;
	  t[elaps]=Q[head-1];
	  elaps++;
	}
      else
	{
	  c+=q;
	  enqueue(Q[head-1]);
	}
    }
  for(i=0;i<n;i++)
    {
      printf("%s %d\n",t[i].name,t[i].t);
    }
	 
  return 0;
}



Measured memory_bytes: 17088
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int[] sunukes = new int[N];

        for (int i = 0; i < K; i++) {
            int temp = scanner.nextInt();
            for (int j = 0; j < temp; j++) {
                int sunuke = scanner.nextInt();
                sunukes[sunuke - 1]++;
            }
        }

        scanner.close();

        int ans = 0;
        for (int index : sunukes) {
            if (index == 0) {
                ans++;
            }
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 46324
N = int(input())
L = []
for i in range(N):
    x,y = map(int, input().split())
    L.append([x,y])
def distance(List):
    s = 0
    for i in range(N-1):
        s += ( (List[i][0]-List[i+1][0])**2+(List[i][1]-List[i+1][1])**2 )**0.5
    return s
import itertools
import math
n = math.factorial(N)
A = list(itertools.permutations(L))
d = 0
for i in range(n):
    d += distance(A[i])
print(d/n)

Measured memory_bytes: 8096
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
using namespace std;

string s;
long long dp[100005][13] = {0};

long long solve();

int main() {
  cin >> s;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  int ssize = s.size();
  dp[0][0] = 1;
  for(int i = 0; i < ssize; ++i)
    for(int j = 0; j < 13; ++j) {
      if(s[i] != '?') {
        dp[i + 1][(j * 10 + s[i] - '0') % 13] += dp[i][j];
        dp[i + 1][(j * 10 + s[i] - '0') % 13] %= N;
      }
      else {
        for(int k = 0; k < 10; ++k) {
          dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
          dp[i + 1][(j * 10 + k) % 13] %= N;
        }
      }
    }

  return dp[ssize][5];
}

Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

void solve(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int trash;
        cin >> trash;
    }
    n -= k;
    cout << (n + k - 2) / (k - 1) + 1;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int H, W, i, j;
    char ans[102][102], a[101];

    scanf("%d %d", &H, &W);

    for(i = 0; i < W+2; i++){
        ans[0][i] = '#';
        ans[H+1][i] = '#';
    }

    for(i = 1; i <= H; i++){
        ans[i][0] = '#';
        scanf("%s", a);
        for(j = 0; j < W; j++){
            ans[i][j + 1] = a[j];
        }
        ans[i][W+1] = '#';
    }

    for(i = 0; i < H+2; i++){
        for(j = 0; j < W+2; j++){
            printf("%c", ans[i][j]);
        }
        printf("\n");
    }


    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 123456
using namespace std;
typedef long long ll;
map<ll,ll>m,ttl;
int main(void)
{
//    freopen("in.txt","r",stdin);

    ll n;
    cin>>n;
    ll a[n+5];
    ll mx=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        mx=max(mx,a[i]);
        ttl[a[i]]++;
    }

//    if(ttl[1]>0)
//    {
//        cout<<"1\n";
//        return 0;
//    }

    sort(a,a+n);
    ll cnt=0LL;
    for(ll i=0;i<n;i++)
    {
        //if(m[a[i]] || ttl[a[i]]>1) continue;
        if(m[a[i]]) continue;
        for(ll k=2;;k++)
        {
            if(k*a[i] > mx) break;
            m[k*a[i]]=1;
        }
        //cnt++;
    }
    for(ll i=0;i<n;i++)
    {
        if(!m[a[i]] && ttl[a[i]]<=1) cnt++;
    }
    cout<<cnt<<endl;

    //main();
    return 0;
}


Measured memory_bytes: 76924
n, m = map(int, input().split())
sw = [list(map(int, input().split())) for _ in range(m)]
for x in sw:
    x.pop(0)
p = list(map(int, input().split()))

ans = 0
for i in range(1<<n):
    s = str(bin(i).replace('0b', '')).zfill(n)
    for j in range(m):
        sum_sw=0
        for k in sw[j]:
            sum_sw+=int(s[k-1])
        if p[j] != sum_sw%2:
            break
    else:
        ans+=1
        
print(ans)

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

int main(){
    int n, m;
    string s;
    cin >> n >> m;

    if(n < m) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
 using namespace std;
 typedef long long ll;
 string s;
 int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

 int main()
 {
 	int k;
 	cin>>k;
 	cout<<a[k-1];
 	return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli x, y;
int main() {
  cin >> x >> y;
  lli ans = 0;
  for (; x <= y; x*=2) ++ans;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
 using namespace std;
int main()
{
	int n;
	string str;
	char c;
	cin>>str;
	n = str.length();
	for (int i = 0; i < n-1; i++) {
		c = str[i];
		if (c == str[i + 1]) {
			cout<<i + 1<<" "<<i + 2;
			return 0;
		}
		else if (c == str[i + 2]) {
			cout<<i + 1<<" "<<i + 3;
			return 0;
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
vector<int> V[100010];
vector<int> children[100010];
int parent[100010];
int root;
ll A[100010];
bool ok = true;

ll deru(int now) {
  if (!ok) return 0;
  if ((int)children[now].size() == 0) return A[now];
  ll sum = 0;
  ll maxi = 0;
  for (auto x : children[now]) {
    ll temp = deru(x);
    sum += temp;
    maxi = max(maxi, temp);
  }
  if ((int)children[now].size() == 1) {
    if (A[now] == sum) return A[now];
    ok = false;
    return 0;
  }
  ll y = sum - A[now];
  ll x = 2 * A[now] - sum;
#if DEBUG == 1
    cerr << "now = " << now << ", x = " << x << ", y = " << y << endl; 
#endif
  if (y >= 0 && x >= 0 && y <= sum - maxi && y <= sum/2) {
    return x;
  } else {
    ok = false;
    return 0;
  }
}

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (auto i = 0; i < N-1; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  if (N == 2) {
    cout << ((A[0] == A[1]) ? "YES" : "NO") << endl;
    return 0;
  }
  for (auto i = 0; i < N; ++i) {
    if ((int)V[i].size() > 1) {
      root = i;
      break;
    }
  }
  stack<int> S;
  parent[root] = -1;
  S.push(root);
  while (!S.empty()) {
    int now = S.top();
    S.pop();
    for (auto x : V[now]) {
      if (x != parent[now]) {
#if DEBUG == 1
        cerr << "parent[" << x << "] = " << now << endl;
#endif
        parent[x] = now;
        children[now].push_back(x);
        S.push(x);
      }
    }
  }
  if (deru(root) == 0 && ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 16384
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n= onem()
a = l()
su = sum(a)

b = [0 for i in range(n)]
for i in range(0,n-1,2):
	su -= 2 * a[i]
b[-1] = su//2
su //= 2

for i in range(n-2,-1,-1):
	b[i] = a[i] - su
	su = b[i]
for i in range(n):
	b[i] *= 2
print(jo(b))

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

int main(void){
    int N;
    int a[200000] {};
    int r[200000] {};
    vector<int> result;

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

    for(int i=N-1; i>=0; --i){
        int sum_multiples=0;

        for(int j=2; j*(i+1)-1<N; ++j){
            sum_multiples += r[j*(i+1)-1];
        }
        
        if(sum_multiples%2 != a[i]){
            r[i] = 1;
            result.insert(result.begin(),i+1);
        }
    }

    if(result.size()==0){
        cout << 0 << endl;
        return 0;
    }
    
    cout << result.size() << endl;
    for(auto i=result.begin(); i!=result.end(); ++i){
        cout << *i;
        if(i+1!=result.end())
            cout << " ";
        else
            cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3320
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int min=c,mid=b,max=a;

    if(b>max){
        max=b;
        if(c>max){
            max=c;
            mid=b;
            min=a;
        }
        else{
            if(c>a){
                mid=c;
                min=a;
            }
            else{
                mid=a;
                min=c;
            }
        }
    }
    if(c>max){
        max=c;
        if(b>max){
            max=b;
            mid=c;
            min=a;
        }
        else{
            if(b>a){
                mid=b;
                min=a;
            }
            else{
                mid=a;
                min=b;
            }
        }
    }

    printf("%d\n",(max-mid)+(mid-min));
    return 0;
}

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


int main(){
	int k,s;
	cin>>k>>s;

	int count=0;

	for (int i = 0; i <= k; i++){
		for (int j = 0; j <= k; j++){
			if(s-i-j>=0&&s-i-j<=k)
			count++;
		}
	}

	cout<<count<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        var n = Integer.parseInt(in.readLine());
        var cnt = new HashMap<Long, Long>();
        StringTokenizer st = new StringTokenizer(in.readLine());
        long sum = 0;
        for (int i = 0; i < n; i++) {
            var a = Long.parseLong(st.nextToken());
            cnt.put(a, cnt.getOrDefault(a, 0L) + 1);
            sum += a;
        }
        var q = Integer.parseInt(in.readLine());
        var sol = new long[q];
        for (int i = 0; i < q; i++) {
            st = new StringTokenizer(in.readLine());
            var b = Long.parseLong(st.nextToken());
            var c = Long.parseLong(st.nextToken());
            if (!cnt.containsKey(b)) {
                sol[i] = sum;
                continue;
            }
            var value = cnt.get(b);
            sum -= (value * b);
            sum += (value * c);
            cnt.remove(b);
            cnt.put(c, cnt.getOrDefault(c, 0L) + value);
            sol[i] = sum;
        }
        for (var i : sol) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 69768
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/

//=================================================
int N;
vector<int> A;
//=================================================
void input()
{
  cin >> N;
  A = vector<int>(N + 1);
  rep(i, N)
  {
    cin >> A[i + 1];
  }
}

//=================================================
void solve()
{
  map<int, int> ans;
  vector<bool> b(N+1);
  for (int i = N; i >= 1; --i)
  {
    int cnt = 0;

    for (int j = i * 2; j <= N; j = j + i)
    { // 倍数を検索
      if (b[j]) {
        cnt++;
      }
    }

    //debug(cnt);
    if (cnt%2 != A[i])
    {
      b[i] = true;
      ans[i]++;
    }
  }

  cout << ans.size() << endl;
  for (auto x : ans)
  {
    cout << x.first << " ";
  }
  cout << endl;
}

//=================================================
signed main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 10496
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;

const int MAXN = 200000 + 10;
const int INF = 1000000000;

int N;
int cnt[13];
int used[24];
int ans;

void DFS(int i)
{
	if (i == 13)
	{
		int cur = 100;
		for (int a = 0; a < 24; a ++)
		{
			if (used[a])
			{
				for (int b = 1; b <= 24; b ++)
					if (used[(a + b) % 24] || used[(a - b + 24) % 24])
					{
						cur = min(cur, b);
						break;
					}
			}
		}
		if (cur > ans) ans = cur;
		return;
	}
	if (cnt[i] == 0)
		DFS(i + 1);
	else if (cnt[i] == 2)
	{
		used[i] = used[24 - i] = 1;
		DFS(i + 1);
		used[i] = used[24 - i] = 0;
	}
	else
	{
		used[i] = 1;
		DFS(i + 1);
		used[i] = 0;
		if (i != 0)
		{
			used[24 - i] = 1;
			DFS(i + 1);
			used[24 - i] = 0;
		}
	}
}

void Work()
{
	scanf("%d", &N);
	cnt[0] = 1;
	for (int i = 0; i < N; i ++)
	{
		int d;
		scanf("%d", &d);
		cnt[d] ++;
	}
	if (cnt[0] > 1 || cnt[12] > 1)
	{
		printf("0\n");
		return;
	}
	for (int i = 1; i <= 11; i ++)
		if (cnt[i] > 2)
		{
			printf("0\n");
			return;
		}
	ans = 0;
	DFS(0);
	printf("%d\n", ans);
}

int main()
{
	Work();
	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;
typedef pair<int,int> P;

int main(void) {
    int A,B,C; cin >> A >> B >> C;
    if(A==B && A!=C) cout << "Yes" << endl;
    else if(B==C && B!=A) cout << "Yes" << endl;
    else if(A==C && B!=A) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <math.h>
typedef struct P{
  double x,y;
}Point;
void kock(int,Point,Point);
int main(){
  Point p1,p2;
  int n;
  scanf("%d",&n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;

  printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}

void kock(int n,Point p1,Point p2){
  Point s,t,u;
  if(n == 0) return;
  s.x = (2*p1.x + p2.x)/3;
  s.y = (2*p1.y + p2.y)/3;
  t.x = (p1.x + 2*p2.x)/3;
  t.y = (p1.y + 2*p2.y)/3;
  u.x = (t.x - s.x)*cos(M_PI/3) - (t.y - s.y)*sin(M_PI/3) + s.x;
  u.y = (t.x - s.x)*sin(M_PI/3) + (t.y - s.y)*cos(M_PI/3) + s.y;

  kock(n-1,p1,s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1,t,p2);
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int H,W; scanf("%d%d",&H,&W);
	char a[H][W];
	for(int i=0;i<H;i++) scanf("%s",a[i]);
	long long int dp[H][W];
	for(int i=0;i<H;i++) for(int j=0;j<W;j++) dp[i][j] = 0;
	dp[0][0] = 1;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(a[i][j]=='.'){
			if(i<H-1&&a[i+1][j]=='.') dp[i+1][j] += dp[i][j]%1000000007;
			if(j<W-1&&a[i][j+1]=='.') dp[i][j+1] += dp[i][j]%1000000007;
			dp[i+1][j] = dp[i+1][j]%1000000007;
			dp[i][j+1] = dp[i][j+1]%1000000007;
			}
		}
	}
	
	printf("%d",dp[H-1][W-1]%1000000007);
	
	//for(int i=0;i<H;i++) for(int j=0;j<W;j++) printf("%d ",dp[i][j]);
	
	
	
	return 0;
}

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


int main(){
    uint64_t H,W;
    cin>>H>>W;
    if (H==1||W==1){
        cout<<1<<endl;
    }
    else if (H%2==0||W%2==0){
        cout<<(W*H)/2<<endl;
    }
    else{
        cout<<((H*W)+1)/2<<endl;
    }
}


Measured memory_bytes: 256
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B)+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()


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

int main(){
  int N, M;
  cin >> N >> M;

  vector<vector<bool>> like(N, vector<bool>(M, false));
  for(int n = 0; n < N; n++){
    int k;
    cin >> k;
    for(int m = 0; m < k; m++){
      int a;
      cin >> a;
      like[n][a - 1] = true;
    }
  }

  int ans = 0;
  for(int m = 0; m < M; m++){
    bool ok = true;
    for(int n = 0; n < N; n++){
      if(!like[n][m]){
        ok = false;
      }
    }
    if(ok){
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    ll ans = ((W + 1) / 2) * ((H + 1) / 2);
    ans += (W / 2) * (H / 2);
    if(H == 1 || W == 1) cout << 1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1100

main(){
    int n=in();
    if(n%2){
        cout<<(n-1)*(n-1)/2<<endl;
        rep2(i,1,n-1){
            rep2(j,i+1,n){
                if(i+j==n)continue;
                cout<<i<<" "<<j<<endl;
            }
        }
    }
    else{
        cout<<(n*n-2*n)/2<<endl;
        rep2(i,1,n){
            rep2(j,i+1,n){
                if(i+j==n+1)continue;
                cout<<i<<" "<<j<<endl;
            }
        }
    }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    int A[200000];
    int A_or = 0, A_xor = 0;
    long ans = 0;
    cin >> N;
    for(int i= 0; i < N; i++){
        cin >> A[i];
    }
    int left = 0, right = 0;
    for(right= 0; right < N; right++){
        A_or = A_or | A[right];
        A_xor = A_xor ^ A[right];
        if(A_or != A_xor){
            while(A_or != A_xor){
                A_or = (A_or ^ A_xor) |((A_or & A_xor) ^ A[left]);
                A_xor = A_xor ^ A[left];
                left++;
            }
        }
        ans += right-left+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 30001


int N;
ll M;
ll table[NUM];
set<ll> SET;


void func(){

	SET.clear();

	table[0] = 0;
	ll ans = 0;

	for(int i = 1; i <= N; i++){
		scanf("%d",&table[i]);
		table[i] += table[i-1];
		table[i] %= M;

		if(i == 1){
			ans = table[i];
			SET.insert(table[i]);
			continue;
		}
		ans = max(ans,table[i]);

		auto it = SET.upper_bound(table[i]);
		if(it != SET.end()){
			ans = max(ans,(table[i]-*it+M)%M);
		}
		SET.insert(table[i]);
	}

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

}


int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = ((int)b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(), c.end()
#define sz(c) ((int)c.size())
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

signed main() {
  int N, M;
  cin >> N >> M;
  vi X(M);
  rep(i, 0, M) cin >> X[i];
  sort(all(X));
  
  vi D(M - 1);
  rep(i, 0, M - 1) {
    D[i] = X[i + 1] - X[i];
  }
  sort(all(D));
  
  int ans = 0;
  rep(i, 0, M - N) {
    ans += D[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=1e2+10;
struct point{
    int x,y;
}p[maxn];
bool cmp(point a,point b){
    return atan2(a.y,a.x)<atan2(b.y,b.x);
}
int nx[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>p[i].x>>p[i].y;
    for(int i=1;i<=n;i++)nx[i]=i+1; nx[n]=1;
    sort(p+1,p+n+1,cmp);
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll x=p[i].x,y=p[i].y;
        ans=max(ans,x*x+y*y);
        for(int j=nx[i];j!=i;j=nx[j]){
            x+=p[j].x;
            y+=p[j].y;
            ans=max(ans,x*x+y*y);
        }
    }
    cout<<setiosflags(ios::fixed)<<setprecision(10)<<sqrt(ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
/**  '' "\n" ^ **/


typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;


int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  sf(n);
  vi a(n);
  in(i,n)
   sf(a[i]);
   for(int i=n-2;i>=0;i--)
   {
       if(a[i]<=a[i+1])
        continue;
       else
       {
           a[i]--;
           if(a[i]<=a[i+1])continue;
           else
           {
               cout<<"No\n";
               return 0;
           }
       }
   }
   cout<<"Yes\n";
}


Measured memory_bytes: 640
(defun ev (x y z)
  (+ (expt x 2)
     (expt y 2)
     (expt z 2)
     (* x y)
     (* y z)
     (* z x)))

(defun p (x y z)
  (cond ((= x y z) 1)
        ((and (= y z) (/= x y)) 3)
        ((and (= x y) (/= z x)) 3)
        (t 6)))

(defun f (n)
  (let ((c (make-array (list (1+ n)) :initial-element 0)))
    (loop :named x-loop
          :for x :from 1 :to 99
          :do (loop :named y-loop
                    :for y :from x :to (- 123 x)
                    :do (loop :named z-loop
                              :for z :from y :to (- 123 (+ x y))
                              :if (> (ev x y z) n)
                              :do (cond ((= x y z)
                                         (return-from x-loop))
                                        ((= y z)
                                         (return-from y-loop))
                                        (t
                                         (return-from z-loop)))
                              :do (incf (aref c (ev x y z)) (p x y z)))))
    c))

(let* ((n (read))
       (ans (f n)))
  (loop :for x :from 1 :to n
        :do (format t "~A~%" (aref ans x))))


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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int n;
  cin >> n;
  int best = INT_MAX;
  for (int i = 1; i <= 9; ++i) {
    if (111 * i >= n) {
      best = min(best, 111 * i);
    }
  }
  cout << best << "\n";
}

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


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

int main(){

    int N;
    int A, B;
    int ans = 0;
    cin >> N;
    cin >> A >> B;
    
    for(int i = A; i <= N; i++){
        int num = i;
        int sum = 0;
        
        while(num){
            //cout << i << endl;
            sum += num % 10;
            num /= 10;
        }
        
        if(A <= sum && sum <= B){
            ans += i;
        }
    }

   cout << ans << endl;
}

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

bool solve (string s) {
  bool f = 1, ef = 0;
  int ac = 0, bc = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') ac++;
    if (s[i] == 'B') bc++;
    if (ef) {
      if (ac == 5 && bc == 5) {
        if (ac + bc != s.size()) {
          f = 0;
        }
      }
    }
    else if (ac ==4 && bc == 4) ef = 1;
    else if (ac == 5 || bc == 5) {
      if (ac + bc < s.size()) {
        f = 0;
      }
    }
  }

  return f;
}

int main() {
 int J, y;
 cin >> J >> y;
 string a = "";
 for (int i = 0; i < J; i++) {
  a += "A";
 }
 for (int i = 0; i < y; i++) {
  a += "B";
 }

 
  if (solve(a)) cout << a << endl;
 while (next_permutation(a.begin(), a.end())) {
  if (solve(a)) cout << a << endl;
 }
}

Measured memory_bytes: 1204
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	int t=0;
	int m,n;
	for(m=1;m<=10000;m++){
		if(m*b<a)
		++t;
	}
 		printf("%d",t+1);
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	vector<int> x(5);
	for(int i = 0; i < 5; ++i) {
		cin >> x[i];
	}
	
	int k;
	cin >> k;
	
	bool yes = true;
	for(int i = 0; i < 5; ++i) {
		for(int j = 0; j < 5; ++j) {
			if( x[j] - x[i] > k ) {
				yes = false;
				break;
			}
		}
	}
	
	if( yes ) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return 0;
}


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

const ll MOD = 998244353;

int main(){
  
  ll n,k;
  cin >> n >> k;
  vector<pair<int,int>> imos(k);
  rep(i,k){
    int L,R;
    cin >> L >> R;
    imos[i] = make_pair(L,R+1);
  }
  vector<ll> dp(500000,0);
  dp[0] = 0;
  dp[1] = 1;
  rep(i,n){
    if(i > 0) dp[i] += dp[i-1];
    dp[i] %= MOD;
    rep(j,k){
      int L = imos[j].first;
      int R = imos[j].second;
      dp[i+L] += dp[i];
      dp[i+L] %= MOD;
      dp[i+R] -= dp[i];
      dp[i+R] = (dp[i+R]+MOD)%MOD;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 7216
n = int(input())
a = list(map(int,input().split()))
x=[]
for i in range(n):
    x.append(int(0))
s = sum(a)
x[0] = s -2*(sum(a[1:n:2]))
for i in range(0,n-1):
    x[i+1] = 2*a[i]-x[i]
print(*x)

Measured memory_bytes: 14028
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <climits>
#include <complex>

using namespace std;

#define MP make_pair

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

typedef long long LL;
typedef pair<int,int> PII;

int norm(int x, int y) {
  return x * x + y * y;
}

struct R {
  int h, w;
  R(int h, int w) :h(h), w(w) {}
  bool operator==(const R& other) {
    return h == other.h && w == other.w;
  }
};

bool operator<(const R& x, const R& y) {
  return (norm(x.h, x.w) == norm(y.h, y.w)) ? x.h < y.h : norm(x.h, x.w) < norm(y.h, y.w);
}


int main() {
  vector<R> arr;
  for (int x = 1; x <= 200; x++) {
    for (int y = x + 1; y <= 200; y++) {
      arr.push_back(R(x, y));
    }
  }
  sort(arr.begin(), arr.end());
  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) {return 0;}
    vector<R>::iterator i = find(arr.begin(), arr.end(), R(h, w));
    i++;
    cout << i->h << " " << i->w << endl;
  }
}

Measured memory_bytes: 1328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long hight = scanner.nextInt();
        long width = scanner.nextInt();
//        int[][] array = new int[hight][width];
//        for (int i = 0; i < hight; i++){
//            for (int j = 0; j < width; j++){
//                array[i][j] = 0;
//            }
//        }
        long result;

        if (hight == 1 || width == 1){
            result = 1;
        }else {
            long sum = hight * width;
            if (sum % 2 == 0) {
                result = sum / 2;
            } else {
                result = sum / 2 + 1;
            }
        }


        System.out.println(result);
    }
}


Measured memory_bytes: 23124