akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ab[1100000],o=2,p=-1,ac[20],q=1;
pair<int,int> pp[20];
string s,ss[220000];
char c,ca;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        ab[aa[i]]++;
    }
    sort(aa,aa+n);
    for(int i=n-1;i>-1;i--){
        rep(j,20){
            pp[j].first=0;
            pp[j].second=0;
        }
        rep(j,20){
            ac[j]=0;
        }
        o=2;
        p=-1;
        q=1;
        if(ab[aa[i]]>=2){
            goto no;
        }
        while(1){
            if(aa[i]%o==0){
                if(pp[p].first==o){
                    pp[p].second++;
                }else{
                    p++;
                    pp[p].first=o;
                    pp[p].second++;
                }
                aa[i]/=o;
            }else{
                o++;
            }
            if(o>sqrt(aa[i])){
                if(aa[i]!=1){
                    if(pp[p].first==aa[i]){
                        pp[p].second++;
                    }else{
                        p++;
                        pp[p].first=aa[i];
                        pp[p].second++;
                    }
                }
                break;
            }
        }
        rep(j,p+1){
            q*=pp[j].second+1;
        }
        rep(j,q-1){
            int d=1;
            rep(k,p+1){
                d*=pow(pp[k].first,ac[k]);
            }
            if(ab[d]!=0){
                goto no;
            }
            ac[0]++;
            rep(k,p+1){
                if(ac[k]==pp[k].second+1){
                    ac[k]=0;
                    ac[k+1]++;
                }
            }
        }
        cnt++;
        no:;
    }
    cout<<cnt;
}

Measured memory_bytes: 20176
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static class Move {
		int fx, fy, gx, gy;
		
		public Move(int fx, int fy, int gx, int gy) {
			this.fx = fx;
			this.fy = fy;
			this.gx = gx;
			this.gy = gy;
		}
		
		public String toString() {
			return this.fy + " " + this.fx + " " + this.gy + " " + this.gx;
		}
	}
	
	public static int[][] move_dirs = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	public static boolean in_range(int x, int y, int W, int H) {
		return 0 <= x && x < W && 0 <= y && y < H;
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] array = new int[N];
			for(int i = 0; i < N; i++) { array[i] = sc.nextInt(); }
			
			System.out.println(Arrays.stream(array).sum() - Arrays.stream(array).max().getAsInt() / 2);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define allof(v) (v).begin(), (v).end()


#define MOD 1000000007

li n, m;

inline li calc(vector<li>& arr) {
	li base = arr[0];
	li res = 0;
	li cumul = 0;
	repp(i, 1, arr.size()) {
		res = (res + cumul + i * (arr[i] - arr[i - 1])) % MOD;
		cumul = (cumul + i * (arr[i] - arr[i - 1])) % MOD;
	}
	return res;
}

int main(void)
{
	vector<li> xs;
	vector<li> ys;

	cin >> n >> m;
	rep(i, n) {
		li x;
		cin >> x;
		xs.push_back(x);
	}
	rep(i, m) {
		li y;
		cin >> y;
		ys.push_back(y);
	}

	cout << (calc(xs) * calc(ys)) % MOD << endl;


	return 0;
}

Measured memory_bytes: 2548
import sys
sys.setrecursionlimit(10**7) #再帰回数の上限を変更
from collections import deque
N,M=map(int,input().split())
G=[[]for _ in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

dist=[-1 for _ in range(N)]
chk=[0 for _ in range(N)]
dist[0]=0
prev=[-1 for _ in range(N)]


que=deque()
que.append((0,-1))

while(len(que)):
    v,p=que.popleft()
    for tmp in G[v]:
        if dist[tmp]!=-1:
            continue
        dist[tmp]=dist[v]+1
        prev[tmp]=v
        que.append((tmp,v))

print("Yes")
#print(dist)
for i in range(N):
    if i==0:
        continue
    print(prev[i]+1)

Measured memory_bytes: 39772
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    int n, k; cin >> n >> k;
    vector<ll> a(n+1, 1);
    rep(i, n) cin >> a[i+1];

    for (int i = k+1; i <= n; i++) {
        if (a[i-k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int main() {
  int N , M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0;i < M;i++){
    int a , b;
    cin >> a >> b;
    vec.at(a - 1)++;
    vec.at(b - 1)++;
  }
  for (int i = 0;i < N;i++){
    cout << vec.at(i) << endl;
  }
}
    

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rrepn(i, n) for(int i=((int)(n)); i>0; --i)
#define SZ(x) ((int)(x).size())
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; }
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));


void solve(long long A, long long B){
    cout << A*B << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;

// dp[i+1][v] := i番目までの品物を見たとき, 価値の総和がv以上となるような重さの総和の最小値
long long dp[102][100005];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int n, lim_w;
  cin >> n >> lim_w;

  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }

  for (int i = 0; i < 102; i++) {
    for (int j = 0; j < 100005; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 100005; j++) {
      // i番目の品物を選ぶ
      if (j >= v[i]) {
        dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]] + w[i]);
      }
      // i番目の品物を選ばない
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }
  }

  int ans = 0;
  for (int i = 0; i < 100005; i++) {
    if (dp[n][i] <= lim_w) {
      ans = max(ans, i);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 80000
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int N=0;
  cin >> N;
  cout << "ABC" << N << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int main() {
	int h,w;
	int i,j;
	char a[102][102];
	cin >> h >> w;
	for(i=0;i<h;i++){
		cin >> a[i];
	}
	for(i=0;i<=h+1;i++){
		for(j=0;j<=w+1;j++){
			if(i==0 || j == 0 || i==h+1 || j==w+1){
				cout << "#";
			}else{
				cout << a[i-1][j-1];
			}
			 if(j == w+1){
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    char color;
    int count = 0; 
    for (int i = 0; i < n; i++){
        scanf("%c", &color);
        if(color == 'Y'){
            count = 1;
            break;
        }
    }
    printf("%s\n", count ? "Four":"Three");
    return 0; 
}

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int a[][] = new int[h][w];
        int sum = 0;


        for(int i=0;i<h;i++) {
        	for(int j=0;j<w;j++) {
        		a[i][j] = sc.nextInt();
        		sum = a[i][j];
        	}
        }
        int z = h*w;
        String t[] = new String[z];
        Arrays.fill(t, "");

        int r = 0;
        int k=0;

        for(int i = 0;i<h;i++) {
        	if(i%2 == 0) {
        		for(int j=0;j<w-1;j++) {
        			if((a[i][j] + r)%2 == 1) {
        				t[k] = ((i+1) + " " + (j+1) + " " + (i+1) + " " + (j+2));
        				r = 1;
        				k= k+1;
        			}else {
        				r = 0;
        			}
        		}
        		if(i != h-1 && (a[i][w-1]+r)%2 == 1) {
        			t[k] = ((i+1) + " " + w + " " + (i+2) + " " + w);
        			r = 1;
    				k= k+1;
        		}else {
        			r = 0;
        		}
        	}else {

        		for(int j=w-1;j>0;j--) {
        			if((a[i][j] + r)%2 == 1) {
        				t[k] = ((i+1) + " " + (j+1) + " " + (i+1) + " " + j);
        				r = 1;
        				k= k+1;
        			}else {
        				r = 0;
        			}
        		}
        		if(i != h-1 && (a[i][0]+r)%2 == 1) {
        			t[k] = ((i+1) + " " + 1 + " " + (i+2) + " " + 1);
        			r = 1;
    				k= k+1;
        		}else {
        			r = 0;
        		}
        	}
        }
    	System.out.println(k);
    	for(int i=0;i<k;i++) {
    		System.out.println(t[i]);
    	}

    }

}

Measured memory_bytes: 103528
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 10001;

int n;
vector <int> a, ans, v[N];

void dfs(int node, int pnode){
    ans[node] = a.back();
    a.pop_back();
    for(auto &i : v[node]){
        if(i == pnode) continue;
        dfs(i, node);
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0 ; i < n - 1 ; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    a.resize(n);
    for(auto &i : a) cin >> i;
    sort(a.begin(), a.end());
    ll sum = 0;
    for(int i = 0 ; i < n - 1 ; i++){
        sum += a[i];
    }
    ans.resize(n);
    dfs(0, 0);
    cout << sum << endl;
    for(auto &i : ans) cout << i << " ";
    cout << endl;
}


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

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

using namespace std;

int N;

void process(string &group,int &g,int &b,int n,int &cur){
  ( cur += ( n - 1 ) ) %= group.size();
  if( group[cur] == 'B' ) --b;
  else                    --g;
  group.erase(group.begin()+cur);
}

int calc(string group,int g,int b,int cur){
  if( group.empty() ) return b;
  process(group,g,b,N+1,cur);
  while( !( g == 0 || b == 0 ) ){
    process(group,g,b,N,cur);
  }
  return b;
}

void compute(string group){
  int g = 0, b = 0;
  rep(i,(int)group.size()) {
    if( group[i] == 'G' ) ++g;
    else                  ++b;
  }
  int maxi =  0, cur = 0;
  while( !( g == 0 || b == 0 ) ){
    maxi = max(maxi,calc(group,g,b,cur));
    process(group,g,b,N,cur);
  }
  maxi = max(maxi,b);
  cout << maxi << endl;
}

int main(){
  int T;
  cin >> T;
  while( T-- ){
    string group;
    cin >> N >> group;
    compute(group);
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    int res = 0;
    for (int i = 0; i < k; i++) {
        vector<vector<int>> dp(n / k + 5, vector<int>(3, -INF));
        dp[0][0] = 0, dp[0][1] = 0, dp[0][2] = 0;
        int id = 1;
        for (int j = i; j < n; j += k) {
            for (int l = 0; l < 3; l++) {
                for (int m = 0; m < 3; m++) {
                    if (l != m) {
                        chmax(dp[id][l], dp[id - 1][m]);
                    }
                }
            }
            if (t[j] == 'r') {
                chmax(dp[id][2], max(dp[id - 1][0], dp[id - 1][1]) + p);
            } else if (t[j] == 's') {
                chmax(dp[id][0], max(dp[id - 1][1], dp[id - 1][2]) + r);
            } else {
                chmax(dp[id][1], max(dp[id - 1][0], dp[id - 1][2]) + s);
            }
            id++;
        }
        res += max({dp[id - 1][0], dp[id - 1][1], dp[id - 1][2]});
    }
    cout << res << endl;
}

Measured memory_bytes: 5840
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n; cin>>n;
 	bool can=false;
  map<int,int>mp;
  int x;
  for(int i=0;i<n;i++)
  {
	cin>>x;
    mp[x]++;
    if(mp[x]>1)
    {
      can=true;
    }
  }
  if(can){cout<<"NO\n";}
  else
  {
    cout<<"YES";
  }
}
  
  

Measured memory_bytes: 9600
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long cnt=0,i;
    string s,a;
    cin>>s>>a;
    for(i=0;i<s.length();i++)
    {
        if(s[i]!=a[i]){cnt++;}
    }
    cout<<cnt;

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

string s;

int main() {
    cin >> s;
    int lost = 0;
    for (char c : s) {
        if (c == 'x') {
            lost += 1;
        }
    }
    if (lost > 7) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int x,k,d;
  cin >> x >> k >> d;
  if(x<0){
    x*=-1;
  }
  if(k<x/d){
    x-=k*d;
  }
  else{
    if((k-x/d)%2==0){
      x=x%d;
    }
    else{
      x=d-x%d;
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 3680
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>

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

using namespace std;

int M;

template<class T>
class FenwickTree{
	vector<T> a;
public:
	FenwickTree(int n):a(n){}
	T sum(int i,int j)const{
		if(i==0){
			T s=0;
			for(;j>=0;j=(j&(j+1))-1) s=(s+a[j])%M;
			return s;
		}
		return ((sum(0,j)-sum(0,i-1))%M+M)%M;
	}
	void add(int i,T v){
		for(;i<a.size();i|=i+1) a[i]=(a[i]+v)%M;
	}
};

int ofset;
char s[100001][16];
bool lex(int a,int b){
	return strcmp(s[a-ofset],s[b-ofset])<0;
}

int main(){
	for(int a,b;scanf("%d%d%d",&a,&b,&M),a;){
		ofset=a;
		int n=b-a+1,seq[100000];
		rep(i,n){
			seq[i]=a+i;
			sprintf(s[i],"%d",a+i);
		}
		sort(seq,seq+n,lex);

		FenwickTree<int> F(b-a+1);
		rep(i,n) F.add(seq[i]-a,F.sum(0,seq[i]-a)+1);

		printf("%d\n",F.sum(0,n-1));
	}

	return 0;
}

Measured memory_bytes: 0
from fractions import gcd

A, B = map(int, input().split())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

g = gcd(A, B)

print(len(set(prime_decomposition(g)))+1)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int sum = 0;
	int m = 10000;

	for (int i = 0;i < 4;i++){
		int tmp; cin >> tmp;
		sum += tmp;
		m = min(m,tmp);
	}	

	int a,b; cin >> a >> b;

	cout << sum-m+max(a,b) << endl;

	return 0;

}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define M 2550
using namespace std;
struct ll{
	int l,to,c;
}edge[M<<1];
int n,m,h[M],len,dis[M],cnt[M],flg,k;
bool mark[M],mem[M];
vector<int>son[M];
void Add(int st,int to,int c){
	edge[++len].to=to;
	edge[len].l=h[st];
	edge[len].c=c;
	h[st]=len;
}
queue<int>Q;
void spfa(){
	dis[1]=0;
	Q.push(1);
	while(!Q.empty()){
		int x=Q.front();
		Q.pop();
		mark[x]=0;
		for(int i=h[x];i;i=edge[i].l){
			int y=edge[i].to,c=edge[i].c-k;
			if(!mem[y])continue;
			if(dis[y]<dis[x]+c){
				dis[y]=dis[x]+c;
				cnt[y]=cnt[x]+1;
				if(cnt[y]>n){
					flg=-1;
					return;
				}
				if(!mark[y])mark[y]=1,Q.push(y);
			}
		}
	}
}
queue<int>W;
void bfs(){
	W.push(n);
	mem[n]=1;
	while(!W.empty()){
		int x=W.front();
		W.pop();
		for(int i=0;i<son[x].size();i++){
			int y=son[x][i];
			if(mem[y])continue;
			mem[y]=1,W.push(y);
		}
	}
}
int main(){
	memset(dis,-16,sizeof(dis));
	int u,v,c;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=m;i++)scanf("%d%d%d",&u,&v,&c),Add(u,v,c),son[v].push_back(u);
	bfs();
	spfa();
	if(~flg)printf("%d\n",max(0,dis[n]));
	else puts("-1");
	return 0;
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    int n, k;
    cin>>n>>k;
    int a[n];
    fr(i, n) cin>>a[i];

    vector<bool> dp(k + 1);
    /// dp[i] = whether players with the chance wins or not with i stones left
    for(int stones = 0; stones <= k; ++stones){
        for(auto x: a){
            if(stones >= x && !dp[stones - x]){
                dp[stones] = true;
            }
        }
    }

    cout<<(dp[k] ? "First" : "Second");

}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#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))

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

using namespace std;

static const int W = 0;
static const int B = 1;

struct Edge {
    int to, dist;

    Edge(int to, int dist){
        this->to = to;
        this->dist = dist;
    }
};

void solve(const vector<vector<Edge> >& edges, int cur, int prev, int color, vector<int>& ans) {
    ans[cur] = color;
    for(const Edge& e : edges[cur]){
        if(e.to == prev) continue;
        int this_color = color ^ (e.dist % 2 == 1);
        solve(edges, e.to, cur, this_color, ans);
    }
}

int main() {
    int n;

    cin >> n;
    
    vector<vector<Edge> > e(n);
    
    for(int i = 0; i < n-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        e[u].push_back(Edge(v, w));
        e[v].push_back(Edge(u, w));
    }

    vector<int> ans(n);
    solve(e, 0, -1, W, ans);

    for(int i = 0; i < n; i++){
        cout << (ans[i] == 1 ? 1 : 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 9728
#1番目の味はL,最後の味はL＋N－１
N,L=map(int,input().split())
taste=[]
for i in range(N):
  taste.append(i+1+L-1)
if L>=1:
  print(sum(taste)-L)
elif L==0:
  print(sum(taste))
elif L<0:
  if L+N-1<0:
    print(sum(taste)-(L+N-1))
  else:
    print(sum(taste))

Measured memory_bytes: 3064
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 800000000000000000
vector<pair<long long,long long>> vertexs[300000];
long long dijkstra[300000] = {};
int can_be_connected[300000] = {};
int already_used[300000] = {};
int main() {
	iostream::sync_with_stdio(false);
	long long n, m, c;
	cin >> n >> m >> c;
	long long souwa = 0;
	REP(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		souwa += c;
		vertexs[a].push_back(make_pair(b, c));
		vertexs[b].push_back(make_pair(a, c));
	}
	REP(i, 300000) {
		dijkstra[i] = LONG_INF;
	}
	priority_queue<pair<long long, long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> wow;
	vector<pair<long long,int>> connect_sort;
	wow.push(make_pair(0, 1));
	dijkstra[0] = 0;
	while (wow.empty() == false) {
		pair<long long, long long> now = wow.top();
		wow.pop();
		if (already_used[now.second] == false) {
			connect_sort.push_back(make_pair(now.first, now.second));
			already_used[now.second] = true;
			for (int i = 0;i < vertexs[now.second].size();++i) {
				if (vertexs[now.second][i].second + now.first < dijkstra[vertexs[now.second][i].first]) {
					dijkstra[vertexs[now.second][i].first] = vertexs[now.second][i].second + now.first;
					wow.push(make_pair(dijkstra[vertexs[now.second][i].first], vertexs[now.second][i].first));
				}
			}
		}
	}
	sort(connect_sort.begin(), connect_sort.end());
	long long ans = LONG_INF;
	for (int i = 0;i < connect_sort.size();++i) {
		can_be_connected[connect_sort[i].second] = true;
		for (int q = 0;q < vertexs[connect_sort[i].second].size();++q) {
			if (can_be_connected[vertexs[connect_sort[i].second][q].first] == true) {
				souwa -= vertexs[connect_sort[i].second][q].second;
			}
		}
		ans = min(ans, connect_sort[i].first*c + souwa);
	}
	cout << ans << endl;
	return 0;
}


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

bool pallin(string &s,int i,int j)
{
  while(i<j)
  {
    if(s[i]!=s[j]) return false;
    i++; j--;
  }
  return true;
}

int main()
{
    double s;cin>>s;
    s=s/3.0;
    cout<<fixed<<setprecision(12)<<(s*s*s);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <cstdio>
using namespace std;
int a,b,c;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}
int main()
{
    a=read(),b=read(),c=read();
    printf("%d\n",(a-c)/(b+c));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 1000005
using namespace std;
int n,m,sum,mk;
char a[N],b[N];
int main()
{
	scanf("%d",&n);
	scanf("%s",a+1);
	scanf(" %s",b+1);
	for(int i=1;i<=n;i++)
	{
		int k=0;
		for(int j=1;j<=n;j++)
		{
			if(j+i-1>n)
				break;
			if(b[j]!=a[i+j-1])
			{
				k=0;
				break;
				//~ printf("2\n");
			}
			k++;
			//~ printf("%d %d %d\n",k,i,j);
		}
		mk=max(k,mk);
	}
	printf("%d",2*n-mk);
}


Measured memory_bytes: 256
#include <cstdio>
int main()
{
	int n, k;
	int b[18];
    scanf("%d %d",&n,&k);
	for(int i=0;i<k;i++)
	    scanf("%d",&b[i]);
	for(long j=0;j<(1<<k);j++) {
		long d=0;
		for(int u=0;u<k;u++) {
			if(j&(1<<u))
				d+=(1<< b[u]);
		}
		printf("%d:",d);
		for(int s=0;s<k;s++){
			if(j&(1<<s))
				printf(" %d",b[s]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2688
using System;

namespace JKTX_AOJ2015
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = new int[3];
            string[] str = Console.ReadLine().Split(' ');

            data[0] = int.Parse(str[0]);
            data[1] = int.Parse(str[1]);
            data[2] = int.Parse(str[2]);

            Array.Sort(data);

            Console.WriteLine("{0} {1} {2}", data[0], data[1], data[2]);
        }
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 A, B;
  cin >> A >> B;

  if (A <= 9 && B <= 9) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

fn main() {
    // let s = std::io::stdin();
    // let mut sc = Scanner { stdin: s.lock() };
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let D:usize = sc.read();
    let C:Vec<i64> = sc.vec(26);
    let S: Vec<Vec<i64>> = (0..D).map(|_| sc.vec(26)).collect();
    let mut past: Vec<i64> = (0..26).map(|_| -1).collect();
    let mut ANS:Vec<usize> = Vec::new();
    let mut point:i64 = 0;
    for i in 0..D{
        let mut m:i64 = -1000000000;
        let mut ind:usize = 0;
        for j in 0..26{
            let mut temp_point:i64 = point+S[i][j];
            for k in 0..26{
                if k == j{
                    continue
                }
                temp_point -= C[k]*((i as i64)-past[k]);
            }
            if m < temp_point{
                ind = j;
                m = temp_point;
            }
        }
        ANS.push(ind);
        point = m;
        past[ind] = i as i64;
    }
    let deadline = D;
    let times = 29;
    for _ in 0..times{
        for i in 0..deadline{
            let oldest:usize = ANS[i];
            for j in 0..26{
                if j == oldest {
                    continue
                }
                let old = ANS[i];
                ANS[i] = j;
                let temp_point = check_point(D,&S,&ANS,&C);
                if point < temp_point{
                    // println!("!!!!!! {} < {}",point, temp_point);
                    point = temp_point;
                }else{
                    ANS[i] = old;
                }
            }
        }
    }
    for i in 0..D{
        println!("{}", ANS[i]+1);
    }
    // for i in 0..D{
    //     ans += S[i][T[i]-1];
    //     past[T[i]-1] = i as i64;
    //     for j in 0..26{
    //         ans -= C[j]*((i as i64)-past[j]);
    //     }
    //     println!("{}", ans);
    // }
}

fn check_point(D:usize, S:&Vec<Vec<i64>>, T:&Vec<usize>,C:&Vec<i64>) -> i64{
    let mut ans:i64 = 0;
    let mut past: Vec<i64> = (0..26).map(|_| -1).collect();
    for i in 0..D{
        ans += S[i][T[i]];
        past[T[i]] = i as i64;
        for j in 0..26{
            ans -= C[j]*((i as i64)-past[j]);
        }
    }
    ans
}

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);


impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
}





Measured memory_bytes: 2288
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long a = scan.nextInt();
        long b = scan.nextInt();
        long c = scan.nextInt();
        long d = scan.nextInt();

        long bc = b*c;
        long bd = b*d;
        long ac = a*c;
        long ad = a*d;

        long maxb = Math.max(bc, bd);
        long maxa = Math.max(ac, ad);


        os.println(Math.max(maxa,maxb));
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int n;

int main() {
  cin >> n;
  vector<int> h(n);
  string ans = "Yes";
  rep(i, n) cin >> h[i];
  if (n > 1) {
    for (int i = n - 2; i >= 0; --i) {
      if (h[i] > h[i + 1] + 1) {
        ans = "No";
        break;
      } else if (h[i] == h[i + 1] + 1) {
        --h[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()
ab=sorted([lmp() for i in range(m)],key=itemgetter(1))
removed=-1
ans=0
for a,b in ab:
    if a>removed:
        removed=b-1
        ans+=1
print(ans) 

Measured memory_bytes: 31932
from collections import deque
N,M,K = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
col = [-1 for _ in range(N+1)]
cnt = 0
for i in range(1,N+1):
    if col[i]<0:
        col[i] = cnt
        que = deque([i])
        while que:
            x = que.popleft()
            for y in G[x]:
                if col[y]<0:
                    col[y] = cnt
                    que.append(y)
        cnt += 1
C = {}
for i in range(1,N+1):
    c = col[i]
    if c not in C:
        C[c] = 0
    C[c] += 1
B = {i:[] for i in range(1,N+1)}
for _ in range(K):
    c,d = map(int,input().split())
    B[c].append(d)
    B[d].append(c)
A = []
for i in range(1,N+1):
    c = col[i]
    cnt = C[c]-len(G[i])-1
    for y in B[i]:
        if col[y]==c:
            cnt -= 1
    A.append(cnt)
print(*A)

Measured memory_bytes: 124856
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

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


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
ll N, C, K;
ll t[100010];
int main(void) {
    cin >> N >> C >> K;
    REP(i, N) cin >> t[i];
    ll ans=1;
    sort(t, t+N);
    t[N]=0;
    ll temp=t[0], cnt=1;
    for(int i=1; i<N; ++i){
        cnt++;
        if((t[i]>temp+K)||(cnt>C)){
            temp=t[i];
            cnt=1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int s[14]={0},h[14]={0},c[14]={0},d[14]={0};
	int nIn=0;
	cin>>nIn;
	char cIn;
	int nInput=0;
	for (int i=0;i<nIn;i++)
	{
		cin>>cIn>>nInput;
		if ('S'==cIn)
		{
			s[nInput]=1;
		}
		if ('H'==cIn)
		{
			h[nInput]=1;
		}
		if ('D'==cIn)
		{
			d[nInput]=1;
		}
		if ('C'==cIn)
		{
			c[nInput]=1;
		}
	}
	for(int i=1;i<14;++i)
	{
		if(0==s[i])
		{
			cout<<"S "<<i<<endl;
		}
	}
	for(int i=1;i<14;++i)
	{
		if(0==h[i])
		{
			cout<<"H "<<i<<endl;
		}
	}
	for(int i=1;i<14;++i)
	{
		if(0==c[i])
		{
			cout<<"C "<<i<<endl;
		}
	}
	for(int i=1;i<14;++i)
	{
		if(0==d[i])
		{
			cout<<"D "<<i<<endl;
		}
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int cost = 0;
    int cost_min = INFINITY;

    for (int i = 0; i <= 100000; ++i) {
        cost = i * 2 * c;
        if (i < x)cost += (x - i) * a;
        if (i < y)cost += (y - i) * b;
        if (cost < cost_min)cost_min = cost;
        }
    print(cost_min);
}

Measured memory_bytes: 256
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
MOD = 10**9 + 7

memo = [-1]*(1 << N)
memo[0] = 1
def dfs(state, c):
    if memo[state] != -1:
        return memo[state]
    r = 0
    for i in range(N):
        if state & (1 << i) and A[c][i]:
            r += dfs(state ^ (1 << i), c+1)
    memo[state] = r = r % MOD
    return r
print(dfs((1 << N)-1, 0))

Measured memory_bytes: 62044
//https://blog.csdn.net/hesorchen
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define mod 1000000007
ll s[200005];
ll p[200005];
int main()
{
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> p[i];
    for (int i = 1; i <= n; i++)
    {
        s[i] = p[i] + s[i - 1];
    }
    ll maxx = 0;
    for (int i = k; i <= n; i++)
        maxx = max(maxx, s[i] - s[i - k]);
    printf("%.12lf\n", (double)(maxx + k) / 2);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n;
	cin >> n;
    long long int r=0;
    for(int i=1;i<n+1;++i){
        if(i%3!=0&&i%5!=0){
            r+=i;
        }
    }
    cout<<r;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;

int main(){
    LL n;
    cin >> n;
    LL ans = 0;
    for(LL i=1; i*i <= n; i++){
        if(n%i != 0) continue;
        if(i-1 > 0 && n/(i-1) == n%(i-1)) ans += i - 1;
        if((n/i-1) > 0 && n/(n/i-1) == n%(n/i-1)) ans += n/i - 1;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long K){
  vector<int> run(1000000, -1);

  run[0] = 1;
  auto countup = [&](){
    for (int i = 0; i+1 < run.size(); ++i) {
      if (run[i+1] == -1) {
        if (run[i] < 9) {
          run[i]++;
          for (int j = i-1; j >= 0; --j) {
            run[j] = max(0, run[j+1] - 1);
          }
          return;
        } else {
          run[i+1] = 1;
          for (int j = i; j >= 0; --j) {
            run[j] = 0;
          }
          return;
        }
      }
      if (run[i+1] - run[i] >= 0 && run[i] < 9) {
        run[i]++;
        for (int j = i-1; j >= 0; --j) {
          run[j] = max(0, run[j+1] - 1);
        }
        return;
      }
    }
  };

  for (int i = 0; i < K-1; ++i) {
    countup();
    // int m = 0;
    // for (int i = 0; i < run.size(); ++i) {
    //   if (run[i] == -1) {
    //     m = i-1;
    //     break;
    //   }
    // }
    // for (int i = m; i >= 0; --i) {
    //   std::cout << run[i];
    // }
    // std::cout << std::endl;
  }

  int m = 0;
  for (int i = 0; i < run.size(); ++i) {
    if (run[i] == -1) {
      m = i-1;
      break;
    }
  }
  for (int i = m; i >= 0; --i) {
    std::cout << run[i];
  }
  std::cout << std::endl;
}

int main(){
  long long K;
  scanf("%lld",&K);
  solve(K);
  return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<char> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int cnt=0;
	for (int i=1;i<n;i++)
	{
		cnt+=(a[i]!=a[i-1]);
	}
	cout<<min(n-1,n-1-cnt+2*k)<<'\n';
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 2e5 + 5 ;
int n , a[maxn] ;
int main()
{
	scanf("%d" , &n) ;
	for(int i = 1 ; i <= n ; i ++)  scanf("%d" , &a[i]) ;
	sort(a + 1 , a + n + 1) ;
	for(int i = 2 ; i <= n ; i ++)
	  if(a[i] == a[i - 1]){printf("NO\n") ; return 0 ;}
	printf("YES\n") ;
	return 0 ;
}

Measured memory_bytes: 1024
#include<stdio.h>

int a[100][101];

int Plus(int r,int c){

	int i;
	int sum = 0;

	for(i=0;i<r;i++){
		sum += a[i][c];
	}

	return sum;

}

int main(void){

	int r,c;
	int i,j;
	int sum;

	scanf("%d %d",&r,&c);

	for(i=0;i<r;i++){
		sum = 0;
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
			sum += a[i][j];
		}
		a[i][c] = sum;
	}

	for(i=0;i<r;i++){
		printf("%d",a[i][0]);
		for(j=1;j<c+1;j++){
			printf(" %d",a[i][j]);
		}
		puts("");
	}
	printf("%d",Plus(r,0));
	for(i=1;i<c+1;i++){
		printf(" %d",Plus(r,i));
	}
	puts("");

	return 0;

}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define lson t << 1, l, mid
#define rson t << 1 | 1, mid + 1, r
#define mem0(x) memset(x, 0, sizeof(x))
#define mem1(x) memset(x, -1, sizeof(x))
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i > b; i--)
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
//---------------------------------------------------------//
const int N = 2e5 + 5;

int n, k, a[105];

int main()
{
//	ios::sync_with_stdio(false);
	cin >> n >> k;
	rep(i, 0, n)  cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	int ans = 0;
	for (int i = 0; i < k; i++)  ans += a[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	ll x,y;
	cin>>x>>y;
	for(int i=0;i<=x;i++)
	{
		if(i*2+(x-i)*4==y)
		{
			return cout<<"Yes",0;
		}
	}
	cout<<"No";
		
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  
  int a,fa,sa,fi,si;
  for(int i=0; i<n; i++){
    cin >> a;
    if(a>=fa){
      sa = fa;
      si = fi;
      fa = a;
      fi = i;
    }else if(a>=sa){
      sa = a;
      si = i;
    }
  }
  
  for(int i=0; i<n; i++){
    if(i==fi)cout << sa << endl;
    else cout << fa << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

const int maxn=100005;
typedef long long ll;

int read()
{
	int f=0; char c=getchar();
	while(c>'9' || c<'0') c=getchar();
	while(c<='9' && c>='0') {f=f*10+c-'0'; c=getchar();}
	return f;
}

ll n,t;

ll tot;
map<ll,int> m1;

void chk(ll x, ll t)
{
	if(t==1) return;
//	cout<<x<<' '<<t<<endl;
	while(x%t==0) x/=t;
//	cout<<"ch "<<x<<' '<<t<<endl;
	x--;
	if(x%t==0)
	{
		if(m1[t]==0)
			m1[t]=++tot;
	}
}

void chk2(ll x)
{
	for(int i=1;i<=sqrt(x);i++)
	{
		if(x%i==0)
		{
			if(m1[i]==0)
				m1[i]=++tot;
			if(m1[x/i]==0)
				m1[x/i]=++tot;
		}
	}
}

int main()
{
	cin>>n; chk2(n-1);
	for(ll i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			chk(n/i,i); chk(i,n/i);
		}
	}
	cout<<tot-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	int N;
	string tanni;

	cin >> N;

	if (N % 10 == 3) {
		tanni = "bon";
	}
	if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) {
		tanni = "hon";
	}
	if(N%10==0||N%10==1||N%10==6||N%10==8){
		tanni = "pon";
	}
	cout << tanni << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, k;

signed main() {
	int i, j;
	
	cin >> n >> k;
	
	double syoritu = 0;
	for (i = 1; i <= n; i++) {
		if (i < k) {
			int bai = (k + i - 1) / i;
			int j;
			for (j = 0; (1 << j) < bai; j++);
			syoritu += pow(0.5, j);
		}
		else {
			syoritu += 1;
		}
	}
	syoritu /= n;
	
	printf("%.14f\n", syoritu);
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var A = input[0];
            var B = input[1];
            var C = input[2];
            var D = input[3];

            var a = (A - 1) - (A - 1) / C - (A - 1) / D + (A - 1) / Lcm(C, D);
            var b = B - B / C - B / D + B / Lcm(C, D);

            Console.WriteLine(b - a);
        }

        private static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        private static long Gcd(long a, long b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var r = a % b;
                a = b;
                b = r;
            }
            return a;
        }
    }
}

Measured memory_bytes: 13268
n,h = map(int,input().split())

A = []
B = []
for _ in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
maxA = max(A)
B.sort(reverse=True)

cnt = 0
for i in range(n):
    if B[i] > maxA:
        h -= B[i]
        cnt += 1
    else:
        break
    
    if h <= 0:
        break

if h <= 0:
    print(cnt)
elif h % maxA == 0:
    print(h//maxA + cnt)
else:
    print(h//maxA + 1 + cnt)

Measured memory_bytes: 11352