akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define N 5000
#define INF 1000000000000000LL
typedef long long LL;
using namespace std;
int nd[N], nx[N], g[N], a[N], d[N], cnt = 1, S, T, n;
LL c[N];

void link(int x, int y, LL z) {
    nd[++cnt] = y, nx[cnt] = g[x], c[cnt] = z, g[x] = cnt;
    nd[++cnt] = x, nx[cnt] = g[y], c[cnt] = 0, g[y] = cnt;
}

bool bfs() {
    memset(d, -1, sizeof(d));
    queue<int> q;
    q.push(S), d[S] = 0;
    while (!q.empty()) {
        int tmp = q.front();
        q.pop();
        for(int p = g[tmp]; p; p = nx[p])
            if (d[nd[p]] == -1 && c[p]) {
                d[nd[p]] = d[tmp] + 1;
                q.push(nd[p]);
            }
    }
    return d[T] != -1;
}

LL dfs(int u, LL f) {
    if (u == T || f == 0) return f;
    LL ret = 0;
    for(int p = g[u]; p; p = nx[p])
        if (d[nd[p]] == d[u] + 1 && c[p]) {
            LL w = dfs(nd[p], min(f, c[p]));
            c[p] -= w, c[p ^ 1] += w, f -= w;
            ret += w;
        }
    if (!ret) d[u] = -1;
    return ret;
}

LL dinic() {
    LL ret = 0;
    while (bfs()) ret += dfs(S, INF);
    return ret;
}

void make_edge() {
    S = 0, T = n + 1;
    for(int i = 1; i <= n; i++) {
        if (a[i] >= 0) link(i, T, a[i]);
        if (a[i] < 0) link(S, i, -a[i]);
    }
    for(int i = 1; i <= n; i++)
        for(int j = 2 * i; j <= n; j += i)
            link(i, j, INF);
}

int main() {
    cin >> n;
    LL ans = 0;
    for(int i = 1; i <= n; i++) cin >> a[i], ans += a[i] * (a[i] > 0);
    make_edge();
    cout << ans - dinic() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/

int main()
{
	cin >> n >> m;
	if (n > m) {
		cout << n - m << endl;
	} else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	cout<<s.substr(0,3)<<8<<s.substr(4);
	return 0;
}

Measured memory_bytes: 256
a = list(input())

if a[0]=="o":
    t=100
else:
    t=0
    
if a[1]=="o":
    x=100
else:
    x=0
if a[2]=="o":
	y=100
else:
	y=0
    
total=700+t+x+y

print(total)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int h[1005];
int main()
{
	int x,n,m,y;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		for(int j=1;j<=x;j++)
			cin>>y,h[y]++;
	}
	int ans=0;
	for(int i=1;i<=m;i++)
		if(h[i]==n)
			ans++;
	cout<<ans;
	exit(0);
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n%2==0){
    if(s.substr(n/2)+s.substr(n/2)==s){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vd p(N); REP(i, N) cin >> p[i];
    
    vvd dp(N+1, vd(N+1, 0.0));
    dp[0][0] = 1.0;
    REP(i, N){
        REP(j, i+2){
            if(j == 0){
                dp[i+1][j] = (1-p[i])*dp[i][j];
            }
            else{
                dp[i+1][j] = p[i]*dp[i][j-1] + (1-p[i])*dp[i][j];
            }
        }
    }
    
    double ans = 0.0;
    REP(i, N+1){
        if(i > N-i){
            ans += dp[N][i];
        }
    }
    cout << std::fixed << std::setprecision(20) << ans << endstr;
    return 0;
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char subn[10],input[100000];
gets(subn);
int n = atoi(subn);
gets(input);
int i=0,j=0;
int num[n];
char media[10],submedia[2];
for(i;i<n;i++){
media[0]='\0';
while(input[j] != ' '&&input[j] != '\0'){
submedia[0]=input[j];
submedia[1]='\0';
strcat(media,submedia);
j++;
}
j++;
num[i]=atoi(media);
}
int min=num[0],max=num[0];
long long sum=num[0];
for(i=1;i<=n-1;i++){
sum+=num[i];
if(num[i]>max){
max=num[i];
}
if(num[i]<min){
min=num[i];
}
}
printf("%d %d %lld\n",min,max,sum);
return NULL;
}

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

int main(){
  int N;
  string S;
  cin >>N;
  cin >>S;
  for(int i=0;i<S.size();i++){
    int x = S.at(i)-'A';
    int m = (x+N)%26;
    S.at(i)='A';
    for(int j=0;j<m;j++){
      S.at(i)++;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main(void){
    int i,j,k=0,l;
    int f=0;
    string str;
    string max="\0";
    int count[100]={0};
    string count_str[100];
    int count_max=0;
     
    while(cin>>str){
        if(max.size()<str.size()){
            max=str;
        }
        for(i=0;i<k;i++){
            if(count_str[i]==str){
                count[i]++;
                f=1;
                break;
            }
        }
        if(f==0){
            count_str[k]=str;
            k++;
        }
    }
     
    for(i=0;i<k;i++){
        if(count[count_max]<=count[i]){
            count_max=i;
        }
    }
    cout<<count_str[count_max]<<" "<<max<<endl;
    return(0);
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int W, H, N;
int main() {
    cin >> W >> H >> N;
    vector<vector<int>> board(H, vector<int>(W, 1));
    int x, y, a = 0;
    for(int i = 0; i < N; ++i) {
        cin >> x >> y >> a;
        if(a == 1) {
            for(int j = 0; j < x; ++j) {
                for(int m = 0; m < H; ++m) {
                    board.at(m).at(j) = 0;
                }
            }
        }else if(a == 2) {
            for(int j = x; j < W; ++j) {
                for(int m = 0; m < H; ++m) {
                    board.at(m).at(j) = 0;
                }
            }
        }else if(a == 3) {
            for(int k = 0; k < y; ++k) {
                for(int l = 0; l < W; ++l) {
                    board.at(k).at(l) = 0;
                }
            }
        }else {
            for(int k = y; k < H; ++k) {
                for(int l = 0; l < W; ++l) {
                    board.at(k).at(l) = 0;
                }
            }
        }
    }

    int sum = 0;

    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            sum += board.at(i).at(j);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<p> v(n);
  vector<p> time(n);
  rep(i, n){
    cin >> v[i].first >> v[i].second;
    time[i].second = v[i].first - v[i].second;
    time[i].first = v[i].first + v[i].second;
  }
  sort(ALL(time));
  ll res = n;

  int bi = 0;
  int tmp = 0;
  for (int i = 1; i < n; i++) {
    int start = time[i].second;
    // int end = time[i].first;
    if(start < time[bi].first) {
      // cout << i << endl;
      res--;
      tmp++;
    }else{
      bi += tmp+1;
      tmp = 0;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> K;
	if(K&1)ans = (K / 2)*(K / 2+1);
	else ans = (K / 2)*(K / 2);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

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

typedef unsigned long ul;
using namespace std;

string s;
int n;
int n1;
int n2[200000];

void solve() {
    int bs = 0;
    int bss[n];
    int ws = 0;
    int wss[n];
    REP(i, n) {
        int j = n - i - 1;
        if (s[i] == '#') {
            bs += 1;
        }
        if (s[j] == '.') {
            ws += 1;
        }
        bss[i] = bs;
        wss[j] = ws;
    }
    int res = 300000;
    REP(i, n + 1) {
        if (i == 0) {
            res = min(res, wss[i]);
        } else if (i == n) {
            res = min(res, bss[i - 1]);
        } else {
            res = min(res, bss[i - 1] + wss[i]);
        }
    }
    cout << res;
}

int main() {
    cin >> n;
    REP(i, n) {
        cin >> s[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 2048
// CPP program to find the number of pairs 
// such that gcd equals to 1 
#include <bits/stdc++.h> 
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
#define N 1000050 
#define int long long
int lpf[N], mobius[N]; 
int fre[N] = {0}; 
// Function to calculate least 
// prime factor of each number 
void least_prime_factor() 
{ 
	for (int i = 2; i < N; i++) 

		// If it is a prime number 
		if (!lpf[i]) 

			for (int j = i; j < N; j += i) 

				// For all multiples which are not 
				// visited yet. 
				if (!lpf[j]) 
					lpf[j] = i; 
} 

// Function to find the value of Mobius function 
// for all the numbers from 1 to n 
void Mobius() 
{ 
	for (int i = 1; i < N; i++) { 

		// If number is one 
		if (i == 1) 
			mobius[i] = 1; 
		else { 

			// If number has a squared prime factor 
			if (lpf[i / lpf[i]] == lpf[i]) 
				mobius[i] = 0; 

			// Multiply -1 with the previous number 
			else
				mobius[i] = -1 * mobius[i / lpf[i]]; 
		} 
	} 
} 

// Function to find the number of pairs 
// such that gcd equals to 1 
int gcd_pairs(int a[], int n) 
{ 
	// To store maximum number 
	int maxi = 0; 

	// To store frequency of each number 
	

	// Find frequency and maximum number 
	for (int i = 0; i < n; i++) { 
		fre[a[i]]++; 
		maxi = max(a[i], maxi); 
	} 

	least_prime_factor(); 
	Mobius(); 

	// To store number of pairs with gcd equals to 1 
	int ans = 0; 

	// Traverse through the all possible elements 
	for (int i = 1; i <= maxi; i++) { 
		if (!mobius[i]) 
			continue; 

		int temp = 0; 
		for (int j = i; j <= maxi; j += i) 
			temp += fre[j]; 

		ans += temp * (temp - 1) / 2 * mobius[i]; 
	} 

	// Return the number of pairs 
	return ans; 
} 

// Driver code 
int32_t main() 
{ 
	fast;
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}

	int x= gcd_pairs(a, n); 
	//cout << x << endl;
	if(x==(n*(n-1))/2)
	{
		cout << "pairwise coprime";
		return 0;
	}
	
	int gc=a[0];
	for(int i=1;i<n;i++)
	gc=__gcd(gc,a[i]);
	
	if(gc==1)
	{
		cout << "setwise coprime";
		return 0;
	}
	
	cout << "not coprime";
	
	
	
	
	return 0; 
} 


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

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

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	vector<vector<char>> g(h,vector<char>(w));
	rep(i,h)rep(j,w){
		cin>>g[i][j];
	}
	vector<vector<mint>> dp(h,vector<mint>(w,0));
	dp[0][0]=1;
	rep(i,h)rep(j,w){
		if(g[i][j]=='#') continue;
		if(i+1<h && g[i+1][j]!='#') dp[i+1][j]+=dp[i][j];
		if(j+1<w && g[i][j+1]!='#') dp[i][j+1]+=dp[i][j];
	}
	cout<<dp[h-1][w-1].x<<endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   string S,T;
   cin>>S>>T;
   bool match=false;
   int len=S.size();
   rep(i,len){
       if(S==T){
           match=true;
           break;
       }
       S=S[len-1]+S.substr(0,len-1);
   }
    
    if(match==true){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3608
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N = int(input())
T = [0]*N
A = [0]*N
for i in range(N):
    T[i],A[i] = map(int,(input().split()))

t,a = T[0],A[0]

for i in range(1,N):
    s = T[i] + A[i]
    now = 1
    l = 1
    r = 10**18//s + 1
    mae = -1
    while now != mae:
        mae = now
        if T[i]*now < t or A[i]*now < a:
            l = now
        else:
            r = now
        now = (l+r+1)//2
    t,a = T[i]*now,A[i]*now
print(t+a)

Measured memory_bytes: 39408
N=int(input())
a=list(map(int,input().split()))
brk=0
check=1
  
for i in range(N):
  if check==a[i]:
    check += 1
  else:
    brk +=1

if brk==0:
  print(0)
elif check==1 and brk==N:
  print(-1)
else:
  print(brk)

Measured memory_bytes: 24744
#include <stdio.h>

int main(){
  int a,b,c[2],i,j,k;
  while(1){
    b=0;c[0]=0;c[1]=0;k=0;
    while((a=getchar())){
      if(a==10) break;
      if(a==32) b++;
      else c[b]=c[b]*10+a-48;
    }
    if(b==0) break;
    for(i=c[0];i<=c[1];i++){
      j=i;
      while(j%2==0) j=j/2;
      while(j%3==0) j=j/3;
      while(j%5==0) j=j/5;
      if(j==1)k++;
    }
    printf("%d\n",k);
  }
  return 0;
}

Measured memory_bytes: 368
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
const Int INF = 1e17;
struct edge{
  Int w,u,v,to;
  edge(){}
  edge(Int w,Int u,Int v,Int to):w(w),u(u),v(v),to(to){}
  bool operator<(const edge &a)const{
    if(w!=a.w) return w<a.w;
    if(u!=a.u) return u<a.u;
    return v<a.v;
  }
};

struct LowLink{
  Int n,cnt;
  vector<vector<edge> > G;
  vector<Int> sum,used,pre,low,par;
  
  LowLink(Int n):n(n),cnt(0),G(n),sum(n),used(n),pre(n),low(n),par(n){}

  void add_edge(Int u,Int v,Int w){
    G[u].emplace_back(w,u,v,v);
    G[v].emplace_back(w,u,v,u);
  }

  void dfs(Int v,Int p){
    pre[v]=low[v]=cnt++;
    used[v]=1;
    for(auto e:G[v]){
      Int u=e.to;
      if(!used[u]){
	par[u]=v;
	dfs(u,v);
	low[v]=min(low[v],low[u]);
	sum[v]+=sum[u]+e.w;
      }else if(u!=p){
	low[v]=min(low[v],pre[u]);
        sum[u]+=e.w;
      }      
    }
  }
  
  edge build(){
    dfs(0,-1);
    edge ans(INF,0,0,0);
    Int all=sum[0];
    for(Int i=0;i<n;i++){
      for(edge e:G[i]){
	Int u=e.u,v=e.v;
	if(par[u]==v){	    
	  Int a=sum[u];
	  Int b=all-sum[u]-e.w;
	  edge e2(abs(a-b),u,v,-1);
	  if(pre[u]==low[u]&&e2<ans) ans=e2;
	}
	if(par[v]==u){
	  Int a=sum[v];
	  Int b=all-sum[v]-e.w;
	  edge e2(abs(a-b),u,v,-1);
	  if(pre[v]==low[v]&&e2<ans) ans=e2;
	}
	{
	  edge e2(all-e.w,u,v,-1);
	  if(e2<ans) ans=e2;	  
	}
      }
    }
    return ans;
  }
  
};



signed main(){
  Int n,m;
  cin>>n>>m;
  LowLink G(n);
  Int sum=0;
  for(Int i=0;i<m;i++){
    Int u,v,w;
    cin>>u>>v>>w;
    u--;v--;
    G.add_edge(u,v,w);
    sum+=w;
  }
  edge ans=G.build();
  //cout<<sum<<":"<<G.sum[0]<<endl;
  //cout<<ans.w<<endl;
  assert(sum==G.sum[0]);
  cout<<ans.u+1<<" "<<ans.v+1<<endl;
  return 0;
}



Measured memory_bytes: 18380
n=int(input())
r=sorted([list(map(int,input().split()))for i in range(n)], key=lambda r: -r[1])
b=sorted([list(map(int,input().split()))for i in range(n)])
ans=0
for c,d in b:
  for a,x in r:
    if a<c and x<d:
      r.remove([a,x])
      ans+=1
      break
print(ans)

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

int jump_cost_acc[1000000];
int k;
// 6
// 30 10 60 10 60 50
int jump_cost(int * arr, int n)
{
	if(n<=1) return 0;
    if(jump_cost_acc[n]!=-1) return jump_cost_acc[n];
    

//    else if (n==2) return abs(arr[1] - arr[0]);

    int mini = INT_MAX;
    for(int i =1;i<=min(k,n-1);i++)
    {
        mini = min(mini,abs(arr[i] - arr[0]) + jump_cost(arr+i, n-i) );
    }

    jump_cost_acc[n] =  mini;
    return jump_cost_acc[n];
    
}

int main()
{
    int n;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];

    for(int i =0;i<1000000;i++)jump_cost_acc[i] = -1;
	jump_cost_acc[0] = 0;
	jump_cost_acc[1] = 0;
	jump_cost_acc[2] = abs(arr[n-2] - arr[n-1]);
    cout<<jump_cost(arr,n)<<"\n";
//    for(int i =0;i<= n;i++) cout<<jump_cost_acc[i]<<" ";
//    cout<<endl;
}

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

N = int(input())
Act = [[0,0,0]] + [list(map(int,input().split())) for _ in range(N)]
dp = [[None for _ in range(3)] for _ in range(N+1)]
dp[1][0] = Act[1][0]
dp[1][1] = Act[1][1]
dp[1][2] = Act[1][2]

for i in range(2,N+1):
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + Act[i][0]
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + Act[i][1]
    dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + Act[i][2]
    
ans = max(dp[N])
print(ans)

Measured memory_bytes: 47204
#109_C
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
x=[abs(x[i]-X) for i in range(N)]
GCD=x[0]
for i in range(1,N):
    GCD=fractions.gcd(GCD,x[i])
print(GCD)

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

int main(){
	int n,k,sum=0;
	cin>>n>>k;
	int a[n+1],bj[210000];
	memset(bj,0,sizeof(bj));
	for(int i=1;i<=n;i++){
		cin>>a[i];
		bj[a[i]]++;
	}
	sort(bj+1,bj+n+1);
	
	for(int i=1;i<=n-k;i++){
		sum+=bj[i];
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;


int N, L, M[200], s;
int ea = 10000;
int main() {
	
	cin >> N >> L;
	for (int i = 0; i < N; i++){
		M[i] = L + i;
	}
	for (int i = 0; i < N; i++) {
		if (sqrt(ea * ea) > sqrt(M[i] * M[i])) {
			ea = M[i];
		}
	}
	for (int i = 0; i < N; i++) {
		s += M[i];
	}
	cout << s - ea << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int read()
{int x=0;
char c=getchar();
while (c<'0'||c>'9') c=getchar();
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x;
}
int x[100005],num[17],o[17],cnt=0;
int dp[32769],f[32769],p[32769];
inline int max(int a,int b)
{return a>b?a:b;}
int main (){
	int a,b,c,i,maxn=0,n,j;
	n=read();
	for (i=1;i<n;i++)
	{a=read()+1;b=read()+1;c=read();
	x[a]^=c;x[b]^=c;
	}
	for (i=1;i<=n;i++)
	{num[x[i]]++;}
	maxn=num[0];
	for (i=1;i<=15;i++)
	{maxn+=(num[i]>>1);
	if (num[i]&1) {o[cnt++]=i;}
	}
	for (i=0;i<cnt;i++) p[(1<<i)]=i;
	for (i=1;i<(1<<cnt);i++)
	{f[i]=f[i-(i&(-i))]^o[p[i&(-i)]];}
	for (i=1;i<(1<<cnt);i++)
	{for (j=i;j;j=(j-1)&i)
	{if (f[j]) continue;
	dp[i]=max(dp[i],dp[i^j]+1);
	}
	}
	maxn+=dp[(1<<cnt)-1];
	printf ("%d\n",n-maxn);
	return 0;
}
	
	
	
	
	
	
	

Measured memory_bytes: 896
M, D = map(int,input().split())
cnt = 0
for i in range(1, M+1):
    for j in range(1, D+1):
        d1 = j % 10
        d10 = j // 10
        if d1 >= 2 and d10 >= 2 and d1*d10 == i:
            cnt += 1
print(str(cnt))

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<set>
#include<bitset>
#include<vector>
#include<functional>
#include<deque>
#include<cctype>
#include<climits>
#include<complex>
#include<bits/stdc++.h>
#include<ctime>

using namespace std;

typedef long long LL;
typedef double DB;
typedef pair<int,int> PII;
typedef pair<DB,DB> PDD;
typedef complex<DB> CP;
typedef vector<int> VI;

#define mmst(a,v) memset(a,v,sizeof(a))
#define mmcy(a,b) memcpy(a,b,sizeof(a))
#define fill(a,l,r,v) fill(a+l,a+r+1,v)
#define re(i,a,b)  for(i=(a);i<=(b);i++)
#define red(i,a,b) for(i=(a);i>=(b);i--)
#define rep(i,a,b) for(i=(a);i<(b);i++)
#define fi first
#define se second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define two(k) (1<<(k))
#define SZ(x) (int(x.size()))
#define all(x) (x).begin(),(x).end()
#define ire(i,v,x) for(i=0,v=i<SZ(x)?x[i]:0;i<SZ(x);v=x[++i])
#define ls (rt<<1)
#define rs (rt<<1|1)
#define MID ((l+r)>>1)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template<class T>inline T sqr(T x){return x*x;}
template<class T>inline void upmin(T &t,T tmp){if(t>tmp)t=tmp;}
template<class T>inline void upmax(T &t,T tmp){if(t<tmp)t=tmp;}

inline int sgn(DB x){if(fabs(x)<1e-9)return 0;return(x>0)?1:-1;}
const DB Pi=acos(-1.0);

int gint()
  {
		int res=0;bool neg=0;char z;
		for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
		if(z==EOF)return 0;
		if(z=='-'){neg=1;z=getchar();}
		for(;z!=EOF && isdigit(z);res=(res<<3)+(res<<1)+z-'0',z=getchar());
		return (neg)?-res:res;
	}
LL gll()
  {
  	LL res=0;bool neg=0;char z;
		for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
		if(z==EOF)return 0;
		if(z=='-'){neg=1;z=getchar();}
		for(;z!=EOF && isdigit(z);res=res*10+z-'0',z=getchar());
		return (neg)?-res:res;
	}

int main(){
  //freopen("input.txt","r",stdin);
  LL n=gll();
  std::vector<int> v;
  while(n)v.pb(n%10),n/=10;
  int i,s=0,ret=0;
  re(i,0,SZ(v)-1)ret+=v[i];
  red(i,SZ(v)-1,0)
  	{
  		if(v[i]) upmax(ret,s+v[i]-1+9*i);
  		s+=v[i];
  	}
  cout<<ret<<endl;
  return 0;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n, m;
   cin>>n>>m;
   int h[100000];
   rep(i, n) cin>>h[i];
   bool good[100000];
   rep(i, n) good[i]=true;
   rep(i, m){
      int a, b;
      cin>>a>>b; a--; b--;
      if(h[a]<=h[b]) good[a]=false;
      if(h[b]<=h[a]) good[b]=false;
   }
   int ans=0;
   rep(i, n) if(good[i]) ans++;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 4124
line1 = str(input())
a,b,c = list(line1)
line2 = str(input())
d,e,f = list(line2)
if a==d:
  if b==e:
    if c==f:
      print("3")
    else:
      print("2")
  else:
    if c==f:
      print("2")
    else:
      print("1")
else:
  if b==e:
    if c==f:
      print("2")
    else:
      print("1")
  else:
    if c==f:
      print("1")
    else:
      print("0")

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

int main() {
    int d;
    cin >> d;
    if(d == 25){
        cout << "Christmas" << endl;
    } else if(d == 24){
        cout << "Christmas Eve" << endl;
    } else if (d == 23){
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

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

long long n;
long long bit[201000];

//aの位置にwを追加
void add(long long a,long long w){
    a++;
    for(long long x=a;x<=n+1;x+=x&-x){
        bit[x] += w;
    }
}

//v[1] + ... + v[a]
long long sum(long long a){
    long long ret=0;
    a++; //aを含む範囲の時はこっち
    for(int x=a;x>0;x-=x&-x){
        ret+=bit[x];
    }
    return ret;
}


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

    long long k;
    cin>>n>>k;

    long long a[201000];
    map<long long,int> mp;
    mp[0]=1;
    a[0]=0;

    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]-=k;
        a[i]+=a[i-1];
        mp[a[i]]=1;
    }
    int c=0;
    for(auto i:mp){
        mp[i.first]=c;
        c++;
    }
    for(int i=0;i<=n;i++){
        add(mp[a[i]],1);
    }
    //for(int i=0;i<=n;i++) cout<<bit[i]<<",";
    long long ans=0;
    for(int i=n;i>0;i--){
        add(mp[a[i]],-1);
        ans+=sum(mp[a[i]]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cmath>
using namespace std;
int n;
bool** comp;
long long int** data;
const long long int M = 1000000007;
long long int match(int index, int subset)
{
  if(data[index][subset]!=-1)return data[index][subset];

  if(index==n-1){
    bool check=0;
    for(int i = 0 ; i<n ; i++ )
    {
      if(comp[index][i]==1 && (subset&(1<<i))!=0){check=1;break;}
    }
    data[index][subset]=check;return check;
  }
  long long int sum=0;
  for(int i = 0 ; i<n ; i++ )
  {
    if(comp[index][i]==1 && (subset&(1<<i))!=0)sum += match(index+1,subset&(~(1<<i)));
  }
  data[index][subset]=sum%M;
  return sum%M;
}
int main()
{

  cin>>n;
  comp = new bool*[n];
  for(int i = 0; i<n ; i++ )
  {
    comp[i] = new bool[n];
    for(int j = 0 ; j<n ; j++ )
    {
      cin >> comp[i][j];
    }
  }
  int x = pow(2.0,n);
  data = new long long int*[n];
  for(int i=0;i<n;i++)
  {
    data[i] = new long long int[x];
    for(int j=0;j<x;j++)
    {
      data[i][j]=-1;
    }
  }
  int set = (1<<n)-1;
  cout<<(match(0,set)%M);
  return 0;
}


Measured memory_bytes: 344448
#隣接する点へいく最短経路で使われないことが必要。かつ十分
n,m = map(int, input().split( ))

Ad = [[] for _ in range(n)]
for _ in range(m):
    ai,bi,ci = map(int, input().split( ))
    ai -= 1
    bi -= 1
    Ad[ai].append((bi,ci))
    Ad[bi].append((ai,ci))

dp = [[10**10 for i in range(n)] for j in range(n)]
for i in range(n):
    dp[i][i] = 0
    for b,c in Ad[i]:
        dp[i][b] = c

ans = []

for k in range(n):
    for i in range(n):
        for b,c in Ad[i]:
            if dp[i][b]>dp[i][k]+dp[k][b]:
                ans.append((i,b))
                dp[i][b] = dp[i][k]+dp[k][b]
        for j in range(n):
            dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j])
ans = set(ans)
#print(ans)
print(len(ans)//2)

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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> d(k);
    int i,j,h;
    int ans;
    for(i = 0; i < k; i++)cin>>d.at(i);
    for(i = n; i <= 100000; i++)
    {
        string a = to_string(i);
        bool ok = true;
        for(j = 0; j < k; j++)
        {
            for(h = 0; h < a.length(); h++)
            {
                if(a.at(h)-48 == d.at(j))ok = false;
            }
        }
        if(ok)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

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

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

	int n;
	cin >> n;
	vint t(n), a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int now = n;
	bool flg = true;

	if (n % 2 == 0)
	{
		for (int i = 0; i < n; i++)
		{
			if (flg)
			{
				t[i] = now;
				if (t[i] == 2)
				{
					now = 1;
					flg = false;
					continue;
				}
				now -= 2;
			}
			else
			{
				t[i] = now;
				now += 2;
			}
		}
	}
	else
	{
		for (int i = 0; i < n; i++)
		{
			if (flg)
			{
				t[i] = now;
				if (t[i] == 1)
				{
					now = 2;
					flg = false;
					continue;
				}
				now -= 2;
			}
			else
			{
				t[i] = now;
				now += 2;
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		cout << a[t[i] - 1] << " ";
	}

	return 0;
}

Measured memory_bytes: 5376
from collections import defaultdict
row=defaultdict(int)
col=defaultdict(int)
H,W,M=map(int,input().split())
#matrix=[[1 for i in range(W)] for j in range(H)]
matrix=defaultdict(bool)
for i in range(M):
    h,w=map(int,input().split())
    row[h-1]+=1
    col[w-1]+=1
    matrix[(h-1,w-1)]=True
#print(row)
#print(col)
#for i in matrix:
#    print(*i)
temp=list(row.items())
temp.sort(key=lambda x:x[1])
a,b=temp[-1][0],temp[-1][1]
cnt=0
for i in range(W):
    temp=0
    if matrix[(a,i)]:
        temp=(b+col[i]-1)
    else:
        temp=(b+col[i])
    cnt=max(cnt,temp)
#print(cnt)
temp=list(col.items())
temp.sort(key=lambda x:x[1])
a,b=temp[-1][0],temp[-1][1]
cnt2=0
for i in range(H):
    temp=0
    if matrix[(i,a)]:
        temp=(b+row[i]-1)
    else:
        temp=(b+row[i])
    cnt2=max(cnt2,temp)
print(max(cnt,cnt2))

Measured memory_bytes: 193052
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (ans + k * (n - i - 1) < k * (n - i))
			ans <<= 1;
		else
			ans += k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3588
import Foundation

private func readInt() -> [Int]{
    return readLine()!.split(separator: " ").map{Int($0)!}
}

func mainB() {
    let X = Int64(readLine()!)!
    var a: Int64 = 100
    var count = 0
    while a < X {
        a = Int64(Double(a) * 1.01)
        count += 1
    }
    
    print(count)
}

mainB()


Measured memory_bytes: 13168
n = int(input())
d = list(map(int, input().split()))
if(len(d)%2 == 0):
    d.sort()
    t = int(len(d)/2)-1
    s = d[t]
    m = s
    i = t
    while (d[t+1] > s):
        s += 1
    print(s-m)
else:
    print(0)

Measured memory_bytes: 14556
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vector<ll> v(k+1), w(k+1, 1);
    rep(i,k)v[i+1] = k/(i+1);
    while(n > 0){
        if (n & 1)
            rep(i,k){
                w[i+1] *= v[i+1];
                w[i+1] %= mod;
            }
        rep(i,k){
            v[i+1] *= v[i+1];
            v[i+1] %= mod;
        }
        n >>= 1;
    }
    for(ll i = k; i > 0; --i){
        ll j = i+i;
        for(; j <= k; j+=i){
            w[i] -= w[j];
            w[i] += mod;
            w[i] %= mod;
        }
    }
    ll ans = 0;
    rep(i,k){
        ans += (i+1) * w[i+1];
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 2e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n, x;
int niz[maxn];

int main() {
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++)
		scanf("%d", niz+i);

	llint sol = 0;
	for (int i = 1; i < n; i++) {
		llint tren = max(0, min(niz[i], niz[i] + niz[i - 1] - x));
		sol += tren;
		niz[i] -= tren;
	}

	if (niz[0] + niz[1] > x) sol += niz[0] + niz[1] - x;
	printf("%lld\n", sol);
	return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    ll ans = 0;

    for(int i=0; i<N; i++) {
        sum -= A[i];
        ans += (A[i]) * (sum % (1000000000 + 7));
        ans %= (1000000000 + 7);
    }
    cout << ans;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    VL arr(n);
    ll sum=0;
    fr(i,0,n)
    {
        cin>>arr[i];
        // /sum+=arr[i];
    }
    sort(ALL(arr));
    reverse(ALL(arr));
    if(n==1)
    {
        cout<<"0\n";
    }
    else if(n==2)
    {
        cout<<arr[0]<<"\n";
    }
    else
    {
        sum=arr[0];
        n-=2;
        ll x=n/2;
        fr(i,0,x)
        {
            sum+=(2*arr[1+i]);
        }
        if(n%2==1)
        {
            sum+=arr[x+1];
        }
        cout<<sum<<endl;
    }
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 4776
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <vector>
#include <algorithm>

bool valid(
    int cx, int cy, const std::vector<int> &x, const std::vector<int> &y,
    const std::vector<int> &h, int &res) {

  intmax_t d=h[0]+abs(x[0]-cx)+abs(y[0]-cy);
  for (size_t i=1; i<x.size(); ++i) {
    if (h[i] == 0) {
      if (abs(x[i]-cx)+abs(y[i]-cy) < d) return false;
      continue;
    }
    intmax_t dd=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
    if (dd != d) return false;
  }
  res = d;
  return true;
}

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

  std::vector<int> x(N), y(N), h(N);
  for (size_t i=0; i<N; ++i) {
    std::cin >> x[i] >> y[i] >> h[i];
  }
  if (h[0] == 0) {
    for (size_t i=1; i<N; ++i) {
      if (h[i]) {
        std::swap(x[0], x[i]);
        std::swap(y[0], y[i]);
        std::swap(h[0], h[i]);
        break;
      }
    }
  }

  int res=1;
  for (int i=0; i<=100; ++i) {
    for (int j=0; j<=100; ++j) {
      if (valid(i, j, x, y, h, res)) {
        return !printf("%d %d %d\n", i, j, res);
      }
    }
  }

  return 1;
}


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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if (e-a > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
  
}



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

using namespace std;

int main(){
  int n,k,sum=0;
  cin >> n >> k;
  int l[n];
  for(int i=0;i<n;i++)cin >> l[i];
  sort(l, l+n, greater<int>());
  for(int i=0;i<k;i++)sum+=l[i];
  cout<<sum<<endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <stack>
#include <cstdlib>

using namespace std;

int main()
{
    stack<int> s;
    string a;
    int temp1 = 0,temp2 = 0;
    while(cin >> a)
    {
        if(a[0] == '+')
        {
            temp1 = s.top();
            s.pop();

            temp2 = s.top();
            s.pop();

            s.push(temp1 + temp2);

        }

        else if(a[0] == '-')
        {
            temp1 = s.top();
            s.pop();

            temp2 = s.top();
            s.pop();

            s.push(temp2 - temp1);
        }

        else if(a[0] == '*')
        {
            temp1 = s.top();
            s.pop();

            temp2 = s.top();
            s.pop();

            s.push(temp1 * temp2);

        }

        else
        {
            s.push(atoi(a.c_str()));

        }

    }

    cout << s.top() << endl;

    return 0;
}


Measured memory_bytes: 3180
if true then
  fh=STDIN
else
  fh=open("in1_0112.txt")
end
n=-999

while fh.gets do
  n=$_.chomp.to_i
  break if n==0
  f=[]
  0.upto(n-1){|i| f[i]=fh.gets.chomp.to_i}

  g=f.sort
  acc=0
  h=g.map{|x|
    acc0=acc
    acc+=x
    acc0}
  puts h.inject(0){|acc,x| acc+x}
end
abort("input strange") if n!=0

Measured memory_bytes: 9180
n,m,k=map(int,input().split())

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

mod=10**9+7
a=cmb(n*m-2,k-2)%mod
res=0
for d in range(1,n):
	res+=(d*(n-d)*m**2*a)%mod
	res%=mod
for d in range(1,m):
	res+=(d*(m-d)*n**2*a)%mod
	res%=mod
print(res)

Measured memory_bytes: 52788
# -*- coding: utf-8 -*-
#ABC143C
import sys
import math
import collections
#sys.setrecursionlimit(100000)


n=int(input())

s = input()
#tmp = input().split()
#a = list(map(lambda a: int(a), tmp))

sum=1
for i in range(1,n):
	if(s[i]!=s[i-1]):
		sum+=1

print(sum)



Measured memory_bytes: 3564
//om namah shivaay
//faith over fear
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int fun(ll a,ll b,ll c,ll k){
    if(k==0){
        if((c>b)&&(b>a)) return(1);
        else return(0);
    }
    ll p=fun(2*a,b,c,k-1);
    ll q=fun(a,2*b,c,k-1);
    ll r=fun(a,b,2*c,k-1);
    return(p||q||r);
}

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll p=fun(a,b,c,k);
    if(p==0) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 3624
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int N, M, K;
  cin >> N >> M >> K;

  vector<long long> A(N + 1), B(M + 1);
  A[0] = 0; B[0] = 0;
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    A[i] = A[i - 1] + a;
  }
  for (int i = 1; i <= M; i++) {
    int b;
    cin >> b;
    B[i] = B[i - 1] + b;
  }

  int j = M;
  long long ans = 0;
  for (int i = 0; i <= N && j >= 0; i++) {
    while (A[i] + B[j] > K && j > 0) j--;
    if (A[i] + B[j] <= K) ans = max(ans, (long long)i + j);
  }
  cout << ans << endl;
}

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



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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] AB = Array.ConvertAll(Console.ReadLine().Split(),double.Parse);
            Console.WriteLine(Math.Ceiling((AB[0]+AB[1])/2));
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11092
//  IT'S NEVER TOO LATE...

		    #include <bits/stdc++.h>
			#include <complex>
		    #define ll long long

			#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
			#define forn(i, n) fore(i, 0, n)
			#define fori(i, l, r) fore(i, l, (r) + 1)
			#define sz(v) int((v).size())
			#define all(v) (v).begin(), (v).end()
			#define pb push_back
			#define mp make_pair
		    #define ff first
		    #define ss second
			#define inf 1e9
		    
			#define C complex<int>
			#define X real()
			#define Y imag()

		    using namespace std; 

		    const double PI = atan(1)*4;


		    bool isprime(int n)
		    {
		        for(int i=2;i*i<=n;i++)
		            if(n%i==0)
		                return false;
		        return true;
		    }
		     
		    bool comp(pair<double,int> a, pair<double,int> b)
		    {
		    	if( b.ff == a.ff )
		    		return a.ss < b.ss ;
		    	return b.ff < a.ff ;
		    }

		    int modpow(int b,int p,int m)
		    {
		    	if(p==0) return 1%m;
		    	if(p%2) return (b*modpow(b,p-1,m))%m;
		    	int u=modpow(b,p/2,m);
		    	return (u*u)%m;
		    }

		    vector<int> ar[100005];
		    int vis[100005],from[100005];
		    double dis[100005];
		    
		     
		/*    void dikstra(int s,int n)
		    {
		    	forn(i,n+3)
		    	{
		    		dis[i]=inf;
		    		vis[i]=0;
		    		from[i]=-1;
		    	}

		    	dis[s]=0;
		    	priority_queue<pair<int,int>> q;
		    	q.push({0,s});
		    	from[s]=s;

		    	while(!q.empty())
		    	{
		    		pair<int,int> a;
		    		a=q.top();
		    		q.pop();
		    		//cout<<a.ss<<" ";

		    		if(vis[a.ss]) continue;
		    		vis[a.ss]=1;

		    		for(pair<int,int> b:ar[a.ss])
		    		{
		    			if(dis[b.ff]>dis[a.ss] + b.ss)
		    			{
		    				dis[b.ff]=dis[a.ss] + b.ss;
		    				from[b.ff]=a.ss;
		    				q.push({-dis[b.ff],b.ff});
		    			}
		    		}
		    	}
		    }*/

		    int main()
		    {
		    	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		     
		     
		    	int tt=1;
		    	//cin>>t;
		    	
		    	while(tt--)
		    	{
					int n;
					cin>>n;

					string s;
					cin>>s;

					if(s.length()>n)
					{
						forn(i,n)
						cout<<s[i];
						cout<<"...";
					}
					else
					{
						cout<<s;
					}
				}

		    	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";

		    	return 0;
		    }
		    				//              NOW IT'S TIME TO WAKE UP...

Measured memory_bytes: 6188