akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef long long ll;

struct UnionFind{
  vector<int> par;
  UnionFind(int n):par(n){
    rep(i,n) par[i]=i;
  }
  
  int root(int x){
    if(par[x]==x) return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx==ry) return;
    par[rx] = ry;
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> p(n),q(n);
  rep(i,n){cin>>p[i]; p[i]--; q[p[i]]=i;}
  
  UnionFind tree(n);
  
  rep(i,m){
    int x,y;
    cin>>x>>y;
    x--; y--;
    tree.unite(x,y);
  }
  
  int ans = 0;
  rep(i,n){
    if(tree.same(q[i],i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
N,K=map(int,input().split())
A=list(map(int,input().split()))
imos=[0 for i in range(N+1)]
zero=[0 for i in range(N+1)]
ANS=[str(N)]*N
if K>=40:
  ans=" ".join(ANS)
  print(ans)
else:
  for t in range(K):
    for i in range(N):
      l=max(0,i-A[i])
      r=min(N,i+A[i]+1)
      imos[l]+=1
      imos[r]-=1
    for i in range(0,N):
      imos[i+1]+=imos[i]
      A[i]=imos[i]
    imos=[0 for i in range(N+1)]
  for i in range(N):
    A[i]=str(A[i])
  ans=" ".join(A)
  print(ans)  

Measured memory_bytes: 168644
package main

import (
	"fmt"
)

func main() {
	var n, d, x int
	fmt.Scan(&n, &d, &x)
	iday := 1
	chocotabetai := 0
	ichoco := 1
	for i := 0; i < n; i++ {
		ichoco = 1
		var a int
		fmt.Scan(&a)
		for j := 0; j < d; j++ {
			iday += a
			if iday > d {
				chocotabetai += ichoco
				iday = 1
				break
			}
			ichoco++
		}
	}
	fmt.Println(chocotabetai + x)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a) > abs(x-b))
    cout << "B" << endl;
  else cout << "A" << endl;
}

Measured memory_bytes: 3680
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

string N;
LL dp[20][1 << 4][2];

int change(int state, int d) {
	int nxt = 0;
	for (int b = 0; b < 5; ++b) {
		if (state & (1 << b)) {
			/*if (b == 0 && d == 5) {
				nxt |= (1 << 1);
			}
			if (b == 1 && d == 1) {
				nxt |= (1 << 2);
			}
			if (b == 2) {
				nxt |= (1 << 3);
			}
			if (b == 3 && d == 3) {
				nxt |= (1 << 4);
			}
			if (b == 4) {
				nxt |= (1 << 4);
			}*/
		}
	}
	if (d == 5) {
		nxt |= (1 << 0);
	}
	else if (d == 1) {
		if (state & (1 << 0)) {
			nxt |= (1 << 1);
		}
	}
	else if (d == 3) {
		if (state & (1 << 2)) {
			nxt |= (1 << 3);
		}
	}
	else {}
	if (state & (1 << 1)) {
		nxt |= (1 << 2);
	}
	return nxt;
}

int main(void)
{
	cin >> N;
	LL num = stoll(N);
	dp[0][0][0] = 1;
	for (int i = 0; i < N.size(); ++i) {
		for (int j = 0; j < (1 << 3); ++j) {
			//dp[i][j][0]
			//set<int>ok, nx, tk;
			map<int, LL>nextmap;
			for (int d = 0; d < N[i] - '0'; ++d) {
				nextmap[change(j, d)]++;
			}
			//dp[i + 1][0][1] += dp[i][j][0] * (LL)ok.size();
			//dp[i + 1][1][1] += dp[i][j][0] * (LL)tk.size();
			//dp[i + 1][j + 1][1] += dp[i][j][0] * (LL)nx.size();
			for (auto&p : nextmap) {
				dp[i + 1][p.first][1] += dp[i][j][0] * p.second;
			}
			nextmap.clear();
			for (int d = N[i] - '0'; d == N[i] - '0'; ++d) {
				nextmap[change(j, d)]++;
			}
			//dp[i + 1][0][0] += dp[i][j][0] * (LL)ok.size();
			//dp[i + 1][1][0] += dp[i][j][0] * (LL)tk.size();
			//dp[i + 1][j + 1][0] += dp[i][j][0] * (LL)nx.size();
			//dp[i][j][1]
			//set<int>ok, nx;
			for (auto&p : nextmap) {
				dp[i + 1][p.first][0] += dp[i][j][0] * p.second;
			}
			nextmap.clear();
			for (int d = 0; d < 10; ++d) {
				nextmap[change(j, d)]++;
			}
			//dp[i + 1][0][1] += dp[i][j][1] * (LL)ok.size();
			//dp[i + 1][1][1] += dp[i][j][1] * (LL)tk.size();
			//dp[i + 1][j + 1][1] += dp[i][j][1] * (LL)nx.size();
			for (auto&p : nextmap) {
				dp[i + 1][p.first][1] += dp[i][j][1] * p.second;
			}
		}
	}
	LL sum = 0;
	for (int j = 0; j < (1 << 3); ++j) {
		sum += dp[N.size()][j][0] + dp[N.size()][j][1];
	}
	cout << num - sum + 1 << endl;
	return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int INF = 1000000000; // 10^9

int main() {
    int A, B, C; cin >> A >> B >> C;
    if (A == B && B == C && A % 2 == 0) cout << "-1" << endl;
    else {
        int cnt = 0, p, q, r;
        while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
            p = A; q = B; r = C;
            A = (q+r) / 2;
            B = (p+r) / 2;
            C = (p+q) / 2;
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    String a = scan.next();
    String b = scan.next();
    for (int i=0;i<n;i++){
      System.out.print(a.charAt(i));
      System.out.print(b.charAt(i));
    }
    System.out.println();
  }
}


Measured memory_bytes: 35620
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] list=new int[100];
        int max=0;
        while(sc.hasNext()) {
            int n=sc.nextInt()-1;
            list[n]++;
            max=Math.max(max, list[n]);
        }
        for(int i=0;i<100;i++) {
            if(max==list[i]) {
                System.out.println(i+1);
            }
        }
    }
}


Measured memory_bytes: 26172
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VL vector<LL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int k;
    string s;
    cin>>k>>s;
    int l = s.length();
    string ans;
    if(l <= k) ans = s;
    else
    {
        ans = "";
        loop(i,0,k) ans += s[i];
        ans += "...";
    }

    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

bool compare(pair<int, int> a, pair<int, int> b)
{
  return a.second < b.second;
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> ab;
  ab.resize(M);
  for (int i = 0; i < M; ++i)
  {
    int a, b;
    cin >> a >> b;
    ab[i] = pair<int, int>(a, b);
  }
  sort(ab.begin(), ab.end(), compare);
  int last = 0;
  int ans = 0;
  for (int i = 0; i < M; ++i)
  {
    if (ab[i].first >= last)
    {
      last = ab[i].second;
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import math
X = int(input())
low_N = (-1 + (1 + 8 * X)**0.5) / 2
high_N = (1 + (1 + 8 * X)**0.5) / 2
if low_N % 1 == 0:
    print(int(low_N))
else:
    print(math.floor(high_N))

Measured memory_bytes: 3060
#include<stdio.h>
 
int main(){
  int h,w,i,j;
 
  while(1){
    scanf("%d%d",&h,&w);
 
    if(!h&&!w)
      return 0;
 
    for(i=0;i<h;i++){
      for(j=0;j<w;j++)
    printf("#");
      printf("\n");
    }      
    printf("\n");
  }
}

Measured memory_bytes: 572
//バブルソートにもいろいろなやり方があるが、その中でもっともバブルな感じにする。
#include<iostream>
#include<algorithm>
using namespace std;

int n,A[100];

int Bubblesort(int *p,int size){
	int count = 0;
	for(int i = 0;i < size-1;i++){
		for(int j = size-1;j >= i+1;j--){
			if(A[j] < A[j-1]){
				swap(A[j],A[j-1]);
				count++;
			}
		}
	}
	return count;
}
int main(){
	int count;
	cin >> n;
	for(int i = 0;i < n;i++)
		cin >> A[i];
	count = Bubblesort(A,n);
	for(int i = 0;i < n-1;i++)
		cout << A[i] << " ";
	cout << A[n-1] << endl;
	cout << count << endl;
	return 0;
}
	

Measured memory_bytes: 1164
import java.util.*;
import java.util.regex.*;
 
class Main{
    public static void main(String []args){
        Scanner s=new Scanner(System.in);
         
        Pattern p=Pattern.compile("[ .,]");
        boolean first=true;
        while(s.hasNext()){
            String a=s.next();
            String[] b=p.split(a);
            for(int i=0;i<b.length;i++)if(b[i].length()>2&&b[i].length()<7){
                if(!first)System.out.print(" ");
                else first=false;
                System.out.print(b[i]);
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 25980
#include <stdio.h>

int main() {
    int temp, a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a > b) {
        temp = a;
        a = b;
        b = temp;
    }
    if(a > c) {
        temp = a;
        a = c;
        c = temp;
    }
    if(b > c) {
        temp = b;
        b = c;
        c = temp;
    }
    printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <set>
#include <algorithm>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline T cabs(const T &x){return x>=0?x:-x;}
const int N=100010;
struct Pt{
	lint x,y;
	int id;
	inline Pt to1(){
		return (Pt){y-x,x+y,id};
	}
	inline Pt to2(){
		return (Pt){x+y,y-x,id};
	}
	inline friend Pt operator + (const Pt &a,const Pt &b){
		return (Pt){a.x+b.x,a.y+b.y};
	}
	inline friend bool operator < (const Pt &a,const Pt &b){
		return a.x!=b.x?a.x<b.x:a.y<b.y;
	}
}pt[N],pt1[N],pt2[N];
int n;
set<Pt>s1,s2;
lint ans=0;
int que[N],qh=0,qt=0;
inline void psh(int v){
	s1.erase(pt[v].to1());
	s2.erase(pt[v].to2());
	que[qt++]=v;
}
inline void work(Pt pt[],set<Pt>&s,Pt l,Pt r){
	ans+=upper_bound(pt+1,pt+n+1,r)-lower_bound(pt+1,pt+n+1,l);
	set<Pt>::iterator it1=s.lower_bound(l);
	set<Pt>::iterator it2=s.upper_bound(r);
	for(;it1!=it2;psh((*(it1++)).id));
}
int main(){
	n=ni;
	int a=ni,b=ni;
	for(int i=1;i<=n;i++){
		pt[i]=(Pt){ni,ni,i};
		s1.insert(pt1[i]=pt[i].to1());
		s2.insert(pt2[i]=pt[i].to2());
	}
	sort(pt1+1,pt1+n+1);
	sort(pt2+1,pt2+n+1);
	lint d=cabs(pt[a].x-pt[b].x)+cabs(pt[a].y-pt[b].y);
	if(d==0){
		puts("1");
		return 0;
	}
	psh(a);
	for(;qh<qt;qh++){
		Pt cur=pt[que[qh]];
		Pt pt1=(Pt){cur.x+d,cur.y};
		Pt pt2=(Pt){cur.x,cur.y+d};
		Pt pt3=(Pt){cur.x-d,cur.y};
		Pt pt4=(Pt){cur.x,cur.y-d};
		work(::pt2,s2,pt1.to2(),pt2.to2()+(Pt){0,-1});
		work(::pt1,s1,pt3.to1()+(Pt){0,1},pt2.to1());
		work(::pt2,s2,pt4.to2()+(Pt){0,1},pt3.to2());
		work(::pt1,s1,pt4.to1(),pt1.to1()+(Pt){0,-1});
	}
	printf("%lld\n",ans>>1);
	return 0;
}

Measured memory_bytes: 20224
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
P = LIST()
C = LIST()

check = [0]*N 
score = []

i = 0
while 1:
	while i < N and check[i]:
		i += 1
	if i == N:
		break

	tmp = []
	while check[i] == 0:
		check[i] = 1
		i = P[i]-1
		tmp.append(C[i])
	score.append(tmp)

ans = -INF
for x in score:
	x_acc = list(accumulate([0] + x*3))
	n = len(x)

	if x_acc[n] <= 0:
		tmp_ans = 0
		l = min(K, n)
	else:
		tmp_ans = x_acc[n]*(max(0, K//n-1))
		l = min(K%n+n, K)
	tmp_max = -INF

	for i, j in combinations(range(3*n+1), 2):
		if j-i <= l:
			if tmp_max < x_acc[j]-x_acc[i]:
				tmp_max = x_acc[j]-x_acc[i]
	tmp_ans += tmp_max
	ans = max(ans, tmp_ans)

print(ans)


Measured memory_bytes: 79980
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <complex>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cctype>
using namespace std;
 
#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

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

typedef complex<ll> P;

int x, y, r;
P tri[3];
pair<P,ll> circle;

ll cross(P e1, P e2) {
	return e1.real() * e2.imag() - e1.imag() * e2.real();
}

bool inc() {
	P e0 = tri[0] - circle.first;
	P e1 = tri[1] - circle.first;
	P e2 = tri[2] - circle.first;
	ll d0 = cross(e0, e1);
	ll d1 = cross(e1, e2);
	ll d2 = cross(e2, e0);
	if(d0 * d1 > 0 && d1 * d2 > 0 && d2 * d0 > 0) return true;
	return false;
}

ll norm2(P p) {
	return p.real() * p.real() + p.imag() * p.imag();
}

bool proj(P p1, P p2, P p) {
	P e12 = p2 - p1;
	P e1 = p - p1;
	P e2 = p2 - p;
	int d1 = e1.real() * e12.real() + e1.imag() * e12.imag();
	int d2 = e2.real() * e12.real() + e2.imag() * e12.imag();
	if(d1 >= 0 && d2 >= 0) return true;
	return false;
}

void dist2(P p1, P p2, P p, ll& nm, ll& de) {
	if(!proj(p1, p2, p)) {
		nm = min(norm2(p1 - p) , norm2(p2 - p));
		de = 1;
		return;
	}

	ll a = p2.imag() - p1.imag();
	ll b = -(p2.real() - p1.real());
	ll c = - a * p1.real() - b * p1.imag();
	nm = a * p.real() + b * p.imag() + c;
	nm = nm * nm;
	de = a * a + b * b;
	if(de == 0) {
		nm = norm2(p1 - p);
		de = 1;
	}
}


void solve() {
	ll r2 = circle.second * circle.second;
	vector<pll> d(6);
	d[3].first = norm2(tri[0] - circle.first); d[3].second = 1LL;
	d[4].first = norm2(tri[1] - circle.first); d[4].second = 1LL;
	d[5].first = norm2(tri[2] - circle.first); d[5].second = 1LL;
	if(d[3].first <= r2 && d[4].first <= r2 && d[5].first <= r2) {
		cout << "b" << endl;
		return;
	}

	bool iscin = inc();
	dist2(tri[0], tri[1], circle.first, d[0].first, d[0].second);
	dist2(tri[1], tri[2], circle.first, d[1].first, d[1].second);
	dist2(tri[2], tri[0], circle.first, d[2].first, d[2].second);
	if(iscin && (d[0].first >= r2 * d[0].second) &&
		        (d[1].first >= r2 * d[1].second) &&
		        (d[2].first >= r2 * d[2].second)) {
		cout << "a" << endl;
		return;
	}

	bool inter = false;
	rep(i,6) {
		if(d[i].first <= r2 * d[i].second) {
			inter = true;
			break;
		}
	}

	if(inter) {
		cout << "c" << endl;
		return;
	}

	cout << "d" << endl;
}

int main() {
	while( 1 ) {
		scanf("%d%d", &x, &y);
		if(x == 0 && y == 0) break;
		tri[0] = P(x, y);

		scanf("%d%d", &x, &y);
		tri[1] = P(x, y);
		
		scanf("%d%d", &x, &y);
		tri[2] = P(x, y);
		
		scanf("%d%d", &x, &y);
		scanf("%d", &r);
		circle.first = P(x, y);
		circle.second = r;

		solve();
	}
}

Measured memory_bytes: 1204
package main
 
import (
  "fmt"
)
 
func main() {
  var ant [5]int
  var k int
  for i := 0; i < 5; i++ {
	fmt.Scanf("%d", &ant[i])
  }
  fmt.Scanf("%d", &k)
  
  ans := "Yay!"
  for i := 0; i < 5; i++ {
    for j := i; j < 5; j++ {
      if ant[j] - ant[i] > k {
        ans = ":("
      }
    }
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1836
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}


int main() {
	int n, k;
	cin >> n >> k;
	int *h = new int[n];
	int *sum = new int[n+1];
	sum[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		sum[i + 1] = sum[i] + h[i];
	}
	sort(h, h + n);
	int min = INT_MAX;
	for (int i = 0; i <= n-k; i++) {
		int temp = h[i + k-1] - h[i];
		if (min > temp)min = temp;
	}
	cout << min;
	

	
	return 0;
}

Measured memory_bytes: 1024
import math
K   = int(input())
Sum = 0
for A in range(1,K+1):
    for B in range(1,K+1):
        AB = math.gcd(A,B)
        if AB==1:
            Sum = Sum+K
        else:
            for C in range(1,K+1):
                Sum = Sum+math.gcd(AB,C)
print(Sum)

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

int main(){
    ll N;
    cin >> N;
    ll p[N];
    for(ll i=0;i<N;i++){
        cin >> p[i];
    }
    ll count=0;
    for(ll i=0;i<N;i++){
        if(i!=(p[i]-1)){
            count++;
        }
    }
    if((count==2) || (count==0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def Cal(val)
  Math.log10(val).to_i+1
end
n=gets.to_i
min=9*10**9
for i in 1..(n**0.5)
  if (n%i).zero?
    val1=Cal(i)
    val2=Cal(n/i)
    val=(val1>val2) ? val1 : val2
    if val<min
      min=val
    end
  end
end
puts min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << abs(n - m) << endl;
}


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

int main() {
	string x;
	int a;

	while (1) {
		cin >> x;
		if (x == "0")
			break;

		a = 0;
		for (int i = 0;i < x.length();i++) {
			a += x[i] - '0';
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1188
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int[] input = new int[100000];

            int i;
            for ( i = 1; i < input.Length; i++)
            {
                input[i] = int.Parse(Console.ReadLine());
                if (input[i] == 0) break;
            }
            for (int t = 1; t < i; t++)
            {
                Console.WriteLine("Case "+t+": "+input[t]);
            }
        }
    }
}

Measured memory_bytes: 9916
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
map<string,int> mp;
vector<pair<int,string>> vc;

int main(){
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++) {
        string s;
        cin>>s;
        mp[s]++;
    }
    
    auto it = mp.begin();

    int mx=0;
    while(it != mp.end())
    {  mx=max(mx,it->second);
       vc.push_back({it->second,it->first});
       it ++;
    }
    
    sort(vc.begin(),vc.end());
    for(auto t:vc){
        if(t.first==mx) cout<<t.second<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 29552
#include <iostream>
#include <cmath>

using namespace std;

void nabeatsu(int n);

int main()
{
    int n;
    cin >> n;
    nabeatsu(n);
}

void nabeatsu(int n)
{
    for( int i = 1; i <= n ; ++i ){
        int x = i;

        if ( !(x % 3) ){
            cout << " " << i;
        }
        else
        {
            do{
                if ( x % 10 == 3 ){
                    cout << " " << i;
                    break;
                }
            } while( x /= 10 );
        }
    }

    cout << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,k;
   cin >> a >> b >> k;
   int rr = k,j=a;
   set <int> st;
   while(rr-- && j<=b)
   {
       st.insert(j);
       j++;
   }
    j = b;
    while(k-- && j>=a)
    st.insert(j--);

    for(auto itr = st.begin(); itr!=st.end(); ++itr)
    {
        cout << *itr << endl;
    }

}


Measured memory_bytes: 3516
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    int a_left = 0;
    int a_right = 0;

    for (int i = 0; i < m; i++) {
        int ai;
        cin >> ai;
        if (ai < x) {
            a_left++;
        } else {
            a_right++;
        }
    }

    cout << min(a_left, a_right) << endl;

    return 0;
}


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

using namespace std;

#define endl '\n'

typedef long long ll;
typedef long double lb;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y, int x, int H, int W)
{ 
  return (y >= 0 && x >= 0 && y < H && x < W);
}

inline int in() {int x; std::cin >> x; return x;}

const ll mod = 1e9 + 7;
const ll inf = 1e9 + 9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

bool p[50001] = {false};

void prime()
{
  p[0] = p[1] = true;
  for (int i = 2; i * i < 50000; i++){
    if (!p[i]){
      for (int j = 2 * i; j <= 50000; j += i){
        p[j] = true;
      }
    }
  }
}

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

  prime();

  int n;
  int cnt;

  while (cin >> n, n){
    cnt = 0;
    if (n % 2 == 1){
      if (!p[n - 2]) cnt = 1;
      else cnt = 0;
    }

    else {
      for (int i = 0; i <= n / 2; i++){
        if (!p[i] && !p[n - i]) cnt++;
      }
    }

    cout << cnt << endl;
  }
  return (0);
}

Measured memory_bytes: 1252
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

void primeFact(int n, map<int, int>& mp){
	int k = n;
	for(int i = 2; i * i <= n; i++){
		while(k > 1 && k % i == 0){
			k /= i;
			mp[i]++;
		}
	}
	if(k > 1) mp[k]++;
}

int main(){
	int n;
	cin>>n;
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	map<int, int> mp;
	for(int i = 2; i <= n; i++){
		primeFact(i, mp);
	}
	ll ans = 1LL;
	for(auto& p : mp){
		(ans *= (ll)(p.se+1))%=MOD;
		//cout<<" "<<p.fi<<" "<<p.se<<" "<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

using namespace std;
#define scii(x, y)     int x, y;    scanf("%d%d", &x, &y);
const int MAX_N = 51;
const int INF = 1000000001;
int main() {
  scii(N,M);
  int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];
  int m[MAX_N];
  for (int i=0; i<N; i++) {
    scanf("%d%d", &a[i], &b[i]);
    m[i]=INF;
  }
  int ans[MAX_N];
  for (int j = 0; j < M; j++) {
    scanf("%d%d", &c[j], &d[j]);
    for (int i=0; i<N; i++) {
      int dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if (dist < m[i]){
        m[i] = dist;
        ans[i]=j+1;
      }
    }
  }
  for (int i = 0; i < N; ++i) {
    printf("%d\n", ans[i]);
  }
}

Measured memory_bytes: 888
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var inputs = input.trim();
  	var items = input.split(" ").map((item) => {return parseInt(item); });
  	items.sort();
  var target = [5, 5, 7];
  var flag = true;
  for (var i = 0; i < 3; ++i) {
    if (items[i] != target[i]) {
      flag = false;
      break;
    }  
  }
	console.log(flag ? "YES" : "NO");
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>
 
int main()
{
  int n, i, x;
  scanf("%d", &n);
  if(n<3) return 0;
  
  for(i=3; i<=n; i++){
    x=i;
    if(x%3 == 0) printf(" %d", i);
    else{
      while(x){
        if(x%10 == 3){
          printf(" %d", i);
          break;
        }
        x /= 10;
      }
    }
  }
  puts("");
  return(0);
  
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;
vector <ll> H;

void solve(long long N, long long K, std::vector<long long> h){
  if(N<=K) K = N-1;
  dp = vector<ll> (N+1, 0);
  for (ll i = 1; i <= K; i++)
  {
    dp[i] = abs(h[i]-h[0]);
  }

  for (ll i = K; i < N; i++)
  {
    vector<ll> d;
    for (ll j = 1; j <= K; j++)
    {
      d.push_back(dp[i-j] + abs(h[i] - h[i-j]));
    }
    dp[i] = *min_element(d.begin(), d.end());
  }
  cout << dp[N-1] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll> 
#define mll map<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ing(m,ad) rep(i,m){ int u,v; cin>>u>>v; u--;v--; ad[u].pb(v); ad[v].pb(u);}
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100005;
int spf[MAXN];
ll fac1[MAXN],fac2[MAXN],inv[MAXN];
ll gcd(ll x, ll y){ return y?gcd(y,x%y):x; }

void sieve(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

void pre(){
    fac1[0]=fac2[0]=inv[1]=1;
    for(int i=1;i<MAXN;i++){
        fac1[i]=(fac1[i-1]*i)%mod;
        if(i>1) inv[i]=( mod - ((ll)(mod/i)*inv[mod%i])%mod ) %mod;
    }
    for(int i=1;i<MAXN;i++) fac2[i]=(fac2[i-1]*inv[i])%mod;
}
ll C(int n,int k){
    if(n<k) return 0;
    return ((fac1[n]*fac2[n-k]%mod)*fac2[k]%mod);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,m,t=1;
    // cin>>t;
    while(t--){
        cin>>n; m=0;
        string s;
        cin>>s;
        rep(i,n) if(s[i]=='W') m++;
        int val=m;
        for(int i=n-1;i>n-1-val;i--) if(s[i]=='W') m--;
        cout<<m<<nl;
    }
    return 0;
}

Measured memory_bytes: 3380
N = int(input())
*W, = map(int, input().split())
C = {w: i for i, w in enumerate(W)}
W.sort()

ans = 0
S = []
used = [0]*N
for i in range(N):
    if used[i]:
        continue
    sq = []
    w = W[i]
    p = i; j = None
    while j != i:
        j = C[w]; w = W[j]
        used[j] = 1
        sq.append(w)
        p = j
    mi = min(sq); ln = len(sq)
    if ln >= 2:
        ans += sum(sq)
    S.append((mi, ln))
S.sort()
m, ln = S[0]
if ln >= 2:
    ans += (ln-2)*m
for mi, ln in S[1:]:
    if ln <= 2:
        continue
    ans += min(m+mi+ln*m, (ln-2)*mi)
print(ans)



Measured memory_bytes: 5724
#include <stdio.h>

int gcd1(int,int);
int gcd2(int,int);

int main(){
  int x,y,num;

  scanf("%d%d", &x, &y);
  if(x > 20 || y > 20){
    num = gcd2(x,y);
  }else{
    num = gcd1(x,y);
  }
  printf("%d\n", num);

  return 0;
}

int gcd1(int x,int y){
  int n,d;
  if(x > y){
    n = y;
  }else{
    n = x;
  }
  for(d = n; d >= 1; d--){
    if(x%d == 0 && y%d == 0){
      return d;
    }
  }
}

int gcd2(int x,int y){
  int r;
  if(x < y){
    r = x;
    x = y;
    y = r;
  }
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{ll s,t,d;};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;

vi getDist(Graph graph, ll V, ll r) {
  vi dist(V); REP(i,V) dist[i]=INF;
  priority_queue<pii,vpii,greater<pii>> pq;
  dist[r]=0; pq.push({0ll,r});
  while(pq.size()){
    ll s=pq.top().second;
    for(Edge e:graph[s]) if(dist[e.t] > dist[e.s]+e.d) {
      dist[e.t]=dist[e.s]+e.d;
      pq.push({dist[e.t],e.t});
    }
    pq.pop();
  }
  return dist;
}

int main() {
  ll N; cin>>N;
  Graph G(N);
  REP(i,N-1) {
    ll a,b,c; cin>>a>>b>>c;
    a-=1; b-=1;
    Edge x,y; x.s=y.t=a; x.t=y.s=b; x.d=y.d=c;
    G[x.s].PB(x);
    G[y.s].PB(y);
  }
  ll Q,K; cin>>Q>>K;
  vi dist= getDist(G,N,K-1);
  REP(i,Q) {
    ll x,y; cin>>x>>y;
    x-=1; y-=1;
    cout<<dist[x]+dist[y]<<endl;
  }
}


Measured memory_bytes: 20528
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll pow(ll x,ll y){
    if(y==0) return 1;
    if(y&1) return x*pow(x,y-1);
    ll p=pow(x,y/2);
    return p*p;
}

void solve(){
    ll k;
    cin >> k;
    repi(i,1,10){
        print(i);
        k--;
        if(k==0) return;
    }
    repi(i,1,10){
        print((ll)(i*10+9));
        k--;
        if(k==0)return;
    }

    repi(i,2,11){
        repi(j,i,i*10+1){
            print((ll)j*pow(10ll,i)-1);
            k--;
            if(k==0)return;
        }
    }
    repi(j,11,101){
        print((ll)j*pow(10ll,11)-1);
        k--;
        if(k==0) return;
    }
    repi(i,12,16){
        repi(j,i-1,(i-1)*10+1){
            print((ll)j*pow(10ll,i)-1);
            k--;
            if(k==0) return;
        }
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

bool got[256];

int main() {
	std::string str;
	std::cin >> str;
	if(str == "zyxwvutsrqponmlkjihgfedcba") str = "-1";
	else {
		for(auto a : str) {
			got[a - 'a'] = true;
		}
		int hmm = 0;
		while(got[hmm]) hmm++;
		if(hmm == 26) {
			for(int i = 0; i < 26; i++) {
				got[i] = false;
			}
			int pos = 0, lul = 0;
			for(int i = 0; i < 26; i++) {
				char x = str[i];
				int cur = 0;
				for(int j = x + 1; j <= 'z'; j++) {
					if(!got[j - 'a']) {cur = j - x;break;}
				}
				if(cur != 0) {
					pos = i;
					lul = cur;
				}
				got[x - 'a'] = true;
			}
			str = str.substr(0, pos + 1);
			//std::cout << "pos is " << pos << "\n";
			str[str.size() - 1] += lul;
		} else {
			str += 'a' + hmm;
		}
	}
	std::cout << str << "\n";
}

Measured memory_bytes: 256
//失敗するからこそそこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;
 
#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	string s, t;cin >> s >> t;
	int n = s.size(), m = t.size();
	for(int i = n - 1; i >= m - 1; i--){
		string now;
		for(int j = 0; j < m; j++){
			now += s[i - j];
		}
		reverse(now.begin(), now.end());
		bool ok = true;
		for(int j = 0; j < m; j++){
			if(now[j] != t[j] && now[j] != '?'){
				ok = false;
				break;
			}
		}
		if(ok){
			int k = 0;
			for(int j = i - m + 1; j <= i ; j++){
				s[j] = t[k++];
			}
			for(int i = 0; i < n; i++){
				if(s[i] == '?')s[i] = 'a';
			}
			cout << s;
			return 0;
		}
	}
	cout << "UNRESTORABLE";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  int W, H, N;
  cin >> W >> H >> N;
  vector<vector<int>> vec(H, vector<int>(W,1));

  int x, y, a;
  int ans = 0;

  for (int i = 0; i < N; i++){
    cin >> x >> y >> a;

    if(a == 1){
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < x; j++) {
          vec.at(i).at(j) = 0;
        }
      }
    } else if (a == 2){
      for (int i = 0; i < H; i++) {
        for (int j = x; j < W; j++) {
          vec.at(i).at(j) = 0;
        }
      }
    } else if (a == 3){
      for (int i = 0; i < y; i++) {
        for (int j = 0; j < W; j++) {
          vec.at(i).at(j) = 0;
        }
      }
    } else if (a == 4){
      for (int i = y; i < H; i++) {
        for (int j = 0; j < W; j++) {
          vec.at(i).at(j) = 0;
        }
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans += vec.at(i).at(j);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int A, B;
    cin >> A >> B;
    int ans = -1;
    rep(i, 1001){
        if ((int)(i*0.08) == A && (int)(i*0.1) == B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
    }
    if n % 1000 == 0 {
        println!("0");
    } else {
        println!("{}", 1000 - n % 1000);
    }
}


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

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


int main(){
    LL n;
    cin >> n;
    vector<pair<LL,LL>> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i].second >> a[i].first;
    }
    LL used = 0;
    sort(a.begin(), a.end());
    for(LL i = 0; i < n; ++i){
        used += a[i].second;
        if(used > a[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> sum(n + 1);
  for (int i = 0; i + 1 < n; i++) {
    sum[i + 1] = sum[i] + (s[i] == 'A' && s[i + 1] == 'C');
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << sum[r - 1] - sum[l - 1] << endl;
  }
  return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
  string S;
  cin >> S;
  unsigned long long num = 0;
  unsigned long long bnum = 0;
  for (auto&& c : S) {
    if(c == 'B'){
      bnum++;
    }else{
      num += bnum;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7

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

    int n,m;

    cin >> n >> m;

    vector<vector<int> > adj(n+1);

    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    queue<pair<int,int> > q;

    q.push({1,0});

    vector<bool> visited(n+1);

    while(!q.empty())
    {
        int p = q.front().first,c = q.front().second;
        if(c>2) break;
        q.pop();
        if(p==n){ cout << "POSSIBLE"; return 0; }
        for(int i = 0;i < adj[p].size();i++)
        {
            if(!visited[adj[p][i]])
            {
                visited[adj[p][i]] = true;
                q.push({adj[p][i],c+1});
            }
        }
    }

    cout << "IMPOSSIBLE";
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
#define EPS 1e-9

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 250, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

void go(int tc = 0){
    int n;  cin >> n;
    int a[n];
    for(int i = 0;i < n;i++)    cin >> a[i];

    int ans = 0;
    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            for(int k = j + 1;k < n;k++){
                int b[] = {a[i], a[j], a[k]};
                sort(b, b + 3);
                if(b[0] == b[1] || b[1] == b[2])
                    continue;
                if(b[0] + b[1] > b[2])
                    ans++;
            }
        }
    }

    cout << ans;
}

int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

   int t = 1, tc = 1;
//   cin >> t;
    while(t--)
        go(tc++);
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define int long long
using namespace std;



int32_t main() {
    ios_base::sync_with_stdio(0);

    int a, b, c;

    cin >> a >> b >> c;

    int s = a + b + c;
    int m = max(a, max(b, c));

    if ((3*m - s) % 2 == 0) {
        cout << (3*m - s) / 2 << "\n";
    } else {
        cout << (3*m + 3 - s) / 2 << "\n";
    }

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    long long sum_A = 0, sum_B = 0;
    vector<long long> A(N), B(N);
    for (int i = 0; i < N; i++) {
        long long a;
        cin >> a;
        sum_A += a;
        A.at(i) = a;
    }
    for (int i = 0; i < N; i++) {
        long long b;
        cin >> b;
        sum_B += b;
        B.at(i) = b;
    }

    long long keep = 0, count = 0;
    bool alr = true;
    vector<long long> data;
    if (sum_A < sum_B) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) {
        keep += A.at(i) - B.at(i);
        if (A.at(i) - B.at(i) < 0) {
            alr = false;
            count++;
        }
        else {
            data.push_back(A.at(i) - B.at(i));
        }
    }

    if (alr) {
        cout << 0 << endl;
        return 0;
    }
    sort(data.begin(), data.end());
    while (data.size() != 0) {
        keep -= data.at(0);
        if (keep >= 0) {
            data.erase(data.begin());
        }
        else {
            break;
        }
    }

    cout << data.size() + count << endl;
    return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k, b[10] = {}, d;
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        cin >> d;
        b[d] = 1;
    }
    for (int i = n; i < 100000; i++) {
        bool y = 0;
        
        string s = to_string(i);
        for (int j = 0; j < s.length(); j++) if (b[s[j] - '0']) y = 1;
        
        int a = i;
        while (a) {
            if (b[a % 10]) y = 1;
            a /= 10;
        }
        
        if (y == 0) {
            cout << i;
            break;
        }
    }
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import math

N = int(input())
min_len = pow(10,10)

for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i == 0:
        if (len(str(i)) >= len(str(N // i))) and (min_len > len(str(i))):
            min_len = len(str(i))
        elif (len(str(i)) < len(str(N // i))) and (min_len > len(str(N // i))):
            min_len = len(str(N // i))
        else:
            continue
print(min_len)

Measured memory_bytes: 3064
#include <iostream>
#include <memory.h>

using namespace std;

int N;
int a[100];

int colors[8];

int count() {
  int r = 0;
  for (int i = 0; i < 8; i++) {
    r += colors[i];
  }
  return r;
}

void solve() {
  for (int i = 0; i < 8; i++) {
    colors[i] = 0;
  }

  int free = 0;
  for (int i = 0; i < N; i++) {
    int s = a[i];
    if (1 <= s && s <= 399) {
      colors[0] = 1;
    } else if (400 <= s && s <= 799) {
      colors[1] = 1;
    } else if (800 <= s && s <= 1199) {
      colors[2] = 1;
    } else if (1200 <= s && s <= 1599) {
      colors[3] = 1;
    } else if (1600 <= s && s <= 1999) {
      colors[4] = 1;
    } else if (2000 <= s && s <= 2399) {
      colors[5] = 1;
    } else if (2400 <= s && s <= 2799) {
      colors[6] = 1;
    } else if (2800 <= s && s <= 3199) {
      colors[7] = 1;
    } else {
      free++;
    }
  }

  cout << max(1, count()) << ' ' << count() + free << endl;
}

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

  solve();
}

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

#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl         "\n"
#define int          long long
#define all(v)       v.begin(),v.end()
#define sz(v)        (int)v.size()
#define pii          pair<int,int>
#define fi           first
#define se           second
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define deb(x)       cout << #x << ' ' << x << endl
#define clock        cerr << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms" << endl;

void INPUT() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

const int N = 1e5 + 5;

vector <int> v[N];
int vis[N], cache[N];
int n, m, ans;

void dfs(int src) {
	vis[src] = 1;
	for(auto i : v[src]) {
		if (!vis[i]) dfs(i);
		cache[src] = max(cache[src], 1 + cache[i]);
	}
}

int32_t main(){
    IOS //INPUT();
    cin >> n >> m;
    forn(i, 0, m) {
    	int a, b;
    	cin >> a >> b;
    	a--; b--;
    	v[a].push_back(b);
    }
    forn(i, 0, n) {
    	if (!vis[i]) dfs(i);
    }
    cout << *max_element(cache, cache + n) << endl;
    return 0;
}

Measured memory_bytes: 9344