akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int x;
  scanf("%d",&x);
  cout<<!x<<endl;
  return 0;
}






















Measured memory_bytes: 3760
<?php

$arr = array(
    'meiji' => 18680907,
    'taisho' => 19120729,
    'showa' => 19261224,
    'heisei' => 19890107
);

while (($line = trim(fgets(STDIN))) !== '') {
    sscanf($line, '%d %d %d', $y, $m, $d);
    $n = (int)sprintf('%04d%02d%02d', $y, $m, $d);
    $result = 'pre-meiji';
    foreach ($arr as $k => $v) {
        if ($n > $v) {
            $y2 = $y - (int)substr($v, 0, 4) + 1;
            $result = sprintf('%s %d %d %d', $k, $y2, $m, $d);
        }
    }
    echo $result, PHP_EOL;
}

Measured memory_bytes: 6608
import java.util.*;

public class Main
{
	public static void main(String[] args) 
    {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	double ans = 0;
    	for(int i = 0; i < n; i++) 
        {
      		double x = sc.nextDouble();
      		String u = sc.next();
      		if(u.equals("JPY"))
            {
        		ans += x;
      		}
          	else
            {
       			ans += (x * (double)380000);
      		}
    	}
    	System.out.println(ans);
  	}	
}

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

typedef long long ll;
typedef unsigned long long ull;

ll fact(ll n) {
  if (n > 0) {
    return n * fact(n-1);
  } 
  return 1;
}


void perm(vector<pair<ll, ll>> ms, vector<ll> vec, vector<vector<ll>> &res) {
  if (vec.size() == ms.size()) {
    res.push_back(vec);
    return;
  }

  ms[vec[vec.size()-1]].first = 100000000;

  for (ll next = 0; next < ms.size(); ++next) {
    if (ms[next].first > 10000000) continue;

    vector<ll> nextVec = vec;
    nextVec.push_back(next);
    perm(ms, nextVec, res);
  }
}

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

  vector<pair<ll, ll>> ms(n);
  for (ll i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    ms[i] = pair<ll, ll>(x, y);
  }

  vector<vector<ll>> vv;
  for (ll i = 0; i < n; ++i) {
    vector<ll> v;
    v.push_back(i);
    perm(ms, v, vv);
  }

  long double sum = 0;
  for (ll i = 0; i < vv.size(); ++i) {
    vector<ll> v = vv[i];
    for (ll j = 1; j < v.size(); ++j) {
      ll xi = ms[v[j-1]].first;
      ll xj = ms[v[j]].first;
      ll yi = ms[v[j-1]].second;
      ll yj = ms[v[j]].second;

      long double dx = xi - xj;
      long double dy = yi - yj;

      sum += sqrt(dx*dx + dy*dy);
    }
  }

  cout << fixed << setprecision(10);

  cout << sum / fact(n) << endl;
  
  return 0;
}

Measured memory_bytes: 4408
A, B = map(int, input().split())
S = input()
NUM = [str(i) for i in range(10)]

for i in range(A):
    if S[i] not in NUM:
        print("No")
        quit()

if S[A] != "-":
    print("No")
    quit()

for i in range(A + 1, A+B+1):
    if S[i] not in NUM:
        print("No")
        quit()
print("Yes")       

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

using namespace std;

/*ll ma=998244353;
ll power(ll v,ll ti){
if(ti==1)
    return v;
ll x=power(v,ti/2);
x=(x*x)%ma;
if(ti%2==1)
    x=(x*v)%ma;
return x;

}
struct t{
int a,b;
};
vector<vector<t > >g;
vector<int> v;


ll n;


void dfs(int i,int sum){
v[i]=1;


for(int j=0;j<go[i].size();j++){
    int x=go[i][j].a;
    int y=go[i][j].b;
    if(v[x]==0){
        dfs(x,min(y,sum));

    }

}

}*/



 int main(){
ll n,k;
cin>>n>>k;
if(n-k>=0)
    cout<<n-k+1<<endl;
else
    cout<<0<<endl;

 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 2e5 + 5;
const int M = 1e6 + 6;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int sz, a[N], p[M], done[M];
map<int, int> mop;

void sieve() {
    p[0] = p[1] = 1;
    for (int i = 2 * 2; i < M; i += 2)
        p[i] = 1;
    for (int i = 3; i * i < M; i += 2) if (!p[i]) {
        for (int k = i * i; k < M; k += i)
            p[k] = 1;
    }
    p[sz++] = 2;
    for (int i = 3; i < M; i += 2) {
        if (!p[i]) p[sz++] = i;
    }
}

void div(int x) {
    int m = sqrt(x);
    for (int i = 0; i < sz && p[i] <= m; i++) {
        int c = 0;
        while (x % p[i] == 0) {
            x /= p[i];
            c++;
        }
        mop[p[i]] = max(c, mop[p[i]]);
    }
    if (x > 1) {
         mop[x] = max(1, mop[x]);
    }
}

ll bigMod(ll b, ll p, ll m) {
    ll ret = 1, cur = b % m;
    while (p) {
        if (p & 1) ret = (ret * cur) % m;
        cur = (cur * cur) % m;
        p = p >> 1;
    }
    return ret;
}

ll modInv(ll a, ll m) {
    return bigMod(a, m - 2, m);
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    sieve();
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        if (done[a[i]]) continue;
        done[a[i]] = 1;
        div(a[i]);
    }
    ll lcm = 1;
    for (int i = 0; i < sz; i++) {
        lcm *= bigMod(p[i], mop[p[i]], MOD);
        lcm %= MOD;
    }
//    cout << lcm << endl;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll x = lcm * modInv(a[i], MOD);
        ans += x;
        ans %= MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

/**

3
1000000 999999 999998
996989508

3
2 3 4
13

**/


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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


ll gcd(ll a, ll b){
  ll c = a % b;
  if(c == 0)
    return b;
  else
    return gcd(b, c);
}
  
int main(){
  ll a, b;
  cin >> a >> b;
  
  ll g = gcd(a, b);
  
  cout << a/g*b << endl;
}





Measured memory_bytes: 256
#include <stdio.h>

#define EPS (1e-7)

int p,q,a,n;

long long tansaku(double rest,int nowa,int n,int start) {
	long long result=0;
	int i;
	if(n<=0)return 0;
	i=start;
	if((long long)nowa*i>a)i=a/nowa;
	for(;i>0;i--) {
		double nextrest=rest-1.0/i;
		if(nextrest+EPS<0)break;
		else if(-EPS<nextrest && nextrest<EPS){result++;break;}
		else result+=tansaku(nextrest,nowa*i,n-1,i);
	}
	return result;
}

int main(void) {
	while(scanf("%d%d%d%d",&p,&q,&a,&n)==4 && (p|q|a|n)!=0) {
		printf("%lld\n",tansaku((double)p/q,1,n,a));
	}
	return 0;
}

Measured memory_bytes: 600
import fractions
a, b, c, d = map(int, input().split())
 
def wareruzu(x):
    if b < x:
        return 0
    if b == x:
        return 1
    start_a = a if a % x == 0 else a - (a % x) + x
    end_b = b - (b % x) # bより小さい最大の値。
    m = end_b - start_a
    return m // x + 1
 
all_n = b - a + 1
print(all_n - wareruzu(c) - wareruzu(d) + wareruzu((c*d) // fractions.gcd(c,d)))

Measured memory_bytes: 5048
#ABC 49, B - thin
h, w = [int(el) for el in input().split(' ')]
C = [list(input()) for i in range(h)]

for i in range(0, 2*h, 2):
    C.insert(i+1, C[i])

[print(''.join(C[i])) for i in range(2*h)]


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

using namespace std;

int main(void)
{
    string S;
    cin >> S;
    auto f = atoi(S.substr(0, 2).c_str());
    auto s = atoi(S.substr(2, 2).c_str());
    switch (int(1 <= f && f <= 12) * 2 + int(1 <= s && s <= 12))
    {
    case 1:
        cout << "YYMM";
        break;
    
    case 2:
        cout << "MMYY";
        break;
    
    case 3:
        cout << "AMBIGUOUS";
        break;
    
    default:
        cout << "NA";
        break;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	
	int h = read.to!int;
	int w = read.to!int;
	
	char[][] as;
	foreach(i; 0 .. h){
		as ~= readln.chomp.to!(char[]);
	}
	
	
	int[][] ys = new int[][](h, w);
	foreach(i; 0 .. h) foreach(j; 0 .. w){
		if(as[i][j] == '.') ys[i][j] += 1;
	}
	int[][] xs = new int[][](h, w);
	
	foreach(i; 0 .. h) foreach(j; 0 .. w){
		if(as[i][j] == '#') xs[i][j] = 0;
		else if(j == 0) xs[i][j] = 1;
		else xs[i][j] = xs[i][j - 1] + 1;
		ys[i][j] += xs[i][j] - 1;
	}
	log("xs:", xs);
	log("ys:", ys);
	
	foreach(i; 0 .. h) foreach_reverse(j; 0 .. w){
		if(as[i][j] == '#') xs[i][j] = 0;
		else if(j == w - 1) xs[i][j] = 1;
		else xs[i][j] = xs[i][j + 1] + 1;
		ys[i][j] += xs[i][j] - 1;
	}
	log("xs:", xs);
	log("ys:", ys);
	
	foreach(i; 0 .. h) foreach(j; 0 .. w){
		if(as[i][j] == '#') xs[i][j] = 0;
		else if(i == 0) xs[i][j] = 1;
		else xs[i][j] = xs[i - 1][j] + 1;
		ys[i][j] += xs[i][j] - 1;
	}
	log("xs:", xs);
	log("ys:", ys);
	
	foreach_reverse(i; 0 .. h) foreach(j; 0 .. w){
		if(as[i][j] == '#') xs[i][j] = 0;
		else if(i == h - 1) xs[i][j] = 1;
		else xs[i][j] = xs[i + 1][j] + 1;
		ys[i][j] += xs[i][j] - 1;
	}
	log("xs:", xs);
	log("ys:", ys);
	
	long ans = -1;
	foreach(i; 0 .. h) foreach(j; 0 .. w){
		ans = max(ans, ys[i][j]);
	}
	
	ans.writeln;
}


Measured memory_bytes: 38876
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	int n;
	cin>>n;
	VI a;
	FOR(i,0,n){
		int x;
		cin>>x;
		a.PB(x);
	}
	int min_so_far=a[0];
	int ans=1;
	FOR(i,1,n){
		min_so_far=min(min_so_far,a[i]);
		if(a[i]==min_so_far){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

double dist(double a, double b) {
	return a * a + b * b;
}

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

	int n; cin >> n;
	vector<double> x(n), y(n);
	double X = 0.0, Y = 0.0;
	rep(i, 0, n) {
		cin >> x[i] >> y[i];
		X += x[i];
		Y += y[i];
	}

	X /= (double)n; Y /= (double)n;
	double P = 0.1;
	double d, e;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X) * P;
		Y += (y[f] - Y) * P;
		P *= 0.999;
	}

	cout << fixed << setprecision(10) << sqrt(d) << endl;
	return 0;
}

Measured memory_bytes: 3808
(setq a(read))
(setq b(read))
(setq c(read))
(setq d(read))
(setq e(read))
(setq f(read))
(setq g(read))
(setq h(read))
(setq i(read))
(setq x(+ a (* c -2) b))
(setq y(+ d (* f -2) e))
(setq z(+ g (* i -2) h))
(princ(if(= x y z)"Yes""No"))

Measured memory_bytes: 24364
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define gnr(i,l,r) for(int i=int(r)-1; i>=int(l); i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;

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

  cin>>n; V(int)mi;
	V(int)::iterator it;
	rep(i,n){
		cin>>x; x*=-1;
		it=upper_bound(ALL(mi),x);
		if(it==mi.end())mi.eb(x);
		else{
			*it=x;
		}
	}
	pri1(mi.size());
}

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

int main() {
  string S, T;
  cin >> S >> T;
  for (int i = 0; i < S.size(); i++) {
    cout << S.at(i);
    if (i < T.size()) cout << T.at(i);
  }
  cout << "\n";
}

Measured memory_bytes: 3616
N = int(input())
*h, = map(int, input().split())

dp = [0] * N

for i in range(1, N, 1):
        if i==1:
                dp[i]=abs(h[i]-h[i-1])
        else:
                dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

Measured memory_bytes: 13932
import java.io.*;
class Main{
    public static void main(String[] args) throws NumberFormatException,IOException{
        BufferedReader r =
         new BufferedReader(new InputStreamReader(System.in), 1);
         
        String line = r.readLine();    
        String[] w = line.split(" ",0); 
        int a=Integer.parseInt(w[0]);
        int b=Integer.parseInt(w[1]);
        int c=Integer.parseInt(w[2]);
        System.out.println(a<b&&b<c?"Yes":"No");
        r.close();
    }
}

Measured memory_bytes: 24304
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    int n,cnt = 0;cin >> n;
    int A[2*n];
    rep(i,2*n) cin >> A[i];
    sort(A,A+2*n);
    rep(i,2*n) if(i%2==0) cnt += A[i];
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

int main(){
    long X;
    cin>>X;

    vector<bool> is_prime(150000, true);
    for(int i=2; i<350; ++i){
        for(int j=i+1; j<150000; ++j){
            if(is_prime[j] == true && j%i == 0){
                is_prime[j] = false;
            }
        }
    }

    for(int j=X; j<150000; ++j){
        if(is_prime[j] == true){
            cout<<j<<endl;
            break;
        }
    }

    return 0;
}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).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; }

using ll = long long;

const int MAX_N = 100+10;
const int MAX_M = 1e5+10;
ll N, W;
ll WV[MAX_N][2] = {{0}};
ll DP[MAX_N][MAX_M] = {{0}};

inline void input() {
  cin >> N >> W;
  rep(i, N) cin >> WV[i][0] >> WV[i][1];
}

inline void solve() {
  rep(i, N) {
    rep(j, W+1) {
      if(j - WV[i][0] >= 0)
        chmax(
          DP[i+1][j],
          DP[i][j-WV[i][0]]+WV[i][1]
        );

      chmax(
        DP[i+1][j],
        DP[i][j]
      );
    }
  }
}

inline void Main() {
  // code
  input();
  solve();
  cout << DP[N][W] << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

int main() {
    int n,k;
    cin>>n>>k;
    long long arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    long long sum=0;
    for(int i=0;i<k;i++)sum+=arr[i];
    cout<<sum<<endl;
}



Measured memory_bytes: 3640
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

def main():
    N = II()
    xy = []
    for _ in range(N):
        xy.append(LI())
    xy2g = defaultdict(int)
    g2xy = defaultdict(set)
    for x, y in xy:
        y = -y
        gx = xy2g[x]
        gy = xy2g[y]
        if gx != 0 and gy != 0:  # merge
            if gx == gy:
                continue
            if len(g2xy[gx]) < len(g2xy[gy]):
                gx, gy = gy, gx
            for xy in g2xy[gy]:
                xy2g[xy] = gx
            g2xy[gx] |= g2xy[gy]
            g2xy[gy].clear()
        else:
            g = gx or gy or x
            xy2g[x] = xy2g[y] = g
            g2xy[g] |= {x, y}
    ans = -N
    for xys in g2xy.values():
        nx = sum(xy > 0 for xy in xys)
        ny = len(xys) - nx
        ans += nx * ny
    return ans

print(main())

Measured memory_bytes: 114524
/*Bismillahir Rahmanir Rahim*/
#include<bits/stdc++.h>
using namespace std;
#define     ll        long long
#define     n         1e9+9
#define     PI        acos(-1.0)
#define     pb        push_back
#define     mp        make_pair
#define     ff        first
#define     ss        second
#define     gt        getchar()
#define     MOD       1000000007
#define     All(v1)   v1.begin(),v1.end()
#define     DBG(a)    cout<< #a <<" --> "<<(a)<<endl
ll arr[2000007],brr[200007],crr[200007];
char att[1000],m;
string g,h,v,x;
int main()
{
    ll a,b,c,d,e,f,i,j,k,l,t;
    ll N,M;
    cin>>N>>M;
    a=N-1;
    b=M-1;
    l=(a*(a+1))/2;
    t=(b*(b+1))/2;
    cout<<l+t<<endl;
    return 0;
}








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

// {
#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<c && c<'9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }
//}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k, a, b;
	cin >> k >> a >> b;
	for(int i=0; ; i+=k){
		if( i>=a ){
			if( i<=b ){
				cout << "OK" << endl;
				return 0;
			}else{
				cout << "NG" << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{
  int parent,left,right;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}
int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right!=NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}
int getSibling(int u){
  if(T[u].parent == NIL)return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
  if(T[u].parent==NIL){
    printf("root\n");
  }
  else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}
int main(){
  int i,v,l,r,root = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }
  for(i=0;i<n;i++)if(T[i].parent == NIL)root = i;
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++)print(i);
  return 0;
}



Measured memory_bytes: 2052
use std::cmp::Ordering;
use std::str::FromStr;
use std::io;
 
fn main() {
 
	let mut line = String::new();
	io::stdin().read_line(&mut line);
	let split : Vec<&str> = line.split(' ').collect(); 
 
	let X = i32::from_str(split[0].trim()).unwrap();
	let t = i32::from_str(split[1].trim()).unwrap();
 
	match X.cmp(&t) {
        Ordering::Less => println!("0"),
        Ordering::Greater => println!("{}", X-t),
        Ordering::Equal => println!("0"),
    }
}

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

int main() {
 int a,b,c;
  string s;
  cin>>a>>s;
  c=0;
  b=0;
  for(int i=0;i<a;i++){
  	if(s.at(i)=='I')
      c++;
    else
      c--;
    
    b=max(b,c);
  }
  
  cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
  int A[100];
  int i, j, n, x, minj, count;

  scanf("%d", &n);

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

  count = 0;

  for( i = 0; i < n; i++){
    minj = i;

    for( j = i; j < n; j++){

      if( A[j] < A[minj] ) minj = j;

    }
    
    if( A[i] != A[minj] ){
    x = A[i];
    A[i] = A[minj];
    A[minj] = x;

    count++;

    }

  }

  for( i = 0; i < n; i++){
    if( i == n-1 ) printf("%d\n", A[i]);
    else printf("%d ", A[i]);
  }

  printf("%d\n", count);

  return 0;

}

Measured memory_bytes: 600
n=int(input())
a=[int(input())for _ in[0]*n]+[0]
r=0
if a[0]!=0:print(-1);exit()
for i in range(n):
    if a[i]+1<a[i+1]:print(-1);exit()
    elif a[i]>=a[i+1]: r+=a[i]
print(r)

Measured memory_bytes: 12584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string alpha[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
  string inputstr;
  cin >> inputstr;
  int disnum = 0;
  while(!(alpha[disnum] == inputstr)){
  	disnum++;
  }
  cout << alpha[disnum+1];
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args) throws IOException{
    Scanner sc =new Scanner(System.in);
    
    int read;
    int five=0,seven=0;
    for(int i=0;i<3;i++){
            read = sc.nextInt();
      if(read==5){
        five++;
      }
      else if(read==7){
        seven++;
      }
    }
    String ans ="NO";
    if(five==2||seven==1){
      ans="YES";
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1359",problemID = "C",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    t = insr()
    print(t.replace("?","D"))
        
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
    sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))

#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

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


#define MAX 100000

int parent(int i) { return i/2;}
int left(int i){ return 2*i;}
int right(int i){ return 2*i+1;}

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i = 1;i<=H;i++) scanf("%d",&A[i]);

  for(i = 1;i<= H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<= H) printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H) printf("right key = %d, ",A[right(i)]);

    printf("\n");
  }
  return 0;

}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i,n){
    cin >> a[i];
    a[i]--;
  }

  int pos=0;
  int cnt=1;
  vector<int> ans;
  map<int,int> mp;
  ans.emplace_back(0);
  mp[0] = cnt;
  while(mp[a[pos]] == 0){
    mp[a[pos]] = ++cnt;
    ans.emplace_back(a[pos]);
    pos=a[pos];
  }

  // REP(i,ans.size()){
  //   cout << ans[i] << "   " << mp[ans[i]] << endl;
  // }

  int l = mp[a[ans.back()]]-1;
  int r = ans.size() - l;

  if(k < l){
    cout << ans[k] + 1 << endl;
  }else{
    k -= l;
    k %= r;
    cout << ans[k+l] + 1 << endl;
  }





}



Measured memory_bytes: 14012
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int from, to; int cost; };
ostream& operator << (ostream& s, const edge& e) {
   s << "(" << e.from << "->" << e.to << ": " << e.cost << ")";
   return s;
}
bool operator< (const edge &edge1, const edge &edge2){
   return edge1.cost < edge2.cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

vector<int> frac;
void init_frac(int N) {
   frac.resize(N+1);
   frac[0] = 1;
   for (int i = 1; i <= N; i++) {
      frac[i] = mod(frac[i-1] * i);
   }
}
int powM(int x, int n) {
   int res = 1;
   while (n > 0) {
      if ((n & 1) == 1) {
         res = mod(res * x);
      }
      x = mod(x * x);
      n >>= 1;
   }
   return res;
}
int inverseM(int x) {
   return powM(x, MOD-2);
}
int comb(int n, int r) {
   if (n < 0 || n-r < 0 || r < 0) {
      return 0;
   }
   return mod(frac[n] * inverseM(mod(frac[n-r]*frac[r])));
}
int sum(int h, int w) {
   return comb(h-1+w-1, h-1);
}

signed main()
{
   int H, W, A, B; cin >> H >> W >> A >> B;

   init_frac(H+W);
   int ans = sum(H, W);
   REP(j, 1, B+1) {
      ans = mod(ans - mod(sum(H-A,j)*sum(A,W-j+1)));
   }

   cout << ans << endl;

   return 0;
}


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

int main() {
  int s,w;
  cin >> s >> w;

  if (s <= w) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }


}


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

int top, S[100];

void push(int x){
  top++;
  S[top] = x;
}

int pop(){
  top--;
  return S[top + 1];
}

int main(void){
  int a,b;
  top = 0;
  char str[11];
  while(scanf("%s", str) != EOF){
    if(str[0] == '+'){
      a = pop();
      b = pop();
      push(b + a);
    } else if (str[0] == '-'){
      a = pop();
      b = pop();
      push(b - a);
    } else if (str[0] == '*'){
      a = pop();
      b = pop();
      push(b * a);
    } else {
      push(atoi(str));
    }
  }
  printf("%d\n", pop());
  return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int n;
// a[i](1-indexed) を i 番目のモンスターが受けた攻撃量として，d[i+1] = a[i+1] - a[i]
ll d[270000];

void add( int a, int x ){
	for( int i = a; i <= n; i += ( i & -i ) ) d[i] += x;
}

ll kan( int a ){
	ll res = 0;
	for( int i = a; i > 0; i -= ( i & -i ) ) res += d[i];
	return res;
}

// 区間 [l, r] に x を足す
void jia( int l, int r, int x ){
	add( l, x );
	add( r+1, -x );
}

int main(){
	cin >> n;
	ll r, a; cin >> r >> a;
	vector<pair<int, int>> e;
	for( int i = 0; i < n; ++i ){
		int x, y; cin >> x >> y;
		e.emplace_back(x, y);
	}
	sort( e.begin(), e.end() );
	vector<ll> x(n+1);
	vector<ll> h(n+1);
	for( int i = 1; i <= n; ++i ){
		x[i] = e[i-1].first;
		h[i] = e[i-1].second;
	}
	ll ans = 0;
	// 1-indexed なので座標計算するときにベクトル先頭のイテレータを 1 足しておく
	auto xb = x.begin(); ++xb;
	for( int link = 1; link <= n; ++link ){
		//すでに倒している
		if( kan(link) >= h[link] ) continue;
		int recht = upper_bound( x.begin(), x.end(), x[link]+2*r ) - xb;
		ll xuyao = h[link]-kan(link);
		ll cnt = (xuyao+a-1)/a;
		ans += cnt;
		// Fenwick Tree で爆風を実際に起こす
		jia( link, recht, cnt*a );
	}
	cout << ans << endl;
}

/*
方針:
	貪欲に左端のモンスターを倒すことを目標にする
	できるだけ爆風で他のモンスターを巻き込みたい
		→ 左端から +2r のところで爆破する（右端をにぶたんで出す）
	巻き込むモンスター全てに対して実際にダメージ計算をする (Fenwick Tree でゴリ押す)
*/

Measured memory_bytes: 6640
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a,b;
  cin>>a>>b;
  int s=a-n,t=b-n;
  if(fabs(s)>fabs(t))
    cout<<'B';
  else
    cout<<'A';
  return 0;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
map<set<int>, int> dp;
/***** MAIN *****/
signed main() {
  int n = in();
  int ans = 0;
  REPS(i,1,n+1) {
    REPS(j,1,n+1) {
      int inj = gcd(i,j);
      REPS(k,1,n+1) {
        ans += gcd(inj, k);
      }
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}	
int a[114514],b[114514];	
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i];
	ic(m)
	rep(0,i,m)cin>>b[i];
	int ans=0;
	rep(0,i,m){
		int l=0;
		int r=n;
		while(r-l>=1){
			int j=(l+r)/2;
			if(a[j]==b[i]){
				ans++;
				break;
			}	
			else if(a[j]<b[i])l=j+1;
			else r=j;
		}
	}
	c(ans)
}		



Measured memory_bytes: 4280
#include <stdio.h>
#include <stdbool.h>

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

    int pH = 0;
    bool f = true;
    for(int ni=0; ni<N; ni++){
        int H;
        scanf("%d", &H);
        if(pH < H){
            f = true;
        } else if(pH == H){
        } else if(pH-1 == H && f == true){
            f = false;
        } else {
            printf("No\n");
            return 0;
        }
        pH = H;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )
#define MINUSINF ( "-" )

void chmax( string &a, string b )
{
	if ( a == MINUSINF )
	{
		a = b;
	}
	else
	{
		if ( a.size() < b.size() )
		{
			a = b;
		}
		else if ( a.size() == b.size() )
		{
			if ( a < b )
			{
				a = b;
			}
		}
	}
}

int main()
{
	int N, M;
	cin >> N >> M;

	const int Am[] = {
		0, 2, 5, 5, 4, 5, 6, 3, 7, 6
	};

	vector<int> v( M );
	rep( i, M )
	{
		cin >> v[i];
	}

	vector<string> dp( N + 100, MINUSINF );
	dp[0] = "";

	rep( i, N + 1 )
	{
		if ( dp[i] == MINUSINF )
		{
			continue;
		}
		for ( auto &&it : v )
		{
			chmax( dp[i + Am[it]], dp[i] + (char)( it + '0' ) );
		}
	}

	cout << dp[N] << endl;

	return ( 0 );
}


Measured memory_bytes: 30464
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, depth[10010], ord[10010];
vector<int> G[10010];

void dfs(int cur, int par=-1) {
    for(auto to : G[cur]) {
        if(to == par) continue;
        depth[to] = depth[cur] + 1;
        dfs(to, cur);
    }
}

signed main() {
    cin >> N;
    for(int i=0; i<N-1; i++) {
        int u, v;
        cin >> u >> v; u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    dfs(0);

    iota(ord, ord + N, 0LL);
    sort(ord, ord + N, [&](int x, int y) {
            return depth[x] > depth[y];
        });

    int sum = 0;
    vector<int> ans(N);
    for(int i=0; i<N; i++) {
        ans[ ord[i] ] = A[i];
        if(i < N - 1) sum += A[i];
    }
    cout << sum << endl;
    for(int i=0; i<N; i++) cout << ans[i] << " \n"[i + 1 == N];
    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) arr[i] = sc.nextInt();

        int max = 0;
        int cur = 0;
        for(int i = N-2; i >= 0; i--) {
            if(arr[i] >= arr[i+1]) {
                cur++;
            } else {
                cur = 0;
            }
            max = Math.max(max, cur);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 58976
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll x,y,buf;
	string s = "Yes";
	bool flag = false;

	cin >> x >> y;

	while (x > 0)
	{
		if (y >= x * 4)
		{
			y -= 4;
			x--;
		}
		else
		{
			y -= 2;
			x--;
		}
	}

	if (y != 0)
		s = "No";

	cout << s;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main()
{

	int N, K;

	set<int> cake;
	
	cin >> N >> K;
	int d[K];
	for(int i = 0; i < K; i++){
		cin >> d[i];
		for(int j = 0; j < d[i]; j++){
			int A;
			cin >> A;
			cake.insert(A);
		}	
	}

	int ans = N - cake.size();
	
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define MOD 1000000007
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    vector<vector<long long>> dp(N, vector<long long>(N, 1LL<<60));
    for(int i=0; i<N; i++)
        dp[i][i] = 0;

    vector<long long> b(N+1);
    for(int i=1; i<=N; i++)
        b[i] = b[i-1] + a[i-1];

    for(int k=2; k<=N; k++){
        for(int left=0; left<=N-k; left++){
            int right = left+k-1;
            for(int mid=left; mid<right; mid++){
                dp[left][right] = min(dp[left][right], dp[left][mid] + dp[mid+1][right] + b[right+1]-b[left]);
            }
        }
    }
    cout << dp[0][N-1] << endl;
    return 0;
}

Measured memory_bytes: 1536