akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#define debug(x) cout << #x << "==" << x << endl;

using namespace std;

const int INF = 1e+8;

//??\???
#define MAX_N 50000
#define MAX_M 20
int N;
int M;
int C[MAX_M];

// dp ????????????
int dp[MAX_N + 1];
bool checked[MAX_N + 1];


int least_coins(int s) {

  if(s < 0) { return INF; }
  if(checked[s] == true) { return dp[s]; }
  if(s == 0) { return 0; }

  int mn = INF;
  for(int i = 0; i < M; i++) {
    mn = min( mn, least_coins( s - C[i] ) + 1 );
  }

  checked[s] = true;
  return dp[s] = mn;

}

int main() {
  ios::sync_with_stdio(false);

  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> C[i];
  }

  cout << least_coins(N) << endl;

  return 0;

}

Measured memory_bytes: 5736
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    sc.close();
    final char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();
    int[] rchars = new int[chars.length];
    Arrays.fill(rchars, 0);

    char[] arr  = a.toCharArray();
    int [] rarr = new int[arr.length];
    for (int i=arr.length; i>0; i--) {
      int rank=rchars[0];
      for (int j=1;j<rchars.length;j++)
        rank = Math.min(rank, rchars[j]);

      int idx=i-1;
      char c = arr[idx];
      rchars[c-'a']=rank+1;
      rarr[idx]=rank+1;
    }

    int rank=rchars[0];
    for (int j=1;j<rchars.length;j++)
      rank = Math.min(rank, rchars[j]);
    StringBuffer sb = new StringBuffer(rank+1);

    int idx=0;
    while (idx<arr.length) {
      loop: for (int j=0;j<chars.length;j++) {
        char c = chars[j];
        boolean flag=true;
        for (int i=idx;i<arr.length;i++) {
          if (arr[i]==c) {
            if (rarr[i]==rank) {
              sb.append(c);
              rank--;
              idx=i+1;
              break loop;
            } else {
              flag = false;
              break;
            }
          }
        }
        if (flag) {
          sb.append(c);
          idx=arr.length;
          break loop;
        }
      }
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 28876
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  ll N;
  cin >> N;
  
  if(N&1) {
    pt(0);
    return 0;
  }
  
  ll ans=0;
  for(ll i=5; i<=N; i*=5) {
    ans+=N/i/2;
  }
  
  pt(ans);
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

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

ll dp[5555][5555];

int main(){
	
	int n;cin >> n;
	vector<pair<ll,pair<ll,ll>>> v;
	
	REP(i,n){
		ll a,b;cin >> a >> b;
		v.PB(MP(a+b,MP(a,b)));
	}
	
	sort(ALL(v));
	
	REP(i,5555)REP(j,5555)dp[i][j] = LLINF;
	dp[0][0] = 0;
	
	REP(i,n){
		auto now = v[i].SE;
		REP(j,n){
			if(dp[i][j] != LLINF){
				dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
				if(now.FI >= dp[i][j]){
					dp[i+1][j+1] = min(dp[i][j] + now.SE,dp[i+1][j+1]);
				}
			}
		}
	}
	
	ll ans = 0;
	
	REP(i,5555){
		if(dp[n][i] != LLINF)ans = i;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;++i){
    cin>>h.at(i);
  }
  sort(h.begin(),h.end(),greater<int>());

  int count=0;
  int i=0;
  while(i<N && h.at(i)>=K){
    ++count;
    ++i;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
package main

import(
	"fmt"
)

const M = 2019
func main(){
	var l,r int
	fmt.Scanln(&l, &r)
	if l/M != r/M {
		fmt.Println(0)
		return
	}
	min:=M-1
	l=l%M
	r=r%M

	for i:=l;i<=r;i++{
		for j:=i+1;j<=r;j++{
			rem:=(i*j)%M
			if rem<min{
				min=rem
			}
		}
	}

	fmt.Println(min)
}

Measured memory_bytes: 512
from sys import stdin

def main():
    input = stdin.readline
    h, w = map(int, input().split())
    n = int(input())
    a = list(map(int, input().split()))
    m = [[0] * w for _ in range(h)]
    x, y, LR, v = 0, 0, 1, 0
    for n in a:
        v += 1
        for _ in range(n):
            m[y][x] = str(v)
            x += LR
            if x == w:
                y += 1
                x = w - 1
                LR = -1
            elif x < 0:
                y += 1
                x = 0
                LR = 1
    for i in range(h):
        print(" ".join(m[i]))
main()

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int mx = max({a, b, c});
    int sm = a + b + c;

    if (!(mx%2 == sm %2)) {
        mx++;
    }

    cout << (mx*3-sm)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "  


int main()
{
    int x;
    cin >> x;
    if(x>=30)
        cout << "Yes" << endl;
        else
        {
            cout << "No" << endl;
        }
        
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, V, B, W, T;
  IN(A,V);
  IN(B,W);
  IN(T);

  if(A>B){
    A = -A;
    B = -B;
  }

  ll L = B-A;

  if(B-A<=(V-W)*T){
    OUT("YES");
  }else{
    OUT("NO");
  }

  return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

#define MAX 10000
#define NIL -1

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

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

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if( T[u].parent == NIL ) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int v, l, r, root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;
  for(int i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(int i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
    int n;
    int v[100000];
    int v1[50000];
    int v2[50000];
    int cnt1[100000] = {0};
    int cnt2[100000] = {0};
    int cnt[100000] = {0};
    
    cin >> n;

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

    for(int i = 0, j = 0; i < n; i += 2, j++){
        v1[j] = v[i];
    }
    
    for(int i = 1,j = 0; i < n; i += 2, j++){
        v2[j] = v[i];
    }
    // cout << "a" << endl;

    for(int i = 0; i < n/2; i++){
        cnt1[v1[i]]++;
    }

    for(int i = 0; i < n/2; i++){
        cnt2[v2[i]]++;
    }
    
    /*
    for(int i = 0; i < n/2; i++){
        cout << v1[i];
    }

    cout << endl;

    for(int i = 0; i < n/2; i++){
        cout << v2[i];
    }

    cout << endl;
    */

    
    int m1_idx_1 = 0;
    int m1_idx_2 = 0;
    int m2_idx_1 = 0;
    int m2_idx_2 = 0;
    for(int i = 0; i < 100000; i++){
        if(cnt1[i] > cnt1[m1_idx_1]){
            m1_idx_2 = m1_idx_1;
            m1_idx_1 = i;
        }
        else if(cnt1[m1_idx_2] < cnt1[i]){
            m1_idx_2 = i;
        }

        if(cnt2[i] > cnt2[m2_idx_1]){
            m2_idx_2 = m2_idx_1;
            m2_idx_1 = i;
        }
        else if(cnt2[m2_idx_2] < cnt2[i]){
            m2_idx_2 = i;
        }
    }

    // cout << m1_1 << " " << m1_idx_1 << " " << m1_2 << " " << m1_idx_2 << endl;
    // cout << m2_1 << " " << m2_idx_2 << " " << m2_2 << " " << m2_idx_2 << endl;

    if(m1_idx_1 != m2_idx_1){
        cout << n - cnt1[m1_idx_1] - cnt2[m2_idx_1] << endl;
    }
    else{
        cout << min(n - cnt1[m1_idx_2] - cnt2[m2_idx_1], n - cnt1[m1_idx_1] - cnt2[m2_idx_2]) << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int p[100];
    int i;
    for(i=1;i<=n;i++){
        scanf("%d",&p[i]);
    }
    int j=1;
    int count=0;
    while(j<=n){
        if(p[j]==j){
            j++;
        }
        else{
            j++;
            count++;
        }
    }
    if(count<=2){
    printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>

using namespace std;

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

  for (int N_i = 0; N_i < N; N_i++) {
    bool overflow = false;
    string str_data1, str_data2;
    cin >> str_data1;
    cin >> str_data2;

    stack<int> data1, data2; 
    for (int data1_i = 0; data1_i < str_data1.size(); data1_i++) {
      char buff[2];
      buff[0] = str_data1[data1_i];
      buff[1] = '\0';
      data1.push(atoi(buff));
    }
    if (data1.size() > 80) {
      cout << "overflow" << endl;
      continue;
    }
    for (int data2_i = 0; data2_i < str_data2.size(); data2_i++) {
      char buff[2];
      buff[0] = str_data2[data2_i];
      buff[1] = '\0';
      data2.push(atoi(buff));
    }
    if (data2.size() > 80) {
      cout << "overflow" << endl;
      continue;
    }

    stack<int> sum;
    int carry = 0;
    int flag = data1.size() < data2.size() ? 0 : 1;
    while(flag == 0 ? !data1.empty() : !data2.empty()) {
      int presum = data1.top() + data2.top() + carry;
      carry = presum / 10;
      sum.push(presum % 10);
      data1.pop();
      data2.pop();
    }
    stack<int> *data;
    data = data1.size() > data2.size() ? &data1: &data2;
    while(!data->empty()) {
      int presum = data->top() + carry;
      carry = presum / 10;
      sum.push(presum % 10);
      data->pop();
    }

    if (carry != 0)
      sum.push(carry);

    if (sum.size() > 80) {
      cout << "overflow" << endl;
      continue;
    }

    if (overflow) {
      cout << overflow << endl;
    } else {
      for (int sum_i = 0; !sum.empty(); sum_i++) {
        cout << sum.top();
        sum.pop();
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1224
N, K, Q = map(int,input().split())
win = [0 for _ in range(N)]
#loss = []
for _ in range(Q):
    A = int(input())-1
    win[A] += 1
for i in range(N):
#    loss.append(K-win[i])
    if K-Q+win[i]>0: print('Yes')
    else: print('No')

Measured memory_bytes: 4620
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
X=sum(A)
for i in range(N):
  if B[i]>=A[i]:    
    B[i]-=A[i]
    A[i]=0
    
    if B[i]>=A[i+1]:
      A[i+1]=0
    else:
      A[i+1]-=(B[i]-A[i])
  else:
    A[i]-=B[i]
Y=sum(A)
print(X-Y)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int maxm=125;
const int INF = 0x3f3f3f3f;

int a[maxn],idx[maxn];
int main()
{
    int n,x,cnt=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        cin>>x;
        a[i]=x;
        idx[x]=i;
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        cout<<idx[a[i]]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1536
A,B,M=map(int,input().split())
#print(A,B,M)
mylist=[]
largelist=[]
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
pricelist=[]

for i in range(M):
    mylist=list(map(int,input().split()))
    largelist.append(mylist)
    
#print(largelist)

#Aのmin,Bminを求める
no_wari=min(Alist)+min(Blist)
pricelist.append(no_wari)

#割引券を総当たり
for i in range(M):
    now_a=largelist[i][0]
    now_b=largelist[i][1]
    now_c=largelist[i][2]
    #print(now_a,now_b,now_c)
    pricelist.append(Alist[now_a-1]+Blist[now_b-1]-now_c)
    
print(min(pricelist))

Measured memory_bytes: 42528
#include <iostream>
using namespace std;
int main(void){
     long long int N,x,a[100000] ;
     cin >> N >> x ;
     for(int i=0;i<N;i++){
          cin >> a[i] ;
     }
     long long int count = 0 ; 
     for(int i=0;i<N-1;i++){
          if(a[i]+a[i+1]>x){
               count += a[i]+a[i+1]-x ;
               if(x>=a[i]){
                    a[i+1] -= a[i]+a[i+1]-x ;  ;
               }else{
                    a[i+1] = 0 ;
               }
          }
     }
     cout << count ;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


/* bellmanford begin*/
struct edge {
	long long to, cost;
};

class bellmanford
{
private:
	long long vertex;	// 頂点数
	vector<vector<edge>> list;	// 隣接リスト
	vector<long long> distance;	// 距離
public:
	void init(long long n);	// nは頂点数
	void add_edge(long long v1, long long v2, long long cost);	// 頂点v1から頂点v2に辺を張る
	bool run(long long s);		// sは開始地点。返り値がfalseのとき負の閉路あり
	long long get_distance(long long v);	// 頂点vへの距離を返す
};

void bellmanford::init(long long n) {
	list.resize(n);
	vertex = n;
}

void bellmanford::add_edge(long long v1, long long v2, long long cost) {
	list[v1].push_back({ v2, cost });
}

bool bellmanford::run(long long s) {
	distance = vector<long long>(vertex, INF);
	distance[s] = 0;	//開始点の距離は0

	for (long long i = 0; i < vertex; i++) {
		for (long long v = 0; v < vertex; v++) {
			for (auto edge : list[v]) {
				if (distance[v] != INF && distance[edge.to] > distance[v] + edge.cost) {
					distance[edge.to] = distance[v] + edge.cost;
					if (i == vertex - 1) {
						//return false;
						distance[edge.to] = -INF;
					}
				}
			}
		}
	}
	return true;
}

long long bellmanford::get_distance(long long v) {
	return distance[v];
}
/* bellmanford end*/

int main()
{
	ll n, m;

	cin >> n >> m;

	bellmanford bell;
	bell.init(n);

	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;

		bell.add_edge(a, b, -c);
	}

	bell.run(0);

	if (bell.get_distance(n - 1) > -INF) {
		cout << -bell.get_distance(n - 1) << endl;
	}
	else {
		cout << "inf" << endl;
	}
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 );
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< std::string, int64_t > origin, std::pair< std::string, int64_t > another )
{
    return origin.second  > another.second;
}
 
int main()
{

    std::string word = "aa";
    int64_t a,b,c,d,e;
    std::cin>> a;

    std::vector< int64_t > list( a );

    for( int i = 0; i < a; i++ )
    {
        std::cin>> list[i];
    }

    d = INFINITY;
    
    for( int i = 1; i < 100; i++ )
    {
        c = 0;
        
        for( int r = 0; r < a; r++ )
        {
            c += pow( i - list[r], 2 );
        }

        d = std::min( d, c );
    }

    std::cout<< d;
}


Measured memory_bytes: 256
def main() -> None:
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    if W >= V:
        print("NO")
    else:
        print("YES" if (V - W) * T >= abs(B - A) else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

class UnionFindTree
{
	vector<int> m_parents;
	vector<int> m_depths;

	public:
		UnionFindTree(int N)
			: m_parents(N), m_depths(N)
		{
			FOR(n,N) {
				m_parents[n]=n;
				m_depths[n]=0;
			}
		}

	public:
		void unionTree(int i, int j)
		{
			// DOUT << "unionTree("<<i<<","<<j<<")"<<endl;
			int depth_i = 0;
			int depth_j = 0;
			int root_i = findRoot(i, depth_i);
			int root_j = findRoot(j, depth_j);
			if(root_i==root_j) {
				return;
			}
			if(depth_i<depth_j) {
				m_parents[root_i] = root_j;
				m_depths[root_i] = 1;
			}
			else {
				m_parents[root_j] = root_i;
				m_depths[root_j] = 1;
			}
		}

		int findRoot(int i, int &out_depth)
		{
			if(i==m_parents[i]) {
				out_depth = 0;
				return i;
			}
			int depth = 0;
			int root = findRoot(m_parents[i], depth);
			m_parents[i] = root;
			m_depths[i] = depth+1;
			out_depth = depth+1;
			return root;
		}

		bool sameRoot(int i, int j)
		{
			int depth_i=0;
			int depth_j=0;
			return findRoot(i, depth_j) == findRoot(j, depth_i);
		}
};

int N,K,L;
map<pair<int, int>, int> parentsMap;
int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin >> N >> K >> L;
	UnionFindTree roadTree = UnionFindTree(N);
	UnionFindTree railTree = UnionFindTree(N);
	FOR(k,K) {
		int p,q;
		cin >> p >> q;
		roadTree.unionTree(p-1,q-1);
	}
	FOR(l,L) {
		int r,s;
		cin >> r >> s;
		railTree.unionTree(r-1,s-1);
	}
	int depth=0;
	FOR(n,N) {
		parentsMap[MP(roadTree.findRoot(n,depth),railTree.findRoot(n,depth))]++;	
	}
	FOR(n,N) {
		if(n>0) {
			cout << " ";
		}
		cout<<parentsMap[MP(roadTree.findRoot(n,depth),railTree.findRoot(n,depth))];
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 15104
"""
観光スポット    1   2   3   4   ... N
座標           A1  A2  A3  A4  ... An

-O-+--+-+---+
観光スポットiを回るのをやめたときの、移動金額の総和

3-O----1--2

0 3 5 -1 0


"""


N = int(input())
As = [0]+list(map(int, input().split()))+[0]

## 総和を出す
cnt = 0
prev = 0
for a in As:
    cnt += abs(a-prev)
    prev = a
cnt += abs(a)
# print(cnt)

## 損失はどのくらいか
for i in range(N):
    l = As[i]
    m = As[i+1]
    r = As[i+2]
    diff1 = abs(r-m)+abs(m-l)
    diff2 = abs(r-l)
    print(cnt-(diff1-diff2))


Measured memory_bytes: 14176
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll max_rect(VL a){
    int n = a.size();
    VI l(n), r(n);

    stack<int> st;
    REP(i,n){
        while (!st.empty() && a[st.top()] >= a[i]) st.pop();
        l[i] = (st.empty() ? 0 : st.top() + 1);
        st.push(i);
    }

    while (!st.empty()) st.pop();
    FORR(i,n-1,0){
        while (!st.empty() && a[st.top()] >= a[i]) st.pop();
        r[i] = (st.empty() ? n : st.top());
        st.push(i);
    }

    ll ret = 0;
    REP(i,n){
        ret = max(ret, a[i] * (r[i] - l[i]));
    }
    return ret;
}

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

    VL h(n);
    REP(i,n) cin >> h[i];

    cout << max_rect(h) << endl;

    return 0;
}

Measured memory_bytes: 5616
#abc098d

n=int(raw_input())
a=map(int,raw_input().split())
l,r=0,0
res=0
temp=0
while r<n:
 if temp & a[r]==0:
  temp+=a[r]
  r+=1
  res+=r-l
 elif l==r:
  l+=1
  r+=1
 else:
  temp-=a[l]
  l+=1
print res


Measured memory_bytes: 19996
#include<stdio.h>
int main(void)
{
	int a1,a2,a3,a4,b1,b2,b3,b4,s,t;
	scanf("%d %d %d %d %d %d %d %d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4);
	s=a1+a2+a3+a4;
	t=b1+b2+b3+b4;
	if(s<t){
		printf("%d\n",t);
	}
	else if(t<s){
		printf("%d\n",s);
	}
	else if(s==t){
		printf("%d\n",s);
	}
	return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 300005, MAXM = 45004, Mod = 998244353 , MAXLog = 20;


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int a, b, t;
    cin >> a >> b >> t;

    cout << t / a * b << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,sum,d;
  while(scanf("%d %d",&a,&b)!=EOF){
    for(sum=a+b,d=1;sum>=10;d++){
      sum/=10;
    }
    printf("%d\n",d);
  }
  return 0;
}

Measured memory_bytes: 600
# B - Nice Shopping
import sys
def input(): return sys.stdin.readline().rstrip()
na, nb, nm = map(int, input().split())
A = [10**5] + list(map(int, input().split()))
B = [10**5] + list(map(int, input().split()))
coupon = [list(map(int, input().split())) for _ in range(nm)]

min_price = 2 * 10**5
for i in range(len(coupon)):
    price = A[coupon[i][0]] + B[coupon[i][1]] - coupon[i][2]
    if min_price > price: min_price = price
no_coupon = min(A)+min(B)
print(min_price if min_price < no_coupon else no_coupon)

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

int	main()
{
	const static int64_t	inf = static_cast<int64_t>(1e+9 * 2000) + 1;
	int	N, M;
	cin >> N >> M;
	vector<int64_t>				v_score(N, -inf);
	map<int, map<int, int64_t>>	e_score;
	map<int, int>	prev_map;
	int	a, b;
	int64_t	c;
	for (int i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		--a; --b;
		if (!e_score.count(a))
			e_score[a] = map<int, int64_t>(); 
		e_score.at(a)[b] = c;
	}
	bool	updated = false;
	v_score.at(0) = 0;
	int64_t	tmp_score;
	set<int>	updated_set;
	for (int i = 0; i < N; ++i) {
		updated = false;
		updated_set.erase(updated_set.begin(), updated_set.end());
		for (a = 0; a < N; ++a) {
			if (v_score.at(a) == -inf)
				continue;
			if (!e_score.count(a))
				continue;
			for (auto pr : e_score.at(a)) {
				b = pr.first;
				tmp_score = v_score.at(a) + pr.second;
				if (tmp_score > v_score.at(b)) {
					v_score.at(b) = tmp_score;
					updated = true;
					prev_map[b] = a;
					updated_set.insert(b);
				}
			}
		}
		if (!updated)
			break;
	}
	bool	has_posi_cycle = false;
	for (b = N - 1; b != 0; b = prev_map.at(b)) {
		if (updated_set.count(b)) {
			has_posi_cycle = true;
			break;
		}
	}
	if (v_score.at(0) > 0)
		has_posi_cycle = true;
	if (has_posi_cycle)
		cout << "inf" << endl;
	else
		cout << v_score.at(N - 1) << endl;
}


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

const int N = 2e5 + 10;
const int inf = INT_MAX;

#define ll long long
#define FOR(i,a,b) for(int i = a;i <= b;i++)
#define _FOR(i,a,b) for(int i = a;i >= b;i--)

template<typename T> void read(T &x)
{
  x = 0;int f = 1;
  char c = getchar();
  for(;!isdigit(c);c = getchar()) if(c == '-') f = -1;
  for(;isdigit(c);c = getchar()) x = x * 10 + c - '0';
  x *= f;
}

struct edge
{
  int to,next;
} e[N * 2];

int head[N],n,q,t,dfn[N],pos[N],cnt,size[N],chafen[N];
int ans[N];

void add(int x,int y)
{
  e[++t] = (edge){y,head[x]};
  head[x] = t;
}

void dfs(int x,int fa)
{
  size[x] = 1,dfn[++cnt] = x,pos[x] = cnt;	
  for(int i = head[x];i;i = e[i].next)
    if(e[i].to != fa) dfs(e[i].to,x),size[x] += size[e[i].to];
}

int main()
{
  //freopen(".in","r",stdin);
  //freopen(".out","w",stdout);
  read(n),read(q);
  FOR(i,1,n - 1)
  {
  	int x,y;
  	read(x),read(y);
  	add(x,y),add(y,x);
  }
  dfs(1,0);
  while(q--)
  {
  	int x,val;
  	read(x),read(val);
  	chafen[pos[x]] += val;
  	chafen[pos[x] + size[x]] -= val;
  }
  FOR(i,1,n)
    ans[dfn[i]] = ans[dfn[i - 1]] + chafen[i];
  FOR(i,1,n)
    printf("%d ",ans[i]);
  puts("");
  return 0;
}



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

int main(){
	int n,t;
	long long ans=0;
	vector <int> d;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t;
		d.push_back(t);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=d[i]*d[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
    
    
public class Main {
	static int INF = 2 << 27;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int K = sc.nextInt();
			if(n == 0 && K == 0) break;
			int[] c = new int[n];
			for(int i = 0; i < n; i++) {
				c[i] = sc.nextInt();
			}
			int CMax = 0;
			for(int i = 0; i < n; i++) {
				if(i + (K-1) >= n) break;
				int sum = 1;
				for(int j = 0; j < K; j++) {
					sum *= c[i + j];
				}
				CMax = Math.max(sum, CMax);
			}
			int AMax = 0;
			for(int i = 0; i < n; i++) {
				for(int j = i+1; j < n; j++) {
					int tmp = c[i];
					c[i] = c[j];
					c[j] = tmp;
					for(int k = 0; k < n; k++) {
						if(k + (K-1) >= n) break;
						int sum = 1;
						for(int l = 0; l < K; l++) {
							sum *= c[k + l];
						}
						AMax = Math.max(sum, AMax);
					}
					tmp = c[i];
					c[i] = c[j];
					c[j] = tmp;
				}
			}
			System.out.println(AMax < CMax?"NO GAME":AMax - CMax);
			
			
		}
	}
}

Measured memory_bytes: 47416
require 'pp'

a, b, x = gets.chomp!.split(" ").map(&:to_i)

s = a * a
# 傾けてない状態でのcm
y = x / s.to_f

if a * b * a >= 2 * x
  h = 2 * x.to_f / (b * a)
  r = Math.sqrt(b * b + h * h)

  puts 90 - Math.asin(h / r) * 180 / Math::PI
else
  z = 2 * (b - y)
  r = Math.sqrt(z * z + a * a)
  puts 90 - Math.asin(a.to_f / r) * 180 / Math::PI
end


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int X; cin >> X;
    vector<int> dp(X+1,0);
    dp[0] = 1;   
    for(int i = 0; i < X; ++i){
        if(i+100<=X) dp[i+100] |= dp[i];
        if(i+101<=X) dp[i+101] |= dp[i];
        if(i+102<=X) dp[i+102] |= dp[i];
        if(i+103<=X) dp[i+103] |= dp[i];
        if(i+104<=X) dp[i+104] |= dp[i];
        if(i+105<=X) dp[i+105] |= dp[i];
    }
    cout << dp[X] << endl;

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int n,h;
    cin>>n>>h;
    priority_queue<pair<ll int,int>,vector<pair<ll int,int>>> v;
    rep(i,2*n){
        ll int temp;
        cin>>temp;
        pair<ll int,int> p;
        if(i%2){
          	p.first=temp;
          	p.second=1;
            v.push(p);
        }
        else {
          p.first=temp;
          p.second=0;
          v.push(p);
        }
    }
    ll int num=0;
    while(h>0){
        if(v.top().second){
            h-=v.top().first;
            v.pop();
            num++;
        }
        else break;
    }
    num+=((h+v.top().first-1)/v.top().first);
    cout<<num;
    return 0;

}

Measured memory_bytes: 6384
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=ST()
    head = 0
    tail = 0
    c,e = 0,0
    for s in S:
        if s=="(":
            c += 1
        else:
            e += 1
        if c<e:
            head += e-c
            e=c
    if c>e:
        tail = c-e
    print(head * "(" + S + tail * ")")
        
if __name__ == '__main__':
    main()
    #H*W = Sになるような最大値最小の(H,W)を求める
    # S=I()
    # x1,y1 = 0,0
    # x2,y3 = 0,0

    # x2,y2


    # S=ST()
    # ans = 0
    # for i in range(len(S)):
    #     for it in combinations([i for i in range(len(S))], i):
    #         before = 0
    #         for j in it:
    #             print(int(S[before:j+1]), before,j)
    #             ans += int(S[before:j+1])
    #             before = j+1
    #         try:
    #             ans += int(S[before:])
    #         except:
    #             pass
    #         print(ans)
    # print(ans)

Measured memory_bytes: 7812
import itertools
import math

N = int(input())
cnt = 0
listA = []
for i in range(3, int(math.sqrt(N)+1), 2):
    listA.append(i)
#print(listA)
listB = list(itertools.combinations(listA, 3))
#print(listB)
for listC in listB:
    seki = 1
    for x in listC:
        seki = seki * x
    if seki <= N:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,k,a[N],dp[N];
int main(){
	cin>>n>>k;
	memset(dp,0x3f,sizeof(dp));
	dp[1]=0;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=2;i<=n;i++){
		for(int j=1;j<=min(k,i);j++){
			dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.next();
		if(str.charAt(0) == str.charAt(str.length() - 1) && str.charAt(0) == 'x')
		{
			System.out.println('x');
		}
		else
		{
			System.out.println('o');
		}
	}
}

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



int main()
{
	FAST;
	ll n;
	cin >> n;
	if(n < 1200){
		cout << "ABC";
		return 0;
	}
	if(n < 2800){
		cout << "ARC";
		return 0;
	}
	cout << "AGC";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, k; cin >> n >> k;
    if(k %2 == 1){
        ll ans = n/k;

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

    ll jud = n/k;
    ll jud2 = n/(k/2) - jud;

    cout << jud * jud * jud + jud2 * jud2 * jud2 << endl;

}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

res = 0
flag = True
while flag:
    for i in range(N):
        if A[i]%2 == 0:
            A[i] = A[i] // 2
        else:
            flag = False
            break
    res += 1
print(res - 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
    double t,x;
    cin >> t >> x;
    cout << fixed << setprecision(10) << t/x << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int d, n;cin >> d >> n;
    int ans = 1;
    inc(i, 0, d) ans *= 100;
    if(n == 100){
        n++;
    }
    ans *= n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string N;
	cin >> N;
	string ans = "No";
	rep(i, 3)
	{
		if (N[i] == '7')
			ans = "Yes";
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();
        int c = 0;
        for(int i=0; i<1000; i++) {
            String temp = Integer.toString(i);
            int len = temp.length();
            if(len < 3) {
                temp = (len==1 ? "00" : "0") + temp;
            }
            char t1 = temp.charAt(0);
            char t2 = temp.charAt(1);
            char t3 = temp.charAt(2);
            int i1 = s.indexOf(t1, 0);
            if(i1<0) {
                continue;
            }
            int i2 = s.indexOf(t2, i1+1);
            if(i2<0) {
                continue;
            }
            if(s.indexOf(t3, i2+1)>0) {
                c++;
            }
        }

        System.out.println(c);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;


long long dp[1000005];

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

int main() {
	int X, Y;
	cin >> X >> Y;

	int x1, x2, y1, y2;
	x2 = X / 2;
	x1 = X % 2;
	y2 = Y / 2;
	y1 = Y % 2;

	dp[0] = 1;
	dp[1] = 1;
	for (int i = 2; i < 1000001; ++i) {
		dp[i] = (dp[i-1]%AAA) * (i%AAA) % AAA;
	}

	long long ans = 0;

	for (int r = 0; r <= x2; r++) {
		int d = X - 2 * r;
		if (X == r * 2 + d && Y == d * 2 + r) {
			int n = r + d;
			ans += (dp[n] * calc((dp[r]*dp[d]%AAA),AAA-2,AAA)) % AAA;
					   			 
		}


	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    char a, b;
    cin >> a;

    b = a + 1;
    cout << b << endl;


  

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	char S[30];
	scanf("%s", S);

	S[5] = ' ';
	S[13] = ' ';

	printf("%s", S);





}

Measured memory_bytes: 128
K = input()
D = int(input())

#dp[桁][余り][未満flag]
dp = [[[0 for k in range(2)] for j in range(D)] for i in range(len(K)+1)]
dp[0][0][0] = 1
s = 0
for i in range(len(K)):
    n = int(K[i])
    dp[i+1][(s+n)%D][0] = dp[i][s%D][0]
    s += n
    for j in range(D):
        for k in range(10):
            if k < n:
                dp[i+1][(j+k)%D][1] += dp[i][j][0]
            dp[i+1][(j+k)%D][1] += dp[i][j][1]
            dp[i+1][(j+k)%D][1] %= 1000000007

print(sum(dp[len(K)][0], -1)%1000000007)


Measured memory_bytes: 130012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Selection of Participants of an Experiment
 */
public class Main {

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

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

			int n = parseInt(line);
			if (n == 0) break;

			int[] arr = new int[n];

			StringTokenizer st = new StringTokenizer(br.readLine());

			for (int i = 0; i < n; i++) arr[i] = parseInt(st.nextToken());

			Arrays.sort(arr);

			int min = Integer.MAX_VALUE;

			for (int i = 0; i < n - 1; i++) {
				min = Math.min(min, arr[i + 1] - arr[i]);
				if (min == 0) break;
			}

			System.out.println(min);

		} //end while
	} //end main
}

Measured memory_bytes: 31592
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int h, w, n;
  cin >> n >> w >> n;
  int c = 0;
  bool flag = true;
  string line = "";
	rep(i, n){
    int a;
    cin >> a;
    rep(j, a){
      // cout << c << " " << line << endl;
      if(c == w){
        c = 0;
        flag = !flag;
        cout << line << endl;
        line = "";
      }
      if(flag) line = line + (line==""?line:" ") + to_string(i+1);
      else line = to_string(i+1)+ (line==""?line:" ") + line;
      c++;
    }
  }
  cout << line << endl;
	return 0;
}


Measured memory_bytes: 256
let id x = x

let to_class w =
  if w <= 48.0 then "light fly"
  else if w <= 51.0 then "fly"
  else if w <= 54.0 then "bantam"
  else if w <= 57.0 then "feather"
  else if w <= 60.0 then "light"
  else if w <= 64.0 then "light welter"
  else if w <= 69.0 then "welter"
  else if w <= 75.0 then "light middle"
  else if w <= 81.0 then "middle"
  else if w <= 91.0 then "light heavy"
  else "heavy"

let _ =
  try
    while true do
      let w = Scanf.scanf "%f\n" id in
      Printf.printf "%s\n" (to_class w)
    done
  with
    End_of_file -> ()

Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              300005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

string s;

int main(){
    Fast;
    int a,b,c, i,j, n,m,t, cs=1;
    cin>>n>>s;

    if(s.size()<=n){
        cout<<s<<endl;
        return 0;
    }
    for(i=0; i<n; i++){
        cout<<s[i];
    }
    cout<<"..."<<endl;


    return 0;
}


Measured memory_bytes: 3652
program main
  implicit none
  integer :: n, m, res
  integer, allocatable :: x(:), y(:)
  read (*, *) n, m
  allocate (x(m), y(m - 1))
  read (*, *) x(:)

  call quicksort(x)
  y(:) = x(2:) - x(:m - 1)
  if (m - 1 > 1) call quicksort(y)

  res = sum(y(:m - n))
  write (*, "(i0)") res

  contains

  recursive subroutine quicksort(a)
    integer, intent(inout) :: a(:)
    integer :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    if (1 < i - 1) call quicksort(a(1:i - 1))
    if (j + 1 < n) call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main


Measured memory_bytes: 1536