akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=3010;
const ll MOD=10;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
//C,R,W
int RR,CC,K;
ll dp[MAXN][MAXN][4];
ll square[MAXN][MAXN];
void solve(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>RR>>CC>>K;
    for(int u=0;u<K;u++){
        int r,c,v;
        cin>>r>>c>>v;
        square[r][c]=v;
    }
    ll ans=0;
    for(int u=1;u<=RR;u++){
        for(int v=1;v<=CC;v++){
            for(int k=0;k<=3;k++){
                dp[u][v][0]=max(dp[u][v][0],dp[u-1][v][k]);
            }
            dp[u][v][0]=max(dp[u][v][0],dp[u][v-1][0]);
            for(int w=1;w<=3;w++){
                dp[u][v][w]=max(dp[u][v][w],dp[u][v-1][w]);
                dp[u][v][w]=max(dp[u][v][w],
                    dp[u][v-1][w-1]+square[u][v]);
            }
            for(int k=1;k<=3;k++){
                dp[u][v][1]=max(dp[u][v][1],
                    dp[u-1][v][k]+square[u][v]);
            }
        }
    }
    for(int u=1;u<=RR;u++){
        for(int v=1;v<=CC;v++){
            for(int w=0;w<=3;w++){
                ans=max(ans,dp[u][v][w]);
            }
        }
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 355952
#include<stdio.h>

int bs (int [], int, int);

int min(int b,int c)
{
	if(b>=c) return c;
	return b;
}

int main(void)
{
	int i,j,n,a,dp[1000001],dp2[1000001];
	
	for(i=0;i<=1000000;i++)
	{
		dp[i]=i;
		dp2[i]=i;
	}
	for(i=3,a=4;a<=1000000;i++)
	{
		for(j=a;j<=1000000;j++)
		{
			dp[j]=min(dp[j],dp[j-a]+1);
		}
		
		if(a%2==1)
		{
			for(j=a;j<=1000000;j++)
		    {
			    dp2[j]=min(dp2[j],dp2[j-a]+1);
	    	}
		}
		a=i*(i+1)*(i+2)/6;
	}
	
	while(1)
	{
		scanf("%d",&n);
		if(n==0) break;
		printf("%d %d\n",dp[n],dp2[n]);
	}
	return 0;
}

Measured memory_bytes: 8412
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, T, ans;
int a[maxn];
set<int> s;
int main()
{
	cin >> n >> T;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	int Min = a[1], Max = 0;
	for(int i = 1; i <= n; ++i)
	{
		Max = max(Max, a[i] - Min);
		Min = min(Min, a[i]);
	}
	for(int i = 1; i <= n; ++i)
	{
		if(s.find(a[i] - Max) != s.end())
			++ans;
		s.insert(a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8668
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int f=0,s=0;
    for(int i =0;i<3;i++){
        int num;cin>>num;
        if(num==5){
            f++;
        }else if(num==7){
            s++;
        }
    }
    cout<<(f == 2 && s == 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#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(){

  int n;cin>>n;
  string s;cin>>s;

  REP(i,s.size()){
    int p = s[i] - 'A';
    p = (p+n)%26;
    s[i] = ('A'+p);
  }
  cout<<s<<endl;


  return 0;
}

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 vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	string s,t;
	cin>>s>>t;
	if(L(s)+1==L(t) && s==t.substr(0,L(s)))
	cout<<"Yes";
	else cout<<"No";
}

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


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

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

	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}

	vector<bool> is_prime(101010, true);
	vector<long long> ps;
	map<long long, long long> rt;

	for (long long i = 2; i < 101010; i++) {
		if (is_prime[i]) {
			ps.push_back(i);
			rt[i * i] = i;
			for (int j = i * 2; j < 101010; j += i) {
				is_prime[j] = false;
			}
		}
	}

	map<vector<long long>, vector<long long>> inv;
	map<vector<long long>, int> cnt;

	for (int i = 0; i < n; i++) {
		vector<long long> p, q;
		for (int j = 0; ps[j] <= 2500; j++) {
			int c = 0;
			while (a[i] % ps[j] == 0) a[i] /= ps[j], c++;
			c %= 3;
			if (c > 0) {
				for (int i = 0; i < c; i++) p.push_back(ps[j]);
				for (int i = 0; i < 3 - c; i++) q.push_back(ps[j]);
			}
		}
		if (a[i] != 1) {
			if (rt.count(a[i])) {
				p.push_back(rt[a[i]]);
				p.push_back(rt[a[i]]);
				q.push_back(rt[a[i]]);
			} else {
				p.push_back(a[i]);
				q.push_back(a[i]);
				q.push_back(a[i]);
			}
		}
		inv[p] = q;
		inv[q] = p;
		cnt[p]++;
	}

	int ans = 0;
	for (auto &kv : inv) {
		auto &x = kv.first;
		auto &y = kv.second;

		if (x == y) {
			ans++;
		} else if (x < y) {
			ans += max(cnt[x], cnt[y]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 66304
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int m;
signed main(){
	cin>>m;
	cout<<48-m<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	bool appr = true;
	int n;
	cin >> n;
	while(n--) {
		int x;
		cin >> x;
		if (x%2==0 && x%3!=0 && x%5!=0)
			appr = false;
	}
	if(appr) cout << "APPROVED\n";
	else cout << "DENIED\n";
	return 0;
}

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v, int num=0){
  if(num == 0) num = (int)v.size();
	for(int i=0; i<num; i++){
		cout << v[i]; if(i!=num-1) cout << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

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

  const ll INF = 1e9 + 1;
  ll ans = -INF;
  ll MIN = INF;
  cin >> MIN;
  for(int i=1; i<n; i++){
    ll r;
    cin >> r;
    ans = max(ans, r - MIN);
    MIN = min(MIN, r);
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 3100
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(M):
  x,y,c=map(int,input().split())
  tmp=a[x-1]+b[y-1]-c
  ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 18736
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  cout<< max(0,min(B,D)-max(A,C)) <<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n,m;
    cin>>n>>m;
    ll res=100*(n-m)+1900*(m);
    cout<<llpow(2LL,m)*res<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>

int main()
{
    std::vector<std::array<int, 2>> result;
    result.reserve(3000);
    int a, b;
    while (scanf("%d %d", &a, &b)) {
        if (a == 0 && b == 0) {
            break;
        }
        result.push_back({a, b});
    }

    for (std::array<int, 2> r : result) {
        if (r[0] < r[1]) {
            std::cout << r[0] << " " << r[1] << std::endl;
        } else {
            std::cout << r[1] << " " << r[0] << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3216
def abc062_a():
    x, y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
        print("Yes")
    else:
        print("No")


abc062_a()

Measured memory_bytes: 3060
from collections import Counter

def factors(num):
    f = []
    n = num
    i = 2
    while i * i <= n:
        while n % i == 0:
            f.append(i)
            n //= i
        i += 1
    if n > 1:
        f.append(n)
    return f


if __name__ == '__main__':
    n = int(input())
    d = Counter()
    for i in range(2, n+1):
        d.update(factors(i))
    result = 1
    for k, v in d.items():
        result = (result * (v + 1)) % (10 ** 9 + 7)
    print(result)

Measured memory_bytes: 3316
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

s = input()
cnt = 0

for i in range(len(s) // 2):
  if s[i] != s[len(s) - 1 - i]:
    cnt += 1

print(cnt)


Measured memory_bytes: 2940
n,k = map(int,input().split())
nn = []
for i in range(n):
    nn.append(i+1)
    
ans = []
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        if j in nn:
            nn.remove(j)
print(len(nn))

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

using namespace std;

const int INF = 0x3f3f3f3f;

int pd[100000];
int n, k;
int vet[100000];

int solve(int i) {
	if(i == n-1) return 0;
	if(i >= n) return INF;
	
	int &ans = pd[i];
	if(ans != -1) return ans;
	ans = INF;
	for(int j = 1; j <= k; j++)
		ans = min(ans, solve(i+j) + abs(vet[i]-vet[i+j]));

	return ans;
}

int main(void) {
	
	scanf("%i %i", &n, &k);
	for(int i = 0; i < n; i++)
		scanf("%i", &vet[i]);
	
	memset(pd, -1, sizeof(pd));
	
	printf("%i\n", solve(0));
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
    char ch=getchar(); int f=1; t=0;
    while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9');t*=f;
}
const int maxn=710;
int n,m,ans,f[maxn],c1,c2;
int a[maxn],b[maxn];
bool d[maxn][maxn],dp[maxn][maxn][maxn];
bool dfs(int u) {
	if (f[u]==1) c1++; else c2++;
	for (int i=1;i<=n;i++) {
		if (!d[i][u]) continue; int v=i;
		if (f[v]!=-1&&f[v]==f[u]) return 0;
		if (f[v]!=-1) continue;
		f[v]=1-f[u];
		if (!dfs(v)) return 0;
	}
	return 1;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	memset(d,1,sizeof(d));
	for (int i=1;i<=n;i++) d[i][i]=0;
	for (int i=1;i<=m;i++) {
		int x,y; read(x); read(y);
		d[x][y]=d[y][x]=0;
	}
	memset(f,-1,sizeof(f));
	for (int i=1;i<=n;i++) {
		if (f[i]!=-1) continue;
		f[i]=1; c1=c2=0;
		if (!dfs(i)) {
			ans=-1; break;
		}
		a[i]=c1; b[i]=c2;
	}
	if (ans!=-1) {
		dp[0][0][0]=1;
		for (int i=1;i<=n;i++) {
			for (int j=0;j<=n;j++)
				for (int k=0;k<=n;k++) {
					if (j>=a[i]&&k>=b[i])
						dp[i][j][k]=dp[i-1][j-a[i]][k-b[i]];
					if (j>=b[i]&&k>=a[i])
						dp[i][j][k]|=dp[i-1][j-b[i]][k-a[i]];
				}
		}
		ans=1e9;
		for (int i=1;i<=n;i++) {
			if (!dp[n][i][n-i]) continue;
			ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for (int &hi: h) cin >> hi;
    vector<int> dp(n, 0);
    for (int i = 1; i < n; i++) {
        if (h[i - 1] >= h[i]) dp[i] = dp[i - 1] + 1;
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  vector<int> c{1,3,1,2,1,2,1,1,2,1,2,1};
  if(c.at(a-1)==c.at(b-1)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool p(int a)
{
	if(a==1)return 0;
	for(int i=2;i*i<=a;i++)
		if(a%i==0)return 0;
	return 1;
}
int main()
{
	int a;
	cin>>a;
	for(int i=a;;i++)
	{
		if(p(i))
		{
			cout<<i<<endl;
			return 0;
		}
	} 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  cout << "ABC" << N << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <set>

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

using namespace std;

int main() {
    int N, M;
    int a[200000];
    int b[200000];
    set<int> S;
    bool flag = false;
    scanf("%d %d", &N, &M);
    REP(i, M){
        scanf("%d %d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
    }
    REP(i, M) {
        if (a[i] == 0) {
            S.insert(b[i]);
        }
    }
    REP(i, M) {
        if (b[i] == N-1) {
            if(S.find(a[i])!=S.end()){
                flag = true;
                break;
            };
        }
    }
    flag ? printf("POSSIBLE\n") : printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 6528
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = std.nextInt();
        }

        long count = 0;
        for (int i = 1; i < n - 1; i++) {
            PriorityQueue<Integer> pq = new PriorityQueue<>(3);
            int left = p[i - 1];
            int right = p[i + 1];
            int v = p[i];
            pq.add(left);
            pq.add(right);
            pq.add(v);
            pq.poll();
            if (v == pq.poll()) {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21716
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int dp[M];
 main()

{
    fast
    int n,k;
    cin>>n>>k;
    int ses=0;
    rf(g,k,1)
    {
        int p=k/g;
        dp[g]=bigmod(p,n);
        for(int j=2*g;j<=k;j=j+g)
        {
            dp[g]=sub(dp[g],dp[j]);
        }
        int z=gun(dp[g],g);
        ses=ad(ses,z);
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 4352
#include <stdio.h>

int bubbleSort (int A[], int N) {
	int flag = 1;
	int i = 0,j,token,time=0;
	
	while (flag) {
		flag = 0;
		for(j=N-1; j>=i+1; j--) {
			if(A[j]<A[j-1]) {
				token = A[j-1];
				A[j-1] = A[j];
				A[j] = token;
				flag = 1;
				time ++;
			}
		}
		i++;
	}
	return time;
}

void trace (int A[],int N) {
	int i;
	for(i=0; i<N; i++) {
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}
		

int main(void) {
	int N,i,time;
	int A[100];
	scanf("%d",&N);
	for(i=0; i<N; i++) {
		scanf("%d",&A[i]);
	}
	
	time = bubbleSort(A,N);
	trace(A,N);
	printf("%d\n",time);
	
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
  fastio
  int n,m;cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++)  cin>>a[i];
  vector<int>edges[n];
  for(int i=0;i<m;i++){
    int u,v;cin>>u>>v;u--;v--;
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int pass=1;
    for(auto x:edges[i]){
      if(a[x]>=a[i]) pass=0;
    }
    ans+=pass;
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 9148
import java.util.*;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int a[] = new int[6];
		int min = 100;
		int sum = 0;
		for (int i = 0;i < 4;++i) {
			a[i] = sc.nextInt();
			sum += a[i];
			min = Math.min(min, a[i]);
		}
		for (int i = 4;i < 6;++i) {
			a[i] = sc.nextInt();
		}
		System.out.println(sum - min + Math.max(a[4], a[5]));
	}
}



Measured memory_bytes: 25996
s1 = str(input())
s2 = ''
for i in range(len(s1)):
    s2 += s1[- i - 1]
if s1 != s2:
    print('No')
    exit()

t1 = s1[0 : ((len(s1)) - 1) // 2]
t2 = ''
for i in range(len(t1)):
    t2 += t1[- i - 1]
if t1 != t2:
    print('No')
    exit() 

u1 = s1[(len(s1) + 3) // 2 - 1:]
u2 = ''
for i in range(len(u1)):
    u2 += u1[- i - 1]
if u1 != u2:
    print('No')
    exit() 
print('Yes')

Measured memory_bytes: 3064
// C.

#include <iostream>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>

using namespace std;

typedef long long LL;

struct BIT {
	std::vector<int> bit;
	int size;
public:
	BIT() { }
	BIT(int sz) { init(sz); }
	void init(int sz) {
		bit = std::vector<int>((size = sz) + 1);
	}
	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(int i, int x) {
		while (i <= size) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

int main(int argc, char* argv[]) {
	int n, k;
	cin >> n >> k;

	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	k = min(k, 50);

	BIT bit(n + 2);
	bit.add(1, a[0]);
	for (int i = 1; i < n; ++i) {
		bit.add(i + 1, -a[i - 1] + a[i]);
	}
	for (int i = 0; i < k; ++i) {
		//for (int i = 0; i < min(n, 20); ++i) {
		//	printf(" %3d", bit.sum(i + 1));
		//}
		//cout << endl;

		BIT next(n + 2);
		for (int j = 0; j < n; ++j) {
			int s = bit.sum(j + 1);
			int left = max(1, j + 1 - s);
			int right = min(n + 1, j + 2 + s);
			next.add(left, 1);
			next.add(right, -1);
		}
		bit = next;
	}

	for (int i = 0; i < n; ++i) {
		printf(" %d", bit.sum(i + 1));
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 5824
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll x, y; cin >> x >> y;
    ll res = 0;

    if (y == 0) {
        if (x < 0) res = -x;
        else if (x == 0) res = 0;
        else res = x + 1;
    } else if (y < 0) {
        if (x < 0) {
            if (x < y) res = abs(x) - abs(y);
            else if (x == y) res = 0;
            else res = abs(y) - abs(x) + 2;
        } else if (x == 0) res = abs(y) + 1;
        else { // y is negative and x > y
            if (x < 0) res = abs(y) - abs(x) + 2;
            else if (x == 0) res = abs(y) + 1;
            else { // y is negative and x > y and x > 0
                if (abs(y) > x) res = abs(y) - x + 1;
                else res = x - abs(y) + 1;
            }
        }
    } else { // y > 0
        if (x < 0) {
            if (abs(x) < y) res = y - abs(x) + 1;
            else res = abs(x) - y + 1;
        } else if (x == 0) res = y;
        else { // y > 0 && x > 0
            if (x < y) res = y - x;
            else res = x - y + 2;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3612
#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 vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	ll x,y,d,n,i;
	cin>>n>>d;
	d*=d;
	int cnt=0;
	for(i=0;i<n;i++)
	{
		cin>>x>>y;
		if(x*x + y*y <= d) cnt++;
	}
	cout<<cnt<<'\n';
}

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


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
LL gcm(LL a,LL b) {
  LL temp;
  if(a < b) return gcm(b,a);
  while(temp = a%b) {
    a = b;
    b = temp;
  }
  return b;
}

LL lcm(LL a,LL b) {
  return b / gcm(a,b) * a;
}

int main() {
	int n;
  LL k,ans = 1;
  scanf("%lld",&n);
  for(int i=0; i<n; i++) {
  	  scanf("%lld",&k);
    ans = lcm(k,ans);
  }
  printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>

using namespace std;

int main (){
	string s; cin >> s;
	if (s.find('A') != string::npos && s.find('B') != string::npos){
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int op(int i, int j) { return max(i, j); }
int e() { return -1; }
int v;
bool f(int x) { return x < v; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    atcoder::segtree<int, op, e> seg(a);

    for (int i = 0; i < q; i++) {
        int t, a, b; cin >> t >> a >> b;
        if (t == 1) {
            a--;
            seg.set(a, b);
        } else if (t == 2) {
            a--;
            cout << seg.prod(a, b) << '\n';
        } else {
            a--;
            v = b;
            cout << seg.max_right<f>(a) + 1 << '\n';
        }
    }    
    return 0;
}


Measured memory_bytes: 6112
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int a, b;
	cin >> a >> b;
	
	if( a + b >= 10 ) cout << "error" << endl;
	else cout << a + b << endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		int i1 = i * 1.08;
		if (i1 == n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7
s = input()
n = len(s)
dp = [ [0]*13 for _ in range(n+1) ]
dp[0][0] = 1

for i in range(n):
    if s[i] == '?':
        for j in range(13):
            for num in range(0,9+1):
                dp[i+1][(j*10+num)%13] += dp[i][j]
                dp[i+1][(j*10+num)%13]%=MOD
    else:
        num = int(s[i])
        for j in range(13):
            dp[i+1][(j*10+num)%13] += dp[i][j]
            dp[i+1][(j*10+num)%13]%=MOD

print(dp[n][5])

Measured memory_bytes: 96160
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;

int v[100005], cnt[100005];
vector<ii> par, impar;

int main(){

    map<int,int> mapa;
    int n; cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> v[i];

    for(int i = 1; i <= n; i+=2)
        cnt[v[i]]++;
    for(int i = 1; i <= 1e5; i++)
        if(cnt[i])
            impar.push_back({cnt[i], i});
    sort(impar.rbegin(), impar.rend());

    memset(cnt, 0, sizeof cnt);

    for(int i = 2; i <= n; i+=2)
        cnt[v[i]]++;
    for(int i = 1; i <= 1e5; i++)
        if(cnt[i])
            par.push_back({cnt[i], i});
    sort(par.rbegin(), par.rend());

    if(par[0].second != impar[0].second)
        cout << n - par[0].first - impar[0].first;
    else{
        if(par.size() == 1 or impar.size() == 1)
            cout << n/2 << endl;
        else
            cout << n - max(par[0].first+impar[1].first, par[1].first+impar[0].first) << endl;
    }
	return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;

#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;
int a,b,c;
str s1,s2,s;
int32_t main() {
    fast();
    cin >> a;
    vector<pair<string,int>>q(a);
    f(i,0,a){
        cin >> q[i].F >> q[i].S;
    }
    cin >> s;
    int ind,sum=0;
    f(i,0,a){
        if(s==q[i].F){
            ind=i;
            break;
        }
    }
    f(i,ind+1,a){
        sum+=q[i].S;
    }
    cout<<sum;

    return 0;
}
 

Measured memory_bytes: 256
# ALDS1_4_A.py で十分通る

import sys

n = int(sys.stdin.readline())
S = [int(x) for x in sys.stdin.readline().split()]
q = int(sys.stdin.readline())
T = [int(x) for x in sys.stdin.readline().split()]

count = 0
for t in T:

    left = 0
    right = len(S)
    pmid = 0

    while left < right:
        mid = (right + left) // 2
        if mid == pmid:
            break
        pmid = mid
        m = S[mid]
        if t == m:
            count += 1
            break
        else:
            if t < m:
                right = mid
            else:
                left = mid + 1

print(count)


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

#ifndef ONLINE_JUDGE
#include "myfile.h"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


void solve() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<char>> g(h, vector<char>(w));
	for (vector<char> &v : g)
		for (char &c : v) cin >> c;

	int cnt = 0;
	for (int rMask = 0; rMask < (1 << h); rMask++) {
		for (int cMask = 0; cMask < (1 << w); cMask++) {
			int val = 0;
			for (int i = 0; i < h; i++) {
				if (rMask & (1 << i)) continue;
				for (int j = 0; j < w; j++) {
					if (cMask & (1 << j)) continue;
					if (g[i][j] == '#') val++;
				}
			}

			if (val == k) cnt++;
		}
	}

	cout << cnt << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 3652
/*
* @Author: wxyww
* @Date: 2020-03-11 20:37:32
* @Last Modified time: 2020-03-11 20:42:23
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int N = 20;
ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int a[N];
ll dfs(int l,int r,ll x,ll y) {
	if(r - l <= 1) return 0;
	ll ret = 1e17;
	for(int i = l + 1;i < r;++i)
		ret = min(ret,dfs(l,i,x,x + y) + dfs(i,r,x + y,y) + a[i] * (x + y));
	return ret;
}
int main() {
	int n = read();
	for(int i = 1;i <= n;++i) a[i] = read();

	cout<<a[1] + a[n] + dfs(1,n,1,1);

	return 0;
}

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

int main(void)
{
  int N,i;
  long int sum = 0;
  int max = 1;
  int a;

  scanf("%d",&N);

  for(i = 0;i < N;i++)
  {
    scanf("%d",&a);
    if(a > max)max = a;
    sum += (max - a);
  }

  printf("%ld",sum);
  
  return 0;
}


Measured memory_bytes: 1676
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1000000000;

ll dfs(int idx, int n, int status, vvl& g) {
  if (status == (1 << n) - 1) {
    return 1;
  }
  ll ans = 0;
  for (auto& v : g[idx]) {
    if ((status >> v) & 1) {
      continue;
    } else {
      ans += dfs(v, n, (status | (1 << v)), g);
    }
  }
  return ans;
}

int main() {
  //
  ll n, m;
  cin >> n >> m;
  vvl g(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll ans = dfs(0, n, 1, g);
  cout << ans << endl;
  return 0;
}


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

int main(){
  int H,W;
  cin >>H>>W;
  
  vector<vector<char>> C(H,vector<char>(W));
  repeat(i,0,H){
    repeat(j,0,W) cin>>C[i][j];
  }
  
  repeat(i,0,H){
    repeat(j,0,W) cout <<C[i][j];
    cout <<endl;
    repeat(j,0,W) cout <<C[i][j];
    cout <<endl;
  }
}

Measured memory_bytes: 256
#include <vector>
#include <functional>
#include <deque>
#include <stdexcept>
#include <algorithm>


template<typename T, typename Container = ::std::deque<T>, typename Compare = ::std::greater<typename Container::value_type>>
class sliding_window {
    using value_compare = Compare;
    using value_type = T;
    using const_reference = const value_type &;

    value_compare comp;
    size_t length;
    Container val;

public:
    void push(const value_type &v) {
        while (!val.empty() && comp(val.back(), v))val.pop_back();
        val.push_back(v);
        ++length;
    }

    void pop(const value_type &v) {
        if (v == val.front())val.pop_front();
        --length;
    }

    explicit sliding_window(const Compare &_comp = Compare()) : length(0), comp(_comp), val({}) {}
    template<typename ForwardIterator>
    sliding_window(ForwardIterator begin, ForwardIterator end, const Compare &_comp = Compare()) : length(0), comp(_comp), val({}) {
        while(begin != end){
            push(*begin);
            ++begin;
        }
    }

    const size_t size() const {
        return length;
    }

    const_reference top() const {
        return val.front();
    }

};

#include <iostream>

int main() {
    unsigned long long N, L;
    std::cin >> N >> L;

    std::vector<unsigned long long> A(N);
    for (auto &i : A)std::cin >> i;

    sliding_window<unsigned long long> slidingWindow(A.begin(), A.begin() + L);
    std::cout << slidingWindow.top();

    for(unsigned long long i = L; i != N; ++i){
        slidingWindow.push(A[i]);
        slidingWindow.pop(A[i - L]);
        std::cout << " " << slidingWindow.top();
    }

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 11200
/*
2020-05-03
atcoder ABC
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> data(N);

    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int c;
            cin >> c;
            data[c - 1]++;
        }
    }
    rep(i, N){
        if(data[i] == 0){
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


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


int main(){
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<string> v;
    unordered_map<string,int> mp;
    for(int j = 1; j <= 5; j++){
        rep(i, n - j + 1){
            string t = s.substr(i,j);
            if (mp[t] > 0) continue;
            v.push_back(t);
            mp[t]++;
        }
    }

    sort(v.begin(), v.end());
//    rep(i, n) cout << v[i] << endl;

    cout << v[k-1] << endl;

    return 0;
}


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

int main() {
    int N, a;
    cin >> N;
    vector<ll> A(N + 1);

    for (int i = 1; i <= N; i++) {
        cin >> a;
        A[i] = A[i - 1] + a;
    }

    sort(A.begin(), A.end());
    ll ans = 0, cnt = 0;
    rep(i, N) {
        if (A[i] == A[i + 1]) {
            cnt++;
        } else {
            ans += cnt * (cnt + 1) / 2;
            cnt = 0;
        }
    }
    ans += cnt * (cnt + 1) / 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val x = readInteger()
    val powList = mutableListOf<Int>()
    powList += 1
    var b = 2
    while (b * b <= x) {
        var tmp = b
        while (tmp <= x) {
            powList += tmp
            tmp *= b
        }

        b++
    }
    val aa = powList.sortedDescending().first()
    println(aa)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 34236
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long i64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 8e3+5, M = 2e2+5, P = 998244353;
int lim, rev[N<<2]; i64 g[N<<2];
i64 qpow(i64 a, int b) { i64 ret = 1; for( ; b; b >>= 1, a = a*a%P) if(b&1) ret = ret*a%P; return ret;  } 
void prepare(int ti)
{
    for(lim = 1; lim <= ti; lim <<= 1);
    i64 gn = qpow(3, (P-1)/lim); g[0] = 1;
    for(int i = 1, j = lim>>1; i < lim; ++i) 
    {
        g[i] = g[i-1]*gn%P, rev[i] = j;
        for(int k = lim>>1; (j ^= k) < k; k >>= 1);
    }
}
struct Poly
{
    vector<int> A;
    int& operator [] (const int i) { return A[i]; }
    void set(int ti) { A.resize(ti+1); }
    int ti() { return A.size()-1; }
    void ntt(int t)
    {
        if(!t)
        {
            A.resize(lim); for(int i = 1; i < lim; ++i) if(i > rev[i]) swap(A[i], A[rev[i]]);
            for(int mid = 1; mid < lim; mid <<= 1)
                for(int j = 0, len = mid<<1; j < lim; j += len)
                    for(int k = 0, p = 0, q = lim/len; k < mid; ++k, p += q)
                    {
                        i64 t = g[p]*A[j+k+mid]%P;
                        A[j+k+mid] = (A[j+k]-t+P)%P, A[j+k] = (A[j+k]+t)%P;
                    }
        }
        else 
        {
            reverse(++A.begin(), A.end()), ntt(0); i64 v = qpow(lim, P-2);
            for(int i = 0; i < lim; ++i) A[i] = A[i]*v%P;
        }
    }
    friend Poly operator * (Poly A, Poly B)
    {
        int n = A.ti(), m = B.ti(); prepare(n+m), A.ntt(0), B.ntt(0);
        for(int i = 0; i < lim; ++i)  A[i] = 1ll*A[i]*B[i]%P;
        A.ntt(1), A.set(n+m); return A; 
    }
}A, B;
int n, m, f[N][M], ans; i64 ifac[N], fac[N];
i64 C(int n, int m) { return fac[n]*ifac[m]%P*ifac[n-m]%P; }
int main()
{
    n = read(), m = read(), f[0][0] = 1, A.set(n);
    fac[0] = 1; for(int i = 1; i <= n+2; ++i) fac[i] = fac[i-1]*i%P;
    ifac[n+2] = qpow(fac[n+2], P-2); for(int i = n+2; i; --i) ifac[i-1] = ifac[i]*i%P;
    for(int i = 1; i <= n; ++i) A[i] = ifac[i+2];
    for(int j = 1; j <= m; ++j)
    {
        B.set(n); for(int i = 0; i <= n; ++i) B[i] = f[i][j-1]*ifac[i]%P; B = A*B; 
        for(int i = 0; i <= n; ++i) f[i][j] = (f[i][j-1]*(1+(i+1ll)*i/2)%P+B[i]*fac[i+2]%P)%P;
    }
    for(int i = 0; i <= n; ++i) ans = (ans+C(n, i)*f[i][m]%P)%P;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 7296
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let s = readLine()!.map { String($0) }
    var zeroOne = 0
    var oneZero = 0
    var nextColor = "0"
    
    for i in 0..<s.count {
        if s[i] == nextColor {
            zeroOne += 1
        } else {
            oneZero += 1
        }
        nextColor = nextColor == "0" ? "1": "0"
    }
    print(min(zeroOne, oneZero))
}
main()


Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    long long n, m;
    cin >> n >> m;
    vector<vector<long long> > a(n, vector<long long>(m));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a.at(i).at(j);
        }
    }
    vector<long long> b(m);
    for (int i = 0; i < m; i++)
    {
        cin >> b.at(i);
    }

    vector<long long> c(n);
    for (int i = 0; i < n; i++)
    {
        long long t = 0;
        for (int j = 0; j < m; j++)
        {
            t += a.at(i).at(j) * b.at(j);
        }
        c.at(i) = t;
    }

    for (int i = 0; i < n; i++)
    {
        cout << c.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		sc.close();
		StringBuilder sb = new StringBuilder(s2);
		sb.reverse();
		if(s1.equals(sb.toString())) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) (((long long)mod_x)%modulo)


int main(){
	
	int N,X;
	cin>>N>>X;
	
	int ans = 1;
	int now = 0;
	
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		now+=a;
		if(now<=X)ans++;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(v * t >= w * t + abs(a - b))cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    
    vector<int> v(n);
    for(int&i:v)cin>>i;
    
    int midpos=n/2-1;
    auto v2=v;
    sort(v.begin(),v.end());
    int m1=v[midpos], m2=v[midpos+1];
    for(int i=0; i<n; i++){
        if(v2[i]<=m1) cout<<m2<<endl;
        else cout<<m1<<endl;
        
    }
   
    
    return 0;
}

Measured memory_bytes: 3840