akhauriyash/Code-Regression huggingface dataset:
#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>;
 
 
int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int count=0;
    while(true){
        if(a>=b){
            b*=2;
            count++;
        }
        if(b>=c){
            c*=2;
            count++;
        }
        if(a<b&&b<c)break;
    }
    if(count<=k) cout << "Yes" << endl;
    else cout << "No" << endl;
 
}
   


Measured memory_bytes: 3628
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#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 reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int q;
    cin >> q;
    while (q--) {
        int b, e;
        cin >> b >> e;
        reverse(a.begin()+b, a.begin()+e);
    }
    rep(i, n) cout << a[i] << (i == n-1 ? '\n' : ' ');
}



Measured memory_bytes: 3224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_167_Registration
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();
            string t = Console.ReadLine();


            if (System.Text.RegularExpressions.Regex.IsMatch(t, s + @"."))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            //string result = "Yes";
            //if (t.Length - s.Length != 1)
            //{
            //    result = "No";
            //}
            //else
            //{
            //    for (int i = 0; i < s.Length; i++)
            //    {
            //        if (s[i] != t[i])
            //        {
            //            result = "No";
            //            break;
            //        }
            //    }
            //}


            //Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi 3.1415926535
using namespace std;

int main() 
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    if(k<=a) cout<<k;
    else if(k<=a+b) cout<<a;
    else cout<<a-(k-(a+b));
}

Measured memory_bytes: 3636
# coding: utf-8

N = int(input())
alp = [chr(i) for i in range(97, 97+26)]
L = []
for i in range(N):
    s = list(input())
    L.append(s)
for i in range(N):
    L[i].sort()
L.sort()

ans = 0
cnt = 1
for i in range(N-1):
    if L[i]==L[i+1]:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        cnt = 1
if cnt > 1:
    ans += cnt*(cnt-1)//2
print(ans)

Measured memory_bytes: 127040
// https://atcoder.jp/contests/abc165/tasks/abc165_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll X;
  cin >> X;

  ll cur = 100;
  ll res = 0;

  while (cur < X) {
    cur = cur + cur / 100;
    res++;
  }

  cout << res << "\n";
}


Measured memory_bytes: 3644
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<LL, LL>> mazai(n);
	rep(i, 0, n) cin >> mazai[i].fir >> mazai[i].sec;

	SORT(mazai);
	LL ans = 0, sum = 0;
	rep (i, 0, n) {
		if (sum + mazai[i].sec <= m) {
			ans += (mazai[i].first * mazai[i].sec);
			sum += mazai[i].sec;
		}
		else {
			LL c = m - sum;
			ans += (mazai[i].first * c);
			break;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int m = scanner.nextInt();
		int n = scanner.nextInt();
		int[] manju = new int[m];
		for (int i = 0; i < m; i++)
			manju[i] = scanner.nextInt();
		int[] dp = new int[m + 1];
		Arrays.fill(dp, 1 << 30);
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			int c = scanner.nextInt();
			int e = scanner.nextInt();
			for (int j = m; j >= 0; j--) {
				int a = Math.max(0, j - c);
				dp[j] = Math.min(dp[j], dp[a] + e);
			}
		}
		Arrays.sort(manju);
		int ans = 0;
		int sum = 0;
		for (int i = 0; i < m; i++) {
			sum += manju[m - i - 1];
			ans = Math.max(ans, sum - dp[i + 1]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 38636
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007
#define MAXN 300002
ll dp[MAXN][2];
int main() {
       ll t;
       ios::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);
      string s;
      cin>>s;
      for(ll i=1;i<=sz(s);i++)
      {
        dp[i][0]=(s[i-1]!='0')+dp[i-1][1];
        dp[i][1]=(s[i-1]!='1')+dp[i-1][0];
      }
      cout<<min(dp[sz(s)][0],dp[sz(s)][1]);
       return 0;
}

Measured memory_bytes: 2000
import sys

cin = sys.stdin
N, = map(int, cin.readline().split())
A = list(map(int, cin.readline().split()))

pos = []
neg = []
for a in A:
    if a>0:
        pos.append(a)
    else:
        neg.append(a)
if len(neg)>0:
    if len(pos)>0:
        ttl = sum(pos) - sum(neg)
    else:
        ttl = - sum(neg) + 2 * max(neg)
else:
    # N >= 2 => len(pos)>=2
    ttl = sum(pos) - 2 * min(pos) - sum(neg)
print(ttl)

acc = 0
if len(neg)>0:
    if len(pos)>0:
        for i in range(len(pos)-1):
            print(neg[0], pos[i])
            neg[0] -= pos[i]
        print(pos[-1], neg[0])
        pos[-1] -= neg[0]
        for i in range(1, len(neg)):
            print(pos[-1], neg[i])
            pos[-1] -= neg[i]
    else:
        neg.sort()
        for i in range(len(neg)-2, -1, -1):
            print(neg[-1], neg[i])
            neg[-1] -= neg[i]
else:
    # N >= 2 => len(pos)>=2
    pos.sort()
    if N == 2:
        print(pos[1], pos[0])
    else:
        for i in range(1, len(pos)-1):
            print(pos[0], pos[i])
            pos[0] -= pos[i]
        print(pos[-1], pos[0])



Measured memory_bytes: 14036
#include<stdio.h>
int N,E[100010][2],L,M,i,l,r,m;

int ch(int n)
{
	int i,t=1;
	for(i=0;i<N;i++)
		if(E[i][0]<=n&&E[i][1]>=n)
			t++;
	return t>=n;
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d%d",&E[i][0],&E[i][1]);
	for(i=N+1;i>=0;i--)
		if(ch(i))break;
	printf("%d\n",i-1);
	return 0;
}

Measured memory_bytes: 1376
#include<cstdio>
#include<cstring>
using namespace std;

 int main(){
   char S[10];
    
   scanf("%s",S);

  if ((S[0] == 'Y')&&(S[1] == 'A')&&(S[2] == 'K')&&(S[3] == 'I')) printf ("Yes\n");
  else printf ("No\n");


 return 0;
}


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

int main() {
    long long A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long long ans = pow(10, 15);
    for (long long i = 0; i <= pow(10, 5); i++) {
        long long tmpans = i * 2 * C;

        if (X > i) {
            tmpans += (X - i) * A;
        }
        if (Y > i) {
            tmpans += (Y - i) * B;
        }
        ans = min(ans, tmpans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args)throws Exception{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int[] num=new int[10];
        
        for(int i=0;i<10;i++){
            num[i]=Integer.valueOf(buf.readLine());
        }
        Arrays.sort(num);
        
        for(int i=0;i<3;i++){
            System.out.println(num[9-i]);
        }
    }
}

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

int main(){
  string S, T;
  cin >> S >> T;

  bool ans = false;
  for(int i = 0; i < S.length(); i++){
    bool ans_i = true;
    for(int j = 0; j < S.length(); j++){
      if(S[j] != T[(j + i) % S.length()]){
        ans_i = false;
      }
    }
    ans = ans || ans_i;
  }

  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
while True:
    x,y=map(int,input().split())
    if x==0 and y==0:
        break
    num=0
    while True:
        num+=1
        if x==0:
            print(y,num-1)
            break
        elif y==0:
            print(x,num-1)
            break
        
        elif x>=y:
            x=x%y
        elif x<y:
            y=y%x
            
        


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

int main(){
	int a, b;		
	while(cin >> a >> b){		
		if(a > b){
			printf("-1\n");
			continue;
		}
		bool f = false;
		for(int i = 10; i <= 1000; i++){
//			int x = i * 8, y = i;
//			if(x % 10 == 0){
//				if(x / 10 % 10 <= 5) x = x / 100;
//				else x = x / 100 + 1;
//			}
//			else if(x % 10 <= 5)x = x / 100;
//			else {
//				x += 10;
//				x /= 10;
//				if(x % 10 > 5)
//					x = x / 100 + 1;
//				else x = x / 100;
//			}
//			if(y % 10 <= 5) y = y / 10;
//			else y = y / 10 + 1;
			int x = i * 0.08, y = i * 0.1;
			if(x == a && y == b){
				printf("%d\n",i);
				f = true;
				break;
			}
		}
		if(f) continue;
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

template <typename K, typename V, typename A>
void  key_count (map<K, V> &mapBuff, A a){
    for(auto c : a) {
        if (mapBuff.count(c) == 0 ) {
            mapBuff.insert(make_pair(c, 1));
        } else {
            auto it = mapBuff.find(c);
            mapBuff.insert(make_pair(c, it->second++));
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<string> vec(n);
    map<string, long long> m;
    long long ans = 0;
    for(int i = 0; i < n; i++){
        cin >> vec.at(i);
        sort(vec[i].begin(),vec[i].end());
    }

    key_count(m,vec);

    for(auto i = m.begin(); i != m.end(); ++i){
        if (i->second >= 2) {
            ans += (i->second * (i->second - 1))/2;
        }
        //cout << i->first << i->second << endl;
    }
   cout << ans << endl;
}

Measured memory_bytes: 18944
/*
                            Author: Ankit Kaul
*******Code Belongs to Respective Author Only*************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
/*freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x)%M;
            x=(x*x)%M;
            n=n/2;
        }
    return result%M;
}
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}   
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi  
    int x;
    cin>>x;
    if(x==0)
    cout<<1<<endl;
    else
    cout<<0<<endl;        
}


Measured memory_bytes: 3648
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int my_abs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    vector<int> bun(3);
    cin >> bun.at(0) >> bun.at(1) >> bun.at(2);
    vector<int> ans(11);
    ans.at(bun.at(0))++;
    ans.at(bun.at(1))++;
    ans.at(bun.at(2))++;
    if (ans.at(5) == 2 && ans.at(7) == 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
int n,v[20],x[N],dep,dpl[N],dpr[N];
int blo[20][N],L[20][N],R[20][N];
void init(int dep){
	int cnt=0;
	blo[dep][1]=L[dep][1]=R[dep][1]=cnt=1;
	for (int i=2;i<=n;i++){
		if (x[i-1]+v[dep]>=x[i]) blo[dep][i]=cnt,R[dep][cnt]++;else
		blo[dep][i]=++cnt,L[dep][cnt]=R[dep][cnt]=i;
	}
	L[dep][0]=1;R[dep][0]=n;
}
bool ans[N];
int main()
{
	scanf("%d%d",&n,&v[0]);
	while (v[dep]) v[dep+1]=v[dep]>>1,dep++;
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	for (int i=0;i<=dep;i++) init(i);
	int U=(1<<dep)-1;
	for (int S=1;S<=U;S++)
	for (int i=0;i<dep;i++)
	if (S>>i&1) dpl[S]=max(dpl[S],R[i+1][blo[i+1][dpl[S^(1<<i)]+1]]);
	for (int S=0;S<=U;S++) dpr[S]=n+1;
	for (int S=1;S<=U;S++)
	for (int i=0;i<dep;i++)
	if (S>>i&1) dpr[S]=min(dpr[S],L[i+1][blo[i+1][dpr[S^(1<<i)]-1]]);
	if (blo[0][n]<=20){
		for (int i=1;i<=blo[0][n];i++){
			int l=L[0][i],r=R[0][i];bool ok=0;
			for (int S=0;S<=U;S++)
			if (dpl[S]>=l-1&&dpr[U^S]<=r+1) ok=1;
			if (!ok) continue;
			for (int j=l;j<=r;j++) ans[j]=1;
		}
	}
	for (int i=1;i<=n;i++) puts(ans[i]?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 74112
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    vector<vector<int>>A(9,vector<int>(9,0));
    for(int i=1;i<=N;i++){
        string d=to_string(i);
        int j=d[0]-'0';
        int k=i%10;
        if(k!=0)A[j-1][k-1]++;
    }
    int ans=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=A[i-1][j-1]*A[j-1][i-1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    int n;
    cin >> n;
    int S[9][9];
    int a=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(n==i*j){
                a++;
            }
        }
    }
    if(a>=1){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

const int MAX_N = int(1e5);
const int MAX_M = int(2e5);

template<typename numType>
inline bool updateMax(numType& old, const numType& test) {
	if (old < test) {
		old = test;
		return true;
	}
	return false;
}

struct Edge {
	int from, to;

	Edge(){}
	Edge(int from_, int to_):
		from(from_), to(to_)
	{}
};

int N, M;
vector<int> ids[MAX_N];
vector<Edge> graph[MAX_N];
Edge es[MAX_M];

int lengthFromS[MAX_N], lengthFromT[MAX_N];

void init() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a; --b;
		es[i] = Edge(a, b);
		graph[a].push_back(Edge(a, b));
		graph[b].push_back(Edge(b, a));
	}
}

void solve() {
	int height = 0;
	for (int v = 0; v < N; ++v) {
		updateMax(height, lengthFromS[v]);
		for (int i = 0; i < int(graph[v].size()); ++i) {
			const Edge &e = graph[v][i];
			const int u = e.to;
			if (v < u) {
				updateMax(lengthFromS[u], lengthFromS[v] + 1);
			}
		}
	}

	for (int v = N - 1 ; v >= 0; --v) {
		for (int i = 0; i < int(graph[v].size()); ++i) {
			const Edge &e = graph[v][i];
			const int u = e.to;
			if (v > u) {
				updateMax(lengthFromT[u], lengthFromT[v] + 1);
			}
		}
	}

	for (int i = 0; i < M; ++i) {
		if (lengthFromS[es[i].from] + 1 + lengthFromT[es[i].to] == height) {
			ids[lengthFromS[es[i].from]].push_back(i);
		}
	}

	vector<int> ans;
	for (int i = 0; i < N; ++i) {
		if (int(ids[i].size()) == 1) {
			ans.push_back(ids[i][0]);
		}
	}
	sort(ans.begin(), ans.end());
	if (ans.empty()) {
		puts("-1");
	}
	else {
		for (int i = 0; i < int(ans.size()); ++i) {
			printf("%d\n", ans[i]+1);
		}
	}
}

int main() {
	init();
	solve();
	return 0;
}

Measured memory_bytes: 14324
Input1 = input().split(" ")
Input2 = input().split(" ")
Input3 = input()
Dict = {}
Dict[Input1[0]] = int(Input2[0])
Dict[Input1[1]] = int(Input2[1])
Dict[Input3] -= 1
print("{0} {1}".format(Dict[Input1[0]],Dict[Input1[1]]))

Measured memory_bytes: 3060
H,W,K = map(int,input().split())
cake = [list(input()) for i in range(H)]
K += 1
noichigo = []
for i in range(H):
    if '#' in cake[i]:
        ichigo = 0
        K -= 1
        for j in range(W):
            if cake[i][j] == '#' and ichigo == 0:
                ichigo = 1
                cake[i][j] = K
            elif cake[i][j] == '#' and ichigo == 1:
                K -= 1
                cake[i][j] = K
            else:
                cake[i][j] = K
    else:
        noichigo.append(i)
for i in range(len(noichigo)):
    get = noichigo[0]
    want = noichigo[0]
    while get in noichigo and get < H:
        get += 1
    if get < H:
        cake[want] = cake[get]
        noichigo.pop(0)
    else:
        break
for i in range(len(noichigo)):
    get = noichigo[0]
    want = noichigo[0]
    while get in noichigo:
        get -= 1
    cake[want] = cake[get]
    noichigo.pop(0)
for h in range(H):
    ans = list(map(str, cake[h]))
    print(' '.join(ans))


Measured memory_bytes: 7280
import java.awt.datatransfer.FlavorEvent;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.nextLine();
        String str2[] = str.split(" ");
        int ints[] = new int[n];
        int flag = 1;
        int count = 0;

        for(int i = 0;i<n;i++)
        {
            ints[i]= sc.nextInt();
        }

        while (flag==1){
             flag = 0;
             for(int j=n-1;j>0;j--)
            {
                if(ints[j]<ints[j-1])
                {
                    int x = ints[j];
                    ints[j]=ints[j-1];
                    ints[j-1]=x;
                    flag = 1;
                    count++;
                }
            }
        }
        for (int i = 0; i<n;i++)
        {
          System.out.print(ints[i]);
          if(i!=n-1)
            System.out.print(" ");
        }
        System.out.print("\n"+count+"\n");
    }   
}


Measured memory_bytes: 26520
S=input()
ans = True
while S:
    if S.endswith("dream"): S = S[:-len("dream")]
    elif S.endswith("dreamer"): S = S[:-len("dreamer")]
    elif S.endswith("erase"): S = S[:-len("erase")]
    elif S.endswith("eraser"): S = S[:-len("eraser")]
    else:
        ans = False
        break
print('YES' if ans else 'NO')

Measured memory_bytes: 133908
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    int H,W,K; cin >> H >> W >> K;
    char C[H][W];
    rep(i,H){
        rep(j,W){
            cin >> C[i][j];
        }
    }
    int cnt[H+1][W+1];
    rep(i,H+1) rep(j,W+1) cnt[i][j]=0;
    rep(i,H){
        rep(j,W){
            if(C[i][j]-'0') cnt[i+1][j+1]=1;
        }
    }
    rep(i,H){
        rep(j,W){
            cnt[i+1][j+1]+=cnt[i+1][j];
        }
    }
    rep(i,H){
        rep(j,W){
            cnt[i+1][j+1]+=cnt[i][j+1];
        }
    }
    int ans=INF;
    rep(i,(1<<(H-1))){
        int cntt=0;
        vi v;
        v.eb(0);
        rep(j,H-1){
            if((i>>j)&1) {
                cntt++;
                v.eb(j+1);
            }
        }
        v.eb(H);
        int pos=0;
        int rpos=0;
        bool frag=true;
        while(pos<=W){
            bool can=true;
            rep(j,v.size()-1){
                if(cnt[v[j+1]][pos]-cnt[v[j+1]][rpos]-cnt[v[j]][pos]+cnt[v[j]][rpos]>K){
                    can=false;
                }
            }
            if(!can) {
                if(pos-rpos==1) frag=false;
                rpos=pos-1;
                cntt++;
            }
            pos++;
        }
        if(frag) chmin(ans,cntt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>

using namespace std;

int gcd(int a, int b){
  int r;
  while(b != 0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {

  int n, ans = 0;
  char inp, old = '#';
  double clay, third;
  cin >> n;
  for(int a =1;a <= n;a++){
    for(int b =1;b <= n;b++){
      for(int c =1;c <= n;c++){
        ans += gcd(a, gcd(b, c));
      }
    }
  }
  cout << ans;
  return 0;
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 0;
  int pf = 0, pb = n-1;
  while (pf <= pb) {
    // 左端からWを見つける
    for (;pf<=pb;++pf) {
      if (s[pf] == 'W') {
        break;
      }
    }
    // 右端からRを見つける
    for(;pb>=pf;--pb){
      if (s[pb] == 'R') {
        break;
      }
    }
    if ((pf < pb) && (s[pf] == 'W' && s[pb] == 'R')) {
      swap(s[pf], s[pb]);
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
string a;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a;
    a[3] = '8';
    cout<<a;
    return 0;
}

Measured memory_bytes: 764
def main():
    A = int(input())
    T = prime_decomposition(A)
    TV = list(set(T))
    cnt = 0
    #if(A==1):
    #    print(0)
    #    return

    for d in TV:
        D = T.count(d)
        cc = 0
        while True:
            cc +=1
            if D >=cc:
                D-=cc
                cnt +=1
            else:
                break

    print(cnt)




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

if __name__ == '__main__':
    main()


Measured memory_bytes: 9272
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,c = map(int,input().split())
    xv = [list(map(int,input().split())) for i in range(n)]
    x = [xv[i][0] for i in range(n)]
    v = [xv[i][1] for i in range(n)]
    r1,r2,l1,l2 = [0]*(n+1),[0]*(n+1),[0]*(n+1),[0]*(n+1)
    ans = 0
    dis = 0
    for i in range(n):
        r1[i+1] = r1[i]+v[i]-(x[i]-dis)
        r2[i+1] = r2[i]+v[i]-2*(x[i]-dis)
        dis = x[i]
    dis = c
    for i in reversed(range(n)):
        l1[n-i] = l1[n-i-1]+v[i]-(dis-x[i])
        l2[n-i] = l2[n-i-1]+v[i]-2*(dis-x[i])
        dis = x[i]
    for i in range(n):
        l1[i+1] = max(l1[i+1],l1[i])
        r1[i+1] = max(r1[i+1],r1[i])
    for i in range(n+1):
        ans = max(ans,max(r2[i]+l1[n-i],l2[i]+r1[n-i]))
    print(ans)

if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 49732
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	int sum = 0;
	for(string s; getline(cin, s);) {
		rep(i,s.length()) if(!isdigit(s[i])) s[i] = ' ';
		istringstream is(s);
		for(int t; is >> t;) {
			sum += t;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
   int main(void){
      int a, b;
      int i, j, k;
      
      scanf("%d", &a);
      scanf("%d", &b);
      i = a % 3;
      j = b % 3;
      k = (a+b) % 3;
      
      if(i == 0){
      printf("Possible");
         }else if(j == 0){
         printf("Possible");
            }else if(k == 0){
            printf("Possible");
      }else {
         
         printf("Impossible");
      }
   return 0;
}

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

vector<P>prime_factorize(int n) {
    vector<P> res;
    for (int p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  rep(c,1,n){
    //cout << "c = " << c << endl;
    if(c == n-1) ans += 1;
    else{
      int tmp = 1;
      vector<P>data = prime_factorize(n-c);
      rep(i,0,data.size()){
        //cout << data[i].first << " " << data[i].second << endl;
        tmp *= data[i].second+1;
      }
      ans += tmp;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

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

    int n, m;
    cin >> n >> m;
    priority_queue<pair<int,int>> pq;
    vector<int> v(n);

    long long totalSum = 0;
    for(int i= 0; i< n; ++i)
    {
        cin >> v[i];
        totalSum+=v[i];
    }

    for(int i =0; i < n; ++i)
    {
        pq.push({v[i]-(v[i]>>1), v[i] >> 1});
    }

    while(m--)
    {
        pair<int,int> x = pq.top();
        totalSum-=x.first;
        pq.pop();
        pq.push({x.second-(x.second>>1),x.second>>1});
    }

    cout << totalSum;

    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b)
{
   return a  / gcd(a, b)*b;
}
int main() {
  int n; cin >>n;
  vector<long long>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  long long kotae=1;
  for(int i=0;i<n;i++){
    kotae=lcm(kotae,a[i]);
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    [N, W] = [int(num) for num in input().split()]

    products = []
    for i in range(N):
        products.append([int(num) for num in input().split()])

    dp = [[0] * (W+1) for _ in range(N+1)]

    for i in range(N+1):
        if i == 0:
            continue
        for w in range(W+1):
            if w < products[i-1][0]:
                dp[i][w] = dp[i-1][w]
            else:
                dp[i][w] = max(dp[i-1][w-products[i-1][0]] + products[i-1][1], dp[i-1][w])

    print(dp[N][W])

if __name__ == '__main__':
    main()


Measured memory_bytes: 118256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int ct=0,temp,q,i;
	int p[101],s[101];
	int rank[101];
	
	while(scanf("%d,%d",&p[ct],&s[ct])){
		if(p[ct]==0&&s[ct]==0)
		break;
		ct++;
	}
	for(i=0;i<ct;i++){
		for(int j=i+1;j<ct;j++){
			if(s[i]<s[j]){
				temp = p[i];
				p[i] = p[j];
				p[j] = temp;
				temp = s[i];
				s[i] = s[j];
				s[j] = temp;
			}
		}
	}
	rank[0]=1;
	temp = 1;
	for(i=1;i<ct;i++){
		if(s[i-1]!=s[i]){
			temp++;
			rank[i]=temp;
		}
		else
		rank[i]=temp;
	}
	while(scanf("%d",&q)!=EOF){
		for(int i=0;i<ct;i++){
			if(q==p[i]){
				printf("%d\n",rank[i]);
				break;
			}
		}
	}
}

Measured memory_bytes: 3216
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

vector<vector<char>> grids;

int main()
{
    int H, W; cin >> H >> W;
    grids = vector<vector<char>>(H, vector<char>(W));
    for (int r = 0; r < H; ++r)
    {
        for (int c = 0; c < W; ++c)
        {
            cin >> grids[r][c];
        }
    }
    vector<vector<int>> dists(H, vector<int>(W, 1000000));
    dists[0][0] = (grids[0][0] == '.') ? 0 : 1;
    for (int r = 0; r < H; ++r)
    {
        for (int c = 0; c < W; ++c)
        {
            if (r > 0)
            {
                if (grids[r][c] == grids[r - 1][c])
                {
                    dists[r][c] = min(dists[r][c], dists[r - 1][c]);
                }
                else
                {
                    dists[r][c] = min(dists[r][c], dists[r - 1][c] + 1);
                }
            }
            if (c > 0)
            {
                if (grids[r][c] == grids[r][c - 1])
                {
                    dists[r][c] = min(dists[r][c], dists[r][c - 1]);
                }
                else
                {
                    dists[r][c] = min(dists[r][c], dists[r][c - 1] + 1);
                }
            }
        }
    }
    if (grids[H - 1][W - 1] == '#')
    {
        ++dists[H - 1][W - 1];
    }
    cout << dists[H - 1][W - 1] / 2 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<string,int,int>;

int main(){
  int n; cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  int mx = h[0];
  int ans = 1;
  for(int i = 1; i < n; i++){
    if(mx > h[i]) continue;
    ans++;
    mx = h[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	
	ll X; cin >> X;
	ll tmp = 100;

	ll ans = 0;
	while(tmp < X){
		tmp = tmp * 1.01;
		ans++;
	}

	cout << ans << endl;




	return 0;

}


Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,n=0,h,w,j,i,c=0;
    char x[100],y[100];
    scanf("%s%s",x,y);
    for(i=strlen(y)-1;i>=0;i--)
    {
        y[i]='\0';
        if(strcmp(x,y)==0)
        {
            c=1;
            break;
        }
    }
    if(c==1){printf("Yes\n");}
    else{printf("No\n");}



    return 0;
}


Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3752
n,k=map(int, input().split())
ans=True
for i in range(n+1):
    for j in range(n-i+1):
        if k-(10000*i+5000*j)==(n-i-j)*1000:
            print(i,j,n-i-j)
            ans=False
            break
    if ans==False:
        break
if ans:
    print(-1)
    print(-1)
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const double EPS = 1e-9;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

/*
    x2 y3 - x3 y2 = s
    10^9 y3 - 1 x3 = s
    10^9 (a+1) - (10^9-b) = s
    10^9 a + b = s
    x3 = (b == 0 ? 0 : (10^9-b))
    y3 = (b == 0 ? a : (a+1))
*/

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll s;
    cin >> s;
    ll a = s/1000000000;
    ll b = s%1000000000;
    cout << "0 0 1000000000 1 ";
    ll x, y;
    if(b){
        x = 1000000000-b;
        y = a+1;
    }else{
        x = 0;
        y = a;
    }
    cout << x << " " << y << endl;
    assert(1000000000 * y - x == s);
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int W,H,N;

signed main(){
    cin>>W>>H>>N;
    vpint p;
    rep(i,N){
        int x,y;
        cin>>x>>y;
        p.pb({x,y});
    }
    sort(all(p));

    int ma=0;
    int ans=INT_MAX;
    for(int i=N-1;i>=0;i--){
        chmin(ans,p[i].fi+ma);
        chmax(ma,p[i].se);
    }
    chmin(ans,ma);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4888
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long cnt[1000005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int i;
	for(i = 1;i <= n;i *= 10){
		if(i == n){
			cout << 10;
			return 0;
		}
	}
	
		int ans = 0;
		while(n > 0){
			ans += (n % 10);
			n /= 10;
		}
		cout << ans;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;


typedef struct {
    int visit;
    vector<int> edge;
    map<int,bool> used;
}node_t;

vector<node_t> node;
queue<int> q;
map<pair<int, int>, int> color;
int K = 0;


void coloring() {
    int x = q.front();
    q.pop();
    node[x].visit = 1;

    int kind = 1;
    for (auto to : node[x].edge) {
        if (!node[to].visit) {
            pair<int, int> eda = make_pair(x, to);
            for (int i = kind; i <= K; i++) {
                if (node[x].used[i]) continue;
                color[eda] = i;
                node[x].used[i] = true;
                node[to].used[i] = true;
                q.push(to);
                kind = i + 1;
                break;
            }
        }

    }

    if (!q.empty())
        coloring();

}

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

    
    node = vector<node_t>(N + 1);
    map<int, pair<int, int>> id;

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        node[a].edge.push_back(b);
        node[b].edge.push_back(a);
        color[make_pair(a, b)] = 0;
        id[i] = make_pair(a, b);
    }

    K = 0;
    for (int i = 1; i <= N; i++) {
        K = max(K, (int)node[i].edge.size());
    }
    q.push(1);
    coloring();
    cout << K << endl;
    for (int i = 0; i < N -1; i++)
        cout << color[id[i]] << endl;
}


Measured memory_bytes: 44288
#include<stdio.h>

int main(void){

  int a,b,c,ans=0;

  scanf("%d %d", &a, &b);

  c = b-a;

  for(int i=1; i<c; i++){
    ans += i;
  }

  ans -= a;

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
using System;

public class Hello{
    public static void Main(){
        var line = Console.ReadLine();
        var str = line.Split(' ');
        int x = int.Parse(str[0]);
        int a = int.Parse(str[1]);
        int b = int.Parse(str[2]);
        int dist_a = Math.Abs(x-a);
        int dist_b = Math.Abs(x-b);
        if(dist_a > dist_b)Console.WriteLine("B");
        else Console.WriteLine("A");
    }
}


Measured memory_bytes: 17744
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	int H, W, d;
	while(cin >> H >> W >> d){
		for(int i=0;i<H;i++){
			string res(W, '.');
			for(int j=0;j<W;j++){
				if(d % 2){
					res[j] = "RG"[(i+j)%2];
				} else {
					int a = (i+j)/2/(d/2)%2;
					int b = (i-j+W)/2/(d/2)%2;
					res[j] = "RGBY"[2*a+b];
				}
			}
			cout << res << endl;
		}
	}
}

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

typedef long long ll;
#define int ll

#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

signed main(void){
    int n, m; cin >> n >> m;

    vi w(n);
    for(auto && e : w) cin >> e;

    vector<set<int>> edge(n);
    rep(loop, m){
        int u, v; cin >> u >> v;
        u--, v--;

        edge[u].insert(v);
        edge[v].insert(u);
    }

    vi dp(n, 0);
    queue<int> q;
    set<int> uncnt;
    range(u, 1, n){
        if(edge[u].size() == 1){
            q.push(u);
        }
    }

    while(q.size()){
        int v = q.front(); q.pop();
        uncnt.insert(v);

        int u = *edge[v].begin();
        edge[u].erase(v);

        dp[u] = max(dp[u], dp[v] + w[v]);

        if(u == 0 || edge[u].size() != 1) continue;
        q.push(u);
    }

    int res = *max_element(dp.begin(), dp.end());
    rep(u, n){
        if(uncnt.count(u) == 0){
            res += w[u];
        }
    }

    cout << res << endl;

	return 0;
}

Measured memory_bytes: 19248
while true
    n = gets.to_i
    break if n == 0
    arr = []
    n.times{arr << gets.to_i}
    arr.sort!
    1.upto(n-1){|i| arr[i] += arr[i - 1]}
    sum = 0
    arr[0..-2].each{|x| sum += x}
    puts sum
end



Measured memory_bytes: 7152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] str = br.readLine().split(" ");
    
    System.out.println(str[2] + " " + str[0] + " " + str[1]);
  }
}


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

char s[150],t[150];
int a[30],b[30];

int main()
{
    memset(a, 0, sizeof a);
    memset(b, 0, sizeof b);
    scanf("%s %s", s, t);
    int i;
    int ls=strlen(s);
    for(i=0;i<ls;i++) a[s[i]-'a']++;
    int lt=strlen(t);
    for(i=0;i<lt;i++) b[t[i]-'a']++;

    int g=0;
    int j=0;
    int k=28;
    while(a[j]==0) j++;
    while(b[k]==0) k--;

    if(k>j) puts("Yes");
    else if(ls<lt) {
        int f=1;
        for(i=0;i<30;i++) {
            if(a[i]>b[i]) f=0;
        }
        if(f==1) puts("Yes");
        else puts("No");
    }
    else puts("No");
}


Measured memory_bytes: 256