akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
    // clang-format on

#include <cmath>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll S;
    cin >> S;
    cout << 0 << " " << 0 << " ";
    ll a = ceil(sqrt(S));
    cout << a << " " << 1 << " ";
    cout << a * a - S << " " << a << endl;
    return 0;
}


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

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N,Q;
    cin >> N >> Q;
    vector<vector<int>> ki(N,vector<int>(0));
    vector<int> sum(N);
    vector<int> ans(N);
    vector<int> bran(N);
    vector<int> next(0);
    vector<int> root(N);
    REP(i,N - 1){
        int l,m;
        cin >> l >> m;
        ki[l - 1].push_back(m - 1);
        ki[m - 1].push_back(l - 1);
        bran[l - 1]++;
        bran[m - 1]++;
    }
    REP(i,Q){
        int l,m;
        cin >> l;
        cin >> m;
        sum[l-1]+=m;
    }
    next.push_back(0);
    root[0] = -1;
    REP(i,N){
        ans[next[i]] = sum[next[i]];
        REP(o,bran[next[i]]){
            if(root[next[i]] != ki[next[i]][o]){
                sum[ki[next[i]][o]]+=sum[next[i]];
                root[ki[next[i]][o]] = next[i];
                next.push_back(ki[next[i]][o]);
            }
        }
    }
    REP(i,N)cout <<ans[i]<< "\n";
}

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

int main(){
    string n;
    cin >> n ;
    int ans=0;
    if((n[0]==n[1]&&(n[1]==n[2]))||((n[1]==n[2])&&(n[2]==n[3]))) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._


  val Array(n, d) = readLine.trim.split(' ').map(_.toInt)
  val len = readLine.trim.split(' ').map(s ⇒ (s.toInt - 1) % (d + 1))
  println(
    if (len.reduce(_^_) == 0) "Second" else "First"
  )
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 100240
S = input()
a = int(S[0] + S[1])
b = int(S[2] + S[3])
if 1<=a<=12:
    if 1<=b<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=b<=12:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    void calc()
    {
        Scanner cin = new Scanner();
        while (true)
        {
            int N = cin.nextInt();
            int P = cin.nextInt();
            if (N == 0) break;
            int now = -1;

            int[] num = new int[N];
            int box = P;

            while (true)
            {
                now++; if (now >= N) now = 0;
                if (box > 0)
                {
                    box--;
                    num[now]++;
                    if (num[now] == P)
                    {
                        Console.WriteLine(now);
                        break;
                    }
                }
                else
                {
                    box = num[now];
                    num[now] = 0;
                }
            }

        }

    }
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        do
        {
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        } while ((s.Length == 1 && s[0] == "") || s.Length == 0);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 5628
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
using namespace std;
using namespace tr1;
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
//const int INF = 100000000000+1;
//const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

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

        ll n, smol = 10e11+1;
        cin >> n;
        FOR(i,1,sqrt(n)){
            if(n % i == 0)
                smol = min(smol, i + n/i - 2);
        }
        cout << smol;
        return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );
struct node
{
    int to,next;
}e[MAX];
int head[MAX],cut;
void add(int u,int v)
{
    e[cut].to=v;
    e[cut].next=head[u];
    head[u]=cut++;
}
int f[MAX],dp[MAX],p[MAX],x[MAX],n;
int dfs(int u)
{
    for(int i=head[u];~i;i=e[i].next)//先遍历。
        dfs(e[i].to);
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    for(int i=head[u];~i;i=e[i].next)
    {
        int v=e[i].to;
        for(int j=x[u];j>=0;j--)
        {
            int temp=INF;
            if(j>=x[v]) //u,v同色。
                temp=min(temp,dp[j-x[v]]+f[v]);
            if(j>=f[v])//u,v不同色。
                temp=min(temp,dp[j-f[v]]+x[v]);
            dp[j]=temp;
        }
    }
    for(int i=0;i<=x[u];i++)
        f[u]=min(f[u],dp[i]);
}
int main()
{
    cut=0;
    memset(head,-1,sizeof(head));
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        scanf("%d",&p[i]);
        add(p[i],i);
    }
    for(int i=1;i<=n;i++)
        scanf("%d",&x[i]);
    memset(f,0x3f,sizeof(f));
    
    dfs(1);
    if(f[1]<INF)
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}

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

#define int long long

const int N = 2e3 + 10 ;
const int mod = 1e9 + 7 ;

int dp[N] ;
int n ;
int solve(int i = 0){
	if(i > n) return 0 ;
	if(i == n){
		return 1 ;
	}
	if(~dp[i]) return dp[i] ;
	int ans = 0 ;
	for(int j = 3 ; j <= n ; j++){
		ans = (ans + solve(i + j)) % mod ;
	}
	return dp[i] = ans ;
}

int32_t main(){
	cin >> n ;
	memset(dp , -1 , sizeof(dp)) ;
	cout << solve() ;
	return 0 ;
}



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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 2e5+10;
const lint LNF = 2e18;

int n, A[MAX], m; // [1,m]
vector<int> G[MAX];
int ans[MAX];

inline int _max(int a, int b){ return a<b ? b : a; }

struct Seg_t{
	int sz, T[1<<19] = {};
	multiset<int> V[MAX];
	void init(int zs){
		sz = zs;
		for(int i=0; i<(1<<19); i++) T[i] = -INF;
	}

	void put(int v, int s, int e, int x, int d){
		if(x<s || e<x) return;
		if(s==e){
			V[x].insert(d);
			T[v] = (V[x].empty() ? -INF : *V[x].rbegin());
			return;
		}
		put(v*2, s, (s+e)/2, x, d);
		put(v*2+1, (s+e)/2+1, e, x, d);
		T[v] = _max(T[v*2], T[v*2+1]);
	}

	void pop(int v, int s, int e, int x, int d){
		if(x<s || e<x) return;
		if(s==e){
			auto it = V[x].find(d);
			V[x].erase(it);
			T[v] = (V[x].empty() ? -INF : *V[x].rbegin());
			return;
		}
		pop(v*2, s, (s+e)/2, x, d);
		pop(v*2+1, (s+e)/2+1, e, x, d);
		T[v] = _max(T[v*2], T[v*2+1]);
	}

	int mx(int v, int s, int e, int l, int r){
		if(e<l || r<s) return -INF;
		if(l<=s && e<=r) return T[v];
		return _max(mx(v*2, s, (s+e)/2, l, r), mx(v*2+1, (s+e)/2+1, e, l, r));
	}

	void put(int x, int d){ put(1, 1, sz, x, d); }
	void pop(int x, int d){ pop(1, 1, sz, x, d); }
	int mx(int l, int r){ return mx(1, 1, sz, l, r); }
} Seg;

void solve(int v, int p){
	int now = Seg.mx(1, A[v]-1) + 1;
	// cout<<"Now: "<<v<<" ("<<A[v]<<")"<<' '<<now<<'\n';
	Seg.put(A[v], now);
	ans[v] = Seg.mx(1, m);
	for(int x:G[v]){
		if(x==p) continue;
		solve(x,v);
	}
	Seg.pop(A[v], now);
}

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

	cin>>n;
	vector<int> X;
	for(int i=1; i<=n; i++) cin>>A[i], X.push_back(A[i]);
	X.push_back(0);
	sort(X.begin(), X.end());
	m = unique(X.begin(), X.end()) - X.begin();
	X.resize(m);
	for(int i=1; i<=n; i++)
		A[i] = lower_bound(X.begin(), X.end(), A[i]) - X.begin() + 1;
	
	for(int i=1; i<n; i++){
		int u,v; cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	Seg.init(m);
	Seg.put(1, 0);
	solve(1, 0);

	for(int i=1; i<=n; i++) cout<<ans[i]<<'\n';

	return 0;
}


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

typedef pair<int, int> P;

int N;
vector<int> G[100000];
vector<int> c(100000);
vector<P> v;
vector<int> ans(100000);
priority_queue<int> que_max;

void dfs(int s) {
    ans[s] = que_max.top();
    que_max.pop();
    queue<int> que;
    que.push(s);

    while (que.size()) {
        int p = que.front();
        que.pop();

        for (int i = 0; i < G[p].size(); i++) {
            int to = G[p][i];
            if (ans[to] == 0) {
                ans[to] = que_max.top();
                que_max.pop();
                que.push(to);
            }
        }
    }
}

int main() {
    cin >> N;
    vector<int> F(N - 1), B(N - 1);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        F[i] = a;
        B[i] = b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    for (int i = 0; i < N; i++) {
        int c;
        cin >> c;
        que_max.push(c);
    }

    for (int i = 0; i < N; i++) {
        v.emplace_back(P(G[i].size(), i));
    }
    sort(v.begin(), v.end());
    dfs(v[0].second);

    int sum = 0;
    for (int i = 0; i < N - 1; i++) {
        sum += min(ans[F[i]], ans[B[i]]);
    }
    cout << sum << endl;

    for (int i = 0; i < N; i++) {
        cout << ans[i];
        if (i != N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int N=200010;

int main(){ 
    char a[N],b[N];
    cin>>a>>b;
    int ans=0;
    for(int i=0;i<strlen(a);i++){
        if(a[i]!=b[i]) ans++;
    }
    cout<<ans<<endl;
  
    return 0;
}



Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N;
ll A[100000];
ll l[100010], r[100010];
ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N) cin>>A[i];
    l[0]=A[0];
    rep(i,0,N-1){
        l[i+1]=gcd(l[i], A[i+1]);
    }
    r[N-1]=A[N-1];
    rer(i,N,1){
        r[i-1]=gcd(r[i],A[i-1]);
    }
    if(N==2){
        cout <<max(A[0], A[1])<<"\n";
        return 0;
    }
    ll ans=max(r[1], l[N-2]);
    rep(i,1,N-1){
        ans=max(gcd(l[i-1], r[i+1]), ans);
    }
    cout <<ans<<"\n";
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n,0);
  
  for(int i=0;i<n-1;i++){
    int x;
    cin >> x;
    a.at(x-1)++;
  }
  
  for(int i=0;i<n;i++)
    cout << a.at(i) << endl;
}

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

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

class Rectangles {
    public:
    ll n;
    std::vector<ll> xs;  // n番目の長方形の左上のx座標->n*2, 右下のx座標->n*2+1
    std::vector<ll> ys;
    std::vector<ll> xss;  // xs, ysをsortしたもの exのy,xに対応
    std::vector<ll> yss;
    std::vector<std::vector<ll>> ex;

    Rectangles(ll n) : n(n){
        xs.assign(n*2+1, 0); ys.assign(n*2+1, 0);
        ex.assign(n*2+1, std::vector<ll>(n*2+1, 0));
    }

    void push(ll num, ll x1, ll y1, ll x2, ll y2){
        xs[num*2]=x1; xs[num*2+1]=x2;
        ys[num*2]=y1; ys[num*2+1]=y2;
    }
    void build(){
        xss = xs;
        yss = ys;
        std::sort(xss.begin(), xss.end()); std::sort(yss.begin(), yss.end());
        for(ll i=0; i<n; i++){
            ll xl = std::distance(xss.begin(), std::lower_bound(xss.begin(), xss.end(), xs[i*2]));
            ll yl = std::distance(yss.begin(), std::lower_bound(yss.begin(), yss.end(), ys[i*2]));
            ll xr = std::distance(xss.begin(), std::lower_bound(xss.begin(), xss.end(), xs[i*2+1]));
            ll yr = std::distance(yss.begin(), std::lower_bound(yss.begin(), yss.end(), ys[i*2+1]));
            ex[yl][xl]++;
            ex[yl][xr]--;
            ex[yr][xl]--;
            ex[yr][xr]++;
        }
        for(ll x=0; x<=n*2; x++)for(ll y=0; y<n*2; y++) ex[y+1][x] += ex[y][x];
        for(ll y=0; y<=n*2; y++)for(ll x=0; x<n*2; x++) ex[y][x+1] += ex[y][x];
    }

    ll calc_area(){
        ll ans=0;
        for(ll x=0; x<n*2; x++)for(ll y=0; y<n*2; y++)if(ex[y][x]>0){
            ans += (xss[x+1]-xss[x]) * (yss[y+1]-yss[y]);
        }
        return ans;
    }
};

int main(){
    ll n, x1, y1, x2, y2;
    cin >> n;
    Rectangles rc(n);
    REP(i,n){
        cin >> x1 >> y1 >> x2 >> y2;
        rc.push(i, x1, y1, x2, y2);
    }
    rc.build();
    /*
    REP(y,4){
        REP(x,4)cout << rc.ex[y][x] << " ";
        cout << endl;
    }*/
    cout << rc.calc_area() << endl;
}


Measured memory_bytes: 128264
#include<bits/stdc++.h>
#define lint long long int
using namespace std;

int main() {
	lint k=0;
	lint ans=0;
	lint p=0;
	cin>>k;
	for(int h=1;h<=k;h++)
	{
		for(int i=1;i<=k;i++)
		{
			for(int j=1;j<=k;j++)
			{
				p=gcd(h,i);
				ans+=gcd(p,j);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string();
int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
    lli l,r;
    cin>>l>>r;
    lli d=r-l;
    if(d>=2019)cout<<0;
    else{
    	lli ans=2018;
    	for(lli i=l;i<=r;i++)for(lli j=i+1;j<=r;j++)ans=min(ans,(i*j)%2019);
    		cout<<ans;
    }




	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

int A[25][25];
ll DP[1<<21];
ll mod = 1e9+7;
int n;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        cin>>A[i][j];

    DP[0]=1;
    for(int mask = 1; mask < (1<<n); mask++)
        for(int j=0; j<n; j++)
    {
        int man = __builtin_popcount(mask);
        if(A[man-1][j] && (mask&(1<<j)))
           DP[mask] = (DP[mask] + DP[mask^(1<<j)])%mod;
    }

    cout<<DP[(1<<n) -1];
}


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

int main(){
  int x;
  cin >> x;
  for(int i=1;i<361;i++){
    if(x*i%360==0){
      cout << i <<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	int n;

	std::cin >> n;

	std::vector<int> v1(n), v2(n), v3(n), v4;

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v1[i];
		v3[i] = i + 1;
	}

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v2[i];
	}

	v4 = v3;

	int count1 = 0, count2 = 0;
	do {
		bool flag = true;
		for (size_t i = 0; i < n; i++)
		{
			if (v1[i] != v3[i]) {
				flag = false;
			}
		}
		if (flag) break;
		count1++;
	} while (std::next_permutation(v3.begin(), v3.end()));

	do {
		bool flag = true;
		for (size_t i = 0; i < n; i++)
		{
			if (v2[i] != v4[i]) {
				flag = false;
			}
		}
		if (flag) break;
		count2++;
	} while (std::next_permutation(v4.begin(), v4.end()));

	std::cout << std::abs(count1 - count2) << std::endl;

	return 0;
}

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

using namespace std;
typedef long long int lint;

void call(int n) {
	int i = 1;
CHECK_NUM:
	int x = i;
	if (x % 3 == 0) {
		cout << " " << i;
		goto END_CHECK_NUM;
	}
INCLUDE3:
	if (x % 10 == 3) {
		cout << " " << i;
		goto END_CHECK_NUM;
	}
	x /= 10;
	if (x) goto INCLUDE3;
END_CHECK_NUM:
	if (++i <= n) goto CHECK_NUM;

	cout << endl;
}

void answer()
{
	int n;
	cin >> n;

	call(n);
}

int main()
{
	answer();
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
using namespace std;

int main(){

  string str, s;
  int n, len, high, low;
  
  cin >> n;

  for(int i=0; i<n; i++){
    cin >> str;

    high = 0;
    low = 0;
    for(int j=0; j<2; j++){
      s = str;
      len = str.length();
      if(j == 0){
        sort(&str[0], &str[0]+len, greater<int>());
        for(int k=len-1; k>=0; k--){
          high += ((int)str[k] - '0') * pow(10, len-1-k);
        }
      }
      else{
        sort(&str[0], &str[0]+len);
        for(int k=len-1; k>=0; k--){
          low += ((int)str[k] - '0') * pow(10, len-1-k);
        }
      }
    }
    
    cout << high - low << endl;

  }

  return 0;

}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
   int n;
   cin >> n;
   map<int,int>a;
   for(int i=0;i<n;i++) {
      int b;
      cin >> b;
      //cout << b<<endl;
      if(a[b]==1){
         cout << "NO"<<endl;
         return 0;
      }
      a[b]++;
      
   }
   cout << "YES"<<endl;
   return 0;
}




Measured memory_bytes: 9600
#include <cstdio>
#include <cassert>
#include <cstring>
using namespace std;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    int x = -1, y = -1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char buf[10];
            scanf("%s", buf);
            if (strcmp(buf, "snuke") == 0) {
                x = j;
                y = i + 1;
            }
        }
    }
    assert(x != -1);
    printf("%c%d\n", (char)(x + 'A'), y);
}


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

int main(){
  int N;
  ll a[300001];
  ll b[300001];
  int cnt(0);
  cin>>N;
  for (int i(1);i<=N;i++)cin>>b[i];
  for (int i(N/2+1);i<=N;i++){
    a[i]=b[i];
    if (a[i]==1)cnt+=1;
  }
  for (int i(N/2);i>0;i--){
    // a[i] is needed
    int sum(0);
    for (int j(i*2);j<=N;j+=i){
      sum+=a[j];
    }
    // cout <<sum << " " <<  b[i] << endl;
    if (sum%2==b[i]) a[i]=0;
    else {
      a[i]=1;
      cnt+=1;
    }
  }

  cout << cnt << endl;
  for (int i(1);i<=N;i++){
    if (a[i]==1){
      cout << i << endl;
    }
  }
  return 0;
}


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

int main() {
	string ans;
	int n;
	int max = 0;
	int sum = 0;

	cin >> n;
	
	vector<int> L(n);

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

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

		sum += L[i];
		
		if (max < L[i]) {
			max = L[i];
		}
	}
	
	if (sum - max > max) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc133/tasks/abc133_e

# あー解説あたまいい
# そのノードで塗れる色の候補を持つのではなくて、
# そのノードの子で塗れる通りの数を持っておく
# あるノードの子で塗れる通りの数は、親とそのノードで塗る色の通りも確定してると考えると、(K-2)P(子の数)となる。(自身が根のときは自身の色の通りも考慮して、(K)P(子の数+1)となる)
# これをdfsで実装すれば良い

import sys
from collections import defaultdict

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


MOD = 10**9 + 7

N, K = read_ints()
tree = defaultdict(lambda: [])
for _ in range(N - 1):
    a, b = read_ints()
    a, b = mina(a, b)
    tree[a].append(b)
    tree[b].append(a)


def perm_mod(n, r, mod=MOD):
    # assert n >= r
    ret = 1
    for _ in range(r):
        ret *= n
        ret %= mod
        n -= 1
    return ret


def dfs(u, p):  # 現在のuと親のp
    if len(tree[u]) == 1 and tree[u][0] == p:
        # 葉なので終了
        return 1
    ret = 1  # その地点までの通りの数
    for to in tree[u]:
        if to == p:
            continue
        ret *= dfs(to, u)
        ret %= MOD
    if p == -1:
        ret *= perm_mod(K, len(tree[u]) + 1)
    else:
        ret *= perm_mod(K - 2, len(tree[u]) - 1)

    return ret % MOD


print(dfs(0, -1))


Measured memory_bytes: 97408
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char[] topping = str.toCharArray();
        int ans = 700;
        for (int i = 0; i < 3; i++) {
        	if (topping[i] == 'o') {
        		ans += 100;
        	}
        }
        System.out.println(ans);
    }
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a==b) cout << "Draw" << endl;
  else if(a==1) cout << "Alice" << endl;
  else if(b==1) cout << "Bob" << endl;
  else if(a>b) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++ )
#define EPS (1e-8)
class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0) :
			x(x), y(y) {
	}
	Point operator +(Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator *(double a) {
		return Point(x * a, y * a);
	}
};
typedef Point Vector;
typedef vector<Point> Polygon;
double norm(Vector a) {
	return a.x * a.x + a.y * a.y;
}
double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw(Point p0, Point p1, Point p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if (cross(a, b) > EPS)
		return COUNTER_CLOCKWISE;
	if (cross(a, b) < -EPS)
		return CLOCKWISE;
	if (dot(a, b) < -EPS)
		return ONLINE_BACK;
	if (norm(a) < norm(b))
		return ONLINE_FRONT;
	return ON_SEGMENT;
}
bool isIntersect(Point p1, Point p2, Point p3, Point p4) {
	return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0
			&& ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool isInside(Polygon pol, Point p) {
	rep(i, 4)
	{
		if (ccw(pol[i], pol[(i + 1) % 4], p) == COUNTER_CLOCKWISE)
			return false;
	}
	return true;
}
bool isIntersectSQ(Polygon p1, Polygon p2) {
	rep(i, 3)
		rep(j, 3)
		{
			if (isIntersect(p1[i], p1[i + 1], p2[j], p2[j + 1]))
				return true;
		}
	rep(i, 4)
		if (isInside(p1, p2[i]))
			return true;
	rep(i, 4)
		if (isInside(p2, p1[i]))
			return true;
	return false;
}
Polygon P[100];
int n, G[100][100];
bool V[100];
//??????????????????????????????????????°???????????????????????????
//?????????V????????¨?????§?????????????´???\???????????°?????????????????°??????used true?????????
//???????????£??????????????¨????????????V????????????????????????????????????????????????
//G????????????????????????????????????????????????from to???????????????????????????V????????????
//??????G???????????§??§????????£????????????????????????V??????????????????????????§????????£??????????????£?????????
//?????°??????true??????????????????????????±??????true?????????????????????????????????
//

void dfs(int u) {
	V[u] = true;
	rep(v, n)
		if (G[u][v] && !V[v])
			dfs(v);
}
int compute() {
	rep(i, n)
		rep(j, n )
			G[i][j] = 0;
	rep(i, n)
		rep(j, n )
			if (isIntersectSQ(P[i], P[j]))
				G[i][j] = 1;
	rep(i, n)
		V[i] = false;
	int ncomponent = 0;
	rep(i, n)
	{
		if (V[i])
			continue;
		ncomponent++;
		dfs(i);
	}
	return ncomponent;
}
int main() {
	int N;
	double x, y;
	while (cin >> N && N) {
		rep(i, N)
		{
			cin >> n;
			rep(j, n)
			{
				Polygon pol;
				rep(k, 4)
				{
					cin >> x >> y;
					pol.push_back(Point(x, y));
				}
				P[j] = pol;
			}
			cout << compute() << endl;
		}
	}
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    rep(i, n, 1000){
        if(i % 111 == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2))
    cout << "Yes" << endl;
  else if (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(1))
    cout << "Yes" << endl;
  else if (S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
    int N;
    cin >> N;
    int p;
    int count = 0;
    for(int i = 0;i < N;i++) {
        cin >> p;
        if(p != i + 1) {
            count++;
        }
    }
    if(count < 3) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())

a = [int(input()) for _ in range(M)]
a .append(N+10)

mod_num = 10 ** 9 + 7


def check(target, _pointer):
    while _pointer < M + 2:
        if a[_pointer] == target:
            return True, _pointer
        elif a[_pointer] < target:
            _pointer += 1
        else:
            return False, _pointer


step = [0 for _ in range(N + 1)]

step[0] = 1
step[1] = 1 if a[0] != 1 else 0

pointer = 0

for i in range(2, N + 1):
    is_broken, pointer = check(i, pointer)
    step[i] = 0 if is_broken else (step[i - 1] + step[i - 2]) % mod_num

print(step[-1])

Measured memory_bytes: 7856
#include <iostream>
using namespace std;
int main(void){
    
    int n, k[10001]={}, flag, count;
    while(1){
        flag=0; //　１種類でも，景品が２個以上残っていたら，flagを1にする。
        count=0;
        cin >> n;
        if(n==0) break; //終了条件
        
        for(int i=0; i<n; i++){
            cin >> k[i];
            if(k[i]>=2) flag=1;
            if(k[i]!=0) count++;
        }
        
        if(flag==0){ //　２つ以上残っている景品がなかった場合
            cout << "NA" << endl;
        }
        
        else cout << count+1 << endl;
    }
    return 0;
}

/*
　同じ景品を２つ取るのに一番長くかかるパターンは，　すべての
　景品を１種類ずつ取ったあと，２周目に同じ景品を取るパターン。
　よって，全部の景品の種類（ただし，残りが０個のものを除く）
　＋１回目を求めればよいということです。
*/


Measured memory_bytes: 3116
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using namespace std;

int pow_mod(int a, int b, int p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

int factorial_mod(int a, int p) {
	if (!a)return 1;
	else return a * factorial_mod(a - 1, p) % p;
}

int sum_digit(int N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

int N;
int a[10100];

int main(){
	int cnt = 0;
	scanf("%d", &N);
	rep(i, N)scanf("%d", &a[i]);
	rep(i, N) {
		for (; a[i] % 2 == 0;) {
			a[i] /= 2;
			cnt++;
		}
	}
	printf("%d", cnt);
	return 0;
}

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

using namespace std;

#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

#define int long long

const int MOD = 1e9 + 7;
const int N = 504002;

string s;

signed main()
{
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        int n = s.size() - i;
        for (char c = 'a'; c <= 'z'; c++)
        {
            vector<int> x(s.size() + 1);
            x[s.size()] = 1e9;
            for (int j = s.size() - 1; j >= 0; j--)
            {
                if (s[j] == c) x[j] = 0;
                else x[j] = x[j + 1] + 1;
            }
            int t = 1;
            for (int j = 0; j < n; j++)
            {
                if (x[j] > i)
                    t = 0;
            }
            if (t)
            {
                cout << i;
                return 0;
            }
        }
    }
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(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);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, M, Q;
ll lr[501][501];

signed main() {
    cin >> N >> M >> Q;
    REP(i, M) {
        LCIN(l, r);
        l--, r--;
        lr[r][l]++;
    }
    REP(i, N) REPR(j, N - 1) { lr[i][j] += lr[i][j + 1]; }
    REP(j, N) REP(i, N) { lr[i + 1][j] += lr[i][j]; }
    REP(i, Q) {
        LCIN(p, q);
        p--, q--;
        cout << lr[q][p] << "\n";
    }
}


Measured memory_bytes: 2944
n = gets.chop.to_i

available = Array.new
for i in 1..9
	number = (i.to_s * 3).to_i
	available.push(number)
end

ok = 0 
i = 0
while ok == 0 && i < 9 do
	if n <= available[i]
		ok = 1
		puts available[i]
	end
	i += 1
end

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

fn main() {
    input! {
        a : i64,
        b : i64,
        c : i64,
        k : i64,
    }

    let mut ans: i64 = 0;

    let mut zan: i64 = k;

    ans += min(a, zan) * 1;
    zan -= min(a, zan);

    if zan == 0 {
        println!("{}", ans);
        return;
    }

    zan -= min(b, zan);

    if zan == 0 {
        println!("{}", ans);
        return;
    }

    ans += min(c, zan) * -1;

    println!("{}", ans);
}


Measured memory_bytes: 2076
n, m = map(int, input().split())

MOD = 10**9 + 7
def fact(x):
    res = 1
    for i in range(2, x+1):
        res *= i
        res %= MOD
    return res

if abs(n - m) > 1:
    ans = 0
elif abs(n - m) == 1:
    ans = (fact(n) * fact(m)) % MOD
else:
    # n == m
    ans = (fact(n) * fact(m) * 2) % MOD

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b, c; cin >> a >> b >> c;
    if(a != b && b != c && c != a){
        cout << "No" << endl;
        return 0;
    }

    if(a == b && b == c){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)


N, K = list(map(int, input().split()))
ans = Base_10_to_n(N, K)
print(len(ans))


Measured memory_bytes: 38472
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int n; cin >> n;
    vector<int> p(n);
    REP(i, n) scanf("%d", &p[i]);
    vector<int> a(n,1),b(n,1);
    REP(i, n) {
        a[p[i] - 1] += i;
        b[p[i] - 1] += i;
    }
    REP(i, n-1) {
        a[i + 1] += a[i];
        b[n - i - 2] += b[n - i - 1];
    }
    REP(i, n) printf("%d ", a[i]);
    printf("\n");
    REP(i, n) printf("%d ", b[i]);
    printf("\n");
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i=0; i<n; i++) cin >> a.at(i);
    for(int i=0; i<n; i++) b.at(a.at(i)-1) = i+1; 
    for(int i:b) cout << i << endl;
}

Measured memory_bytes: 1664
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
print(" ".join([str(s) for s in sum_row]))

Measured memory_bytes: 7696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {

			ArrayList<Integer> cardsArray = new ArrayList<Integer>();
			HashMap<Integer, Integer> cardsHash = new HashMap<Integer, Integer>();

			// 手札読み込み
			for (String s : line.split(",")) {
				int i = Integer.parseInt(s);
				//
				cardsArray.add(i);
				//
				if (cardsHash.containsKey(i)) {
					cardsHash.put(i, cardsHash.get(i) + 1);
				} else {
					cardsHash.put(i, 1);
				}
			}
			// 役判定
			if (isFourCard(cardsHash)) {
				System.out.println("four card");
			} else if (isFullHouse(cardsHash)) {
				System.out.println("full house");
			} else if (isStraight(cardsArray)) {
				System.out.println("straight");
			} else if (isThreeCard(cardsHash)) {
				System.out.println("three card");
			} else if (isTwoPair(cardsHash)) {
				System.out.println("two pair");
			} else if (isOnePair(cardsHash)) {
				System.out.println("one pair");
			} else {
				System.out.println("null");
			}
		}
	}

	public static boolean isFourCard(HashMap<Integer, Integer> cards) {
		if (cards.containsValue(4))
			return true;
		return false;
	}

	public static boolean isFullHouse(HashMap<Integer, Integer> cards) {
		if (cards.containsValue(3) && cards.containsValue(2))
			return true;
		return false;
	}

	public static boolean isStraight(ArrayList<Integer> cards) {
		Integer[] temp = cards.toArray(new Integer[] {});
		Arrays.sort(temp);

		boolean result = true;

		for (int i = 0; i < 4; i++) {
			if (temp[i + 1] - temp[i] == 1)
				result &= true;
			else
				result = false;
		}

		if (temp[0] == 1 && temp[1] == 10 && temp[2] == 11 && temp[3] == 12
				&& temp[4] == 13)
			result = true;

		return result;
	}

	public static boolean isThreeCard(HashMap<Integer, Integer> cards) {
		if (cards.containsValue(3))
			return true;
		return false;
	}

	public static boolean isTwoPair(HashMap<Integer, Integer> cards) {
		int count = 0;
		for (Integer v : cards.values()) {
			if (v == 2)
				count++;
		}
		return count == 2 ? true : false;
	}

	public static boolean isOnePair(HashMap<Integer, Integer> cards) {
		int count = 0;
		for (Integer v : cards.values()) {
			if (v == 2)
				count++;
		}
		return count == 1 ? true : false;
	}
}

Measured memory_bytes: 16948
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<int> a;
    int num =0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'I'){
            num++;
            a.push_back(num);
        }
        else if(s[i] == 'D'){
            num--;
            a.push_back(num);
        }
    }
    sort(a.begin(),a.end(),greater<int>());

    if(a[0] <= 0){cout << 0 << endl;}
    else cout << a[0] << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

from collections import defaultdict

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = II()
    A = LII()
    Q = II()

    ans = sum(A)
    d = defaultdict(int)
    for a in A:
        d[a] += 1

    for _ in range(Q):
        B, C = MII()
        if d[B] > 0:
            d[C] = d[C] + d[B]
            ans += (C - B) * d[B]
            d[B] = 0

        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22640
object Main extends App {
    var get = scala.io.StdIn.readLine()
    var set = get.split(" ")
    var a = set(0).toInt
        var num = readLine
        var max = 0
        var sum = 0
        var j = 0
        for {j <- 0 to a - 1} {
            sum = sum + num.split(" ")(j).toInt
            if (max < num.split(" ")(j).toInt) {
                max = num.split(" ")(j).toInt
            }}
        sum = sum - max
        if (max >= sum) {
            println("No")
        } else {
            println("Yes")
        }
    }

Measured memory_bytes: 25524
def main():
    number, new_year_gift = map(int, input().split(" "))
    answer = True
    for i in range(number, -1, -1):
        if not answer:
            break
        for j in range(number + 1):
            if number < i + j:
                continue
            elif 10000 * i + 5000 * j + 1000 * (number - i - j) == new_year_gift and answer:
                print(i, j, number - i - j)
                answer = False
                break
    if answer:
        print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
const int N=2e5+3;
struct segment{int l,r,f;}b[N];
int n,a[N],t;
inline bool Check(int m){
	t=0;
	for(int i=2;i<=n;i++)if(a[i]<=a[i-1]){
	  if(!m)return 0;
	  for(;t&&b[t].l>a[i];--t);
	  if(t&&b[t].r>a[i])b[t].r=a[i];
	  if(t&&b[t].r==a[i]){
		if(!b[t].l)return 0;
	  }
	  else{
		b[++t]=(segment){a[i],a[i],0};
	  }
	  b[t]=(segment){b[t].l,b[t].l,b[t].f+1};
	  if(b[t].f==m){
		b[t].l--,b[t].f=0;
		if(t>1&&b[t-1].r==b[t].l)
		  b[t-1].r=a[i],--t;
	  }
	}return 1;
}
int main(){
	int l,r,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	for(l=0,r=n;l<r;)m=l+r>>1,Check(m)?r=m:l=m+1;
	printf("%d\n",l+1);
	return 0;
}

Measured memory_bytes: 2512
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,n+1):
        if i*i>n:
            break
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    Q=int(readline())
    l=[0]*Q
    r=[0]*Q
    for i in range(Q):
        l[i],r[i]=map(int,readline().split())

    is_prime=primes(10**5)
    S=[0]*(10**5+1)
    for n in range(3,10**5+1):
        S[n]=S[n-1]
        if is_prime[n] and is_prime[(n+1)//2]:
            S[n]+=1

    for i in range(Q):
        print(S[r[i]]-S[l[i]-1])
if __name__=="__main__":
    main()

Measured memory_bytes: 13360
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

L = sorted(li())

if L[0]+L[1] == L[2]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 2000000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()

int dp[41][401][401];

signed main(){ INIT
    VAR(int, n, ma, mb);
    int a[n], b[n], c[n];
    REP(i, n) cin >> a[i] >> b[i] >> c[i];
    
    REP(i, 41) REP(j, 401) REP(k, 401) dp[i][j][k] = 1001;
    dp[0][0][0] = 0;

    REP(i, n){
        REP(x, 401) REP(y, 401){
            if(x < a[i] || y < b[i]) dp[i+1][x][y] = dp[i][x][y];
            else dp[i+1][x][y] = min(dp[i][x][y], dp[i][x - a[i]][y - b[i]] + c[i]);
        }
    }

    int ans = 1001;
    FOR(i, 1, n+1){
        REP(x, 401) REP(y, 401){
            if(x == 0 && y == 0) continue;
            if(x * mb == y * ma) ans = min(ans, dp[i][x][y]);
        }
    }
    if(ans == 1001) ans = -1;
    OUTL(ans);
RET;}


Measured memory_bytes: 25984
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
#define ll long long int
#define d double 
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
	
	int n,m;
	cin>>n>>m;
	int a[n];
	int i;
	int s=0;
	for(i=0;i<n;i++)
	{
		
		cin>>a[i];
		s=s+a[i];
		
	} 
 
   float z=4*m;
   float x=(1/z)*s;
   
   int count=0;
   for(i=0;i<n;i++)
   {
   	
   	  if(a[i]>=x)
   	  {
   	  	count++;
   	  	
	  }
   	
   }


    if(count>=m)
	{
		
	 cout<<"Yes"<<endl;	
		
	}   
	
	else 
	{
		cout<<"No"<<endl;
		
	}
    
   
    return 0;
}
    

Measured memory_bytes: 3616