akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define Max 3000
int dp[Max+1][Max+1];
string getlCS(string& s,string & t,int len)
{
    int i=0,j=0;
    string LCS;
    while(len>0)
    {
        if(s[i]==t[j])
        {
            LCS.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else
        {
            if(dp[i][j+1]>dp[i+1][j])
            {
                j++;
            }
            else
            {
                i++;
            }
        }
    }
    return LCS;
}
int lenLcs(string &s ,string & t,int i,int j)
{
    if(i>=s.length() || j>=t.length())
    {
        return 0;
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    if(s[i]==t[j])
    {
        return dp[i][j]= 1+lenLcs(s,t,i+1,j+1);
    }
    else
    {
        return dp[i][j]=max(lenLcs(s,t,i+1,j),lenLcs(s,t,i,j+1));
    }
    
}
string solve(string& s,string & t)
{
 memset(dp,-1,sizeof(dp));
 int len=lenLcs(s,t,0,0);
 return getlCS(s,t,len);
}
int main() {
    string s,t;
    cin>>s>>t;
    cout<<solve(s,t);
    return 0;
}


Measured memory_bytes: 39240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;
  cin>>n>>m;
  ll u[n],a[m];
  memset(u,0,sizeof(u));
  for(ll i=0;i<m;i++) cin>>a[i];
  for(ll i=m-1;i>=0;i--){
    if(u[a[i]-1]) continue;
    cout<<a[i]<<endl;
    u[a[i]-1]=1;
  }
  for(ll i=0;i<n;i++){
    if(!u[i]) cout<<i+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 5416
import java.util.*;

class Main{
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      int     n    = scan.nextInt();
      int     m    = scan.nextInt();

      char[][] a = new char[100][100];
      for(int i = 0; i < 100; i++){
          for(int j = 0; j < 100; j++){
              if(i < 50){
                 a[i][j] = '#';
                 }
              else{
                  a[i][j] = '.';
                  }
              }
          }
      int u = 0, count = 0;
      while(n - 1 > 0){
            a[count][u] = '.';
            u          += 2;
            n--;
            if(u == 98){
               u      = 0;
               count += 2;
               }
            }
      u = 0;
      while(m - 1 > 0){
            a[99 - count][u] = '#';
            u += 2;
            m--;
            if(u == 98){
               u      = 0;
               count += 2;
               }
            }
      System.out.println("100 100");
      for(int i = 0; i < 100; i++){
          for(int j = 0; j < 100; j++){
              System.out.print(a[i][j]);
              }
          System.out.println();
          }
   }
}


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

int main(){
  int x;cin >> x;
  ll ans = x-1;
  bool flag = true;
  while(flag) {
    flag = false;
    ans++;
    for(ll i = 2; i < ceil(ans / 2); i++){
      if(ans % i == 0){
        flag = true;
        break;
      } 
    }
    
  }

  cout << ans << endl;
}



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


int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	lli n, m, val, b, c;
	
	cin >> n >> m;
	
	map<lli, lli> mp;
	
	for(int i = 0; i < n; i++){
		cin >> val;
		mp[val]++;
	}
	
	while(m--){
		cin >> b >> c;
		mp[c] += b;
	}
	
	lli sum = 0, sz;
	
	for(auto it = mp.rbegin(); it != mp.rend(); it++){
		if(n == 0) break;
		
		val = it->first; sz = it->second;
		
		if(n >= sz){
			n -= sz;
			sum += (val * sz);
		}
		else{
			sum += (val * n);
			n = 0;
		}
	}
	
	
	cout << sum << "\n";
	
	return 0;
}


Measured memory_bytes: 12800
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int countChar(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//
int getSum(LL n);
//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  LL n;
  cin >> n;
  // Scan done.

  // Code begin.
  int sum = getSum(n);
  if (n%sum==0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  // Code done.

  return 0;
}

//=functions=================================================================//
int getSum(LL n) {
  int sum = 0;
  while (n>0) {
      sum += n%10;
      n /= 10;
  }
  return sum;
}
//===========================================================================//

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int d = 0;
	for (int i = 1; i <= n; i += 2) {
		int c = 0;
		for (int j = 1; j <= i; j++)
			if (i%j == 0) c++;
		if (c == 8) d++;
	}
	cout << d << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;


int main(){
    ios::sync_with_stdio(0);
	cin.tie(NULL);
    Long n; cin>>n;
    map <Long,Long> m;
    vector <Long> v;
    Rep(i,0,n){
        Long a; cin>>a;
        m[a]++;
        v.pb(a);
    }
    Long resp=0;
    for(auto x: m){
        resp+=x.second*(x.second-1)/2;
    }
    Rep(i,0,n){
        cout<<resp-(m[v[i]]-1)<<'\n';
    }
    return 0;
}

Measured memory_bytes: 11120
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    m, d = LI()
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            if int(str(j)[0]) < 2 or int(str(j)[1]) < 2:
                continue
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
    print(ans)
    return

#B
def B():
    n, l = LI()
    a = LI()
    d0 = defaultdict(int)
    d1 = defaultdict(int)
    for i in a:
        d0[i] += 1
    for i in range(n):
        b = 0
        for k in range(i+1, n):
            if a[i] > a[k]:
                b += 1
        d1[i] = b
    ans = 0
    d2 = list(d0.items())
    d2.sort()
    d3 = defaultdict(int)
    d = 0
    for key, value in d2:
        d3[key] = d
        d += value
    for i in range(n):
        ans += d3[a[i]] * l * (l-1) // 2 + d1[i] * l
        ans %= mod
    print(ans % mod)
    return

#C
def C():
    n = II()
    s = S()
    if s[0] == "W":
        print(0)
        return
    lis = [0] * (2 * n)
    l = [0] * (2 * n)
    l[0] = 1
    for i in range(1, 2 * n):
        lis[i] = (lis[i-1] ^ (s[i] == s[i-1]))
        l[i] += l[i - 1] + (lis[i] == 0)
    ans = 1
    if l[-1] != n or s[0] == "W":
        print(0)
        return
    k = 1
    for i in range(2 * n):
        if lis[i]:
            ans *= l[i] - (k - 1)
            ans %= mod
            k += 1
    print(ans * math.factorial(n) % mod)
    return

#D
def D():
    n = II()
    ans = [[] for i in range(n - 1)]
    l = len(bin(n)) - 2
    for i in range(n - 1):
        for j in range(i + 2, n + 1):
            for k in range(l):
                if (j >> k) & 1 != ((i + 1) >> k) & 1:
                    ans[i].append(str(k + 1))
                    break
    print()
    for a in ans:
        print(" ".join(a))
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 48348
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int gcd ( int a, int b )
{
  int c;
  while ( a != 0 ) {
     c = a; a = b%a;  b = c;
  }
  return b;
}

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

    ll a[100001];

    int flag = 0;
    REP(i, n){
        cin >> a[i];
        if(a[i] >= k) flag = 1;
    }

    sort(a, a+ n);

    int p = gcd(a[0],a[1]);
    for(int i = 2; i < n; i++){
        p = gcd(p,a[i]);
    }

    int flag2 = 0;
    
    if(k % p == 0){
        flag2 = 1;
    }

    

    if(flag == 1 && flag2 == 1){
        cout <<"POSSIBLE" <<endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    
    return 0;
}

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

int main()
{
  int n;

  while(cin>>n){
    int count=0;
    for(int a=0;a<10;a++)
      for(int b=0;b<10;b++)
        for(int c=0;c<10;c++)
          for(int d=0;d<10;d++)
            if(a+b+c+d==n)count++;
    cout<<count<<endl;
  }
}

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

signed main(void)
{
	int n, a, b, c, d;
	string s;
	bool ok;

	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;
	ok = true;
	for(int i = a; i <= max(c, d); i++)
	{
		if (s.substr(i, 2) == "##")
			ok = false;
	}
	if (c > d)
	{
		ok = false;
		for(int i = b - 1; i < d; i++)
		{
			if (s.substr(i, 3) == "...")
			{
				ok = true;
				break;
			}
		}
	}
	if(ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,goukei,hako;
    cin >> N;
    vector<ll> A(N);
    map<ll,ll>mpa;

    for(ll i = 0;i < N;i++)
        mpa[i] = 0;
    
    for(ll i = 0;i < N;i++){
        cin >> A.at(i);
        goukei += A.at(i);
    }

    for(ll i = 0;i < N;i++)
        mpa[A.at(i)]++;

    ll Q;
    cin >> Q;

    vector<ll> B(Q),C(Q);

    for(ll i = 0;i < Q;i++){
        cin >> B.at(i) >> C.at(i);
    }

    for(ll i = 0;i < Q;i++){
        hako = mpa[B.at(i)];
        mpa[B.at(i)] = 0;
        mpa[C.at(i)] += hako;
        goukei = goukei + C.at(i) * hako - B.at(i) * hako;
        cout << goukei << endl;
    }

    return 0;

    
}

Measured memory_bytes: 11972
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int h = 0, w = 0;
 
    while(1)
    {
        cin >> h >> w;
        if(((h>0) && (h<=300)) ||
           ((w>0) && (w<=300)))
        {
               for(int i = 0; i<h ;i++)
               {
                   for(int j = 0; j < w; j++)
                   {
                       if((i+j)%2 == 0)
                       {
                            cout << "#";
                       }
                       else
                       {
                            cout << ".";
                       }
                   }
                   cout << endl;
               }
               cout << endl;
        }
        else if((h == 0) && (w == 0))
        {
            break;
        }      
    }
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll d,g; cin>>d>>g;
  vll p(d), c(d);
  rep(i,d) cin>>p[i]>>c[i];
  
  ll ans=LINF;
  for(ll bit=0; bit<(1<<d); bit++){
    ll sum=0;
    ll cnt=0;
    rep(i,d){
      if(bit&(1<<i)){
        sum+=p[i]*(100*(i+1))+c[i];
        cnt+=p[i];
      }
    }
    if(sum>=g){
      chmin(ans,cnt);
      continue;
    }
    rrep(i,d){
      if(bit&(1<<i)) continue;
      rep(j,p[i]){
        sum+=100*(i+1);
        cnt++;
        if(sum>=g) break;
      }
      if(sum>=g){
        chmin(ans,cnt);
        break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void){
    int matrix[100][100];
    int matrix2[100];
    // 行がn列がm lは1列っぽい
    // 行列n * m 行列m * l print thiere product ab
    int n,m,k;
    
    cin >> n >> m;
    
    for(int i = 0;i < n;++i){
        for(int j = 0;j < m;++j){
            cin >> k;
            //cin >> matrix[i][j];
            matrix[i][j] = k;
        }
    }

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

    // 計算
    for(int i = 0;i < n;++i){
        int num = 0;
        for(int j = 0;j < m;++j){
            num += matrix[i][j] * matrix2[j];
        }
        cout << num << endl;
    }

    return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

int n, q;

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

    while (q--) {
        int v, w;
        set<int> st;

        cin >> v >> w;
        v--, w--;

        if (n == 1) {
            cout << min(v, w) + 1 << endl;
            continue;
        }

        st.insert(0);
        while (v > 0) {
            st.insert(v);
            v = (v - 1) / n;
        }

        while (st.count(w) == 0) {
            w = (w - 1) / n;
        }

        cout << w + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 1280
import numpy as np

s1s2s3=int(input())

count1 = 0

num = []

while s1s2s3 != 0:
    num.append(s1s2s3 % 10)
    s1s2s3 //= 10
num.reverse()

for i in range (len(num)):
    if  num[i-1] == 1:
        count1 = count1 + 1
    else:
        pass

print(count1)

Measured memory_bytes: 12504
#include <iostream>
#include <stack>
#include <vector>

struct Node {
	std::deque<int> edges;
};

std::vector<int> find_distance(std::vector<Node>& nodes, int start_node) {
	std::vector<int> result(nodes.size());

	struct StackItem {
		int next_node;
		int prev_node;
		int distance;
	};

	std::stack<StackItem> stack; // node, distance
	stack.push({ start_node, -1, 0 });

	while (!stack.empty()) {
		StackItem s = stack.top();
		stack.pop();

		int distance = s.distance + 1;

		for (int dest_node : nodes[s.next_node].edges) {
			if (dest_node == s.prev_node) continue;

			result[dest_node] = distance;
			stack.push({ dest_node, s.next_node, distance });
		}
	}

	return result;
}

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

	std::vector<Node> nodes(n);

	for (int i = 0; i < n - 1; i++) {
		int a, b;
		std::cin >> a >> b;
		a--;
		b--;
		nodes[a].edges.push_back(b);
		nodes[b].edges.push_back(a);
	}

	std::vector<int> distance_from_fennec = find_distance(nodes, 0);
	std::vector<int> distance_from_snuke = find_distance(nodes, n - 1);

	int fennec_points = 0, snuke_points = 0;
	for (int i = 0; i < n; i++) {
		if (distance_from_fennec[i] <= distance_from_snuke[i])
			fennec_points++;
		else
			snuke_points++;
	}

	std::cout << (fennec_points > snuke_points ? "Fennec" : "Snuke") << std::endl;
}


Measured memory_bytes: 68224
/*
 *idea:将机械臂的长度分为全部都是一段的情形,然后判断和的奇偶性即可,但是注意到机械臂所要达到的范围在1e9量级
 *简单的使用每段长度均为1的机械臂会TLE.
  这题实际使用的是二进制表示方法,可以证明,只要长度为(1,2,2^2,...,2^k)那么就可以到任何(1,1,1,..,1)能到的地方
 *证明使用归纳法,如果坐标和为偶数,那么在原先的基础上加上一段1即可,非常巧妙.
 *题目还可以近一步引申,如果允许长度为0.5的出现,那么就可以到达任意奇偶的位置.
 *详细题解见Note
 */
#include <bits/stdc++.h>
using namespace std;
const int maxn=5e5;
typedef long long ll;
int N,x[maxn],y[maxn];
char alph[5]={'R','L','U','D'};
int dx[5]={1,-1,0,0};
int dy[5]={0,0,1,-1};
int ans[50];
ll length[50];
ll aa(ll a){
	if(a<0)return -a;
	else return a;
}
bool check(ll cx,ll cy,ll ml){
//	printf("cx %d cy %d num %d\n",cx,cy,ml);
	if(aa(cx)+aa(cy)<=(1<<ml)-1)return true;
	else return false;
}
void dfs(int id,int xx,int yy)
{
	ll cx=xx,cy=yy;
	for(int j=id;j>=1;j--)
	{
//		printf("cx %d cy %d\n",cx,cy);
		for(int i=0;i<4;i++){
			ll nx=cx+length[j]*dx[i];
			ll ny=cy+length[j]*dy[i];
			if(check(nx,ny,j-1)){
				ans[j]=i^1;
				cx=nx;cy=ny;
				break;
			}
		}
	}
}

int main()
{
	//freopen("t.in","r",stdin);
	scanf("%d",&N);
	int flag=0,ok=1;
	ll pre=0;
	for(int i=1;i<=N;i++){
		scanf("%d%d",&x[i],&y[i]);
		pre=max(pre,aa(x[i])+aa(y[i]));
		if(i==1)flag=(aa(x[i])+aa(y[i]))%2;
		else{
			if((aa(x[i])+aa(y[i]))%2!=flag)ok=0;
		}
	}

	if(ok==0)printf("-1\n");
	else{
		ll cx,cy;
		if(flag==1){
			printf("31\n");
			for(int i=1;i<=31;i++)printf("%lld%c",length[i]=(1<<(i-1)),i==31?'\n':' ');
			for(int j=1;j<=N;j++){
				cx=cy=0;
				dfs(31,x[j],y[j]);
				for(int i=1;i<=31;i++){
					printf("%c",alph[ans[i]]);
					cx+=length[i]*dx[ans[i]];
					cy+=length[i]*dy[ans[i]];
				}
				//printf("ps %lld %lld\n",cx,cy);
				printf("\n");
			}
		}
		else {
			printf("32\n");
			for(int i=1;i<=32;i++)printf("%lld%c",i==32?length[i]=1:length[i]=(1<<(i-1)),i==32?'\n':' ');
			for(int j=1;j<=N;j++){	
				cx=cy=0;
				dfs(32,x[j],y[j]);
				for(int i=1;i<=32;i++){
					printf("%c",alph[ans[i]]);
					cx+=(ll)length[i]*dx[ans[i]];
					cy+=(ll)length[i]*dy[ans[i]];
				}
				//printf("cx %lld cy %lld\n",cx,cy);
				printf("\n");
			}
		}
		/*
		printf("%d\n",pre);
		for(int i=1;i<=pre;i++)printf("%d%c",1,i==pre?'\n':' ');
		for(int i=1;i<=N;i++){
			printf("x %d y %d pre %d res %d\n",x[i],y[i],pre,(pre-aa(x[i])+aa(y[i]))/2);
			if(x[i]>0)for(int j=1;j<=x[i];j++)printf("R");
			if(x[i]<0)for(int j=1;j<=aa(x[i]);j++)printf("L");
			for(int j=1;j<=pre-aa(x[i]);j++)
				if(j<=((pre-aa(x[i])+aa(y[i]))/2))printf("%c",y[i]>0?'U':'D');
				else printf("%c",y[i]>0?'D':'U');
			printf("\n");
		}
		*/
	}
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    VVI a(3);
    a[0] = {1, 3, 5, 7, 8, 10, 12};
    a[1] = {4, 6, 9, 11};
    a[2] = {2};
    int x, y;
    cin >> x >> y;
    bool fx = false, fy = false, flag = false;
    rep(i, 3){
        rep(j, a[i].size()){
            if(a[i][j] == x){
                fx = true;
            }
            if(a[i][j] == y){
                fy = true;
            }
            if(fx && fy){
                flag = true;
                break;
            }
        }
        if(flag){
            break;
        }
        fx = false;
        fy = false;
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
void read(int &);

bool dp[40002] = {1};

int main()
{
   int N, Q;
   int a[22];

   read(N);
   rep(i,N)read(a[i]);

   rep(i, N){
      for(int j=40000 - a[i]; j >= 0; --j)
         dp[ j+a[i] ] |= dp[j];
   }

   read(Q);
   while(Q--){
      int m;
      read(m);
      puts( dp[m]? "yes" : "no" );
   }
}

void read(int &tmp)
{
   int k;
   bool s = false;
   tmp = 0;

   for(;;){
      k = getchar_unlocked();
      if(k == '-') {
         s = 1;break;
      }
      if('0' <= k && k <= '9') {
         tmp = k -= '0'; break;
      }
   }
   for(;;){
      k = getchar_unlocked();
      if(k < '0' || '9' < k)break;
      (tmp *= 10) += k -= '0';
   }
   if(s)tmp = -tmp;
}




Measured memory_bytes: 2564
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int idx = 1;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (x == idx) {
                idx++;
            }
        }
        int ans;
        if (idx == 1) {
            ans = -1;
        } else {
            ans = n - idx + 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 63844
import java.util.*;
import java.io.*;
import java.lang.*;

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

        String a = sc.next();
        String b = sc.next();

        int ans = 0;

        for (int i = 0; i<3; i++){
            if (a.charAt(i) == b.charAt(i))
                ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35480
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int a[510][510];
int step[250000][4];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    REP(i, H)REP(j, W) cin >> a[i][j];
    int ans = 0;
    REP(i, H)REP(j, W-1){
        if(a[i][j] % 2){
            step[ans][0] = i;
            step[ans][2] = i;
            step[ans][1] = j;
            step[ans][3] = j+1;
            ++ans;
            a[i][j]--;
            a[i][j+1]++;
        }
    }

    REP(i, H-1){
        int j = W-1;
        if(a[i][j] % 2){
            step[ans][0] = i;
            step[ans][2] = i+1;
            step[ans][1] = j;
            step[ans][3] = j;
            ++ans;
            a[i][j]--;
            a[i+1][j]++;
        }
    }

    cout << ans << endl;
    REP(i, ans)REP(j, 4) cout << step[i][j]+1 << (j==3 ? "\n":" ");

    return 0;
}


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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
string s;
int s_length;
bool dp[100005];
string subs[] = {"dream", "dreamer", "erase", "eraser"};

signed main() {
  string s;
  cin >> s;
  s_length = s.size();
  REPS(i,0,s_length-4) {
    REP(j,4) {
      if(i > 0) {
        if(!dp[i-1]) continue;
      }
      string sub = subs[j];
      int sub_length = sub.size();
      if(i+sub_length > s_length)
        continue;

      auto s_begin = s.begin();
      if(equal(s_begin+i, s_begin+i+sub_length, sub.begin(), sub.end())) {
        dp[i+sub_length-1] = true;
      }
    }
  }
  if(dp[s_length-1]) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 512
#include <bits/stdc++.h>
	
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
//#define int long long int
#define vi vector <int >
#define vvi vector < vector < int >  >
#define vii vector < pii >
#define vll vector <ll >
#define all(x) x.begin(),x.end()
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
//#define double long double
#define a first
#define b second


int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    
    int n;
    cin >> n;
    vi arr(n);
    forn(i, n)
        cin >> arr[i];
    sort(all(arr));
    bool g = false;
    rep(i, 1, n){
        if(arr[i] == arr[i - 1]){
            g = true;
            break;
        }
    }

    if(!g) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1024
a = list(input())
s = "+-"
for i in range(2):
  for j in range(2):
    for k in range(2):
      if eval(a[0]+s[i]+a[1]+s[j]+a[2]+s[k]+a[3]) == 7:
        print(str(a[0]+s[i]+a[1]+s[j]+a[2]+s[k]+a[3])+"=7")
        quit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define fr first
#define sc second
#define sz size()
#define smin(x,y) ((x)=min((x),(y)))
#define smax(x,y) ((x)=max((x),(y)))
#define all(x) x.begin(),x.end()
#define CS ios_base::sync_with_stdio(false);
#define show(x) cerr << #x << " is " << x <<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi; 
const int M=1e5+5;
int now[M];
int red[M];
int32_t main()
{
	red[1]=1;
	fill(now,now+M,1);
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y; cin>>x>>y;
		if(red[x]) red[y]=1;
		now[x]--;
		if(!now[x]) red[x]=0;
		now[y]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++) if(red[i]) ans++;
	return cout<<ans<<endl,0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
  int n,m,i,p;
  int ac[100005]={0},wa[100005]={0};
  int WA=0,AC=0;
  char s[3];
  scanf("%d%d", &n,&m);
  for(i=0; i<m; i++){
    scanf("%d",&p);
    scanf("%s",s);
    if(ac[p]==1)
      continue;
    else if(s[0] == 'A')
      {
      WA += wa[p];
      ac[p]++;
      AC++;
      }
    else
      wa[p]++;
  }
  printf("%d %d", AC,WA);
  return 0;
}

Measured memory_bytes: 2508
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if(s < t){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int a;
	cin >> a;
	cout << 3*a*a << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  while(n --> 0){
    int out = 0;
    int run = 0;
    int p = 0;
    while( out < 3 ){
      string str;
      cin >> str;
      if(str == "HIT"){
        run++;
        if(run == 4){
          p++;
          run = 3;
        }
      }else if(str == "OUT"){
        out++;
      }else{
        p += run + 1;
        run = 0;
      }
    }
    cout << p << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;



void _main() {
    int A, B;
    cin >> A >> B;
    cout << (IN(A, 1, 9) && IN(B, 1, 9) ? A * B : -1) << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,i;scanf("%d%d",&N,&K);
  int a[N];
  for(i=0;i<N;i++) scanf("%d",&a[i]);
  for(i=0;i<N-K;i++) cout << ((a[i] < a[i+K]) ? "Yes\n":"No\n");
}

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

const int maxn=1e5+10;

int n;
int tote,TO[maxn],NEXT[maxn],FIR[maxn];

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

int dfs(int u)
{
	vector<int> x;
	int Ans=0;
	for (int p=FIR[u];p;p=NEXT[p])
		x.push_back(dfs(TO[p]));
	sort(x.begin(),x.end());
	int sz=x.size();
	for (int i=0;i<sz;i++)
		Ans=max(Ans,x[i]+sz-i);
	return Ans;
}

int main()
{
#ifdef h10
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
	int i,f;
	scanf("%d",&n);
	for (i=2;i<=n;i++)
		scanf("%d",&f),addedge(f,i);
	printf("%d\n",dfs(1));
}


Measured memory_bytes: 9216
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int N = scanInt(), M = scanInt();
        long[] ten = new long[N];
        int[] ans = new int[N];
        for (int i = 0; i < N; i++) {
            ten[i] = scanLong();
        }
        for (int i = 0; i < M; i++) {
            int A =  scanInt() - 1;
            int B =  scanInt() - 1;
            if (ten[A] < ten[B]) {
                ans[A] = 1;
            } else if (ten[A] > ten[B]) {
                ans[B] = 1;
            } else {
                ans[A] = 1;
                ans[B] = 1;
            }
        }
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (ans[i] == 0) count++;
        }
        out.print(count);
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 54392
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n;cin>>n;
    vll a(n); REP(i,n) cin>>a[i];
    VSORTR(a);
    ll mx = 1000;
    ll ans=0;
    REP(i,n){
        if (mx > a[i]){
            mx = a[i];
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld, lld> pi;
#define F first
#define S second
#define N 1000007
#define MOD 17868
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (lld i = a; i < b; i++)
lld r, j, l, m, n, s, q, i, k, t, p,z,timer,x,y;string s1, s2;
vi v[N];lld vis[N],dp[N];
void dfs(lld s)
{
	vis[s]++;
	for(auto x:v[s])
	{
		if(!vis[x])
		{
			dfs(x);
			
		}
	}
	for(auto x:v[s])
	{
	   dp[s]=max(dp[s],dp[x]+1);
	}
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m;
  while(m--)
  {
  	cin>>x>>y;v[x].PB(y);
  }
  rep(i,1,n+1)
  {
  	if(!vis[i])
     dfs(i);
  }
  p=1;
  rep(i,1,n+1)p=max(p,dp[i]);//,cout<<dp[i]<<' '<<i<<endl;
  cout<<p;
}

Measured memory_bytes: 36480
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<17;


int imos[2*100000+2],sum[2*100000+2],mi[2*100000+2];
LL cum[2*100000+2];

int main(){
    int n,m;
    cin >> n >> m;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    LL ans=0;
    for(int i=0;i<n-1;i++){
        if(a[i+1]>a[i]){
            ans+=a[i+1]-a[i];
            imos[a[i]+2]++;
            imos[a[i+1]+1]--;
            mi[a[i+1]+1]-=a[i+1]-a[i]-1;
        }
        else{
            ans+=m-a[i]+a[i+1];
            imos[a[i]+2]++;
            imos[m+a[i+1]+1]--;
            mi[m+a[i+1]+1]-=m+a[i+1]-a[i]-1;
        }
    }
    LL s=0;
    for(int i=1;i<=2*m+1;i++){ 
        s+=imos[i];
        sum[i]+=s;
    }
    s=0;
    for(int i=1;i<=2*m+1;i++){
        s+=sum[i]+mi[i];
        cum[i]+=s;
    }
    LL maxi=0;
    for(int i=1;i<=m;i++){
        maxi=max(cum[i]+cum[i+m],maxi);
    }
    cout << ans-maxi << endl;
    return 0;
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

typedef struct {
    int value;
    char suit;
} Card;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

void BubbleSort(Card*, int);
void SelectionSort(Card*, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    Card c[n];
    rep(i, n) cin >> c[i].suit >> c[i].value;

    Card bs[n];
    rep(i, n) bs[i] = c[i];

    BubbleSort(bs, n);
    rep(i, n - 1) cout << bs[i].suit << bs[i].value << " ";
    cout << bs[n - 1].suit << bs[n - 1].value << endl;

    cout << "Stable" << endl;

    SelectionSort(c, n);
    rep(i, n - 1) cout << c[i].suit << c[i].value << " ";
    cout << c[n - 1].suit << c[n - 1].value << endl;

    bool flg = 0;

    for(int i = 0; i < n; i++) {
        if(c[i].suit != bs[i].suit) break;
        if(i == n - 1) flg = 1;
    }

    if(flg)
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;

    return 0;
}
//===========================================

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

void BubbleSort(Card* c, int n) {
    for(int i = 0; i < n; i++) {
        for(int j = n - 1; j > i; j--) {
            if(c[j].value < c[j - 1].value) swap(c[j], c[j - 1]);
        }
    }
}

void SelectionSort(Card* c, int n) {
    for(int i = 0; i < n; i++) {
        int minj = i;
        for(int j = i; j < n; j++) {
            if(c[j].value < c[minj].value)
                minj = j;
        }
        swap(c[i], c[minj]);
    }
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

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

	char s[128];
	scanf("%s",s);

	int d[100];

	int left = 0;
	int right = 0;

	for(int i=0;i<N;i++){
		char buf = s[i];
		if('('==buf) left++;
		if(')'==buf) right++;
		d[i] = left - right;
	}

	int min = 0;
	for(int i=0;i<N;i++){
		if(min > d[i]) min = d[i];
	}

	for(int i=0;i<(-1)*min;i++) printf("%c",'(');
	printf("%s",s);
	for(int i=0;i<d[N-1]-min;i++) printf("%c",')');
	printf("\n");

	return 0;
}


Measured memory_bytes: 128
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

int main() {
    int a, b, c, ans;
    cin >> a >> b >> c;
    
    for (int i=a; i<=b; i++) {
        if (c%i == 0) ans++;
    }
    cout << ans << endl;
    return 0;		 
}


Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int kiriage(int x){
  int y;
  y=x%10;
  if(y==0){
    return x;
  }
  else{
    return (x+10-y);
  }
}
int max(int a,int b){
  if(a>b){
    return a;
  }
  else{
    return b;
  }
}


int main()
{
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  /*
  abcdeを切り上げて，増えた量が一番多いのを最後に回すので，
  abcdeの切り上げたものの和に増加量が一番大きいものを除いたものを引けばいい
  */
  int A,B,C,D,E;
  A=kiriage(a);
  B=kiriage(b);
  C=kiriage(c);
  D=kiriage(d);
  E=kiriage(e);
  int sum=A+B+C+D+E;
  int k=max(max(max(max(A-a,B-b),C-c),D-d),E-e);
  cout<<sum-k;

  
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORE(x, xs) for (auto &x: xs)

const int MAX = 1e5+10;
int N, M;
vi E[MAX];
int len[MAX];

void solve (int s) {
  FORE (i, E[s]) {
    if (len[i] == 0) solve(i);
    len[s] = max(len[s], len[i]);
  }
  len[s]++;
}

int main() {
  cin >> N >> M;
  REP (i, M) {
    int x, y;
    cin >> x >> y;
    E[x].push_back(y);
  }

  int ans = 0;
  FOR (i, 1, N+1) {
    if (len[i] == 0) solve(i);
    ans = max(ans, len[i]);
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
#define FOR(i,n) for(long long i=0;i<n;i++)
#define SFOR(i,a,b) for(long long i=a;i<b;i++)
#define RFOR(i,a,b) for(long long i=b;i>a;i--)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll q,h,s,d,n,ans=0,cnt=0,temp;
  cin>>q>>h>>s>>d;
  cin>>n;
  if(n>=2){
    temp=(min(min(q*8,h*4),min(s*2,d)));
    cnt+=n/2*temp;
    n%=2;
  }
  if(n>=1){
    temp=min(min(q*4,h*2),s);
    cnt+=temp;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 256
using System;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        int H = int.Parse(Console.ReadLine());
        int W = int.Parse(Console.ReadLine());

        //出力
        Console.WriteLine((N - H + 1) * (N - W + 1));
        
    }
}

Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		int ans=700;
		if(s.charAt(0)=='o') ans+=100;
		if(s.charAt(1)=='o') ans+=100;
		if(s.charAt(2)=='o') ans+=100;
		System.out.println(ans);
	}


}


Measured memory_bytes: 26920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	vector<int> tet;
	vector<int> tet_odd;
	for (int i = 1; i*(i+1)*(i+2)<6000000; ++i) {
		tet.push_back((i*(i+1)*(i+2))/6);
		if (i%4 == 1) tet_odd.push_back((i*(i+1)*(i+2))/6);
	}
	reverse(tet_odd.begin(), tet_odd.end());
	set<int> tet_one, tet_two, tet_three;
	for (int t : tet) {
		tet_one.insert(t);
		for (int u : tet) {
			tet_two.insert(t+u);
			for (int v : tet) {
				tet_three.insert(t+u+v);
			}
		}
	}
	int dp[1000001];
	for (int i = 0; i < 1000001; ++i) dp[i] = i;
	for (int i = 2; i < 1000001; ++i) {
		for (int to : tet_odd) {
			if (i>=to) dp[i] = min(dp[i], dp[i-to]+1);
		}
	}

	while (1) {
		int x; cin >> x;
		int ans1 = 5;
		if (x == 0)	return 0;
		auto on = tet_one.find(x);
		auto tw = tet_two.find(x);
		auto th = tet_three.find(x);
		if (on != tet_one.end()) ans1 = 1;
		else if (tw != tet_two.end()) ans1 = 2;
		else if (th != tet_three.end()) ans1 = 3;
		else {
			for (int i = 2; i*2 <= x; ++i)
			{
				auto fo = tet_two.find(i);
				auto ur = tet_two.find(x-i);
				if (fo != tet_two.end() && ur != tet_two.end()) {
					ans1 = 4;
					break;
				}
			}
		}

		cout << ans1 << " " << dp[x] << endl;
	}
}


Measured memory_bytes: 39576