akhauriyash/Code-Regression huggingface dataset:
n=input()

n1=int(n[0])
n2=int(n[1])
n3=int(n[2])
n4=int(n[3])

if n1+n2+n3+n4==7:
    print ("{}+{}+{}+{}=7".format(n1,n2,n3,n4))
    exit()
elif n1+n2+n3-n4==7:
    print ("{}+{}+{}-{}=7".format(n1,n2,n3,n4))
    exit()
elif n1+n2-n3+n4==7:
    print ("{}+{}-{}+{}=7".format(n1,n2,n3,n4))
    exit()    
elif n1+n2-n3-n4==7:
    print ("{}+{}-{}-{}=7".format(n1,n2,n3,n4))
    exit() 
elif n1-n2-n3-n4==7:
    print ("{}-{}-{}-{}=7".format(n1,n2,n3,n4))
    exit()
elif n1-n2-n3+n4==7:
    print ("{}-{}-{}+{}=7".format(n1,n2,n3,n4))
    exit()
elif n1-n2+n3-n4==7:
    print ("{}-{}+{}-{}=7".format(n1,n2,n3,n4))
    exit()
elif n1-n2+n3+n4==7:
    print ("{}-{}+{}+{}=7".format(n1,n2,n3,n4))
    exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007

using namespace std;

void dfs(vector<int> v[],bool f[],int x) {
	f[x] = 1;
	
	for(auto it:v[x]) {
		if(f[it] == 0) {
			dfs(v,f,it);
		}
	}
}

void input() {
	int n,m;
	cin>>n>>m;
	
	vector<int> v[n];
	for(int i=0;i<m;i++) {
		int a,b;
		cin>>a>>b;
		
		a -= 1;
		b -= 1;
		
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	bool f[n];
	memset(f,0,sizeof(f));
	
	int ans=0;
	
	for(int i=0;i<n;i++) {
		if(f[i] == 0) {
			ans++;
			dfs(v,f,i);
		}
	}
	
	ans -= 1;
	cout<<ans<<"\n";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	input();

	return 0;
}



Measured memory_bytes: 10088
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
													 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 998244353;
const ll maxn = 1000005;
const ll mm = 1e+18;
void solve()
{
	int a,b;
	cin>>a>>b;
	cout<<a*b;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    int m1 = 0, m2 = -1;
    REP(i, N) if(A[m1] < A[i]) m1 = i;
    REP(i, N) if(i != m1 && A[m2] < A[i]) m2 = i;
    REP(i, N)
    {
        if(i == m1) cout << A[m2] << endl;
        else cout << A[m1] << endl;
    }
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>

int gcd(int a, int b){
  if(b<a) std::swap(a, b);
  int r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}

int cnt[1000001];
int main(){
  int n;scanf("%d", &n);
  int o = 0, g;
  for(int i=0;i<n;i++){
    int num;scanf("%d", &num);
    if(num==1) o++;
    if(i==0) g = num;
    else g = gcd(g, num);
    cnt[num]++;
  }
  if(n - o > 80000){
    if(g==1) printf("setwise coprime\n");
    else printf("not coprime\n");
    return 0;
  }

  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    int S = 0;
    for(int j=i;j<=1000000;j+=i) S += cnt[j];
    max_S = std::max(max_S, S);
  }
  if(max_S<2) printf("pairwise coprime\n");
  else if(max_S != n) printf("setwise coprime\n");
  else printf("not coprime\n");
}


Measured memory_bytes: 7576
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

long long gcd(long long m, long long n) {
  if (m < n)
    return gcd(n, m);
  if (n == 0)
    return m;
  return gcd(n, m % n);
}

void solve(long long N, long long K, std::vector<long long> A) {
  ll maxNum = 0;
  rep(n, N) { maxNum = max(maxNum, A[n]); }

  if (maxNum < K) {
    print(NO);
    return;
  }

  ll gcdNum = A[0];
  for (ll i = 1; i < N; i++) {
    gcdNum = gcd(gcdNum, A[i]);
  }

  if (K % gcdNum == 0) {
    print(YES);
  } else {
    print(NO);
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    ll N, M;
    cin >> N >> M;

    vector<pair<ll,ll>> v(N);
    REP(i,N) cin >> v[i].first >> v[i].second;

    sort(ALL(v));

    //REP(i,N) cout << v[i].first << " " << v[i].second << endl;

    ll ans = 0;
    REP(i,N){
        ll buy = min(M,v[i].second);
        ans += buy*v[i].first;
        M -= buy;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
from collections import Counter

N = int(input())

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

mod = 1000000007

isok=True
for a in A:
    if a%2==0:
        if a==0:
            if A[a]!=1:
                isok=False
                break
        elif (N-1)%2!=0 or A[a]!=2:
                isok=False
                break
    else:
        if (N-1)%2!=1 or A[a]!=2:
            isok=False
            break

if isok:
    ans = 1
    for i in range(N//2):
        ans = (ans*2)%mod
    print(ans)
else:
    print(0)

Measured memory_bytes: 14820
import math

def is_prime(n):
    if n == 1:
        return False
    if not isinstance(n,int):
        return False
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

N=int(input())

prime = []
for i in range(55555):
    if is_prime(i+1):
        prime.append(i+1)

prime_5 = []
for i in range(len(prime)):
    if prime[i] % 5 == 1:
        prime_5.append(prime[i])

for i in range(N):
    print(prime_5[i],end=" ")

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll n,k,l;
ll inf=0xffffffffffff;
vector<ll> a(200005,0);
bool judge(ll t){
  vector<ll> rsum(200005,inf);
  rsum[0]=0;
  ll ret=0;
  for(int i=1;i<=n;i++){
    rsum[i]=rsum[i-1];
    if(a[i]<=t) rsum[i]++;
  }
  int st,gr;
  for(st=1;st+k<=n+1;st++){
    gr=lower_bound(rsum.begin(),rsum.end(),k+rsum[st-1])-rsum.begin();
    gr=max(st+(int)k-1,gr);
    ret+=n+1-gr;
    //cout<<st<<" "<<ret<<" / ";
  }
  //cout<<" /"<<t<<" "<<ret<<endl;
  return ret>=l;
}
int main(){
  cin>>n>>k>>l;
  for(int i=1;i<=n;i++) cin>>a[i];
  ll lb=0,rb=n+100;
  while(rb-lb>1){
    int mid=(lb+rb)/2;
    if(judge(mid)) rb=mid;
    else lb=mid;
  }
  cout<<rb<<endl;
}



Measured memory_bytes: 6008
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int x, y;
    while(cin >> x >> y){
        if(x < y){
            int temp = x;
            x = y;
            y = temp;
        }
        while(y != 0){
            int a, b;
            a = y;
            b = x % y;
            x = a;
            y = b;
        }
        cout << x << endl;
    }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}
ll modexpo(ll a, ll b, ll m) {if (b == 0) {return 1;} else if (a == 1) {return 1;} if (b % 2 == 0) {ll t = modexpo(a, b / 2, m); t = (t * t) % m; return t;} else {ll t = modexpo(a, b / 2, m); t = (t * t) % m; t = (t * a) % m; return t;}}










int main() {

    // taskkill /IM "cp.exe" /F
    fast



    // memset(dp, -1, sizeof(dp));
    int n;
    cin >> n;
    double a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    double dp[n + 1][n + 1];
    // print(a, n);
    // cout << n << endl;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (i == 0 ) {
                dp[i][j] = 1.0;
            }
            else if (j == 0) {
                double op1 = dp[i - 1][j];
                op1 = op1 * (1.0 - a[i - 1]);
                dp[i][j] = op1 ;
            }
            else {
                double op1 = 0;
                if (j <= (i - 1)) {
                    op1 = dp[i - 1][j];
                    op1 = op1 * (1.0 - a[i - 1]);
                }


                double op2 = dp[i - 1][j - 1];
                op2 = op2 * (a[i - 1]);

                dp[i][j] = op1 + op2;
            }

        }
    }
    // for (int i = 0; i <= n; i++) {
    //     print(dp[i], i + 1);
    // }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(14) << ans << endl;
}

Measured memory_bytes: 49912
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
string s;
cin>>s;
int cnt=0;
for(int i=0;i<n-2;i++)
{
	if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
		cnt++;
}	
cout<<cnt;
}
int main()
{
//code
	int t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


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

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            Console.WriteLine(Enumerable.Range(input[0], input[1] - input[0] + 1).Count(p => (input[2] % p) == 0));
        }
    }
}

Measured memory_bytes: 5928
n, x, m = map(int, input().split())
tmp = x
t = [0] * m
cnt = 0
s = 0
while t[x] == 0:
    t[x] += 1
    cnt += 1
    s += x
    x = x * x % m
k = tmp
cnt2 = 0
ans2 = 0
while k != x:
    cnt2 += 1
    ans2 += k
    k = k * k % m
if n <= cnt2:
    s = 0
    x = tmp
    for i in range(n):
        s += x
        x = x * x % m
    print(s)
else:
    n -= cnt2
    s = (s - ans2) * (n // (cnt - cnt2))
    for i in range(n % (cnt - cnt2)):
        s += x
        x = x * x % m
    print(s + ans2)


Measured memory_bytes: 65100
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)

	if x >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1768
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=310;
const int mod=1000000007;
int n,m,f[maxn][maxn][maxn];
vector<pii> G[maxn];
int check(int i,int j,int k) {
	int p=max(i,max(j,k));
	rep(z,0,G[p].size()-1) if((i>=G[p][z].xx)+(j>=G[p][z].xx)+(k>=G[p][z].xx)!=G[p][z].yy) return 0;
	return 1;
}
int main() {
	n=read();m=read();
	rep(i,1,m) {
		int l=read(),r=read(),v=read();
		G[r].pb(mp(l,v));
	}
	f[0][0][0]=1;
	int ans=0;
	rep(i,0,n) rep(j,0,n) rep(k,0,n) if(check(i,j,k)) {
		int p=max(i,max(j,k));
		if(p==n) (ans+=f[i][j][k])%=mod;
		(f[p+1][j][k]+=f[i][j][k])%=mod;
		(f[i][p+1][k]+=f[i][j][k])%=mod;
		(f[i][j][p+1]+=f[i][j][k])%=mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 114944
const mod=10^9+7
const LIM=2<<20
const F=zeros(Int,LIM)
const I=zeros(Int,LIM)
function power(a,b)
	b==0 ? 1 : power(a*a%mod,div(b,2))*(b%2==1 ? a : 1)%mod
end
function init()
	F[1]=1
	for i=1:LIM-1
		F[i+1]=F[i]*i%mod
	end
	I[LIM]=power(F[LIM],mod-2)
	for i=LIM-1:-1:1
		I[i]=I[i+1]*i%mod
	end
end
function f(R,C)
	ret=0
	for c=0:C
		ret+=F[c+R+2]*I[c+2]%mod*I[R+1]%mod
		ret%=mod
	end
	ret
end
function main()
	init()
	r1,c1,r2,c2=map(x->parse(Int,x),split(readline()))
	ans=f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1)
	println((ans%mod+mod)%mod)
end
main()


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

using namespace std;

typedef long long ll;

const ll MAX_N = 1100;
const ll INF = 1e12;

vector<pair<ll, ll> > g[MAX_N]; // firstに最短距離, secondに頂点番号
ll d[MAX_N];
int n; // 頂点数

bool used[MAX_N][MAX_N];

int pr[MAX_N]; // 最短路の直前の頂点

// bellman ford法で負辺がない場合。計算量はO(|E|log|V|)
void dijkstra(int s){
  priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > PQ;
  for(int i=1;i<=n;i++) d[i] = INF;
  for(int i=1;i<=n;i++) pr[i] = -1;
  d[s] = 0;
  PQ.push(make_pair(0, s));

  while(!PQ.empty()){
    pair<ll, ll> p = PQ.top(); PQ.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto gvi: g[v]){
      ll cost = gvi.first;
      int u = gvi.second;
      if(d[u] > d[v] + cost){
        d[u] = d[v] + cost;
        PQ.push(make_pair(d[u], u));
        pr[u] = v;
      }
    }
  }
}

// 頂点tへの最短路
void get_path(int t){
  for(;t!=-1;t=pr[t]){
    used[t][pr[t]] = true;
    used[pr[t]][t] = true;
  }
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int m; cin >> n >> m;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      used[i][j] = true;
    }
  }
  for(int i=0;i<m;i++){
    ll a, b, c; cin >> a >> b >> c;
    g[a].push_back(make_pair(c, b));
    g[b].push_back(make_pair(c, a));
    used[a][b] = false;
    used[b][a] = false;
  }
  for(int i=1;i<=n;i++){
    dijkstra(i);
    for(int j=i+1;j<=n;j++){
      // cout << i << " " << j << " " << d[j] << endl;
      get_path(j);
    }
  }
  int cnt = 0;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(used[i][j] == false) cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main() {
  string N;

  vector<int> cnt(26);
  while (cin >> N) {
    for (int i = 0; i < N.size(); i++) {
      if (N.at(i) - 'a' >= 0 && N.at(i) - 'a' <= 26)
        cnt.at(N.at(i) - 'a')++;
      else if (N.at(i) - 'A' >= 0 && N.at(i) - 'A' <= 26)
        cnt.at(N.at(i) - 'A')++;
    }
  }

  for (int i = 0; i < 26; i++) {
    cout << (char)('a' + i) << ' ' << ':' << ' ' << cnt.at(i) << endl;
  }
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += l.at(N-1-i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static int selectionSort(int A[],int N){
        int count = 0;
        for (int i = 0; i<N-1;i++){
            int minj = i;
            for (int j = i;j<N;j++){
                if (A[j]<A[minj])
                {
                    minj = j;
                }
            }
            int temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
            if (i!= minj){ count++;}
        }
        return count;
    }


    public static void main(String[]args){
       int A[] = new int[100];
        int count = 0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        for (int i = 0; i<N; i++){
            A[i] = scanner.nextInt();
        }
        count = selectionSort(A,N);

        for (int i = 0; i<N; i++){
            if (i>0){
                System.out.print(" ");
            }
            System.out.print(A[i]);
        }
        System.out.println();
        System.out.println(count);
    }
}



Measured memory_bytes: 26316
#include <iostream>

int main()
{
    unsigned long long h;
    int n;
    std::cin>>h>>n;
    unsigned long long s=0;
    for(int i=0; i<n; i++)
    {
        int x;
        std::cin>>x;
        s+=x;
    }
    if (s>=h) std::cout<<"Yes";
    else std::cout<<"No";
    return 0;
}

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

typedef uint32_t u32;
typedef uint64_t u64;
typedef std::pair<int, int> pii;

int main() {

  int N;
  std::cin >> N;
  int res = 0;
  N -= 1;
  while( N != 0 ) {
    res += 1;
    N /= 3;
  }

  std::cout << res << std::endl;

  return 0;
}

Measured memory_bytes: 3092
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k):
    s = [0]*n
    for i,d in enumerate(a):
        if d==0:
            s[i] += 1
            if i+1<=n-1:
                s[i+1] -= 1
        else:
            s[max(0,i-d)] += 1
            if i+d+1<=n-1:
                s[min(n-1, i+d+1)] -= 1
    ss = [0]*n
    tmp = 0
    for i,num in enumerate(s):
        tmp += num
        ss[i] = tmp
    if all(t==v for t,v in zip(a,ss)):
        break
    a = ss
    
write(" ".join(map(str, a)))

Measured memory_bytes: 170308
#include <stdio.h>

int main(void) {
	int a, b, i, sum, x=0;
	
	while(1){

	
		scanf("%d %d", &a, &b);
		if(a==0 && b==0)
		break;
		
				if(x!=0){
			printf("\n");
		}
		
		else
		x=1;
		
		sum=0;
		
		for(i=a;i<=b;i++){
			if((i%4==0 && i%100!=0) || i%400==0){
			printf("%d\n", i);
			sum++;
		}
		}
		if(sum==0)
		printf("NA\n");
		
		
	}
	
	return 0;
}

Measured memory_bytes: 616
#include <stdio.h>
#include <queue>

using namespace std;

int n,inputed_order[41] = {0};
queue<int> Queue;

struct Node{
	Node(){
		left_child = right_child = -1;
	};
	int left_child,right_child;
};

void postORDER(Node order[],int id){
	if(order[id].left_child != -1) postORDER(order,order[id].left_child );
	if(order[id].right_child != -1) postORDER(order,order[id].right_child );
	Queue.push(id+1);
}

int findRoot(int inorder[],int left,int right){
	int root = inorder[left];
	for(int i = left+1; i <= right; i++){
		if(inputed_order[root] > inputed_order[inorder[i]]){
			root = inorder[i];
		}
	}
	return root;
}

void reconstruct(int inorder[],Node order[],int root,int left,int right){
	int root_index;
	for(root_index = left; inorder[root_index] != root; root_index++);
	if(left < root_index){
		int new_root = findRoot(inorder,left,root_index-1);
		order[root-1].left_child = new_root-1;
		if(left < root_index-1)	reconstruct(inorder,order,new_root,left,root_index-1);
	}
	if(root_index < right){
		int new_root = findRoot(inorder,root_index+1,right);
		order[root-1].right_child = new_root-1;
		if(root_index+1 < right) reconstruct(inorder,order,new_root,root_index+1,right);
	}
}

int main(){
	scanf("%d",&n);
	int preorder[n],inorder[n];
	Node order[n];

	for(int i = 0; i < n; i++){
		scanf("%d",&preorder[i]);
		inputed_order[preorder[i]] = i;
	}
	for(int i = 0; i < n; i++){
		scanf("%d",&inorder[i]);
	}

	if(n == 1){
		printf("%d\n",preorder[0]);
	}else{
		reconstruct(inorder,order,preorder[0],0,n-1);
		postORDER(order,preorder[0]-1);
		while(!Queue.empty()){
			if(Queue.size() != 1){
				printf("%d ",Queue.front());
				Queue.pop();
			}else{
				printf("%d\n",Queue.front());
				Queue.pop();
			}
		}
	}

}



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

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

    char ans = '1';
    if (k == 1 || s.size() == 1)
        ans = s[0];
    else {
        rep(i, s.size()) {
            if (s[i] != '1') {
                ans = s[i];
                break;
            }
        }
    }

    if (k <= s.size()) {
        bool one = true;
        rep(i, k) if (s[i] != '1') one = false;
        if (one) ans = '1';
    }

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


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> nus(n, false);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            nus.at(a - 1) = true;
        }
    }
    int cnt = 0;
    for (auto a : nus) {
        if(!a)
            cnt++;
    }
    cout << cnt << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);
  
  vector<int> B(N);
  rep(i, N) B.at(A.at(i) - 1) = i + 1;
  rep(i, N) cout << B.at(i) << " ";
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  REP(i, l, r+1){
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int check[b+1],i;
  for(i=0;i<b;i++)
    check[i]=0;
  a%=b;
  i=0;
  while(check[i]==0){
    check[i]++;
    i=(i+a)%b;
  }
  if(check[c]==0)
    puts("NO");
  else
    puts("YES");
  return 0;
}

Measured memory_bytes: 1604
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 998244353;




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

  int n, kk; cin >> n >> kk;
  vector<P> point(n);
  vector<int> x(n);
  vector<int> y(n);
  rep(i, n) {
    cin >> x.at(i) >> y.at(i);
    point.at(i) = P(x.at(i), y.at(i));
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  ll ans = LONG_MAX;
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      for(int k=0; k<n; k++) {
        for(int l=k+1; l<n; l++) {
          ll xmin = x.at(i); //debug(xmin);
          ll xmax = x.at(j); //debug(xmax);
          ll ymin = y.at(k); //debug(ymin);
          ll ymax = y.at(l); //debugln(ymax);
          int cnt = 0;
          rep(m, n) {
            ll xx = point.at(m).first;
            ll yy = point.at(m).second;
            if (xmin <= xx && xx <= xmax && ymin <= yy && yy <= ymax) {
              cnt++;
            }
          }
          //debugln(cnt);
          if (cnt >= kk) {
            ans = min(ans, (xmax-xmin)*(ymax-ymin));
          }
        }
      }
    }
  }


  cout << ans << endl;

}

Measured memory_bytes: 256
function Main(arg) {
  var n = arg.split("\n")[0].split("");

  var ans = [];
  for (var i = 0; i < n.length; i++){
    if (n[i] === "B") {
      ans.pop();
    }
    else {
      ans.push(n[i]);
    }
  }

  console.log(ans.join(""));
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define MX 100005
#define f .first
#define s .second
#define pb .push_back
 
using namespace std;

vector<int>v[MX];
int d[MX];
int dp(int a){
    if(d[a]==-1){
        if(v[a].empty()){
            d[a]=0;
            return 0;
        }
        int mx=0;
        rep(i,v[a].size()){
            mx=max(dp(v[a][i]),mx);
        }
        d[a]=1+mx;
    }
    return d[a];
}
int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a]pb(b);
    }
    memset(d,-1,sizeof(d));
    int ans=0;
    rep(i,n){
        ans=max(ans,dp(i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<string>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

ll a, b, c, k;

int main() {
	
	// freopen("in.in", "r", stdin);
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	if (k <= a) printf("%lld\n", k);
	else if (k <= a + b) printf("%lld\n", a);
	else if (k <= a + b + c) printf("%lld\n", a -(k - (a + b)));
	else printf("%lld\n", a - c);

	return 0;
}		


Measured memory_bytes: 3256
import bisect
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    a = sorted(a)
    b = sorted(b)
    c = sorted(c)

    ans = 0

    for i in range(len(b)):
        a_index = bisect.bisect_left(a, b[i])
        c_index = bisect.bisect_right(c, b[i])
        a_num = 0
        c_num = 0
        if a_index == len(a):
            a_num = len(a)
        else:
            if a[a_index] == b[i]:
                a_num = a_index 
            else:
                a_num = a_index 
        
        if c_index == len(c):
            c_num = 0
        else:
            c_num = len(c) - c_index
        ans += a_num * c_num
    print(ans)

Measured memory_bytes: 24052
#include <stdio.h>

int	main(void)
{
	unsigned long long	H, W, sq;

	scanf("%llu %llu", &H, &W);
	if (H == 1 || W == 1)
	{
		printf("%d", 1);
		return (0);
	}
	sq = H * W;
	if (sq % 2 == 0)
		printf("%llu", sq / 2);
	else
		printf("%llu", sq / 2 + 1);
	return (0);
}


Measured memory_bytes: 128
n,k = map(int,input().split())
l = list(map(int,input().split()))
a = [0]*n
a[1] = abs(l[0]-l[1])
i = 2
while(i < len(a)):
    e = i-k
    ma = 10**10
    j = i-1
    while(j > -1 and j >= e):
        r = a[j]+abs(l[i]-l[j])
        ma = min(ma,r)
        j = j-1

    a[i] = ma
    i = i+1

#print(a)
print(a[-1])

Measured memory_bytes: 84852
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] a = new String[h];

		for (int i = 0; i < h; i++) {
			a[i] = sc.next();
		}

		sc.close();

		for (int i = 0; i < w + 2; i++) {
			System.out.print("#");
		}
		System.out.println("");

		for (int i = 0; i < h; i++) {
			System.out.print("#");
			System.out.print(a[i]);
			System.out.println("#");
		}

		for (int i = 0; i < w + 2; i++) {
			System.out.print("#");
		}
		System.out.println("");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N, M;  cin >> N >> M;
    vector<string> A(N); rep(i, N) cin >> A[i];
    vector<string> B(M); rep(i, M) cin >> B[i];

    int m = N - M + 1;
    rep(i, m) {
        rep(j, m) {
            bool flag = true;
            rep(k, M) {
                if (A[i+k].substr(j, M) != B[k]) {
                    flag = false;
                }
            }
            if (flag) {
                yes;
                return 0;
            }
        }
    }

    no;
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int i,j,e[4];
	for(i=0;i<4;i++)
		scanf("%d",&e[i]);
	for(i=0;i<3;i++){
		for(j=3;j>i;j--){
			if(e[j-1]>e[j]){
				int tmp=e[j-1];
				e[j-1]=e[j];
				e[j]=tmp;
			}
		}
	}
	if(e[0]==e[1]&&e[2]==e[3])
		puts("yes");
	else
		puts("no");
	return 0;
}

Measured memory_bytes: 580
/*
  A - Restaurant
  Contest 055
  Rakesh Kumar --> 16/08/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;

    std::cout << (n * 800) - ((n / 15) * 200) << std::endl;

    return 0;
}


Measured memory_bytes: 3600
n,m=map(int,input().split())
num = [1]*(n + 1)
pena = [0]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC':
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
            WA_cnt += pena[int(p)]
    else:
        pena[int(p)] += 1
print(AC_cnt,WA_cnt)


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

int a[101];
int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 0;i < n;i++)scanf("%d", &a[i]);
	int ans = 0;
	for(int i = 0;i < n;i++){
		ans += min(a[i], abs(a[i]-k));
	}
	printf("%d\n", ans*2);
	return 0;
}

Measured memory_bytes: 256
n,y = map(int,input().split())
for i in range(y//10000+1):
	for j in range(y//5000+1):
		k = n - i - j
		if k >= 0 and 10000*i + 5000*j + 1000*k == y:
			print(i,j,k,sep=" ")
			exit()
print('-1 -1 -1')


Measured memory_bytes: 9168
from collections import deque
n = int(input())
*a, = map(int, input().split())
b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 == 1:
    b.reverse()

print(" ".join([str(v) for v in b]))


Measured memory_bytes: 125980
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;bool flag=true;
  cin >> n;
  int a[n];int k;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i==0) k=a[0];
    if(k!=a[i]) flag=false;
  }
  int sum=0;int ans=100000000;
  if(flag) cout << 0 <<endl;
  else{
      for(int i=-100;i<=100;i++){
        for(int j=0;j<n;j++){
          sum+=(a[j]-i)*(a[j]-i);
        }
        ans=min(sum,ans);
        sum=0;
      }
      cout << ans<<endl;
  }
}


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

int main() {
  int K, N;
  cin >> N >> K;
  
  vector<int> h(N);
  for (int i=0; i<N; i++) {
    cin >> h.at(i);
  }
  
  sort(h.begin(), h.end());
  int gap=1000000000;
  
  for (int i=K-1; i<N; i++){
    if (h.at(i)-h.at(i-K+1) < gap) {
      gap = h.at(i)-h.at(i-K+1);
    }
  }
  cout << gap << endl;
        
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.math.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static ArrayList<Long>[] al;
	static int maxn=101;
	static Pair[] a;
	static Map<Long,Long> m1=new HashMap<>();
	static Map<Long,Long> m2=new HashMap<>();
	
	@SuppressWarnings("unchecked")
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt(),w=sc.nextInt();long ctr=0;a=new Pair[n];
		
		for(int i=0;i<n;i++)
		{
			a[i]=new Pair(sc.nextInt(),sc.nextInt());
			
			if(m1.get(a[i].a)==null)
			{
				m1.put(a[i].a,ctr);
				
				m2.put(ctr++,a[i].a);
			}
		}
		
		while(m2.size()<4)
		{
			m1.put(0L,ctr);m2.put(ctr++,0L);
		}
		
		int m=4;al=new ArrayList[m];
		
		for(int i=0;i<m;i++)
		{
			al[i]=new ArrayList<Long>();
		}
		
		for(int i=0;i<n;i++)
		{
			int curr = (int)(long)m1.get(a[i].a);
			
			al[curr].add(a[i].b);
		}
		
		long[][] pre=new long[m][n+1];
		
		for(int i=0;i<m;i++)
		{
			Collections.sort(al[i],Collections.reverseOrder());long sum=0;
			
			for(int j=0;j<al[i].size();j++)
			{
				sum+=al[i].get(j);
				
				pre[i][j+1]=sum;
			}
		}
		
		long res=0;
		
		for(int i=0;i<=al[0].size();i++)
		{
			for(int j=0;j<=al[1].size();j++)
			{
				for(int k=0;k<=al[2].size();k++)
				{
					long val1=(m2.get(0L)*i)+(m2.get(1L)*j)+(m2.get(2L)*k);
					
					if(val1<=w)
					{
						long now=w-val1;
						
						long curr = pre[0][i]+pre[1][j]+pre[2][k];res=Math.max(res,curr);
						
						for(int x=0;x<=al[3].size();x++)
						{
							long now2 = (x*m2.get(3L));
							
							if(now2<=now)
							{
								res=Math.max(res,curr+pre[3][x]);
							}
						}
					}
				}
			}
		}
		
		out.println(res);out.close();
    }
}

class Pair
{
	long a,b;
	
	public Pair(long a,long b)
	{
		this.a=a;this.b=b;
	}
}

class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 23120
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int x,y;
    int a;
    cin >> x >> y;
    FOR(i,0,x){
        a = x-i;
        if(2*i+4*a == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3564
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	
	String INPUT = "";
	
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		out.flush();
	}
	
	void solve(Scanner sc, PrintWriter out) {
		int a,b;
		
		a = sc.nextInt();
		b = sc.nextInt();
		int d = a/b;
		int r = a%b;
		double f = (double)a/(double)b;
		System.out.println(d + " " + r + " " + String.format("%.5f", f));
	}
}



Measured memory_bytes: 26612
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define LL long long

using namespace std;

LL read()
{
	LL ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

const int N=2e5+5;
LL n,a[N],k,ans;

int main()
{
	n=read();k=read();
	for(int i=1;i<=n;++i)
		a[i]=read();
	sort(a+1,a+1+n);
	for(int i=1;i<=n-k;++i)
		ans+=a[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    sort(x.begin(), x.end(), [](int a, int b) {
        return a > b;
        });

    int sumA = 0, sumB = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            sumA += x[i];
        }
        else {
            sumB += x[i];
        }
    }

    cout << (sumA - sumB) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long n;
int main() {
    cin >> n;
    long long x = 1; long long y = 1;
    for(int i = 0; i < n; ++i) {
        long long t, a;
        cin >> t >> a;
        long long m = max((x+t-1)/t, (y+a-1)/a);
        x = t*m; y = a*m;
        // cout << x << " " << y << endl;
    }
    cout << x+y << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

template<typename T>
T gcd(T m, T n)
{
	T temp = m;
	temp %= n;
	while (temp) {
		m = n;
		n = temp;
		temp = m%n;
	}
	return n;
}

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, p;
	std::cin >> n >> p;
	std::vector<uint32> a(n);
	uint64 c1 = 0, c0 = 0;
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i];
		if (a[i] & 1) ++c1;
		else ++c0;
	}
	uint64 ans = 0;
	ans += (uint64)1 << c0;
	if (p) {
		if (c1 == 0) {
			ans = 0;
		}
		else {
			ans *= (uint64)1 << (c1 - 1);
		}
	}
	else {
		if (c1 != 0) {
			ans *= (uint64)1 << (c1 - 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 764
N=int(input())
A=[int(i) for i in input().split()]
B=[0]*N
mod=10**9+7
B[0]=A[0]
for i in range(1,N):
    B[i]=A[i]^B[i-1]
F=[0]*(1<<20)
dp=[1]*(1<<20)
dp1=[0]*(1<<20)
x=1
#print(B)
for i in range(N):
    if B[i]==0:
        x+=1
    dp[B[i]]+=dp1[B[i]]*(x-F[B[i]])
    dp[B[i]]%=mod
    dp1[B[i]]+=dp[B[i]]
    dp1[B[i]]%=mod
    F[B[i]]=x
    #print(dp[:16],dp1[:16])
#print(dp[:10],B,x)
if B[-1]!=0:
    print(dp[B[-1]])
else:
    ans=pow(2,x-2,mod)
    for i in range(1,1<<20):
        ans+=dp1[i]
        ans%=mod
    print(ans)

Measured memory_bytes: 128116
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLong()
  var cnt = 0
  var cur = 100L
  while (cur < n) {
    cnt += 1
    cur += cur / 100
  }
  println(cnt)

  def readIntPair: (Int, Int) = {
    val Array(x, y) = StdIn.readLine().split(" ").map(_.toInt)
    (x, y)
  }
}

Measured memory_bytes: 54608
#include <iostream>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define INF 1e+9
#define MAX_V 10

int main() {
    int N;
    cin >> N;
    int M;
    cin >> M;
    set<int> st[N];
    queue<int> q;
    for (int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        st[a-1].insert(b-1);
        st[b-1].insert(a-1);
    }
    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    vector<int> mark(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

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

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

        // v から辿れる頂点をすべて調べる
        for (auto itr = st[v].begin(); itr != st[v].end(); ++itr) {
            if (dist[*itr] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            mark[*itr] = v+1;
            dist[*itr] = dist[v] + 1;
            que.push(*itr);
        }
    }

    // for (int i=0; i<N; ++i) {
    //     for(auto itr = st[i].begin(); itr != st[i].end(); ++itr) {
    //         cout << *itr+1 << "\n";      // イテレータの指す先のデータを表示
    //     }
    //     cout << "-------" << endl;
    // }
    cout << "Yes" << endl;
    for (int v = 1; v < N; ++v) {
        //cout << v << ": " << dist[v] << endl;

        cout << mark[v] << endl;
    }

}

Measured memory_bytes: 28000
#include<bits/stdc++.h>
using namespace std;
int n,ans;
string a,b,c;
int main()
{
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++)
	{
		set<char>s;
		s.clear();
		s.insert(a[i]);
		s.insert(b[i]);
		s.insert(c[i]);
		ans+=s.size()-1;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

int main(){
	string A;
	char c;
	cin >> A;

	for (int i = 0; i < A.length()/2; i++){
		c = A[i];
		A[i] = A[A.length() - i - 1];
		A[A.length() - i - 1] = c;
	}
	cout << A << '\n';

	return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <iostream>
#include <vector>
using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int main() {
    int k;
    string s;
    cin >> k;
    cin >> s;
    if (s.size() <= k) {
        cout << s << endl;
    } else {
        rep(i, 0, k) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
char c[110][110]; 
int H, W; 
cin >> H >> W; 
for (int i = 0; i <= H+1; ++i) {
  for (int j = 0; j <= W+1; ++j){
  c[i][j] = '#'; 
}
}
for (int i = 1; i <= H; ++i) {
  for (int j = 1; j <= W; ++j){
  char s; 
  cin >> s; 
  c[i][j] = s; 
}
}
for (int i = 0; i <= H+1; ++i) {
  for (int j = 0; j <= W+1; ++j){
  cout << c[i][j]; 
}
  cout << endl; 
}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,X;
    int sum=0;
    cin >>A>>B>>C>>X;
    for(int a=0;a<=A;a++){
        for(int b=0;b<=B;b++){
            for(int c=0;c<=C;c++){
                if(X==500*a+100*b+50*c){
                    sum++;
                }
            }
        }
    }
    cout <<sum;
}


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


int main() {
    int n,temp;
    vector<int> mondai;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> temp;
        mondai.push_back(temp);
    }
    int target = 1;
    int count = 0;

    for(int i = 0; i < n; i++){
        if(target != mondai.at(i)) count +=1;
        else target +=1;
    }
    if(target == 1) cout << -1;
    else cout << count;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

vector<ll> ans;

void cal(ll s, int num, int p) {
  int t = (int)(to_string(s)[(to_string(s)).length() - 1]) - (int)'0';
  if (p == num) {
    ans.push_back(s);
  } else {
    cal(s * 10 + t, num, p + 1);
    if (t != 9) {
      cal(s * 10 + t + 1, num, p + 1);
    }
    if (t != 0) {
      cal(s * 10 + t - 1, num, p + 1);
    }
  }
}

int main() {
  int k;
  cin >> k;
  for (int s = 0; s <= 10; s++) {
    for (int i = 1; i <= 9; i++) {
      cal(i, s, 0);
    }
  }
  SORT(ans);
  for (int i = 0; i < k; i++) {
    // cout << ans[i] << endl;
  }
  cout << ans[k - 1] << endl;
}


Measured memory_bytes: 12524
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll a,b,k;cin>>a>>b>>k;

  if(a<k){
        k -= a;
    a = 0;
    //cout<<k<<endl;
    b = max((ll)0,b-k);
  }else{
    a = a - k;
  }

  cout<<a<<" "<<b<<endl;
 

  return 0;
}


Measured memory_bytes: 256