akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    using namespace std;
    
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define int long long 
    #define double long double
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n" 
         
    #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 bp __builtin_popcountll
    #define inf 1e18
    
    const int N=1e5+5; 
    const int MOD=1e9+7;
    void solve()
    {
        int n;
        cin>>n;
        int a[n+1];
        f(i,1,n)
        cin>>a[i];
        if(n%2==0)
        {
        	int dp[n+1];
        	dp[0]=0;
        	dp[1]=a[1];
        	dp[2]=a[2];
        	f(i,3,n)
        	{
        		if(i%2==0)
        		dp[i]=max(dp[i-2],dp[i-3])+a[i];
        		else
        		dp[i]=dp[i-2]+a[i];
        	}
        	int ans=max(dp[n],dp[n-1]);
        	cout<<ans;
        	return;
        }
        else
        {
        	int dp[n+1][2];
        	dp[0][0]=0;
        	dp[0][1]=0;
        	dp[1][0]=0;
        	dp[1][1]=a[1];
        	dp[2][0]=a[2];
        	dp[2][1]=a[2];
        	dp[3][0]=max(a[3],a[1]);
        	dp[3][1]=a[1]+a[3];
        	f(i,4,n)
        	{
        		if(i%2==0){
        			dp[i][0]=max(dp[i-2][0],dp[i-3][1])+a[i];
        			dp[i][1]=max(dp[i-2][0],dp[i-3][1])+a[i];
        		}
        		else
        		{
        			dp[i][0]=max(dp[i-2][0],dp[i-3][0])+a[i];
        			dp[i][1]=dp[i-2][1]+a[i];
        		}
        		
        	}
        	int ans=max(max(dp[n][0],dp[n-1][0]),dp[n-2][1]);
        	cout<<ans;
        	return;
        }
    }
    
    signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
            solve();
        }
    }



Measured memory_bytes: 8328
N = int(input())

def print_missingcard(pattern, cardlist):
    for i in range(1,14):
        if i not in cardlist:
            print(str(pattern) +' '+ str(i))

s_cards = []
h_cards = []
c_cards = []
d_cards = []

for i in range(N):
    pattern, num = (x for x in input().split())
    num = int(num)
    if pattern == 'S':
        s_cards.append(num)
    elif pattern == 'H':
        h_cards.append(num)
    elif pattern == 'C':
        c_cards.append(num)
    elif pattern == 'D':
        d_cards.append(num)
    else:
        None

print_missingcard('S', s_cards)
print_missingcard('H', h_cards)
print_missingcard('C', c_cards)
print_missingcard('D', d_cards)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int ans[100005];
struct e{
    int v, w;
};
vector<e> g[100005];
void dfs(int u, int p, bool cur)
{
    ans[u] = cur;
    for (int i = 0; i < g[u].size(); ++i){
        if (g[u][i].v == p) continue;
        dfs(g[u][i].v, u, g[u][i].w & 1 ? !cur : cur);
    }
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n, u, v, w;
	cin >> n;
	for (int i = 1; i < n; ++i){
        cin >> u >> v >> w;
        g[u].push_back(e{v, w});
        g[v].push_back(e{u, w});
	}
	dfs(1, 0, 0);
	for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 9984
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.close();
    String ans = "ABC";
    if(n >= 1000)ans = ans.replace("C","D");
    System.out.println(ans);
  }
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	ll g = 0;
	ll m = 0;
	rep(i, n) {
		cin >> a[i];
		m = max(m, a[i]);
		g = __gcd(g, a[i]);
	}
	if (k > m) {
		cout << "IMPOSSIBLE" << endl;
	} else if (k % g != 0) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << "POSSIBLE" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
ll A[100010];
ll mx[100010];
ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i <= N; ++i){
        cin >> A[i];
    }
    if(N == 0){
        cout << (A[0] == 1 ? 1 : -1) << endl;
        return 0;
    }
    if(A[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    mx[0] = 1;
    for(int i = 1; i <= N; ++i){
        ll M = mx[i - 1] * 2;
        if(M > linf) M = linf;
        if((i != N && M <= A[i]) || M < A[i]){
            cout << -1 << endl;
            return 0;
        }
        mx[i] = M - A[i];
    }
    ans += A[N];
    ll node = A[N];
    for(int i = N - 1; i >= 1; --i){
        ans += min(node, mx[i]) + A[i];
        node = min(node, mx[i]) + A[i];
    }
    ans++;
    cout << ans << endl;
    return 0;
}

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

long long powmod(long long x, long long y){
    long long ret=1;
    while(y--){
        ret *= x;
        ret %= mod;
    }
    return ret;
}

int main(){
    long long N; cin>>N;
    
    long long all = powmod(10,N);
    long long no0 = powmod(9,N);
    long long no9 = powmod(9,N);
    long long no09 = powmod(8,N);
    long long ans = all - no0 - no9 + no09;
    ans = (ans+mod*2)%mod;
    cout << ans << endl;
}




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

const int maxn= 100010;
vector<int> adj[maxn * 3];
int vis[maxn * 3];

int main() {
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  #endif
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v + n);
    adj[u + n].push_back(v + 2 * n);
    adj[u + 2 * n].push_back(v);
  }

  int s, t;
  cin >> s >> t;

  queue<pair<int, int>> q;
  q.push(make_pair(s, 0));
  vis[s] = 1;
  while (!q.empty()) {
    auto top = q.front(); q.pop();
    if (top.first == t) {
      cout << top.second / 3;
      return 0;
    }
    for (auto v : adj[top.first]) {
      if (!vis[v]) {
        vis[v] = 1;
        q.push(make_pair(v, top.second + 1));
      }
    }
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define out(i) cout<<i<<endl;
#define m_p make_pair
typedef long long ll;
typedef string str;
typedef vector<int> V;
typedef pair<int,int> P;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}
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;}

signed main(){
  int n;
  cin>>n;
  V b(n),a;
  rep(i,n)cin>>b[i];
  while(b.size()){
    bool find=false;
    for(int i=b.size()-1;i>=0;--i){
      if(i+1==b[i]){
        a.pb(b[i]);
        b.erase(b.begin()+i);
        find=true;
        break;
      }
    }
    if(!find){
      cout<<-1<<endl;
      return 0;
    }
  }
  reverse(all(a));
  rep(i,n)cout<<a[i]<<endl;


  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  i64 ans = 0;
  char bf = '$';
  i64 cnt = 0;
  rep(i,0,N) {
    if(bf == s[i]) {
      ans++;
    }
    else {
      cnt++;
    }
    bf = s[i];
  }
  while(K > 0 && cnt > 2) {
    cnt -= 2;
    ans += 2;
    K--;
  }
  while(K > 0 && cnt >= 2) {
    cnt -= 1;
    ans += 1;
    K--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
#define vel vector<long long>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
long long p = 998244353;
vel kai(2001, 1);
vel ink(2001, 1);
vel uni(vel &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	vel ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 2000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 2001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
signed main() {
int n; cin >>n ;
bool fl=true;
int mn=1000000000,sum=0;
rep(i,n){
int a,b;cin >> a>>b;
sum+=a;
if(a>b){mn=min(mn,b);fl=false;}
}
if(fl){cout << 0<<endl;}
else{cout << sum-mn<<endl;}
return 0;
}


Measured memory_bytes: 256
#include<cstdio>;
int n, l;
int a[100005];
bool chk[100005];
int main() {
	scanf("%d%d", &n, &l);
	int i;
	for (i = 1; i <= n; i++) scanf("%d", &a[i]);
	int s = 0;
	for (i = 1; i < n; i++) {
		if (a[i] + a[i + 1] >= l) {
			s = i; break;
		}
	}
	if (s == 0) printf("Impossible");
	else {
		printf("Possible\n");
		for (i = n - 1; i >= s + 1; i--)
			printf("%d\n", i);
		for (i = 1; i < s; i++) printf("%d\n", i);
		printf("%d\n", s);
	}
	return 0;
}

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

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

using namespace std;

int main(void){
    
    int leepyear[1000][745] = {0};
    int i,j=0,k = 0,l=0,m = 0,n= 0;
    int yearA,yearB;
    int checyear = 0;

    while(cin >> yearA >> yearB,yearA+yearB)
    {
        FOR(i, yearA, yearB+1)
        {
            checyear = i;
            if(checyear % 400 == 0)
            {
                leepyear[j][k] = checyear;
                k++;
                
            }else if((checyear % 4 == 0) && (checyear % 100 != 0))
            {
                leepyear[j][k] = checyear;
                k++;
            }
        }
        k = 0;
        j++;
    }
    REP(l, j)
    {
        n = 0;
        if(leepyear[l][0])
        {
            while (leepyear[l][n])
            {
                cout << leepyear[l][n] << endl;
                n++;
                
            }
            if( l != (j-1))
            cout << endl ;
        }
        else cout << "NA" << endl << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
 #define fi first
 #define se second

int main(){
    ll n, p=-inf, q=inf, ans=0, ml=-inf;
    cin >> n;
    vector<pair<ll, ll>> r(n), ret;
    rep(i, n){
        cin >> r.at(i).fi >> r.at(i).se;
        r.at(i).fi--;
        p = max(p, r.at(i).fi);
        q = min(q, r.at(i).se);
        ml = max(ml, r.at(i).se-r.at(i).fi);
    }
    ans = max(q-p, 0LL)+ml;
    rep(i, n){
        int li, ri;
        li = max(0LL, r.at(i).second - p);
        ri = max(0LL, q - r.at(i).first);
        ret.push_back(make_pair(ri, -li));
    }
    sort(ret.begin(), ret.end());
    ll lng = inf;
    rep(i, n){
        ret.at(i).second *= -1;
        if(i != 0){
            ans = max(ans, lng+ret.at(i).first);
        }
        lng = min(lng, ret.at(i).second);
    }
    cout << ans;
}

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

int main(void){
    int n;  cin >> n;
    
    map<string ,int > mp;
    string s;   cin >> s;
    mp[s]++;
    
    for(int i=0;i<n-1;i++){
        string t;   cin >> t;
        mp[t]++;
        if(s[s.size()-1]!=t[0]){
            cout << "No" << endl;
            return 0;
        }
        s = t;
    }
    
    if(mp.size()!=n){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> d(10);
    rep(i, k)
    {
        int ipt;
        cin >> ipt;
        d[ipt] = 1;
    }
    vector<int> nums(100000);
    for (int i = 1; i <= 100000; i++)
    {
        nums[i - 1] = i;
    }
    for (int i = 0; i < 100000; i++)
    {
        if (i < n)
        {
            continue;
        }
        bool flag = false;
        string nums = to_string(i);
        for (int j = 0; j < nums.size(); j++)
        {
            if (d[nums[j] - '0'] == 1)
            {
                flag = true;
                break;
            }
        }
        if (flag)
        {
            continue;
        }
        cout << i << endl;
        return 0;
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from collections import deque,defaultdict
def resolve():
    n,k=map(int,input().split())
    A=list(map(lambda x:int(x)-1,input().split()))
    S=[0]*(n+1)
    for i in range(n):
        S[i+1]=(S[i]+A[i])%k

    ans=0
    C=defaultdict(int)
    Q=deque()
    for s in S:
        ans+=C[s]
        C[s]+=1
        Q.append(s)
        if(len(Q)==k):
            C[Q.popleft()]-=1
    print(ans)
resolve()

Measured memory_bytes: 105704
#include <stdio.h>

int main(){
  int n,a[100],i,k,j,key;
  scanf("%d",&n);
 
  for(i=0;i<n;i++) scanf("%d",&a[i]);
 for(i=0;i<n-1;i++) printf("%d ",a[i]);
 printf("%d\n",a[n-1]);
 for(j=1;j<n;j++){
   key=a[j];
  i=j-1;
  while (i>-1 && a[i]>key){
    a[i+1]=a[i];
i--;
}
  a[i+1]=key;
for(k=0;k<n-1;k++) printf("%d ",a[k]);
 printf("%d\n",a[n-1]);
}

return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

int N, M, P;
map<string,vector<int> > m1;
map<vector<int>,string > m2;
map<string,string> var;
string S;
int pos;
bool error_flag;

vector<int> formula();
vector<int> term();
vector<int> factor();

vector<int> factor() {
  if(S[pos] == '(') {
    ++pos;
    vector<int> v = formula();
    ++pos;
    return v;
  } else {
    int begin = pos;
    while(isalpha(S[pos])) ++pos;
    return m1[var[S.substr(begin,pos-begin)]];
  }
}

vector<int> term() {
  vector<int> v = factor();
  while(pos < S.size() && S[pos] == '*' || S[pos] == '/') {
    int d = S[pos] == '*' ? 1 : -1;
    ++pos;
    vector<int> u = factor();
    for(int i = 0; i < N; ++i) v[i] += u[i]*d;
  }
  return v;
}

vector<int> formula() {
  vector<int> v = term();
  while(pos < S.size() && S[pos] == '+' || S[pos] == '-') {
    ++pos;
    if(term() != v) {
      error_flag = true;
    }
  }
  return v;
}

int main() {
  while(cin >> N >> M >> P && (N|M|P)) {
    m1.clear();
    m2.clear();
    var.clear();
    for(int i = 0; i < M; ++i) {
      string name;
      vector<int> v(N);
      cin >> name;
      for(int j = 0; j < N; ++j) cin >> v[j];
      m1[name] = v;
      m2[v] = name;
    }
    cin >> S;

    for(int i = 0; i < P; ++i) {
      string varname, name;
      cin >> varname >> name;
      var[varname] = name;
    }

    pos = 0;
    error_flag = false;
    vector<int> res = formula();
    if(error_flag) cout << "error" << endl;
    else if(m2.find(res) != m2.end()) cout << m2[res] << endl;
    else cout << "undefined" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);
		
		Console.WriteLine((n==k)?"Yes":"No");

	}
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>

int main()
{int n;scanf("%d",&n);long long int a[n],j;for(j=0;j<n;j++)scanf("%lld",(a+j));
long long int s=0,d=0,p=1000000007;for(j=0;j<n;j++){s=((s+a[j])%p);d=((d+((a[j]*a[j])%p))%p);}
s=((s*s)%p);
long long int k=p-2,ans=1,c=2;
while(k!=0)
{
    if(k%2==0)
    {
        k/=2;c=((c*c)%p);
    }
    else
    {
        k--;ans=((ans*c)%p);
    }
}
long long int x;x=((s-d)*ans)%p;
if(x<0)x=x+p;
printf("%lld\n",x);
return(0);
}


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

#endif


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

    int N; cin >> N;
    vvi A(2, vi(N));
    REP(i, 2)
        REP(j, N) cin >> A[i][j];

    int ans = -INF;
    REP(i,N) {
        int sum = 0;

        REP(j,N) {
            if (j < i) sum += A[0][j];
            else if (j == i) sum += A[0][j] + A[1][j];
            else sum += A[1][j];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
ll n, a[100010], b[100010], bit[200010];

ll sum(int p){
	ll res = 0;
	for(int i=p; i>0; i-=i&-i) res += bit[i];
	return res;
}

void add(int x, int p){
	for(int i=p; i<=2*n+1; i+=i&-i) bit[i] += x;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	ll l = 1e18, r = -1e18;
	for(int i=0; i<n; ++i){
		cin >> a[i];
		l = min(l, a[i]);
		r = max(r, a[i]);
	}
	++r;
	while(l+1 != r){
		ll m = (l + r) / 2, cnt = 0;
//		cout << l << " " << r << " " << m << "\n";
		for(int i=1; i<=n; ++i)
			b[i] = (a[i-1] >= m ? 1 : -1) + b[i-1];
		memset(bit, 0, sizeof(bit));
		add(1, n+1);
		for(int i=1; i<=n; ++i){
			cnt += sum(b[i]+n+1);
			add(1, b[i]+n+1);
		}
//		cout << cnt << "\n";
		if(cnt >= (n*(n+1)/2+1)/2) l = m;
		else r = m;
	}
	cout << l << "\n";
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n;
ll dp[22][1<<22];
bool a[22][22];
ll mod = 1000000007;

ll findAns(ll i, ll mask)
{
    if(mask >= (1<<n)-1)
        return 1;

    if(i==n)
        return 1;

    if(dp[i][mask]!=-1)
    {
        return dp[i][mask];
    }

    ll ans = 0;

    fr(j,0,n-1)
    {
        bool x = a[i][j];
        if(x)
        {
            if(!(mask&(1<<j)))
            {
                ans = ans + findAns(i+1,mask | (1<<j));
                ans = ans%mod;
            }
        }
    }

    return dp[i][mask] = ans;
}

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

    cin >> n;
    fr(i,0,n-1)
    {
        fr(j,0,n-1)
        {
            cin >> a[i][j];
        }
    }

    fr(i,0,n)
    {
        fr(j,0,1<<n)
        {
            dp[i][j] = -1;
        }
    }

    cout << findAns(0,0) << endl;
}

Measured memory_bytes: 405760
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include <unordered_map> 
#include<vector>
#include<queue>
#include <bits/stdc++.h> 
#include<string>
#define ll long long int
#define N 100005
#define MOD 1e9+7
using namespace std;
string s1,s2;
template <typename T> void max_self(T &a, T b){
	if(b>=a){
		a = b;
	}
}
//int dp[N][N];
int dp[N];
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int stones = 1;stones<=k;stones++){
		for(int i=0;i<n;i++){
			if(stones >=a[i] && !dp[stones-a[i]]){
				dp[stones] = 1;
			}
		}
	}
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
}


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

int main () {
    int N, A;
    cin >> N >> A;
    bool hantei = false ;
    for (int i = 0; i < 25; i++) {
        for (int j = 0; j < A + 1; j++) {
            if (N == 500 * i + j) hantei = true ;
        }

    }
    printf(hantei == true ? "Yes" : "No");
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;
//template<typename A, size_t N, typename T>
//void Fill(A (&array)[N], const T &val){
//    std::fill( (T*)array, (T*)(array+N), val );
//}


int main()
{
    debug("aaa")
    int N, M;

    cin >> N >> M;

    vector<ll> A(M);
    rep(i, M)cin >> A[i];

    int B_[] = {2,5,5,4,5,6,3,7,6};
    vector<ll> B(M);
    string mem[N+100];
    rep(k, N+100)mem[k] = "";


    rep(i, M)B[i] = B_[A[i]-1];
    
    rep(i, M)rep(j, M){
        if(B[i] == B[j])
        A[i] = max(A[i], A[j]);
    }
    auto cmp=[](string a,string b){
             if(a.size()!=b.size()) return a.size()<b.size();
             for(int i=0;i<(int)a.size();i++)
               if(a[i]!=b[i]) return a[i]<b[i];
             return false;
           };

    rep(i, M){
        mem[B[i]] = (cmp(mem[B[i]] , to_string(A[i]) )? to_string(A[i]): mem[B[i]]);
        debug(mem[B[i]])
    }
    

    for(int k = 0; k <= N; k++){
        rep(i, M){

            if(mem[k].size()==0)continue;
            string t =  mem[k]+to_string(A[i]);
                            //debug(mem[l+1][k+B[i]])debug(k+B[i])
            //debug(t)
            //debug(mem[l+1][k+B[i]] < t)
            mem[k+B[i]] = (cmp(mem[k+B[i]] , t )? t: mem[k+B[i]]);
        }
    }
        
    


    int K = N;
        
        cout << mem[N] << endl;
        
       
        
    
    return 0;
}/**/

Measured memory_bytes: 32512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> s;
	ans = s.size();
	while(1) {
		ans -= 2;
		x = 1;
		for(i=0;i<ans/2;i++) {
			if (s[i]!=s[i+ans/2]) x = 0;
		}
		if (x) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll n; cin >> n; vl dpa(n); vl dpb(n); vl dpc(n);
  
  ll a,b,c; cin >> a >> b >> c;
  
  dpa[0] = a; dpb[0] = b; dpc[0] = c;
  
  for(ll i=1; i < n; i++){
    cin >> a >> b >> c;
    dpa[i] = max(dpb[i-1]+a,dpc[i-1]+a);
    dpb[i] = max(dpc[i-1]+b,dpa[i-1]+b);
    dpc[i] = max(dpa[i-1]+c,dpb[i-1]+c);
  }
  
  cout << max({dpa[n-1],dpb[n-1],dpc[n-1]}) << endl;
  
  
}
  
  

Measured memory_bytes: 5624
N = int(input())
 
def num_divisors_table(N):
    ans = 0
    for i in range(1, N + 1):
        u = i
        t = i * (N // i)
        n = N // i
        ans += (u + t) * n // 2
    
    return ans

print(num_divisors_table(N))

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

#define ll             long long
#define LL             long long
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define ff             first
#define ss             second
#define sz(x)          (int)x.size()
#define TN             typename
#define all(v)         v.begin(), v.end()
#define fill(a, b)     memset(a, b, sizeof(a))
#define endl           '\n'

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> T sqr(T a) {return a * a;}
template <TN T> T cube(T a) {return a * a * a;}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}

template <TN T> inline void Int(T &n) {
	n = 0; int f = 1; register int ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
	for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
	n = n * f;
}

#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
	vector <string> v;
	stringstream ss(s); string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
	cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
	err(++it, args...);
}

inline int in() {int n; scanf("%d", &n); return n;}
inline ll Lin() {ll n; scanf("%lld", &n); return n;}
inline double Din() {double n; scanf("%lf", &n); return n;}

inline int add(int a, int b, int mod) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b, int mod) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod;}

const int N          = 2e5 + 5;
const ll  Mod        = (ll)1e9 + 7;
const int inf        = (int)2e9;
const ll  Inf        = (ll)1e18;
const int mod        = (int)1e9 + 7;


int solve() {
	int n = in(), k = in();
	vi dp(k + 1);
	dp[0] = 1;
	for (int child = 1; child <= n ; child++) {
		int upto = in();
		vi prefix(k + 1);
		for (int used = k; used >= 0; used--) {
			int tem = dp[used];
			int l = used + 1, r = min(k, used + upto);
			if (l <= r) {
				prefix[l] = add(prefix[l], tem, mod);
				if (r + 1 <= k) prefix[r + 1] = sub(prefix[r + 1], tem, mod);
			}
		}
		int sum = 0;
		for (int i = 1; i <= k; i++) {
			sum = add(sum, prefix[i], mod);
			dp[i] = add(dp[i], sum, mod);
		}
	}
	printf("%d\n", dp[k]);
	return 0;
}

int main() {
	int test = 1, tc = 0;
	//scanf("%d", &test);
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}





Measured memory_bytes: 1024
import sys
import math
input = sys.stdin.readline

a, b, x = map(int, input().split())

if x <= a*a*b/2:
    ans = 90 - math.degrees(math.atan(2*x/(a*b*b)))
else:
    ans = math.degrees(math.atan(2*(a*a*b-x)/(a*a*a)))

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 300001
#define PI 3.14159265358979323846264338327950
 
#define ll    long long int 
#define mod  1000000007

ll dp[205];

int main()
{
	FAST;
	ll a, b, c;
	cin >> a >> b >> c; ll ans = 0;
	if(a % c == 0){
		ans = 0;
	}
	else{
		a -= a%c;
		a += c;
	}
	while(a <= b){
		ans ++;
		a += c;
	} cout << ans;
}

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

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

inline int Pow(int a, int k) {
  int s = 1; 
  for(; k; k >>= 1) {
    k & 1 ? s = 1LL * s * a % MOD : 0;
    a = 1LL * a * a % MOD;
  }
  return s;
}

// Init variables here
const int N = 1e6 + 7;

void input() {
  //freopen("??.in", "r", stdin);
  //freopen("??.out", "w", stdout);
}

void preprocess() {
}

void debug() {
  //  44gg
  if (true) {
  
  }
}


void solve() {
  preprocess();
  // 50gg
  int n;
  cin >> n;
  int mx, a;
  cin >> mx;
  int res = 1;
  FOR(i, 1, n) {
    cin >> a;
    if (a >= mx) {
      res++;
      mx = max(mx, a);
    }
  }
  cout << res << endl;
  //debug();
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

void output() {

}

#undef int
int main() {
#define int long long
	ios_base::sync_with_stdio(false);
	cin.tie();
  //auto beginProgram = chrono::steady_clock::now();

  //int t; cin >> t;
  //while (t--) 
  {
    input();
    solve();
    output();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


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

int main(void){
	int n = 0;
	double debt = 100;	/*100 thousand yen*/
	int i = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		debt = ceil(debt * 1.05);
	}

	printf("%d\n", (int)(debt * 1000));

	return 0;
}

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

using namespace std;

#define sz(a) int(a.size())

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

	map <int, vector <int> > ev_I, ev_O;

	set <int> ev;
	for (int i = 0; i < n; i++) {
		int s, t, x;
		cin >> s >> t >> x;
		ev_I[s-x].push_back(x);
		ev_O[t-x].push_back(x);
		ev.insert(s-x), ev.insert(t-x);
	}

	multiset<int> cur;
	int last = -1;

	vector <int> D (q);
	for (int &t : D) cin >> t;

	int id = 0;
	for (auto t : ev) {
		if (ev_O.count(t)) {
			for (auto r : ev_O[t]) cur.erase(cur.find(r));
		}
		if (ev_I.count(t)) {
			for (auto r : ev_I[t]) cur.insert(r);
		}

		while (id < q && D[id] < t) id++, cout << last << endl;

		last = cur.empty() ? -1 : *begin(cur);
	}

	while (id < q) id++, cout << -1 << endl;


}



Measured memory_bytes: 73856
#include  <stdio.h>
#define N 100

int main(){
	int i,j,n,temp,A[N],cnt=0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
		
		//?????????????????????
		for (i = 0; i < n - 1; i++) {
        	for (j = n - 1; j > 0; j--) {
            	if (A[j - 1] > A[j]) {  /* ??????????´????????????§????????£?????? */
                	temp = A[j];        /* ???????????? */
                	A[j] = A[j - 1];
                	A[j - 1]= temp;
                	cnt++;
            	}
        	}
    }
	 for (i = 0; i < n-1 ; i++)
        	printf("%d ", A[i]);
        	printf("%d\n",A[i]);
        	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define MOD 1000000007
#define long long long

// x^n mod
long mod_pow(long x, long n, long mod){
  long res=1;
  x %= mod;
  while(n>0){
    if(n&1) res=res*x%mod;
    x=x*x%mod;
    n>>=1;
  }
  return res;
}
long mod_inv(long x){ return mod_pow(x,MOD-2,MOD); }

long fact[1005];
long fact_inv[1005];
long inv[1005];
long comb(long n, long k){ return fact[n]*fact_inv[k]%MOD*fact_inv[n-k]%MOD; }

int main(){
  long n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  vector<vector<long>> dp(b+1, vector<long>(n+1,0));
  // dp[i][j] i人以下のグループのみからなる組み合わせをn人のうちのj人からつくる

  fact[0]=1;
  rep(i,1000) fact[i+1]=(i+1)*fact[i]%MOD;
  rep(i,1001) fact_inv[i]=mod_inv(fact[i]);
  rep(i,1001) inv[i]=mod_inv(i);

  dp[0][0]=1;
  rep(i,b) dp[i][0]=1;
  repl(i,a,b+1){
    repl(j,1,n+1){
      long tmp = 1;
      long x = n-j;
      dp[i][j] = dp[i-1][j];
      for(int k=1; k*i<=n; k++){
        if(k>d) break;
        if(j<i*k) break;
        x += i;
        tmp = tmp*comb(x,i)%MOD*inv[k]%MOD;
        if(k<c) continue;
        dp[i][j] += tmp*dp[i-1][j-i*k];
        dp[i][j] %= MOD;
      }
    }
  }
//  rep(i,b+1)dbg(dp[i]);

  cout<<dp[b][n]<<endl;

  return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    int cost = 100000000;
    for(int ix=0;ix<n;ix++){
        cin >> a.at(ix);
    }
    for(int ix=-100;ix<=100;ix++){
        int tmp=0;
        for(int ixx=0;ixx<n;ixx++){
            tmp += pow(a.at(ixx) - ix, 2);
        }
        cost = min(cost,tmp);
    }
    cout << cost << endl;
}

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

using namespace std;

vector <string> v;
long long same, sol, n;

int main()
{
    cin >> n;

    for(long long i = 1; i <= n; ++i)
    {
        char x[20];
        cin >> x;
        sort(x, x + 10);
        v.push_back(x);
    }

    sort(v.begin(), v.end());
    auto it2 = v.begin();
    ++it2;
    same = 1;

    for(auto it = v.begin(); it2 != v.end(); ++it, ++it2)
    {
        if(*it == *it2)
        {
            ++same;
        }
        else
        {
            sol += same * (same - 1) / 2;
            same = 1;
        }
    }

    sol += same * (same - 1) / 2;
    cout << sol;
    return 0;
}


Measured memory_bytes: 5748
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N;
	std::cin >> N;
	std::vector<int> count(N);
	for (auto i : boost::irange(N - 1))
	{
		int a;
		std::cin >> a;
		--a;
		++count[a];
	}
	for (auto v : count)
	{
		std::cout << v << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3992
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader();
		int n=s.nextInt();
		int k=s.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++) {
			arr[i]=s.nextInt();
		}
		int[] dp=new int[n];
		for(int i=1;i<n;i++) {
			int temp=k;
			int pos=i-1;
			int min=Integer.MAX_VALUE;
			while(temp>0 && pos>=0) {
				min=Integer.min(dp[pos]+Math.abs(arr[i]-arr[pos]), min);
				temp--;
				pos--;
			}
			dp[i]=min;
		}
		out.println(dp[n-1]);
		out.close();
	}

	public static PrintWriter out;
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
}


Measured memory_bytes: 32900
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_N = 100000;



int main(int argc, char *args[]) {
	int N;
	cin >> N;
	cout << N * N * N << endl;
}

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

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
    string N;
    cin >> N;

    if (N[N.size()-1]=='2'||N[N.size()-1]=='4'||N[N.size()-1]=='5'||N[N.size()-1]=='7'||N[N.size()-1]=='9')
    {
        cout << "hon";
    }
    else if (N[N.size()-1]=='0'||N[N.size()-1]=='1'||N[N.size()-1]=='6'||N[N.size()-1]=='8')
    {
        cout << "pon";
    }
    else
    {
        cout << "bon";
    }
    
    

    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}
int S,D,M;
vector<pii> ss[1001];
int fs[1001];
pii dp[101][51][1001];
const int INF=1<<30;
pii dfs(int pos,int k,int money){
  if(dp[pos][k][money].first!=INF)return dp[pos][k][money];
  pii res;
  int kind=fs[pos];
  if(pos==D)return res;
  if(k==(int)ss[kind].size())return dfs(pos+1,0,money);
  res=min(res,dfs(pos,k+1,money));
  if(money-ss[kind][k].second>=0){
    pii tmp=dfs(pos,k+1,money-ss[kind][k].second);
    tmp.first-=ss[kind][k].first;
    tmp.second+=ss[kind][k].second;
    res=min(res,tmp);
  }
  return dp[pos][k][money]=res;
}

int main(){
  while(cin>>S>>D>>M){
    for(int i=0;i<101;i++)
      for(int k=0;k<51;k++)
	for(int j=0;j<301;j++)
	  dp[i][k][j].first=INF;
    for(int i=0;i<S;i++){
      ss[i].clear();
      int k;
      cin>>k;
      for(int j=0;j<k;j++){
	int w,p;
	cin>>w>>p;
	ss[i].push_back(pii(w,p));
      }
    }
    for(int i=0;i<D;i++)cin>>fs[i];
    pii p=dfs(0,0,M);
    cout<<-p.first<<" "<<p.second<<endl;
  }
  return 0;  
}

Measured memory_bytes: 41924
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n) cout<<fixed<<setprecision(n);
#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  ll a, b, c, d; cin >> a >> b >> c >> d;
  outl(max(max(0LL, a * b), c * d))
}


Measured memory_bytes: 256
s = input()
K = int(input())
d = []
ele = []
for i in range(len(s)):
    for j in range(0,K):
        substr = s[i:i+j+1]
        if not substr in d and len(substr)<=K:
            d.append(substr)
d.sort()
print(d[K-1])


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

using namespace std;

int main(){
    ll n;
    cin>>n;
    ll m = n;
    set <ll> s;
    while(n--){
        ll t;
        cin>>t;
        s.insert(t);
    }
    if(s.size() == m) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 9600
N = int(input())
H = list(map(int,input().split()))

h = [0]*N
ans = 0
while any(a<b for a,b in zip(h,H)):
    ans += 1
    l = r = -1
    for i in range(N):
        if l < 0:
            if h[i]==H[i]: continue
            l = i
        else:
            if h[i]<H[i]: continue
            r = i
            break
    else:
        r = N
    for i in range(l,r):
        h[i] += 1
print(ans)

Measured memory_bytes: 3064
function Main(input) {
  input = input.split("\n");
  var A = parseInt(input[0]);
  var B = parseInt(input[1]);
  var C = parseInt(input[2]);
  var D = parseInt(input[3]);
  var result = null;
  var result1 = null;
  if (A < B) {
    result = A;
  } else {
    result = B;
  }
  if (C < D) {
    result1 = C;
  } else {
    result1 = D;
  }
  console.log(result + result1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
  s = input()
  if s == 'AC':
    AC += 1
  elif s == 'WA':
    WA += 1
  elif s == 'TLE':
    TLE += 1
  else:
    RE += 1
print('AC','x', AC)
print('WA','x', WA)
print('TLE','x', TLE)
print('RE','x', RE)

Measured memory_bytes: 9204
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct query{
	int a;
	int b;
	int o;
};

int main() {
	while (1) {
		int R, C, Q; cin >> R >> C >> Q;
		if (!R)break;
		vector<query>qs;
		for (int i = 0; i < Q; ++i) {
			int a, b, o; cin >> a >> b >> o;
			qs.push_back(query{ a,b,o });
		}
		reverse(qs.begin(), qs.end());
		vector<int>rstatus(R), cstatus(C);
		int rvalid = R, cvalid = C;
		int ans = 0;
		for (int i = 0; i < Q; ++i) {
			query q(qs[i]);
			if (q.o == 1) {
				if (q.a == 0) {
					if (!rstatus[q.b]) {
						rstatus[q.b] = 1;
						ans += cvalid;
						rvalid--;
					}
				}
				else {
					if (!cstatus[q.b]) {
						cstatus[q.b] = 1;
						ans += rvalid;
						cvalid--;
					}
				}
			}
			else {
				if (q.a == 0) {
					if (!rstatus[q.b]) {
						rstatus[q.b] = -1;
						rvalid--;
					}
				}
				else {
					if (!cstatus[q.b]) {
						cstatus[q.b] = -1;
						cvalid--;
					}
				}
			}

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

Measured memory_bytes: 4204
package FenwickTree;
sub new{
	return bless[(0)x$_[1]],$_[0];
}
sub add{
	my$self=shift;
	my$p=$_[0]+1;
	while($p<=@{$self}){
		$self->[$p-1]+=$_[1];
		$p+=$p&-$p;
	}
}
sub sum{
	my$self=shift;
	return$self->prefixsum($_[1])-$self->prefixsum($_[0]);
}
sub prefixsum{
	my$self=shift;
	my$r=shift;
	my$s=0;
	while($r>0){
		$s+=$self->[$r-1];
		$r-=$r&-$r;
	}
	return$s;
}
package main;
my($N,$Q)=split$",<>;
my$fenwicktree=FenwickTree->new($N);
my@a=split$",<>;
for$i(0..$#a){
	$fenwicktree->add($i,$a[$i]);
}
for(1..$Q){
	my($t,$a,$b)=split$",<>;
	if($t==0){
		$fenwicktree->add($a,$b);
	}
	else{
		print$fenwicktree->sum($a,$b),$/;
	}
}


Measured memory_bytes: 80828