akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<string,int>;
using Mat = vector<vector<int>>;

/*
int main(){
    //読み込み
    int n;
    cin >> n;
    typedef tuple<string, int, int> t;
    vector<t> val(n);
    rep(i,n) cin >> get<0>(val.at(i)) >> get<1>(val.at(i));

    //tupleの三要素目にインデックスを追加．
    rep(i,n) get<2>(val.at(i)) = i;

    //まず普通に昇べきソート
    sort(val.begin(), val.end());
    
    //店ごとに降べきソート
    sort(val.begin(),
            val.end(),
            [](const t& x, const t& y)
            {return (get<0>(x) == get<0>(y)) ? (get<1>(x) >= get<1>(y)): false;}
    );//ラムダ式使って店名が一緒の時だけ二番目の値でソート

    //出力
    rep(i,n) cout(get<2>(val.at(i))+1);


    return 0;
}
*/


//解答の一例
int main(){
    int n;
    cin >> n;

    typedef pair<pair<string, int>, int> t;
    vector<t> rest(n);
    rep(i,n){
        string s;
        int p;
        cin >> s >> p;
        rest.at(i) = {{s,-p},i+1};//-pとすれば良いのか！！！！ 
    }
    sort(rest.begin(), rest.end());
    rep(i,n) cout(rest.at(i).second);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    string S;
    cin >> S;
    for(int i=0;i<S.size();i+=2){
        cout << S[i];
    }
    cout << endl;
	return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int Q;
    cin >> Q;
    rep(_, Q) {
        int n;
        cin >> n;
        int ans = 0;
        while (n >= 10) {
            int D = log10(n);
            int ma = -1;
            while (D > 0) {
                int l = n / pow(10, D);
                int r = n % (int)pow(10, D);
                ma = max(ma, l * r);
                D--;
            }
            n = ma;
            ans++;
        }
        cout << ans << endl;
    }

}

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

int main(){
    int N;
    cin >> N;
  N = N % 10;
  if(N == 3){cout << "bon" << endl;}
  else if((N == 0) || (N == 1) || (N == 6) || (N == 8)){cout << "pon" << endl;}
  else{cout << "hon" << endl;}
}

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

using namespace std;

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

signed main () {
  int n;
  cin >> n;
  vector<int> a;
  a.pb(1);
  int tmp=6;
  REP(i, 6) {
    a.pb(tmp);
    tmp *= 6;
  }
  tmp = 9;
  REP(i, 5) {
    a.pb(tmp);
    tmp *= 9;
  }
  sort(a.begin(), a.end());

  vector<int> dp(n+1, 1000000);
  dp[0] = 0;
  
  REP(i, a.size()) {
    REP(j, n+1) {
      if(j >= a[i]) {
        dp[j] = min(dp[j], dp[j - a[i]] + 1);
      }
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  if(S[0]=='1'){
    S[0]='9';
  }else if(S[0]=='9'){
    S[0]='1';
  }
  if(S[1]=='1'){
    S[1]='9';
  }else if(S[1]=='9'){
    S[1]='1';
  }
  if(S[2]=='1'){
    S[2]='9';
  }else if(S[2]=='9'){
    S[2]='1';
  }
  cout<<S<<endl;
  return 0;
}

Measured memory_bytes: 256
// なにこれ
// なにこれと言いながらシミュレーションすると解けます

#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>v(300000);
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		v[a + b] ++;
	}
	for (int i = 0; i < 250000; i++) {
		v[i + 1] += v[i] / 2;
		v[i] %= 2;
		if (v[i] > 0) cout << i << " " << 0 << endl;
	}
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<string> s(N);
    REP(i,N)s[i] = in<string>();
    int M = in();
    vector<string> t(M);
    REP(i,M)t[i] = in<string>();
    sort(ALL(s));
    sort(ALL(t));
    int answer = 0;
    REP(i,N){
        int count = 0;
        REP(l,N){
            if(s[i] == s[l])count++;
        }
        REP(l,M){
            if(s[i] == t[l])count--;
        }
        answer = max(answer,count);
    }
    cout << answer << "\n";
}

Measured memory_bytes: 256
class SegTreeNode:
    def __init__(self, value = 0, l = 0, r = 0, lson = None, rson = None):
        self.value = value
        self.l = l
        self.r = r
        self.lson = lson
        self.rson = rson

class SegTree:
    MIN_NUMBER = 0
    MAX_NUMBER = 2**31 - 1
    def __init__(self, l, r):
        self.root = self.build(l, r)
    
    def build(self, l, r):
        if l > r:
            return None
        root = SegTreeNode(self.MAX_NUMBER, l, r)
        if l == r:
            return root
        mid = (l + r) >> 1
        root.lson = self.build(l, mid)
        root.rson = self.build(mid+1, r)
        return root
    
    def __update(self, root, l, r, value):
        if l > root.r or r < root.l or root == None:
            return
        if l <= root.l and root.r <= r:
            root.value = value
            return
        self.__update(root.lson, l, r, value)
        self.__update(root.rson, l, r, value)
        root.value = min(root.lson.value, root.rson.value)
    
    def update(self, i, value):
        self.__update(self.root, i, i, value)

    def __query(self, root, l, r):
        if l > root.r or r < root.l or root == None:
            return SegTree.MAX_NUMBER
        if l <= root.l and root.r <= r:
            return root.value
        return min(self.__query(root.lson, l, r), self.__query(root.rson, l, r))

    def query(self, l, r):
        return self.__query(self.root, l, r)

n, q = map(int, input().split())
seg = SegTree(0, n)
while q:
    q -= 1
    op, l, r = map(int, input().split())
    if op == 0:
        seg.update(l, r)
    else:
        print(seg.query(l, r))


Measured memory_bytes: 46332
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int s;
        cin >> s;
        set<int> st;

        
        while (st.count(s)==0)
        {
                st.insert(s);
                if (s%2==0)
                {
                        s /= 2;
                } else{
                        s = s * 3 + 1;
                }
        }

        cout<< st.size() + 1 << endl;

        return 0;
}


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

int i,N;
int main(){
	scanf("%d",&N);
	int sq = sqrt(N);
	int ans = N;
	for(i = 2; i <= sq; i++)if(N % i == 0){
		ans = ans / i * (i - 1);
		while(N % i == 0)N /= i;
	}
	if(N > 1)ans = ans / N * (N - 1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2756
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

dp = [N] * (N + 1)
dp[0] = 0
for i in range(N):
    dp[i + 1] = min(dp[i + 1], dp[i] + 1)
    six = 6
    nine = 9
    for p in range(10):
        if i + six <= N:
            dp[i + six] = min(dp[i + six], dp[i] + 1)
        if i + nine <= N:
            dp[i + nine] = min(dp[i + nine], dp[i] + 1)
        six *= 6
        nine *= 9

print(dp[N])


Measured memory_bytes: 4468
#include<iostream>
#include <cstdio>
using namespace std;

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x = i;
        if ( x % 3 == 0 ){
            cout << " " << i;
            continue;
        }
        while(x){
            if ( x % 10 == 3 ){
                cout << " " << i;
                break;
            }
            x /= 10;
        }

    }


    cout << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <numeric>
#include <limits>
#include <type_traits>
#include <algorithm>

using namespace std;
typedef long long int ll;

long double to_deg(long double r) {
    return r * 45.0 / atan(1.0);
}

int main(){
    long double a,b,x;
		cin>>a>>b>>x;



    if(x>=0.5*a*a*b){
      cout<<setprecision(10)<<to_deg(atan2(2*(b*a*a-x),a*a*a))<<endl;
    }
    else{
      cout <<setprecision(10)<< 90-to_deg(atan2(2*x,a*b*b)) << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace CF2017_qual_B_C___3_Steps
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static long solver()
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];

            var nodes = new Node[N + 1];
            for (int i = 0; i < N + 1; i++) nodes[i] = new Node();
            for (int i = 0; i < M; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                nodes[ab[0]].connection.Add(ab[1]);
                nodes[ab[1]].connection.Add(ab[0]);
            }

            var queue = new Queue<Node>();
            queue.Enqueue(nodes[1]);
            var isSearch = new bool[N + 1];
            isSearch[1] = true;
            while (queue.Count > 0)
            {
                var current = queue.Dequeue();
                foreach (int n in current.connection)
                {
                    if (isSearch[n])
                    {
                        if (current.isBlack == nodes[n].isBlack) return (long)N * (long)(N - 1) / 2 - M;
                    }
                    else
                    {
                        isSearch[n] = true;
                        nodes[n].isBlack = !current.isBlack;
                        queue.Enqueue(nodes[n]);
                    }
                }
            }
            var black = nodes.Count(n => n.isBlack);
            return (long)black * (long)(N - black) - M;
        }

        class Node
        {
            public List<int> connection;
            public bool isBlack;
            public Node()
            {
                connection = new List<int>();
            }
        }
    }
}


Measured memory_bytes: 32256
#include<iostream>
using namespace std;
int main()
{
	int i,j,k;
	int Aprice=500;
	int Bprice=100;
	int Cprice=50;
	int ac,bc,cc,amount,calcAmount,way=0;
	cin>>ac;
	cin>>bc;
	cin>>cc;
	cin>>amount;
	for(i=0; i<=ac; i++)
	{
		for(j=0; j<=bc; j++)
		{
			for(k=0; k<=cc; k++)
			{
				calcAmount=(i*Aprice)+(j*Bprice)+(k*Cprice);
				if(calcAmount==amount)
					{
						way++;
					}
			}
		}
	}	
	cout<<way;
	return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)


char s[100001];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  int m = n>>1;

  int ans1 = n;
  for (int i = 1; i <= m; ++i) if (s[i-1] != s[i]) ans1 = n-i;

  int ans2 = n;
  for (int i = n-1; i > m; --i) if (s[i-1] != s[i]) ans2 = i;

  printf("%d\n", min(ans1, ans2));
  return 0;
}


Measured memory_bytes: 384
from itertools import accumulate
n, *A = map(int, open(0).read().split())
B = list(accumulate(A))
p0 = n0 = p1 = n1 = 0
for i, b in enumerate(B):
    if i % 2 == 0:
        if b+p0-n0 <= 0:
            p0 += abs(b+p0-n0)+1
        if b+p1-n1 >= 0:
            n1 += abs(b+p1-n1)+1
    else:
        if b+p0-n0 >= 0:
            n0 += abs(b+p0-n0)+1
        if b+p1-n1 <= 0:
            p1 += abs(b+p1-n1)+1
print(min(p0+n0, p1+n1))


Measured memory_bytes: 20052
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z)                                                        \
  cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z  \
       << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXQ 1000100
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B;
  cin >> A >> B;

  vec< bool > p(MAXQ + 1, false);
  vec< int > pri;
  p[0] = p[1] = true;
  for (int i = 2; i <= MAXQ; ++i) {
    if (!p[i]) {
      pri.pb(i);
      for (int j = i * 1LL * i; j <= MAXQ; j += i) {
        p[j] = true;
      }
    }
  }
  //  REP(i, 25) DEBUG(pri[i]);
  int ans = gcd(A, B);

  /*  int res = 1;
    // DEBUG(pri.size());
    FORA(val, pri) {
      if (ans % val == 0)
        res++;
      while (ans % val == 0) {
        ans /= val;
        if (ans == 1)
          break;
      }
      if (ans == 1) {
        print(res);
        return 0;
      }
    }*/
  int res = 0;
  FORA(val, pri) {
    if (ans == 1) {
      res++;
      print(res);
      return 0;
    } else {
      if (ans % val == 0) {
        while (ans % val == 0) {
          ans /= val;
        }
        res++;
      }
    }
  }
  print(res + 2);
}

Measured memory_bytes: 1528
//<--sbhmsh-->//

#include <bits/stdc++.h>
#include <iostream>
#define FASTIO std::ios::sync_with_stdio(false);
using namespace std;
#define lli long long int
#define endl '\n'
#define deb cout<<"sab_badhiya"<<endl;
// const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
const long INF = 1000 * 1000 * 1000;
const long long int mod = 1000000007;
	set<lli>v;
void primeFactors(lli n)
{
    while (n % 2 == 0)
    {
        v.insert(2);
        n = n/2;
    }
      for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            v.insert(i);
            n = n/i;
        }
    }


    if (n > 2)
        v.insert(n);
}
int main(){
  FASTIO
  long long int a, b,c, ans=0, ans1=0;
	cin>>a>>b;
	// cout<<a<<" "<<b<<endl;
	c = __gcd(a, b);
	primeFactors(c);
	cout<<v.size() + 1<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = sorted([int(input()) for _ in range(n)])
length = len(a)
cnt = 1
ans = 0
for i in range(length - 1):
  if a[i] == a[i+1]:
    cnt += 1
  else:
    ans += cnt % 2
    cnt = 1
  
ans += cnt % 2
    
    
print(ans)
    

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




int main()
{
    string S;
    cin >> S;

    int ans = 0;
    int tmp = 0;
    rep(i,S.size()){
        if(S[i] == 'A'||S[i] == 'G'||S[i] == 'C'||S[i] == 'T'){
            tmp++;
            ans = max(ans,tmp);
        }
        else tmp = 0;        
    }


    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    s=input()
    s2=[0]*N
    for i in range(N):
        if s[i]=="x":
            s2[i]=1
        
    
    #0が羊，1が狼，最初の2匹を決めておく
    ans=-1
    for a in range(2):
        if ans==-1:
            for b in range(2):
                L=[0]*N
                L[0]=a
                L[1]=b
                for i in range(2,N):
                    L[i]=(L[i-2]+L[i-1]+s2[i-1])%2
                
                
                if L[0]==(L[-2]+L[-1]+s2[-1])%2 and L[1]==(L[-1]+L[0]+s2[0])%2:
                    ans=1
                    break
        
        
    if ans==-1:
        print(ans)
    else:
        ans=["S"]*N
        for i in range(N):
            if L[i]==1:
                ans[i]="W"
                
        print(''.join(map(str, ans)))
            
                
            

main()


Measured memory_bytes: 51024
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string ANS="0000000000";

void cal(string A,string B,int C,int D){
	if(A.size()==D+1){
		string st="";
		for(int i=0;i<A.size();i++)st+=(A[i]-B[i]+'0');
		reverse(st.begin(),st.end());
		if(ANS<st)ANS=st;
	}
	else{
		if(A[D]>=B[D]){
			cal(A,B,C,D+1);
		}
		else{
			A[D]+=10;
			string AA=A;
			A[D+1]--;
			cal(A,B,C,D+1);
			if(C>0){
				cal(AA,B,C-1,D+1);
			}
			
		}
	}
}


int main(){
	string a,b;
	int c;
	cin>>a>>b>>c;
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	while(a.size()<10)a+="0";
	while(a.size()>b.size())b+="0";
	cal(a,b,c,0);
	
	for(int i=0,j=0;i<ANS.size();i++){
		if(j==0&&ANS[i]!='0')j=1;
		if(j)cout<<ANS[i];
	}
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 1216
#include<stdio.h>

int main(){
    int x,y,tmp;
    
    while(1){
    scanf("%d %d\n",&x,&y);
        if(x > y){
            tmp = x;
            x = y;
            y = tmp;
        }else if(x == 0 && y == 0){
            break;
        }
            printf("%d %d\n",x,y);
    }
    return 0;
}


Measured memory_bytes: 2088
#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;
ll N;
ll a[300000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,3*N){
        cin>>a[i];
    }
    sort(a,a+3*N);
    reverse(a,a+3*N);
    ll ans=0;
    rep(i,0,N){
        ans+=a[2*i+1];
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 2560
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int j = 0;
    int a, b;

    String input = sc.nextLine();
    //System.out.println(input);

    String[] s = input.split(" ",0);
    int len = s.length;

    int[] stack = new int[len];

    for (int i = 0; i < len; i++) {
      if(s[i].equals("+")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a+b;
        j = j-1;
      }
      else if(s[i].equals("-")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a-b;
        j = j-1;
      }
      else if(s[i].equals("*")){
        a = stack[j-2];
        b = stack[j-1];
        stack[j-2] = a*b;
        j = j-1;
      }
      else{
        a = Integer.parseInt(s[i]);
        stack[j] = a;
        j=j+1;
      }
    }
    System.out.println(stack[0]);
  }
}


Measured memory_bytes: 26176
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, err := strconv.Atoi(sc.Text())
    if err != nil {
        panic(err)
    }
    return i
}

func main(){
    n := nextInt()
    fmt.Println(n*n*n)
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 2010
const int MOD = 1000000007;

int dp[maxn];
void solve() {
    int s;
    cin >> s;

    dp[0] =1;
    for(int i = 0; i <= s; i++){
        for(int j = 3; j + i <= s; j++){
            dp[i + j] += dp[i];
            if(dp[i + j] >= MOD)dp[i + j] -= MOD;
        }
    }
    cout << dp[s] << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3632
def month(num):
    if 0 < num <= 12:
        return 1
    else:
        return 0


S = input()
first = int(S[:2])
second = int(S[2:])

if month(first) == 1 and month(second) == 1:
    print('AMBIGUOUS')

elif month(first) == 1 and month(second) == 0:
    print('MMYY')

elif month(first) == 0 and month(second) == 1:
    print('YYMM')

else:
    print('NA')





Measured memory_bytes: 3060
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const int m = getInt();
  vector<int> a(n);
  REP(i,n) a[i] = getInt();

  const int k = n / __gcd(n, m);

  int ans = 0;
  REP(i,k){
    int mn = 1e8;
    int mx = 0;
    REP(j,m){
      const int s = a[(m * i + j) % n];
      mx = max(mx, s);
      mn = min(mn, s);
    }
    ans += mx - mn;
  }

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

  return 0;
}

Measured memory_bytes: 2680
nt = map(int, raw_input().split())
cheapest = 1001
for i in range(nt[0]):
    ct = map(int, raw_input().split())
    if ct[1] <= nt[1]:
        if ct[0] < cheapest:
            cheapest = ct[0]
if cheapest == 1001:
    print("TLE")
else:
    print(cheapest)


Measured memory_bytes: 2568
H,N=map(int,input().split())
magic=[]
for _ in range(N):
    A,B=map(int,input().split())
    magic.append((A,B))

inf=float("inf")
dp=[inf]*(H+1)
dp[0]=0

for i in range(H):
    for a,b in magic:
        d=min(i+a,H)
        dp[d]=min(dp[d],dp[i]+b)
print(dp[H])

Measured memory_bytes: 43100
#include<bits/stdc++.h>
using namespace std;
int read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch=='-')f=1;ch=getchar();}
	while(isdigit(ch)) {x = x * 10 + ch - '0';ch = getchar();}
	return f?-x:x;
}
const int N = 1e6 + 10,inf = 0x3f3f3f3f;
int n,a[N];
int main()
{
	n = read()^1;
	cout << n << endl;
	return 0;
}

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

using namespace std;

typedef vector<int> vec;

class Seg
{
public:
    vec data;
    vec lazy;
    int n;
    const int no=1001;

    Seg(int _n)
    {
        data.resize(4*_n);
        lazy.resize(4*_n);
        for(n=1;n<_n;n<<=1);
        fill(lazy.begin(),lazy.end(),no);
    }

    void Down(int p,int l,int r)
    {
        if(lazy[p]==no) return;
        data[p]=lazy[p]*(r-l);
        if(l+1<r)
        {
            lazy[p*2+1]=lazy[p*2+2]=lazy[p];
        }
        lazy[p]=no;
    }

    int update(int p,int l,int r,int x,int a,int b)
    {
        if(a>=r||l>=b)
        {
            Down(p,l,r);
            return data[p];
        }else if(a<=l&&r<=b)
        {
            lazy[p]=x;
            Down(p,l,r);
            return data[p];
        }else
        {
            Down(p,l,r);
            int mid=(l+r)/2;
            return data[p]=update(p*2+1,l,mid,x,a,b)+update(p*2+2,mid,r,x,a,b);
        }
    }

    int getSum(int p,int l,int r,int a,int b)
    {
        if(a>=r||l>=b) return 0;
        else if(a<=l&&r<=b)
        {
            Down(p,l,r);
            return data[p];
        }else
        {
            Down(p,l,r);
            int mid=(l+r)/2;
            return getSum(p*2+1,l,mid,a,b)+getSum(p*2+2,mid,r,a,b);
        }
    }
};

int main()
{
    int n,q;

    while(scanf("%d %d",&n,&q)!=EOF)
    {
        Seg seg(n);
        while(q--)
        {
            int op,a,b,c;
            scanf("%d",&op);
            if(op)
            {
                scanf("%d %d",&a,&b);
                printf("%d\n",seg.getSum(0,0,seg.n,a,b+1));
            }else
            {
                scanf("%d %d %d",&a,&b,&c);
                seg.update(0,0,seg.n,c,a,b+1);
            }
        }
    }


    return 0;
}



Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;



int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	
	int z;
	int N; cin >> N;
	int A, B, C; cin >> A >> B >> C;
	int l[10];
	int cnt;
	int ans=10000;
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}
	for (int i = 0; i < pow(4, N) - 1; i++) {
		z = i;
		cnt = 0;
		int fans = -30;
		vector<int> a, b, c;
		while (z > 0) {
			if (z % 4 == 3)c.push_back(l[cnt]);
			else if (z % 4 == 2)b.push_back(l[cnt]);
			else if (z % 4 == 1)a.push_back(l[cnt]);
			cnt++;
			z /= 4;
		}
		int la = 0, lb = 0, lc = 0;
		cnt = 0;
		while (cnt < a.size() && la < A) {
			la += a[cnt];
			cnt++;
			fans += 10;
		}
		cnt = 0;
		while (cnt < b.size() && lb < B) {
			lb += b[cnt];
			cnt++;
			fans += 10;
		}
		cnt = 0;
		while (cnt < c.size() && lc < C) {
			lc += c[cnt];
			cnt++;
			fans += 10;
		}
		if (la == 0 || lb == 0 || lc == 0)continue;
		ans = min(abs(A - la) + abs(B - lb) + abs(C - lc) + fans, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  int a, b;
  cin >> a >> b;
  string sa, sb;
  rep(i,b) sa += a+'0';
  rep(i,a) sb += b+'0';
  cout << (sa < sb ? sa : sb) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++)
		{
			System.out.println("Case " + Integer.toString(i+1) + ":");
			int s = sc.nextInt();
			for (int j = 0; j < 10; j++)
			{
				s *= s;
				StringBuffer buf = new StringBuffer(Integer.toString(s));
				while (buf.length() < 8)
				{
					buf.insert(0, '0');
				}
				s = Integer.parseInt(buf.substring(2, 6));
				System.out.println(s);
			}
		}
	}
}

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

using namespace std;

long long n, a[300005], bi[62], oddcnt, temp, ans;
const long long mod = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i=0; i<n; i++) cin >> a[i];
	bi[0] = 1;
	for (int i=1; i<62; i++) {
		bi[i] = (bi[i - 1] * 2) % mod;
	}
	for (int i=0; i<60; i++) {
		oddcnt = 0; temp = 0;
		for (int j=0; j<n; j++) {
			if (a[j] % 2) oddcnt++;
			a[j] /= 2;
		}
		temp = (oddcnt * (n - oddcnt)) % mod;
//		cout << "oddcnt is " << oddcnt;
		temp = (temp * bi[i]) % mod;
//		cout << " and temp is " << temp << endl;
		ans += temp;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using P = pair<int,int>;

int main(){
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= s*t){
        cout << "Yes" << endl;
        return 0;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	int Limit = sc.nextInt();
      	int Current,Count=0;
      for (int i = 0 ; i < N; i ++){
          Current = sc.nextInt();          
          if (Current>=Limit)
          {
            Count++;
          }
        }     
        System.out.println(Count);
      }
	}

Measured memory_bytes: 45728
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll sum(n+1,0) ;
	for(int i=1;i<=n;i++){
		ll a ; cin >> a ;
		sum.at(i) = sum.at(i-1)+a ;
	}
	map<ll,ll> m ;
	m[0] = 1 ;
	ll ans = 0 ;
	for(int i=1;i<=n;i++){
		if(m.count(sum.at(i))){
			ans += m[sum.at(i)] ;
			m[sum.at(i)]++ ;
		}else{
			m[sum.at(i)] = 1 ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 14336
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;
 
 
public class Main {
     
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
         
        final int n = sc.nextInt();
         
        Deque<Integer> deque = new ArrayDeque<Integer>(2000000);
         
        for(int t = 0; t < n; t++){
            String input = sc.next();
             
            if("insert".equals(input)){
                final int x = sc.nextInt();
                 
                deque.addFirst(x);
            }else if("delete".equals(input)){
                final int x = sc.nextInt();
                 
                deque.remove(x);
            }else if("deleteFirst".equals(input)){
                deque.pollFirst();
            }else if("deleteLast".equals(input)){
                deque.pollLast();
            }
        }
         
        boolean first = true;
        for(int i : deque){
            System.out.print((first ? "" : " ") + i);
             
            if(first){
                first = false;
            }
        }
        System.out.println();
         
    }
 
}
 
class Scanner {
     
    private BufferedReader br;
    private StringTokenizer tok;
     
    public Scanner(InputStream is) throws IOException{
        br = new BufferedReader(new InputStreamReader(is));
        getLine();
    }
     
    private void getLine() throws IOException{
        while(tok == null || !hasNext()){
            tok = new StringTokenizer(br.readLine());
        }
    }
     
    private boolean hasNext(){
        return tok.hasMoreTokens();
    }
     
    public String next() throws IOException{
        if(hasNext()){
            return tok.nextToken();
        }else{
            getLine();
            return tok.nextToken();
        }
    }
     
    public int nextInt() throws IOException{
        if(hasNext()){
            return Integer.parseInt(tok.nextToken());
        }else{
            getLine();
            return Integer.parseInt(tok.nextToken());
        }
    }
     
    public long nextLong() throws IOException{
        if(hasNext()){
            return Long.parseLong(tok.nextToken());
        }else{
            getLine();
            return Long.parseLong(tok.nextToken());
        }
    }
     
    public double nextDouble() throws IOException{
        if(hasNext()){
            return Double.parseDouble(tok.nextToken());
        }else{
            getLine();
            return Double.parseDouble(tok.nextToken());
        }
    }
}


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        while(true) {
            int n = Integer.parseInt(sc.next());
            int x = Integer.parseInt(sc.next());
            if (n == 0 && x == 0) {
                break;
            }

            int count = 0;
            for (int i = 1; i <= n-2; i++) {
                for (int j = i + 1; j <= n-1; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (i + j + k == x) {
                            count ++;
                        }
                    }
                }
            }
            out.printf("%d\n", count);
        }
        out.flush();
    }
}


Measured memory_bytes: 27336
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;

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

int main(){
	
	while(true){
		int N;
		cin >> N;
		if(N == 0){
			break;
		}
		
		int r[1100], w[1100], r_sum = 0, w_sum = 0;
		
		for(int i = 0; i < N; i++){
			cin >> r[i] >> w[i];
			r_sum += r[i];
			w_sum += w[i];
		}
		
		bool flag = true;
		int pos, rem;
		for(int i = 0; i < N; i++){
			if(r[i] * 2 > r_sum){
				pos = i;
				rem = 2 * r[i] - r_sum;
				flag = false;
			}
		}
		
		if(flag){
			cout << r_sum + w_sum << endl;
			continue;
		}
		
		bool DP[1100] = {};
		DP[0] = true;
		for(int i = 0; i < N; i++){
			if(i == pos){
				continue;
			}
			for(int j = rem; j >= w[i]; j--){
				DP[j] |= DP[j - w[i]];
			}
		}
		
		for(int j = rem; j >= 0; j--){
			if(DP[j]){
				cout << r_sum + w_sum + rem - j << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3120
N = gets.chomp.to_i
as = [] 
N.times { as.push(gets.chomp.to_i) }

first = -1
second = -1
N.times do |i|
  if first < as[i]
    second = first
    first = as[i]
  elsif second < as[i]
    second = as[i]
  end
end

as.map! { |a| a == first ? second : first }

puts as.join("\n")


Measured memory_bytes: 6520
n,m = map(int ,input().split())
s = [0] * n
cnt = [0] * n
pe = [0] * n
for i in range(m):
    P, S = input().split()
    p = int(P)
    p -= 1
    if(S == "AC" and s[p] == 0):
        s[p] = 1
        cnt[p] = pe[p]
    elif(S == "WA" and s[p] == 0):
        pe[p] += 1
print(sum(s), sum(cnt))

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

int main(){
  
  int n,a;
  cin >> n;
  int min = 10000;
  
  
  for(int i = 0; i < n; i++){
    cin >> a;
    int cnt = 0;
      while(a%2==0){
        a /=2;
        cnt ++;
     }
      if(cnt < min)
        min =cnt;
  }
     
    cout << min << endl;

}
    



Measured memory_bytes: 256
from collections import defaultdict
import sys

input = sys.stdin.readline

n, k = map(int, input().split())
e = defaultdict(list)
for _ in range(n):
    t, d = map(int, input().split())
    t -= 1
    e[t].append(d)

tops = []
rests = []
for l in e.values():
    for i, d in enumerate(sorted(l, reverse=True)):
        if i == 0:
            tops.append(d)
        else:
            rests.append(d)

tops.sort(reverse=True)
c_tops = [0]
for t in tops:
    c_tops.append(c_tops[-1] + t)

rests.sort(reverse=True)
c_rests = [0]
for t in rests:
    c_rests.append(c_rests[-1] + t)

ans = 0
for i in range(1, min(k, len(tops)) + 1):
    if k - i > len(rests): continue
    ans = max(ans, c_tops[i] + c_rests[k - i] + pow(i, 2))
print(ans)


Measured memory_bytes: 32800
import numpy as np

H, W = map(int,input().split())
A = np.array([list(input()) for _ in range(H)], 'U1')
mod = 10**9+7

dp = [[0 for j in range(W+1)] for i in range(H+1)]
dp[0][1] = 1

for i in range(H):
    for j in range(W):
        if A[i][j] == '.':
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % mod

print(dp[-1][-1])

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

int main() {
	int a;	// 正整数.
	int b;	// 正整数.
	cin >> a;
	cin >> b;
	if ((a * b) % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int code(char s){
  if(s=='A')return 0;
  if(s=='B')return 1;
  if(s=='C')return 2;
  return -1;
}
main(){
  int cup[3]={1,0,0};
  char x,y;
  int tmp;
  while(~scanf("%c,%c ",&x,&y)){
    tmp=cup[code(x)];
    cup[code(x)]=cup[code(y)];
    cup[code(y)]=tmp;
  }
  if(cup[0])printf("A\n");
  if(cup[1])printf("B\n");
  if(cup[2])printf("C\n");
  return 0;
}

Measured memory_bytes: 528
#include <cstdio>
using namespace std;
int main(){
    char S[4];
    int sum=0;
    for(int i=0;i<4;i++){
        scanf("%c",&S[i]);
        if(S[i]=='+'){
            sum++;
        }
        else if(S[i]=='-'){
            sum--;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		if( n == m) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22612
// AOJ 0141
#include<iostream>
#include<cstring>

char ptn[104][105];
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
int dir;

bool check( int x, int y, int dir )
{
	int nx = x + dx[dir], ny = y + dy[dir];

	for( int i = 0; i != 4; ++i )
	{
		int nnx = nx + dx[i], nny = ny + dy[i];

		if( nnx == x && nny == y )
			continue;

		if( ptn[nny][nnx] == '#' )
			return false;
	}

	return true;
}

int main()
{
	int d;
	std::cin >> d;
	while( d-- )
	{
		int n;
		std::cin >> n;

		for( int i = 0; i != n + 4; ++i )
			for( int j = 0; j != n + 4; ++j )
				ptn[i][j] = !i || !j || i == n + 3 || j == n + 3 ? '#' : ' ';

		int x = 2, y = n + 1;
		bool fl = false;
		dir = 0;

		while( true )
		{
			ptn[y][x] = '#';

			if( !check( x, y, dir ) )
			{
				if( !fl )
				{
					dir = ( dir + 1 ) & 3;
					fl = true;
					continue;
				}
				else
					break;
			}
			else
				fl = false;

			x += dx[dir];
			y += dy[dir];
		}

		for( int i = 2; i != n + 2; ++i )
		{
			for( int j = 2; j != n + 2; ++j )
				std::cout << ptn[i][j];

			std::cout << std::endl;
		}

		if( d )
			std::cout << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	pair<int, int> P[500];
	static int ANS[250000] = {};
	int Cur = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int X;
		cin >> X;
		P[i] = { X - 1, i + 1 };
	}
	sort(P, P + N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < P[i].second - 1; j++) {
			while (ANS[Cur] != 0) Cur++;
			ANS[Cur] = P[i].second;
		}
		if (ANS[P[i].first] != 0) {
			cout << "No" << endl;
			return 0;
		}
		ANS[P[i].first] = P[i].second;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - P[i].second; j++) {
			while (ANS[Cur] != 0) Cur++;
			if (Cur < P[i].first) {
				cout << "No" << endl;
				return 0;
			}
			ANS[Cur] = P[i].second;
		}
	}
	cout << "Yes" << endl;
	for (int i = 0; i < N * N; i++) {
		if (i != 0) cout << " ";
		cout << ANS[i];
	}
	cout << endl;
}

Measured memory_bytes: 2176
# include"stdio.h"
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int r[m][2];
    for(int i=0;i<m;i++)
        scanf("%d %d",&r[i][0],&r[i][1]);
    int c[n+1];
    for(int i=0;i<n+1;i++)  c[i]=0;
    for(int i=0;i<m;i++){
        c[r[i][0]]++;
        c[r[i][1]]++;
    }
    for(int i=1;i<n+1;i++)
        printf("%d\n",c[i]);
}


Measured memory_bytes: 1708
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))
B = [0] * 61

for i in range(n):
    b = list(format(A[i], "b").zfill(61))
    for j in range(61):
        if b[j] == "1":
            B[j] += 1

mod=10**9+7
M2 = [1]
for i in range(70):
    M2.append((M2[-1] * 2) % mod)

# print(B)
ans = 0
for i in range(61):
    p = (B[i] * (n-B[i]) * M2[61-i-1]) % mod
    ans = (ans+p) % mod
print(ans)

Measured memory_bytes: 123132
#include<stdio.h>

int main(){
  int i,j,k,l,n,p[100+1],m[101][101],ans,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&q);
  }
  p[i]=q;
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n+1;l++){
    for(i=1;i<=n-l+2;i++){
      j = i + l - 1;
      m[i][j] = 1000000;

      for(k=i;k<=j-1;k++){
        ans  = (m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
        if(m[i][j]>ans){
          m[i][j]=ans;
        }
      }
    }
  }
  printf("%d\n",m[1][n]);

  return 0;
}



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

using namespace std;

int n,m,cnt,sum = 1000001,t,f;
int a[102];
pair <int, string> p1[10001];
int main (){	
	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			for (int u = 1; u <= n; u++){
				cnt++;
			}
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 384
# coding:utf-8

n = int(input())

keta = len(str(n))

count = 0

for i in range(keta):
    # 面倒なので0はとばす
    # 1 ~ 桁数-1まで考える
    if i == 0:
        continue
    elif i == 1:
        count += 9
    else:
        if i % 2:
            # 最上位桁は9パターン，それ以下は10パターン
            count += 10 ** (i-1) * 9

# 最上位桁のカウント
if keta % 2:
    count += n - 10 ** (keta - 1) + 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std ;
 
/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
const int mod = (int)1e9 + 7 ;
const int inf = (int)1e9 ;
/************************************************************/

bool diff( vector<int> a ){
	int len = a.size() ;
	sort( all(a) ) ;
	for( int i = 0 ; i < len - 1 ; i++ ){
		if( a[i+1] == a[i] ){
			return false ;
		}
	}
	return true ;
}
bool check( int &a, int &b, int &c ){
	return ( a + b > c && b + c > a && c + a > b ) ;
} 

 
signed main(){
	int n ; cin >> n ;
	vector<int> a(n) ;
	for( int i = 0 ; i < n ; i++ ) {
		cin >> a[i] ;
	}
	int cnt = 0 ;
	for( int i = 0 ; i < n ; i++ ){
		for( int j = i + 1 ; j < n ; j++ ){
			for( int k = j + 1 ; k < n ; k++ ) {
				vector<int> temp = { a[i], a[j], a[k] } ;
				if( diff( temp ) && check( a[i], a[j], a[k] ) ){
					cnt++ ;
				}
			}
		}
	}
	cout << cnt ;
	return 0 ;
}
  


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		int m=(int)s[0]*100;
		var dp=new long[m+1];
		for(int i = 1;i<=m;i++) {dp[i]=int.MaxValue;}
		for(int i = 1;i<=s[0];i++) {
			var e=sc.La;
			for(int j = m;j>=e[0];j--) {
				dp[j]=Min(dp[j],dp[j-e[0]]+e[1]);
			}
		}
		for(int i = m;i>=0;i--) {
			if(dp[i]<=s[1]){
				Console.WriteLine("{0}",i);
				break;
			}
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 20004