akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_N = 100000;

struct V {
	double x, y;
	V(double x = 0, double y = 0) : x(x), y(y) {}//constructor
	V& operator+=(const V& v) {
		x += v.x; y += v.y;
		return *this;
	}
	V operator+(const V& v)const { return V(*this) += v; }

	V& operator-=(const V& v) {
		x -= v.x; y -= v.y;
		return *this;
	}
	V operator-(const V& v)const { return V(*this) -= v; }

	V& operator*=(double s) {
		x *= s; y *= s;
		return *this;
	}
	V operator*(double s)const { return V(*this) *= s; }

	V& operator/=(double s) {
		x /= s; y /= s;
		return *this;
	}
	V operator/(double s)const { return V(*this) /= s; }

	double dot(const V& v) const { return x*v.x + y*v.y; }
	double cross(const V& v) const { return x*v.y - v.x*y; }
	double norm2() const { return x*x + y*y; }
	double norm() const { return sqrt(norm2()); }

	int ort()const {
		if (y > 0)return x > 0 ? 1 : 2;
		else return x > 0 ? 4 : 3;
	}
	bool operator<(const V& v)const {
		int o = ort(), vo = v.ort();
		if (o != vo)return o < vo;
		return cross(v)> 0;
	}
};

istream& operator>>(istream& is, V& v) {
	is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os, const V& v) {
	os << "(" << v.x << "," << v.y << ")"; return os;
}

int main(int argc, char *args[]) {
	int n;
	cin >> n;
	vector<V> v(n);
	rep(i, n) cin >> v[i];
	sort(v.begin(), v.end());//角度でsort
	double ans = 0;
	rep(l, n) {
		int r = l;
		V now;
		rep(i, n) {
			now += v[r];
			ans = max(ans, now.norm());
			r = (r + 1) % n;
		}
	}
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 256
fun main() {
    val values = nextIntList().sorted()
    println(values.last() - values.first())
}
// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)
// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }
// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

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

	string result = "";

	rep(i, s.length()) {
		string t = s.substr(i, 1);

		if (t == "1" || t == "0") {
			result += t;
		} else if (t == "B") {
			result = result.substr(0, result.length()-1);
		}
	}

	cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		MaxHeap pq = new MaxHeap();

		String command;
		int k;
		while(  ! ( command = br.readLine() ).equals("end")  ) {
			switch (command) {
			case "extract":
				System.out.println(pq.extract());
				break;
			default :
				k = Integer.parseInt(command.split(" ")[1]);
				pq.insert(k);
				break;
			}
		}
	}

	public static class MaxHeap {
		private ArrayList<Integer> array;

		public MaxHeap() {
			array = new ArrayList<Integer>();
		}

		private int left(int i) { // index of left chiid
			return 2*i + 1;
		}

		private int right(int i) { // index of right child
			return 2*i + 2;
		}

		private int parent(int i) { // index of parent
			return (i-1) / 2;
		}

		public void insert(int k) {
			array.add(k);
			int index = array.size() - 1; // index of k

			while (index != 0) {
				int parent = parent(index); // index of parent of k
				if ( array.get(parent) < k ) { // key of parent < key of child
					int temp = array.get(parent);
					array.set(parent, k);
					array.set(index, temp);
					index = parent;
				} else {
					break;
				}
			}
		}

		public int extract() {
			int lastkey = array.remove( array.size() - 1 ); // ?????????Node???key
			if (array.size() == 0) {
				return lastkey;
			}
			int MaxKey = array.set(0, lastkey); // ???????????????????????§??????key??????????????????lastkey?????£???????????\??????

			maxHeapify(array, 0);

			return MaxKey;
		}

		// index??????????????????Node??????????????´???????§?????????????
		private void maxHeapify(ArrayList<Integer> array, int index) {
			int l = left(index);
			int r = right(index);
			int largest = index; // ?????¨????????????????????§???key????????§?????????index

			if (l < array.size()) {
				if ( array.get(index) < array.get(l) ) {
					largest = l;
				}
			}
			if (r < array.size()) {
				if ( array.get(largest) < array.get(r) ) {
					largest = r;
				}
			}

			//??????key???????????????key????????§????????£?????´???
			if (largest != index) {
				int temp = array.get(index);
				array.set(index, array.get(largest));
				array.set(largest, temp);
				maxHeapify(array, largest);
			}
		}

	}
}

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



int main() 
{
  ll N; cin>>N;
  vector<ll> a(N);
  ll ans=1e7;
  rep(i,N)
  {
    cin>>a.at(i);
  }
  rep(i,101)
  {
    ll l=i,min1=0,min2=0;
    rep(j,N)
    {
      l=abs(l);
      ll a_j=a.at(j);
      min1+=(a_j-l)*(a_j-l);
      l=-l;
      min2+=(a_j-l)*(a_j-l);
    }
    ans=min(ans,min(min1,min2));
  }  
  cout<<ans<<endl;
  return 0;
}


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


int main() {
    int x;
	cin >> x;
    string ans;
    if(x/100==x%10)ans="Yes";
    else ans = "No";
      cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll mod=1e9+7;
ll qpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return res%mod;
}
ll a[200005];
int main(){
	ll k,n,ans,mx=0;
	cin>>k>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ans=a[n]-a[1];
	for(int i=1;i<n;i++){
		mx=max(a[i+1]-a[i],mx);
	}
	cout<<min(ans,k-mx)<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,X;
  cin>>K>>X;
  if(K==1){
    cout<<X<<endl;
  }
  else{
    for(int i=X-K+1;i<X+K;i++){
      cout<<i<<" ";
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    string N;
    cin >> N;
    int sum = 0;

    for(int i=0; i<N.size(); i++){
        sum = sum + (int)N[i] - 48;
    }

    if(sum%9 == 0){
        cout << ("Yes") << endl;
    }else{
        cout << ("No") << endl;
    }

    //cout << (int)'0' << endl;

   

    return 0;

}

Measured memory_bytes: 3676
main :: IO ()
main = do
    [a, b, c, x, y] <- map read . words <$> getLine
    print $ solve a b c x y

solve :: Int -> Int -> Int -> Int -> Int -> Int
solve a b c x y = minimum $ cost <$> [0..((2*x) `max` (2*y))]
    where
        cost mixno = ano * a + bno * b + mixno * c
            where
                ano = (x - mixno `div` 2) `max` 0
                bno = (y - mixno `div` 2) `max` 0


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<cctype>
#include<climits>
using namespace std;
typedef long long ll;

int main(){
  ll n, TLE, sum = 0LL;
  string s;
  cin >> n >> TLE;
  cin >> s;

  for(int i = 0 ; i < s.size() ; i++ ){
    if(isdigit(s[i])){
      ll calc = 1LL;
      for(int j = 0 ; j < s[i] - '0' ; j++ ){
	calc = min( calc * n, (ll)INT_MAX);
      }
      sum = min( sum + calc, (ll)INT_MAX);
    }
  }
  sum *= TLE;
  if(sum <= 1e+9) cout << sum << endl;
  else cout << "TLE\n";
}

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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        int64_t n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n, m, a, b) << '\n';
    }
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int c;
    string s,t,q;
    cin>>s>>t>>q;
    size_t a=s.length();
    size_t b=t.length();
    if(s[a-1]==t[0] && t[b-1]==q[0]) cout<<"YES\n";
    else cout<<"NO\n";
    return(0);
}

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

string S;
ll K;

int main() {
    cin >> S >> K;
    ll N = S.length();

    bool f = true;
    for (int i = 0; i < N-1; i++) {
        if (S[i] != S[i+1]) {
            f = false;
            break;
        }
    }

    if (f) {
        cout << N*K/2 << endl;
    }
    else if (S[0] == S[N-1]) {
        ll check;
        for (int i = 0; i < N; i++) {
            if (S[i] != S[i+1]) {
                check = i;
                break;
            }
        }
        string new_S = S.substr(check+1, N-check-1) + S.substr(0, check+1);
        //cout << new_S << endl;
        ll cnt = 0;
        for (int i = 0; i < new_S.length() - 1; i++) {
            if (new_S[i] == new_S[i+1]) {
                new_S[i+1] = '_';
                cnt++;
            }
        }
        ll last = 0;
        string last_s = S.substr(check+1, N-check-1);
        for (int i = 0; i < last_s.length(); i++) {
            if (last_s[i] == last_s[i+1]) {
                last_s[i+1] = '_';
                last++;
            }
        }
        //cout << new_S << " " << check <<  " " << last_s << endl;
        cout << (check+1)/2 + cnt*(K-1) + last << endl;
    }
    else {
        ll cnt = 0;
        for (int i = 0; i < N-1; i++) {
            if (S[i] == S[i+1]) {
                S[i+1] = '_';
                cnt++;
            }
        }
        cout << cnt * K << endl;
    }

    
    
    return 0;
}


Measured memory_bytes: 256
class DisjointSet(object):
    class Node(object):
        def __init__(self, number: int):
            self.number = number  # int
            self.parent = None    # Node  根　　ではNone
            self.rank = 0         # int   根以外ではNone

            self.linked_num = 1

        def is_root(self):
            return self.parent is None

        def find_root(self) -> "Node":
            if self.is_root():
                return self

            # 木をなるべく低くするために，根に直結させる
            self.parent = self.parent.find_root()
            self.rank = None
            return self.parent

    def __init__(self, size: int):
        self.size = size
        self.nodes = list(map(lambda i: self.Node(i), range(size)))

    def get_node(self, number: int) -> Node:
        if number < 0 or self.size <= number:
            raise ValueError("number out of range")

        return self.nodes[number]

    def unite(self, left_node: Node, right_node: Node) -> "DisjointSet":
        if left_node.number < 0 or self.size <= left_node.number:
            raise ValueError("not existing left_node")

        if right_node.number < 0 or self.size <= right_node.number:
            raise ValueError("not existing right_node")

        left_root = left_node.find_root()
        right_root = right_node.find_root()
        if left_root is right_root:
            return self

        # rank の大きい木をベースに結合
        if left_root.rank < right_root.rank:
            left_root.parent = right_root
            left_root.rank = None

        elif left_root.rank > right_root.rank:
            right_root.parent = left_root
            right_root.rank = None

        else:  # left_root.rank == right_root.rank
            # どちらに結合してもよく，このときだけ rank を1増やす
            right_root.parent = left_root
            right_root.rank = None
            left_root.rank += 1

        root = left_root.find_root()
        root.linked_num = left_root.linked_num + right_root.linked_num
        return self

    def have_same_root(self, left_node: Node, right_node: Node) -> bool:
        if left_node.number < 0 or self.size <= left_node.number:
            raise ValueError("not existing left_node")

        if right_node.number < 0 or self.size <= right_node.number:
            raise ValueError("not existing right_node")

        return left_node.find_root() is right_node.find_root()


if __name__ == '__main__':
    N, M = map(int, input().split())
    A, B = [], []
    for i in range(M):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    comb = N * (N-1) // 2

    ans = [comb]
    linked_num = [1 for _ in range(N+1)]
    disjointSet = DisjointSet(N+1)

    for a, b in zip(reversed(A), reversed(B)):
        node_a, node_b = disjointSet.get_node(a), disjointSet.get_node(b)
        if disjointSet.have_same_root(node_a, node_b):
            ans.append(ans[-1])
        else:
            linked_num_a = node_a.find_root().linked_num
            linked_num_b = node_b.find_root().linked_num
            ans.append(ans[-1] - linked_num_a * linked_num_b)
            disjointSet.unite(node_a, node_b)

    print('\n'.join(map(str, reversed(ans[:-1:]))))


Measured memory_bytes: 53936
#include <bits/stdc++.h>
#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;

#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

const int inf = 1 << 24;

int main(void){
    string s; cin >> s;

    vi num, br_l, br_r;
    string op;
    rep(i, (int)s.size()){
        if(isdigit(s[i])){
            num.pb(s[i] - '0');
            if(0 <= i - 1 && s[i - 1] == '(')            br_l.pb(true);
            else                                         br_l.pb(false);
            if(i + 1 < (int)s.size() && s[i + 1] == ')') br_r.pb(true);
            else                                         br_r.pb(false);
        }
        if(s[i] == '+' || s[i] == '-'){
            op.pb(s[i]);
        }
    }

    vvi dp_max(num.size(), vi(num.size(), -inf));
    vvi dp_min(num.size(), vi(num.size(), inf));
    rep(i, (int)num.size()){
        dp_max[i][i] = dp_min[i][i] = num[i];
    }

    range(i, 2, (int)num.size() + 1){    // len 
        rep(j, (int)num.size() - i + 1){ // l such [l, l + len)
            int l = j, r = j + i - 1;
            if(br_r[l] || br_l[r]) continue;

            range(k, l + 1, r + 1){
                //if(br_l[k - 1] || br_r[k]) continue;
                
                if(op[k - 1] == '+'){
                    if(dp_min[l][k - 1] != inf && dp_min[k][r] != inf)
                        dp_min[l][r] = min(dp_min[l][r], dp_min[l][k - 1] + dp_min[k][r]);
                    if(dp_max[l][k - 1] != -inf && dp_max[k][r] != -inf)
                        dp_max[l][r] = max(dp_max[l][r], dp_max[l][k - 1] + dp_max[k][r]);
                }
                else {
                    if(dp_min[l][k - 1] != inf && dp_max[k][r] != -inf)
                        dp_min[l][r] = min(dp_min[l][r], dp_min[l][k - 1] - dp_max[k][r]);
                    if(dp_max[l][k - 1] != -inf && dp_min[k][r] != inf)
                        dp_max[l][r] = max(dp_max[l][r], dp_max[l][k - 1] - dp_min[k][r]);
                }
            }
        }
    }

    cout << dp_max[0][(int)num.size() - 1] << endl;

    return 0;
}

Measured memory_bytes: 3236
import fractions

n , k = map(int,input().split())
a = list(map(int,input().split()))
if max(a) < k:
    print("IMPOSSIBLE")
    exit()
f = a[0]
for i in range(n):
    if a[i] == k:
        print("POSSIBLE")
        exit()
    f = fractions.gcd(f,a[i])
    
if k % f != 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Measured memory_bytes: 16240
def gcd(x,y):
    if y>x:
        a=y
        y=x
        x=a
    while y:
        a=x%y
        x=y
        y=a
    return x
N=int(input())
T=[int(input()) for i in range(N)]
lcm=d=T[0]
T=T[1:]
for i in T:
    j=i*lcm
    d=gcd(i,lcm)
    lcm=j//d
print(lcm)


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

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

// const int mxN = 1e9 + 7;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

// ll fact[mxN + 1], inv[mxN + 1];
// ll C(ll n, ll k)
// {
// 	return (((fact[n] * inv[k]) % M) * inv[n - k]) % M;
// }
// ll f1[M + 1], f2[M + 1];
// ll C(int n, int k)
// {
// 	return (((f1[n] * f2[k]) % M) * f2[n - k]) % M;
// }

int main()
{
	fast;
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b != c || a == c && a != b || b == c && c != a)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main (){
    int ans = 700;
    for (int i = 0; i < 3; i++){
        char a;
        cin >> a;
        if (a == 'o') ans += 100;
    }
    cout << ans << endl;
    return 0;
    }
    


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

int main() {
    int h, w;
    cin >> h >> w;

    // map of (start index, current index)
    map<int, int> s;
    // times took right step
    multiset<int> vals;

    for (int i = 0; i < w; ++i) {
        s[i] = i;
        vals.insert(0);
    }

    for (int i = 0; i < h; ++i) {
        int l, r;
        cin >> l >> r;
        l--;
        auto itr = s.lower_bound(l);
        int till = -1;
        while(itr != s.end() && itr->first <= r) {
            till = max(till, itr->second);
            int x = itr->first - itr->second;
            vals.erase(vals.find(x));
            s.erase(itr++);
        }
        if(till != -1 && r < w) {
            vals.insert(r - till);
            s[r] = till;
        }

        int ans = -1;
        if(vals.size()) {
            ans = *vals.begin() + (i+1);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 22348
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    int m = A + B;
    if (m < A - B){
        m = A - B;
    }
    if (m < A * B){
        m = A * B;
    }

    cout << m << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	S = input().rstrip()
	bcnt = 0
	A = []
	for i in range(len(S)):
		if S[i] == 'B': bcnt += 1
		if S[i] == 'W': A.append(bcnt)
	
	print(sum(A))

if __name__ == '__main__':
	main()

Measured memory_bytes: 5932
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Point {

	final int y;
	final int x;

	Point( final int y, final int x ) {
		this.y = y;
		this.x = x;
	}	
}

class Main {

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

		final BufferedReader br = new BufferedReader( new InputStreamReader(System.in ) );

		while ( true ) {

			final int[] hw = parse( br.readLine().split( " " ) );
			final int width = hw[ 0 ];
			final int height = hw[ 1 ];
			if ( height == 0 && width == 0 ) break;
			final char[][] map = new char[ height ][];
			for ( int i = 0; i < height; i++ ) {
				map[ i ] = br.readLine().toCharArray();
			}
			solve( map );
		}	
    }

	static void solve( final char[][] map ) {
		final Point start = findStart( map );
		System.out.println( dfs( map, start.y, start.x ) );
	}

	static final int[] dx = { -1, 0, 1, 0 };
	static final int[] dy = { 0, 1, 0, -1 };
	
	static int dfs( final char[][] map, final int y, final int x ) {
		int count = 1;
		map[ y ][ x ] = 'o';
		
		for ( int i = 0; i < 4; i++ ) {
			final int nx = x + dx[ i ];
			final int ny = y + dy[ i ];
			if ( 0 <= ny && ny < map.length &&
				 0 <= nx && nx < map[ ny ].length &&
				 map[ ny ][ nx ] == '.' ) {

				count += dfs( map, ny, nx );
			}
		}
		return count;
	}

	static Point findStart( final char[][] map ) {
		for ( int y = 0; y < map.length; y++ ) {
			for ( int x = 0; x < map[ y ].length; x++ ) {
				if ( map[ y ][ x ] == '@' ) {
					return new Point( y, x );
				}
			}
		}
		return null;
	}

	static int[] parse( String[] sinput ) {
		final int[] input = new int[ sinput.length ];
		for ( int i = 0; i < input.length; i++ ) {
			input[ i ] = Integer.parseInt( sinput[ i ].trim() );
		}
		return input;
	}	
}

Measured memory_bytes: 22368
//AtCoder ABC046 A - AtCoDeerくんとペンキ / AtCoDeer and Paint Cans
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    std::unordered_set<int> col;
    for(int i=0;i<3;++i){
        int c;
        cin>>c;
        col.insert(c);
    }
    cout<<col.size()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num[1000005];
bool vis[1000005];
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    string s;
    cin>>s;
    memset(vis,false,sizeof(vis));
    int n=s.length();
    int now=1,cnt=1;
    int lftpos=0;
    for(int i=1;i<n;i++){
        if(now==1){
            if(s[i]=='R')cnt++;
            else{
                vis[i-1]=true;
                num[i-1]=cnt;
                now=2;
                lftpos=i;
                cnt=1;
                vis[i]=true;
            }
        }
        else if(now==2){
            if(s[i]=='L')cnt++;
            else{
                num[lftpos]=cnt;
                cnt=1;
                now=1;
            }
        }
    }
    num[lftpos]=cnt;
    for(int i=0;i<n;i++){
        if(!vis[i])
            cout<<"0 ";
        else{
            int l=num[i],r=num[i+1];
            int sum=l+r;
            if(l==r)cout<<l<<" "<<r<<" ";
            else if(l<r){
                int mi=(l+1)%2;
                int d=(r-l)&1;
                int z=(mi+d)%2;
                l=(sum)/2;
                r=(sum+1)/2;
                if(z&1)cout<<r<<" "<<l<<" ";
                else cout<<l<<" "<<r<<" ";
            }
            else
            {
                int mi=(r+1)%2;
                int d=(l-r)&1;
                int z=(mi+d)%2;
                l=(sum+1)/2;
                r=(sum)/2;
                if(z&1)
                {
                    cout<<r<<" "<<l<<" ";
                }
                else
                {
                    cout<<l<<" "<<r<<" ";
                }
            }
            i++;
        }
    }
	return 0;
}

Measured memory_bytes: 2000
# -*- coding: utf-8 -*-
#"""
#Created on Wed Nov 20 17:37:14 2019
#
#@author: manakamura
#"""

#https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_c

n= int(input())
#s= input()
tup = []
for i in range(0,n):
    tmp = input().split()
    tmpa,tmpb = list(map(lambda a: int(a), tmp))
    tup.append([tmpa+tmpb,tmpa,tmpb])

#print(tup)
tup=sorted(tup, reverse=True, key=lambda x:x[0])
#print(tup)

total=0
for i in range(0,n):
    if (i%2==0):
       total+=tup[i][1]
    else:
       total-=tup[i][2]
          
print(total)

Measured memory_bytes: 25640
def resolve():
	import sys
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		b = a[i]
		if b%2 ==0:
			if b%3 !=0 and b%5 !=0:
				print("DENIED")
				exit()
	print("APPROVED")
resolve()

Measured memory_bytes: 38384
#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 int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	vector<pii> v(n - 1);
	for(int i = 0; i < n - 1; i++) {
		cin >> v[i].fi >> v[i].se;
		if(v[i].fi > v[i].se) {
			swap(v[i].fi, v[i].se);
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += i * (n - i + 1);
	}
	for(int i = 0; i < n - 1; i++) {
		ans -= (v[i].fi) * (n - v[i].se + 1);
	}
	cout << ans;

	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){

  int n;
  cin >> n;
  int a[n];
  int ans = 0;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    if ((a[i] % 2) != 0){
      cout << ans << endl;
      return 0;
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
P = gets.split.map(&:to_i)

a = []
b = []
N.times{|i|
  a << 30000 * (i + 1)
  b << 30000 * (N - i)
}

P.each_with_index{|pi, i|
  a[pi-1] += i
}

v = P.map{|pi|
  a[pi-1] + b[pi-1]
}

#p v

puts a * ' '
puts b * ' '


Measured memory_bytes: 5072
N, X = map(int, input().split())
result = [[]] * (N + 1)
result[0] = [1, 1] #[all-num, patty-num]
for i in range(1, N + 1):
    result[i] = [
        result[i - 1][0] * 2 + 3,
        result[i - 1][1] * 2 + 1,
    ]

def count_patty(idx, remain):
    if remain >= result[idx][0]:
        return result[idx][1]
    if remain <= 1:
        return 0
    ret = 0
    if remain >= result[idx][0] // 2 + 1:
        ret += result[idx - 1][1]
        ret += 1
        remain -= result[idx][0] // 2
    ret += count_patty(idx - 1, remain - 1)
    return ret

print(count_patty(N, X))

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())

    # id table
    N=0
    id=[[None]*n for _ in range(n)]
    from itertools import product
    for i,j in product(range(n),repeat=2):
        if(i>=j): continue
        id[i][j]=N
        N+=1
    toID=lambda i,j:id[min(i,j)][max(i,j)]

    E=[[] for _ in range(N)]
    for i in range(n):
        A=list(map(lambda x:int(x)-1,input().split()))
        for j in range(n-2):
            u=toID(i,A[j])
            v=toID(i,A[j+1])
            E[u].append(v)

    # longest path problem
    dp=[-1]*N
    def dfs(v):
        if(dp[v]>=0): return dp[v]
        dp[v]=-2
        res=0
        for nv in E[v]:
            if(dp[nv]==-2):
                print(-1)
                exit()
            res=max(res,dfs(nv)+1)
        dp[v]=res
        return res

    print(max(dfs(v) for v in range(N))+1)
resolve()

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

public class Main {
	
	public static void main(String[] args) throws IOException{
		
		InputStreamReader inputStreamReader = new InputStreamReader(System.in);
		BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
		
		String input = bufferedReader.readLine();
		int r = Integer.parseInt(input);
		
		String result = "AGC";
		
		if(r < 1200) {
			result = "ABC";
		}else if(r < 2800) {
			result = "ARC";
		}
		
		print(result);
	}
	
	public static void print(String string) {
		System.out.println(string);
	}

}


Measured memory_bytes: 21204
import sys
def input(): return sys.stdin.readline().rstrip()

N = int(input())
a = input()
# a = '1' * N

def bit_count(i):
    res = 0
    while ((i>0) and (i&1 == False)):
        i  >>=1
        res += 1
        # print(i)
    return res

f = [0]
for i in range(N//2):
    f.append(f[-1] + bit_count(N-1-i) - bit_count(i+1))

def nCr(n, r):
    if r > n-r: r = n-r
    if f[r] == 0:   # 奇数
        return 1
    else:
        return 0

def main():
    ans = 0
    for i in range(N):
        now = int(a[i]) - 1     # 全体を1引いても同じ
        if now%2:
            # print(i, nCr(N-1, i))
            ans += now * (nCr(N-1, i) % 2)
            ans %= 2
    if ans:
        return ans

    if '2' in a:    # 答えが奇数でなく、入力に2が含まれる場合は答えは0
        return 0

    ans = 0
    for i in range(N):
        now = (int(a[i]) - 1) // 2     # 全体を1引いても同じ
        if now%2:
            ans += now * (nCr(N-1, i) % 2)
            ans %= 2
    return ans*2    # 答えは0か2なので2倍して出す

print(main())


Measured memory_bytes: 10144
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
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*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    string s;
    cin >> s;

    int slen = s.length();

    int res = 0;
    rep(i, slen-1){
        if(s[i] == s[i+1]) continue;
        else res++;
    }
    
    cout << res << endl;

    return 0;
}


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

#define int long long

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

signed main() {
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    for(int i=0; i<h; ++i) cin >> v[i];

    for(int i=0; i<h; ++i) {
        for(int j=0; j<w; ++j) {
            if(v[i][j]=='.') {
                int tmp = 0;
                for(int k=0; k<8; ++k) {
                    int ny = i + dy[k];
                    int nx = j + dx[k];
                    if(nx>=0&&nx<w&&ny>=0&&ny<h&&v[ny][nx]=='#') tmp++;
                }
                v[i][j] = '0' + tmp;
            }
        }
    }
    for(int i=0; i<h; ++i) cout << v[i] << endl;
    return 0;
}



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

using namespace std;

template <class T> struct SegmentTreeSum
{
	int N;
	vector<T> node;

	SegmentTreeSum (int n){
		N = 2 << (int)log2(n);
		node.resize(N*2, 0);
	}

	void update(int idx, T val){
		idx += N;
		node[idx] += val;
		while (idx > 0){
			node[idx>>1] = sum(node[idx], node[idx^1]);
			idx >>= 1;
		}
	}

	T sum(T x, T y){
		return x+y;
	}

	T getSum(int l, int r){
		T ret = 0;
		for (l += N, r += N; l < r; l >>= 1, r >>= 1) {
			if (l&1) ret = sum(ret, node[l++]);
			if (r&1) ret = sum(ret, node[--r]);
		}
		return ret;
	}
};

int main(int argc, char const *argv[])
{
	int n, q;
	cin >> n >> q;

	vector<int> ans;

	SegmentTreeSum <int> st(n);
	for (int i = 0; i < q; ++i) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com==0) st.update(--x, y);
		else ans.push_back(st.getSum(--x, y));
	}

	for (int i = 0; i < ans.size(); ++i){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4420
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n,m;
	cin>>n>>m;

	for(i=1;i<=max(n,m);i++)
	{
		cout<<min(n,m);
	}

}

Measured memory_bytes: 3576
#include <iostream>
using namespace std;
 
int main()
{
   int a , b;
   cin>>a>>b;
   if(a>=0 && a<=5){
    cout<<0;
   }
   else if(a>=6 && a<=12){
    cout<<b/2;
   }
   else if(a>=13){
    cout<<b;
   }
    cout<<'\n';
}

Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
ll R=1000000000+7;
int main(){
    int n;
    vector<int> x;
    cin>>n;
    rp(i,0,n){
        int y;
        cin>>y;
        x.push_back(y);
    }
    sort(x.begin(),x.end());
    ll ans=0;
    int start=0;
    if(n%2==1){
        if(x[0]!=0){
            cout<<'0'<<endl;
            return 0;
        }
        rp(i,0,n/2){
            if(x[(i*2+1)]==(i+1)*2 and x[(i*2+2)]==(i+1)*2) ans+=1;
            else{
            cout<<'0'<<endl;
            return 0;
            }
        }

        ll ans2=1;
        rp(i,0,ans) ans2=(ans2*2)%R;

        cout<<ans2<<endl;
        return 0;
    }
    rp(i,start,n/2){
            if(x[(i*2)]==i*2+1 and x[(i*2+1)]==i*2+1) ans+=1;
            else{
            cout<<'0'<<endl;
            return 0;
            }
        }
    ll ans2=1;
        rp(i,0,ans) ans2=(ans2*2)%R;

        cout<<ans2<<endl;
        
    
};




Measured memory_bytes: 892
import sys

a = sys.stdin.readline().split(' ')
data = sys.stdin.readlines()

S = int(a[0])
H = int(a[1])

dx = [0,1,0,-1]
dy = [1,0,-1,0]

for i in range(S):
    for j in range(H):
        count = 0
        if data[i][j] == '#':
            for k in range(4):
                x = j + dx[k]
                y = i + dy[k]
                if x < 0 or y < 0 or x >= H or y >= S:
                    continue
                else:
                    if data[y][x] == "#":
                        count = count+1
            if count == 0:
                print('No')
                sys.exit()


print('Yes')



Measured memory_bytes: 3064
N,M=map(int,input().split())
X=sorted([int(i) for i in input().split()])

cost=[0 for _ in range(M-1)]

for i in range(1,M):
    cost[i-1]=X[i]-X[i-1]

cost.sort(reverse=True)

print(sum(cost[N-1:]))




Measured memory_bytes: 13840
#include <iostream>

using namespace std;

int main() {
  string S;
  cin >> S;
  int c1=0;
  int c2=0;
  for(int i=0;i<S.size();i+=2) {
    if (S[i] == '0') c1++;
    if (S[i] == '1') c2++;
    if (i+1 < S.size()) {
    	if (S[i+1] == '1') c1++;
        if (S[i+1] == '0') c2++;
    }
  }
  if (c1 > c2) {
  	cout << c2;
  } else {
  	cout << c1;
  }
  return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct P
{
	string s;
	int i, p;
	P(int i, string s, int p) :i(i), s(s), p(p) {}
	P() :P(0, "", 0) {}
	bool operator<(const P& other)
	{
		return s != other.s ? s < other.s : p>other.p;
	}
};

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

	int N;
	cin >> N;
	string s;
	int p;
	P Ps[110];
	rep(i, 0, N)
	{
		Ps[i].i = i + 1;
		cin >> Ps[i].s >> Ps[i].p;
	}

	sort(Ps, Ps + N);

	rep(i, 0, N)
	{
		cout << Ps[i].i << endl;
	}

	return 0;
}



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

int main(){
int a,b,X,T=1,N;
cin >> N;
	
a = N/100;
T = N-100*a;
b = T/10;
T = T-10*b;
if(T == 3){
	cout << "bon" << endl;
}
else if(T == 0 || T == 1|| T == 6|| T == 8){
	cout << "pon" << endl;
}
else{
	cout << "hon" << endl;
}
}

Measured memory_bytes: 3644
#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 n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  int t = n-1;
  rep(i,n) {
    int lim = 2;
    if (i == 0) lim = 1;
    rep(j,lim) {
      if (t > 0) {
        ans += a[i];
        t--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
const int MAX = 1e5;
int dp[MAX+1];
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n; cin >> n;
   vector<int>h(n+1);
   rep(i,n)cin>>h[i+1];
   dp[1]=0;dp[2]=abs(h[2]-h[1]);
   for (int i = 3; i <= n; i++){
      dp[i] = min(dp[i-2]+abs(h[i]-h[i-2])
                  ,dp[i-1]+abs(h[i]-h[i-1]));
   }
   cout << dp[n] << endl;
}

Measured memory_bytes: 4012
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int num[3];
int main() {
	string S; cin >> S;
	for(int i=0; i<S.size(); ++i) ++num[S[i]-'a'];
	sort(num, num+3);
	if(num[2]-num[0]<2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main()
{
int a,b;
cin>>a>>b;
cout<<(a-1)*(b-1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll p[100001] = {};
bool v[100001] = {};
ll s = 100001;
ll l[100001], r[100001];

int main() {
	v[0] = true;
	v[1] = true;
	for (int i = 2; i*i < s; i++) {
		ll k = i;
		for (int j = 2; j*k < s; j++) {
			v[j * k] = true;
		}
	}

	ll sum = 0;
	rep(i, 2, s) {
		if (!v[i] && !v[(i + 1) / 2]) {
			p[i] = ++sum;
			//v[i] = true;
			//cout << i << endl;
		}
		p[i] = sum;
	}

	ll N; cin >> N;
	rep(i, 0, N) {
		cin >> l[i] >> r[i];
	}
	rep(i, 0, N) {
		ll cnt = p[r[i]] - p[l[i]];
		if (p[l[i]] != p[l[i] - 1]) {
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#B問題
N,M,X,Y=input().split()
N=int(N)
M=int(M)
X=int(X)
Y=int(Y)

x=input().split()
y=input().split()

for i in range(0,len(x)):#0から<2まで(1まで)
    x[i]=int(x[i])
for i in range(0,len(y)):#0から<2まで(1まで)
    y[i]=int(y[i])

#X< Z <=Y
comment='War'
for Z in range(X+1,Y+1):#X+1からYまで
    #print(Z)
    #最大x<Zか調べる
    if(max(x) < Z):
        #最小y>=Zか調べる
        if(min(y)>=Z):
            comment='No War'#Norと書いたミス
            break
print(comment)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#define MAXN 406
#define MAXM 100006
using namespace std;
int n,m,p[MAXN],fa[MAXN],u[MAXM],v[MAXM],ans,vis[MAXN][MAXN];
int root(int x)
{
	if(fa[x]!=x) fa[x]=root(fa[x]);
	return fa[x];
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&u[i],&v[i]);
	for(int i=1;i<=n;i++)
	{
		p[i]=1;
		for(int j=1;j<=n;j++)
			fa[j]=j;
		for(int j=m;j>=1;j--)
		{
			int l=root(u[j]);
			int r=root(v[j]);
			if(l!=root(i)&&r!=root(i)) continue;
			if(l==root(i)&&r==root(i))
			{
				p[i]=0;
				break;
			}
			if(l!=root(i)) fa[l]=root(i);
			if(r!=root(i)) fa[r]=root(i);
		}
		if(!p[i]) continue;
		for(int j=1;j<=n;j++)
			if(root(j)==root(i)) vis[i][j]=1;
	}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(p[i]&&p[j])
			{
				int ok=1;
				for(int k=1;k<=n;k++)
					if(vis[i][k]&&vis[j][k])
					{
						ok=0;
						break;
					}
				ans+=ok;
			}
	printf("%d",ans);
}

Measured memory_bytes: 1280
import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_t, b_t = [0], [0]
for i in range(n):
    a_t.append(a_t[i] + a[i])
for i in range(m):
    b_t.append(b_t[i] + b[i])
ans = 0
j = m
for i in range(n+1):
    if (a_t[i] > k):
        break
    while(a_t[i] + b_t[j] > k):
        j -= 1
    ans = max(ans, i + j)
print(ans)



Measured memory_bytes: 65020