akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int n,m,a,b,c,d[100005] = {};
string s,t;

int main(){
    
    IN n >> m;
    map<int,int> t;
    
    rep(i,0,m){
        IN a >> b;
        t[a]++;
        t[b]++;
    }

    rep(i,1,n+1)P(t[i]);
    
	return  0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
using namespace std;
int main()
{
	int n,l,v=0;
	map<int,int>s;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&l);
		if(!s[l]) s[l]++,v++;
		else s[l]--,v--;
	}
	printf("%d\n",v);
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
using namespace std;
long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    int k;
    cin>>k;
    long long s=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                s+=gcd(i,gcd(j,l));
            }
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3632
const MOD: i64 = 1000000007;

fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	use num::integer::Roots;
	let sqrtn = n.sqrt();
	let mut small = vec![0; sqrtn + 1];
	let mut large = vec![0; sqrtn + 1];
	small[1] = 1;

	for _ in 0..k {
		std::mem::swap(&mut small, &mut large);

		for i in 1..sqrtn {
			large[i + 1] = (large[i + 1] + large[i]) % MOD;
			large[i] = (large[i] * (n / i - n / (i + 1)) as i64) % MOD;
		}
		if sqrtn == n / sqrtn {
			small[sqrtn] = large[sqrtn];
		} else {
			small[sqrtn] = (small[sqrtn] + large[sqrtn]) % MOD;
		}
		large[sqrtn] = (large[sqrtn] * (n / sqrtn - n / (sqrtn + 1)) as i64) % MOD;

		for i in (1..sqrtn).rev() {
			small[i] = (small[i] + small[i + 1]) % MOD;
		}
	}

	let ans = small[sqrtn]
		+ if sqrtn == n / sqrtn { 0 } else { large[sqrtn] }
		+ (1..sqrtn).fold(0, |r, i| (r + small[i] + large[i])) % MOD;
	println!("{}", ans % MOD);
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  vector<vector<int>> a(3,vector<int>(3));
  vector<vector<bool>> f(3,vector<bool>(3,0));
  rep(i,3){
    rep(j,3){
      cin>>a[i][j];
    }
  }
  int n; cin>>n;
  rep(i,n){
    int b; cin>>b;
    rep(j,3){
      rep(k,3){
        if(a[j][k]==b) f[j][k]=1;
      }
    }
  }
  bool c=0;
  if(f[0][0]&&f[0][1]&&f[0][2])
  c=1;
  if(f[1][0]&&f[1][1]&&f[1][2])
  c=1;
  if(f[2][0]&&f[2][1]&&f[2][2])
  c=1;
  if(f[0][0]&&f[1][0]&&f[2][0])
  c=1;
  if(f[0][1]&&f[1][1]&&f[2][1])
  c=1;
  if(f[0][2]&&f[1][2]&&f[2][2])
  c=1;
  if(f[0][0]&&f[1][1]&&f[2][2])
  c=1;
  if(f[0][2]&&f[1][1]&&f[2][0])
  c=1;

  if(c)
  puts("Yes");
  else
  puts("No");


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

/*class Graph {

  map<int, list<pair<int, int> > > l;

public:
  void addEdge(int x, int y, int cost) {
    l[x].pb(make_pair(y, cost));
    l[y].pb(make_pair(x, cost));
  }

  int dfs_helper(int n, int node, map<int, int> &vis, map<int, int> &count, int &ans) {
    //cout << node << " " ;
    vis[node] = 1;
    count[node] = 1;
    for (auto m : l[node]) {
      if (!vis[m.F]) {
        vis[m.F] = 1;
        count[node] += dfs_helper(m.F, vis, count, ans);
        ans += 2 * min(count[node], n - count[node]) * m.S.S;
      }
    }
    return count[node];
  }

  void dfs() {
    map<int, int> vis;
    map<int, int> count;
    int ans = 0;
    dfs_helper(0, vis, count, ans);
    cout << ans << endl;
  }

};*/

int dp[100005];

int f(int a[], int n)
{
  //cout << i << endl;
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    int op1, op2;
    op1 = abs(a[i] - a[i - 1]) + dp[i - 1];;
    if (i - 2 >= 1)
      op2 = abs(a[i] - a[i - 2]) + dp[i - 2];
    else
      op2 = INT_MAX;
    dp[i] = min(op1, op2);
  }
  return dp[n];
}


int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;
  //cin >> t;
  for (int i9 = 1; i9 <= t; i9++)
  {
    /* Graph G;
     int n, x, y, cost;
     cin >> n;
     while (n--) {
       cin >> x >> y >> cost;
       G.addEdge(x, y, cost);
     }
     G.dfs();*/
    //freopen("ouputnew.txt", "w", stdout);
    //flclose(stdout);
    memset(dp, 0 , sizeof (dp));
    int n, k;
    cin >> n;
    int a[n + 1];
    for (int i = 0; i < n; i++)
      cin >> a[i + 1];
    cout << f(a, n);
  }
}



Measured memory_bytes: 5220
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    int N;
    vector<LL> A,B;
    LL ans=0;
    cin>>N;
    REP(i,N){int a,b;cin>>a>>b;A.pb(a);B.pb(b);}
    for(int i=N-1;0<=i;i--){
        if((A[i]+ans)%B[i]!=0)
            ans+=B[i]-((A[i]+ans)%B[i]);
    }
    cout<<ans<<endl;
     return 0;
}

Measured memory_bytes: 2036
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	String O,E;
	public void solve() {
		O = next();
		E = next();

		for(int i = 0;i < Math.max(O.length(), E.length());i++){
			if(i < O.length()){
				out.print(O.charAt(i));
			}

			if(i < E.length()){
				out.print(E.charAt(i));
			}
		}
		out.println();
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<LL> A(N);
	vector<LL> H(N,0);
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	for (i=1;i<N;i++){
		if (A[i-1]+H[i-1]>A[i]){
			H[i]=A[i-1]+H[i-1]-A[i];
		}
	}
	LL ans=0;
	for (i=0;i<N;i++){
		ans+=H[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N,Y,ans=0;
  cin >> N >> Y;
  Y = Y/1000;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N-i; j++) {
      if(Y==10*i+5*j+(N-i-j)){
        cout << i <<" " << j << " " << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
import collections as col

n = int(input())
L_W = []
for i in range(0,n):
    L_W.append(input())
 
dic = col.Counter(L_W)

dic_values_max = max(list(dic.values()))
 
max_key = [i for i, j in dic.items() if j == dic_values_max]
 
max_key.sort()
 
for k in max_key:
    print(k)

Measured memory_bytes: 35572
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a!=b&&b!=c&&a!=c){
    cout<<"3";
  }
  else if(a==b&&b==c&&a==c){
    cout<<"1";
  }
  else{
    cout<<"2";
  }
}

Measured memory_bytes: 3132
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
def plis(a): return " ".join(list(map(str, a)))

alf = list("abcdefghijklmnopqrstuvwxyz")
A = rls()
n = len(A)
ans = n*(n-1)/2 + 1
for i in alf:
    count = 0
    for j in A:
        if(i == j):
            count += 1
    ans -= count*(count-1)/2

print(int(ans))


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 100009
using namespace std;

int n,m,p[N];
struct matrix{ int p[3][3]; }a,b,c;
matrix operator *(matrix x,matrix y){
	matrix z; memset(z.p,0,sizeof(z.p));
	int i,j,k;
	for (i=0; i<3; i++)
		for (j=0; j<3; j++)
			for (k=0; k<3; k++) z.p[i][k]=(z.p[i][k]+(ll)x.p[i][j]*y.p[j][k])%mod;
	return z;
}
matrix ksm(matrix x,int y){
	matrix z; int i;
	memset(z.p,0,sizeof(a.p));
	for (i=0; i<3; i++) z.p[i][i]=1;
	for (; y; y>>=1,x=x*x) if (y&1) z=z*x;
	return z;	
}
int main(){
	scanf("%d%d",&m,&n);
	int i;
	b.p[0][0]=b.p[0][2]=b.p[1][1]=b.p[1][2]=b.p[2][0]=1;
	b.p[0][1]=b.p[2][1]=b.p[2][2]=2;
	memset(a.p,0,sizeof(a.p));
	p[0]=1;
	a.p[0][0]=a.p[0][2]=1; a.p[0][1]=2;
	for (i=1; i<=n; i++){
		scanf("%d",&p[i]); p[i]++;
		a=a*ksm(b,p[i]-p[i-1]-1);
		b.p[2][0]=b.p[2][1]=0; b.p[2][2]=1;
		a=a*b;
		b.p[2][0]=1; b.p[2][1]=b.p[2][2]=2;
	}
	a=a*ksm(b,m-p[n]);
	printf("%d\n",a.p[0][2]);
	return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 1e5 + 5;

int A[N], D[N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	ll s = 0;
	for (int i = 0; i < n; i++) cin >> A[i], s += A[i];
	A[n] = A[0];
	for (int i = 0; i < n; i++) D[i] = A[i + 1] - A[i];
	if (s % (1LL * n * (n + 1) / 2) != 0) die("NO");
	ll k = (2 * s) / (1LL * n * (n + 1));
	for (int i = 0; i < n; i++) if (k < D[i] || (k - D[i]) % n != 0) die("NO");
	cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i = 0; i < D; ++i)  cin >> p[i] >> c[i];

    int ans = INF;
    for(int bit = 0; bit < (1 << D); ++bit){
        int S = 0, cnt = 0;
        for(int i = 0; i < D; ++i){
            if((bit >> i) & 1){
                S += 100 * (i + 1) * p[i] + c[i];
                cnt += p[i];
            }
        }
        if(S >= G){
            chmin(ans, cnt);
            continue;
        }
        for(int i = D - 1; i >= 0; --i){
            if((bit >> i) & 1)  continue;
            int per = 100 * (i + 1);
            int need = (G - S + per - 1) / per;
            if(p[i] >= need){
                S += per * need;
                cnt += need;
                break;
            }
            else{
                S += per * p[i];
                cnt += p[i];
            }
        }
        if(S >= G)  chmin(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int n;
	scanf("%d", &n);
	int *v = malloc(sizeof(int) * n);
	double ans = 0;
	for(int i = 0; i < n; i++)
		scanf("%d", v + i);
	qsort(v, n, sizeof(int), cmp);
	ans = v[0];
	for(int i = 0; i < n; i++)
		ans = (ans + v[i]) / 2;
	printf("%f\n", ans);
	return 0;
}


Measured memory_bytes: 2216
#include <iostream>

using namespace std;

static const int MAX = 100;

void trace(int A[], int N){
    for (int i = 0; i < N; i++){
        if (i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

int selectionSort(int A[], int N){
    int sw = 0;
    for (int i = 0; i < N - 1; i++){
        int minj = i;
        for (int j = i + 1; j < N; j++){
            if (A[j] < A[minj]) minj = j;
        }
        if (i != minj){
            int tmp = A[minj];
            A[minj] =  A[i];
            A[i] = tmp;
            sw++;
        }
    }
    return sw;
}

int main(){
    int A[MAX], num;
    cin >> num;
    for (int i = 0; i < num; i++) cin >> A[i];

    int count = selectionSort(A, num);

    trace(A, num);
    cout << count << endl;

    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

const int INF = 10010010;

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

	vector <int> a(M);
	vector <int> dec(M);	//ベクタc[ii]をinteger値に変換したもの
	for (int ii = 0; ii < M; ++ii){
		int b;
		cin >> a[ii] >> b;
		for (int jj = 0; jj < b; ++jj){
			int c;
			cin >> c;
			c--;
			dec[ii] += (1<<c);
		}
	}

	int stateNum = (1<<N);
	vector <int> dp(stateNum, INF);	//最小値
	vector <bool> visit(stateNum, false);
	visit[0] = true;
	dp[0] = 0;
	for (int ii = 0; ii < N; ++ii){
		for (int state = 0; state < stateNum; ++state){
			if (!visit[state]) continue;
			for (int jj = 0; jj < M; ++jj){
				int newState = state | dec[jj];
				visit[newState] = true;
				dp[newState] = min(dp[newState], dp[state] + a[jj]);
			}
		}
	}

	if (visit[stateNum-1]){
		cout << dp[stateNum-1] << "\n";
	} else {
		cout << -1 << "\n";		
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 8

int X[N][N]={0};

int calc(int);
int Search(int ,int);
void Print();

int main(){
	int a,b,c = 0;
	int n,i,j;

	scanf("%d",&n);
	for(i=0;i < n;i++)
	{
		scanf("%d %d",&b,&a);
		X[b][a] = 1;
	}
	i = calc(c);
	return 0;
}

int Search(int b,int a){
	int i,j;

	for(i=0 ; i < N ; i++)
	{
		if(i!=a && X[b][i] == 1)return 0;
	}
	for(i=0 ; i < N ; i++)
	{
		if(i!=b && X[i][a] == 1)return 0;
	}
	i=b-1; j=a+1;
	while(i >=0 && j < N)
	{
		if(X[i--][j++] == 1)return 0;
	}
	i=b-1; j=a-1;
	while(i >=0 && j >=0)
	{
		if(X[i--][j--] == 1)return 0;
	}
	i=b+1; j=a-1;
	while(i < N && j >=0)
	{
		if(X[i++][j--] == 1)return 0;
	}
	i=b+1; j=a+1;
	while(i < N && j < N)
	{
		if(X[i++][j++] == 1)return 0;
	}
	return 1;
}

int calc(int c){
	int i;
	for(i=0 ; i < N ; i++)
	{
		if(X[c][i] == 1)
		{
			if(!calc(c+1))return 0;
		}
	}
	if(c == N)
	{
		Print();
		return 1;
	}

	else
	{
		for(i=0 ; i < N ; i++)
		{
			if(X[c][i] == 0 && Search(c,i))
			{
				X[c][i]=1;
				if(!calc(c+1))
				{
					X[c][i]=0;
				}
			}
		}
	}
	return 0;
}

void Print()
{
	int i,j;
	for(i=0 ; i < N ; i++)
	{
		for(j=0 ; j < N ; j++)
		{
			if(X[i][j] == 1)
			{
				printf("Q");
			}
			else
			{
				printf(".");
			}
		}
		printf("\n");
	}
	return;
}



Measured memory_bytes: 2084
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var kab = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        if (kab[1] + 2 >= kab[2] || kab[0] <= kab[1])
        {
            WriteLine(kab[0] + 1);
            return;
        }

        kab[0] -= kab[1] - 1;
        WriteLine((long)kab[2] * (kab[0] / 2) + kab[0] % 2 - Max((long)kab[1] * (kab[0] / 2 - 1), 0));
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;
    return 0;
}

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

using namespace std;

#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn;++i)

typedef long long ll;

const int N=200005;
const int M=600005;
const ll INF=(1ll<<60);

int n,m,e,P,a[N]; ll sum;

struct Seg {
	ll A[M];
	void build() {
	  	for(int i=e-1; i>=1; --i)
		  	A[i]=min(A[i<<1],A[i<<1|1]);
	}
	void modify(int t,ll d) {
		t+=e, A[t]=d;
		for(int i=t>>1; i; i>>=1)
			A[i]=min(A[i<<1], A[i<<1|1]);
	  }
	ll query(int l,int r) {
		ll res=INF;
		l=(l-1+e),r=(r+1+e);
		for(; l^r^1; l>>=1,r>>=1) {
			if(~l&1) res=min(res,A[l^1]);
			if( r&1) res=min(res,A[r^1]);
		  }
		return res;
	  }
} F,G;
int main() {
	int i; ll u,v;
	scanf("%d %d %d %d",&n,&m,&a[0],&P);

	for(i=1;i<=m;++i) scanf("%d",&a[i]);
	for(i=1;i<=m;++i) sum+=abs(a[i]-a[i-1]);
	for(e=1;e<=n+1;e<<=1);

	for(i=1;i<=n;++i) F.A[i+e]=G.A[i+e]=INF;
	F.A[P+e]=-P,G.A[P+e]=P;
	F.build(),G.build();

	for(i=1;i<=m;++i) {
		u=min(F.query(1,a[i])+a[i], G.query(a[i],n)-a[i])
		 - abs(a[i]-a[i-1]);
		v = F.A[a[i-1]+e]+a[i-1];
		if(u<v) F.modify(a[i-1],u-a[i-1]),G.modify(a[i-1],u+a[i-1]);
	}
	ll ans=INF;
	for(i=1; i<=n; ++i) ans=min(ans,sum+F.A[i+e]+i);
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int n;
	cin>>n;
	double p[n];
	for(int i=0;i<n;i++)
		cin>>p[i];
	double dp[n+1][n+1]={0};
//	for(int i=0;i<n;i++)
//		cout<<p[i]<<endl;
	for(int i=0;i<n+1;i++)
	{
		for(int j=0;j<n+1;j++)
		{
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(j==0)
				dp[i][j]=dp[i-1][j]*(1-p[i-1]);
			else
				dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1];
		}
	}
	double ans=0;
	for(int i=n/2+1;i<=n;i++)
		ans+=dp[n][i];
	cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 74024
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 5e6 + 5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

vector<int> v[N];
int DP[N];

void solve()
{
	int k;
	cin >> k;
	int curr = 0;
	for(int i = 1; i <= 5000000; i++)
	{
		curr = curr * 10 + 7;
		curr %= k;
		if(curr == 0)
		{
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}
 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> to(N),cost(N);
  rep(i,N-1) {
    int a,b,w;
    cin >> a >> b >> w; a--; b--;
    to[a].push_back(b); cost[a].push_back(w);
    to[b].push_back(a); cost[b].push_back(w);
  }

  vector<int> ans(N,-1);
  queue<int> q;

  ans[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    rep(i,to[v].size()) {
      int u = to[v][i];
      int w = cost[v][i];
      if (ans[u] != -1) continue;
      ans[u] = (ans[v]+w)%2;
      q.push(u);
    }
  }
  rep(i,N){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define INF 1e9+7
using namespace std;
using ll=long long int;
using pii=pair<int,int>;

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m; cin>>n>>m;
    int sum=0;
    for(int i=0;i<m;i++) {
        int t; cin>>t;
        sum+=t;
    }
    if(sum<=n) cout<<n-sum<<endl;
    else cout<<"-1"<<endl;
}



Measured memory_bytes: 3640
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

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

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t;
    for (char c: s) {
        if (t.empty() || t.back() != c) t.push_back(c);
    }
    cout << t.size() << endl;
    return 0;
}


Measured memory_bytes: 592
process.stdin.resume();
process.stdin.setEncoding('utf8');
var input_string = '';

process.stdin.on('data', function(chunk) {
    input_string += chunk;
});

process.stdin.on('end', function() {
    const lines = input_string.split('\n');
  	const n = lines[0]
 	var input = lines[1].split(' ')
    var out = Array()
    for(var i = 0; i < n; i++) {
      out[input[i]] = i+1
    }
	var result = input.join(' ')
    console.log(out.join(' '))
});

Measured memory_bytes: 44604
#include<stdio.h>

int main(){
	int i, j, len, count=0, flag=0;
	char s[100], t[100];
	
	scanf("%s", s);
	scanf("%s", t);

	for(i=0; s[i]!='\0'; i++);
	len = i;

	

	char buff[len];
	

	for(i=0; i<len; i++){
		buff[0] = s[0];
		for(j=0; j<len; j++){
			if(j==len-1){
				s[0] = buff[j];
			}else{
				buff[j+1] = s[j+1];
				s[j+1] = buff[j];
			}
		}
		
		
		for(j=0; j<len; j++){
			if(s[j] == t[j]){
				count++;
			}
		}
		if(count == len){
			flag = 1;
			break;		
		}
		
		count = 0;
		
	}	

	if(flag==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
	
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
        int a,b,k;
        cin>>a>>b>>k;
        int maxn=max(a,b);
        int n=0;
        for(int i=maxn;i>=1;i--)
        {
                if(a%i==0&&b%i==0)
                        n++;
                if(n==k){
                        cout<<i<<endl;
                        break;
                }
        }
        return 0;
}


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

int main(){
  int64_t a,b;
  cin>> a >> b;
  
  int64_t x=max(a,b), y=min(a,b), r=x%y;
  while (r!=0){
    x=y; y=r; r=x%y;
  }
  
  int64_t ans=1;
  x=2;
  bool boo=true;
  while (y>=x*x){
    if (y%x==0){
      ans++;
      while(y%x==0){
        y/=x;
      }
    }
    if (boo){x++; boo=false;}
    else x+=2;
  }
  if(y!=1) ans++;
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int ans=0;
  for(Int i=0;i<n;i++){
    Int j=i;
    while(j<n&&a[i]==a[j]) j++;
    ans+=(j-i)/2;
    i=j-1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
// D - Widespread
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define rp(i,n) for(int i=0;i<(n);++i)
#define roundup(a,b) (((a)+(b)-1)/(b))

int main(){
	int N,A,B; cin>>N>>A>>B;
	vector<int> H(N); rp(i, N) cin>>H[i];
	int ans = INT_MAX;
	LL ab = (LL)A - B;//additional damage
	int L = 0, R = 1e9;
	while(L <= R){
		int t = (L + R)/2;//mid
		LL tb = (LL)t * B;
		LL s = 0;
		rp(i, N){
			LL h = H[i] - tb;
			if(h > 0) s += roundup(h, ab);
		}
		if(t >= s){
			R = t - 1;//mid-1
			ans = t;
		}
		else L = t + 1;//mid+1
	}
	cout<< ans <<endl;
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    int counter = 0;
    int ans;
    for (int i = min(a, b); i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            counter++;
            ans = i;
        }
        if (counter == k) break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(raw_input())
ms = map(int, raw_input().split(' '))
bs = map(int, raw_input().split(' '))
msorig = ms[:]

for i in range(len(bs)):
    if bs[i] >= ms[i]:
        ms[i+1] = max(0, ms[i+1] - (bs[i] - ms[i]))
    ms[i] = max(0, ms[i] - bs[i])

print sum(msorig) - sum(ms)

Measured memory_bytes: 14440
x, y, p, q = map(int, input().split())

p -= x
q -= y

# s -> t
r1 = 'R' * p + 'U' * q

# t -> s
r2 = 'L' + 'D' * (q-1) + 'L' * (p-1) + 'D'

# s -> t
r3 = 'L' + 'U' * (q + 1) + 'R' * (p + 1) + 'D'

# t -> s
r4 = 'R' + 'D' * (q + 1) + 'L' * (p + 1) + 'U'


print(r1 + r2 + r3 + r4)


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
  int i,j,n,k,v,u,a[100][100];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)a[i][j]=0;
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      a[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
        if(j)printf(" ");
      printf("%d",a[i][j]);
      // if(j)printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2072
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int D; cin>>D;
	vector<int> cs(26);
	vector<vector<int>> s(D,vector<int> (26));
	vector<int> last(26,-1);
	rep(i,26)cin>>cs[i];
	rep(i,D)rep(j,26)cin>>s[i][j];
	ll sum = 0;

	vector<int> ans(D);
	rep(d, D){
		int m_type;
		ll m_plus = -INF;
		rep(t, 26){
			int e_ans = s[d][t];
			rep(k, 26){
				if(t == k)continue;
				e_ans -= cs[k] * (d - last[k]);
			}
			if(sum + e_ans > m_plus){
				m_plus = sum + e_ans;
				m_type = t;
			}
		}
		sum = m_plus;
		last[m_type] = d;
		ans[d] = m_type + 1;
	}
	// cout<<sum<<endl;
	rep(i,D)cout<<ans[i]<<endl;
	return 0;
}

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

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

using namespace std;

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

  int cnt = 0;
  for(int i = 0; i < n; i++){
    while(true){
      if(a[i] % 2 == 0){
        a[i] /= 2;
        cnt++;
      }else{
        break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    vector<int> rct(n,0), lct(n,0);
    for(int i=0; i<n; i++){
        if(i){
            rct[i]=rct[i-1];
            lct[i]=lct[i-1];
        }
        if(s[i]=='(') lct[i]++;
        else rct[i]++;
    }
    int ladd=0;
    for(int i=0; i<n; i++){
        ladd=max(ladd,rct[i]-lct[i]);
    }
    
    vector<int> rctb(n,0), lctb(n,0);
    for(int i=0; i<n; i++){
        if(i){
            lctb[i]=lctb[i-1];
            rctb[i]=rctb[i-1];
        }
        if(s[n-1-i]=='(') lctb[i]++;
        else rctb[i]++;
    }
    int radd=0;
    for(int i=0; i<n; i++){
        radd=max(radd,lctb[i]-rctb[i]);
    }
    string s1(ladd,'(');
    s1+=s;
    string s2(radd,')');
    s1+=s2;
    
    cout<<s1;
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		long n=Integer.parseInt(stdin.next());
		long m=Integer.parseInt(stdin.next());
		long ans=0;

		if(n>1 && m>1)
			ans=(n-2)*(m-2);
		else if(n==1 && m>1)
			ans=m-2;
		else if(m==1 && n>1)
			ans=n-2;
		else //if(n==1 && m==1)
			ans=1;

		System.out.println(ans);

	}
}

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

using namespace std;

int main()
{
  int N, K;
  char c;
  string S;

  cin >> N >> S >> K;

  c = S[K - 1];

  for (int i = 0; i < N; i++)
  {
    if (S[i] != c)
    {
      S[i] = '*';
    }
  }

  cout << S << endl;

  return 0;
}

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

int main(){
  string s(101,'b'),t;
  bool flag = true, result = false;
  cin >> s >> t;
  for(unsigned int i = 0; i < t.size(); ++i){
    char tmp = s[t.size() - 1];
    for(unsigned int j = t.size() - 1; j > 0; --j){
      s[j + 1] = s[j];
    }
    s[1] = s[0];
    s[0] = tmp;
    for(unsigned int j = 0; j < t.size(); j++){
      if(s[j] != t[j]){
        flag = false;
        break;
      }
    }
    if(flag){
      result = true;
      break;
    }
    flag = true;
  }
  if(result)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,m;
	cin >> n>> m;
    int l[m];
    int r[m];
    fr(i,m){
      cin >> l[i]>> r[i];
    }
    sort(l,l+m);
    sort(r,r+m);
    cout << max(r[0]-l[m-1]+1,0) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, s;
ll f(ll b, ll n) { return n < b ? n : (f(b, n / b) + n % b);}
int main()
{
	cin >> n >> s;
	for(ll b = 2; b * b <= n; ++b) 
		if(f(b, n) == s)
		{
			cout << b << endl;
			return 0;
		}
	if(n >= s)
	{
		ll x = n - s;
		ll c;
		for(c = 1; c * c <= x; ++c)
			if(x % c == 0)
			{
				ll b = c + 1, x1 = x / (b - 1), x2 = s - x1;
				if(x1 < b && 0 <= x2 && x2 < b)
				{
					cout << b << endl;
					return 0;
				}
			}
		for(--c; c >= 1; --c)
			if(x % c == 0)
			{
				ll b = x / c + 1, x1 = x / (b - 1), x2 = s - x1;
				if(x1 < b && 0 <= x2 && x2 < b)
				{
					cout << b << endl;
					return 0;
				}
			}
	}
	if(n == s)
	{
		cout << n + 1 << endl;
		return 0;
	}
	puts("-1");
	return 0;
}
				

Measured memory_bytes: 3644
def main():
    n = int(input())
    a = list(map(int, input().split(' ')))
    c = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        if a[i] != a[minj]:
            a[i], a[minj] = a[minj], a[i]
            c += 1
    print(' '.join(list(map(str, a))))
    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5604
#include <stdio.h>
int main(void)
{
  double x1,y1,x2,y2;
  scanf("%lf",&x1);
  scanf("%lf",&y1);
  scanf("%lf",&x2);
  scanf("%lf",&y2);
  printf("%lf\n",sqrt(pow(x2-x1,2)+pow(y2-y1,2)));
  return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
using namespace std;

typedef tuple<int, int> mytuple;

int main() {
	int N;

	cin >> N;
	vector<mytuple> Job(N);

	for (int i=0; i<N; i++) {
		int a, b;
		cin >> a >> b;
		auto tmp_tuple = make_tuple(b, a);
		Job.at(i) = tmp_tuple;
	}

	sort(Job.begin(), Job.end());
	int now = 0;
	bool can = true;
	for (int i=0; i<N; i++) {
		auto tmp_tuple = Job.at(i);
		now += get<1>(tmp_tuple);
		if(get<0>(tmp_tuple) < now) {
			can = false;
			break;
		}

	}

	if(can) cout << "Yes";
	else    cout << "No";

}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;

int main(){
	double x1,x2,y1,y2,x,y,n;
	cin >> x1 >> y1 >> x2 >> y2;
	x=x2-x1;
	y=y2-y1;
	n=sqrt((double)pow(x,2.0)+(double)pow(y,2.0));
	printf("%.5f\n",n);
}

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

int main(){
  int n,k;
  cin >> n >> k;
  
  if(n<k)
    cout << 1 << endl;
  else{
  int i=0;
  while(1){
    n /= k;
    if(n<k){
      cout << i+2 << endl;
      break;
    }
    i++;
  }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
int a,b,ans,bas;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(a),read(b),bas=1;
	for(ans=1;;++ans){
		bas*=b;
		if(bas>a) break;
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 256
import functools

def calc_reward(seq):    
    def f(m_r, e):
        return min(m_r[0], e), max(m_r[1], e - m_r[0])
    return functools.reduce(f, seq, (seq[0], 0))[1]

def calc_cost(seq: list):
    mi, ma = min(seq), max(seq)
    if mi == ma:
        return 0
    rev_seq = seq[::-1] 
    return min(seq[seq.index(mi):].count(ma), rev_seq[rev_seq.index(ma):].count(mi))
        
def divide_iter(seq):
    s = [seq[0]]
    for e in seq[1:]:
        if e < s[0]:
            yield s
            s = []
        s.append(e)
    yield s

def solve(seq):
    divided = list(divide_iter(seq))    
    rewards = list(map(calc_reward, divided))
    costs = list(map(calc_cost, divided))
    max_reward = max(rewards)
    return sum(map(lambda r_c: r_c[1], 
            filter(lambda r_c: r_c[0] == max_reward, zip(rewards, costs))))

def main():
    _ = input()
    A = list(map(int, input().split()))
    print(solve(A))

if __name__ == "__main__":
    main()    

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = ~(1<<28);

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    ll A, B, N;

    cin >> A >> B >> N;
    ll ansX = std::min(B - 1, N);
    cout << std::floor((ld)A*ansX/B)-(ld)A*std::floor((ld)ansX/(ld)B) << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

  ll A= 0, B=0, ans=-1;
  cin >> A >> B;

  for (int i=B*10; i<10*(B+1); i++){
    if ((i * 8)/100 == A){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Diff struct {
	Index int
	Diff  int
}

type Diffs []Diff

func (d Diffs) Len() int {
	return len(d)
}
func (d Diffs) Swap(i, j int) {
	d[i], d[j] = d[j], d[i]
}
func (d Diffs) Less(i, j int) bool {
	return d[i].Diff > d[j].Diff
}

var writer = bufio.NewWriter(os.Stdout)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if n > m {
		n = m
	}

	xs := make([]int, m)
	for i := 0; i < m; i++ {
		var x int
		fmt.Scan(&x)
		xs[i] = x
	}

	sort.Ints(xs)

	var diffs Diffs = make([]Diff, m)
	for i := 0; i < m; i++ {
		if i != 0 {
			diffs[i] = Diff{Index: i, Diff: xs[i] - xs[i-1]}
		}
	}
	sort.Sort(diffs)

	target := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		target[i] = diffs[i].Index
	}
	sort.Ints(target)
	target = append([]int{0}, target...)

	ret := 0
	for i := 0; i < n-1; i++ {
		ret += xs[target[i+1]-1] - xs[target[i]]
	}
	ret += xs[m-1] - xs[target[n-1]]

	fmt.Fprintf(writer, "%d\n", ret)
	writer.Flush()
}


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

int main() {
  int n;
  cin >> n;
  while (n) {
    if (n % 10 == 7) {
      cout << "Yes\n";
      return 0;
    }
    n /= 10;
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 3636
def main():
    
    N_all, K_part = map(int, input().split())
    scores = list(map(int, input().split()))

    init = 1

    for i in range(N_all - K_part):
        index = i + K_part
        after = scores[index]
        before = scores[i]
        
        if (before < after):
            print('Yes')
        else:
            print('No')
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 31540
class UnionFind3
  def initialize(size)
    @table = Hash.new{-1}
  end

  def find(x)
    @table[x]<0?x:@table[x]=find(@table[x])
  end

  def union(x, y)
    @table[find(y)] = find(x)
  end
end

#UF=Hash.new{-1}
#def u a,b;UF[f a]=f b;end
#def f c;0>UF[c]?c:UF[c]=f(UF[c])end

cities=(1..n=gets.to_i).map{|i|gets.split.map(&:to_i)+[i]}

road = cities.sort_by{|x,y,i|x}.each_cons(2).map{|(x1,y1,i),(x2,y2,j)|[x2-x1,i,j]}+
       cities.sort_by{|x,y,i|y}.each_cons(2).map{|(x1,y1,i),(x2,y2,j)|[y2-y1,i,j]}

uf=UnionFind3.new(100001)
p road.sort.inject(0){|s,(cost,i,j)|
  if uf.find(i)!=uf.find(j)
    uf.union(i,j)
    s+cost
  else
    s
  end
}


Measured memory_bytes: 29844
import sys
sys.setrecursionlimit(100001)

def gcd(a, b):
    if a == b:
        return a
    elif a == 0:
        return b
    elif b == 0:
        return a
    else:
        if a > b:
            a = a % b
            return gcd(a, b)
        else:
            b = b % a
            return gcd(a, b)

A, B = [int(n) for n in input().split()]

s = A * B // gcd(A, B)

print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//******head by yjjr******
int n,s1=0,s2=0;char ch;
int main(){
    n=read();
    rep(i,1,n){
        cin>>ch;
        if(ch=='B')s1++;else s2++;
    }
    if(s2>s1)puts("Yes");else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 100005
using namespace std;
int n;
int sum=0;
int a[maxn];
int myabs(int now)
{
	return now>0 ? now : -now;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);

	for(int i=0;i<=n;i++)
		sum+=myabs(a[i+1]-a[i]);
//	cerr<<sum<<endl;
	for(int i=1;i<=n;i++)
	{
		int temp1=myabs(a[i]-a[i-1])+myabs(a[i+1]-a[i]);
		int temp2=myabs(a[i+1]-a[i-1]);
		printf("%d\n",sum-temp1+temp2);
	}
}


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

using namespace std;
int a[3];

int main()
{
	int k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a, a+3);

	for(int i = 0 ; i < k ; i++){
		a[2] *= 2;
	}
	cout << a[0] + a[1] + a[2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  string s;
  cin >> s;
  int q;
  cin >> q;
  int f_c=0;
  rep(i,q){
    int t;
    cin >> t;
    if(t==1)f_c++;
    else{
      int f;
      string c;
      cin >> f >> c;
      if((f+f_c)%2==1)s.insert(0,c);
      else s += c;
    }
  }
  if(f_c%2)reverse(s.begin(),s.end());
  cout << s << endl;
}


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

int main() {
    ll n, d, ans = 0;
    vector<ll> x(200010), y(200010);
    cin >> n >> d;
    rep(i, n) cin >> x[i] >> y[i];
    
    rep(i,n){
        ll hoge = x[i] * x[i] + y[i] * y[i];
        if(hoge <= d*d)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6220
import sys
input = sys.stdin.readline

n = int(input())
l = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if k != i and k != j:
                max_t = max(l[i], l[j], l[k])
                if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                    count += (l[i] + l[j] + l[k] - max_t) > max_t
print(count)

Measured memory_bytes: 68616
n = int(input())
*a, = map(int, input().split())
set_a = set(a)
if 0 in set_a:
  print(0)
  exit()
  
res = 1
for elem in a:
  res *= elem
  if res > 10 ** 18:
    print(-1)
    exit()
print(res)
    

Measured memory_bytes: 21788