akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
   uniform_int_distribution<int> uid(l, r);
   return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

vector <int> v;

void solve() {
   int n; cin >> n;
   vector <int> v;
   cin>>n;
   while(n){
      int x = n%26;
      v.pb(x);
      n = (n-1)/26;
   }
   string s = ""; char c;
   for(int i = sz(v)-1; i >= 0; i--) {
      c = 'a' + (v[i]-1+26)%26;
      s += c;
   }
   cout << s << '\n';
}

signed main() {   
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
      solve();
  }
}    


Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    Int N;
    cin >> N;
    Int ans =0;

    vi H = vi(N);
    rep(i,N){
        cin >> H[i];
    }

    Int tail=0, head=0;
    while(head <N && tail <N){

        while(H[head+1]>0 && head <N-1){
            head++;
        }
        int clear =0;
        for(int i=0; i<N; i++){
            clear += H[i];
        }
        if(clear == 0){
            break;
        }

        while(tail<=head){
            Int minimum = inf;
            for(int i=tail; i<=head; i++){
                if(H[i]>0){
                    minimum = min(H[i],minimum);
                }
            }

            for(int i=tail; i<=head; i++){
                if(H[i]>0){
                    H[i]-=minimum;
                }
            }
            ans+=minimum;

            // 尻を押す処理
            while(H[tail] == 0 && tail < N-1){
                tail++;
            }

            // 頭を引っ込める処理
            for(int i=tail; i<=head; i++){
                if(H[i]==0){
                    head = i;
                    break;
                }
            }

            if(tail>head){
                head=tail;
                break;
            }

            int clear2 =0;
            for(int i=0; i<N; i++){
                clear2 += H[i];
            }
            if(clear2 == 0){
                break;
            }
        }
    }



    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    X = list(map(int, input().split()))

    A, B = sorted(X)[N // 2 - 1: N // 2 + 1]
    for x in X:
        if x <= A:
            print(B)
        else:
            print(A)


if __name__ == "__main__":
    main()


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

#define rep1(i,n) for (decay_t <decltype (n)> i = 1, i ## __len = (n); i <= i ## __len; ++ i)

template <typename T>
constexpr T inf = numeric_limits <T>::max ();

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

  size_t n, k;
  cin >> n >> k;

  vector <int> h (n + 1);
  rep1 (i, n) cin >> h [i];

  vector <int> cost (n + 1, inf <int>);
  cost [1] = 0;
  rep1 (i, n)
  {
    rep1 (di, k)
    {
      auto j = i + di;
      if (j > n) break;
      cost [j] = min (cost [j], cost [i] + abs (h [i] - h [j]));
    }
  }

  cout << cost [n] << endl;
}



Measured memory_bytes: 1024
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
std::string s[55];
long t[55];
std::string x;
int main(){
    scanf("%ld",&n);
    for(int i = 0; i < n; i++){
        std::cin >> s[i] >> t[i];
    }
    std::cin >> x;
    long end = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == x){
            end = i;
            break;
        }
    }
    long sum = 0;
    long ans = 0;
    for(int i = 0; i < n; i++){
        sum += t[i];
        if(i <= end){
            ans += t[i];
        }
    }
    printf("%ld\n", sum - ans);
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for(int i = 0; i < N; i++)
		cin >> A.at(i);

	int all = 0;
	for(int i = 0; i < N; i++)
		all += A.at(i);

	int count = 0;
	for(int i = 0; i < N; i++) {
		if((double)A.at(i) >= (double)all / (4.0 * (double)M))
			count++;
	}
	if(count >= M)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll R;
    cin >> R;
    if(R < 1200) cout << "ABC";
    else if(R < 2800) cout << "ARC";
    else cout << "AGC";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3464
N, k = [int(s) for s in input().split(' ')]
# または N, k = map(int, input().split())
h = []
while len(h) != N:
    h.append(int(input()))
h.sort()
# print(h)
min = 1000000000
for i in range(0, len(h)-k+1):
    x = h[i+k-1]-h[i]
    # print(x)
    if min > x:
        min = x
print(min)


Measured memory_bytes: 7464
import java.util.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/7/5 22:51
 */
public class Main {

    final static int MOD = 1000000007;

    private static int comb(int n, int m) {
        return 1;
    }

    static void getDiv(Map<Integer, Integer> map, int n) {
        int sqrt = (int) Math.sqrt(n);
        for (int i = sqrt; i >= 2; i--) {
            if (n % i == 0) {
                getDiv(map, i);
                getDiv(map, n / i);
                return;
            }
        }
        map.put(n, map.getOrDefault(n, 0) + 1);
    }

    @SuppressWarnings("unchecked")
    private static void solve(Scanner sc) {
        long n = sc.nextInt();
        long m = sc.nextInt();
        char s[] = sc.next().toCharArray();
        char t[] = sc.next().toCharArray();
        if (s[0] != t[0]) {
            System.out.println(-1);
            return;
        }
        long gcd = gcd(n, m);
        long lcm = n * m / gcd;
        int t1 = (int) (n / gcd);
        int t2 = (int) (m / gcd);
        while (t1 < n && t2 < m) {
            if (s[t1] != t[t2]) {
                System.out.println(-1);
                return;
            }
            t1 += (int) (n / gcd);
            t2 += (int) (m / gcd);
        }
        System.out.println(lcm);
    }

    static long gcd(long a, long b) {
        if (a < b) {
            a ^= b;
            b ^= a;
            a ^= b;
        }
        while (b != 0) {
            long tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }

    public static void main(String args[]) {

        solve(new Scanner(System.in));
    }
}


Measured memory_bytes: 27832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] input = Console.ReadLine().ToCharArray();
            string output = "";
            for (int i = input.Length - 1; i >= 0; i--)
            {
                output = output + input[i];
            }
            Console.WriteLine(output);
        }
    }
}

Measured memory_bytes: 5232
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		long a = Integer.parseInt(st.nextToken());
	 		long b = Integer.parseInt(st.nextToken());
	 		long c = Integer.parseInt(st.nextToken());
	 		long d = Integer.parseInt(st.nextToken());
	 	out.println(Math.max(Math.max(a*c, b*d), Math.max(a*d,  b*c)));
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25412
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int SIZEN = 100010;
typedef long long LL;
int N;
LL a[SIZEN] = {0};
int main(){
	scanf("%d",&N);
	for(int i = 1;i <= N;i++)scanf("%lld",&a[i]);
	sort(a + 1,a + 1 + N);
	LL ans = 0;
	if(a[1] >= 0){
		for(int i = 2;i <= N;i++)ans += a[i];
		ans -= a[1];
		printf("%lld\n",ans);
		for(int i = 2;i < N;i++){
			printf("%lld %lld\n",a[1],a[i]);
			a[1] -= a[i];
		}
		printf("%lld %lld\n",a[N],a[1]);
	}
	else if(a[N] <= 0){
		for(int i = 1;i < N;i++)ans += a[i];
		ans = a[N] - ans;	
		printf("%lld\n",ans);
		for(int i = 1;i < N;i++){
			printf("%lld %lld\n",a[N],a[i]);
			a[N] -= a[i];
		}
	}
	else{
		for(int i = 1;i <= N;i++)ans += abs(a[i]);
		printf("%lld\n",ans);
		for(int i = 2;i < N;i++){
			if(a[i] < 0)printf("%lld %lld\n",a[N],a[i]),a[N] -= a[i];
			else printf("%lld %lld\n",a[1],a[i]),a[1] -= a[i];
		}
		printf("%lld %lld\n",a[N],a[1]);
	}
	return 0;
} 

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
    int tall[1000];
    tall[1] = 1;
    for(int i=2; i<1000; i++){
        tall[i] = tall[i-1] + i;
    }

    int a, b;
    cin >> a >> b;
    cout << tall[b-a]-b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int m, nmax, nmin;
int a[210];
int main() {
	while (cin >> m >> nmin >> nmax) {
		if (m == 0)return 0;
		int sa = 0;
		int ansi=nmin;
		for (int i = 0; i < m; i++)cin >> a[i];
		for (int i = nmin ; i <= nmax; i++) {
			int now = sa;
			sa = max(sa, a[i-1] - a[i]);
			if (sa != now)ansi = i;
			if (a[i - 1] - a[i] == now)ansi = i;
		}
		cout << ansi << endl;
	}
}

Measured memory_bytes: 3052
#from math import gcd
from fractions import gcd

A,B = map(int,input().split())
C = gcd(A,B)
def factorize(n):
    b = 2
    fct = set()
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.add(b)
        b = b + 1
    if n > 1:
        fct.add(b)
    return fct

tmp = factorize(C)
print(len(tmp)+1)

Measured memory_bytes: 65644
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a, b, c; 
	cin >> a >> b >> c; 
	if(a + b >= c){
		cout << "No" << endl; return 0; 
	}
	else if((c-a-b) * (c-a-b) <= 4*a*b){
		cout << "No" << endl; return 0; 
	}
	cout << "Yes" << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int n;
    cin >> n;
    set<char> s;
    for(int i = 0; i < n; i++){
        char x;
        cin >> x;
        s.insert(x);
    }
    if(s.size() == 4) cout << "Four";
    else cout << "Three";
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        int a[] = new int[n];
        int x[][] = new int[n][n];
        int y[][] = new int[n][n];
        int i,j,k;
        for(i = 0;i < n; i++){
          a[i] = sc.nextInt();
          for(j = 0;j < a[i];j++){
            x[i][j] = sc.nextInt() - 1;
            y[i][j] = sc.nextInt();
          }
        }
        int ans = 0,count = 0;
        boolean check = false;
      
		for(i = 0; i < (int)Math.pow(2,n); i++){
            //System.out.println(count);
            count = 0;
         	check = true;
			for(j = 0; j < n; j++){
              if((1&i>>j)==1){
                count += 1;
                for(k = 0;k < a[j];k++){
                  if(y[j][k] == 1){
                    if(!((1&i>>(x[j][k]))==1)){
                		check = false;
                    }
                  }else{
              		if(!((1&i>>(x[j][k]))==0)){
                		check = false;
             		 }
            	  }
                }
              }
            }
            if(check == true){
                if(count > ans){
                 ans = count; 
                }
            }
		}
       	System.out.println(ans);
    }
}

Measured memory_bytes: 37492
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define nl '\n'
typedef long long ll;
//////////////////////////////////////////////////////////////////////



int main(){
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int lx = max(a,c);
  int rx = min(b,d);

  cout << max(rx-lx,0) << nl;
  
  return 0;
}


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

using namespace std;

int main() {
	map<long long int, long long int> mp;

	long long int s;
	long long int i = 0;
	cin >> s; 

	while (mp[s] == 0) {
		mp[s] = 1;
		if (s % 2 == 0) {
			s /= 2;
		}
		else {
			s = s * 3 + 1;
		}
		i++;
	}

	cout << i + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int x,y;
	cin>>x>>y;
	if(y%2==1||y>4*x||y<2*x)cout<<"No";
	else cout<<"Yes";
	return 0;
}



Measured memory_bytes: 3672
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;


int main(){
	FIO
	
	int n;cin >> n;
	set<pair<int, int>> pos;
	for1(i, n - 1){
		if(i != n - i)
			pos.insert({min(i, n - i), max(i, n - i)});
	}
	cout << pos.size();
	return 0;
}


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

long long X;

int main(){
	cin >> X;
	map<long long, long long> mapi;

	for(long long i = -1000; i < 1000; i++) {
		long long count = i;
		for(long long j = 0; j < 4; j++) {
			count *= i;
		}
		mapi[i] = count;
	}

	for(long long i = -1000; i < 1000; i++) {
		for(long long j = -1000; j < 1000; j++) {
			if(mapi[i] - mapi[j] == X) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	return 1;
}


Measured memory_bytes: 3732
/*
https://beta.atcoder.jp/contests/abc104/tasks/abc104_a
*/

#include <iostream>

using namespace std;

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

    if(R < 1200){
        cout << "ABC" << endl;
        return 0;
    }
    if(R < 2800){
        cout << "ARC" << endl;
        return 0;
    }
    cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	let
		res = do
			i <- [ 1 .. n ]
			guard $ ( i * 108 `div` 100 )  == n
			return i
	putStrLn $ if null res
		then ":("
		else show $ head res

Measured memory_bytes: 508
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

bool solve(ll c, vector <ll> &A, int n, ll k) {
	ll w=0;
	for (int i=0;i<n;i++) {
		w+=A[i]/c;
		if (A[i]%c==0) {w--;}
		}
	if (w>k) {return false;}
	return true;
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll k;
    cin>>n>>k;
    vector <ll> A(n);
    ll d=0;
    for (int i=0;i<n;i++) {cin>>A[i];d=max(d,A[i]);}
    ll a=1;
    ll b=d;
    while (b-a>3) {
		ll c=(a+b)/2;
		if (solve(c,A,n,k)) {b=c;}
		else {a=c;}
		}
	while (!solve(a,A,n,k)) {a++;}
	cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007


int main(){
    int n,m;
    int ans=0;
    int L=-inf,R=inf;
    cin >> n >> m;
    rep(i,m){
        int l,r;
        cin >> l >> r;
        L=max(l,L);
        R=min(r,R);
    }
    if(R>=L) cout << (R-L)+1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 1000000
int linearSearch(int key,int [1000000]);
int n;
int s[N],t[N];
int main(){
  int q,i,x;
  int num=0;
  scanf("%d", &n);
  for(i = 0; i <n; i++){
    scanf("%d" , &s[i]);
  }
 scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d" , &t[i]);
  }

  for(i = 0; i < q; i++){
    
    x = linearSearch(t[i],s);
  
    if(x != -1) num++;
  }
  printf("%d\n", num);
  return 0;
}

int linearSearch(int key, int A[n]){
  int i=0;
  A[n] = key;
  while(A[i] != key){
        i++;
    if(i == n) return -1;
   
  }
  return i;
}

Measured memory_bytes: 2652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){

	int N, K;
	cin >> N >> K;
	cout << (N-2)/(K-1)+1 << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<queue>
#include<utility>
#include<set>
using namespace std;
using ll = long long;

int main(){ 
    int a,p;
    cin >> a >> p;
    p+=a*3;
    cout << p/2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	ll a,b;
	cin>>a>>b;
	ll p=__gcd(a,b);
	int ans=0;
	for(ll i=2;i*i<=p;i++)
	{ 
		if(p%i==0)
		{
			ans++;
			while(p%i==0)
			{
				p/=i;
			}
		}	
	} 
	if(p!=1)
	{
		ans++;
	}
	ans++;
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    import sys

    input = sys.stdin.readline
    a, b, c = map(int, input().split())

    # See:
    # https://www.youtube.com/watch?v=bHzohtVsG0Q&feature=youtu.be
    # KeyInsight: 整数で比較する．両辺を意味を変えずに変形
    # ハマった点: 小数同士で比較しようとしていた

    # √a + √b < √c
    # (√a + √b) ** 2 < √c ** 2
    # a + 2√ab + b < c
    # 2√ab < c - (a + b)
    # 4ab < (c - (a + b)) ** 2
    diff = c - (a + b)

    # 右辺は、0以上でないといけない
    if diff < 0:
        print('No')
        exit()

    if (4 * a * b) < (diff ** 2):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//

int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (i = 0; i < N; i++) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				cout << "DENIED";
				exit(0);
			}
		}
	}
	cout << "APPROVED";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  long long n,z;
  cin>>n;
  vector<long long> a(n+1,0);
  vector<long long> b(n+1,0);
  vector<long long> c(n+1,0);
  long long dp[n+1][3]={};
  for(int i=1;i<=n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  for(int i=1;i<=n;i++){
    dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2]=max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
  }
  z=max(dp[n][0],max(dp[n][1],dp[n][2]));
    cout<<z<<"\n";
    return 0;
}

Measured memory_bytes: 7924
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> lines = new ArrayList<String>();
		while (br.ready()){
			lines.add(br.readLine());
		}
		
		int N = Integer.parseInt(lines.get(0));
		String[] tmp = lines.get(1).split(" ");
		int[] num = new int[tmp.length];
		for(int i=0; i<tmp.length; i++){
			num[i] = Integer.parseInt(tmp[i]);
		}
		sort(num);


	}

	static void sort(int[] num){
		int key;
		for(int i=0; i<num.length; i++){
			key = num[i];
			
			for(int j=i; j>0 && key < num[j-1];j--){
				num[j] = num[j-1];
				num[j-1] = key;
			}
			print(num);
		}
			
	}
	
	static void print(int[] num){
		for(int i=0; i<num.length-1; i++){
			System.out.print(num[i]);
			System.out.print(" ");
		}
		System.out.println(num[num.length-1]);
	}
}

Measured memory_bytes: 30184
n=int(input())
a,b=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
x=0
y=0
z=0
for i in l:
  if i<=a:
    x+=1
  elif i<=b:
    y+=1
  else:
    z+=1
print(min([x,y,z]))

Measured memory_bytes: 3064
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var a = strShift();
  var len = a.length;
  
  var b = 0;
  var c = 0;
  
  for(var i = 0; i < len ; i++){
  	var hoge = [1,0];
    var fuga = [0,1];
  	var d = a[i];
    if(hoge[i%2]==d)b++;
    if(fuga[i%2]==d)c++;
  }
  
  return ~~Math.min(b,c);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
10010010
`);

Measured memory_bytes: 10188
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin>>N;
    for(int i=N;i<=100000000000;i=i+N){
        if(i%2==0){
            cout<<i<<endl; return 0;
        }else{
            cout<<i+i<<endl; return 0;
        }
    }
    
}


Measured memory_bytes: 256
h,w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
now = 0
for i in range(h):
  ans = []
  res = w
  while a[now] < res:
    ans += [now+1 for i in range(a[now])]
    res -= a[now]
    now += 1
  else:
    ans += [now+1 for i in range(res)]
    a[now] -= res
  if i % 2:
    ans.reverse()
  print(*ans)

Measured memory_bytes: 3700
#include  <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int n;
      int a;
      int b;
      
      cin >> n >> a;
      
      b = n%500;
      
      if (b <= a){
      cout << "Yes" << endl;
      }
      else
      cout << "No" << endl;
        
    }


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){

  int n,m,a,s,ma=0;
  scanf("%d %d",&n,&m);

  for(int i=0;i<n;i++){
    s = 0;
    for(int j=0;j<m;j++){
      scanf("%d",&a);
      s += a;
    }
    if(s > ma) ma = s;
  }

  printf("%d\n",ma);
  return (0);
}
    

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



int main(){
  int n,i;
  cin >> n;
  long long int ans=1;
  long long int thold = 1e18;
  bool overflow=false;
  for(i=0;i<n;i++){
    long long int a;
    cin >> a;
    if(a == 0) {
      ans =0;
      break;
    }else{
      if(!overflow) {
      	if(ans > thold/a){
        	overflow = true;
          	ans = -1;
        }else{
	        ans *=a;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int K,A,B, tmp;

void solve(){
    tmp = (A+ K - 1) / K;

    if(B >= tmp * K) cout << "OK" << endl;
    else cout << "NG" << endl; 
}

int main(){
    cin >> K >> A >> B;

    solve();
}


Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))

def check(a):
    for i in a:
        if i % 2 == 0:
            if i % 3 != 0 and i % 5 != 0:
                return False
    return True

ans = 'APPROVED' if check(a) else 'DENIED'
print(ans)

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

int main()
{
    ll N; cin >> N;
    vector<ll> a(N, 0);
    rep(i,N) {
        ll tmp; cin >> tmp;
        a[i] = tmp - 1;
    }
    ll ansi = 0;
    ll ans = 0;
    rep(i,N) {
        ans++;
        if (a[ansi] == 1) {
            cout << ans << endl;
            exit(0); 
        }
        ansi = a[ansi];
    }
    cout << -1 << endl;



}


Measured memory_bytes: 4384
#include <iostream>

int cnt = 0;

void bubbleSort(int A[],int N){
    bool flag = true;
    int tmp;
    while(flag){
        flag = false;
        for(int i=N-1;i>0;i--){
            if(A[i]<A[i-1]){
                tmp = A[i];
                A[i] = A[i-1];
                A[i-1] = tmp;
                flag = true;
                cnt++;
            }
        }
    }
}

int main(){
    int N;
    std::cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        std::cin >> A[i];
    }
    bubbleSort(A,N);
    for(int i=0;i<N;i++){
        std::cout << A[i];
        if(i==N-1){
            std::cout << std::endl;
        }else{
            std::cout << " ";
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 3108
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [list(map(int,input().split())) for i in range(m)]

ans = []

for i in a:
  count = 10**10
  check = 0
  for j in range(m):
    if count > abs(i[0]-b[j][0])+abs(i[1]-b[j][1]):
      check = j+1
      count = abs(i[0]-b[j][0])+abs(i[1]-b[j][1])
    
  ans.append(check)
for i in ans:
  print(i)


Measured memory_bytes: 3064
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1];
	ulong tmp = 1;
	ulong res;
	while(tmp < B) {
		tmp--;
		tmp += A;
		res++;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main(void){
	int n;
	int k;
	int now=0;
	int t=0;
	int a0=0,a1=0,a2=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>k;
		if(k%3==0)a0++;
		if(k%3==1)a1++;
		if(k%3==2)a2++;
	}
	if(a1==0&&a2==0){
		cout<<1<<endl;
		return 0;
	}
	t=a0+1;
	if(a1>a2){
		a1--;
		now=1;
	}
	else{
		a2--;
		now=2;
	}
	while(true){
		// cout<<a2<<":"<<a1<<":"<<now<<endl;
		if(now==2){
			if(a2>0){
				now=1;
				a2--;
				t++;
			}else{
				if(a1>0){
					t++;
					a1--;
				}
				break;
			}
		}else if(now==1){
			if(a1>0){
				now=2;
				a1--;
				t++;
			}else{
				if(a2>0){
					t++;
					a2--;
				}
				break;
			}
		}
	}
	if(a1!=0&&a2!=0)t++;
	cout<<t<<endl;
	return 0;

}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int main()
{
	IOS;
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i *= 100) {
		int v = min(i*10-1, n);
		ans += v - i + 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

//return the number of ng
long long binary_search(vector<long long> vec, long long value) {
    long long left = -1;
    long long right = (long long)vec.size();
    while (right - left > 1) {
        long long mid = (left + right) / 2;
        if(vec[mid] >= value){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int main() {
    long long n;
    cin >> n;
    vector<long long> vec(n);
    rep(i, n) cin >> vec[i];
    sort(all(vec));

    // 1 2 3 4
    ll ans = 0;
    for(ll i = 0; i < n-1; i++){
        for(ll j = i+1; j < n; j++){
            ll tmp = vec[i] + vec[j];
            ll c = binary_search(vec, tmp);
            ans = ans + (c - (j+1)) ;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<cctype>
#define rep(i,start,n) for(int i=start;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main(void) {
	while (true) {
		string str;
		cin >> str;
		if (str == "-")break;
		int m; cin >> m;
		vector<int> h(m);
		rep(i, 0, m) {
			cin >> h[i];
		}
		rep(i, 0, m) {
			string sub, upper;
			sub = str.substr(0, h[i]);
			upper = str.substr(h[i], str.length()-h[i]);
			str = upper + sub;
		}
		cout << str<<endl;
	}

}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
long long solve(vector<long long> &x, vector<long long> &y){
	long long ans=0;
	int n = x.size();
	long long s = INT_MAX, c = INT_MAX;
	for(int a : {1, -1}){
		for(int b : {1, -1}){
			s = a*x[0] + b * y[0] + 0;
			for(int i = 1; i<n; i++){
				c = a*x[i] + b*y[i] ;
				ans = max(ans, c - s);
				s = min(s, c);
			}
		}
	}
	return ans;
}
int main(){
	int n;
	vector<long long> x, y;
	cin >> n;
	for(int i = 0; i<n; i++){
		long long a, b;
		cin >>a >> b;
		x.push_back(a), y.push_back(b);
	}
	cout << solve(x, y) <<endl;
	
  return 0;
}


Measured memory_bytes: 6632
//c.c --- Maximal Value
#include<stdio.h>

int main(void){
    int n,sum=0;
    scanf("%d",&n);
    int a[100],b[100];
    for(int i=0;i<n-1;++i){
        scanf("%d",&b[i]);
    }
    a[0] = b[0];
    for(int j = 0;j<n-1;++j){
        if(j!=n-2){
            int x = b[j],y = b[j+1];
            if(x>y){
                a[j+1] = y;
            }else{
                a[j+1] = x;
            }
        }else{
            a[j+1] = b[j];
        }
    }
    for(int k=0;k<n;++k){
        sum += a[k];
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    while( n>0 ){
    if ( n%10==7 ) {
        cout << "Yes" << '\n';
        return 0;
    }
    n/=10;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
import fractions

N=int(input())
A=list(map(int,input().split()))

L=[0,A[0]]
R=[0,A[-1]]
for i in range(N-1):
    #l=fractions.gcd(L[i+1],A[i+1])
    #r=fractions.gcd(R[i+1],A[N-i-2])
    L.append(fractions.gcd(L[i+1],A[i+1]))
    R.append(fractions.gcd(R[i+1],A[N-i-2]))
    #print(L[i+1],A[i+1],R[i+1],A[N-i-2])
#print(L)
#print(R)
arr=[]
for i in range(N):
    a=fractions.gcd(L[i],R[N-i-1])
    arr.append(a)
    #print(i,L[i],R[N-i-1],a,arr)
print(max(arr))

Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;

ll solve (ll x) {
    int p;
    rrep(i,50) {
        if(pow(2,i) > x) {
            p = i;
            break;
        }
    }
    x++;
    ll res = 0;
    rep(i,p) {
        ll div = x / (ll)pow(2,i+1);
        ll r = x % (ll)pow(2,i+1);
        ll cnt = 0;
        if(r <= (ll)pow(2,i)) cnt += (ll)pow(2,i) * div;
        else cnt += (ll)pow(2,i) * div + r - (ll)pow(2,i);
        if(cnt % 2) res += (ll)pow(2,i);
    }
    return res;
}

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

ll A,B;
cin >> A >> B;
ll ans = solve(A-1) ^ solve(B);
cout << ans << endl;
return 0;
}

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

int main(){
	vector<int>vec;
	int s,i;
	cin>>s;
	vec.push_back(s);
	for(;;){
		if(vec[i]%2==0){
			vec.push_back(vec[i]/2);
		}
		else{
			vec.push_back(vec[i]*3+1);
		}
		for(int j=0;j<i;j++){
			if(vec[j]==vec[i]){
				cout<<i+1<<endl;
				return 0;
			}
			
		}
		i++;
	}
}

Measured memory_bytes: 256
from sys import stdin
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
M1, D1 = map(int, stdin.readline().rstrip().split())
M2, D2 = map(int, stdin.readline().rstrip().split())
#S = [list(stdin.buffer.readline().decode().rstrip()) for _ in range(h)]

if M1 != M2:
    print(1)
else:
    print(0)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int ans;
string s;
int main() {
  int a, b;
  cin >> s;
  if(s[0] == '1') ans++;
  if(s[1] == '1') ans++;
  if(s[2] == '1') ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int N=sc.nextInt();
       String S;
       int counter=0;

        S=sc.next();

        for (int i=0;i<N;i++){
            if (S.charAt(i)=='C')
                if (S.charAt(i-1)=='B')
                    if (S.charAt(i-2)=='A')
                        counter++;
        }
        System.out.println(counter);


    }
}


Measured memory_bytes: 22736
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	repn(i, 1, s.size()){
		if(s[i] == s[i - 1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main() {

	int A, B;

	cin >> A >> B;

	if (A <= 8 && B <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	
	return 0;

}


Measured memory_bytes: 256
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
      if(N==1){
        Console.WriteLine(0);
      }else{
        Console.WriteLine(1);
      }
    }
    
  }

}


Measured memory_bytes: 27516
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  string s;
  cin >> s;
  if(std::count(all(s), '7') >= 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620