akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if(X == 2){System.out.println("2"); return;}
        Map<Boolean, List<Integer>> res = IntStream.rangeClosed(2, X+10000).boxed().collect(new PrimeCollector());
        int prm = res.get(true).stream().filter(a->a>=X).findFirst().get();
        System.out.println(prm);

    }

    private static class PrimeCollector implements Collector<Integer, Map<Boolean, List<Integer>>, Map<Boolean, List<Integer>>>{

        @Override
        public Supplier<Map<Boolean, List<Integer>>> supplier() {
            Map<Boolean, List<Integer>> res = new HashMap<>();
            res.put(true, new ArrayList<>());
            res.put(false, new ArrayList<>());
            return ()->res;
        }

        @Override
        public BiConsumer<Map<Boolean, List<Integer>>, Integer> accumulator() {
            return (mp, candidate)->{

                boolean isDivisible = mp.get(true).stream().filter(d -> d<=Math.sqrt(candidate))
                        .anyMatch(d->candidate % d == 0);
                mp.get(!isDivisible).add(candidate);
            };
        }

        @Override
        public BinaryOperator<Map<Boolean, List<Integer>>> combiner() {
            return (mp1, mp2)->{
                mp1.get(false).addAll(mp2.get(false));
                mp1.get(true).addAll(mp2.get(true));
                return mp1;
            };
        }

        @Override
        public Function<Map<Boolean, List<Integer>>, Map<Boolean, List<Integer>>> finisher() {
            return Function.identity();
        }

        @Override
        public Set<Characteristics> characteristics() {
            Set<Characteristics> cs = new HashSet<>();
            cs.add(Characteristics.IDENTITY_FINISH);
            return cs;
        }
    }
}


Measured memory_bytes: 49304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp9
{   
    class Program
    {
        public static void Main(string[] args) {
            while (true)
            {
                string[] sss = Console.ReadLine().Split(' ');
                int a = int.Parse(sss[0]); int b = int.Parse(sss[1]);
                if (a == 0 && b == 0) { break; }
                else if (a < b)
                    Console.WriteLine("{0} {1}", a, b);
                else
                    Console.WriteLine("{0} {1}",b,a);
            }
        }
    }
}

Measured memory_bytes: 9408
import java.util.Scanner;

class Main{
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int num = sc.nextInt();
      int i = 0;
      int[] n_box = { 1, 1, 1, 2, 1, 2, 1, 5,
                      2, 2, 1, 5, 1, 2, 1, 14,
                      1, 5, 1, 5, 2, 2, 1, 15,
                      2, 2, 5, 4, 1, 4, 1, 51};
      if(num == 0 || num > 32){
        System.out.println("1 => K =< 32 ins");
      }else{
        i = --num;
        System.out.println(n_box[i]);
      }
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <algorithm>
#define MAX 1000000000000000000
using namespace std;
 
int main() {
	unsigned long long int a,ans;
	long double b;
	cin >> a>>b;
	int x = b * 100+0.001f;
	ans = a * x;
	cout << (ans / 100);
	return 0;
}

Measured memory_bytes: 3708
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      String s = sc.next();
      String t = sc.next();

      char[] sd =new char[n];
      char[] td =new char[n];

      for (int i = 0;i<n ;i++) {
        sd[i] = s.charAt(i);
        td[i] = t.charAt(i);
      }

      for (int i = 0;i<n ;i++) {
        System.out.print(sd[i]);
        System.out.print(td[i]);
      }
      System.out.println();


}
}


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

using namespace std; 

int main() {
  cout << fixed << setprecision(12);
  while (true) {
    int n;
    double a[1000], sum = 0, avg, ans = 0;
    cin >> n;
    if (!n) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    avg = sum / n;
    for (int i = 0; i < n; i++) {
      ans += pow(a[i] - avg, 2);
    }
    ans = sqrt(ans / n);
    cout << ans << '\n';
  }
  return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef vector<P> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
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;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  V a(x),b(y),c(z);
  rep(i,x)cin>>a[i];
  rep(i,y)cin>>b[i];
  rep(i,z)cin>>c[i];
  RSORT(a);
  RSORT(b);
  RSORT(c);

  V ans;
  rep(i,x){
    rep(j,y){
      rep(l,z){
        if((i+1)*(j+1)*(l+1)>k)break;
        ans.pb(a[i]+b[j]+c[l]);
      }
    }
  }
  RSORT(ans);
  rep(i,k)cout<<ans[i]<<"\n";

  /* O( k^2 log k )
  V ab;
  rep(i,x)rep(j,y)ab.pb(a[i]+b[j]);
  RSORT(ab);
  if(ab.size()>k+1)ab.erase(ab.begin()+k,ab.end());
  
  V abc;
  rep(i,ab.size())rep(j,z)abc.pb(ab[i]+c[j]);
  RSORT(abc);

  rep(i,k)cout<<abc[i]<<"\n";
  */
  
  return 0;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define vll vector< ll >
//#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define int long long
using namespace std;
//using ll = unsigned long long;
ll md=MD;
//ll M=1073741824;
ll M=998244353;
//ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}
ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1)ans=(ans*a)%M;a=(a*a)%M;b=b>>1;}return ans;}
const int INF=1000000000000000000;


int32_t main()
{
	IOS;
	int t;
//	cin>>t;
	t=1;
	while(t--)
	{
		 int n;
		 cin>>n;
		 vector<int> a(n);
		 for(int i=0;i<n;++i)cin>>a[i];
		 int sum=0;
		 for(int i=0;i<n;i+=2)
		 {
		 	sum^=(a[i]^a[i+1]);
		 }
		 for(int i=0;i<n;++i)
		 {
		 	a[i]^=sum;
		 }
		 for(int i=0;i<n;++i)cout<<a[i]<<" ";
		 cout<<"\n";
	}
	return 0;
}

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

int main(){
  int A, B;
  string S;
  cin >> A >> B >> S;
  for(int i=0; i<A; i++){
    if(S[i]<'0' || S[i]>'9'){
      cout << "No" << endl;
      return 0;
    }
  }
  if(S[A]!='-'){
    cout << "No" << endl;
    return 0;
  }
  for(int i=A+1; i<A+B+1; i++){
    if(S[i]<'0' || S[i]>'9'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define M 300
using namespace std;

int n,q;
int c[300100],x;

int main(){
  scanf("%d%d",&n,&q);
  int lim = 0;
  for(int i=0;i<n;i++){ scanf("%d",&c[i]); lim = max(lim,c[i]); }
  sort(c,c+n);
  int m[M] = {0};
  for(int i=1;i<=M;i++){
    for(int j=0;j<n;j++)m[i] = max(m[i],c[j]%i);
  }

  for(int i=0;i<q;i++){
    scanf("%d",&x);
    if(x<=M)printf("%d\n",m[x]);
    else{
      int res = 0;
      for(int j=1;j*x<=lim;j++){
	int tmp = lower_bound(c,c+n,j*x) - c;
	if(tmp)res = max(res,c[tmp-1]%x);
      }
      printf("%d\n",res);
    }
  }
}

Measured memory_bytes: 2212
#include "bits/stdc++.h"
// Custom Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)
#define LF          '\n'

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '\0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    --a , --b;
    cout << a * b << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

ll p(ll m, ll n) {
	if (n <= 0) { return 1; }
	return m * p(m,n - 1);
}


int main() {
	
	ll H, W, N;
	cin >> H >> W >> N;

	map<pair<ll, ll>, ll> mp;

	repn(i, N) {
		ll a, b;
		cin >> a >> b;

		rep(j, 3)rep(k, 3) {
			mp[{a - 1 + j, b - 1 + k}]++;
		}
	}

	vector<ll> ans(10,0);

	for (auto q : mp) {
		ll x = q.first.first;
		ll y = q.first.second;
		ll j = q.second;
		//cout << x << y << j<<endl;
		if (2 <= x && x <= H-1 && 2 <= y && y <= W-1) { ans[j]++; }
	}

	ans[0] = (H-2) * (W-2);
	repn(i, 9) ans[0] -= ans[i];
	
	rep(i, 10)cout << ans[i] << endl;

	system("PAUSE");
}

Measured memory_bytes: 56696
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(N);
	READV(K);
	READAR(A,N);
	ll sum=0;
	FORI(i,0,N)
	{
		sum+=A[i];
	}
	set<ll> GP;
	for (ll i = 1; i*i <= sum; ++i)
	{
		if (sum%i==0)
		{
			GP.insert(i);
			GP.insert(sum/i);
		}
	}
	ll ans=1;
	trav(x,GP)
	{
		multiset<ll> P;
		FORI(i,0,N)
		{
			if (A[i]%x!=0)
			{
				P.insert(A[i]%x);
			}
		}
		deque<ll> Q;
		trav(x,P)
		{
			Q.pb(x);
		}
		ll op=0;
		while(sz(Q)>1)
		{
			ll l=Q.front();
			ll r=Q.back();
			Q.pop_front();
			Q.pop_back();
			ll t=min(l,x-r);
			r=(r+t)%x;
			l=l-t;
			op+=t;
			if (l!=0)
			{
				Q.pf(l);
			}
			if (r!=0)
			{
				Q.pb(r);
			}
		}
		if (sz(Q)==0 && op<=K)
		{
			ans=max(ans,x);
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, M, X, Y int
	fmt.Scan(&N, &M, &X, &Y)
	x := make([]int, N)
	for i := range x {
		fmt.Scan(&x[i])
	}
	y := make([]int, M)
	for i := range y {
		fmt.Scan(&y[i])
	}
	x = append(x, X)
	y = append(y, Y)
	sort.Ints(x)
	sort.Ints(y)
	// fmt.Printf("[d0] %v, %v\n", x, y)
	if y[0]-x[len(x)-1] > 0 {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}


Measured memory_bytes: 512
def main():
    S = list(map(int, list(input())))
    cnt1, cnt2 = 0, 0
    for i, s in enumerate(S):
        if i % 2 == 0:
            if s:
                cnt1 += 1
            else:
                cnt2 += 1
        else:
            if s:
                cnt2 += 1
            else:
                cnt1 += 1
    print(min(cnt1, cnt2))


if __name__ == '__main__':
    main()

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

int main(){
	string str[]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
	double up[]={0,3.0,3.0,3.0,3.0,4.0,5.0,6.0,6.0,10.0,0};
	double n;
	int i;
	while(cin >> n){
		if(n <=48.0) cout << str[0] << endl;
		else if(n > 91.0) cout << str[10] << endl;
		else {
			double wei = 48.0;
			for(i=1;i<10;i++){
				if(n > wei && n <= wei+up[i]){
					cout << str[i] << endl;
					break;
				}
				wei += up[i];
			}
		}
	}
}

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

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

    queue<int> a;

    for (int i = 0; i < N; i++)
    {
        cin >> in;
        a.push(in);
    }

    int count = 0, number = 1;
    bool flag_1 = false;

    for (int i = 0; i < N; i++)
    {
        if (a.front() != number)
            count++;

        else
        {
            flag_1 = true;
            number++;
        }

        a.pop();
    }

    if (flag_1)
        cout << count << endl;

    else
        cout << -1 << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  map<int, int> ms;
  ms[A]++;
  ms[B]++;
  ms[C]++;
  if(ms.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
long long a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    cin >> a >> b >> c;
    pr((a - c) / (b + c));
    return 0;
}


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

int main(){
    int n; cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    vector<pair<string,pair<int,int> > > v;
    for(int i=0;i<n;i++){
        cin >> s[i] >> p[i];
        v.push_back(make_pair(s[i],make_pair(-p[i],i+1)));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        cout << v[i].second.second << endl;
    }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t n;
    std::cin >> n;

    std::deque<int64_t> deq;
    int64_t rem = n % 2;
    for (int64_t i = 0; i < n; i++)
    {
        int64_t a;
        std::cin >> a;
        if (i % 2 == rem) deq.push_back(a);
        else deq.push_front(a);
    }

    for (int64_t i = 0; i < n - 1; i++)
    {
        std::cout << deq[i] << " "; 
    }
    std::cout << deq[n - 1] << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	int x;
	cin >> x;
	x %= 1000;
	x = 1000 - x;
	if (x == 1000) x = 0;
	cout << x << "\n";
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

struct uf_tree
{
    vector<int> par, rank;
    uf_tree(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x)
    {
        if (x == par[x])
            return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);

        if (x == y)
            return;

        if (rank[x] < rank[y])
            swap(x, y);
        par[y] = x;
        rank[x] += rank[y];
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    int size(int x)
    {
        return rank[par[x]];
    }
};

int main()
{
    int n, k, l;
    cin >> n >> k >> l;

    uf_tree street(n), train(n);
    rep(i, k)
    {
        int p, q;
        cin >> p >> q;
        --p, --q;
        street.unite(p, q);
    }

    rep(i, l)
    {
        int r, s;
        cin >> r >> s;
        --r, --s;
        train.unite(r, s);
    }

    map<pii, int> mp;

    rep(i, n)
        mp[pii(street.find(i), train.find(i))]++;

    rep(i, n)
    {
        cout << mp[pii(street.find(i), train.find(i))];
        if (i != n - 1)
            cout << " ";
    }

    return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007



// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main(){
    vector<int> foo(4);
    rep(i,4) cin>>foo[i];
    SORT(foo);
    if(foo[0]==1&&foo[1]==4&&foo[2]==7&&foo[3]==9){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 123456789
//0x3f3f3f3f
#define INFL 10000000000000000
#define SIZE 100005
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;
int N,M;
vector<pair<pair<int,ll>,bool> > hen[SIZE];
struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -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)]; }
};
bool used[SIZE];
ll xza[SIZE];
bool checked[SIZE];
bool ans;
void dfs(int i){
	for(int j=0;j<hen[i].size();j++){
		bool hoge=hen[i][j].second;
		pair<int,ll> fuga=hen[i][j].first;
		int to=fuga.first;
		ll d=fuga.second;
		//cout<<d<<endl;
		if(hoge==true){
			hen[i][j].second=false;
			if(used[to]==false){
				used[to]=true;
				xza[to]=xza[i]+d;
				dfs(to);
			}else{
				if(xza[to]-xza[i]!=d)ans=false;
			}
		}
	}
}
int main(){
	cin>>N>>M;
	ans=true;
	rep(i,SIZE)used[i]=false,xza[i]=0;
	UnionFind uf;
	uf.init(N);
	for(int i=0;i<M;i++){
		int l,r;
		ll d;
		cin>>l>>r>>d;l--;r--;
		uf.unionSet(l,r);
		hen[l].pb(mp(mp(r,d),true));
		hen[r].pb(mp(mp(l,-d),true));
	}
	vi rts;
	for(int i=0;i<N;i++){
		if(uf.root(i)==i)rts.pb(i);
	}
	for(int i=0;i<rts.size();i++){
		//cout<<rts[i]<<endl;
		int ne=rts[i];
		xza[ne]=(ll)0;
		used[ne]=true;
		dfs(ne);
	}
	//rep(i,N)cout<<xza[i]<<endl;
	if(ans){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}



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

int main()
{
    string N;
    cin >> N;
    char count = 0;
    for (char n : N)
    {
        count += n - '0';
        count %= 9;
    }
    if (count % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

#A
def A():
    n = II()
    print(n//3)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


Measured memory_bytes: 39884
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  string s;
  cin>>n>>m>>s;
  if((int)s.at(m-1)<=90) s.at(m-1)+=32;
  else s.at(m-1)-=32;
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	int K;
	cin>>K;
	vector<ll> cands;
	rep(t,15){
		rep(v,1000){
			ll a = v+1;
			rep(i,t) a*=10;
			a--;
			cands.pb(a);
		}
	}
	sort(all(cands));
	cands.erase(unique(cands.begin(),cands.end()),cands.end());
	int N = cands.size();
	vector<double> d(N,0);
	vector<double> acd(N+1,0);
	acd[N] = 1e18;
	rep(i,N){
		ll n = cands[i];
		int s = 0;
		{
			ll tmp = n;
			while(tmp){
				s += tmp%10;
				tmp/=10;
			}
		}
		d[i] = (double)n/s;
	}
	for(int i=N-1;i>=0;i--){
		acd[i] = min(acd[i+1],d[i]);
	}
	double eps = 1e-9;
	vector<ll> ans;
	rep(i,N){
		if(d[i]<acd[i+1]+eps) ans.pb(cands[i]);
	}
	rep(i,K) cout<<ans[i]<<endl;
}

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

const int kNmax = 2010;
const int kInf = numeric_limits<int>::max();

int n, z, w, x;
vector<int> v;
int dp[kNmax][2];

int main() {
  scanf("%d %d %d", &n, &z, &w);
  v.push_back(z);
  v.push_back(w);
  
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    v.push_back(x);
  }
  
  for (int pos = n; pos > 0; pos--) {
    dp[pos][0] = -kInf;
    for (int next_pos = pos + 1; next_pos < n + 2; next_pos++) {
      if (next_pos < n + 1) {
        dp[pos][0] = max(dp[pos][0], dp[next_pos][1]);
      } else {
        dp[pos][0] = max(dp[pos][0], abs(v.back() - v[pos]));
      }
    }
    
    dp[pos][1] = kInf;
    for (int next_pos = pos + 1; next_pos < n + 2; next_pos++) {
      if (next_pos < n + 1) {
        dp[pos][1] = min(dp[pos][1], dp[next_pos][0]);
      } else {
        dp[pos][1] = min(dp[pos][1], abs(v.back() - v[pos]));
      }
    }
  }
  
  printf("%d\n", dp[1][0]);
}

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

int h, w, n, x[11], y[11];
string buff = "S123456789";

char mas[1000][1000];

int bfs(){
  int dy[] = { 0, 1, 0, -1}, dx[] = { 1, 0, -1, 0};
  int min_cost[1000][1000];
  deque< int > quex, quey;

  int ret = 0;
  for(int i = 0; i < n; i++){
    fill_n( *min_cost, 1000 * 1000, 1 << 30);
    quey.push_back(y[i]), quex.push_back(x[i]);
    min_cost[y[i]][x[i]] = 0;
    while(!quey.empty()){
      int py = quey.front(), px = quex.front();
      quey.pop_front(), quex.pop_front();
      if(py == y[i + 1] && px == x[i + 1]){
        ret += min_cost[py][px];
        break;
      }
      for(int i = 0; i < 4; i++){
        int ny = py + dy[i], nx = px + dx[i];
        if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        if(mas[ny][nx] == 'X') continue;
        if(min_cost[py][px] + 1 < min_cost[ny][nx]){
          min_cost[ny][nx] = min_cost[py][px] + 1;
          quey.push_back(ny), quex.push_back(nx);
        }
      }
    }
    quey.clear(), quex.clear();
  }
  return ret;
}

int main()
{
  cin >> h >> w >> n;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> mas[i][j];
      if(buff.find(mas[i][j]) != string::npos){
        y[buff.find(mas[i][j])] = i;
        x[buff.find(mas[i][j])] = j;
      }
    }
  }
  cout << bfs() << endl;
}

Measured memory_bytes: 6104
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,x[N],a[N],b[N],c[N],p[N];long long kk;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
int main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",&x[i]);
	scanf("%d%lld",&m,&kk);
	rep(i,1,n-1)a[i]=b[i]=i;
	rep(i,1,m){int y;scanf("%d",&y);swap(a[y-1],a[y]);}
	for(;kk;kk>>=1){
		if(kk&1)
		rep(i,1,n-1)b[i]=a[b[i]];
		rep(i,1,n-1)c[i]=a[a[i]];
		rep(i,1,n-1)a[i]=c[i];
	}
	long long ans=x[1];
	rep(i,1,n){
		printf("%lld.0\n",ans);
		ans+=x[b[i]+1]-x[b[i]];
	}
}

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

int main(){
  int n;
  cin >> n;
  std::vector<int> d(n);
  int count = 0;
  rep(i, n){
    cin >> d.at(i);
  }
  rep(i, n){
    for(int j = i + 1; j < n; j++){
      count += d.at(i) * d.at(j);
    }
  }
  std::cout << count << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A, B, C;
    int n;

    scanf("%d%d%d", &A, &B, &C);
    
    n = (C / (7 * A + B)) * 7;
    
    C %= (7 * A + B);
    
//    printf("<n=%d C=%d>", n, C);
    
    if (C / A >= 7){
        n += 7;
    }
    else {
        n += C / A;
        if (C % A != 0){
            n++;
        }
    }


    printf("%d\n", n);
    
    return (0);
}



Measured memory_bytes: 2140
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
int GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
   ll a,b,n;
   cin>>a>>b>>n;
   if(b==1){
       cout<<0<<"\n";
       return 0;
   }
   ll t=min(n,b-1);
   cout<<a*t/b-a*(t/b)<<"\n";
}

Measured memory_bytes: 3648
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <boost/range/adaptors.hpp>
#include <iomanip>
#include <tuple>
#include <numeric>

std::map<int64_t, int> prime_factor(int64_t n) {
  std::map< int64_t, int> ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

std::vector< int64_t > divisor(int64_t n) {
  std::vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    long N;
    std::cin >> N;

    auto result = prime_factor(N - 1);
    long long count = 1;
    for(auto p : result) {
        count *= (p.second + 1);
        // std::cout << p.first << ": " << p.second << std::endl;
        // while(p.second--) std::cout << " " << p.first;
    }
    --count;

    auto result_ = divisor(N);
    for (int i = 1; i < result_.size() - 1; ++i) {
        // if (result_[i] * result_[i] > N) {
        //     break;
        // }
        // std::cout << result_[i] << std::endl;
        // std::cout << result_[i] * result_[i] << std::endl;
        // std::cout << N << std::endl;
        auto value = N;
        while (value % result_[i] == 0) value = value / result_[i];
        if (value % result_[i] == 1) ++count;
    }
    ++count;
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int N;
    int M;
    int L[100001];
    int R[100001];
    int i;
    scanf("%d",&N);
    scanf("%d",&M);
    for(i=1;i<=M;i++){
        scanf("%d",&L[i]);
        scanf("%d",&R[i]);
    }
    int l;
    int r;
    l=1;
    r=N;
    for(i=1;i<=M;i++){
        if(L[i]>l){
            l=L[i];
        }
        if(R[i]<r){
            r=R[i];
        }
    }
    int ans;
    ans=r-l+1;
    if(ans<0){
        ans=0;
    }
    printf("%d",ans);
}

Measured memory_bytes: 896
import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s,edge,n):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

def main():
    N = int(input())
    edge = [[] for i in range(N)]
    for i in range(N-1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        edge[u].append([w,v])
        edge[v].append([w,u])
    d = dijkstra_heap(0,edge,N)
    for i in range(N):
        if d[i] % 2 == 0:
            print(0)
        else:
            print(1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 91864
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        var A = new Dictionary<long, long>();
        long sum = 0;
        A[0] = 1;
        for (int i = 0; i < N; i++)
        {
            sum += cin.nextint;
            //Write(sum + " ");
            if (A.ContainsKey(sum))
            {
                A[sum]++;
            }
            else
            {
                A[sum] = 1;
            }
        }

        long ans = 0;
        foreach (var item in A.Values)
        {
            ans += item * (item - 1) / 2;
        }

        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 40688
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll x;
	cin >> x;
	ll n = 100;
	for (ll i = 1; i <= 10000000; i++)
	{
		n *= 1.01;
		if (n >= x)
		{
			cout << i << endl;
			ret;
		}
	}

	return 0;
}

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

#define debug(x) cout << #x << ": " << (x) << endl

typedef pair<double, int> PDI;

struct edge { int to; double cost; };
struct xyr { int x, y, r; };
typedef vector<vector<edge> > Graph;

const double INF = numeric_limits<double>::infinity();

double djikstra(const Graph &G, int s, int t) {
  int V = G.size();
  double dist[V];
  bool done[V];
  priority_queue<PDI, vector<PDI>, greater<PDI> > pq;
  fill(dist, dist + V, INF);
  fill(done, done + V, false);
  pq.push(make_pair(0.0, s));

  while (not pq.empty()) {
    auto cv = pq.top(); pq.pop();
    double cost = cv.first;
    int v = cv.second;
    done[v] = true;
    for (int i = 0; i < G[v].size(); ++i) {
      const edge &e = G[v][i];
      double new_cost = cost + e.cost;
      if (new_cost < dist[e.to] and not done[e.to]) {
        dist[e.to] = new_cost;
        pq.push(make_pair(new_cost, e.to));
      }
    }
  }
  return dist[t];
}

int main() {
  int N;
  int xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;
  cin >> N;
  xyr xyrs[N + 2];
  xyrs[N] = xyr{xs, ys, 0};
  xyrs[N + 1] = xyr{xt, yt, 0};
  for (int i = 0; i < N; ++i) {
    int x, y, r;
    cin >> x >> y >> r;
    xyrs[i] = xyr{x, y, r};
  }

  Graph G(N + 2);
  for (int i = 0; i < G.size(); ++i) {
    const xyr &x = xyrs[i];
    for (int j = i + 1; j < G.size(); ++j) {
      const xyr &x2 = xyrs[j];
      double cost = max(0.0, sqrt(pow(x.x - x2.x, 2) + pow(x.y - x2.y, 2)) - x.r - x2.r);
      G[i].push_back(edge{j, cost});
      G[j].push_back(edge{i, cost});
    }
  }

  cout << fixed << setprecision(10) << djikstra(G, N, N + 1) << endl;
  return 0;
}


Measured memory_bytes: 22768
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue<Long> value = new PriorityQueue<>(Comparator.reverseOrder());
        for(int i = 0; i < n; ++i) value.add(sc.nextLong());
        for(int i = 0; i < m; ++i) {
            long lo = value.poll();
            value.add(lo >> 1);
        }
        
        long ans = 0;
        for(long v : value) ans += v;
        System.out.println(ans);
    }
}


Measured memory_bytes: 62260
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

int n;

string s[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};

vector<int> v;
vector<string> ans;

void dfs(int depth, string now, int use){
    if(depth == n){
        ans.emplace_back(now);
        return;
    }
    for (int i = 0; i < 10; i++){
        if(i > use) break;
        dfs(depth + 1, now + s[i], max(use, i + 1));
    }
}

signed main() {
    cin >> n;
    dfs(0, "", 0);
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 7796
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<int> boll(n+10,0);
  for(int i=0;i<n;i++){
    int a;cin>>a;
    boll[a]++;
  }
  sort(boll.begin(),boll.end(),greater<int>());
  ll ans=0;
  for(int i=0;i<k;i++){
    ans+=boll[i];
  }
  cout<<n-ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <utility>
 
using namespace std;


int main() {

string s;

long int K;

cin >>s;
cin >>K;

long int l;
l=s.size();

int n[100];

for(int i=0; i<l;i++){
n[i]=s[i]-'0';
}

int ans=1;

for(int i=0; i<min(l,K); i++){
if(n[i]!=1){ans=n[i]; break;}
}

cout <<ans;


}



Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=-1,n,num=0,fin=0;
    cin >>n;
    ll in[n+1];
    ll out[n+1];
    bool flag=true;
    for(int i=1;i<=n;i++){
        cin>>in[i];
        out[i]=0;
    }
    for(int i=n;i>0;i--){
        if(in[i]==0){
            for(int j=i+i;j<=n;j+=i){
                out[i]^=out[j];
            }
            if(out[i]==1){
                fin=i,num++;
            }
        }else{
            for(int j=i+i;j<=n;j+=i){
                out[i]^=out[j];
            }
            out[i]=(out[i]+1)%2;
            if(out[i]==1)fin=i,num++;;
        }
    }
    if(!flag)cout<<"-1"<<endl;
    else{
        cout<<num<<endl;
        for(int i=n;i>0;i--){
            if(out[i]==1){
                cout<<i;
                if(i>fin)cout<< " ";
                else cout<<endl;

            }
        }
    }


    return 0;

}

Measured memory_bytes: 3968
#include <iostream>
#include <queue>
using namespace std;
static const int N = 100;
static const int INF = (1 << 21);

int n, M[N][N];
int d[N];

void BFS(int s){
	queue<int> q;
	q.push(s);
	for (int i = 0; i < n; i++) {
		d[i] = INF;
	}
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front();
		q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 1 && d[v] == INF) {
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i+1 << " " << ( (d[i] == INF) ? -1 : d[i]) << endl;
	}
}
int main(int argc, char *argv[]) {
	int u, k, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = 0;
		}
	}
	
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	BFS(0);
	return 0;
}


Measured memory_bytes: 3112
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

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

    g = tuple(set() for _ in range(N))
    for _ in range(M):
        a, b = (int(x) - 1 for x in input().split())
        g[a].add(b)
        g[b].add(a)

    dist = [-1] * N
    par = [-1] * N
    dist[0] = 0
    dq = deque([0])
    while dq:
        v = dq.popleft()
        d = dist[v]
        for u in g[v]:
            if ~dist[u]: continue
            dist[u] = d + 1
            par[u] = v + 1
            dq.append(u)

    print('Yes')
    print(*par[1:], sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 68496
K = int(input())

if K <= 9:
    print (K)
    exit()

lst = [[1] * 11 for _ in range(2)]
lst_append = lst.append
lst[0][10] = 0
lst[1][0] = 0
lst[1][10] = 0

now = 9
p = 0
flag = 0
while True:
    if p == 0:
        lst[flag + 1][0] = lst[flag][0] + lst[flag][1]
        p += 1
        continue
    tmp = lst[flag][p - 1] + lst[flag][p] + lst[flag][p + 1]
    lst[flag + 1][p] = tmp
    if now + tmp >= K:
        break
    now += tmp
    p += 1

    if p == 10:
        p = 0
        flag += 1
        lst_append([0] * 11)

# print ('now', now)
# print ('p', p)
# print ('flag', flag)
# print (lst[0])
# print (lst[1])

#先頭がpでかつ現在地がnow
ans = str(p)
flag += 1
while True:
    if flag == 0:
        break
    # print (p)
    if p >= 1 and K <= now + lst[flag - 1][p - 1]:
        flag -= 1
        ans += str(p - 1)
        p -= 1
    elif K <= now + lst[flag - 1][p - 1] + lst[flag - 1][p]:
        now += lst[flag - 1][p - 1]
        flag -= 1
        ans += str(p)
    else:
        now += lst[flag - 1][p - 1] + lst[flag - 1][p]
        flag -= 1
        ans += str(p + 1)
        p += 1

print (ans)

# for tmp in lst:
#     print (tmp)
    

Measured memory_bytes: 3064