akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;




int main()
{
    idfc;
    int n;
    cin>>n;
    ll x=0;
    int e;
    int i;
    vector<int> vv;
    for(i=0;i<n;i++)
    {
        cin>>e;
        vv.pb(e);
        x^=e;
    }
    vector<ll> ans;
    for(i=0;i<n;i++)
    {
        ans.pb(x^vv[i]);
    }
    for(ll i:ans)cout<<i<<" ";
    return 0;
}


Measured memory_bytes: 6064
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
using namespace std;
lo int n,a,b,A[li],sum,A2[li];
bool check(lo int gg){
	lo int tot=gg*b;
	lo int cev=0;
	for(int i=1;i<=n;i++){
		A2[i]=A[i]-tot;
	}
	for(int i=1;i<=n;i++){
		if(A2[i]>0){
			cev+=(A2[i]+(a-b)-1)/(a-b);
		}
	}
	return gg>=cev;
}
int main(){
	scanf("%lld %lld %lld",&n,&a,&b);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	lo int bas=0,son=1000000000000000/a;
	while(bas<=son){
		lo int mid=(bas+son)/2;
		if(check(mid)) son=mid-1;
		else bas=mid+1;
	}
	printf("%lld\n",bas);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

bool compare(pair<int,int> i1, pair<int,int> i2) 
{ 
    return (i1.second < i2.second); 
} 

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(int argc, const char * argv[]) {

  // int a, b, c;
  vector<int> ring(3);
  rep(i,3){
    cin >> ring[i];
  }
  sort(ring.begin(), ring.end());
  cout << ring[0] + ring[1] << endl;
  
  
}


Measured memory_bytes: 256
A=input()
if A[0]==A[1]==A[2]==A[3]:
  print("No")
elif A[0]==A[1] and A[2]==A[3]:
  print("Yes")
elif A[1]==A[2] and A[0]==A[3]:
  print("Yes")
elif A[0]==A[2] and A[1]==A[3]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int w,h,a[100][100],b[100][100],c[100][100],d[100][100];

int main(){
	rep(i,100){a[0][i]=1;b[i][0]=1;}
	for(int i=1;i<100;i++)for(int j=1;j<100;j++){
		a[i][j]=(a[i][j-1]+c[i][j-1])%100000;
		b[i][j]=(b[i-1][j]+d[i-1][j])%100000;
		c[i][j]=b[i][j-1]%100000;
		d[i][j]=a[i-1][j]%100000;
	}
	while(cin>>w>>h&&w){
		cout<<(a[h-1][w-1]+b[h-1][w-1]+c[h-1][w-1]+d[h-1][w-1])%100000<<endl;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll a,b,c,d,t;
  cin>>a>>c>>b>>d>>t;
  if(a>b){
    a=-a;
    b=-b;
  }
  ll ta=a+t*c;
  ll tb=b+t*d;

  if(tb<=ta){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}


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

using namespace std;

int alphabet[26];

int main(){
  int N;  cin >> N;
  
  for(int i = 0; i < 26; i++){ alphabet[i] = 1e9;}
  
  
  vector<vector<int>> alphabetical(N, vector<int>(26,0));
  for(int i = 0; i < N; i++){
    string S; cin >> S; 
    for(int j = 0; j < (int) S.size(); j++){
      int c = S[j] - 'a';
      alphabetical[i][c]++;}
  }
  
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < N; j++){
      alphabet[i] = min(alphabet[i], alphabetical[j][i]);}}
  
  string ans = "";
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < alphabet[i]; j++){
      char d = i + 'a';
      ans += d;}}  sort( ans.begin(),ans.end());
  
  cout << ans << endl; return 0;}
  

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N, W; cin >> N >> W;
  vi64 lst[4];
  int w, v; cin >> w >> v;
  lst[0].push_back(v);
  i64 w0 = w;
  rep(i, N - 1) {
    cin >> w >> v;
    lst[w - w0].push_back(v);
  }
  rep(i, 4) sort(all(lst[i])), lst[i].push_back(0), reverse(all(lst[i]));
  rep(i, 4) rep(j, lst[i].size() - 1) lst[i][j + 1] += lst[i][j];
  i64 ans = 0;
  rep(i, lst[0].size()) rep(j, lst[1].size()) rep(k, lst[2].size()) rep(l, lst[3].size()) {
    if (w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l > W) break;
    amax(ans, lst[0][i] + lst[1][j] + lst[2][k] + lst[3][l]);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
W, H, N = map(int,input().split())
dx, dy = 0, 0
for _ in range(N):
  x, y, a = map(int,input().split())
  if(a == 1):
    dx = max(dx, x)
  elif(a == 2):
    W = min(W, x)
  elif(a == 3):
    dy = max(dy, y)
  else:
    H = min(H, y)
if(W <= dx or H <= dy):
  print(0)
else:
  print((dx-W) * (dy-H))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int N;
int a[MAX_N*3+10];

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

  cin >> N;
  rep(i, 3*N) cin >> a[i];

  sort(a, a+3*N);
  reverse(a, a+3*N);

  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    ans += a[2*i-1];
  }

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



Measured memory_bytes: 1408
import math
inf=float('inf')
N = int(input())
x = list(map(int, input().split()))
y = [0]*(N)
j=0
for i in range(0,N,1):
    
    if i%2==0:
        y[j]=x[N-1-i]
  
    if i%2==1:
        y[N-1-j]=x[N-1-i]
        j+=1
    
    


for i in range(len(y)):
    print(y[i],end=' ')
 
quit()

Measured memory_bytes: 25156
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.141592653589793

int main() 
{	
	int t = 1;
	//cin>>t;
	while (t--) {
		string s;
		cin>>s;
		int n = sz(s);
		int x = s[n-1] - '0';
		if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9) cout<<"hon";
		else if (x == 0 || x == 1 || x == 6 || x == 8) cout<<"pon";
		else cout<<"bon";
		cout<<"\n";
	}
    return 0; 
} 


Measured memory_bytes: 3628
import math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

# grid
# N = I()
# 黒く塗りつぶす#が独立していたら不可
H,W = LI()
S = [list(_S()) for _ in range (H)]

def check(x, y):
    # 移動する4方向をループ
    res = False
    # for dx,dy in itertools.product([-1,0,1],repeat=2):
    dxs = [-1,1]
    dys = [-1,1]
    for dx in dxs:
        nx = x + dx
        ny = y
        if 0 <= nx and nx < H and S[nx][ny] == "#":
            res = True
    for dy in dys:
        nx = x
        ny = y + dy
        if 0 <= ny and ny < W and S[nx][ny] == "#":
            res = True
    return res

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            if not check(i,j):
                print('No')
                exit()

print('Yes')

Measured memory_bytes: 27040
#include<iostream>

using namespace std;

void call(int n) {
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
		}
		else {
			int x = i;
			while (x != 0) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	call(n);
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    
    long double ans = 0.0;
    while (n--) {
        int a;
        cin >> a;
        long double x = 1.0/a;
        ans += x;
    }
    ans = 1.0/ans;
    cout << fixed << setprecision(6) << ans << endl;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int W, a, b;
void input() {
  cin >> W >> a >> b;
  ;
}
void solve() {
  int ans;
  if (a + W < b) {
    ans = b - a - W;
  } else if ((a <= b && a + W >= b) || (b <= a && b + W >= a)) {
    ans = 0;
  } else {
    ans = a - b - W;
  }
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 300005;

i64 n;

i64 a[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);


    i64 a, b;
    cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
        cout << a * b << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read.Reverse();
            var words = new string[] { "maerd", "remaerd", "esare", "resare" };
            var flag = true;
            for (int i = 0; i < S.Length;)
            {
                var flag2 = false;
                foreach (var x in words)
                    if (S.Length - i < x.Length) continue;
                    else if (S.Substring(i, x.Length) == x) { flag2 = true; i += x.Length; }
                if (!flag2) { flag = false; break; }
            }
            if (flag) WriteLine("YES");
            else WriteLine("NO");
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
    }
}


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
        
    if ( a <= b && b <= c ){
        
    cout << a << " " << b << " " << c << endl;
    
    }
    
    else if ( ( a >= b && b <= c )&& a <= c ){
        
    cout << b << " " << a << " " << c << endl;
    
    }
    
    else if (( a <= b && b >= c ) && a <= c ){
        
    cout << a << " " << c << " " << b << endl;
    
    }
    
    else if ( ( a <= b && b >= c ) && a >= c ){
        
    cout << c << " " << a << " " << b << endl;
    
    }
    
    else if ( ( a >= b && b <= c ) && a >= c ){
        
    cout << b << " " << c << " " << a << endl;
    
    }
    
    else if ( a > b && b > c  ){
        
    cout << c << " " << b << " " << a << endl;
    
    }

}


Measured memory_bytes: 3088
//بسم الله الرحمن الرحيم
//* In The Name 0f ALLAH *//* The Most Beneficent *//* The Most Merciful *//*
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx=1e5+123;
ll b,ans;

void _case_()
{
    int a,b;
    cin >> a >> b;
    cout << (6-(a+b)) el;
}

int main()
{
    //file();
    optimize();
    //_test_
        _case_();

    return 0;
}

///////////*  N A Y E M  *///////////

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
   
   string s,t;
   cin>>s>>t;
   int n=s.length();int m=t.length();
   int dp[n+1][m+1];
   memset(dp,0,sizeof(dp));string ans="";
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=m;j++)
       {
           if(s[i-1]==t[j-1])
           {
               dp[i][j]=dp[i-1][j-1]+1;//ans+=s[i-1];
           }
           else
           {
               dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
           }
       }
   }
   int i=n,j=m;
   while(i>0 && j>0)
   {
       if(s[i-1]==t[j-1])
       {
           ans+=s[i-1];i--;j--;
       }
       else if(dp[i-1][j]>dp[i][j-1])
       {
           i--;
       }
       else
       {
           j--;
       }
   }
   reverse(ans.begin(),ans.end());
   cout<<ans;
	return 0;
}

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

ans=[]

re=[[] for _ in range(n)]



for _ in range(m):
  a=list(map(int,input().split()))
  re[a[0]-1].append(a[1])
  ans.append(a)
  
d={}
for f in re:
  new=sorted(f)
  
  for i in range(len(new)):
    d[new[i]]=i+1
  
for x in ans:
  p=x[0]
  q=d[x[1]]
  print(str('{:0=6}'.format(p))+str('{:0=6}'.format(q)))
  



Measured memory_bytes: 46496
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long

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

	int N,K;
	cin>>N>>K;
	vector<int> A(100001, 0);

	for (int i = 0; i < N; i++) {
		int a,b;
		cin>>a>>b;
		A[a] += b;
	}
	int tmp = 0;
	int ans = 0;
	for (int i = 0; i < 100001; i++) {
		tmp += A[i];
		if(tmp>=K){
			ans=i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ve <ll> A(n),B(n);
    ve <ll> freA(1e6,0),freB(1e6,0);
    rep (i,0,n)
    {
        cin>>A[i];
        freA[A[i]]++;
    }
    rep (i,0,n)
    {
        cin>>B[i];
        freB[B[i]]++;
    }
    rep (i,0,1e6)
    {
        if (freA[i]+freB[i]>n)
        {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    
    ll opr=0;
    reverse(all(B));
    rep (i,0,n)
    {
        if (A[i]==B[i])
        {
            reverse(B.begin()+i,B.end());
            i--;
            opr+=n-i;
        }
        if (opr>5e6)
        {
            goto zee;
        }
    }
    for (auto x: B)
    {
        cout<<x<<" ";
    }
    return 0;
    zee:;
    map <ll,ll> m1;
    rep (i,0,n)
    {
        m1[B[i]]++;
    }
    ve <ll> ans;
    auto itr=m1.begin();
    ll p=0;
    while (p<n)
    {   
        ll val=itr->first;
        // cout<<"val.. "<<val<<"\n";
        while (A[p]==val||m1[val]==0)
        {
            // cout<<"val.. "<<itr->first<<"\n";
            itr++;
            if (itr==m1.end())
            {
                itr=m1.begin();
            }
            val=itr->first;
        }
        // cout<<"val.. "<<itr->first<<"\n";
        ans.pb(itr->first);
        m1[itr->first]--;
        p++;
    }

    for (auto x: ans)
    {
        cout<<x<<" ";
    }
}


Measured memory_bytes: 24080
#include <cstdio>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

int main() {
    int H[1001];
    double N,T,A;
    double temp[1001];
    cin >> N>> T>> A;
    for(int i=0; i<N; i++){
        cin>> H[i];
        temp[i] = T - 0.006 * H[i];
    }
    double min = 1000000;
    int place=0;
    for(int i=0; i<N; i++){
        double a = temp[i] -A;
        if(a <=0){
            a = -a;
        }
        if(a < min){
            min = a;
            place = i+1;
        }
    }

    printf("%d", place);
    return 0;


}



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

int main(void) {
  int N;
  cin >> N;
  vector<int> B(N - 1);
  vector<int> A(N, 100001);
  for (int i = 0; i < N - 1; i++) {
    cin >> B[i];
  }
  A[0] = B[0];
  for (int i = 1; i < N - 1; i++) {
    A[i] = min(B[i - 1], B[i]);
  }
  A[N - 1] = B[N - 2];
  cout << accumulate(A.begin(), A.end(), 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
typedef long long int ll;
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x=a*c;
	ll y=a*d;
	ll i=b*c;
	ll j=b*d;
	ll p=max(i,j);
	ll q=max(x,y);
	cout<<max(p,q);
}

Measured memory_bytes: 3176
n = eval(input())
a = input().split()
prod = 1
for i in range(0, n):
    a[i] = int(a[i])
a = sorted(a)
for i in range(0, n):
    prod *= int(a[i])
    if prod > 1e18:
        break
if prod > 1e18:
    print(-1)
else:
    print(prod)


Measured memory_bytes: 19176
def check(n):
    if (n%3==0) | (n%5==0):
        return 0
    else:
        return n

n = int(input())
s = list(map(int, input().split()))
p = [i for i in s if i%2 == 0]
q = map(check,p)

if sum(q)==0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

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

    const string last = "zyxwvutsrqponmlkjihgfedcba";
    if(s == last){
        cout << -1 << endl;
        return 0;
    }

    vector<bool> used(last.size(), false);
    for(char c : s){
        used[c - 'a'] = true;
    }

    if(s.size() < last.size()){
        REP(i, used.size()){
            if(!used[i]){
                s.push_back('a' + (char)i);
                cout << s << endl;
                return 0;
            }
        }
    }else{
        while(1){
            ll nxt = -1;
            for(ll i = (ll)(s.back() - 'a') + 1; i < used.size(); ++i){
                if(!used[i]){
                    nxt = i;
                    break;
                }
            }
            if(nxt != -1){
                s.back() = ('a' + nxt);
                cout << s << endl;
                return 0;
            }else{
                used[s.back() - 'a'] = false;
                s.pop_back();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define f first
#define s second
    
int n,m,l,r,d, dis[N], vis[N], v=1;
vector <pair<int, int>> g[N];
stack <int> st;
int dfs(int from)
{
    vis[from] = v;
    for(auto pa : g[from])
    {
        if(vis[pa.f] != v)
        {
            dis[pa.f] = dis[from] + pa.s;
            if(dfs(pa.f) == -1)
            {
                return -1;
            }
        }else if(dis[pa.f] != dis[from] + pa.s)
        {
            return -1;
        }
    }
    return 1;
}

void dfs1(int from)
{
    vis[from] = v;
    for(auto pa: g[from])
    {
        if(vis[pa.f] != v)
        {
            dfs1(pa.f);
        }
    }
}

int main() {
    cin >> n >> m;
    for(int i=0; i<m; i++)
    {
        cin >> l >> r >> d;
        g[l].push_back({r,d});
    }
    for(int i=1; i<n ;i++)
    {
        if(vis[i] != v) 
        {
            st.push(i);
            dfs1(i);
        }
    }
    v++;
    while(!st.empty())
    {
        int i = st.top();
        if(vis[i] != v)
        {
            for(auto pa : g[i])
            {
                if(vis[pa.f] == v)
                {
                    dis[i] = dis[pa.f] - pa.s;
                    break;
                }
            }
            if(dfs(i) == -1)
            {
               cout << "No";
                return 0;
            }
        }
        st.pop();
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 9600
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    map<long long, int, greater<long long>> nums;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        nums[a]++;
    }
    for(int i=0;i<m;i++){
        int b, c;
        cin >> b >> c;
        nums[c] += b;
    }
    int rest = n;
    long long sumx = 0;
    for(auto pair: nums){
        if(rest <= pair.second){
            sumx += rest * pair.first;
            break;
        }        
        else{
            sumx += pair.first * pair.second;
            rest -= pair.second;
        }
    }
    cout << sumx << endl;
    return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int W, H;
		cin>>W>>H;
		if(W == 0 && H == 0) break;
		vector<vector<char> > m(H, vector<char>(W));
		vector<vector<pair<ll, string> > > dp(H, vector<pair<ll, string> >(W));
		REP(i, H) {
			REP(j, W) {
				cin>>m[i][j];
			}
		}
		REP(i, H) {
			REP(j, W) {
				int nh = H - 1 - i;
				int nw = W - 1 - j;
				if(i == 0 && j == 0) {
					if('0' <= m[nh][nw] && m[nh][nw] <= '9') {
						dp[nh][nw].second = m[nh][nw];
						dp[nh][nw].first = 1;
					} else {
						dp[nh][nw].first = 0;
						dp[nh][nw].second = "";
					}
				} else if(i == 0) {
					if('0' <= m[nh][nw] && m[nh][nw] <= '9') {
						dp[nh][nw].second = m[nh][nw];
						dp[nh][nw].second += dp[nh][nw + 1].second;
						dp[nh][nw].first = 1 + dp[nh][nw + 1].first;
					} else {
						dp[nh][nw].first = 0;
						dp[nh][nw].second = "";
					}
				} else if(j == 0) {
					if('0' <= m[nh][nw] && m[nh][nw] <= '9') {
						dp[nh][nw].second = m[nh][nw];
						dp[nh][nw].second += dp[nh + 1][nw].second;
						dp[nh][nw].first = 1 + dp[nh + 1][nw].first;
					} else {
						dp[nh][nw].first = 0;
						dp[nh][nw].second = "";
					}
				} else {
					if('0' <= m[nh][nw] && m[nh][nw] <= '9') {
						pair<ll, string> np = max(dp[nh][nw + 1], dp[nh + 1][nw]);
						dp[nh][nw].second = m[nh][nw];
						dp[nh][nw].second += np.second;
						dp[nh][nw].first = 1 + np.first;
					} else {
						dp[nh][nw].first = 0;
						dp[nh][nw].second = "";
					}
				}
			}
		}
		ll nagasa = 0;
		string ans = "";
		REP(i, H) {
			REP(j, W) {
				if(dp[i][j].first > nagasa && (dp[i][j].second)[0] != '0') {
					nagasa = dp[i][j].first;
					ans = dp[i][j].second;
				} else if(dp[i][j].first == nagasa && (dp[i][j].second)[0] != '0') {
					ans = max(ans, dp[i][j].second);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3268
/*
***************************************************************************
 name  : ITP1_05_B.cpp
 title : Print a Frame
 make  : 2018/08/15 tanabe
***************************************************************************
*/

// Library
#include <iostream> // standard input output object

main(void){
  int h; // height
  int w; // width
  int l; // line
  int c; // column

   // initialized input "h w"
  // continue h != 0 or w != 0
  // input "h w" at loop update
  for(std::cin >> h >> w;h || w;std::cin >> h >> w){
    // initialized l = 0
    // continue l < h
    // increment l at loop update
    for(l = 0;l < h;l++){
      // initialized c = 0
      // continue c < w
      // increment c at loop update
      for(c = 0;c < w;c++){
        if(l == 0 || l == h-1){
          std::cout << "#"; // output "#"
        }
        else{
          if(c == 0 || c == w-1){
            std::cout << "#"; // output "#"
          }
          else{
            std::cout << "."; // output "."
          }
        }
      }
      std::cout << std::endl; // new line
    }
    std::cout << std::endl; // new line
  }

}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
string k;
int main(){
	cin>>k;
	set<ll>kl;
	for(char c:k) kl.insert(c);
	for(ll ia = 'a';ia<=ll('z');ia++) if(!kl.count(char(ia))){cout<<char(ia)<<'\n';return 0;}
	cout<<"None\n";
}

Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int h, w;
int a[80][80];
int b[80][80];

const int C = 13000;
bool dp[81][81][26000];

int main() {
	int i, j, k, l;
	
	cin >> h >> w;
	rep(i, h) rep(j, w) cin >> a[i][j];
	rep(i, h) rep(j, w) cin >> b[i][j];
	
	dp[0][0][C] = true;
	rep(i, h) {
		rep(j, w) {
			rep(k, 26000) {
				if (dp[i][j][k] == false) continue;
				
				int nk[2];
				nk[0] = k + a[i][j] - b[i][j];
				nk[1] = k + b[i][j] - a[i][j];
				
				rep(l, 2) {
					dp[i + 1][j][nk[l]] = true;
					dp[i][j + 1][nk[l]] = true;
				}
			}
		}
	}
	
	int ans = 1145141919;
	rep(k, 26000) {
		if (dp[h-1][w-1][k] == false) continue;
		
		int diff = a[h-1][w-1] - b[h-1][w-1];
		int res1 = k - C - diff;
		int res2 = k - C + diff;
		ans = min({ans, abs(res1), abs(res2)});
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 165632
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  vector<long>d(N);
  ins(d);
  sort(all(d));
  cpp_int cnt=0;
  long M=1e5+5;
  rep(i,M){
    auto t=lb(all(d),i);
    long low_num=t-d.begin();
    long up_num=d.end()-t;
    if(low_num==up_num)cnt++;
  }
  out(cnt);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int main(){
	cin.sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	if((__builtin_popcount(a) & 1) == (__builtin_popcount(b) & 1)){
		cout << "NO" << '\n';
		return 0;
	}
	int mask = (1 << n) - 1;
	vector<int> z;
	vector<int> ans;
	while(mask > 0){
		int q = 0;
		while(((a ^ b) & (1 << q)) == 0) q++;
		vector<int> other_bits;
		for(int j = 0; j < n; j++) if(j != q && ((mask >> j) & 1)) other_bits.push_back(j);
		if(other_bits.size() > 1){
			while(true){
				random_shuffle(other_bits.begin(), other_bits.end());
				if((a ^ b) != (1 << other_bits.back())) break;
			}
		}
		int k = int(other_bits.size());
		for(int i = 0; i < (1 << k); i++){
			if(i == 0){
				ans.push_back(a);
			} else {
				ans.push_back(ans.back() ^ (1 << other_bits[__builtin_ctz(i)]));
			}
		}
		a = ans.back() ^ (1 << q);
		mask ^= (1 << q);
	}
	ans.push_back(b);
	cout << "YES" << '\n';
	for(int i = 0; i + 1 < ans.size(); i++){
		assert(__builtin_popcount(ans[i] ^ ans[i+1]) == 1);
	}
	for(int r : ans){
		cout << r << ' ';
	}
	cout << '\n';
	assert(ans.back() == b);
}

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

int blank( int num )
{
	if ( num == 0 || num == 1 )
		return num;
	return num % 10 + blank(num/10);
}

int main()
{
	int a;
	cin >> a;
	cout << blank(a) << "\n" ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    long long a,b,x ;
    scanf ("%lld%lld%lld",&a,&b,&x) ;
    long long ans1=b/x,ans2=(a-1)/x ;
    if (a==0) {
        printf ("%lld ",ans1+1) ;
    } else {
        printf ("%lld",ans1-ans2) ;
    }
    return 0 ;
}

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

typedef unsigned long long ulli;
const int MAXN = 300005;
const ulli B = 777737377ULL;
ulli Bn[MAXN];

int main() {
  Bn[0] = 1;
  for(int i = 1; i < MAXN; ++i) Bn[i] = Bn[i-1] * B;
  for(string S, T; cin >> S >> T; ) {
    map<ulli, ulli> num;
    ulli hash = 0;
    for(int i = 0; i < S.size(); ++i) {
      hash = hash * B + S[i];
      if(i >= T.size()) hash -= S[i-T.size()] * Bn[T.size()];
      if(i+1 >= T.size()) num[hash]++;
    }
    hash = 0;
    for(int i = 0; i < T.size(); ++i) {
      hash = hash * B + T[i];
    }
    ulli res = 0;
    for(int i = 0; i < T.size(); ++i) {
      for(char c = 'A'; c <= 'z'; ++c) {
        if(!isalpha(c)) continue;
        if(c == T[i]) continue;
        ulli nhash = hash;
        nhash += c * Bn[T.size()-i-1];
        nhash -= T[i] * Bn[T.size()-i-1];
        if(num.count(nhash)) {
          res += num[nhash];
        }
      }
    }
    cout << res << endl;
  }
  return 0;  
}

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

using namespace std;

int main() {

	string str; cin >> str;

	for (int i = 0; i < str.length() - 1; i++) {

		if (str[i] == str[i + 1]) {

			cout << i + 1 << " " << i + 2 << "\n";
			return 0;

		}

		if (i + 2 >= str.length()) continue;

		if (str[i] == str[i + 2]) {

			cout << i + 1 << " " << i + 3 << "\n";
			return 0;

		}

	}

	cout << "-1 -1\n";

	return 0;

}

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

int main(void){
    int n;
    cin >> n;
    
    int x[200000];
    int y[200000];
    int i;
    for(i = 0; i < n; i++){
        cin >> x[i];
        y[i] = x[i];
    }
    
    sort(y, y + n);
    float middle = ((float)y[n / 2 - 1] + y[n / 2]) / 2;
    
    for(i = 0; i < n; i++){
        if(x[i] < middle){
            cout << y[n / 2] << endl;
        }else{
            cout << y[n / 2 - 1] << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main(void){
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        if(m == -1 || f == -1) cout << "F" << endl;
        else if(m+f >= 80) cout << "A" << endl;
        else if(m+f >= 65) cout << "B" << endl;
        else if(m+f >= 50) cout << "C" << endl;
        else if(m+f >= 30 && r >= 50) cout << "C" << endl;
        else if(m+f >= 30) cout << "D" << endl;
        else cout << "F" << endl;
    }
    return 0;
}


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

int main()
{	
	int n;
	cin >> n;
	int build[n] = {};

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

	int count =0;
	for(int i=0; i<n ;i++){
		int mini = i;
		for(int j=i;j<n;j++){
			if(build[mini] > build[j])
				mini = j;
		}
		if(build[mini] != build[i]){
			swap(build[mini],build[i]);
			count++;
		}
			
	}
	

	for(int i=0;i<n;i++) cout << build[i] << " \n"[i==n-1];
	cout << count << endl;


    return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, a[60], b[60];
int main()
{
    IO
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            for(int k=0; k<n; k++)
                b[k]=a[k];
            swap(b[i],b[j]);
            if(is_sorted(b,b+n))
                return cout<<"YES", 0;

        }
    cout<<"NO";
}


Measured memory_bytes: 256
//15DTG
//16072020
#include<bits/stdc++.h>
using namespace std;
#define bolt ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef long double ld;
const ld pi=3.1415926535897932384626433;
const int mod = 1e9+7;
int main()
{
   bolt;
   ll n,k;
   cin>>n>>k;
   vector <ll> a(n);
   for (ll i=0;i<n;i++)
   {
      cin>>a[i];
   }
   ll s=0;
   sort(a.begin(),a.end());
   for (ll i=0;i<k;i++)
   {
      s+=a[i];
   }
   cout<<s;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>	
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n+1,0);
  for(int i=1;i <= sqrt(n);i ++){
    for(int j=1;j <= i;j ++){
      for(int k=1;k <= j;k ++){
        if(i*i+j*j+k*k + i*j +j*k + k*i <= n && i*i+j*j+k*k + i*j +j*k + k*i > 0){
          if(i!=j&&i!=k&&j!=k){
            a.at(i*i+j*j+k*k + i*j +j*k + k*i)=a.at(i*i+j*j+k*k + i*j +j*k + k*i)+6;
          }
          else if(i==j&&i!=k || j==k &&i!=j){
            a.at(i*i+j*j+k*k + i*j +j*k + k*i) = a.at(i*i+j*j+k*k + i*j +j*k + k*i)+3;
          }
          else if(i == j&&i == k){
            a.at(i*i+j*j+k*k + i*j +j*k + k*i)++;
          }
        }
      }
    }
  }
  for(int i=0;i < n;i++){
    cout<<a.at(i+1)<< endl;
  }
}

Measured memory_bytes: 3556
N, W = map(int, input().split())
dp = [[0]*(W+1) for _ in range(N)]
w, v = [0]*N, [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())
for i in range(N):
    for k in range(1,W+1):
        if w[i] <= k:
            dp[i][k] = max(dp[i-1][k-w[i]]+v[i],dp[i-1][k])
        else:
            dp[i][k] = dp[i-1][k]
print(dp[N-1][W])

Measured memory_bytes: 120044
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n;
    cin>>n;
    Vi a(n);
    REP(i,0,n) cin>>a[i];

    Vi count(n);
    REP(i,0,n) count[a[i]]++;
    REP(i,1,n+1){
        if(i==n){ if(count[0]!=n%2) {cout<<0<<endl; return 0;}}
        else if(i%2==1){ if(count[n-i]!=2) {cout<<0<<endl; return 0;}}
        else if(i%2==0){ if(count[n-i]!=0) {cout<<0<<endl; return 0;} }
    }
    cout<<mypow(2,n/2,MOD)<<endl;
    return 0;
}

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

int main(){
    int N;
    cin>>N;
    vector<int> W(N);
    for(int i=0;i<N;i++){
        cin>>W.at(i);
    }

    int S1=0;
    for(int i=0;i<N;i++){
        S1+=W.at(i);
    }
    int ans=S1,S2=0;
    for(int i=N-1;i>0;i--){
        S1-=W.at(i);
        S2+=W.at(i);
        if(ans>abs(S1-S2)) ans=abs(S1-S2);
    }
    cout<<ans<<endl;
}

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

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

int main(){
    ll n,m;
    cin >> n >> m;
    if(n%2){
        int cnt=0;
        for(int l=1, r=n-1; l<r; l++, r--){
            cout << l << ' ' << r << endl;
            cnt++;
            if(cnt==m) break;
        }
    }else{
        bool flag = false;
        int cnt=0;
        for(int l=1, r=n-1; l<r; l++, r--){
            if(!flag && r-l<=n/2){
                --r;
                flag = true;
            }
            cout << l << ' ' << r << endl;
            cnt++;
            if(cnt==m) break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632