akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll N; cin >> N;
  // 4hnw = N(nw + wh + hn) = Nhn + N(h+n)w
  // (4hn - N(h+n))w = Nhn

  for(ll h = 1; h <= 3500;h++) {
    for(ll n = 1; n <= 3500; n++) {
      if(4 * h * n - N * (h + n) != 0 &&
      N * h * n % (4 * h * n - N * (h + n)) == 0 &&
      N * h * n / (4 * h * n - N * (h + n)) > 0) {
        cout << h << " " << n << " " << N * h * n / (4 * h * n - N * (h + n)) << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

int a[100005];
int cost[100005];

int main(void){
	int N;
	cin >> N;
	a[0] = 0;
	a[N] = 0;
	for (int i = 1; i < N+1; i++){
		cin >> a[i];
	}
	int crt = 0;
	for (int i = 0; i <= N+2; i++){
		cost[i] += abs(a[i]-crt);
		crt = a[i];
	}


	for (int i = 1; i <= N+2; i++){
		cost[i] += cost[i-1];
	}

	for (int i = 0; i < N; i++){
		int ans = 0;
		ans = cost[i]+(cost[N+1]-cost[i+2]);
		int before_i;
		if (i) before_i = a[i];
		else before_i = 0;
		int after_i;
		after_i = a[i+2];
		ans += abs(after_i - before_i);
		cout << ans << endl;
	}

	return 0;



}



Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll T1,T2,A1,A2,B1,B2;
    cin >> T1 >> T2;
    cin >> A1 >> A2;
    cin >> B1 >> B2;
    A1 *= T1;
    A2 *= T2;
    B1 *= T1;
    B2 *= T2;
    if(A1 < B1 && A1 + A2 < B1 + B2 || A1 > B1 && A1 + A2 > B1 + B2){
        cout << 00 << endl;
        return 0;
    }else if(A1+A2 == B1+B2){
        cout << "infinity" << endl;
        return 0;
    }
    ll sd = abs(A1-B1);
    ll dd = abs(A1+A2-B1-B2);
    ll r = sd % dd;
    ll q = (sd) / dd;
    q *= 2;
    if(r != 0) q++;
    cout << q << endl;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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

int A,B;
int V,W;
int T;

signed main(){
    cin>>A>>V;
    cin>>B>>W;
    cin>>T;
    int D=abs(A-B)-T*(V-W);
    if(D<=0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3632
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val a, b, q = in.nextInt
  val Max = 10000000000L
  val ss = (-2 * Max) +: Array.fill(a)(in.nextLong) :+ (3 * Max)
  val ts = (-2 * Max) +: Array.fill(b)(in.nextLong) :+ (3 * Max)
  val xs = Array.fill(q)(in.nextLong)

  def search(a: Array[Long], l: Int, r: Int, x: Long): (Long, Long) = {
    val m = (l + r) / 2
    if (x < a(m)) search(a, l, m, x)
    else if (x >= a(m + 1)) search(a, m, r, x)
    else (x - a(m), a(m + 1) - x)
  }

  println(xs.map{x =>
    val (sl, sr) = search(ss, 0, ss.size, x)
    val (tl, tr) = search(ts, 0, ts.size, x)
    Array(
      sl max tl,
      sr max tr,
      sl * 2 + tr,
      tl * 2 + sr,
      sl + tr * 2,
      tl + sr * 2).min
  }.mkString("\n"))
}

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

int main() {
    string S;
    cin >> S;
    vector<string> wrd = {"dream", "dreamer", "erase", "eraser"};

    reverse(S.begin(), S.end());
    for(int i = 0; i < 4; i++) {
        reverse(wrd[i].begin(), wrd[i].end());
    }

    bool flag = true;
    for (int i = 0; i < S.size();) {
        bool flag2 = false;
        for (int j = 0; j < 4; j++) {
            if (S.substr(i, wrd[j].size()) == wrd[j]) {
                flag2 = true;
                i += wrd[j].size();
            }
        }
        if (flag2 == false) {
            flag = false;
            break;
        }
    }

    if (flag) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

int main() {
    ll D; vector<ll> c(26); 
    cin >> D;
    rep(i,26){cin >> c[i];}
    vector<vector<ll>> s(D,vector<ll>(26));
    rep(i,D){rep(j,26){cin>>s[i][j];}}

    vector<ll> t(D,0);
    //rep(i,D){cin >> t[i];}

    vector<ll> zenkai(26,0);

    rep(i,D){
        ll score=0,zantei=-1102342,zanteisyu=0;
        rep(j,26){
            score=0;
            score+=s[i][j];
            rep(k,26){
                if(j!=k){score-=c[j]*(i+1-zenkai[j]);}
            }
            if(score>zantei){
                zantei = score;
                zanteisyu = j+1;
            }
        }
        zenkai[zanteisyu-1]=i+1;
        cout << zanteisyu << endl;
    }
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   long long n;
   cin>>n;
   
   if(n==1){
    cout<<0<<"\n";
   }else if(n==2){
    cout<<2<<"\n";
   }else{
    long long x=1;
    long long y=1;
    long long z=1;
    for(long long i=0;i<n;i++){
        x*=10;
        x%=mod;
        y*=9;
        y%=mod;
        z*=8;
        z%=mod;
    }
    y*=2;
    y%=mod;
    cout<<(x+z-y+mod)%mod<<"\n";
    

   }
   
}


Measured memory_bytes: 3648
using System;

namespace ABC102_A_Multiple_of_2_and_N
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			if (n % 2 == 0)
			{
				Console.WriteLine(n);
			}
			else
			{
				Console.WriteLine(2 * n);
			}
		}
	}
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    int K;
    char S[105],Ans[105];
    
    scanf("%d",&K);
    
    scanf("%s",S);
    
    for(int i = K;i <= 105;i++){
        Ans[i] = '\0';
    }
    
    for(int i = 0;i <= K-1;i++){
        Ans[i] = S[i];
    }
    
    int n = strlen(S);
    
    if(n >= K+1){
        for(int i = 0;i <= 2;i++){
            Ans[K + i] = '.';
        }
    }
    
    
    printf("%s",Ans);
   
   
    return 0;
}


Measured memory_bytes: 1684
#include <cstdio>
#include <complex>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <bitset>
using namespace std;


typedef complex<double> point;
typedef pair<double,int> pdi;

#define EPS 1e-5


vector<pdi> rci, rpi;
bitset<100> used1, used2;
int n, m;

bool check(){
	int i = 0, j = 0;
	while(i < m){
		if( j >= n ) return false;

		if( used1[ rpi[i].second ] ){
			++i;
			continue;
		}
		if( used2[ rci[j].second ] ){
			++j;
			continue;
		}
		
		if( rci[j].first + EPS <= rpi[i].first ){
			return false;
		}

		++i;
		++j;
	}
	return true;
}


int main(){
	scanf("%d%d", &n, &m);
	
	vector<double> rc, rp;
	
	rc.reserve(n);
	rp.reserve(m);
	rci.reserve(n);
	rpi.reserve(m);

	double r, x, y;
	for(int i = 0; i < n; ++i){
		scanf("%lf", &r);
		rc.push_back(r);
		rci.push_back( pdi(r, i) );
	}

	for(int i = 0; i < m; ++i){
		int p;
		scanf("%d", &p);
		
		vector<point> pt;
		pt.reserve(p);
		
		for(int j = 0; j < p; ++j){
			scanf("%lf%lf", &x, &y);
			pt.push_back( point(x, y) );
		}
		
		point pos;
		double t = 0.5;
		double maxnr;

		while( t > 1e-10 ){
			for(int j = 0; j < 100; ++j){
				int index = -1;
				maxnr = -1e99;

				for(int k = 0; k < p; ++k){
					double nr = norm(pos - pt[k]);
					if(maxnr < nr){
						maxnr = nr;
						index = k;
					}
				}
				pos += t * (pt[index] - pos);
			}
			t *= 0.5;
		}
		
		double dist = sqrt(maxnr);
		rp.push_back(dist);
		rpi.push_back( pdi(dist, i) );
	}
	
	sort(rci.begin(), rci.end(), greater<pdi>());
	sort(rpi.begin(), rpi.end(), greater<pdi>());
	
	for(int i = 0; i < m; ++i){
		if( rci[i].first + EPS <= rpi[i].first ){
			puts("NG");
			return 0;
		}
	}
	

	for(int i = 0; i < m; ++i){
		int index = -1;
		bool f = false;

		for(int j = 0; ; ++j){
			if( !used2[j] && rc[j] + EPS > rp[i] ){
				used1.set(i);
				used2.set(j);
				
				if( check() ){
					printf("%d\n", j + 1);
					break;
				}
				else{
					used1.reset(i);
					used2.reset(j);
				}
			}
		}
	}
}

Measured memory_bytes: 1104
N,L=map(int, input().split())
A=list(map(int, input().split()))
x=0
for i in range(N-1):
  d=A[i]+A[i+1]
  if d>=L:
    x=1
    knot=i+1
    break
    
if x==0:
  print('Impossible')
  exit()

print('Possible')
for i in range(1,knot):
  print(i)
for i in range(N-1,knot-1,-1):
  print(i)

Measured memory_bytes: 14076
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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

int m,d;
int mon[13] ={0,0,31,60,91,121,152,182,213,244,274,305,335};

int main(){
	
	while(cin>>m>>d,!(m==0&&d==0)){
		
		d+=mon[m];
		d = d%7;
		if(d==0) cout<<"Wednesday\n";
		if(d==1) cout<<"Thursday\n";
		if(d==2) cout<<"Friday\n";
		if(d==3) cout<<"Saturday\n";
		if(d==4) cout<<"Sunday\n";
		if(d==5) cout<<"Monday\n";
		if(d==6) cout<<"Tuesday\n";
	}
	return 0;
	
}

Measured memory_bytes: 1124
#define _USE_MATH_DEFINES  

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>


int main(){
    std::string s;
    
    while(true){
        std::getline(std::cin, s);
        
        if("0" == s){
            break;
        }else{
            long long ans = 0;

            for(int i = 0; i < s.size(); ++i){
                ans += s.at(i) - 48;
            }

            std::cout << ans << std::endl;
        }
    }    

    return 0;
} 


Measured memory_bytes: 3144
N = int(input())
S = input()
right = S[1:].count('E')
left = 0
answer = right
_reader = S[0]

for i in range(1, N):

    if _reader == "W":
        left += 1

    _reader = S[i]
    
    if _reader == "E":
        right -=1

    t = left + right
    answer = answer if answer <= t else t
        

print(answer)


Measured memory_bytes: 3672
//
// Created on 2018-12-22.
//
#include "bits/stdc++.h"

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<(n);++i)
#define RFOR(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define PB push_back
#define EB emplace_back
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int N, H, W;
    cin >> N >> H >> W;


    int a, b;
    int ans = 0;
    REP(_, N){
        cin >> a >> b;
        if (a>=H and b>=W) ans++;
    }

    cout << ans<< endl;

    return 0;

}

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

int main() {
  int64_t X; std::cin >> X;
  for(int64_t A = -999; A <= 1000; ++A) {
    int64_t A5 = A*A*A*A*A;
    for(int64_t B = -1000; B < A; ++B) {
      int64_t B5 = B*B*B*B*B;
      if(A5 - B5 == X) {
        std::cout << A << " " << B << "\n";
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3624
<?php

$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$m = (int)$input[1];
$c = (int)$input[2];

$b_array = [];
$input = explode(' ', trim(fgets(STDIN)));
foreach ($input as $v) {
	$b_array[] = (int) $v;
}

$count = 0;
for ($i=0; $i < $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$sum = $c;
	for ($j=0; $j < $m; $j++) { 
		$sum += (int)$input[$j] * $b_array[$j];
	}
	if ($sum > 0) {
		++$count;
	}
}
echo $count;

Measured memory_bytes: 4728
#include <stdio.h>
#include <stdlib.h>
#define int long long

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

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

signed main(){
	int X, K, Q, i;
	scanf("%lld%lld", &X, &K);
	int *r = (int *)malloc(sizeof(int) * (K + 1));
	r[0] = 0;
	for(i = 1; i <= K; i++){
		scanf("%lld", &r[i]);
	}
	scanf("%lld", &Q);
	int *t = (int *)malloc(sizeof(int) * Q);
	int *a = (int *)malloc(sizeof(int) * Q);
	for(i = 0; i < Q; i++){
		scanf("%lld%lld", &t[i], &a[i]);
	}
	int *termsd = (int *)malloc(sizeof(int) * (K + 1));
	int *termsu = (int *)malloc(sizeof(int) * (K + 1));
	int *Ad = (int *)malloc(sizeof(int) * (K + 1));
	int *An = (int *)malloc(sizeof(int) * (K + 1));
	int *Au = (int *)malloc(sizeof(int) * (K + 1));
	termsd[0] = 0;
	termsu[0] = X;
	Ad[0] = 0;
	An[0] = 0;
	Au[0] = X;
	for(i = 1; i <= K; i++){
		if(i % 2 == 1){
			Ad[i] = min(X, max(0, Ad[i - 1] + r[i - 1] - r[i]));
			An[i] = An[i - 1] + r[i - 1] - r[i];
			Au[i] = min(X, max(0, Au[i - 1] + r[i - 1] - r[i]));
			termsd[i] = max(termsd[i - 1], -An[i]);
			termsu[i] = min(termsu[i - 1], X - An[i]);
		}
		else{
			Ad[i] = min(X, max(0, Ad[i - 1] - r[i - 1] + r[i]));
			An[i] = An[i - 1] - r[i - 1] + r[i];
			Au[i] = min(X, max(0, Au[i - 1] - r[i - 1] + r[i]));
			termsd[i] = max(termsd[i - 1], -An[i]);
			termsu[i] = min(termsu[i - 1], X - An[i]);
		}
	}
	int left, half, right;
	int ans1, ans2, j;
	for(i = 0; i < Q; i++){
		left = 0;
		right = K + 1;
		while(right - left > 1){
			half = (left + right) / 2;
			if(r[half] < t[i]){
				left = half;
			}
			else{
				right = half;
			}
		}
		if(left % 2 == 0){
			if(a[i] <= termsd[left]){
				ans1 = max(0, Ad[left] + r[left] - t[i]);
			}
			else if(a[i] < termsu[left]){
				ans1 = max(0, a[i] + An[left] + r[left] - t[i]);
			}
			else{
				ans1 = max(0, Au[left] + r[left] - t[i]);
			}
		}
		else{
			if(a[i] <= termsd[left]){
				ans1 = min(X, Ad[left] - r[left] + t[i]);
			}
			else if(a[i] < termsu[left]){
				ans1 = min(X, a[i] + An[left] - r[left] + t[i]);
			}
			else{
				ans1 = min(X, Au[left] - r[left] + t[i]);
			}
		}
		printf("%lld\n", ans1);
/*		ans2 = a[i];
		for(j = 1; r[j] <= t[i] && j <= K; j++){
			if(j % 2 == 1){
				ans2 = max(0, ans2 + r[j - 1] - r[j]);
			}
			else{
				ans2 = min(X, ans2 - r[j - 1] + r[j]);
			}
		}
		if(j % 2 == 1){
			ans2 = max(0, ans2 + r[j - 1] - t[i]);
		}
		else{
			ans2 = min(X, ans2 - r[j - 1] + t[i]);
		}
		printf("%lld\n", ans2);
*/	}
	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n;
	cin >> n;
	int cum1[101], cum2[101];
	int a1[101], a2[101];
	rep(i, n) cin >> a1[i];
	rep(i, n) cin >> a2[i];
	rep(i, n) {
		if (i==0) {
			cum1[i] = a1[i];
			cum2[i] = a2[i];
		} else {
			cum1[i] = cum1[i-1] + a1[i];
			cum2[i] = cum2[i-1] + a2[i];
		}
	}
	int ans = 0;
	rep(i, n) {
		int now = cum1[i] + a2[i] + (cum2[n-1] - cum2[i]);
		ans = max(ans, now);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}


void solve() {
  int n, m;
  cin >> n >> m;
  vector<pii> v(m);

  rep(i, m) {
    int s, c;
    cin >> s >> c;
    s--;
    v[i] = pii(s, c);
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());

  m = sz(v);
  // cout << endl; rep(i, m) cout << v[i] << endl;

  rep(i, m - 1) {
    if (v[i].F == v[i + 1].F && v[i].S != v[i + 1].S) {
      cout << -1 << endl;
      return;
    }
  }

  vector<int> tmp(n, 1);
  rep(i, m) tmp[v[i].F] = v[i].S;

  if (n == 1 && (sz(v) == 0 || v[0].S == 0)) {
    cout << 0 << endl;
    return;
  }
  if (n == 1) {
    cout << tmp[0] << endl;
    return;
  }

  if (n == 2 && tmp[0] == 0 && tmp[1] == 0) {
    cout << 0 << endl;
    return;
  }
  if (n == 2 && tmp[0] == 0) {
    cout << -1 << endl;
    return;
  }

  if (n == 3 && tmp[0] == 0 && tmp[1] == 0 && tmp[2] == 0) {
    cout << 0 << endl;
    return;
  }
  if (n == 3 && (tmp[0] == 0 || (tmp[0] == 0 && tmp[1] == 0))) {
    cout << -1 << endl;
    return;
  }

  vector<int> x(n);
  rep(i, m) x[v[i].F] = v[i].S;
  if (x[0] == 0) x[0] = 1;
  rep(i, n) cout << x[i]; cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sumvec(vector<S>&a){return accumulate(all(a),S());}
template<class S>S maxvec(vector<S>&a){return *max_element(all(a));}
template<class S>S minvec(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}


int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='L'){
                puta("No");
                return 0;
            }
        }else{
            if(s[i]=='R'){
                puta("No");
                return 0;
            }
        }
    }
    puta("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(50 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, m=0, k, ans = 0, a[1005]{}, ma = 0;
    vector<ll> b, tmp;
    cin >> n >> k;
    REP(i,n){
        ll t;
        cin >> t;
        a[i+1] += t;
        a[i+1] += a[i];
    }
    REP(i,n){
        for(int j=i+1;j<=n;j++){
            b.push_back(a[j]-a[i]);
            ma = max(ma, a[j]-a[i]);
        }
    }
    while((1ll<<(m+1))<ma)m++;
    for(int i=m;i>=0;i--){
        int cnt = 0;
        tmp.clear();
        REP(j,b.size()){
            if((b[j]>>i)&1){
                tmp.push_back(b[j]);
                cnt++;
                
            }
        }
        if(cnt>=k){
            ans += (1ll<<i);
            b = tmp;
            //for(auto i : b)cout << "b=" << i << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &V) {
  for (int i = 0; i < (int)V.size(); ++i) {
    if (i != 0) os << ' ';
    os << V[i];
  }
  return os;
}
template<typename T>
istream &operator>>(istream &is, vector<T> &V) {
  for (int i = 0; i < (int)V.size(); ++i) {
    is >> V[i];
  }
  return is;
}

int cnt(int n) {
  int ans = 0;
  while (n != 0) {
    n /= 10;
    ++ans;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  int ans = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    if (cnt(i) % 2 == 1) ans++;
  }
  cout << ans;
  return 0;
} 


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

int main(){
int A, B, C;
cin >> A >> B >> C;
if ((A == 5 || A == 7) && (B == 5 || B == 7) && (B == 5 || B == 7)){
    if (A + B + C == 17) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}
else {
    cout << "NO" << endl;
}
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;

int n,x[105],y[105],c[105];
std::vector<int> a[105];
std::pair<ll,ll> Ans;

void DFS(int x,int y,int d)
{
    int s=0;
    for(int i:a[x])if(i!=y)++s,DFS(i,x,d+1);
    c[d]=std::max(c[d],s);
}

void Update()
{
    ll u=0,v=1;
    while(c[u])v*=c[u++];
    Ans=std::min(Ans,std::make_pair(u,v));
}

int main()
{
    scanf("%d",&n),Ans=std::make_pair(n+1,0);
    for(int i=1;i<n;++i)
    {
        scanf("%d%d",&x[i],&y[i]);
        a[x[i]].push_back(y[i]);
        a[y[i]].push_back(x[i]);
    }
    for(int i=1;i<=n;++i)
    {
        memset(c,0,sizeof c);
        c[0]=1,DFS(i,0,1),Update();
    }
    for(int i=1;i<n;++i)
    {
        memset(c,0,sizeof c);
        c[0]=2,DFS(x[i],y[i],1),DFS(y[i],x[i],1),Update();
    }
    std::cout<<Ans.first<<' '<<Ans.second<<std::endl;
    return 0;
}


Measured memory_bytes: 256
R="R"
L="L"

def f(r, l):
    ans_r = (r // 2) + (l // 2) + (r % 2) 
    ans_l = (r // 2) + (l // 2) + (l % 2)
    return (ans_r, ans_l)

S=input()
N=len(S)
ans=[0]*N

r_begin = 0
r_end = 0
l_begin = 0
l_end = 0
for i in range(N-1):
    if S[i:i+2] == R+L:
        r_end = i
        l_begin = i+1
    elif S[i:i+2] == L+R:
        l_end = i
        a = f(r_end - r_begin + 1, l_end - l_begin + 1)
        ans[r_end] = a[0]
        ans[l_begin] = a[1]
        
        r_begin = i+1
        r_end = 0
        l_begin = 0
        l_end = 0
else:
    l_end = N - 1
    a = f(r_end - r_begin + 1, l_end - l_begin + 1)
    ans[r_end] = a[0]
    ans[l_begin] = a[1]

print(*ans)


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N >> S >> K;
	for (int i = 0; i < N; i++) {
		if (S[K - 1] != S[i])S[i] = '*';
	}
	cout << S;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int d,g;cin>>d>>g;
  int p[11],c[11];
  rep(i,d) cin>>p[i]>>c[i];
  int res=INF;
  rep(i,(1<<d)){
    int score=0,cnt=0;
    rep(j,d){
      if(i>>j&1){
	score+=c[j]+p[j]*100*(j+1);
	cnt+=p[j];
      }
    }
    if(score>=g) res=min(res,cnt);
    else{
      int k=0;
      while(i>>(d-1-k)&1&&k<d) k++;
      if(k==d) return 0;
      int cnnt=0;
      while(score<g&&cnnt<=p[d-1-k]){
	score+=100*(d-k);
	cnnt++;
	cnt++;
      }
      if(cnnt!=p[d-1-k]+1) res=min(res,cnt);
    }
    // prin(score);
  }
  prin(res);
  return 0;
}


Measured memory_bytes: 256
h, w, n = map(int, input().split())
a = [[0] * w for _ in range(h)]

while n > 0:
  n -= 1
  y, x, z = map(int, input().split())
  if z == 1:
    for i in range(y):
      for j in range(w):
        a[i][j] = 1
    continue
  if z == 2:
    for i in range(y, h):
      for j in range(w):
        a[i][j] = 1
    continue
  if z == 3:
    for i in range(h):
      for j in range(x):
        a[i][j] = 1
    continue
  for i in range(h):
    for j in range(x, w):
      a[i][j] = 1

print(w * h - sum(sum(it) for it in a))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
vector<int> E[200200];
bool visited[200200];
vector<int> c;
void dfs(int v){
    visited[v] = true;
    for(int u : E[v]){
            if(!visited[u])dfs(u);
    }
    c[v/100050]++;
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int x,y;
        cin>>x>>y;
        y+=100050;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    ll ret = 0;
    for(int i=1;i<=200100;++i){
        if(!visited[i]){
            c = {0,0};
            dfs(i);
            ret += 1ll*c[0]*c[1];
        }
    }
    cout << ret - n << endl;
    return 0;
}



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

using namespace std;
//namespace adaptor = boost::adaptors;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main()
{
    rep(i,5){
		int a;
		cin >> a;
		if(a == 0){
			cout << i + 1 << endl;
			return;
		}
	}
}

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: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll > P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int x, y;
    cin >> x >> y;
    if(y%2!=0){
        cout << "No" << endl;
        return 0;
    }
    int l = 2*x;
    int r = 4*x;
    if(y >= l && y <= r){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    int m=log2(n);
    long long int sum=0;
    for(int i=0;i<=m;i++)
    {
        sum+=pow(2,i);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()

ja=[[] for i in range(k)]

for i in range(n):
    ja[i%k].append(t[i])

sum=0
for i in range(k):
    for j in range(len(ja[i])):
        if j!=0 and ja[i][j-1]==ja[i][j]:
            c+=1
        else:
            c=1
        if c%2 ==1:
            if ja[i][j]=='r':
                sum+=p
            elif ja[i][j]=='s':
                sum+=r
            else:
                sum+=s

print(sum)


Measured memory_bytes: 13428
import java.util.Scanner;

public class Main {
	static int[] g;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		for(int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();
		int cnt = 0;
		g = new int[N];
		while(true) {
			int m = 1;
			int l = 0;
			int r = 0;
			int c = 0;
			int flag = 0;
			for(int i = 0; i < N; i++) {
				if(h[i] == g[i]) {
					flag++;
					if(flag == N) {
						System.out.println(cnt);
						System.exit(0);
					}
				}
				if(h[i] - g[i] > 0) {
					c++;
					if(c == 1) {
						m = h[i] - g[i];
					}else {
						m = Math.min(m, h[i] - g[i]);
					}
					if(i == N - 1) {
						m = Math.min(m, h[i] - g[i]);
						//System.out.println(i +" " + c);
						add(i - c + 1, i, m);
						//disp(g);
						c = 0;
						cnt += m;
					}
				}else {
					if(c == 0) {
						continue;
					}else {
						add(i - c, i - 1, m);
						//disp(g);
						c = 0;
						cnt += m;
					}
				}
			}
		}
	}

	static void disp(int[] a) {
		for(int i : a) {
			System.out.print(i +" ");
		}
		System.out.println();
	}
	static void add(int l, int r, int m) {
		for(int i = l; i <= r; i++) {
			g[i] += m;
		}
	}
}

Measured memory_bytes: 25172
#include <stdio.h>
#define M 5000000
#define MOD 1000000007
int inv[M],fact[M],factr[M];
int comb(int n,int k){
	if(k<0||n<k)return 0;
	return (long long)fact[n]*factr[k]%MOD*factr[n-k]%MOD;
}
int h(int n,int k){return comb(n+k-1,k);}
int main(){
	int a,b,c,sx,sy,i,d,w,r;
	for(i=0;i<M;i++)inv[i]=fact[i]=factr[i]=1;
	for(i=2;i<M;i++){
		inv[i]=(long long)(MOD-MOD/i)*inv[MOD%i]%MOD;
		fact[i]=(long long)fact[i-1]*i%MOD;
		factr[i]=(long long)inv[i]*factr[i-1]%MOD;
	}
	for(;scanf("%d%d%d%d%d",&a,&b,&c,&sx,&sy),a+b+c;){
		if(sx<sy || (sx==sy&&a<b)){
			a^=b,b^=a,a^=b;
			sx^=sy,sy^=sx,sx^=sy;
		}
		d=sx-sy,r=0;
		if(a==0){
			//x??????????????????????????????????????????????????§???x??????????????????0????????°y??????????????????0??§???????????°?????????
			r=(b>0||sx!=sy) ? 0 : h(c,sx);
		}else if(b==0){
			r=h(a,d-a)*h(a+b+c,sx-d);
		}else{
			for(w=a>d+b?a:d+b;w<=sx;w++){
				r=((long long)h(a,w-a)*h(b,w-d-b)%MOD*h(a+b+c,sx-w)+r)%MOD;
			}
		}
		printf("%d\n",(int)((long long)r*comb(a+b+c,a)%MOD*comb(b+c,b)%MOD));
	}
	return 0;
}

Measured memory_bytes: 59192
#include<stdio.h>
#include<stdlib.h>
int BubSort(int *,int);
void ShowData(int *,int);

int main(){
  int i,n,N;
  int *P;

  scanf("%d",&n);
  P=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&P[i]);
  }
  N=BubSort(P,n);
  ShowData(P,n);
  printf("%d\n",N);
  return 0;
}

  int BubSort(int *P,int n){
    int i,j,tmp,N=0;
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(P[j-1]>P[j]){
	  tmp=P[j];
	  P[j]=P[j-1];
	  P[j-1]=tmp;
	  N++;
	}
      }
    }
    return N;
  }


  void ShowData(int *P,int n){
    int i;
    for(i=0;i<n;i++){
      if(i!=n-1){
	printf("%d ",P[i]);
      }
      else{
	printf("%d",P[i]);
      }
    }
    printf("\n");
  }



Measured memory_bytes: 2088
H,W = map(int, input().split())
a = [list(input()) for i in range(H)]
a = [x for x in a if '#' in x]

aT = list(zip(*a))
aT = [x for x in aT if '#' in x]
ans = list(zip(*aT))

for i in ans:
    print("".join(i))


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n; cin >>n;
    vector<int> a(n); REP(i,n) cin >> a[i];

    vector<int> vals;
    for (int i = 0; i < (int)a.size(); i++) {
        vals.push_back(a[i]);
    }
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());  //重複のない列にしている

    cout << (int)vals.size() << endl;
    return 0;
}



Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.root = [-1] * (n + 1)
            self.rnk = [0] * (n + 1)

        def find_root(self, x):
            while self.root[x] >= 0:
                x = self.root[x]
            return x

        def unite(self, x, y):
            x = self.find_root(x)
            y = self.find_root(y)
            if x == y:
                return
            elif self.rnk[x] > self.rnk[y]:
                self.root[x] += self.root[y]
                self.root[y] = x
            else:
                self.root[y] += self.root[x]
                self.root[x] = y
                if self.rnk[x] == self.rnk[y]:
                    self.rnk[y] += 1

        def isSameGroup(self, x, y):
            return self.find_root(x) == self.find_root(y)

        def size(self, x):
            return -self.root[self.find_root(x)]

    N, Q = map(int, input().split())
    UF = UnionFind(N)
    for _ in range(Q):
        q, u, v = map(int, input().split())
        if q == 0:
            UF.unite(u+1, v+1)
        else:
            print(int(UF.isSameGroup(u+1, v+1)))


if __name__ == '__main__':
    main()


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vector<vll> v(n,vll(26));
  rep(i,n){
    string s; cin>>s;
    rep(j,s.size()){
      v[i][s[j]-'a']++;
    }
  }
  string ans="";
  rep(i,26){
    ll tmp=INF;
    rep(j,n){
      chmin(tmp,v[j][i]);
    }
    rep(j,tmp) ans+=('a'+i);
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int d, e, f;
    d = a + b;
    e = b + c;
    f = c + a;
    
    d = min(d,e);
    d = min(d,f);

    cout << d << endl;

    return 0;
}

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

int main(){
  long n,m;
  cin >> n >> m;
  vector<int> a(m),b(m),size(n),uf(n);
  long maxsize = 1;
  rep(i,n){
    size[i] = 1;
    uf[i] = i;
  }
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    long rx = a[i],ry = b[i],sx = 0,sy = 0;
    while(uf[rx]!=rx){
      rx = uf[rx];
      sx++;
    }
    while(uf[ry]!=ry){
      ry = uf[ry];
      sy++;
    }
    if(rx==ry)continue;
    if(sx>sy){
      uf[ry] = rx;
      size[rx] += size[ry];
    }else{
      uf[rx] = ry;
      size[ry] += size[rx];
    }
  }
  rep(i,n)if(size[i] > maxsize)maxsize = size[i];
  cout << maxsize << endl;
  return 0;
}

Measured memory_bytes: 6416
K,N = input().split()
K = int(K)
N = int(N)

A = []
for i in input().split():
  A.append(int(i))

mergin = []
for i in range(len(A)-1):
  mergin.append(A[i+1]-A[i])
mergin.append(A[0]+K-A[-1])
mergin.sort()

print(K-mergin[-1])
  
  
  
  
  

Measured memory_bytes: 26444
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {

    int n;
    cin >> n;
    vector<P> v(n);
    for (P &p:v) cin >> p.first >> p.second;

    vector<ll> a(n), b(n);
    rep(i, n) a[i] = v[i].first + v[i].second;
    rep(i, n) b[i] = v[i].first - v[i].second;
    auto x = minmax_element(a.begin(), a.end());
    auto y = minmax_element(b.begin(), b.end());

    ll f = (*x.second) - (*x.first);
    ll l = (*y.second) - (*y.first);
    cout << max(f, l) << endl;

}


Measured memory_bytes: 9596
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin>>n;
  
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  
  sort(ALL(vec));
  
  int x = vec[n/2]-vec[n/2-1];
  cout << x <<endl;
  
  return 0;
}

Measured memory_bytes: 640
s = gets.chop
t = gets.chop

y = s.split("")

s.length.times do |i|
  y[s.length] = y[0]
  y = y.drop(1)

  neko = y.join

  if neko == t
    puts "Yes"
    y = false
    break
  end
end

if y
  puts "No"
end


Measured memory_bytes: 1916
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
//typedef pair<ll,ll> p; 
int main()
{
     ll n,k;
     cin>>n>>k;
     ll p;
     p=n/k;
     cout<<min(abs((p+1)*k - n),abs(n - p*k))<<endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define INFll (1LL << 60)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int a, b; cin >> a >> b;
    cout << (1+2+3)-a-b << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			StringBuffer sb = new StringBuffer("I");
			for(int i=0;i<n;i++) sb.append("OI");
			String t = sb.toString();
			int m = sc.nextInt();
			String s = sc.next();
			int count = 0;
			int len = 1+2*n;
			for(int i=0;i<=m-len;i++){
				if(s.substring(i,i+len).compareTo(t)==0) count++;
			}
			System.out.println(count);
		}
	}	
}

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

#define lli long long int
#define mpr make_pair
#define pr pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

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

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res;
}

lli modInverse(lli n,lli  p)
{
	return power(n,p-2,p);
}

lli nCr(lli n,lli r,lli p)
{
	if(r==0)
	return 1;
	lli fac[n+1];
	fac[0]=1;
	for(lli i=1;i<=n;i++)
	fac[i]=fac[i-1]*i%p;
	return ((fac[n]* modInverse(fac[r], p) % p )%p* 
            modInverse(fac[n-r], p) % p) % p; 
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	lli n,c0=0,c1=0,c2=0,c3=0;
	cin>>n;
	for(lli i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s=="AC") c0++;
		else if(s=="WA") c1++;
		else if(s=="TLE") c2++;
		else c3++;
	}
	cout<<"AC x "<<c0<<endl;
	cout<<"WA x "<<c1<<endl;
	cout<<"TLE x "<<c2<<endl;
	cout<<"RE x "<<c3<<endl;



	
	
	
return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,W;
    cin>>n>>W;
    vector<long long> v(n),w(n);
    for(long i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    long long dp[n+1][W+1];
    for(long i=0;i<=n;i++)
    {
        for(long j=0;j<=W;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(w[i-1]<=j)
                dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][W];
    return 0;
}


Measured memory_bytes: 79104
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ").map(Number);
    const A = arr[0];
    const B = arr[1];
    let ans = 0;
    let cur = 1;
    while (cur < B) {
        ans++;
        cur += A - 1;
    }
    console.log(ans);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29504
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)

int main() {
    Int n;
    cin >> n;
    auto s = 0LL;
    reps(i, n) {
        auto c = 1LL;
        auto x = i*c;
        while (x<=n) {
            s += x;
            c++;
            x = i * c;
        }
    }
    PUTS(s)
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

struct Node
{
	int pos;
	int speed;
	double cost;
	int prev;

	bool operator<(const Node& r) const{
		return cost>r.cost;
	}
};

int main()
{
	int n,m;
	while(cin>>n>>m && n)
	{
		vector<Node> G[n];
		int s,g;
		cin>>s>>g;
		--s;
		--g;
		for(int i = 0; i < m; ++i)
		{
			int a,b,c;
			double d;
			cin>>a>>b>>d>>c;
			--a;
			--b;
			G[a].push_back({b,c,d,a});
			G[b].push_back({a,c,d,b});
		}

		priority_queue<Node> q;
		for(Node e: G[s])
		{
			int nv = 1;
			if(nv <= e.speed)
				q.push({e.pos,nv,e.cost/nv,s});
		}

		int d[40][40][40] = {};
		memset(d,0,sizeof(d));
		bool flag = 0;
		while(q.size())
		{
			Node tmp = q.top();
			q.pop();
			
			if(d[tmp.pos][tmp.speed][tmp.prev]++) continue;
			if(tmp.pos == g && tmp.speed == 1)
			{
				printf("%.5lf\n",tmp.cost);
				flag = 1;
				break;
			}

			if(tmp.speed != 0)
				for(Node e: G[tmp.pos])
					for(int nv = tmp.speed-1; nv <= tmp.speed + 1; nv++)
						if(nv > 0 && nv <= e.speed && e.pos != tmp.prev)
							q.push({e.pos,nv,tmp.cost+e.cost/nv,tmp.pos});
		}
		if(!flag)
			cout<<"unreachable"<<endl;
	}
	return 0;
}


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

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

int main()
{
	ll a, b;
	cin >> a >> b;
	cout << a / gcd(a, b) * b;	
	return 0;
}

Measured memory_bytes: 256