akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

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

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

constexpr ll mod = 998244353;
ll myp(ll a, ll n) {
  if (n == 0)return 1;
  ll d = myp(a, n / 2);
  if (n & 1)return a * d % mod * d % mod;
  return d * d % mod;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi v(n);
  REP(i, n)cin >> v[i];
  map<int, int> cnt;

  REP(i, n)cnt[v[i]]++;
  if (v[0] != 0 || cnt[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  {
    auto c = cnt.end();
    c--;
    if ((*c).first != cnt.size() - 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  
  int pre = 1;
  ll ans = 1;
  for (auto a : cnt) {
    if (a.first == 0)continue;
    ans *= myp(pre, a.second);
    pre = a.second;
    ans %= mod;
  }
  cout << ans << endl;
  

}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(int i =a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;

string s,t;
int dp[3001][3001] = {{0}};

signed main()
{
	//FILEIO
 	start_routine
	
	cin>>s>>t;
	fr(i,1,s.size() + 1)
	{
		fr(j,1,t.size() + 1)
		{
			if(s[i - 1] == t[j - 1])
			{
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}	
	}

	int i = s.size(), j = t.size();
	string ans;
	while(i > 0 && j > 0)
	{
		if(max(dp[i - 1][j], dp[i][j - 1]) <= dp[i - 1][j - 1] && dp[i][j] == dp[i - 1][j - 1 ]+ 1) {ans += s[i - 1]; i--,j--; continue;}
		if(dp[i - 1][j] > dp[i][j - 1]) i--;
		else j--;
	}

	reverse(ans.begin(), ans.end());
	cout<<ans;
	 end_routine
}

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

using namespace std;
long long i,n,a[1000001],dem,ln;


int main()
{
   cin>>n;
   for(i=1;i<=n;i++)
	cin>>a[i];
	dem=1;ln=1;
	for(i=n;i>=2;i--)
	{
		if(a[i]<=a[i-1])
		{
			dem=dem+1;
			if(ln<dem)
				ln=dem;
		}
		else
			dem=1;
	}
	cout<<ln-1;

}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
int a[N];
int b[N];
int main(void)
{
    int n;
    cin>>n;
    for (int i = 1;i <= n;++i)
        cin>>a[i];
    for (int i = 1;i <= n;++i)
        cin>>b[i];
    ll cnt = 0;
    for (int i = 1;i <= n;++i)
    if (a[i] < b[i])
    {
        ll g = b[i] - a[i] + 1;
        g /= 2;
        cnt += g;
        a[i] += 2 * g;
    }
    for (int i = 1;i <= n;++i)
        if (b[i] < a[i])
        {
            if (a[i] - b[i] <= cnt)
                cnt -= a[i] - b[i];
            else
                return puts("No") * 0;
        }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  int i = 0;
  int p = 0;
  while (i < N) {
    int l, r;
    cin>>l>>r;
    p += r - l + 1;
    i++;
  }
  cout<<p<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int N;
int K;
long long arr[100123];
long long memo[100123];
 
long long solve(int n) {
  if (n == N - 1) return 0;
  if (memo[n] != -1) return memo[n];
  long long best = abs(arr[n] - arr[n+1]) + solve(n + 1);
  for (int j = n + 2; j <= min(N - 1, n + K); ++j) {
    best = min(best, abs(arr[n] - arr[j]) + solve(j));
  }
  return memo[n] = best;
}
int main() {
  ios_base::sync_with_stdio(false);
  memset(memo, -1, sizeof memo);
  cin >> N >> K;
  for (int i = 0; i < N; ++i) cin >> arr[i];
  
  long long ans = solve(0);
  cout << ans << '\n';
}


Measured memory_bytes: 6528
import heapq
import sys
input = sys.stdin.readline

l = -10**9-1
r = 10**9 + 1
ll = []
rl = []
ls = l
rs = r
bs = 0
ans = 0
Q = int(input())
for i in range(Q):
    t = input()
    if t == "2\n":
        print("{} {}".format(l, -((ls-rs+2*10**9+2)//2)+bs))
    else:
        _, a, b = (int(i) for i in t.split())
        bs += b
        if a < l:
            heapq.heappush(rl, r)
            ls -= l
            rs += l
            r = l
            heapq.heappush(ll, -a)
            heapq.heappush(ll, -a)
            ls += 2*a
            l = -heapq.heappop(ll)
        elif a > r:
            heapq.heappush(ll, -l)
            rs -= r
            ls += r
            l = r
            heapq.heappush(rl, a)
            heapq.heappush(rl, a)
            rs += 2*a
            r = heapq.heappop(rl)
        else:
            heapq.heappush(ll, -l)
            heapq.heappush(rl, r)
            ls += a
            rs += a
            l = a
            r = a

Measured memory_bytes: 89304
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define mp           make_pair
#define int          long long
#define uint         unsigned long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define vs           vector<string>
#define pi           pair<int,int>
#define di           deque<int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define noob         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
    char ch;
    cin>>ch;
    if(ch>='a'&&ch<='z')
    {
        cout<<"a";return;
    }
    cout<<"A";
}

signed main()
{
        noob
        // #ifndef ONLINE_JUDGE
        //  freopen("input.txt","r",stdin);
        //  freopen("output.txt","w",stdout);
        //  #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

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

int main(void) {
	long long A, B, K;
	cin >> A >> B >> K;
	
	if (K >= A) {
		K -= A;
		A = 0;
	} else {
		A -= K;
		K = 0;
	}

	B -= K;
	if (B < 0) B = 0;

	cout << A << " " << B << endl;
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<bitset<30>> A(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        A[i]=bitset<30> (a[i]);
    }
    bitset<30> total(0);
    for(int i=0;i<n;i++){
        total^=A[i];
        
    }
    for(int i=0;i<n;i++){
        if(i) cout<<' ';
        bitset<30> ans=total;
        ans^=A[i];
        cout<<ans.to_ullong();
    }
    cout<<endl;
}

Measured memory_bytes: 5540
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};
  
/* ----------------------------------------------------------------------------------- */


void solve() {
	int x;
	cin >> x;
	int n = (x / 500);
	int red = (x % 500);
	int res = (red / 5.00);
	int result = ((n * 1000) + (res * 5));
	cout << result << endl;
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    int a,b;
    cin >> a>> b;
    if(a>b*2){
        cout<<a-2*b<<endl;
    }else{
        cout<<0<<endl;
    }
    
    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    for(int i = 0; i < M; i ++){
        cin >> L.at(i) >> R.at(i);
    }
    int min = L.at(0);
    int max = R.at(0);
    for(int i = 0; i < M; i ++){
        min = (min >= L.at(i)) ? min : L.at(i);
        max = (max >= R.at(i)) ? R.at(i) : max;
    }
    if(max >= min){
        cout << (max - min + 1) << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
long long int gcd(long long int x,long long int y)
{ if(!y)return x;
  return gcd(y,x%y);

}
int main()
{   long long int a,b;
scanf("%lld %lld",&a,&b);
printf("%lld",a*b/gcd(a,b));

    return 0;
}


Measured memory_bytes: 128
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

void speed_solve(){
    ll n, x, m;
    cin >> n >> x >> m;
    ll freq[m + 1];
    init(freq, 0);
    ll cnt = 0, sum = 0;
    ll freq2[m + 1];
    init(freq2, 0);
    while(true) {
        if(freq[x]) {
            if(freq2[x]) {
                break;
            }
            freq2[x]++;
        } else {
            freq[x]++;
            sum += x;
            cnt++;
            if(cnt == n) {
                break;
            }
        }
        x = ((x % m) * (x % m)) % m;
    }
    if(cnt == n) {
        cout << sum;
        return;
    }
    ll repeatSum = 0, len = 0;
    for(ll i = 0 ; i < m ; i++) {
        if(freq2[i]) {
            len++;
            repeatSum += i;
        }
    }
    ll ans = sum + repeatSum * ((n - cnt) / len);
    ll rem = ((n - cnt) % len);
    while(rem > 0) {
        ans += x;
        x = ((x % m) * (x % m)) % m;
        rem--;
    }
    cout << ans;
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

bool check(int n) {
	for (int i=2; i*i <= n; i++){
		if (n%i==0) return false;
	}
	return true;
}

int main(int, char**) {
	int x; cin >> x;
	while (true) {
		if (check(x)) {
			cout << x << endl;
			return 0;
		}
		x++;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
#define LSG(S,F) S::value_type,S::op,S::e,F::value_type,F::mapping,F::composition,F::id //S: 取得 F: 更新
#define SG(S) S::value_type, S::op, S::e

template<class T> class RMinQ { public:
	using value_type = T;
	static T op(T l, T r) {return min(l, r);}
	static T e(){return (T)1e9;}
};
template<class T> class RMaxQ { public:
using value_type = T;
	static T op(T l, T r){ return max(l, r); }
	static T e(){return (T)-1e9;}
};
template<class T> class RSumQ { public:
	static T op(T l, T r){ return l + r; }
	static T e(){return T(0);}
};



int main()
{
	int n, q; cin >> n >> q;
	vector<int> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	atcoder::segtree<SG(RMaxQ<int>)> tree(a);

	for(int i = 0; i < q; i++) {
		int t; cin >> t;
		if(t == 1) {
			int x, y; cin >> x >> y; x--;
			tree.set(x, y);
		}
		if(t == 2) {
			int l, r; cin >> l >> r;
			cout << tree.prod(l - 1, r) << endl;
		}
		if(t == 3) {
			int x, v; cin >> x >> v;
			x--;
			cout << tree.max_right(x, [&](int prod) {return prod < v;}) + 1 << endl;
		}
	}
	

}

Measured memory_bytes: 6136
///Bismillahir Rahmanir Rahim
#define ll long long
#define scf1(a)  scanf("%lld",&a);
#define scf2(a,b)  scanf("%lld %lld",&a,&b)
#define pf    printf
#define pb    push_back
#define rsrt(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define ff first
#define ss second
#define spd ios_base::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ll a,b;
     cin>>a>>b;
     if(a<=9&&b<=9)
        cout<<a*b<<endl;
     else
        cout<<-1<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

var (
	n  int
	hs [][3]int
	dp [][3]int
)

func main() {
	fmt.Scan(&n)
	hs = make([][3]int, n)
	for i := range hs {
		fmt.Scan(&hs[i][0], &hs[i][1], &hs[i][2])
	}

	dp = make([][3]int, n+1)
	for i := range hs {
		chmax(&dp[i+1][0], dp[i][1]+hs[i][0])
		chmax(&dp[i+1][0], dp[i][2]+hs[i][0])
		chmax(&dp[i+1][1], dp[i][0]+hs[i][1])
		chmax(&dp[i+1][1], dp[i][2]+hs[i][1])
		chmax(&dp[i+1][2], dp[i][0]+hs[i][2])
		chmax(&dp[i+1][2], dp[i][1]+hs[i][2])
	}

	m := max(dp[n][0], dp[n][1], dp[n][2])
	fmt.Println(m)
}

func chmax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func max(as ...int) int {
	max := as[0]
	for _, a := range as {
		if a > max {
			max = a
		}
	}
	return max
}


Measured memory_bytes: 8192
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 998244353
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

int n, w;
pii arr[100];
ll dp[100][100001];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d %d", &n, &w);
	for (int i = 0; i < n; i++) scanf("%d %d", &arr[i].first, &arr[i].second);
	dp[0][arr[0].first] = arr[0].second;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= w; j++) dp[i][j] = dp[i - 1][j];
		for (int j = 0; j <= w - arr[i].first; j++) {
			dp[i][j + arr[i].first] = max(dp[i][j + arr[i].first], 
				dp[i - 1][j] + arr[i].second);
		}
	}
	ll ans = -INF;
	for (int i = 0; i <= w; i++) ans = max(ans, dp[n - 1][i]);
	cout << ans << endl;
	return 0;
}

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

int main(){
	int N;
	long K;
	cin>>N>>K;
	map<int,long>num;
	vector<int>arr;
	int a,b;
	for(int i=0;i<N;++i){
		cin>>a>>b;
		if(num[a]==0)arr.push_back(a);
		num[a]+=b;
	}
	/*
	for(int i=0;i<arr.size();++i){
		cout<<arr[i]<<endl;
	}
	*/
	sort(arr.begin(),arr.end());
	long k=0;
	int ans;
	for(int i=0;i<N;++i){
		//cout<<k<<endl;
		if(k+num[arr[i]]>=K){
			ans=arr[i];
			break;
		}
		k+=num[arr[i]];
	}
	cout<<ans<<endl;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;


#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  LL mh, ma, md, ms; cin >> mh >> ma >> md >> ms;
  vector<PLL> en;
  LL dsum = 0;
  REP(i,N){
	LL h, a, d, s; cin >> h >> a >> d >> s;
	if(ma <= d){
	  if(a-md > 0){
		cout << -1 << endl;
		return 0;
	  }
	  continue;
	}
	en.EB((h - 1) / (ma - d) + 1, max(0LL,a-md));
	if(s < ms) dsum -= en.back().SS;
  }

  N = SZ(en);
  sort(ALL(en), [](PLL& p1, PLL& p2){
	  return p1.FF*p2.SS < p1.SS*p2.FF;
	});

  LL tsum = 0;
  for(int i=0;i<N;++i){
	tsum += en[i].FF;
	dsum += tsum * en[i].SS;
	if(dsum >= mh) break;
  }
  cout << (dsum >= mh? -1: dsum) << endl;
  
  return 0;
}

Measured memory_bytes: 3880
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll ans;
    ans = min(n%k, abs(n%k - k));
    if(k==1) ans = 0;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <bitset>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
using ppp = pair<pair<int, int>, pair<int, int>>;
#define MOD 1000000007
#define INF 1LL << 59
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int S[200010], T[200010], X[200010];

int D[200010];

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    if (s[0] == s[n - 1])
    {
        if (n % 2 == 1)
        {
            cout << "Second" << endl;
        }
        else
        {
            cout << "First" << endl;
        }
    }
    else
    {
        if (n % 2 == 1)
        {
            cout << "First" << endl;
        }
        else
        {
            cout << "Second" << endl;
        }
    }

    return 0;
}

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

int main() {
	int N, a[100000];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
	if (a[0] == a[N - 1]) {
		if (a[0] == N - 1 || a[0] * 2 <= N) cout << "Yes";
		else cout << "No";
	}
	else if (a[N - 1] - a[0] == 1) {
		int X = 0, Y = 0;
		for (int i = 0; i < N; i++) {
			if (a[i] == a[0]) X++;
			else Y++;
		}
		if (X < a[N - 1] && 2 * (a[N - 1] - X) <= Y) cout << "Yes";
		else cout << "No";
	}
	else cout << "No";
}

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

using namespace std;

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

	string t;
	cin >> t;
  
	string ans = t;
	for (int i = 0; i < t.length(); i++) {
		if (ans[i] == '?') {
			if (i != 0 && ans[i - 1] == 'P') {
				ans[i] = 'D';
			}
			else if (i != t.length() && (ans[i + 1] == 'D' || ans[i + 1] == '?')) {
				ans[i] = 'P';
			}
			else {
				ans[i] = 'D';
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;

#define N 200
#define MAX 2000000

typedef long long ll;

int main(){
	char com[20];
	priority_queue<int>PQ;
	
	while(1){
		scanf("%s",com);
		if(com[0]=='i'){
			int key;
			scanf("%d",&key);
			PQ.push(key);
		}
		else if(com[1]=='x'){
			cout<<PQ.top()<<endl;
			PQ.pop();
		}
		else if(com[0]=='e'){
			break;
		}
	}
	return 0;
}




Measured memory_bytes: 6920
var
        i,d,n:byte;
        s:string;
begin
        readln(n);
        read(s);
        if n mod 2 <>0 then begin write('No'); exit; end else
        for i:=1 to n div 2 do if s[i]=s[i+(n div 2)] then inc(d);
        if d=n div 2 then write('Yes') else write('No');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int pre[300005];
int suf[300005];
int32_t main(){
	int n;
	string s;
	cin>>n;
	cin>>s;
	for(int i=1;i<=n;i++){
		pre[i]=pre[i-1]+(s[i-1]=='W');
	}
	for(int i=n;i>=1;i--){
		suf[i]=suf[i+1]+(s[i-1]=='E');
	}
	/*for(int i=1;i<=n;i++){
		cout<<pre[i]<<" "<<suf[i]<<"\n";
	}*/
	int ans = 1e9;
	for(int i=1;i<=n;i++){
		ans = min(ans,pre[i-1]+suf[i+1]);
	}
	cout<<ans;
}


Measured memory_bytes: 5380
#include<stdio.h>
 
int main(){
	int i,j;
	int n,a,b,c,x;
	int y[100];
 
	while(scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n){
		for(i = 0;i < n;i++){
			scanf("%d",&y[i]);
		}

		for(i = 0,j = 0;i < 10001;i++){
			if(x == y[j]){
				j++;
			}
			if(n == j)break;
			x = (a * x + b) % c;
		}
		if(i == 10001)i = -1;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
int main(void) {
    int a,b;
    while (scanf("%d %d",&a,&b)!=EOF) {
        while (1) {
            if (a>b) {
                a%=b;
                if (a==0) {
                    printf("%d\n",b);
                    break;
                }
            } else {
                b%=a;
                if (b==0) {
                    printf("%d\n",a);
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    Graph G(N);
    rep(i,0,M){
        int a,b; cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> ans(N+1);
    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            ans[nv+1] = v+1;
            que.push(nv);
        }
    }
    
    cout << "Yes" << endl;
    reps(i,2,N){
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 10652
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>

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

using namespace std;

int main() {
	int N;
	scanf("%d", &N);

	// 現在の場所
	int now_t = 0, now_x = 0, now_y = 0;
	// 次に行く場所
	int t, x, y;

	REP(i, N) {
		scanf("%d %d %d", &t, &x, &y);

		// まず最低限必要な時間
		int rest_t = t - now_t - (abs(x - now_x) + abs(y - now_y));
		if (rest_t < 0 || rest_t % 2 == 1) {
			printf("No\n");
			return 0;
		}

		// 更新
		now_t = t;
		now_x = x;
		now_y = y;
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

const int mx = 100005;
int dp[6][mx];

int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << static_cast<int>(m1!=m2) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();

		int ans = 0;
		for(int i=0; i<s.length/2; i++) {
			if(s[i]!=s[s.length-i-1])
				ans++;
		}
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    cout<<N/3<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int S(int n) {
  string s = to_string(n);
  int sum = 0;
  for (auto e : s) sum += e - '0';
  return sum;
}

int main() {
  Cin(int, n);

  puts(n % S(n) == 0 ? "Yes" : "No");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    int a[n];
    map<int, int> mp;
    rep (i, 0, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    int cnt = 0;
    rep (i, 0, n) {
        bool chk = 0;
        for (int j = 1; j * j <= a[i]; j++) {
            if (j == 1) {
                if (a[i] != 1) {
                    if (mp[a[i]] == 1) {
                        if (mp[1] > 0) {
                            chk = 1;
                            break;
                        }
                    } else {
                        chk = 1;
                        break;
                    }
                } else {
                    if (mp[a[i]] > 1) {
                        chk = 1;
                        break;
                    }
                }
            } else if (a[i] % j == 0) {
                if (mp[j] > 0) {
                    chk = 1;
                    break;
                } else if (mp[a[i] / j] > 0) {
                    chk = 1;
                    break;
                }
            }
        }
        if (!chk) cnt++;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 33260
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


vector<ll> alph[26];

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

    rep(i, s.size()){
        int p = s[i] - 'a';
        alph[p].push_back(i);
    }
    ll num = 0;
    ll now = 0;

    rep(i, t.size()){
        ll c = t[i] - 'a';
        if (alph[c].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        ll len = alph[c].size();
        ll idx_last = distance(alph[c].begin(), lower_bound(alph[c].begin(), alph[c].end(), now));
        
        if (idx_last == len) {
            now = alph[c][0] + 1, num++;
        }
        else now = alph[c][idx_last] + 1;
        // cout << t[i] << ", idx=" << idx_last << ", len=" << len <<  endl;
        // cout << "now=" << now << " num=" << num << endl;
    }
    cout << num * ll(s.size()) + now << endl;
    return 0;
}

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

int main(){
  int n,i,j,x,y,h,w,s,mo;
  int c[6]={60,80,100,120,140,160};
  int b[6]={2,5,10,15,20,25};
  int m[6]={600,800,1000,1200,1400,1600};

  while(cin>>n,n!=0){
    mo=0;
    for(i=0;i<n;i++){
      cin>>x>>y>>h>>w;
      s=x+y+h;
      if(s>c[5]||w>b[5])continue;
      for(j=0;j<6;j++){
	if(s<=c[j]&&w<=b[j]){mo+=m[j];break;}
      }
    }
    cout<<mo<<endl;  
}
return 0;
}

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

struct Node{
  int key;
  Node *next, *prev;
};

Node *nill;

Node *listSearch(int key) {
  Node *cur = nill->next;
  while(cur != nill && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nill = (Node *)malloc(sizeof(Node));
  nill->next = nill;
  nill->prev = nill;
}

void printList(){
  Node *cur = nill->next;
  int isf = 0;
  while(1){
    if(cur == nill) break;
    if(isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if (t == nill) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nill->next);
}

void deleteLast(){
  deleteNode(nill->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nill->next;
  nill->next->prev = x;
  nill->next = x;
  x->prev = nill;
}

int main(){
  int key,n,i;
  char com[20];


  scanf("%d", &n);
  init();
  for(i=0;i<n;++i){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){insert(key);}
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F') deleteFirst();
        else if(com[6] == 'L') deleteLast();
      }else{
        deleteKey(key);
      }
    }
  }
printList();
return 0;

}



Measured memory_bytes: 34456
def mod_inv(value):
    b = mod
    u = 1
    v = 0
    while b:
        t = value // b
        value -= t * b
        b, value = value, b
        u -= t * v
        v, u = u, v
    u %= mod
    if u < 0:
        u += mod
    return u

def calcFact():
    fact[0] = 1
    fact_inv[0] = 1
    for i in range(1, 2010):
        fact[i] = i * fact[i - 1]
        fact[i] %= mod
        fact_inv[i] = mod_inv(fact[i])
    return

def comb(n, r):
    if r == 0:
        return 1
    return fact[n] * fact_inv[r] % mod * fact_inv[n - r] % mod

fact = [0 for i in range(2020)]
fact_inv = [0 for i in range(2020)]

mod = 1000000007

N, K = map(int, input().split())
calcFact()

for i in range(1, K + 1):
    if N - K + 1 < i:
        print(0)
        continue
    ans = comb(K - 1, i - 1) * comb(N - K + 1, i) % mod
    print(ans)
    


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

using namespace std;

int main()
{
	int N, T, A;
	cin >> N >> T >> A;

	int h, index;
	double sub = pow(10, 9);
	for (int i = 0; i < N; i++)
	{
		cin >> h;

		double point = abs((double)T - h * 0.006 - A);
		
		if (sub > point)
		{
			sub = point;
			index = i + 1;
		}
	}

	cout << index<< endl;

	return 0;
}


Measured memory_bytes: 256
def insertion_sort(array, num):
    print(" ".join(map(str, array)))
    for i in range(1, num):
        right_val = array[i]
        j = i - 1
        while j >= 0 and array[j] > right_val:
            array[j + 1] = array[j]
            j = j - 1
        array[j + 1] = right_val
        print(" ".join(map(str, array)))


def main():
    num = int(input())
    array = input()
    array = list(map(int, array.split()))
    insertion_sort(array, num)
    # insertion_sort([5, 2, 4, 6, 1, 3], 6)


if __name__ == "__main__":
    main()



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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int a,b,c;cin>>a>>b>>c;

    if((a==b && a!=c) || (a==c && a!=b) || (b==c && a!=c))cout<<"Yes\n";
    else cout<<"No\n";

    return 0;

}

Measured memory_bytes: 256
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p,x=[],[]
for _ in range(m):
  _p,_x=map(int,input().split())
  p.append(_p-1)
  x.append(_x)
s=sum(t)
for i in range(m):
  print(s-t[p[i]]+x[i])


Measured memory_bytes: 3060
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a > b) {
            System.out.println(a-1);
		}
        else {
            System.out.println(a);
        }
	}
}

Measured memory_bytes: 21972
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    val n = scan.nextInt()
    val a = Array(n){LongArray(n){scan.nextLong()}}
    val scores = LongArray(1.shl(n))
    for (mask in 0 until 1.shl(n)) {
        var ret = 0L
        for (i in 0 until n) {
            for (j in i+1 until n) {
                if (mask.shr(i) and 1 == 1 && mask.shr(j) and 1 == 1)
                    ret += a[i][j]
            }
        }
        scores[mask] = ret
    }

    val dp = LongArray(1.shl(n)){ (-1L).shl(60) }
    dp[0] = 0
    for (mask in 0 until 1.shl(n)) {
        for (sub in bitSubsetsOfSubset(mask)) {
            dp[mask] = Math.max(dp[mask], dp[sub] + scores[mask - sub])
        }
    }
    println(dp[1.shl(n)-1])
}

fun bitSubsetsOfSubset(sup: Int): MutableList<Int> {
    val ret = mutableListOf<Int>()
    var sub = sup
    while (true) {
        ret.add(sub)
        if (sub == 0) {
            break
        }
        sub = (sub - 1) and sup
    }
    return ret
}


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

using ll = long long;
ll n;
std::vector<int> vec;
std::string s;

int main() {
    int a, z;
    std::cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') {
            a = i;
            break;
        }
    }
    for (int i = s.size()-1; i >= 0; i--) {
        if (s[i] == 'Z') {
            z = i;
            break;
        }
    }
    std::cout << (z-a+1) << std::endl;
}

Measured memory_bytes: 640
n,x = list(map(int,input().split()))
a = list(map(int,input().split()))
a = sorted(a)

if sum(a) == x:
    print(n)
elif sum(a) > x:
    num = 0
    for i,ax in enumerate(a):
        num += ax
        if num > x:
            print(i)
            exit()
else:
    print(n-1)


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;
const ll e18 = 1e18;

ll pow_mod(ll x, ll n, int M) {
	ll ans = 1;
	for (; n; n>>=1) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
	}
	return ans;
}

int f(ll x) {
	return x ? 1 + f(x / 10) : 0;
}

int main() {
	ll S; cin >> S;
	ll ans = 0;
	ll r = 1, s = 0;
	for (ll l = 1; l < 10000000; s -= f(l++)) {
		for (; s < S; s += f(r++));
		if (s == S) ans++;
	}
	for (ll k = 8; k * 2 <= S; k++) {
		ll lb = S % k;
		if (!lb) lb = k;
		if (lb > (S - k) / (k + 1)) continue;
		ans += ((S - k) / (k + 1) - lb) / k + 1;
		if (ans >= MOD) ans -= MOD;
	}
	ans %= MOD;
	vector<ll> ks;
	for (ll k = 1; k * k <= S; k++) if (S % k == 0) {
		ks.pb(k);
		if (S / k != k) ks.pb(S / k);
	}
	for (ll k: ks) if (k >= 8)
		ans = (ans + pow_mod(10, k - 1, MOD) * 9 - S / k + 1) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;


int main()
{
   int n,i,j; cin>>n;
   int res=0,c;
   for(i=1;i<=n;i+=2)
   {
       c=0;
       for(j=1;j<=i;j++)
       {
           if(i%j==0) c++;
       }
       if(c==8) res++;
   }
   cout<<res;
}


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

int main() {
    int n;
    cin >> n;
    int *a = new int[n];
    int *b = new int[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    for (int i=0; i<n; i++) {
        cin >> b[i];
    }
    int x = 0;

    for (int i=0; i<n; i++) {
        if (a[i]>b[i]){
            x += a[i] - b[i];
        }
    }
    

    cout << x << endl;
    
    return 0;
}

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

int main(){
  long long n,k;
  cin >> n >> k;
  long long ans=0;
  while(k<=n+1){
    ans=(ans+(k*(n-k+1)+1))%1000000007;
    k++;
  }
  cout << ans << endl;
  return 0;
}  


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

int main(void) {
    int N;
    cin>>N;
    int count = 0;
    for(int i = 0; i < N; ++i) {
        int p;
        cin>>p;
        if(p != i +1) {
            ++count;
        }
    }
    if(count == 2 || count == 0) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
string s;
int num[100004];
int main(){
	int n,q;cin>>n>>q;
	cin>>s;
	for (int i=1;i<n;i++){
		num[i+1]=num[i];
		if (s[i]=='C' && s[i-1]=='A') num[i+1]++;
	}
	while (q--){
		int x,y;
		cin>>x>>y;
		cout<<num[y]-num[x]<<"\n";
	}
}

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

#define lli long long int
#define pb push_back
#define pii pair <int, int>
#define pll pair <lli, lli>
#define _F first
#define _S second
#define mset(x) memset(x, 0, sizeof(x))
#define fastio() ios_base::sync_with_stdio(0); cin.tie(NULL)

using namespace std;

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

	int A[2][n + 1];
	mset(A);

	while(m--)
	{
		int x, y;
		cin >> x >> y;

		if(x == 1)
			A[0][y] = 1;

		if(y == n)
			A[1][x] = 1;
	}

	for(int i = 0; i < n; i++)
		if(A[0][i] and A[1][i])
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}

	cout << "IMPOSSIBLE" << endl;
	
	return (0-0);	
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<string>

using namespace std;
#define INF 1000000
typedef long long int ll;
typedef pair<ll,ll> mypair;
int main(){
	ll n;
	cin>>n;
	vector<ll > p(n+1,INF);
	vector<mypair> inc(n+1);
	for(ll i=1;i<=n;i++){
		cin>>p[i];
		inc[i]=mypair(0,i);
//		dec[i]=mypair(0,n+1);
	}
//	cout<<"ok"<<endl;
	ll t=0;
	ll ans=0;
	ll now=n;
	for(ll i=1;i<=n;i++){
	/*	for(ll j=1;j<=n;j++){
			if(p[i]==inc[j].second){
				inc[j].second++;
				inc[j].first++;
			}
		}*/
		inc[p[i]].first=inc[p[i]-1].first+1;
	}
	for(int i=1;i<=n;i++){
		ans=max(ans,inc[i].first);
//	cout<<inc[i].first<<endl;
	}	
	/*for(ll i=1;i<=n;i++){
		if(p[i]==now){
		now++;
		t++;
		}
	}*/
//	ans=max(t,ans);
	ans=n-ans;
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;

int n, m;
int a[maxn];
ll ans;
multiset < int > s;
int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        s.insert(a[i]);
    }
    for(int i = 1; i <= m; i++){
        int h = *s.rbegin();
        s.erase(s.find(h));
        s.insert(h / 2);
    }
    for(int i : s){
        ans += i;
    }
    cout << ans;
}


Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

class Program
{
    static void Main(string[] args)
    {
        label:
        var sp = ReadLine().Split();
        int left = Parse(sp[0]);
        int right = Parse(sp[1]);
        int diff = right - left;
        WriteLine((diff * (diff + 1)) / 2 - right);
        //goto label;
    }
}


Measured memory_bytes: 11092