akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KyouProg
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] INPUT = Console.ReadLine().Split(' ');
            var A = new List<int>();
            int[] Score = new int[int.Parse(INPUT[0])];
            int i;

            for (i = 0; i < int.Parse(INPUT[2]); i++)
            {
                A.Add(int.Parse(Console.ReadLine()));
            }
            
            for (i = 0; i < int.Parse(INPUT[0]); i++)
            {
                Score[i] = int.Parse(INPUT[1])-int.Parse(INPUT[2]);
            }

            for (i = 0; i < int.Parse(INPUT[2]); i++)
            {
                Score[A[i]-1] += 1;
            }

            for (i = 0; i < int.Parse(INPUT[0]); i++)
            {
                if (Score[i] <= 0) Console.WriteLine("No");
                else Console.WriteLine("Yes");
            }


        }
    }
}


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

int main(){

        int n;
        cin>>n;
        long in;

        set<long>s;

        for(int i=0;i<n;i++){
            cin>>in;
            s.insert(in);
        }
       if(s.size()==n){
           cout<<"YES";
       }
       else cout <<"NO"; 


}

Measured memory_bytes: 9600
#include<stdio.h>
signed main(){
    int x,n,p[105];
    scanf("%d %d",&x,&n);
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int flag[105]={};
    int ans=0;
    for(i=0;i<n;i++){
        flag[p[i]]=1;
    }
    for(i=1;i<=101;i++){
        if(flag[i]==0){
            int abs1,abs2;
            abs1=x-ans;
            abs2=x-i;
            if(abs1<0){
                abs1=abs1*-1;
            }
            if(abs2<0){
                abs2=abs2*-1;
            }
            if(abs1>abs2){
                ans=i;
            }
        }
    }
    printf("%d\n",ans);
    return(0);
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_ARRAY 100
int main(void) {
	int n = 0, a[MAX_ARRAY];
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d",&a[i]);
	}
	for (int k = 0; k < n - 1; k++) {
		cout << a[k] << ' ';
	}
	cout << a[n - 1] << endl;


	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int k = 0; k < n-1; k++) {
			cout << a[k] << ' ';
		}
		cout << a[n-1] << endl;
	}


	return 0;
}

Measured memory_bytes: 3176
def bi(x):
    x = int(x)
    i = 0
    o = [0]*61
    while x > 0:
        o[i] = x % 2
        x //= 2
        i += 1
    return o

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

# print(*A,sep='\n')
ruijoo = 1
bbb = 0
B = [0]*N
h = 0
while h < 61:
    i = 0
    isOne = 0
    while i < N:
        aaaa = A[i][h]
        isOne += aaaa
        B[i] = aaaa
        i += 1
    isZero = N - isOne
    bbb += ruijoo * isZero * isOne
    bbb %= 1000000007
    ruijoo *= 2
    ruijoo %= 1000000007
    h += 1

bbb %= 1000000007
print(bbb)

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    if(N == 1)
    {
        cout << "Hello World" << endl;
        
    }
    else if(N == 2)
    {
        int A,B;
        cin >> A >> B;
        cout << A+B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define S size()
#define E end()
#define B begin()
#define L length()
 
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define fl float
#define ld long double
#define ll long long
 
#define gcd __gcd
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define all(v) v.B,v.E
#define acc(v) accumulate(all(v), 0)
#define psum partial_sum
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation
#define maxe *max_element
#define mine *min_element
 
#define forl(i,n) for(ll i = 0; i < n; i++)
#define fore(i,m,n) for (ll i = m; i <= n; i++)
#define rforl(i,n) for (ll i = n - 1; i >= 0; i--)
#define rfore(i,m,n) for (ll i = m; i >=n; i--)    
#define iter(s) for(auto it:s)
 
 
#define prec(n) fixed<<setprecision(n)
#define popcnt(n) __builtin_popcountll(n)
#define parity(n) __builtin_parityll(n)
#define clz(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctzll(n)
 
#define sll set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vll vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define msll multiset<ll>
#define msc multiset<char>
#define vvll vector<vector<ll>>
#define rev reverse
 
#define tc ll q;cin>>q;while(q--)
#define pat ll n;cin>>n;
#define pat1 vll a(n);forl(i,n)cin>>a[i];
#define pat2 ll n,k;cin>>n>>k;vll a;forl(i,n) cin>>a[i];
#define pats string s;cin>>s;
#define yesno if(flag)cout<<"YES\n";else cout<<"NO\n";
#define loop forl(i,n)
 
#define p0(a) cout << a << " ";
#define p1(a) cout << a << endl;
#define p2(a,b) cout << a << " " << b << endl;
#define p3(a,b,c) cout << a << " " << b << " " << c << endl;
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
 
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832
 
//**********************************
 
int main(){
    ll a;
    string b;
    cin>>a>>b;
    p1((a*(b[0]-'0')*100+a*(b[2]-'0')*10+a*(b[3]-'0'))/100)
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

const ll MOD = 998244353;

ll dp[200010];
pair<ll,ll> a[200010];
vector<pair<int,ll> > stek;
ll INF = 1e12;
bool sortiraj(pair<ll,ll> x1, pair<ll,ll> x2)
{
    return x1.fi < x2.fi;
}

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

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i].fi >> a[i].se;

    sort(a, a + n, sortiraj);
    dp[n] = 1;
    stek.pb(mp(n, INF));
    for(int i = n - 1; i >= 0; i--)
    {
        int index;
        while(stek[stek.size()-1].se < a[i].fi + a[i].se) stek.pop_back();
        index = stek[stek.size()-1].fi;
        dp[i] = (dp[i+1] + dp[index])%MOD;
        stek.pb(mp(i, a[i].fi));
    }
    cout << dp[0];

    return 0;
}


Measured memory_bytes: 7156
def main():
    L, *A = map(int, open(0))

    EO = [(2, 1), (1, 0), (0, 1)]

    dp = [0] * 5

    for a in A:
        e, o = EO[(a - 1) % 2 + 1 if a else 0]

        dp[0] += a
        dp[1] = min(dp[0], dp[1] + e)
        dp[2] = min(dp[1], dp[2] + o)
        dp[3] = min(dp[2], dp[3] + e)
        dp[4] = min(dp[3], dp[4] + a)

    print(min(dp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 11036
#include<bits/stdc++.h>
int gcd(int a, int b){
  if(a < b) return gcd(b, a);
  if(b == 0) return a;
  return gcd(b, a%b);
}

using namespace std;
int main(){
  int n;
  int a, g;
  cin >> n;
  cin >> g;
  for(int i=1;i<n;i++){
    cin >> a;
    g = gcd(a, g);
  }
  cout << g << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>

int main(){
	while(1){
		std::stack<char>Cstr;
		Cstr.push(' ');
		std::string str;
		int count=0;
		std::getline(std::cin,str);
		if(str==".")break;
		for(int i=0;i<str.size();i++){
			if(str[i]=='('||str[i]=='['){
				count++;
				Cstr.push(str[i]);
			}else if(str[i]==')'||str[i]==']'){
				count--;
				if(!((str[i]==')'&&Cstr.top()=='(')||(str[i]==']'&&Cstr.top()=='['))){
					std::cout<<"no"<<std::endl;
					goto end;
				}
				Cstr.pop();
			}
		}
		if(count==0)std::cout<<"yes"<<std::endl;
		else std::cout<<"no"<<std::endl;
		end:;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <set>

using namespace std;

void create_comb(vector<vector<long long>> &arr, int n, int m, vector<long long> arr_temp) {

	int i;

	if (int(arr_temp.size()) == n) {
		arr.push_back(arr_temp);
		return;
	}

	for (i = arr_temp[arr_temp.size() - 1]; i <= m; i++) {
		arr_temp.push_back(i);

		create_comb(arr, n, m, arr_temp);

		arr_temp.pop_back();
	}

	return;
}


int main(void) {
	int n, m, q;
	long long i, j, k;
	long long temp_a, temp_b, temp_c, temp_d;
	vector<long long> a, b, c, d;
	vector<vector<long long>> arr;
	vector<long long> arr_temp;
	long long max = 0;
	long long sum = 0;

	cin >> n >> m >> q;

	for (i = 0; i < q; i++) {
		cin >> temp_a >> temp_b >> temp_c >> temp_d;
		a.push_back(temp_a);
		b.push_back(temp_b);
		c.push_back(temp_c);
		d.push_back(temp_d);
	}

	arr_temp.push_back(1);
	create_comb(arr, n, m, arr_temp);

	for (i = 0; i < arr.size(); i++) {
		for (j = 0; j < q; j++) {
			if (arr[i][b[j] - 1] - arr[i][a[j] - 1] == c[j]) {
				sum += d[j];
			}
		}

		if (max < sum) {
			max = sum;
		}

		sum = 0;
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 9112
#include <iostream>
#include <stack>

std::string num_1, num_2;

void solver() {
    std::stack<char>ss_1, ss_2;
    std::stack<int> ss;
    bool flag=false;
    int tmp;
    for (int i=0; i<num_1.length(); i++) {
        ss_1.push(num_1[i]);
    }
    for (int j=0; j<num_2.length(); j++) {
        ss_2.push(num_2[j]);
    }

    while (!ss_1.empty() && !ss_2.empty()) {
        tmp = (ss_1.top() - '0') + (ss_2.top() - '0');
        ss_1.pop();
        ss_2.pop();

        if (flag) {
            tmp += 1;
        }
        ss.push(tmp % 10);

        flag = (tmp > 9) ? true:false;
    }
    if (ss_1.empty() && !ss_2.empty()) {
        while (!ss_2.empty()) {
            tmp = ss_2.top() - '0';
            if (flag) tmp += 1;

            ss.push(tmp % 10);
            ss_2.pop();
            flag = (tmp > 9) ? true:false;
        }
    } else if (ss_2.empty() && !ss_1.empty()) {
        while (!ss_1.empty()) {
            tmp = ss_1.top() - '0';
            if (flag) tmp += 1;

            ss.push(tmp % 10);
            ss_1.pop();
            flag = (tmp > 9) ? true:false;
        }
    }
    if (flag) ss.push(1);
    if (ss.size() > 80) {
        std::cout << "overflow" << std::endl;
    } else {
        while (!ss.empty()) {
            std::cout << ss.top();
            ss.pop();
        }
        std::cout << std::endl;
    }
}

int main(void) {
    int n;

    std::cin >> n;

    for (int i=0; i<n; i++) {
        std::cin >> num_1;
        std::cin >> num_2;
        solver();
    }

    return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> X >> A >> B;
	cout << (X - A) % B << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();

		if( Character.isUpperCase( N.charAt( 0 ) ) ) {
		    System.out.println( "A" );
		}
		else {
		    System.out.println( "a" );
		}
	}

}

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

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

  priority_queue<pair<int, int>> sushi;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    sushi.emplace(b, a);
  }

  vector<pair<int, int>> v(k);
  vector<int> type(n + 1);
  int64_t ans = 0;
  int64_t d = 0;
  int64_t t;

  for (int i = 0; i < k; i++) {
    auto p = sushi.top();
    sushi.pop();
    d += p.first;
    type[p.second]++;
    v[i] = {p.first, p.second};
  }

  t = count_if(begin(type), end(type), [](auto a){return a > 0;});
  ans = d + t * t;

  reverse(begin(v), end(v));

  for (int i = 0; i < k; i++) {
    auto p = v[i];
    if (type[p.second] == 1) continue;
    bool f = false;
    while (!sushi.empty()) {
      auto s = sushi.top();
      sushi.pop();
      if (type[s.second] == 0) {
        f = true;
        type[s.second]++;
        t++;
        d -= p.first;
        d += s.first;
        break;
      }
    }
    if (f) {
      ans = max(ans, d + t * t);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2164
/*
[abc132] C - Divide the Problems
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int d[MAX_N];

ll solve() {
    sort(d, d + N);
    return d[N / 2] - d[N / 2 - 1];
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

struct LazySegmentTree{
    private:
    int n;
    vector<ll> node,lazy;
    
    
    public:
    LazySegmentTree(vector<ll> v){
        int sz = (int)v.size();
        n = 1;while(n < sz)n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
        
        for(int i=0;i<sz;i++)node[i+n-1] = v[i];
        for(int i=n-2;i>=0;i--)node[i]=min(node[2*i+1],node[2*i+2]);
    }
    
    void eval(int k,int l,int r){
        if(lazy[k] != 0){
            node[k] += lazy[k];
            
            if(r-l > 1){
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }
    
    void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
        if(r<0)r = n;
        
        eval(k,l,r);
        if(b <= l || r <= a)return;
        
        if(a <= l && r <= b){
            lazy[k] += (r - l) * x;
            eval(k,l,r);
        }
        else{
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }
    ll getsum(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0)r = n;
        eval(k,l,r);
        if(b <= l || r <= a)return 0;
        if(a <= l && r <= b)return node[k];
        ll vl = getsum(a,b,2*k+1,l,(l+r)/2);
        ll vr = getsum(a,b,2*k+2,(l+r)/2,r);
        return vl + vr;
    }
};
//SegmentTree seg(vector<int>(N,INF));
//最小値を求めたいときは最大値で初期化

int N,Q;
 
signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>Q;
    LazySegmentTree seg(vint(N,0));
    while(Q--){
        int query;cin>>query;
        if(query == 0){
            int s,t,x;cin>>s>>t>>x;
            seg.add(s-1,t,x);
        }
        else{
            int s,t;cin>>s>>t;
            cout<<seg.getsum(s-1,t)<<endl;
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  string S[N]; rep(i,N) cin >> S[i];
  map<string, int> count;
  rep(i,N) count[S[i]]++;
  int mn = 0; for (auto x: count) mn = max(mn,x.second);
  for (auto x: count) {
    if (x.second==mn) cout << x.first << endl;
  }
  // for (auto x: map) {

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

Measured memory_bytes: 26752
#include <iostream>
#include <algorithm>
#include <fstream>
//#include <chrono>
#include <climits>
using namespace std;

int main(){
  //ifstream fin("in.txt");

  /*
  chrono::system_clock::time_point start, end;
  start = chrono::system_clock::now();
  */

  int n; cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];

  /*
  int dp[n]; //dpテーブル dp[i]がa_iまで見た時のLIS
  dp[0]=1; //1番目まで見た時のLISは1

  int ans=1;
  for(int i=1; i<n; i++){
    int index; int m=0;
    for(int j=0; j<i; j++){
      if(a[i]>a[j]){
        m = max(m, dp[j]);
      }
    }
    dp[i] = m+1;
    ans = max(ans, dp[i]);
  }
  */

  int dp[n]; //dpテーブル dp[i]は長さが(i+1)のLISで最小の文字が入る
  fill(dp, dp+n, INT_MAX);

  for(int i=0; i<n; i++){
    *(lower_bound(dp, dp+n, a[i])) = a[i];
  }

  cout << lower_bound(dp, dp+n, INT_MAX)-dp << endl;

  /*
  end = chrono::system_clock::now();
  double elapsed = chrono::duration_cast<chrono::milliseconds>(end-start).count();
  */

  //cout << elapsed << " s" << endl;

  return 0;

}



Measured memory_bytes: 3892
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	int x, y;
	cin >> x >> y;
	for(int i = 1; i <= 1e6; ++i){
		if(i * 8 / 100 == x && i * 10 / 100 == y){
			cout << i << endl;
			return;
		}
	}
	cout << -1;

}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

ll xor_a_bs(ll a, ll bit, const vector<ll>& residual_bs) {
	ll count = 0;
	ll residual_a = a % (1LL << (bit + 1LL));
	
	count += distance(lower_bound(residual_bs.begin(), residual_bs.end(), (1LL << bit) - residual_a), residual_bs.end());
	count -= distance(lower_bound(residual_bs.begin(), residual_bs.end(), (1LL << bit) * 2LL - residual_a), residual_bs.end());
	count += distance(lower_bound(residual_bs.begin(), residual_bs.end(), (1LL << bit) * 3LL - residual_a), residual_bs.end());
	count -= distance(lower_bound(residual_bs.begin(), residual_bs.end(), (1LL << bit) * 4LL - residual_a), residual_bs.end());

	return count % 2LL;
}

int solve() {
	ll n;
	cin >> n;

	vector<ll> as(n);
	vector<ll> bs(n);
	for (ll i = 0; i < n; ++i) cin >> as[i];
	for (ll i = 0; i < n; ++i) cin >> bs[i];

	ll res = 0;
	vector<ll> residual_bs(n);
	for (ll i = 0; i < 29; ++i) {
		for (ll j = 0; j < n; ++j) {
			residual_bs[j] = bs[j] % (1LL << (i + 1LL));
		}
		sort(residual_bs.begin(), residual_bs.end());
		for (ll j = 0; j < n; ++j) {
			res ^= (xor_a_bs(as[j], i, residual_bs) << i);
		}
	}

	cout << res << endl;

	return 0;
}

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

	solve();

	return 0;
}


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

int main() {
    int n,x;
    cin>>n;
    if(n>=900&&n<=999)n-=800;
    else if(n<=199&&n>=100)n+=800;
    x=n%100;
    if(x>=90&&x<=99)n-=80;
    else if(x>=10&&x<=19)n+=80;
    x=n%10;
    if(x==9)n-=8;
    else if(x==1)n+=8;

    std::cout << n<< std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = 1e18+7;

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    graph g(n);
    vector<int> in(n,0);
    rep(i,0,m){
        int x,y;
        cin >> x >> y;
        x--; y--;
        g[x].emplace_back(y);
        in[y]++;
    }
    queue<int> que;
    rep(i,0,n) if(in[i]==0) que.push(i);
    vector<int> dp(n,0);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto nv: g[v]){
            in[nv]--;
            if(in[nv]==0){
                que.push(nv);
                chmax(dp[nv],dp[v]+1);
            }
        }
    }
    int ans = 0;
    rep(i,0,n) chmax(ans,dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 6528
// a program which reads integer S and convert it to h:m:s where h, m, s denote hours, minutes which is less than 60, and seconds which is less than 60 respectively
import java.util.Scanner

fun main(args:Array<String>){
  var S:Int
  var h:Int
  var m:Int
  var s:Int
  val sPerH = 3600                // 3600 seconds per hour
  val sPerM = 60                  // 60 seconds per minute
  val read = Scanner(System.`in`)

  // read integer S
  S = read.nextInt()

  // convert S to hours, minutes, and seconds
  h = S/(sPerH)
  m = (S-h*sPerH)/sPerM
  s = (S-h*sPerH-m*sPerM)

  print(h.toString() + ":")
  print(m.toString() + ":")
  println(s.toString())
}



Measured memory_bytes: 25640
#include<cstdio>
int const N=100001;
//r[k][i]=(i番目のホテルから2^k日以内に到達可能な最右のホテル番号)
int x[N],r[18][N]={};
int ri(int x,int i){
    if(x==0)return i;
    int lsb=x&(-x),k=0;
    while(lsb>1){
        lsb>>=1;
        k++;
    }
    return r[k][ri(x-(x&(-x)),i)];
}
int main(){
    int n,l,q;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&x[i]);
    scanf("%d%d",&l,&q);
    for(int i=1;i<=n;i++){
        int r0i_min=i,r0i_max=n;
        while(r0i_min+1<r0i_max){
            int r0i_mid=(r0i_min+r0i_max)/2;
            if(x[r0i_mid]<=x[i]+l){
                r0i_min=r0i_mid;
            }else{
                r0i_max=r0i_mid;
            }
        }
        if(x[r0i_max]<=x[i]+l)r[0][i]=r0i_max;
        else r[0][i]=r0i_min;
    }
    for(int k=1;k<18;k++){
        for(int i=1;i<=n;i++){
            r[k][i]=r[k-1][r[k-1][i]];
        }
    }
    for(int i=0;i<q;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        if(a>b){
            int tmp=a;
            a=b;
            b=tmp;
        }
        int day_min=0,day_max=n;
        while(day_min+1<day_max){
            int day_mid=(day_min+day_max)/2;
            if(b>ri(day_mid,a))day_min=day_mid;
            else day_max=day_mid;
        }
        if(b>ri(day_max,a))day_max=day_min;
        else day_min=day_max;
        printf("%d\n",day_min);
    }
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
    using namespace std;
     
    #define REP(i,n) for(ll i=0; i<(ll)(n); i++)
    #define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
    #define pb push_back
    #define INF 1000000007LL
    #define all(a) (a).begin(),(a).end()
     
    typedef long long ll;
    typedef pair<int,int> p;
     
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};
     
    struct UnionFind{
        vector<int> parents;
        vector<int> rank;
        UnionFind(int n){
            parents.resize(n);
            rank.assign(n, 1);
            REP(i, n){
                parents[i] = i;
            }
        }
        int find(int x){
            if(parents[x] == x) return x;
            return parents[x] = find(parents[x]);
        }
        
        int unite(int x, int y){
            x = find(x);
            y = find(y);
            if(x == y) return -1;
            if(rank[x] > rank[y]) parents[y] = x;
            else{
                parents[x] = y;
                if(rank[x]==rank[y]) rank[y]++; // use of rank
            }
            return 0;
        }
        
        bool same(int x, int y){
            return find(x) == find(y);
        }
    };
     
    int N,K,L;
    unordered_map<int, unordered_map<int, int> > cnt;
    int main(){
        ios::sync_with_stdio(false);
        cin >> N >> K >> L;
        UnionFind uf1(N);
        UnionFind uf2(N);
        REP(i,K){
            int p,q;
            cin >> p >> q;
            p--;q--;
            uf1.unite(p,q);
        }
        REP(i,L) {
            int r,s;
            cin >> r >> s;
            r--;s--;
            uf2.unite(r,s);
        }
        REP(i,N) cnt[uf1.find(i)][uf2.find(i)]++;
        REP(i,N-1) cout << cnt[uf1.find(i)][uf2.find(i)] << " ";
        cout << cnt[uf1.find(N-1)][uf2.find(N-1)] << endl;
        return 0;
    }

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int n, m ; cin >> n >> m;
	int t = 0;
	vi a(n); rep(i, n){
		cin >> a[i];	
		t += a[i];
	} 
	sort(a.rbegin(), a.rend());
	int ans =0;
	rep(i,n){
		if(a[i]>=0.25*t/m) ans++;
	}

	if(ans>=m) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
#define s(all)   s.begin(),s.end()
#define rep(i,n) for(long long i=0;i<n;i++)
#define ll       long long

int main() {
  int n=0;
  int b=0;
  int M=0;
  cin>>n;
  string s;
  cin>>s;
  rep(i,n){
    if(s[i]=='I')b++;
    if(s[i]=='D')b--;
    M=max(M,b);
  }
  cout<<M<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
 {
	int a, b;
	cin>>a>>b;

	int m1 = max(a, b);
	int m2 = min(a, b);

	int ans = m1 + m2;

	if(ans%2 == 0) cout<<ans/2<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int flag = 1, i=1;
    char input[5];
    scanf("%s", input);
    while(input[0]!=input[i]){
        i++;
    }
    if(i==1&&input[2]==input[3]&&input[1]!=input[2])
    printf("Yes\n");
    else if(i==2&&input[1]==input[3]&&input[1]!=input[2])
    printf("Yes\n");
    else if(i==3&&input[2]==input[1]&&input[1]!=input[0])
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
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 <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
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 main() {
    int x,y,z;
    cin >> x >> y >> z;
    int t = (x-z)/(y+z);
    cout << t << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    for(int i = 0; i < C; ++i){
        for(int j = 0; j < C; ++j){
            cin >> D[i][j];
        }
    }
    vector<vector<int>> c(3, vector<int>(C, 0));
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            int kyomu;
            cin >> kyomu;
            --kyomu;
            ++c[(i + j) % 3][kyomu];
        }
    }
    int ans = INF;
    for(int x = 0; x < C; ++x){
        int S = 0;
        for(int i = 0; i < C; ++i){
            if(i == x)  continue;
            S += D[i][x] * c[0][i];
        }
        for(int y = 0; y < C; ++y){
            if(x == y)  continue;
            int addy = 0;
            for(int i = 0; i < C; ++i){
                if(i == y)  continue;
                addy += D[i][y] * c[1][i];
            }
            S += addy;
            for(int z = 0; z < C; ++z){
                if(x == z || y == z)    continue;
                int addz = 0;
                for(int i = 0; i < C; ++i){
                    if(i == z)  continue;
                    addz += D[i][z] * c[2][i];
                }
                S += addz;
                chmin(ans, S);
                S -= addz;
            }
            S -= addy;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
def solve(D, G, PCs):
    # print(D, ",", G, ",", PCs)
    ans = 10000
    for d in range(0, 2 ** D):
        b = "{:011b}".format(d)[::-1][:D]
        k = 0
        point = 0
        for i, c in enumerate(b):
            if c == "1":
                k += PCs[i][0]
                point += PCs[i][1] + ((i + 1) * 100 * PCs[i][0])
        if point >= G:
            ans = min(ans, k)
            continue

        for i, (p, c) in enumerate(PCs[::-1]):
            if b[D - (i + 1)] == "1":
                continue
            for _ in range(p):
                point += (D - i) * 100
                k += 1
                if point >= G:
                    break
            if point >= G:
                break
        ans = min(ans, k)
    return ans

if __name__ == "__main__":
    D, G = tuple(map(int, input().split(" ")))
    PCs = [tuple(map(int, input().split(" "))) for _ in range(D)]
    print(solve(D, G, PCs))


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
  int n;
  int i;
  int card[4][13]={{}};
  cin >> n;
  char a;
  int b;
  for(i=0;i<n;i++) {
    cin >> a >> b;
    switch(a){
    case 'S':
      card[0][b-1]=1;
      break;
    case 'H':
      card[1][b-1]=1;
      break;
    case 'C':
      card[2][b-1]=1;
      break;
    case 'D':
      card[3][b-1]=1;
      break;
    }
  }
  for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1 << endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
   
  return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>

using namespace std;

int maximumProfit(deque<int> a, int n) {
  int maxProfit = a[1] - a[0];
  int minValue = min(a[0], a[1]);
  for (int i=2; i<n; ++i) {
    int m = a[i] - minValue;
    if (m > maxProfit) {
      maxProfit = m;
    }
    if (a[i] < minValue) {
      minValue = a[i];
    }
  }
  return maxProfit;
}
int main(int argc, char *argv[]) {
  deque<int> deq;
  int n;
	cin >> n;
  for (int i=0; i<n; ++i) {
	  int x;
    cin >> x;
    deq.push_back(x);
  }
  
  cout << maximumProfit(deq, n) << endl;
  return 0;
}



Measured memory_bytes: 4472
program picking_up
  implicit none
  integer :: n, x(50), y(50), i, j, k, l, p, q, m, t
  x = 0
  y = 0
  read(*,*) n
  do i = 1, n
    read(*,*) x(i), y(i)
  end do
  m = 0
  do i = 1, n
    do j = 1, n
      if (j.eq.i) cycle
      p = x(i)-x(j)
      q = y(i)-y(j)
      t = 0
      do k = 1, n
        do l = 1, n
        if ((x(k)-x(l).eq.p).and.(y(k)-y(l).eq.q)) t = t+1
        end do
      end do
      if (m.lt.t) m = t
    end do
  end do
  write(*,'(i0)') n-m
  stop
end program picking_up

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    vector<int> dp(n, INT_MAX);
    rep(i, 0, n) cin >>
        A[i];
    dp[0] = 0;
    rep(i, 0, n)
    {
        // cout << "dp[" << i << "] is " << dp[i] << endl;
        rep(j, 1, k + 1)
        {
            if (i <= n - 1 - j)
                dp[i + j] = min(dp[i + j], dp[i] + abs(A[i] - A[i + j]));
        }
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 1152
n,m=map(int,input().split())
dp=[0]*(n)
for i in range(n):
	s=input()
	dp[i]=[-1]*m
	for j in range(m):
		if s[j]=="#":
			dp[i][j]=0
fill=1
for i in range(m):
	if dp[0][i]<0:
		dp[0][i]=fill
	else:
		fill=0
fill=1
for i in range(1,n):
	if dp[i][0]<0:
		dp[i][0]=fill
	else:
		fill=0
for i in range(1,n):
	for j in range(1,m):
		if dp[i][j]<0:
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007
print(dp[n-1][m-1])

Measured memory_bytes: 52572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    map<ll,ll> mp;
    rep(i,n){
        if(!mp.count(v[i]-i)){
            mp.ins({v[i]-i,1});
        }
        else mp[v[i]-i]++;
       // cout << v[i]-i <<endl;
    }
    ll ans=0;
    rep(i,n){
        mp[v[i]-i]--;
        if(mp.count(-v[i]-i)){
            ans+=mp[-v[i]-i];
            //cout << -v[i]-i <<" " << i <<" " << mp[-v[i]-i] <<endl;
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 16224
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void){
    int n, a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    
    if (n == 2) {
        cout << max(a[0], a[1]) << " " << min(a[0], a[1]) << endl;
        return 0;
    }
    
    sort(a, a + n);
    
    int x = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] <= a[n - 1] / 2) {
            x = i;  break;
        }
    }
    
    if (a[x] > a[n - 1] - a[x + 1]) cout << a[n - 1] << " " << a[x] << endl;
    else cout << a[n - 1] << " " << a[x + 1] << endl;
    
}


Measured memory_bytes: 640
N,W = map(int, input().split())
w = [0]*(N+1); v = [0]*(N+1);
for i in range(1, N+1):
    w[i], v[i] = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    dp_i = dp[i]
    dp_i_1 = dp[i-1]
    w_i = w[i]
    v_i = v[i]
    for sum_w in range(1, W+1):
        if sum_w - w_i >= 0:
            dp_i[sum_w] = max(dp_i_1[sum_w - w_i] + v_i, dp_i_1[sum_w])
        else:
            dp_i[sum_w] = dp_i_1[sum_w]
print(dp[N][W])

Measured memory_bytes: 148324
#include<stdio.h>
int main()
{
	int a, b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %.8lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T, bool get_max>
class CHT {
    using P = pair<T, T>;
    deque<P> lines;
public:
    CHT() = default;
    int sgn(T x) { return x == 0 ? 0 : (x > 0 ? 1 : -1); }
    bool check(P l1, P l2, P l3){
        if(l1.second == l2.second || l2.second == l3.second){
            return sgn(l1.first - l2.first)*sgn(l2.second - l3.second)
                >= sgn(l2.first - l3.first)*sgn(l1.second - l2.second);
        }else {
            return (l1.first - l2.first)*sgn(l2.second - l3.second)/ static_cast<long double>(abs(l1.second - l2.second))
                   >= (l2.first - l3.first)*sgn(l1.second - l2.second)/ static_cast<long double>(abs(l2.second - l3.second));
        }
    }

    void add_line(T a, T b) { // add ax + b
        if(get_max) a = -a, b = -b;
        P L(a, b);
        if(lines.empty()){
            lines.emplace_back(L);
            return;
        }
        if(lines.front().first <= a){
            if(lines.front().first == a){
                if(lines.front().second <= b) return;
                else lines.pop_front();
            }
            while(lines.size() >= 2 && check(L, lines.front(), lines[1])) lines.pop_front();
            lines.emplace_front(L);
        }else {
            if(lines.back().first == a){
                if(lines.back().second <= b) return;
                else lines.pop_back();
            }
            while(lines.size() >= 2 && check(lines[lines.size()-2], lines.back(), L)) lines.pop_back();
            lines.emplace_back(L);
        }
    }

    T val(const P &L, const T &x) { return L.first * x + L.second; }
    T query(T x){
        int l = -1, r = lines.size() - 1;
        while(r - l > 1){
            int mid = (l+r) >> 1;
            if(val(lines[mid], x) >= val(lines[mid+1], x)) l = mid;
            else r = mid;
        }
        return get_max ? -val(lines[r], x) : val(lines[r], x);
    }

    T query_increase(T x){
        while(lines.size() >= 2 && val(lines.front(), x) >= val(lines[1], x)) lines.pop_front();
        return get_max ? -val(lines.front(), x) : val(lines.front(), x);
    }

    T query_decrease(T x){
        while(lines.size() >= 2 && val(lines.back(), x) >= val(lines[lines.size() - 2], x)) lines.pop_back();
        return get_max ? -val(lines.back(), x) : val(lines.back(), x);
    }
};

int main() {
    ll n, c;
    cin >> n >> c;
    vector<ll> v(n);
    for (auto &&i : v) scanf("%lld", &i);
    vector<ll> dp(n, INF<ll>);
    dp[0] = 0;
    CHT<ll, false> cht;
    cht.add_line(-2*v[0], v[0]*v[0]);
    for (int i = 1; i < n; ++i) {
        dp[i] = cht.query_increase(v[i])+v[i]*v[i]+c;
        cht.add_line(-2*v[i], v[i]*v[i]+dp[i]);
    }
    cout << dp.back() << "\n";
    return 0;
}

Measured memory_bytes: 5504
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Friendships
 */

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

/* constant */

const int MAX_N = 100;
const int MAX_M = MAX_N * (MAX_N - 1) / 2;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int ens[MAX_N];
pii es[MAX_M];

/* subroutines */

inline int c2(int n) { return n * (n - 1) / 2; }

/* main */

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

  int cnt = (n - 1) * (n - 2) / 2;
  if (k > cnt) {
    puts("-1");
    return 0;
  }

  int m = 0;
  for (int i = 1; i < n; i++) es[m++] = pii(0, i);

  for (int i = 1; cnt > k && i < n; i++)
    for (int j = i + 1; cnt > k && j < n; j++)
      es[m++] = pii(i, j), cnt--;

  printf("%d\n", m);
  for (int i = 0; i < m; i++)
    printf("%d %d\n", es[i].first + 1, es[i].second + 1);
  return 0;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = INF;
	int tmp;
	int n;
	cin >> n;
	vector<int> x(n);
	REP(i, n) cin >> x[i];
	REP1(i,100){
		tmp = 0;
		REP(j, n) tmp += (i - x[j]) * (i - x[j]);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 100001
#define LARGENUM 1000000000
int ME[MAX];
vector <int> vec[MAX];
int N;
queue<int> q;

int main(){
    int M, A, B, u, v;
    cin >> N >> M;
    rep(i, M) {
        cin >> A >> B;
        vec[A].push_back(B);
        vec[B].push_back(A);
    }
    q.push(1);
    while(!q.empty()){
        u = q.front();
        q.pop();
        rep(i, vec[u].size()){
            v = vec[u][i];
            if (ME[v] == 0){
                q.push(v);
                ME[v] = u;
            }
        }
    }
    bool flag = true;
    for (int i = 1; i <= N; i++) if (ME[i] == 0) flag = false;
    if (flag){
        cout << "Yes" << endl; 
        for (int i = 2; i <= N; i++) {
        cout << ME[i] << endl;
        }
    }
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 10508
#include <stdio.h>
int main(){
int a[4],b[4],i,sum[2];

scanf("%d %d %d %d\n",&a[0],&a[1],&a[2],&a[3]);
scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);

    sum[0]=a[0]+a[1]+a[2]+a[3];
    sum[1]=b[0]+b[1]+b[2]+b[3];

if(sum[0]<sum[1]){
    printf("%d\n",sum[1]);}
    else {printf("%d\n",sum[0]);}

 return 0;
}

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

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

    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M);
    int mx_L = 0;
    int mn_R = N;
    for (int i = 0; i < M; i++)
    {
        cin >> L[i] >> R[i];
        mx_L = max(mx_L, L[i]);
        mn_R = min(mn_R, R[i]);
    }

    int ans = mn_R - mx_L + 1;
    if (ans >= 0)
    {
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 1024