akhauriyash/Code-Regression huggingface dataset:
// AtCoder.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#pragma once



#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

long long A, B, C, D, K, M, N, X, Y, Z;
long long a[10000];
char ch;
vector <long long>vl;
string S;


int main()
{

	cin >> N >> K >> S;
	B = 0;
	C = 0;
	D = 0;
	X = 0;
	Y = 0;
	A = S[0] - '0';
	Z=A;

	for (int i = 0; i < S.size(); i++) {


		if (Z == S[i] - '0') {
			D++;
		}
		else {
			vl.push_back(D);
			D = 1;
			Z++;
			Z %= 2;
		}

	}

	if (D > 0) {
		vl.push_back(D);
	}


	if (vl.size() == 1) {
		C = N;
		

	}
	else {
		for (int i = 0; i < vl.size() && i < K * 2; i++) {
			B += vl[i];
			X = i;
		}

		if (A == 1) {

			if (X == vl.size() - 1) {

			}
			else {
				B += vl[X + 1];
				X++;
			}

			C = B;

			B -= vl[0] + vl[1];
			Y = 2;

			while (X < vl.size() - 1) {
				if (X < vl.size() - 2) {
					B += vl[X + 1] + vl[X + 2];
				}
				else {
					B += vl[X + 1];
				}

				X += 2;

				if (C < B) {
					C = B;
				}

				B -= vl[Y] + vl[Y + 1];
				Y += 2;

			}

		}
		else {

			C = B;

			if (vl.size() >= 2) {
				B -= vl[0];
				Y = 1;
			}

			while (X < vl.size() - 1) {
				if (X < vl.size() - 2) {
					B += vl[X + 1] + vl[X + 2];
				}
				else {
					B += vl[X + 1];
				}

				X += 2;

				if (C < B) {
					C = B;
				}


				if (Y < vl.size() - 2)
					B -= vl[Y] + vl[Y + 1];
				Y += 2;

			}
		}
	}

	cout << C << endl;

	return 0;
}



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

using namespace std;

typedef long long ll;

int main(void) {
  int W, H, x, y;
  cin >> W >> H >> x >> y;

  double s = ((double)W * (double)H) / 2;

  bool d = ((x << 1) == W) && ((y << 1) == H);
  cout << fixed << setprecision(10) << s << " " << (d ? 1 : 0) << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

 public static void main(String[] args) {
     
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = in.nextInt(); // Scanner has functions to read ints, longs, strings, chars, etc.
    HashMap<Integer,Integer> map = new HashMap();
    //System.out.println(N);
    
    for(int i = 1; i <= N-1; i++) {
        int n = in.nextInt();
        if(map.containsKey(n)) map.put(n, map.get(n)+1);
        else map.put(n, 1);
    }
    
    for(int i = 1; i <= N; i++){
        if(map.containsKey(i)) {
            System.out.println(map.get(i));
        }
        else {
            System.out.println(0);
        }
    }
    
  }
  
}

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

using namespace std;
const int N=3e3+5;

double a[N];
double dp[N][N];
int main()
{
    int n,m;
    cin>>n;

    for(int i=1;i<=n;i++){
      cin>>a[i];
    }
    dp[0][0]=1.0;
    for(int coin=1;coin<=n;++coin){
        for(int head=0;head<=coin;++head){
            if(head)dp[coin][head]+=dp[coin-1][head-1]*a[coin];
            dp[coin][head]+=dp[coin-1][head]*(1-a[coin]);
        }
    }
    double res=0.0;
    for(int i=1;i<=n;++i){
        if(i > n-i){
            res+=dp[n][i];
        }
    }
    printf("%.10f\n", res);
    return 0;
}




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

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef long long ll;
typedef long double ld;



int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int a[n];
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    map<int,int> h;
    rep(i,0,n){
        h[a[i]]++;
    }
    if(h.size()>2){
        cout<<"No"<<endl;
        return 0;
    }
    if(h.size()==1){
        int temp = a[0];
        if( temp==n-1 || (2*temp<=n) ){
            cout<<"Yes"<<endl;
            return 0;
        }
        cout<<"No"<<endl;
        return 0;
    }
    auto it = h.begin();
    auto it1 = h.begin();it1++;
    if((*it1).F != (*it).F + 1){
        cout<<"No"<<endl;
        return 0;
    }
    int temp = (*it).F + 1;
    if(temp <= (*it).S + ((*it1).S/2) && (temp >= (*it).S + 1) && ((*it1).S>=1) ){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
void dbg(){cerr<<endl;}
template<typename A,typename... B>void dbg(A x,B... y){cerr<<x<<" ";dbg(y...);}
#define debug(...) cerr<<#__VA_ARGS__<<"=",dbg(__VA_ARGS__)
int head[N],tot,f[N],g[N],d[N],ans;
struct Edge{int v,next;}edge[N];
inline void add(int x,int y){edge[++tot]=Edge{y,head[x]};head[x]=tot;}
void dfs(int x,int la=0)
{	for(rint i=head[x];i;i=edge[i].next)
	if(to!=la)
	{	dfs(to,x);
		if(f[to]>f[x]) g[x]=f[x],f[x]=f[to];
		else if(f[to]>g[x]) g[x]=f[to];
	}
	f[x]+=d[x]==2; ans=max(ans,f[x]+g[x]);
}
int main()
{	int n,x,y; cin>>n;
	for(rint i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x),d[x]++,d[y]++;
	dfs(1); for(rint i=1;i<=n;i++) ans+=d[i]==1; cout<<ans;
	return 0;
}



Measured memory_bytes: 12032
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

const int N=100010;
int n;
vector<int> ans[N];

int main() {
	scanf("%d",&n);
	int m;n<<=1;
	for(m=1;m*(m-1)<=n;m++) {
		if(m*(m-1)==n) break;
	}
	if(m*(m-1)!=n) return puts("No"),0;
	puts("Yes");int p=0;
	printf("%d\n",m);
	for(int i=1;i<=m;i++) {
		int q=i;
		while(ans[i].size()<m-1) {
			ans[i].pb(++p);
			ans[++q].pb(p);
		}
	}
	for(int i=1;i<=m;i++) {
		printf("%d ",ans[i].size());
		for(int j:ans[i]) printf("%d ",j);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

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

ll mod(ll val, ll M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

// N^P mod M（ただしM == -1の時はmodを取らない）
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

ll fac[1000010], finv[1000010], inv[1000010];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000010; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  	ll N,M,K;
    cin >> N >> M >> K;
    COMinit();
    ll ret = 0;
    for(ll i = 0;i < N;i++) {
        ret = (ret + i * (N - i) * M * M) % MOD;
    }
    for(ll i = 0;i < M;i++) {
        ret = (ret + i * (M - i) * N * N) % MOD;
    }
    ret *= COM(N * M - 2,K - 2);
    ret %= MOD;
    cout << ret << endl;
}

Measured memory_bytes: 27072
#!/usr/bin/env python3
# coding: utf-8
# Last Modified: 03/May/20 05:49:15 PM


import sys


def main():
    arr = []
    for i in range(-(10 ** 4), 10 ** 4):
        arr.append((pow(i, 5), i))
    x = int(input())
    from bisect import bisect_left

    ans = False
    A, B = -1, -1
    for i in arr:
        c = i[0] - x
        idx = bisect_left(arr, (c, -(10 ** 20)))

        if idx < len(arr) and arr[idx][0] == c:
            ans = True
            A = i[1]
            B = arr[idx][1]
            break
    print(A, B)


get_array = lambda: list(map(int, sys.stdin.readline().split()))


get_ints = lambda: map(int, sys.stdin.readline().split())


input = lambda: sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 75444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin>>n;
  int64_t x=1;
  bool a=false;
  bool b=false;
  vector<int64_t>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    if(vec.at(i)==0){
      a=true;
      break;
    }
  }
  
  for(int i=0;i<n;i++){
    if(vec.at(i)<=1000000000000000000/x){
      x*=vec.at(i);
      
    }
    else {b=true;
         break;
         }
  }
  if(a){
    cout<<"0"<<endl;}
  else if(b){
    cout<<"-1"<<endl;}
  else{cout<<x<<endl;}
}


Measured memory_bytes: 3940
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n, k, q; cin >> n >> k >> q;
  vector<lint> a(n + 2, -INF);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  
  lint ans = INF;
  n = a.size();
  for (int id = 1; id < n - 1; id++) {
    lint Y = a[id];
    // 最大値 X を最小化する

    vector<vector<lint>> g;
    // Y 以上からなる区間に分割
    for (int i = 0; i < n - 1; i++) {
      if (a[i] < Y) {
        vector<lint> add;
        for (int j = i + 1; a[j] >= Y; j++) {
          add.push_back(a[j]);

          if (a[j] >= Y) {
            i = j;
          }
        }
        g.push_back(add);
      }
    }

    /*
    for (int i = 0; i < g.size(); i++) {
      for (int j = 0; j < g[i].size(); j++) {
        cout << g[i][j] << " ";
      }
      cout << endl;
    }
    */

    vector<lint> canTake;

    for (int i = 0; i < g.size(); i++) {
      if (g[i].size() == 0) continue;
      sort(ALL(g[i]));

      for (int j = 0; j < (int)g[i].size() - k + 1; j++) {
        canTake.push_back(g[i][j]);
      }
    }
    if (canTake.size() == 0) continue;
    sort(ALL(canTake));

    if (q > canTake.size()) {
      continue;
    } else {
      lint X = canTake[q - 1];
      assert(X >= Y);
      ans = min(ans, X - Y);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
# 超参考：https://atcoder.jp/contests/arc096/submissions/7526451
N, C = gets.split.map(&:to_i)
sushi = N.times.map { gets.split.map(&:to_i) }

def solve(sushi)
  sumv = 0
  prev = 0
  # 進んで、方向転換して始点に戻るまでに得るカロリ
  gain = [0] + sushi.reverse_each.map { |x, v|
    sumv += v
    prev = [sumv - 2 * (C - x), prev].max
  }
  sumv = 0
  ans = (0...N).map { |i|
    x, v = sushi[i]
    sumv += v
    sumv - x + gain[-i - 2]
  }.max
  ans
end

p [0, solve(sushi), solve(sushi.reverse.map { |x, v| [C - x, v] })].max


Measured memory_bytes: 21084
#include <stdio.h>

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

Measured memory_bytes: 1024
n = int(input())
s = str(input())

a = [(0,0) for _ in range(n + 1)]
b = []
for i in range(n):
    if s[i] == "W":
        a[i+1] = (a[i][0] + 1,a[i][1])
    else:
        a[i+1] = (a[i][0],a[i][1] + 1)
    b.append(a[i+1][1]-a[i+1][0])
    
ans = s[0:b.index(max(b))].count('W') + s[b.index(max(b))+1:].count('E')
print(ans)

Measured memory_bytes: 46400
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
int ctoi(char c){return (int)c-(int)'0';}
int main() {
    string N;
    int K;
    cin>>N>>K;
    int d=N.size();
    vvi dp0(d,vi(K,0));
    vvi dp1(d,vi(K,0));
    dp0[0][0]=ctoi(N[0])-1;
    dp1[0][0]=1;
    for (int i = 1; i < d; i++){
        dp0[i][0]=dp0[i-1][0]+9;
        if(ctoi(N[i])>0)dp0[i][0]+=dp1[i-1][0];
        else dp1[i][0]=dp1[i-1][0];
        for (int k = 1; k < K; k++){
            dp0[i][k]=dp0[i-1][k-1]*9+dp0[i-1][k];
            if(ctoi(N[i])>0){
                dp0[i][k]+=dp1[i-1][k-1]*(ctoi(N[i])-1)+dp1[i-1][k];
                dp1[i][k]=dp1[i-1][k-1];
            }else dp1[i][k]=dp1[i-1][k];
        }
    }
    cout<<dp0[d-1][K-1]+dp1[d-1][K-1]<<endl;
}

Measured memory_bytes: 3600
# https://atcoder.jp/contests/abs/tasks/abc085_c

val = [10000, 5000, 1000]

n, y = map(int, input().split())

mx = [y // i for i in val]
nm = [0, 0, 0]
an = [-1, -1, -1]  # 回答入れ
is_find = False

for nm[0] in range(min(n, mx[0]) + 1):
    for nm[1] in range(min(n, mx[1]) + 1):
        nm[2] = n - nm[0] - nm[1]
        if nm[2] < 0:
            break
        elif nm[0] * val[0] + nm[1] * val[1] + nm[2] * val[2] == y and nm[2] >= 0:
            an = nm
            is_find = True
            break
    if is_find:
        break

print("{} {} {}".format(an[0], an[1], an[2]))
pass


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main{
	
	static long mod=(long)1e9+7;
	
	public static void main(String[] args) throws IOException {
		Writer out=new Writer(System.out);
		Reader in=new Reader(System.in);
		int ts=1;
		
		outer: while(ts-->0) {	
			int n=in.nextInt();
			long sum=0;
			for(int i=1; i<=n; i++) {
				if(i%3!=0 && i%5!=0) sum+=i; 
			}
			out.println(sum);
		}
		out.close();		
		
	}

	static boolean tri(int a, int b, int c) {
		if(c<a+b && c>abs(a-b)) return true;
		return false;
	}
	
	
/*********************************** UTILITY CODE BELOW **************************************/	
		
	static int abs(int a) {
		return a>0 ? a : -a;
	}
	
	static int max(int a, int b) {
		return a>b ? a : b;
	}
	
	static int pow(int n, int m) {
		if(m==0) return 1;
		int temp=pow(n,m/2);
		long res=(((long)temp*temp)%mod);
		if(m%2==0) return (int)res;
		return (int)((res*n)%mod);
	}
	
	static class Pair{
		int u, v;
		
		Pair(int u, int v){this.u=u; this.v=v;}
		
		static void sort(Pair [] coll) {		
			List<Pair> al=new ArrayList<>(Arrays.asList(coll));
			Collections.sort(al,new Comparator<Pair>() {
				public int compare(Pair p1, Pair p2) {
					return p1.u-p2.u;
				}	
			});
			for(int i=0; i<al.size(); i++) {
				coll[i]=al.get(i);
			}
		}
		
	}
	
	static void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static void sort(long a[]) {
		ArrayList<Long> list=new ArrayList<>();
		for(long i: a) list.add(i);
		Collections.sort(list);
		for(int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static int [] array(int n, int value) {	
		int a[]=new int[n];
		for(int i=0; i<n; i++) a[i]=value;
		return a;
	}
	
	static class Reader{
		
		BufferedReader br;
		StringTokenizer to;
		
		Reader(InputStream stream){
			br=new BufferedReader(new InputStreamReader(stream));
			to=new StringTokenizer("");
		}
		
		String next() {
			while(!to.hasMoreTokens()) {
				try {
					to=new StringTokenizer(br.readLine());	
				}catch(IOException e) {}
				
			}
			return to.nextToken();
			
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0; i<n ;i++) a[i]=nextInt();
			return a;
		}
		long [] readLongArray(int n) {
			long a[]=new long[n];
			for(int i=0; i<n ;i++) a[i]=nextLong();
			return a;
		}
		
	}
	
	static class Writer extends PrintWriter{
		Writer(OutputStream stream){
			super(stream);
		}
		void println(int [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
		void println(long [] array) {
			for(int i=0; i<array.length; i++) {
				print(array[i]+" ");
			}
			println();
		}
	}
	
}

Measured memory_bytes: 32840
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e3 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n;
char s[Maxn][Maxn];
string S[4][7] = {{"abcc", "abdd", "ccab", "ddab"},
				  {"abbcc", "ad..a", "bd..a", "b.eez", "xxyyz"},
				  {"xxyyzz", ".a.b.c", ".a.b.c", "d.e.f.", "d.e.f.", "xxyyzz"},
				  {".xxyyzz", "xabb...", "xa.c...", "yddc...", "y...abb", "z...a.c", "z...ddc"}};
int main()
{
	cin >> n;
	if (n <= 2)
		return puts("-1"), 0;
	if (n == 3)
	{
		puts("a..");
		puts("a..");
		puts(".bb");
		return 0;
	}
	for (rg int i = 1; i <= n; i++)
		for (rg int j = 1; j <= n; j++)
			s[i][j] = '.';
	int m = 1, x = 4 + n % 4;
	for (int i = 0; i < x; i++)
		for (int j = 0; j < x; j++)
			s[m + i][m + j] = S[x - 4][i][j];
	m += x;
	while (m <= n)
	{
		for (int i = 0; i < 4; i++)
			for (int j = 0; j < 4; j++)
				s[m + i][m + j] = S[0][i][j];
		m += 4;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
			printf("%c", s[i][j]);
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

typedef long long int llint;
const llint BIGNUM = 10000000000000L;

std::vector<std::vector<llint> > 
warshall_floyd(const std::vector<std::vector<llint> > &d_mat){
  int loops = d_mat.size(); // num of points

  std::vector<std::vector<llint> >  distance_matrix = d_mat; // initialize
  for(int k=0; k<loops; k++){
    for(int i=0; i<loops; i++){
      for(int j=0; j<loops; j++){
	if(distance_matrix[i][j] > distance_matrix[i][k] + distance_matrix[k][j])
	  distance_matrix[i][j] = distance_matrix[i][k] + distance_matrix[k][j];
      }
    }
  }
  return distance_matrix;
}

int main(void){
  llint n,m,l;
  std::cin >> n >> m >> l;

  std::vector<std::vector<llint> > d_mat(n+1, std::vector<llint>(n+1, BIGNUM));
  for(int i=0; i<m; i++){
    int a, b, c;
    std::cin >> a >> b >> c;
    d_mat[a][b] = c;
    d_mat[b][a] = c;
  }

  d_mat = warshall_floyd(d_mat);
  for(int i=0; i<d_mat.size(); i++){
    for(int j=0; j<d_mat[i].size(); j++){
      if(d_mat[i][j] <= l) d_mat[i][j] = 1;
      else                 d_mat[i][j] = BIGNUM;
    }
  }

  d_mat = warshall_floyd(d_mat);

  llint q;
  std::cin >> q;
  for(int i=0; i<q; i++){
    int a,b;
    std::cin >> a >> b;
    if(d_mat[a][b] == BIGNUM) std::cout << -1 << std::endl;
    else                      std::cout << d_mat[a][b]-1 << std::endl;
  }
  
  return 0;
}


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

using namespace std;

int main()
{
    long long int N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    long long int m = min(A, min(B, (min(C, min(D, E)))));

    long long int ans = 4 + (N + m - 1) / m;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def isPalindrome(string):
    reverse = string[::-1]
    if(string == reverse):
        return True
    return False
string = input()
if(isPalindrome(string) and isPalindrome(string[0:int((len(string)-1)/2)]) and isPalindrome(string[int((len(string)+3)-1/2):])):
    print('Yes')
else:
    print('No')

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

using namespace std;
using ll = long long;
using ld = long double;
//#define int long long
//signed main(){

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n=s.size();
    vector<int> d(n);
    for(int i = 0; i < n; i++) {
        d[i]=int(s[i]-'0');
    }
    int MOD=2019;

    vector<int> t(n+1);
    t[n]=0;
    int dm=1;
    for(int i = 0; i < n; i++) {
        t[n-i-1] = t[n-i]+(dm*d[n-i-1])%MOD;
        t[n-i-1]%=MOD;
        dm=(dm*10)%MOD;
    }

    vector<int> chm(MOD,0);
    for(int i = 0; i < n+1; i++) {
        chm[t[i]]++;
    }
    int ans=0;
    for(int i = 0; i < MOD; i++) {
        ans+=chm[i]*(chm[i]-1)/2;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5216
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Data {
  int t;
  int f;
  int d;
  Data() {;}
  Data(int t, int f, int d) : t(t), f(f), d(d) {;}
  bool operator<(const Data &rhs) const {
    return t < rhs.t;
  }
};

bool infect[30000];
Data data[30000];

int main() {
  int n, m;
  while (scanf("%d %d", &n, &m), n|m) {
    MEMSET(infect, false);
    REP(i, m) {
      int t, s, d;
      scanf("%d %d %d", &t, &s, &d);
      s--; d--;
      data[i] = Data(t, s, d);
    }
    sort(data, data + m);
    int ans = 1;
    infect[0] = true;
    REP(i, m) {
      if (infect[data[i].f] && !infect[data[i].d]) {
        infect[data[i].d] = true;
        ans++;
      }
    }
    printf("%d\n", ans);
  }
}

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

int main(){
  int n, m;
  cin >> n >> m;
  
  priority_queue<ll> price;
  rep(i, n){
    int a;
    cin >> a;
    price.push(a);
  }
  
  rep(i, m){
    int a;
    a = price.top(); price.pop();
    price.push(a/2);
  }
  
  ll ans = 0;
  rep(i, n){
    ans += price.top(); price.pop();
  }
  cout << ans << endl;
}

    

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n+2),b(n+2);
	FOR(i,1,n+1){
		cin>>a[i];
	}
	bool flag=true;
	set<P> st;
	FOR(i,1,n+1){
		cin>>b[i];
		if(b[i]<a[i]){
			flag=false;
		}
		if(b[i]!=a[i]) st.insert(P(b[i],i));
	}
	if(!flag){
		cout<<-1<<endl;
        return 0;
	}
	b[0]=b[n],b[n+1]=b[1];
	ll ans=0;
	while(!st.empty()){
		auto itr=st.end();
		itr--;
		st.erase(itr);
		auto [num,ind]=*itr;
		ll diff=b[ind-1]+b[ind+1];
		if(b[ind]<=diff){
			cout<<-1<<endl;
			return 0;
		}
		if((b[ind]-a[ind])%diff){
			ans+=b[ind]/diff;
			b[ind]%=diff;
			if(b[ind]<a[ind]){
				cout<<-1<<endl;
				return 0;
			}
			st.insert(P(b[ind],ind));
		}else{
			ans+=(b[ind]-a[ind])/diff;
			b[ind]=a[ind];
		}
		b[0]=b[n],b[n+1]=b[1];
		//cout<<b<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 18764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e5+50;
ll num[MAXN];
int n;
bool cmp(int *a,int *b){
    for(int i=0;i<n;i++)
        if(a[i]!=b[i])
            return false;
    return true;
}
int main()
{
    ll ans=1,a=0,b=0;
    int sa[10],sb[10],sc[10];
    cin>>n;
    for(int i=0;i<n;i++)
        sc[i]=i+1;
    for(int i=0;i<n;i++)
        cin>>sa[i];
    for(int i=0;i<n;i++)
        cin>>sb[i];
    if(cmp(sa,sc))
        a=1;
    if(cmp(sb,sc))
        b=1;
    while(next_permutation(sc,sc+n)){
        ans++;
        if(cmp(sa,sc))
            a=ans;
        if(cmp(sb,sc))
            b=ans;
        if(a&&b)
            break;
    }
    cout<<abs(a-b);
	return 0;
}


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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[210000];
ll p[10],q[10];
vector <ll> f;
main(){
  ll n;
  cin>>n;
  rep(i,1,n+1)f.pb(i);
  rep(i,0,n)cin>>p[i];
  rep(i,0,n)cin>>q[i];
  ll ans1=0,ans2=0,cnt=1;
  do{
    bool pp=true,qq=true;
    rep(i,0,n) if(f[i]!=p[i])pp=false;
    rep(i,0,n) if(f[i]!=q[i])qq=false;
    if(pp)ans1=cnt;
    if(qq)ans2=cnt;
    cnt++;
  }while(next_permutation(f.begin(),f.end()));
  cout<<labs(ans2-ans1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  map<int,int> mp;
  int ans=0;
  rep(i,n){
    cin>>a[i];
    ans+=a[i];
    mp[a[i]]++;
  }
  
  int q;
  cin>>q;
  rep(i,q){
    int b,c;
    cin>>b>>c;
    ans+=mp[b]*(c-b);
    mp[c]+=mp[b];
    mp[b]=0;
     cout<<ans<<endl;
  }
 
    
  


  return 0;
}


Measured memory_bytes: 10248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;
int INF = 1001001001;
const int mod = 1000000007;

int main(){
	int a1,a2,a3;
	cin >> a1 >> a2 >> a3;
	string ans = "win";
	if(a1+a2+a3>=22) ans = "bust";
	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "YES"; } string_type do_falsename() const { return "NO"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, K; cin >> n >> K;
  cout << ((n+1)/2 >= K) << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

	int n, ans = 0, ma = 0;
	cin >> n;
	for(int i = 0, h ; i < n ; i++){
		cin >> h;
		if(h >= ma){
			++ans;
			ma = h;
		}
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define MOD 1000000007LL

ll dp[1<<25];
int a[21][21];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> a[i][j];
    }
  }
  dp[0] = 1;
  for (int bit = 0; bit < (1<<N); bit++) {
    int pos = __builtin_popcount(bit) - 1;
    
    for (int i = 0; i < N; i++) {
      if ((bit & (1<<i)) && a[pos][i]) {
        dp[bit] += dp[bit ^ (1<<i)];
        dp[bit] %= MOD;
      }
    }
  }
  cout << dp[(1<<N) - 1] << endl;
  return 0;
}

Measured memory_bytes: 18688
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int ans;
	if (n <= 104) ans = 0;
	else if (n <= 134) ans = 1;
	else if (n <= 164) ans = 2;
	else if (n <= 188) ans = 3;
	else if (n <= 194) ans = 4;
	else ans = 5;
	cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def solve(N: int):
    ans = ""
    while N > 0:
        N -= 1
        ans += chr(ord("a") + N % 26)
        N //= 26
    print(ans[::-1])
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


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

#define fix(x) cout<<fixed<<setprecision(x);

int main() {
    
    fix(8);
    double r;
    cin>>r;
    cout<<r*r*M_PI<<' '<<2*r*M_PI<<endl;
    return 0;
}


Measured memory_bytes: 3220
n = int(input())
min_time = [float('inf')] * (n+1)
min_time[0] = 0
for i in range(n):
    min_time[i+1] = min(min_time[i+1],min_time[i]+1)
    times_6 = 1
    while i+6**times_6<=n:
        min_time[i+6**times_6] = min(min_time[i+6**times_6],min_time[i]+1)
        times_6 += 1
    times_9 = 1
    while i+9**times_9<=n:
        min_time[i+9**times_9] = min(min_time[i+9**times_9],min_time[i]+1)
        times_9 += 1
print(min_time[-1])






Measured memory_bytes: 74828
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  string s;
  int k;
  cin>>n>>s>>k;
  k--;
  for(int i=0;i<n;i++)
    if(s[i]!=s[k]) s[i]='*';
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int s[3], n;

	cin >> n;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < 3; j++){
			cin >> s[j];
		}
		sort(s, s + 3);

		if (pow(s[0], 2) + pow(s[1], 2) == pow(s[2], 2)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return (0);
}

Measured memory_bytes: 3128
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: 9324
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = int.Parse(str);
		string[] strA = Console.ReadLine().Split();
		int []A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(strA[i]);
		}
		Array.Sort(A);
		int countA = 0;
		int countB = 0;
		int ci = N-1;
		while(true){
			if(ci<0){
				break;
			} else {
				countA += A[ci];
			}
			ci -= 1;
			if(ci<0){
				break;
			} else {
				countB += A[ci];
			}
			ci -= 1;
		}
		Console.WriteLine(countA-countB);
	}
}

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

using ll = long long;

#define N 1005

int n, k, a[30];

const int mod = 1e9 + 7;

int dp[2][N];

void add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}

int inv[N] = {0, 1}, fac[N] = {1, 1};

void init() {
	for (int i = 2; i < N; i ++) {
		inv[i] = 1ll * (mod / i) * (mod - inv[mod % i]) % mod;
		fac[i] = 1ll * fac[i-1] * inv[i] % mod;
	}
	return;
}

int C[N][N];

int main() {
	int u = 0, v = 1;
	dp[0][0] = 1;
	cin >> n >> k;
	init();
	for (int i = 1; i <= k; i ++) cin >> a[i];
	C[0][0] = 1;
	for (int i = 1; i < N; i ++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j ++) {
			add(C[i][j], C[i-1][j]);
			add(C[i][j], C[i-1][j-1]);
		}
	}
	for (int i = 1; i <= k; i ++) {
		memset(dp[v], 0, sizeof dp[v]);
		int mx = a[i];
		for (int j = 0; j <= mx; j ++) {
			for (int p = 0; p <= n; p ++) if (p + j <= n) {
				add(dp[v][p+j], mul(mul(C[n-j][mx-j], fac[j]), dp[u][p]));
			}
		}
		swap(u, v);
	}
	int ans = dp[u][n];
	for (int i = 1; i <= n; i ++) ans = mul(ans, i);
	cout << ans << endl;
	return 0;
}


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

int main() {

    int c[3][3];
    for(int i = 0; i < 3; i++)
      for(int j = 0; j < 3; j++)
        cin >> c[i][j]; 

    int diffx[2] = {c[0][1]-c[0][0], c[0][2]-c[0][1]};
    int diffy[2] = {c[1][0]-c[0][0], c[2][0]-c[1][0]};

    for(int i = 1; i < 3; i++){
          int d1 = c[i][1]-c[i][0];
          int d2 = c[i][2]-c[i][1];
          if( d1 != diffx[0] || d2 != diffx[1] ){
              cout << "No" << endl;
              return 0;              
          }   
    }

    for(int i = 1; i < 3; i++){
          int d1 = c[1][i]-c[0][i];
          int d2 = c[2][i]-c[1][i];
          if( d1 != diffy[0] || d2 != diffy[1] ){
              cout << "No" << endl;
              return 0;              
          }   
    }

    cout << "Yes" << endl;

}


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

int main() {
  int n;
  int cost = 0;
  cin >> n;
  int w[n], a[n], b[n];
  int min_val = numeric_limits<int>::max();
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    a[i] = w[i];
    b[i] = 0;
    min_val = min(w[i], min_val);
  }
  sort(a, a+n);
  for (int i = 0; i < n; i++) {
    if (b[i] == 0 && a[i] != w[i]) {
      int index = find(a, a+n, w[i]) - a;
      if (w[index] == a[i]) {
        cost += w[i] + w[index];
        b[index]++;
      } else {
        int first_value = w[i];
        int local_min = w[i];
        int local_cost = w[i];
        int local_n = 1;
        while (w[index] != first_value) {
          local_min = min(local_min, w[index]);
          local_cost += w[index];
          local_n++;
          b[index]++;
          index = find(a, a+n, w[index]) - a;
        }
        int local_cost2 = local_cost;
        local_cost += (local_n - 2) * local_min;
        local_cost2 += local_min + (local_n + 1) * min_val;
        cost += min(local_cost, local_cost2);
      }
    }
  }
  cout << cost << endl;
}



Measured memory_bytes: 3180
MOD = 10**9+7
def mod(x):
    return x % MOD

def solve(n):
    """
    0: {}
    1: {0}
    2: {9}
    3: {0,9}
    """
    x = [1,0,0,0]
    for i in range(n):
        x = list(map(mod, (
            8*x[0],
            (9*x[1] + x[0]),
            (9*x[2] + x[0]),
            (10*x[3] + x[2] + x[1])
        )))
    return x[3]

n = int(input())
print(solve(n))

Measured memory_bytes: 9132
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a,b;cin>>a>>b;
  cout << fixed << setprecision(10);
  cout << (double)a/b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define abs(a) ((a)>(0)?(a):-(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
int main(void){
    long long n,ans=0,minus=0,min=INFINITY;
    scanf("%lld",&n);
    long long m[n],a,i,j=0;
    rep(i,0,n){
        scanf("%lld",&a);
        if(a<0){
            minus++;
            m[j]=a;
            j++;
        }
        else ans+=a;
        if(abs(a)>=0)min=min(min,abs(a));
    }
    rep(i,0,j)ans+=abs(m[i]);
    if(minus%2==0) printf("%lld",ans);
    else {
        ans-=2*min;
        printf("%lld",ans);
    }
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}
int cnt[33]={0};

int32_t  main(){
	IOS;
  int n,m;cin>>n>>m;
//  memset(cnt,0,sizeof(cnt));
  fori(i,n){
    int k;cin>>k;
    while(k--){
      int x;cin>>x;
      cnt[x]++;
    }
  }
  int ans=0;
  fori(i,m)if(cnt[i]==n)ans++;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  int n,m,l;
  int i,j,k;
  cin >> n >> m >> l;
  int a[n][m];
  int b[m][l];
  
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
        a[i][j]=0;
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
        b[i][j];
    }
  }
    
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      cin >> b[i][j];
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      long c=0;
      for(k=0;k<m;k++){
	c+=a[i][k]*b[k][j];
      }
      if(j==0) cout << c;
      else cout << " " << c; 
    }
    cout << endl;
  }
  return 0;
}



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

int main(){
  vi time(5);
  rep(i,5) cin >> time[i];
  sort(time.begin(),time.end());
  int ans = 10000000;
  do{
    int t=0;
    rep(i,5){
      if(i!=4) t += (time[i]+9)/10*10;
      else t += time[i];
    }
    ans = min(ans, t);
  }while(next_permutation(time.begin(),time.end()));
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int maxn = 1E5 + 10;

int n;
bool vis[maxn];

vector <int> v[maxn];

inline void Dfs(int x,int from)
{
	for (int i = 0; i < v[x].size(); i++)
	{
		int to = v[x][i];
		if (to == from) continue;
		Dfs(to,x); if (vis[to]) continue;
		if (vis[x]) {puts("First"); exit(0);}
		vis[x] = vis[to] = 1;
	}
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n;
	if (n & 1) {puts("First"); return 0;}
	for (int i = 1; i < n; i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		v[x].push_back(y); v[y].push_back(x);
	}
	Dfs(1,0); puts("Second");
	return 0;
}

Measured memory_bytes: 5888
import scala.annotation.tailrec
import scala.io.{StdIn => in}

object Main extends App {

  def calc(num:Int):Int = {
    @tailrec
    def rec(acc:Int, cnt:Int):Int = {
      val fact = acc + cnt
      if(fact >= num) cnt
      else rec(fact, cnt+1)
    }
    rec(0,1)
  }

  val n =in.readInt
  val ans = calc(n)
  println(ans)
}

Measured memory_bytes: 25404
(function(stdin) {
  var lines = stdin.toString().split('\n');
  var param = lines[0].split(' ').map(Number);
  var a = param[0];
  var b = param[1];

  console.log((a * b),(a + b) *2);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
#define resi(i,name) for(auto i=name.begin();i!=name.end();i++)
int main(){
	int n;
	ll a,b;
	ll ans=0LL;
	cin >>n>>a>>b;
	V x(n);
	rep(i,n){
		cin>>x[i];
	}
	int at=x[0];
	rep(i,n-1){
		ans+=min(b,a*(x[i+1]-x[i]));
	}
	cout<<ans<<endl;
}

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

using namespace std;

bool same(string &s)
{
    for (int i = 1; i < s.length(); i++)
    {
        if (s[i] != s[0])
            return false;
    }
    return true;
}

int main()
{
    string s;
    int k;
    cin >> s >> k;
    long long ans = 0;
    if (same(s))
    {
        ans = (int) s.length() * (long long) k / 2;
    }
    else
    {
        int pre = 1;
        for (int i = 1; i < s.length(); i++)
        {
            if (s[i] == s[0])
                pre++;
            else
                break;
        }
        int suf = 1;
        for (int i = s.length() - 2; i >= 0; i--)
        {
            if (s[i] == s[s.length() - 1])
                suf++;
            else
                break;
        }
        int one = 0;
        int index = pre;
        while (index < s.length() - suf)
        {
            int cnt = 1;
            int j = index + 1;
            while (j < s.length() - suf && s[j] == s[index])
            {
                j++;
                cnt++;
            }
            index = j;
            one += cnt / 2;
        }
        if (s[0] == s[s.length() - 1])
        {
            ans = (long long) k * one + (long long) (k - 1) * ((pre + suf) / 2) + pre / 2 + suf / 2;
        }
        else
        {
            ans = (long long) k * one + (long long) k * (pre / 2) + (long long) k * (suf / 2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
'''input
314159265 35897932 384626433
'''
import time
import math
k, a, b = map(int, input().strip().split())
if b > a + 2:
	ans = 1
	if(ans < a):
		ans += min(a - 1, k - 1)
		k -= min(a - 1, k - 1)
	if k % 2 == 1:
 		ans += 1
 		k -= 1
	ans = ans - (a * (k // 2))
	ans = ans + (b * (k // 2))
	print(ans)
else:
	ans = 1 + k
	print(ans)

Measured memory_bytes: 3064
import java.util.*;

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


Measured memory_bytes: 35716
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <set>

#define rep(i,n)  for (int i = 0; i < (int)(n); i++)
#define INF 9999999999
#define PI 3.14159265359
using namespace std;

int main()
{
	int i,n,m,ans=0,l,r,ll=0,rr=INF;
	cin>>n>>m;
	rep(i,m){
		cin >>l>>r;
		ll=max(l,ll);
		rr=min(r,rr);
	}
	if(rr>=ll) ans=rr-ll+1;
	cout << ans<< endl;
	return 0;
}

Measured memory_bytes: 256
//##MohK
// 8/2/2020 ..... 9,00
#include <bits/stdc++.h>
using namespace std ;
using ll = long long ;
using ld = long double;
int main(){
    ll a,sum=0,res=0;
    cin>>a;
    int x[a],y[a];
    for(ll i=0;i<a;i++){
        cin>>x[i];
    }
     for(ll i=0;i<a;i++){
        cin>>y[i];
    }
    for(ll i=0;i<a;i++){
        if(x[i]>=y[i]){
                sum+=x[i];
                res+=y[i];
        }
    }
    cout<<abs(sum-res)<<endl;



    return 0 ;
}



Measured memory_bytes: 256