akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

bool p[1000100];

void erato(){
    fill(p, p+1000100, true);
    p[0] = p[1] = false;

    for(int i=0; i < 1000100; i++){
        if(!p[i]) continue;
        for(int j=i+i; j < 1000100; j += i){
            p[j] = false;
        }
    }
}

int main(){
    erato();
    int n;
    while(cin >> n, n){
        for(int i=n; ; i--)if(p[i] && p[i-2]){cout << i-2 << " " << i << endl;break;}
    }
}

Measured memory_bytes: 2136
require 'set'
n, m = gets.split.map(&:to_i)
g = (0..n).map { Set.new }
m.times do
  i, j = gets.split.map(&:to_i)
  g[i] << j
  g[j] << i
end

queue = [1 << 1]
dist = { 1 << 1 => 0 }
until queue.empty?
  x = queue.shift
  d = dist[x]
  g[x >> 1].each do |j|
    y = (j << 1) + (1 - d % 2)
    next if dist[y]
    dist[y] = d + 1
    queue << y
  end
end

if dist.size == 2 * n
  p [
    dist.select {|x, _| x.even? }.map(&:last).max,
    dist.select {|x, _| x.odd? }.map(&:last).max
  ].min
else
  p -1
end


Measured memory_bytes: 61688
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,i,ans=0,sum=0;
  cin >> n >> m;
  vector<int>a(m);
  for(i=0; i<m; i++){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  if(sum<=n){
    ans=n-sum;
  }
  else{
    ans=-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
	int n;
	scanf("%i",&n);
	vector<pair<int,int>> segs;
	int ans=0,mx=0;
	for(int i=1,l,r;i<=n;i++)
	{
		scanf("%i %i",&l,&r);
		mx=max(mx,r-l+1);
		segs.pb({l,r});
	}
	ans=mx;
	sort(segs.begin(),segs.end());
	int j=0;
	for(int i=0;i<n;i++) if(segs[i].second<segs[j].second) j=i;
	pair<int,int> tmp=segs[j];
	for(int i=j;i>0;i--) segs[i]=segs[i-1];
	segs[0]=tmp;
	vector<int> L(n),R(n);
	for(int i=0,l=0,r=1e9+7;i<n;i++)
	{
		l=max(l,segs[i].first);
		r=min(r,segs[i].second);
		L[i]=max(0,r-l+1);
	}
	for(int i=n-1,l=0,r=1e9+7;i>=0;i--)
	{
		l=max(l,segs[i].first);
		r=min(r,segs[i].second);
		R[i]=max(0,r-l+1);
	}
	for(int i=1;i<n;i++) ans=max(ans,L[i-1]+R[i]);
	ans=max(ans,mx+R[0]);
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 1780
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

n=int(input())
l=lnii()

def eratosthenes(lim):
  num=[1 for i in range(lim)]
  for i in set(l):
    for j in range(i+i,lim,i):
      num[j]=0
  return num

lim=10**6+5
num=eratosthenes(lim)

count=Counter(l)

ans=0
for i in l:
  if num[i]==1 and count[i]==1:
    ans+=1

print(ans)

Measured memory_bytes: 47508
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma gcc target ("avx2")
#pragma gcc optimization ("Ofast")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	vector<int> bit(33);
	rep(i, n) {
		rep(j, 32) {
			if ((1 << j) & a[i])++bit[j];
		}
	}
	vector<int> ans(n);
	rep(i, n) {
		rep(j, 32) {
			if (bit[j] % 2) {
				if (not ((1 << j) & a[i]))ans[i] += (1 << j);
			}
			else {
				if ((1 << j) & a[i])ans[i] += (1 << j);
			}
		}
	}
	rep(i, n)printf("%lld\n", ans[i]);

	Please AC;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
 
#define SKILLER ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define double long double
const int N=3000 + 5, MOD = 1e9 + 7;
string s, t;
int n, m, totW;
//int w[105], v[105];
bool c[N][N];
double cache[N][N];
double a[N];
double dp(int i, int h)
{
    if(i == n+1)
    {
        if(h*2 >= n) return 1;
        else return 0;
    }
    if(c[i][h])return cache[i][h];
    c[i][h] = 1;
    cache[i][h] = a[i]*dp(i+1, h+1) + (1 - a[i])*dp(i+1,h);
    return cache[i][h];
}

int32_t main()
{
    SKILLER
       
   //memset(cache, 0, sizeof(cache));
    cin >> n ;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    double ans = dp(1,0);
   // cout<<ans<<"\n";
    cout<< setprecision(10)<<fixed<<ans;
    return 0;
}

Measured memory_bytes: 148608
#include <iostream>
using namespace std;
int main()
{
int n,m,c,i,j,d=0,seikai=0;
  cin >> n >> m >> c;
  int b[m],a[n][m];
  for(i=0;i<m;i++)cin>>b[i];
    for(i=0;i<n;i++){
    for(j=0;j<m;j++)cin>>a[i][j];
    }
    for(i=0;i<n;i++){
    for(j=0;j<m;j++){d+=b[j]*a[i][j];}
      if(d+c>0)seikai++;
      d=0;
    }
  cout << seikai << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,k;
  string s;
  cin>>n>>k>>s;
  n=sz(s);
  if(n==1){
    in c=(s[0]=='A')+k;
    if(c%2==0)
      cout<<"B"<<endl;
    else
      cout<<"A"<<endl;
    return 0;
  }
  bool wt;
  string ans;
  bool fnd=0;
  forn(i,n){
    wt=(s[i]=='A');
    if(i%2)
      wt=!wt;
    in mvs=1+wt;
    if(mvs<=k){
      k-=mvs;
      continue;
    }
    if(mvs==2 && k==1){
      if(s[i]=='A')
	s[i]='B';
      else
	s[i]='A';
    }
    if(i%2){
      for(in j=i;j<n;++j){
	if(s[j]=='A')
	  s[j]='B';
	else
	  s[j]='A';
      }
    }
    for(in j=i;j<n;++j)
      ans+=s[j];
    forn(j,i){
      if((j+i)%2)
	ans+='A';
      else
	ans+='B';
    }
    fnd=1;
    break;
  }
  if(!fnd){
    forn(j,n){
      if((j+n)%2)
	ans+='A';
      else
	ans+='B';
    }
    if(n%2==1 && k%2==1)
      ans[0]='B';
  }
  cout<<ans<<"\n";
  return 0;
}


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

const int INF = 1e9;

int main() {
  int x;
  cin>>x;
  if (x == 3 || x == 5 || x == 7) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }

}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		char[] s=sc.nextLine().toCharArray();
		s[3]='8' ;
		System.out.println(s);
		
		
	}
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
}


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

int main() {
  int A[7] = {1,2,4,8,16,32,64};

  int N;
  cin >> N;

  int pos = upper_bound(A,A+7,N) - A;

  cout << A[pos-1] << endl;

  return 0;
}


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

int main(){
	int n, k;	cin >> n >> k;
  	vector<int> d(k);
  	vector<vector<int>> a(k);
  	for(int i = 0; i < k; i++){
    	cin >> d.at(i);
      	for(int j = 0; j < d.at(i) ; j++){
          	int tmp;	cin >> tmp;
          	a.at(i).push_back(tmp);
        }
    }
  	
  	set<int> dc;
  	for(int i = 0; i < k; i++){
      	for(int j = 0; j < d.at(i) ; j++){
          	dc.insert(a.at(i).at(j));
        }
    }  		
  
  	int count = 0;
  	for(int i = 1; i <= n; i++){
    	if(dc.count(i) == 0) count++;
    }
  	
  	cout << count << endl;
  	
}

Measured memory_bytes: 3640
n = int(input())
A = [int(input()) for _ in range(n)]
m = 30
C = [False]*m
x = 0
for a in A:
  x ^= a
  for i in range(m):
    if a>>i & 1:
      C[i] = True
      break
total = 0
ans = 0
for i in range(m-1, -1, -1):
  if (x>>i & 1) ^ total:
    if C[i]:
      ans += 1
      total ^= 1
    else:
      print(-1)
      break
else:
  print(ans)

Measured memory_bytes: 7072
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>

using namespace std;


int main(){
  //エラトステネスの篩を実装する
  int n[100011]={0};//i番目が整数iに対応(1~100000)
  //0になったところは素数
  for(int i=2;i<=1000;i++){
    if(n[i]==0){
      for(int j=1;j<=floor(100010/i);j++){
        if(j!=1){
          n[j*i]=1;
        }
      }
    }
  }
  int k;cin >> k;
  for(int i=k;i<=100010;i++){
    if(n[i]==0){cout << i << endl;break;}
  }
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int x,y;
    
    while(1){
        cin >> x >> y;
        if((x==0)&&(y==0)) break;
        if(x <= y){
            cout << x << " " << y <<endl;
        }
        else{
            cout << y << " " << x <<endl; 
        }
    }
    
}


Measured memory_bytes: 3000
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static ulong F(ulong a)
    {
        switch (a % 4)
        {
            case 0:
                return a;
            case 1:
                return 1UL;
            case 2:
                return a ^ 1UL;
            default:
                return 0UL;
        }
    }

    public static void Main()
    {
        ulong A, B;
        string[] strs = Console.ReadLine().Split(' ');
        A = ulong.Parse(strs[0]);
        B = ulong.Parse(strs[1]);
        
        Console.WriteLine(F(B) ^ F(A-1));
    }
}

Measured memory_bytes: 11220
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  i64 r, g, b, N;

  cin >> r >> g >> b >> N;

  i64 cnt = 0;

  rep(i, 0, N+1) {
    rep(j, 0, N+1) {
      i64 rem = N - (i*r + j*g);
      if (rem < 0 || rem % b != 0) continue;
      ++cnt;
    }
  }

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



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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int i = 0;
  while (a > 0 && c > 0) {
    if (i % 2 == 0) {
      c -= b;
    } else {
      a -= d;
    }
    i++;
  }

  if (a > 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
// static const unsigned long long MAX 1000000000000000000;

int main() {
  int n;
  cin >> n;
  unsigned long long a = 1;
  unsigned long long b[100000];
  int flag = 0;
  int zerof = 0;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  // sort(b[0], b[n]);
  for (int i = 0; i < n; i++) {
    if (a > 1000000000000000000 / b[i]) {
      cout << -1 << endl;
      return 0;
    }
    a *= b[i];
  }
  if (zerof == 1) {
    cout << 0 << endl;
  } else if (flag == 1) {
    cout << -1 << endl;
  } else {
    cout << a << endl;
  }
}

Measured memory_bytes: 4376
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();
		
		System.out.println(Math.max(Math.max(a+b, a-b), a*b));
		
		
	}	
}

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

int main() {
  double N,K;
  cin >> N >> K;
  vector<double> p(N+K,0);
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  double sum=0;
  for(int i=0;i<K;i++){
    sum +=p[i];
  }
  //cout << sum << endl;
  double a=sum;
  for(int i=0;i<N;i++){
    sum=sum-p[i]+p[i+K];
    a=max(a,sum);
    //cout << a << endl;
  }
  
  cout << fixed << setprecision(10) << (a+K)/2;
}

Measured memory_bytes: 3328
N=int(input())
A=list(map(int,input().split()))
s=" ".join(map(str,A))
print(s)
for i in range(1,N):
    
    v=A[i]
    j=i-1
    while(j>=0 and v<A[j]):#<で安定になる
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    s=" ".join(map(str,A))
    print(s)


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

int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    r = r - l + 1;
    sum += r;
  }
  
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
using namespace std;
const int MAXn=100;
const int INFTY=1<<21;

int n,M[MAXn][MAXn]={0},d[MAXn];

void bfs(int u)
{
	queue<int> Q;
	Q.push(u);
	for(int i=0;i<n;i++)d[i]=INFTY;
	d[u]=0;
	int v;
	
	while(!Q.empty())
	{
		v=Q.front();Q.pop();
		for(int r=0;r<n;r++)
		{
			if(M[v][r]==0)continue;
			if(d[r]!=INFTY)continue;
			d[r]=d[v]+1;
			Q.push(r);
		}
	}
	
	for(int i=0;i<n;i++)cout<<i+1<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
	
	return;
}

int main() {
	cin>>n;
	int id,k,v;
	for(int i=0;i<n;i++)
	{
		cin>>id>>k;
		id--;
		for(int j=0;j<k;j++)
		{
			cin>>v;
			M[id][--v]=1;
		}
	}
	bfs(0);
	return 0;
}

Measured memory_bytes: 3108
# -*- coding: utf-8 -*-
X = int(input())
if X <= 599:
  print('8')
elif X <= 799:
  print('7')
elif X <= 999:
  print('6')
elif X <= 1199:
  print('5')
elif X <= 1399:
  print('4')
elif X <= 1599:
  print('3')
elif X <= 1799:
  print('2')
elif X <= 1999:
  print('1')

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

int main(){
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
 	int n;
 	cin>>n;
 	int a[n];
 	int b[n];
 	int c[n];

 	for(int i = 0;i<n;i++){
 		cin>>a[i];
 		if(i==0){
 			b[i] = a[i];
 		}
 		else {
 			b[i] = b[i-1] + a[i];
 		}
 	}  
 	for(int i = 0;i<n-1;i++){
 		c[i] = abs(b[i]-(b[n-1]-b[i]));
 	} 
 	sort(c,c+n-1);
 	cout<<c[0];
	return 0;
}

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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define foi(i,a,n) for(i = (a); i <= (n); i++)
#define pd(x) cout<<x
#define sd(x) cin>>x
#define nl cout<<endl
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//ll fibonacci[2][2] = {{0,1},{1,1}};
//ll identity[2][2] = {{1,0},{0,1}};

int main() {
	sws;
	ll i,j,k;
	ll n;
	cin>>n;
	vll v(n);
	fo(i,0,n) cin>>v[i];
	vll v2;
	bool flag = true;
	fo(i,0,n) {
		if (sz(v2)+1 >= v[i]) {
			v2.insert(v2.begin() + v[i] - 1, v[i]);
		} else {
			flag = false;
			break;
		}
	}
	if (!flag) {
		cout << "-1" << endl;
	} else {
		fo(i,0,n) cout << v2[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=105;
const ll INF=1LL<<60;

vector<pair<int,pair<int,int>>> G[MAX];
ll dis[MAX][MAX];
int L;

void dijkstra(int u){
    priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>> PQ;
    
    dis[u][L]=0;

    PQ.push(make_pair(0,make_pair(u,L)));
    while(!PQ.empty()){
        int a=PQ.top().first;
        int b=PQ.top().second.first;
        int c=PQ.top().second.second;
        PQ.pop();
        if(dis[b][c]<a) continue;
        for(int i=0;i<G[b].size();i++){
            int d=G[b][i].first;
            int e=G[b][i].second.first;
            int f=G[b][i].second.second;
            
            if(c>=e){
                if(dis[d][c-e]>dis[b][c]){
                    dis[d][c-e]=dis[b][c];
                    PQ.push(make_pair(dis[d][c-e],make_pair(d,c-e)));
                }
            }
            
            if(dis[d][c]>dis[b][c]+f){
                dis[d][c]=dis[b][c]+f;
                PQ.push(make_pair(dis[d][c],make_pair(d,c)));
            }
        }
    }
    return;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M>>L;
        if(N+M+L==0) break;
        
        for(int i=0;i<=N;i++){
            for(int j=0;j<=L;j++){
                dis[i][j]=INF;
            }
            G[i].clear();
        }
        
        for(int i=0;i<M;i++){
            int a,b,c,d;cin>>a>>b>>c>>d;
            a--;b--;
            G[a].push_back({b,{c,d}});
            G[b].push_back({a,{c,d}});
            
            //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
        }
        
        dijkstra(0);
        
        ll ans=INF;
        
        for(int i=0;i<=L;i++){
            ans=min(ans,dis[N-1][i]);
        }
        
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 3772
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B; cin >> A >> B;
    cout << (A+B) % 24 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;

ll divisor=1e9+7;
int main(){
	ll x;
	cin>>x;
	for(ll a=-200;a<200;a++){
		for(ll b=-200;b<200;b++){
			if(a*a*a*a*a-b*b*b*b*b==x){
				puts(a);
				puts(b);
				 return 0;
			}
		}
	}
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

signed main(){
    int W;cin>>W;
    string s;
    for(int i=3;W;i*=3){
        int tmp=W%3;
        if(tmp==0)s+="0";
        else if(tmp==1)s+="+";
        else{
            s+="-";
            W+=3;
        }
        W/=3;
    }
    reverse(all(s));
    cout<<s<<endl;
}

Measured memory_bytes: 1188
#include<iostream>

int main(){

	while (true){
		int n, base, p;
		int cnt[51] = { 0 };

		std::cin >> n >> base;

		if (n == 0 && base == 0)break;

		p = base;

		int i = 0;
		while (true){
			if (i == n)i = 0;

			if (p == 0){
				p += cnt[i];
				cnt[i] = 0;
			}
			else {
				p--;
				cnt[i]++;
				if (cnt[i] == base)break;
			}

			i++;
		}

		std::cout << i << std::endl;
	}

	return 0;
}

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

int main() {
  int s;
  int count=0;
  cin >> s;
  
  if(s/100==1) count++, s-=100;
  if(s/10==1) count++, s-=10;
  if(s/1==1) count++;
  
  cout << count;  


}

Measured memory_bytes: 256
def LI(): return list(map(int,input().split()))
N,M = LI()
ks = [LI() for _ in range(M)]
p = LI()
ans = 0
for i in range(2**N):
    bit = [i>>j & 1 for j in range(N)]
    for j,x in enumerate(ks):
        k,*s = x
        if p[j]!= sum([bit[y-1] for y in s])%2:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define pb push_back
#define mp make_pair
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define sorta(v) stable_sort(v.begin(),v.end())
#define sortd(v) stable_sort(v.begin(),v.end(),greater <> ())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define I(a) insert(a)
#define F first
#define S second
const int N=1e9+7;

int power(int x, int y){ 
    int res = 1; 
    while (y > 0){
        if (y & 1) 
            res = ((res) * (x));
        res %= N; 
        y = y >> 1; 
        x = ((x) * (x)); 
    }
    return res; 
}

int powmod(int a,int b,int n){
    int x=1, y=a; 
    while (b > 0) {
        if (b%2 == 1) {
            x = (x*y) % n;
        }
        y = (y*y) % n; 
        b /= 2;
    
    }
    return x % n;
}

int32_t main(){
    fastIO
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector <int> v(n+1),dp(n+1,0);
        for(int i=1;i<=n;i++)
            cin>>v[i];
        dp[2]=abs(v[2]-v[1]);
        for(int i=3;i<=n;i++){
            dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
        }
        cout<<dp[n]<<"\n";
    }
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

int a[205];

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < 2 * n; i++)
        scanf("%d", &a[i]);
    sort(a, a + 2 * n);
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2)
        ans += a[i];
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;

int main(){
    ll n;
    ll a[5];
    cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

    int min_pointer = 0;
    ll min_value = a[0];
    for(int i=0; i<5; i++){
        if(a[i] < min_value){
            min_value = a[i];
            min_pointer = i;
        }
    }

    if(n%min_value == 0){
        cout << n/min_value + 4 << endl;
        return 0;
    }

    cout << n/min_value + 5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char a[20],b[20];
inline bool check()
{
	int n=strlen(a);
	for(int i=0;i<n;++i)
	if(a[i]!=b[i])return 0;
	return 1;
}
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	if(strlen(a)+1==strlen(b) && check())puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3688
//By Vlgd
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y){}
	Point operator + (Point p){return Point(x+p.x,y+p.y);}
	Point operator - (Point p){return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);}
	Point operator / (double a){return Point(x/a,y/a);}
	double abs() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x!=p.x?x<p.x:y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;
struct Segment{Point p1,p2;};
double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}
Point CP(Segment s1,Segment s2){
	Vector base=s1.p2-s1.p1;
	Vector a=s2.p1-s1.p1,b=s2.p2-s1.p1;
	double d1=fabs(cross(base,a)/base.abs());
	double d2=fabs(cross(base,b)/base.abs());
	double r=d1/(d1+d2);
	return s2.p1+(s2.p2-s2.p1)*r;
}
main(){
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Point p1(x1,y1),p2(x2,y2);
		Segment s1;
		s1.p1=p1;s1.p2=p2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		Point p3(x1,y1),p4(x2,y2);
		Segment s2;
		s2.p1=p3;s2.p2=p4;
		Point cp=CP(s1,s2);
		printf("%.10lf %.10lf\n",cp.x,cp.y)	;
	}
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll k;cin>>k;
    vector<ll> a(k);
    rep(i,k)cin>>a[i];
    if(a[k-1]!=2){
        cout<<-1<<endl;
        return 0;
    }
    reverse(a.begin(),a.end());
    
    ll tmp=2,tmp2=2;
    rep(i,k){
        if(i==0)continue;
        ll x=(tmp+a[i-1]-1)/a[i],y=(tmp2+a[i]-1)/a[i];
        tmp=x*a[i],tmp2=y*a[i];
        if(x<y){
            cout<<-1<<endl;
            return 0;
        }
    }
    tmp+=(a[k-1]-1);
    cout<<tmp2<<" "<<tmp<<endl;
}


Measured memory_bytes: 4008
def main():
    N=int(input())
    S=input()
    s=0
    if N==1:
        print(1)
    else:
        s=1
        for i in range(0,N-1):
            if S[i]!=S[i+1]:
                s=s+1
        print(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.PLS", "r", stdin );
	int n;
	while (scanf ("%d", &n ) && n ){
		vector<vector<P> > p; p.clear();
		p.resize(n+1 );
		int m0;

		rep (i, n+1 ){
			int m;
			scanf ("%d", &m );
			p[i].resize (m );
			if (i == 0 ) m0 = m;
			rep (j, m ){
				int x, y;
				scanf ("%d %d", &x, &y );
				p[i][j].first = x, p[i][j].second = y;
			} // end for
			if (i == 0 ){
				for (int j = 1; j < m; j++ ){
					p[i][j].first  -= p[i][0].first;
					p[i][j].second -= p[i][0].second;
				} // end for
				p[i][0].first = 0, p[i][0].second = 0;
			} // end if
		} // end rep

		set<int> res; res.clear();
		rep (rot, 4 ){
			for (int i = 1; i <= n; i++ ){
				if (m0 != p[i].size() ){
					continue;
				} // end if
				int m = p[i].size();
				rep (s, 2 ){
					bool found = true;
					vector<P> curr (m ); curr.clear();
					if (s == 0 ){
						for (int j = 1; j < m; j++ ){
							curr[j].first  = p[i][j].first -  p[i][0].first;
							curr[j].second = p[i][j].second - p[i][0].second;
						} // end for
						curr[0].first = 0, curr[0].second = 0;
					}else{
						reverse (ALL (p[i] ) );
						for (int j = 1; j < m; j++ ){
							curr[j].first  = p[i][j].first  - p[i][0].first;
							curr[j].second = p[i][j].second - p[i][0].second;
						} // end for
						curr[0].first = 0, curr[0].second = 0;
					} // end if
					rep (j, m ){
						if (p[0][j].first == curr[j].first && p[0][j].second == curr[j].second ) continue;
						found = false;
					} // end rep
					if (found ){
						res.insert (i );
					} // end if
				} // end rep
			} // end for
			rep (j, m0 ){
				int temp = p[0][j].first;
				p[0][j].first = -p[0][j].second;
				p[0][j].second = temp;
			} // end rep
		
		} // end for
		if (!res.empty() ){
			set<int>::iterator it = res.begin();
			for (; it != res.end(); it++ ){
				printf ("%d\n", (*it) );
			} // end for
		} // end rep
		printf ("+++++\n" );	
	} // end while

	return 0;
}

Measured memory_bytes: 1208
import java.util.*;

public class Main{
	public static void main(String[] args){
	
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int a=sc.nextInt();
	int b=sc.nextInt();
	long total=0;
	for(int i=1;i<=n;i++){
		String s[]=String.valueOf(i).split("");
		int m=0;
		for(int k=0;k<s.length;k++){
			m+=Integer.parseInt(s[k]);
		}
		if(m>=a && m<=b) total+=i;
	}
	System.out.println(total);


	}
}





Measured memory_bytes: 34132
n=int(input())
w=input()
tmp=w[-1:]
d={}
d[w]=1
for i in range(1,n):
    w=input()
    if w not in d:
        d[w]=1
    else:
        print("No")
        exit()
    if w[0]==tmp:
        tmp=w[-1:]
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 9196
import java.util.Scanner;

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

        String item = inp.next();

        while (!item.equals("0")) {
            String[] items = item.split("");

            long total = 0;

            for (String st : items) {
                total += Long.parseLong(st);
            }

            System.out.println(total);

            item = inp.next();
        }
    }
}



Measured memory_bytes: 27240
#include<bits/stdc++.h>
using namespace std;
const int mx = 310;
double dp[mx+5][mx+5][mx+5];
int main()
{
	int n;
	cin >> n;
	int cnt1 = 0,cnt2 = 0,cnt3 = 0;
	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		if(x == 1)
			cnt1++;
		else if(x == 2)
			cnt2++;
		else
			cnt3++;
	}
	for(int k=0;k<mx;k++){
		for(int j=0;j+k<mx;j++){
			for(int i=0;i+j+k<mx;i++){
				if(i == 0 && j == 0 && k == 0)
					continue;
				if(i+j+k > mx)
					continue;
				double p_a = 1.0*i/(i+j+k);
				double p_b = 1.0*j/(i+j+k);
				double p_c = 1.0*k/(i+j+k);
				double p_waste = 1.0 * n/(i+j+k);
				if(i)
					dp[i][j][k] += p_a*dp[i-1][j][k];
				if(j)
					dp[i][j][k] += p_b*dp[i+1][j-1][k];
				if(k)
					dp[i][j][k] += p_c*dp[i][j+1][k-1];
				dp[i][j][k] += p_waste;
			}
		}
	}
	printf("%.12lf\n",dp[cnt1][cnt2][cnt3]);
}

Measured memory_bytes: 122852
import copy
h, w = map(int, input().split())
field = []

for i in range(h):
    field.append(list(input()))

d = [(0, 1), (0, -1), (1, 0), (-1, 0)]
ans = 0

for start_y in range(h):
    for start_x in range(w):
        if field[start_y][start_x] == "#":
            continue

        new_field = copy.deepcopy(field)
        next_pos = [(start_y, start_x)]
        cnt = 0
        new_field[start_y][start_x] = 0
        
        while True:
            next_pos_cand = []
            cnt += 1
            for y, x in next_pos:
                for dy, dx in d:
                    if 0 <= y + dy < h and 0 <= x + dx < w:
                        if new_field[y + dy][x + dx] == ".":
                            next_pos_cand.append((y + dy, x + dx))
                            new_field[y + dy][x + dx] = cnt
            next_pos = next_pos_cand

            if len(next_pos) == 0:
                ans = max(ans, cnt - 1)
                break

print(ans)


Measured memory_bytes: 3444
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    from collections import defaultdict
    ret = defaultdict(list)
    for i in range(self.n):
      ret[self.find(i)].append(i)
    return ret

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
P = list(map(int, input().split()))

uf = UnionFind(N)

for _ in range(M):
  x, y = map(lambda x: int(x)-1, input().split())
  uf.union(x, y)

D = uf.all_group_members()

ans = 0

for L in D.values():
  check = set(L)
  for i in L:
    if P[i]-1 in check:
      ans += 1 

print(ans)

Measured memory_bytes: 104420
N, Y = map(int, input().split())

# 合計値
y = 0

# 正解組み合わせがあった場合
exist_answer = False

for i in range(N + 1):
    for j in range((N + 1) - i):
        k = N - (i + j)
        y = i * 10000 + j * 5000 + k * 1000
        if y == Y:
            exist_answer = True
            print(i, j, k)
            break
    if exist_answer is True:
        break

if exist_answer is False:
    print(-1, -1, -1)

Measured memory_bytes: 3060
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,t){e.exports=function(e){for(var t=e[0],n=0,r=0,o=t.length-1;r<o;)if(t[r]==t[o])r++,o--;else if("x"==t[r])r++,n++;else{if("x"!=t[o])return void console.log(-1);o--,n++}console.log(n)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 7372
function main(input) {
  input=input.trim();
  var a = parseInt(input.split("\n")[0], 10);
  var i=0
  while(Number.isInteger(Math.pow(a-i,1/2))==false){
    i++
  }
  console.log(a-i);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  cin>>n>>s;
  int x=0,max_x=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='I')x++;
    if(s.at(i)=='D')x--;
    max_x=max(x,max_x);
  }
  cout<<max_x<<endl;
}

Measured memory_bytes: 256
n,y = map(int,input().split())
total = 0
for i in range(n+1):
	for j in range(n+1-i):
		k = n - i - j
		total = i*10000 + j*5000 + k*1000
		if total == y:
			print(i,j,k)
			break
		total = 0
	else:
		continue
	break
else:
	print("-1 -1 -1")



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

int main() {

  long long A, B, C, K;
  cin >> A >> B >> C >> K;

  long long answer = 0;

  answer += min(A, K);
  K = max((long long) 0, K - A);
  
  K = max((long long) 0, K - B);

  answer -= min(C, K);
  
  cout << answer << endl;

  return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string n; cin>>n;
    ll sum=0,a=stoll(n);
    rep(i,n.size()){
        sum+=n[i]-'0';
    }
    if(a%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3592
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int l, r, d;cin>>l>>r>>d;
    cout << r/d - (l-1)/d << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc165/abc165_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll A, B, N;
  cin >> A >> B >> N;

  ll x = min(B - 1, N);
  ll ans = (A * x) / B - A * (x / B);

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
using namespace std;

int main(){
  int N,i=0;
  cin>>N;
  
  for(int t=1; t<=1000; ++t){
    if(t*(t+1)==2*N){
      i=t;
    }
  }
  
  if(i>0){
      COYe;
      cout<<i+1<<endl;
      ll ANS[i+1][i+1],DIS[i+1][i+1];
      for(int j=1; j<=i; ++j){
        ANS[0][j]=j;
        for(int k=1; k<=i; ++k) ANS[j][k]=j;
      }
      
      for(int j=1; j<=i; ++j){
        for(int k=1; k<i; ++k){
          DIS[j][k]=i-k;
          if(j==k) DIS[j][k]=i+1-j;
          if(j<k) DIS[j][k]=1;
        }
      }
      
      for(int j=1; j<=i; ++j){
        for(int k=2; k<=i; ++k){
          ANS[j][k]=ANS[j][k-1]+DIS[j][k-1];
        }
      }
      
      for(int j=0; j<=i; ++j){
        cout<<i<<" ";
        for(int k=1; k<=i; ++k){
          cout<<ANS[j][k]<<" ";
        }
        cout<<endl;
      }
      return 0;
    }
  
  CONo;
  return 0;
}

Measured memory_bytes: 4480
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x, n = na()
p = na()
sp = set(p)

mn = 99999999
best = 99999999
for i in range(-100, 300):
    if i not in sp and abs(i-x) < mn:
        mn = abs(i-x)
        best = i
print(best)

Measured memory_bytes: 61932
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

struct sushi{
	int x, v;
};

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

	string A, B, C;
	cin>>A>>B>>C;

	int i = 0, j = 0, k = 0;
	char turn = 'a';

	while (1) {
		//dbg(turn);
		if(turn=='a'){
			if(i==(int)A.size()){
				turn = 'A';
				break;
			}else{
				turn = A[i++];
				continue;
			}
		}
		if(turn=='b'){
			if(j==(int)B.size()){
				turn = 'B';
				break;
			}else{
				turn = B[j++];
				continue;
			}
		}
		if(turn=='c'){
			if(k==(int)C.size()){
				turn = 'C';
				break;
			}else{
				turn = C[k++];
				continue;
			}
		}
	}

	cout << turn << endl;

	return 0;
}

Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A

x = int(input())
y = list(map(int,input().split()))
z = 0

flag = 1
while flag:
	flag = 0
	i = x - 1
	while i > 0:
		if y[i] < y[i - 1]:
			y[i], y[i - 1] = y[i - 1], y[i]
			flag = 1
			z += 1
		i -= 1

print(" ".join(list(map(str,y))))
print(z)

Measured memory_bytes: 7692
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  double k1 = ((a+b)*1.0) / 2.0;
  int ans = round(k1);
  cout << ans << endl;
}


Measured memory_bytes: 384