akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {

  int K, N;
  cin >> N >> K;

  int count = (N - 1) * (N - 2) / 2 - K;
  if (count < 0) {
    cout << -1 << endl;
    return 0;
  }

  count += N - 1;
  cout << count << endl;

  int c = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      cout << i << " " << j << endl;
      c++;
      if (c == count) break;
    }
    if (c == count) break;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define watch(x)   	 cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
using namespace __gnu_pbds;
const int maxn=3000005;

vector<ll>pr;
bool mark[maxn];

void si()
{
    for(ll i=4; i<maxn; i+=2) mark[i]=1;
    for(ll i=3; i*i<maxn; i+=2)
        if(!mark[i])
            for(ll j=i*i; j<maxn; j+=i)
                mark[j]=1;
    pr.pb(2);
    for(ll i=3; i<maxn; i+=2)
        if(!mark[i])
            pr.pb(i);
}
ll bigmod(ll a, ll b, ll mo)
{
    ll ans=1;
    a%=mo;

    while(b>0LL)
    {
        if(b&1) ans=(ans*a)%mo;
        b>>=1;
        a=(a*a)%mo;
    }

    return ans;
}
ll mod=1e9+7;
ll fib[2000+2];
ll finv[20002];
ll inv[20002];

void calc()
{
    inv[1] = 1;
    for (int i = 2; i <2002; ++i)
        inv[i] = (mod - ((mod/i)*inv[mod%i])%mod)%mod;

    fib[0]=1;
    finv[0]=1;
    for(ll i=1; i<=2000; i++)
    {
        fib[i]=(fib[i-1]*i)%mod;
        finv[i]=(finv[i-1]*inv[i])%mod;
    }
}

ll com(ll n,ll r)
{
   // cout<<n<<" "<<r<<endl;
    if(n<0LL || r<0LL || r>n) return 0LL;
    return (fib[n]*finv[r]%mod*finv[n-r]%mod)%mod;
}

int main()
{
    // fast_cin;
    int t,cas=1;
    //si();
    calc();
    ll n,k;
    scanf("%lld%lld",&n,&k);

    for(ll i=1; i<=k; i++)
    {
        ll a=com(n-k+1,i);
        ll b=com(k-1,i-1);
       // cout<<a<< " "<<b<<endl;
        ll ans=(a*b)%mod;

        printf("%lld\n",ans);
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

int main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> x1 >> y1 >> x2 >> y2;
	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x3 - (y3 - y2);
	y4 = y3 + (x3 - x2);
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int N,X,T;
    cin >> N >> X >> T;
    
    cout << ((N + (X-1)) / X)*T << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int K,T;
  cin >> K >> T;
  int a[T];
  for (int i = 0; i < T; i++) {
    cin >> a[i];
  }
  sort(a,a+T);
  reverse(a,a+T);
  int ma = max(0,a[0] - (K - a[0]));
  int ans = max(0,ma-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
int N, M;
void func()
{
    cin >> N;
    ll ans(0), A[N];
    map<ll, int> B;
    rep(i, 1, N + 1)
    {
        cin >> A[i];
        ll k = i - A[i];
        if (B.count(k))
            ++B[k];
        else
            B[k] = 1;
    }
    rep(i, 1, N + 1)
    {
        ll k = i + A[i];
        if (B.count(k))
            ans += B.find(k)->second;
    }
    cout << ans << endl;
}
int main()
{
    func();
}


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

using namespace std;

int main() {
  int array[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  
  cin >> K;
  cout << array[K - 1] << endl;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
a = list(map(int, input().split()))
serch_value = 1
for v in a:
    if (v == serch_value):
        serch_value += 1
found_value = serch_value - 1
if (found_value == 0):
    print(-1)
else:
    print(n-found_value)


Measured memory_bytes: 26780
//============================================================================
// Name        : aoj1500.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int a[10], n, m;
int nwcsum = 0;

int judge(int wc[],int ptr[],int pnum){
	int sum = nwcsum;
	for(int i = 0;i < pnum;i++){
		int x = wc[i];
		if(n % 2 == 0){
			if(ptr[i] % 2 == 0){
				x *= 2;
			}
		}else{
			if(ptr[i] % 2 == 1){
				x *= 2;
			}
		}
		if (x >= 10) {
			sum += x / 10;
		}
		sum += x % 10;
	}
	if(sum % 10 == 0){
		return 1;
	}else{
		return 0;
	}

}

int dfs(int wc[],int ptr[],int i,int pnum){
	int sum = 0;
	if(i == pnum){
		return judge(wc,ptr,pnum);
	}
	for(int j = 0;j < m;j++){
		wc[i] = a[j];
		sum += dfs(wc,ptr,i + 1,pnum);
	}
	return sum;
}


int main() {
	int  wc[7], ptr[7], cnt = 0;
	string s;
	cin >> n >> s >> m;
	for(int i = 0;i < m;i++){
		cin >> a[i];
	}

	//nwcsum ワイルドカード以外の足し算
	for(int i = 0;i < n;i++){
		if(s[n - 1 - i] == '*'){
			ptr[cnt++] = n - 1 - i;
			continue;
		}
		int x = s[n - 1 - i] - '0';
		if(i % 2 == 1){
			x *= 2;
		}
		if (x >= 10) {
			nwcsum += x / 10;
		}
		nwcsum += x % 10;
	}

	cout << dfs(wc,ptr,0,cnt) << endl;

	return 0;
}

Measured memory_bytes: 1332
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int count_W[N]; // 自分より右側のW
    int count_B[N]; // 自分より左側のB
    int cw = 0;
    int cb = 0;
    for (int i = 0; i < N; i++) {
        count_B[i] = cb;
        if (S[i] == '#') cb++;
        count_W[N - i - 1] = cw;
        if (S[N - i - 1] == '.') cw++;
    }
    int minimum = N + 1;
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') minimum = min(minimum, count_W[i] + count_B[i]);
    }
    minimum = min(minimum, cb);
    cout << minimum << endl;
    return 0;
}

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

int lcm(int a,int b) {
	if (a % b==0) return b;
	else return lcm(b, a % b);
	}
long long gcd(long long a,long long b) {
	int lc;
	lc=lcm(a,b);
    return a*b/lc;
}

int main() {
int a[3],b[3],c[3],i,j,k;
while(true) {
	for (i=0;i<3;i++) cin >> a[i] >> b[i];
	if (a[0]==0) break;
	for (i=0;i<3;i++) {
		c[i]=0; j=1;
		do { j=a[i]*j % b[i]; c[i]++;} while (j!=1);
	}
    cout << gcd(gcd(c[0],c[1]),gcd(c[1],c[2])) << endl;
}
return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

string s;
cin>>s;
vi a(26);
for(auto& x: s)
  a[x-'a']++;
for(auto& x: a) {
  if(x%2!=0) {
    cout<<"No"<<endl;
    return 0;
  }
}
cout<<"Yes"<<endl;
return 0;
}


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

int main (void){
  long long int n,a;
  cin >> n;
  vector<int> b(n,0);

  for(int x = 1;x <= 41;x++){
    for(int y = x;y <= 100;y++){
      for(int z = y;z <= 100;z++){
          a = pow(x,2) + pow(y,2) + pow(z,2) + x*y + y*z + z*x;
          if(a <= n){
            a--;
            if(x == y && y == z){
              b[a]++;
            }
            if(x == y && y != z){
              b[a] = b[a] + 3;
            }
            if(x != y && y == z){
              b[a] = b[a] + 3;
            }
            if(x != y && y != z){
              b[a] = b[a] + 6;
            }
        }
      }
    }
  }

  for(int i = 0;i < n;i++){
    cout << b[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3620
using System;

namespace AtCoderProblems
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            if(a % 1000 == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(((a / 1000) + 1) * 1000 - a);
            }
        }
    }

}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, a[100005];
map<int, int> M;

int s[100005];

int main(){
	scanf("%d", &n);
	
	int distinct = 0;
	
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(!M.count(a[i])){
			M[a[i]] = 1;
			distinct++;
		}else{
			M[a[i]]++;
		}
	}
	
	if(distinct > 3){
		printf("No\n");
		return 0;
	}else if(distinct == 3){
		int xx = 0;
		for(auto it: M){
			xx ^= it.first;
			if(it.second * 3 != n){
				printf("No\n");
				return 0;
			}
		}
		if(xx == 0){
			printf("Yes\n");
			return 0;
		}else{
			printf("No\n");
			return 0;
		}
	}else{
		int target;
		if(distinct == 1){
			target = n;
		}else{
			if(n % 3){
				printf("No\n");
				return 0;
			}
			target = n / 3;
		}
		if(!M.count(0) || M[0] != target){
			printf("No\n");
			return 0;
		}
	}
	
	printf("Yes\n");
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
  	for(int i = 0; i < n; i++) {
  		cin >> a[i];
    }
	sort(a.begin(), a.end());
  	cout << a[n/2] - a[n/2-1]<< endl;
}


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

template<typename T> vector<T> divisor(T n){
    vector<T> res;
    for (long long i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i * i != n) { res.emplace_back(n/i); }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    long long sum = accumulate(a.begin(), a.end(), 0LL);
    vector<long long> div = divisor(sum);
    
    auto f = [&] (long long x) {
        vector<long long> v(n), sum(n+1, 0);
        for (int i = 0; i < n; i++) v[i] = a[i] % x;
        sort(v.rbegin(), v.rend());
        for (int i = 0; i < n; i++) sum[i+1] = sum[i] + v[i];
        bool ret = false;
        for (int i = 1; i <= n; i++) {
            long long res1 = i * x - sum[i];
            long long res2 = sum[n] - sum[i];
            ret |= (max(res1, res2) <= k);
        }
        return ret;
    };
    
    long long ans = 1;
    for (const auto& x : div) if (f(x)) ans = x;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(a[2] + " " + a[0] + " " + a[1]);
        }
    }
}


Measured memory_bytes: 28112
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int main(int argc, char* argv[]){
    string s;
    int K;
    string a = "abcdefghijklmnopqrstuvwxyz";
    vector<string> v;
    cin >> s >> K;

    for(int i = 0; i < s.length(); i++){
        rep(j, 26){
            if(s[i] == a[j]){
                rep(k, 5){
                    v.push_back(s.substr(i, k+1));
                }
            }
        }
    }
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());
    cout << v[K-1] << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin>>S>>T;
    int N = S.size();
    int ans=0;
    rep(i,N)if(S[i]!=T[i]) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3816
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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() 
{
  string S,T; cin>>S>>T;
  ll N=S.size(),M=T.size();
  for(int i=N-M;i>=0;i--)
  {
    rep(j,M)
    {
      if(S.at(i+j)!=T.at(j)&&S.at(i+j)!='?') goto OUT;
    }  
    rep(j,M)
    {
      S.at(i+j)=T.at(j);
    }
    rep(j,N)
    {
      if(S.at(j)=='?') S.at(j)='a';
    }  
    cout<<S<<endl; return 0;
    OUT:;
  }  
  cout<<"UNRESTORABLE"<<endl;
  return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>
int main(void)
{
    int n, i, count=0;

    scanf("%d", &n);

    for(i=1; i<=n; i++){
        if(i%2 != 0){
            count++;
        }
    }
    double ans;
    ans = (double)count / n;

    printf("%.10f", ans);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    string a,b,c; cin>>a>>b>>c;
    int ans = 0;
    REP(i,n){
        if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i]) ans += 2;
        else if(a[i]!=b[i]||b[i]!=c[i]||c[i]!=a[i]) ans++;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M; cin >> N >> M;
  vector<pair<int, int>> scan(M);
  for(int i = 0; i < M; i++) {
    int s, c; cin >> s >> c;
    s--;
    scan.at(i) = make_pair(s, c);
  }
  for(int i = ((N == 1) ? 0 : pow(10, N - 1)); i < pow(10, N); i++) {
    string num = to_string(i);
    bool judge = false;
    for(int j = 0; j < M; j++) {
      int s = scan.at(j).first;
      char c = char(scan.at(j).second) + '0';
      if(num.at(s) != c) judge = true;
      if(judge) break;
    }
    if(judge) continue;
    cout << i << endl;
    return 0;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//



//----------//

void print2dArray(vector<vector<ll> > vv, int a){
    rep(i, vv.size()){
        rep(j, a){
            if(i)cout << " ";
            cout << vv[i][j];
        }
        cout << endl;
    }
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    int n, w;
    cin >> n >> w;
    vector<vector<ll> > vv(n+1, vector<ll>(MAX+1));
    vector<ll> W(n);
    vector<ll> V(n);
    rep(i, n+1){
        fill(vv[i].begin(), vv[i].end(), -1);
    }

    rep(i, n){
        cin >> W[i] >> V[i];
    }

    vv[0][0] = 0;
    rep2(i, 1, n+1){
        vv[i][W[i-1]] = max(vv[i][W[i-1]], V[i-1]);
        rep(j, w+1){
            if(vv[i-1][j] != -1){
                vv[i][j] = max(vv[i-1][j], vv[i][j]);
                if(j + W[i-1] <= w)
                    vv[i][j+W[i-1]] = max(vv[i][j+W[i-1]], vv[i-1][j]+V[i-1]);
            }
        }
    }

    //print2dArray(vv, w+1);


    ll res = 0;
    rep(i, w+1){
        res = max(vv[n][i], res);
    }

    cout << res << endl;

    
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 310000
int n,m;
int w[N];
ll ans;
ll sum[N],v[N],vt[N],f1[N],f2[N],vy[N];
int q1[N],h1,r1;
int q2[N],h2,r2;
ll gety1(ll *f,int x){return (ll)x*(x-1)/2+sum[x]+f[x];}
ll gety2(ll *f,int x){return (ll)x*(x+1)/2+sum[x]+f[x];}
void getf(ll *f)
{
	f[0]=0;sum[0]=0;
	q1[h1=r1=1]=0;vy[0]=gety1(f,0);
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+w[i];
	for(int i=1;i<=n;i++)
	{
		f[i]=f[i-1];
		while(h1<r1&&vy[q1[r1]]-vy[q1[r1-1]]<(ll)i*(q1[r1]-q1[r1-1]))r1--;
		f[i]=max(f[i],(ll)i*(i+1)/2-sum[i]+vy[q1[r1]]-(ll)i*q1[r1]);
		vy[i]=gety1(f,i);
		while(h1<r1&&(vy[q1[r1]]-vy[q1[r1-1]])*(i-q1[r1])<(vy[i]-vy[q1[r1]])*(q1[r1]-q1[r1-1]))r1--;
		q1[++r1]=i;
	}
}
void procl(int l,int r)
{
	q1[h1=r1=1]=l-1;vy[l-1]=gety1(f1,l-1);
	for(int i=l;i<=r;i++)
	{
		vy[i]=gety1(f1,i);
		while(h1<r1&&(vy[q1[r1]]-vy[q1[r1-1]])*(i-q1[r1])<(vy[i]-vy[q1[r1]])*(q1[r1]-q1[r1-1]))r1--;
		q1[++r1]=i;
	}
}
void procr(int l,int r)
{
	q2[h2=r2=1]=r+1;vy[r+1]=gety2(f2,r+1);
	for(int i=r;i>=l;i--)
	{
		vy[i]=gety2(f2,i);
		while(h2<r2&&(vy[q2[r2]]-vy[q2[r2-1]])*(i-q2[r2])>(vy[i]-vy[q2[r2]])*(q2[r2]-q2[r2-1]))r2--;
		q2[++r2]=i;
	}
}
void solve(int l,int r)
{
	if(l==r){v[l]=1-w[l];return;}
	int mid=(l+r)>>1;
	solve(l,mid);
	solve(mid+1,r);

	sum[l-1]=0;
	for(int i=l;i<=r;i++)sum[i]=sum[i-1]+w[i];
	procl(l,mid);
	for(int i=r;i>mid;i--)
	{
		while(h1<r1&&vy[q1[h1+1]]-vy[q1[h1]]>(ll)i*(q1[h1+1]-q1[h1]))h1++;
		vt[i]=(ll)i*(i+1)/2-sum[i]+vy[q1[h1]]-(ll)i*q1[h1]+f2[i+1];
		if(i!=r)vt[i]=max(vt[i],vt[i+1]);
	}

	sum[r+1]=0;
	for(int i=r;i>=l;i--)sum[i]=sum[i+1]+w[i];
	procr(mid+1,r);
	for(int i=l;i<=mid;i++)
	{
		while(h2<r2&&vy[q2[h2+1]]-vy[q2[h2]]>(ll)i*(q2[h2+1]-q2[h2]))h2++;
		vt[i]=(ll)i*(i-1)/2-sum[i]+vy[q2[h2]]-(ll)i*q2[h2]+f1[i-1];
		if(i!=l)vt[i]=max(vt[i],vt[i-1]);
	}
	for(int i=l;i<=r;i++)
		v[i]=max(v[i],vt[i]);
}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&w[i]);
	
	getf(f1);
	reverse(w+1,w+1+n);
	getf(f2);
	reverse(w+1,w+1+n);
	reverse(f2+1,f2+1+n);

	solve(1,n);
	scanf("%d",&m);
	for(int p,x;m--;)
	{
		scanf("%d%d",&p,&x);
		ans=f1[p-1]+f2[p+1];
		ans=max(ans,v[p]+w[p]-x);
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 18560
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)


int main()
{
	ll h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << endl;
		return 0;
	}

	cout << (h * w + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, L; cin >> N >> L;
    vi T(N + 1, 0);
    int eat = INF;
    FOR(i,1,N+1) {
        T[i] = L + i - 1;
        if (abs(eat) > abs(T[i])) {
            eat = T[i];
        }
    }

    int sum = 0;
    FOR(i,1,N+1) {
        sum += T[i];
    }

    int ans = sum - eat;
    cout << ans << endl;

    return 0;
}

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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }

// 4近傍（右, 下, 左, 上）
const std::vector<int> dy = { 0, -1, 0, 1 };
const std::vector<int> dx = { 1, 0, -1, 0 };

using namespace std;


int solve(int N, int W, const vector<int> &v, const vector<int> &w) {
    // dp[i][j] = i番目までみたとき、重さjで達成できる価値の最大値
    vector<vector<int>> dp(N + 1, vector<int>(W + 1, -1));
    dp[0][0] = 0;
    FOR(i, 0, N) {
        int value = v[i];
        int weight = w[i];

        FOR(j, 0, dp[0].size()) {
            if (dp[i][j] == -1) { continue; }

            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            if (j + weight <= W) {
                dp[i + 1][j + weight] = max(dp[i + 1][j + weight], dp[i][j] + value);
            }
        }
    }

    int ans = 0;
    FOR(j, 0, dp[0].size()) {
        ans = max(ans, dp[N][j]);
    }

    return ans;
}


vector<vector<int>> memo;
int dfs(int i, int W, const vector<int> &v, const vector<int> &w) {
    if (i >= v.size()) {
        return 0;
    }

    if (memo[i][W] != -1) {
        return memo[i][W];
    }

    int value = v[i];
    int weight = w[i];

    // not use
    int ans = dfs(i + 1, W, v, w);

    // use
    if (W >= weight) {
        ans = max(ans, dfs(i + 1, W - weight, v, w) + value);
    }

    return memo[i][W] = ans;
}


int main() {
    int N , W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    FOR(i, 0, N) {
        cin >> v[i] >> w[i];
    }

    memo.resize(N + 1, vector<int>(W + 1, -1));
    cout << dfs(0, W, v, w) << endl;

    return 0;
}


Measured memory_bytes: 6884
// B
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    reg int n = read(), cnt = 0, k = read();
    for (reg int i = 1; i <= n; i++) {
        reg int x = read();
        if (x >= k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    int x1, x2;
    scanf("%d%d", &x1, &x2);
    if(x1 == x2)
    {
        printf("Draw\n");
    }else
    {
        if(x2 == 1)
        {
            printf("Bob\n");
        }else
        if(x1 == 1)
        {
            printf("Alice\n");
        }else
        {
            if(x1 > x2)
            {
                printf("Alice\n");
            }else
            {
                printf("Bob\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,n) for (lint i = 0; i < (n); i++)
#define REP1(i,n) for (lint i = 1; i < (n); i++)

lint H, A;

int main(void){
    cin >> H >> A;
    ((H % A) == 0) ? cout << (H/A) << endl : cout << (H/A) + 1 << endl;
    return 0;
}

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

int main(){
	string ans="No";
	int n;	cin>>n;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				ans="Yes";
				break;
			}
		}
		if(ans=="Yes")break;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int a, b;
	b = n % 100;
	a = n / 100;
	if (a > 0 && a < 13)
	{
		if (b > 0 && b < 13)
			printf("AMBIGUOUS\n");
		else
			printf("MMYY\n");
	}
	else
	{
		if (b > 0 && b < 13)
			printf("YYMM\n");
		else
			printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 128
import math

n = int(input())
lst = list(map(int, input().split()))

a = sum(lst)//len(lst)
b = -(-sum(lst)//len(lst))

ans_a=0
ans_b=0
for i in lst:
    ans_a += (i-a)**2
    ans_b += (i-b)**2

print(min(ans_a,ans_b))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n, m, a[nax];

int main () {
    cin >> n >> m;
    int tot = 0;

    for (int i = 1 ; i <= n;  ++ i)
        scanf("%d", a + i);


    tot = accumulate(a + 1, a + 1 + n, 0);
    sort(a + 1, a + 1 + n);
    int req = tot / (4 * m);
    int ct = 0;
    
    for (int i = 1 ; i <= n ; ++ i) {
        if (a[i] * 4 * m >= tot) ++ ct;
    }
    
    puts(ct >= m ? "Yes" : "No");
}

/*
    Good Luck
        -Lucina
*/


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

int n;

void func(long long x, int used, int &count)
{
    if (x > n)
        return;
    if (used == 0b111)
        count++;

    func(x * 10 + 3, used | 0b001, count);
    func(x * 10 + 5, used | 0b010, count);
    func(x * 10 + 7, used | 0b100, count);
}

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

    cin >> n;

    int count = 0;
    func(0, 0, count);
    cout << count << endl;
}


Measured memory_bytes: 256
fun main() {
    var (n,a,b)= readLine()!!.split(" ").map { it.toInt() }
    val x= readLine()!!.split(" ").map { it.toLong() }.toLongArray()
    var state=x[0]
    var ans=0L
    for (i in 1 until n){
        if ((x[i]-state)*a>=b){ans+=b}
        else{ans+=(x[i]-state)*a}
        state=x[i]
    }
    println(ans)
}

Measured memory_bytes: 53752
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;

int main()
{
int n;
cin >> n;
vector<vector<bool>> cards(4,vector<bool>(13));
string SHCD="SHCD";
for(int i=0;i<n;i++)
{
char shcd;
int num;
cin >> shcd >> num;
cards.at(SHCD.find(shcd)).at(num-1)=true;
}
for(int i=0;i<4;i++)
{
for(int j=0;j<13;j++)
{
if(!cards.at(i).at(j))cout << SHCD.at(i) << " " << j+1 << endl;
}
}
}



Measured memory_bytes: 3156
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=1000000007;

long long int n,m,k,a,b,c,d,count=0,res=0;
int main() {
    int count=0;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n;
    if(n<=1000000000){
        cout<<0<<" "<<0<<" "<<0<<" "<<1<<" "<<n<<" "<<0;
        return 0;
    }else{
        b=(1000000000-n%1000000000)%1000000000;
        c=1;
        if(b!=0){
        n+=1000000000;
        }
        a=n/1000000000;
        d=1000000000;
        cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<c<<" "<<d;
        return 0;
    }
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    ll sum = 0;
    ll pm = 1;
    rep(i, n) {sum += a[i]*pm; pm = -pm;}
    vector<ll> ans;
    ans.push_back(sum);
    rep1(i, n-1){
        sum = -sum;
        sum += a[i-1]*2;
        ans.push_back(sum);
    }
    show(ans);

}



Measured memory_bytes: 2676
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut count = 0;
    for i in 2..n {
        if (p[i - 2] < p[i - 1] && p[i - 1] < p[i]) || (p[i - 2] > p[i - 1] && p[i - 1] > p[i]) {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2076
def isPalin(s):
    for i in range(len(s)):
        if s[i]!=s[len(s)-1-i]:
            return False
    return True

A,B = [int(i) for i in input().split()]
#s = [[int(j) for j in input().split()] for i in range(N)]

res = 0
for i in range(A,B+1):
    if isPalin(str(i)):
        res+=1
print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

int main(){
  int a,b; cin >> a >> b;
  if (a>b) swap(a,b);
  rep(i,b) cout << a;
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef pair<long long, long long> pp;
const int maxn = 2210;
const long long oo = 1e18;
struct edges
{
	int to, next;
	long long c, f;
}edge[maxn * maxn * 2];
int point[maxn] = {0}, te = 1;
void add(int a, int b, long long c, long long d)
{
	te ++;
	edge[te].to = b;
	edge[te].next = point[a];
	edge[te].f = c;
	edge[te].c = d;
	point[a] = te;
}
void adde(int a, int b, long long c, long long d)
{
	//cout << a << " " << b << " " << c << " " << d << endl;
	add(a, b, c, d);
	add(b, a, 0, -d);
}
int st = 0, ed;
long long dis[maxn];
queue<int> q;
bool in[maxn] = {0};
bool spfa()
{
	for(int i = st; i <= ed; i ++)
	{
		in[i] = 0;
		dis[i] = oo;
	}
	dis[st] = 0;
	q.push(st);
	in[st] = 1;
	while(!q.empty())
	{
		int now = q.front();
		q.pop();
		in[now] = 0;
		for(int e = point[now]; e; e = edge[e].next)
			if(edge[e].f && dis[edge[e].to] > dis[now] + edge[e].c)
			{
				dis[edge[e].to] = dis[now] + edge[e].c;
				if(!in[edge[e].to])
				{
					q.push(edge[e].to);
					in[edge[e].to] = 1;
				}
			}
	}
	return dis[ed] < oo;
}
int cur[maxn];
bool mark[maxn] = {0};
pp dfs(int now, long long flow)
{
	if(flow == 0 || now == ed)
		return mp(flow, 0);
	mark[now] = 1;
	pp ff;
	for(int &e = cur[now]; e; e = edge[e].next)
		if(edge[e].f && dis[edge[e].to] == dis[now] + edge[e].c && !mark[edge[e].to])
		{
			pp hh = dfs(edge[e].to, min(flow, edge[e].f));
			flow -= hh.first;
			edge[e].f -= hh.first;
			edge[e ^ 1].f += hh.first;
			ff.first += hh.first;
			ff.second += hh.second + hh.first * edge[e].c;
			if(flow == 0)
			{
				mark[now] = 0;
				return ff;
			}
		}
	mark[now] = 0;
	return ff;
}
pp ans;
void dinic()
{
	ans.first = ans.second = 0;
	while(spfa())
	{
		for(int i = st; i <= ed; i ++)
			cur[i] = point[i];
		pp a = dfs(st, oo);
		ans.first += a.first;
		ans.second += a.second;
	}
}
int n;
int rx[maxn], ry[maxn], rc[maxn], bx[maxn], by[maxn], bc[maxn];
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> rx[i] >> ry[i] >> rc[i];
	for(int i = 1; i <= n; i ++)
		cin >> bx[i] >> by[i] >> bc[i];
	ed = n * 2 + 9;
	for(int i = 1; i <= n; i ++)
	{
		adde(st, i, rc[i], 0);
		
		adde(i, n * 2 + 1, oo, -(rx[i] + ry[i]));
		adde(i, n * 2 + 2, oo, -(-rx[i] + ry[i]));
		adde(i, n * 2 + 3, oo, -(rx[i] - ry[i]));
		adde(i, n * 2 + 4, oo, -(-rx[i] - ry[i]));
		
		adde(n + i, ed, bc[i], 0);
		
		adde(n * 2 + 5, n + i, oo, -(bx[i] + by[i]));
		adde(n * 2 + 6, n + i, oo, -(-bx[i] + by[i]));
		adde(n * 2 + 7, n + i, oo, -(bx[i] - by[i]));
		adde(n * 2 + 8, n + i, oo, -(-bx[i] - by[i]));
	}
	adde(n * 2 + 1, n * 2 + 8, oo, 0);
	adde(n * 2 + 2, n * 2 + 7, oo, 0);
	adde(n * 2 + 2, n * 2 + 8, oo, 0);
	adde(n * 2 + 3, n * 2 + 6, oo, 0);
	adde(n * 2 + 3, n * 2 + 8, oo, 0);
	adde(n * 2 + 4, n * 2 + 5, oo, 0);
	adde(n * 2 + 4, n * 2 + 6, oo, 0);
	adde(n * 2 + 4, n * 2 + 7, oo, 0);
	adde(n * 2 + 4, n * 2 + 8, oo, 0);
	dinic();
	cout << -ans.second << endl;
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int m,f,r;
    while(true){
        cin >> m >> f >> r;
        
        if (m == -1 && f == -1 && r == -1)
            break;
        
        if (m == -1 || f == -1){
            cout << "F" << endl;
            continue;
        }
            
        int sum = m + f;
        
        if (sum >= 80)
            cout << "A" << endl;
        else if (sum >= 65)
            cout << "B" << endl;
        else if (sum >= 50 || (sum >= 30 && r>= 50))
            cout << "C" << endl;
        else if (sum >= 30)
            cout << "D" << endl;
        else
            cout << "F" << endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int ,int> pi;
typedef pair<ll ,ll> pl;
typedef map<ll ,ll> ml;
#define modulo 1000000007
#define maxN 10000001
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve()
{ 
    int n,k;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i=0;i<n;i++)cin >> arr[i];
    sort(arr.begin(),arr.end());
    int sum=0;
    for(int i=0;i<k;i++)sum+=arr[i];
    cout << sum << endl;
}

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

Measured memory_bytes: 3660
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10桁出力 cout << setprecision(10) << double;
#include <queue>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	int N;
	LL ans = 0;
	

	cin >> N;
	VI L(2*N+1,0);
	FOR(i, 0, 2*N) {
		cin >> L[i];
	}
	sort(L.begin(), L.end(), std::greater<int>());
	for(int i=0; i<2*N;i+=2) {
		LL tempa = L[i];
		LL tempb = L[i + 1];
		ans += min(tempa, tempb);
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import sys

if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))

    min_num = min(a)
    max_num = max(a)

    if max_num - min_num >= 2:
        print("No")
    elif max_num == min_num :
        if max_num == N -1 or 2*max_num <= N:
            print("Yes")
        else:
            print("No")
    else:
        x = a.count(min_num)
        y = a.count(max_num)
        if x < max_num and 2 * (max_num - x) <= y:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 13964
#include <stdio.h>

int main(void){
    int a, b, i;
    char res[100];
    scanf("%d %d", &a, &b);
    
    if(a > b){
        for(i = 0; i < a; i++){
            res[i] = b + '0';
        }
    }else{
        for(i = 0; i < b; i++){
            res[i] = a + '0';
        }
    }
    res[i] = '\0';
    
    printf("%s", res);
    
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atCocderCs
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var lst = new List<int[]>();
            for (int i = 1; i < N; i++)
                lst.Add(Console.ReadLine().Split(' ').Select((v) => int.Parse(v)).ToArray());

            for (int i = 0; i < N; i++)
            {
                int now = 0;
                for (int t = i; t < N - 1; t++)
                {
                    var info = lst[t];
                    now = NextArriveTime(info[0], info[1], info[2], now);
                }
                Console.WriteLine(now);
            }

        }

        static int NextArriveTime(int c, int s, int f, int now)
        {
            if (now > s)
            {
                var d = Convert.ToInt32(Math.Ceiling((now - s) / (double)f));
                return s + d * f + c;
            }
            else
            {
                return s + c;
            }
        }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>

#define MAX_N 1000

int h[MAX_N] = {0};
double kion[MAX_N] = {0};
double sa[MAX_N]  = {0};

int main(void) {

  int n,t,a;
  int k;
  int temp;
  double min;
  int min_p;
  
  scanf("%d %d %d", &n,&t,&a);


  for (k = 0; k < n; k++) {
    scanf("%d",&temp);
    h[k] = temp;
  }

  for (k = 0; k < n; k++) {
    kion[k] = (t - (h[k] * 0.006))+0.0;
    if (a  > kion[k]) {
      sa[k] = (a - kion[k])+0.0;
    } else {
      sa[k] = (kion[k] - a)+0.0;
    }
  }

  min = sa[0];
  min_p = 0;

  for (k = 1; k < n; k++) {
    if (min > sa[k]) {
      min = sa[k];
      min_p = k;
    }
  }
  /*  
  for (k = 0; k < n; k++) {
    printf("%f ",sa[k]);
  }
  */
  printf("%d",min_p+1);

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
long long a[n];
for(long long i=0;i<n;i++){
    cin>>a[i];
}
int ans=0;
for(long long i=0;i<n;i++){
    if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0){
        ans=1;
        break;
    }
}
if(ans==0){
    cout<<"APPROVED"<<endl;
}
else{
    cout<<"DENIED"<<endl;
}

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int ans=n;
    if(n==2){
        cout<<2<<endl;
        return 0;
    }
    int a=sqrt(n);
    while(true){
        rep(i,a){
            if(ans%(i+2)==0){
                break;
            }
            if(i==a-1){
                cout<<ans<<endl;
                return 0;
            }
        }
        ans++;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << H2 * 60 + M2 - (H1 * 60 + M1) - K << endl;
}

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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	string s;
	cin >> s;
	int ans = count_if(all(s), [](char c) { return c == '2'; });
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    B = [0 for _ in range(N)]
    for i in range(N - 1, N // 2 - 1, -1):
        B[i] = A[i]
    for i in range(N // 2 - 1, -1, -1):
        res = 0
        for j in range(i, N, i + 1):
            res += B[j]
        if res % 2 == 0 and A[i] == 1:
            B[i] = 1
        elif res % 2 != 0 and A[i] == 0:
            B[i] = 1

    cnt = 0
    for b in B:
        if b == 1:
            cnt += 1
    print(cnt)
    if cnt > 0:
        res = [i + 1 for i, b in enumerate(B) if b != 0]
        print(*res)


Measured memory_bytes: 72456
def ABC_79_B():
    N=int(input())
    l = [0 for _ in range(N*2)]
    l[0]=2
    l[1]=1

    for i in range(N-1):
        if N==1:
            print(l[1])
            break
        else:
            l[i+2] = l[i]+l[i+1]

    print(l[N])

if __name__ == '__main__':

    ABC_79_B()

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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n,x,t;
		cin>>n>>x>>t;
		n = (n+x-1)/x;
		n*=t;
		cout<<n;		
    }
    return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,x) for(auto& a: x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()

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

int main(){
	int n;cin>>n;
	rep(i,1,10){
		rep(j,1,10){
			if(i*j==n){cout<<"Yes";return 0;}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define db double
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353
 
const ll N=1e9+7;
 
int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}
 
ll solve(){
    
    return 0;
}
 
signed main(){
    IOS
// 	#ifndef ONLINE_JUDGE
//     	freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	#endif
    string s;
  cin>>s;
  ll ans=0;
  rep(i,1,10){
    char c='0'+i;
    ll a=count(all(s),c);
    ans+=(a*i)%9;
  }
  if((ans%9)%9)cout<<"No";
  else cout<<"Yes";
    return 0;
}
// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

    int A, B, C;
    cin >> A >> B >> C;
    cout << A + B + C + max({A, B, C}) * 9 << endl;

    return 0;
}


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

int main(){
  int c[3][3];
  int i,j;

  for(i=0; i<3; i++){
    for(j=0; j<3; j++){
      cin >> c[i][j];
    }
  }

  bool flg=false;

  for(i=0; i<3; i++){
    if(flg)  break;
    if(c[i][0]-c[(i+1)%3][0]==c[i][1]-c[(i+1)%3][1] && c[i][1]-c[(i+1)%3][1]==c[i][2]-c[(i+1)%3][2]){
      continue;
    }else{
      flg=true;
    }
  }
  for(i=0; i<3; i++){
    if(flg)  break;
    if(c[0][i]-c[0][(i+1)%3]==c[1][i]-c[1][(i+1)%3] && c[1][i]-c[1][(i+1)%3]==c[2][i]-c[2][(i+1)%3]){
      continue;
    }else{
      flg=true;
    }
  }
  if(flg) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

int main(void){
  int a[3] = { 0 };
  int b[3];
  int temp;
  for(int i = 0; i < 3; i++) scanf("%d" , &a[i]);
  b[0] = abs(a[0] - a[1]);
  b[1] = abs(a[1] - a[2]);
  b[2] = abs(a[2] - a[0]);
  for(int i = 0; i < 3; i++){
    for(int j = i + 1; j < 3; j++){
      if(b[i] < b[j]){
	temp = b[i];
	b[i] = b[j];
	b[j] = temp;
      }
    }
  }

  printf("%d\n", b[1] + b[2]);
  return 0;
}

Measured memory_bytes: 128