akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

string s;
string dfs(int i, string a, int now){
	if(i == 4 && now == 7){
		return a;
	}else if(i == 4){
		return "";
	}
	string b = dfs(i+1, a+'+'+s.substr(i, 1), now+s[i]-'0');
	string c = dfs(i+1, a+'-'+s.substr(i, 1), now-s[i]+'0');
	if(b != "")
		return b;
	if(c != "")
		return c;
	return "";
}

int main(void){
	cin >> s;
	string res = dfs(1, s.substr(0, 1), s[0]-'0');
	cout << res << "=7" << endl;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int N;

  cin>>N;

  int a[21],b[21],c[21];

  int ans=0;

  for(int i=1;i<=N;i++){
    cin>>a[i];

  }

  
  for(int i=1;i<=N;i++){
    cin>>b[i];

  }

  
  for(int i=1;i<=N-1;i++){
    cin>>c[i];

  }


  for(int i=1;i<=N;i++){

    ans+=b[a[i]];
    

    if(i<=N-1&&a[i]+1==a[i+1]){
      ans+=c[a[i]];
    }


  }


  cout<<ans<<endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(string s){
	if (s[0]!=s[s.length()-1])  {
		if (s.length()%2 == 0) {
			cout << "Second" << endl;
		} else {
			cout << "First" << endl;
		}
	} else {
		if (s.length()%2 == 0) {
			cout << "First" << endl;
		} else {
			cout << "Second" << endl;
		}
	}
}

int main(){	
	string s;
	cin >> s;
	solve(s);
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+5;
const int mod=998244353;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int sum=0;
    for(int i=1;i<=m;i++)
    {
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>n)
    {
        cout<<-1<<'\n';
    }
    else
        cout<<n-sum<<'\n';



}


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

main(){
  int N;
  cin >> N;
  int p[N];
  for(int ii=0;ii<N;ii++){
    cin >> p[ii];
  }
  sort(p,p+N);
  int ans=0;
  for(int ii=0;ii<N;ii++){
    ans+=p[ii];
  }
  ans-=p[N-1]/2;
  //  ans-=max(p,p+N)/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

readline = stdin.buffer.readline

INF = 10 ** 10

K = int(readline())
S = str(input())

if len(S) <= K:
    print(S)
else:
    tmp = "".join([c for c in S[:K]])
    print(tmp + "...")



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

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i=0; i<N; i++) {
    cin >> D.at(i);
  }
  
  int ans = 0;
  for(int i=0; i<N-1; i++) {
    for(int j=i+1; j<N; j++) {
      ans += D.at(i) * D.at(j) ;
    }
  }
  
  cout << ans << endl;
}



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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  string S;
  CIN(S);

  string d[] = {
    "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
  };

  for (int i = 0; i < 7; i++) {
    if (d[i] == S) {
      COUT((7 - i) % 8);
    }
  }

  return 0;
}


Measured memory_bytes: 256
n,k = list(map(int, input().split()))

sums = [0 for i in range(n+1)]
MOD = 1000000007

ans = 1
for i in range(n+1):
    ans += i*min(i,n-k+1)
    ans %= MOD

ans += n-k+1

for i in range(n+1):
    ans -= (n-i)*min(i,n-k+1)
    ans += MOD
    ans %= MOD

print(ans)

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;
  vector < ll > h(n + 1), dp(n + 1);
  for(int i = 1; i <= n; i++) cin >> h[i];

  dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for(int i = 3; i <= n; i++){
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  cout << dp[n] << '\n';
}


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

int main(){
    ll x;
    cin >> x;
    x -= 400;
    ll i = x / 200;
    cout << 8 - i << endl;
    return 0;
}

Measured memory_bytes: 3632
from sys import stdin


def selection_sort(A, N):
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[minj] > A[j]:
                minj = j
        
        if A[minj] != A[i]:
            count += 1
            A[minj], A[i] = A[i], A[minj]
        
    return count
                
def main():
    read = stdin.readline
    N = int(read())
    data = list(map(int, read().split(' ')))
    count = selection_sort(data, N)
    for i in range(N-1):
        print(data[i], end=' ')
    print(data[N-1])
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5612
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 110000;
int f[maxn];

int fsum(int *f, int i) {
    int s = 0;
    for (; i >= 0; i &= i + 1, --i) s ^= f[i];
    return s;
}            

void fadd(int *f, int i, int x) {
    for (; i < maxn; i |= i + 1) f[i] ^= x;
}

int inv2(vi a) {
    int n = a.size();
    forn(i, maxn) f[i] = 0;
    int s = 0;
    ford(i, n) {
        s ^= fsum(f, a[i]);
        fadd(f, a[i], 1);
    }
    return s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vvi a(3, vi(n));
    forn(i, 3) forn(j, n) cin >> a[i][j];
    vi b(n), s(n);
    bool ok = true;
    forn(j, n) {
        ok &= abs(a[0][j] - a[1][j]) == 1 && abs(a[2][j] - a[1][j]) == 1;
        b[j] = a[1][j] / 3;
        ok &= b[j] % 2 == j % 2;
        s[j] = 1;
        if (a[1][j] < a[0][j]) s[j] = -1;
//        cerr << b[j] << ' ' << s[j] << '\n';
    }
    if (!ok) {
        cout << "No\n";
        return 0;
    }
    if (n <= 4) {
        forn(i, n) forn(j, n - 2) {
            if (b[j] > b[j + 2]) {
                swap(b[j], b[j + 2]);
                forn(k, 3) s[j + k] *= -1;
            }
        }
        if (n == 4) if (s[0] == -1) forn(i, n) s[i] *= -1;
        bool ok = true;
        forn(i, n) ok &= s[i] == 1;
        cout << (ok ? "Yes" : "No") << '\n';
        return 0;
    }

    vvi v(2);
    vi cnt(2);
    forn(i, n) v[i & 1].pb(b[i]), cnt[i & 1] ^= (s[i] == -1);
    ok = true;
    forn(i, 2) ok &= (inv2(v[i]) == cnt[i ^ 1]);
    cout << (ok ? "Yes" : "No") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3448
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	K := getInt()
	X := getInt()

	if 500 * K >= X {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


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

const int MOD = 1000000007;

vector<long long> fact_inv, inv, Com;
/*  init_nCk :二項係数のための前処理
    計算量:O(n)
*/
void init_nCk(int n, int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (int i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int k) {
    assert(!(k < 0));
    return Com[k];
}

long long modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

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

    init_nCk(n, max(a, b));
    ll ans = modpow(2LL, n) - 1 - nCk(a) - nCk(b);
    while (ans < 0) ans += MOD;
    cout << ans << endl;
}

Measured memory_bytes: 7836
import sys
input=sys.stdin.readline
n,t=map(int,input().split())
dp=[[0 for i in range(t)] for j in range(n+1)]
food=[list(map(int,input().split())) for i in range(n)]
foodmax=[0]*n
food.sort(key=lambda x:x[1],reverse=True)
food.sort(key=lambda x:x[0])
foodmax[-1]=food[-1][1]
for i in range(n-1)[::-1]:
  foodmax[i]=max(foodmax[i+1],food[i][1])
foodmax+=[0]
for i in range(n):
  for j in range(t):
    if j<food[i][0]:
      dp[i+1][j]=dp[i][j]
    else:
      dp[i+1][j]=max(dp[i][j],dp[i][j-food[i][0]]+food[i][1])
      
ans=0
for i in range(n):
  if ans<dp[i+1][t-1]+foodmax[i+1]:
    ans=dp[i+1][t-1]+foodmax[i+1]
print(ans)


Measured memory_bytes: 119388
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a!=c)cout<<"Yes"<<endl;
  else if(a==c&&a!=b)cout<<"Yes"<<endl;
  else if(b==c&&b!=a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int main(){
    int f=0;
    string s,t;
    cin>>s>>t;
    s+=s;
    for(int i=0;i<t.size();i++){
        if(s.substr(i,t.size())==t) f=1;
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i], a[i]--;
    
    multiset<pair<int,int>> s;
    vector<int> v[m];
    ll sum = 0, tmp = 0;
    for(int i = 0; i+1 < n; i++){
        if(a[i] < a[i+1])   v[a[i]].push_back(a[i+1]), sum += a[i+1]-a[i];
        else                v[a[i]].push_back(a[i+1]+m), s.insert({a[i+1], a[i+1]+m-a[i]}), sum += a[i+1]+m-a[i], tmp += m-1-a[i]-1;
    }
    
    ll ans = 1ll<<60;
    for(int i = 0; i < m; i++){
        tmp += s.size();
        ans = min(ans, sum-tmp);
        while(s.size() > 0 && s.begin()->first == i){
            tmp -= s.begin()->second-1;
            s.erase(s.begin());
        }
        for(int c : v[i]){
            s.insert({c, c-i});
            tmp--;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9984
n=int(input())
d=list(map(int, input().split()))
m=int(input())
t=list(map(int,input().split()))

d.sort()
t.sort()
flg_no = 0
index_start=0
for i in range(m):
  index=index_start
  flg_fin=0
  while index < n:
    if d[index] == t[i]:
      index_start=index+1
      flg_fin=1
      break
    index+=1
  if flg_fin == 0:
    print('NO')
    flg_no = 1
    break
if flg_no == 0:
  print('YES')

Measured memory_bytes: 35420
DIV = 10 ** 9 + 7

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
ans = 0

if a.uniq.size == n || b.uniq.size == m
  ans = 1
  fixes = a & b
  maxes = (a + b).uniq
  (n*m).downto(maxes.min).each do |i|
    if fixes.include?(i)
      # nothing
    elsif maxes.include?(i)
      if j = a.index(i)
        ans = ans * b.count{ |k| k >= i } % DIV
      else
        j = b.index(i)
        ans = ans * a.count{ |k| k >= i } % DIV
      end
    else
      count = b.count{ |k| k >= i } * a.count{ |k| k >= i }
      ans = ans * (count - n * m + i) % DIV

    end
  end

  (1..maxes.min-1).each do |i|
    ans = ans * i % DIV
  end
end
puts ans

Measured memory_bytes: 1916
n,m=map(int,input().split())
mod=10**9+7
def kaijou(x):
  y=1
  for i in range(1,x+1):
    y*=i
    y%=mod
  return y
if abs(n-m)>=2:
  print(0)
elif n==m:
  print((kaijou(n)*kaijou(m)*2)%mod)
else:
  print((kaijou(n)*kaijou(m))%mod)


Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A, B, C;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		
		if(A>C && B>C || A<C && B<C) {
			System.out.println( "No ");
		}else {
		System.out.println(" Yes ");
		}
	}
}


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

int main() {
	int N,a, digit = 0,sum = 0;
	string N_str;
	cin >> N;
	a = N;
	while (a)
	{
		digit = a % 10;
		sum += digit;
		a = a / 10;
	}
	if ((N%sum) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

}

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

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
	int n,m;cin>>n>>m;
	UnionFind<int> uf(n);
	
	for(int i=0; i < m; i++) {
		int l,r,d;
		cin>>l>>r>>d;--l;--r;
		
		if(uf.issame(l,r)) {
			int diff = uf.diff(l,r);
			if(diff != d) {
				cout << "No" << endl;
				return 0;
			}
		} else {
			uf.merge(l,r,d);
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1408
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve() {
	lli x, n;
	cin >> x >> n;
	lli sum = 0;
	for (lli i = 0, v; i < n; i++) {
		cin >> v;
		sum += v;
	}
	if (sum <= x) {
		cout << x - sum << endl;
	} else cout << -1 << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main(){
  int p,age;
  while(cin >> p){
    if(p==0) break;
    int ans[7] = {0};
  for(int i=0;i<p;i++){
    cin >> age;
    if(age<10) ans[0]++;
    else if(age<20) ans[1]++;
    else if(age<30) ans[2]++;
    else if(age<40) ans[3]++;
    else if(age<50) ans[4]++;
    else if(age<60) ans[5]++;
    else ans[6]++;
  }
  for(int i=0;i<7;i++) cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
 
int main()
{
    vector<int> num(101, 0);
    int maxNum = 0;
 
    for(;;){
        int a;
        if(!(cin >> a))
            break;
        maxNum = max(maxNum, ++num[a]);
    }
 
    for(int i=1; i<=100; ++i){
        if(num[i] == maxNum)
            cout << i << endl;
    }
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

long mod = 1000000007L;

signed main() {
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	ll rate = min(min(q * 4, h * 2), s);
	ll pay;
	if (rate * 2LL <= d) {
		pay = n * rate;
	} else {
		pay = (n / 2LL) * d + ((n % 2LL) * rate);
	}
	cout << pay << endl;
}


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

using ll = long long;

int main() {
    string S, T;
    cin >> S >> T;
    vector<string> ans;
    rep(i, S.size() - T.size() + 1) {
        bool f = true;
        rep(j, T.size()) {
            if (S[i + j] != '?' && S[i + j] != T[j]) {
                f = false;
                break;
            }
        }
        if (f) {
            string A = S;
            rep(j, T.size()) {
                if (A[i + j] == '?') A[i + j] = T[j];
            }
            rep(j, A.size()) {
                if (A[j] == '?') A[j] = 'a';
            }
            ans.push_back(A);
        }
    }
    if (ans.size() == 0) {
        cout << "UNRESTORABLE\n";
    } else {
        sort(ans.begin(), ans.end());
        cout << ans[0] << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,m,dp[N][N];
char mp[N][N];
signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i)cin>>(mp[i]+1);
	dp[1][1]=mp[1][1]=='#';
	for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	if(i>1||j>1){
		if(mp[i][j]=='.')dp[i][j]=min(i!=1?dp[i-1][j]:0x3f3f3f3f,j!=1?dp[i][j-1]:0x3f3f3f3f);else
		dp[i][j]=min(i!=1?dp[i-1][j]+(mp[i-1][j]=='.'):0x3f3f3f3f,j!=1?dp[i][j-1]+(mp[i][j-1]=='.'):0x3f3f3f3f);
	}
	cout<<dp[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N,M,Q;
int a[50], b[50], c[50], d[50];
long long dfs(int* array, int depth, int maxI) {
    if (depth == N) {
        long long score = 0;
        for (int i=0; i<Q; i++) {
            if (array[b[i]-1] - array[a[i]-1] == c[i]) score += d[i];
        }
        return score;
    }
    long long maxscore = 0;
    for (int i=maxI; i<=M; i++) {
        array[depth] = i;
        maxscore = max(maxscore, dfs(array, depth+1, i));
    }
    return maxscore;
}
int main() {
    cin >> N >> M >> Q;
    for (int i=0; i<Q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];

    int array[10] = {0};
    cout << dfs(array, 0, 1) << endl;
    return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M;
    cin >> N >> M;
    cout << (N == M ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3644
/******************************************
*    AUTHOR:         BHUVNESH JAIN        *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;

int main() {
	// freopen("inp.txt", "r", stdin);
	int n;
	scanf("%d", &n);
	vector<LL> a(3*n);
	for(int i = 0; i < 3*n; ++i) {
		scanf("%lld", &a[i]);
	}
	sort(a.rbegin(), a.rend());
	LL ans = 0;
	for(int i = 1; i < 2*n; i+=2) {
		ans += a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int m, d;
  cin >> m >> d;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= d; j++) {
      int d1 = j%10;
      int d10 = j / 10;
      if (d1 >= 2 && d10 >= 2 && d1*d10==i) {
        ans++;
      }
    }
  }

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

Measured memory_bytes: 256
n,m,x = map(int,input().split())
ls = []
for i in range(n):
    ca = list(map(int,input().split()))
    ls.append(ca)
    
pattern = [bin(i)[2:].zfill(n) for i in range(2**n)]

ans = 10000000
for i in ls:
    tmp = []
    for j in pattern:
        p2 = 0
        al = [0]*m
        for k in range(len(j)):#101
            if j[k] == "1":
                al = [x + y for (x, y) in zip(ls[k][1:], al)]
                p2 += ls[k][0]
        p = 0
        for k in al:
            if k < x:
                p += 1
                break
        if sum(al) < m*x:
          p += 1
        if p == 0:
            #print(p2)
            ans = min(ans,p2)
if ans == 10000000:
  print(-1)
else:
  print(ans)     
    

Measured memory_bytes: 9328
#include "bits/stdc++.h"
using namespace std;
const int maxn = 300300;
char s[maxn];
int p[maxn];
int main(){
    int n;
    cin >> n;
    for(int e = 1; e <= n; e++) cin >> p[e];
    vector<pair<int, int> > nxt;
    for(int e = 0; e < 20; e++) nxt.push_back({n + 1, e});
    long long res = 0;
    int L = n + 1;
    for(int e = n; e >= 1; e--){
        for(int f = 0; f < 20; f++){
            if(p[e]&(1<<nxt[f].second)){
                L = min(L, nxt[f].first);
                nxt[f].first = e;
            }
        }
        res += (L - e);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	
	int a[7],c[2][7],z,Z,x;
	
	for(int i=0;i<6;i++){
		
		scanf("%d",&a[i]);
	}
	for(int i=0;i<6;i++){
		
		scanf("%d",&c[1][i]);
		c[0][i]=i;
	}
	///?????????????±???????????????????
	
	for(int i=0;i<6;i++){
		
		///??????c[1][i]?????????///
		
		for(int t=0;i!=c[0][0];t++){
			if(t==4) break;
			z=c[0][0];
			Z=c[1][0];
			c[0][0]=c[0][4];
			c[1][0]=c[1][4];
			c[0][4]=c[0][5];
			c[1][4]=c[1][5];
			c[0][5]=c[0][1];
			c[1][5]=c[1][1];
			c[0][1]=z;
			c[1][1]=Z;
		}
		if(i!=c[0][0]){
			for(int t=0;i!=c[0][0];t++){
				if(t==4) break;
				z=c[0][0];
				Z=c[1][0];
				c[0][0]=c[0][2];
				c[1][0]=c[1][2];
				c[0][2]=c[0][5];
				c[1][2]=c[1][5];
				c[0][5]=c[0][3];
				c[1][5]=c[1][3];
				c[0][3]=z;
				c[1][3]=Z;
			}
		}
		///a[]??¨????????????????????´??¢?????????///
		
		for(int t=0;t<4;t++){
			x=0;
			for(int t=0;t<6;t++){
				if(a[t]!=c[1][t]){
					x++;
				}
			}
			//printf("%d\n",x);
			if(x==0) break;
			
			Z=c[1][1];
			c[1][1]=c[1][3];
			c[1][3]=c[1][4];
			c[1][4]=c[1][2];
			c[1][2]=Z;
		}
		if(x==0) break;
	}
	if(x==0){
		printf("Yes\n");
	}
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 2680
import copy
N=int(input())
rH=list(map(int,input().split()))
ans=0
for i in range(max(rH)):#もっと目標が高いものの回数まで行う
    cH=copy.deepcopy(rH)
    for k in range(N):#rHで条件を確認しつつ、cHを更新していく
        if rH[k]!=0 and ((k!=0 and rH[k-1]==0)or(k==0)):
            cH[k]-=1
            ans+=1
        elif rH[k]!=0:
            cH[k]-=1
    rH=copy.deepcopy(cH)
print(ans)

Measured memory_bytes: 3444
import collections
n = int(input())
c = collections.Counter()
total = 0
for i in range(n):
    sn = input()
    l = list()
    sed = ''
    for j in range(10):
        l.append(sn[j])
    l.sort()
    for x in l:
        sed += x
    c[sed] += 1
for y in list(c.values()):
    total += y*(y-1)//2
print(total)


Measured memory_bytes: 18144
#include <iostream>

using namespace std;

int main()
{
  int r, D, init;
  int x[11];
  cin >> r >> D >> init;
  x[0] = init;

  for (int i=0; i<10; i++){
    x[i+1] = r * x[i] - D;
    cout << x[i+1] << endl;
  }
  return 0;
}


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

public class Main {
	static final int START = 1;
	static final int END = 100;
	static final int MAX_COST = 1_000_000;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		Arrays.setAll(x, i -> sc.nextInt());
		
		int minCost = MAX_COST;
		for (int p = START; p <= END; p++) {
			int cost = 0;
			for (int i = 0; i < n; i++) {
				cost += (int) Math.pow(x[i] - p, 2);
			}
			
			if (cost < minCost) {
				minCost = cost;
			}
		}
		
		System.out.println(minCost);
		
		sc.close();
	}
}






Measured memory_bytes: 30036
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
int n,m,a[N],fa[N],ans;
int getfa(int x)
{
	return fa[x]==x ? x : fa[x]=getfa(fa[x]); 
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	  scanf("%d",&a[i]),fa[i]=i;
	for(int i=1;i<=m;i++){
		int x,y; scanf("%d%d",&x,&y);
		fa[getfa(x)]=getfa(y);
	}
//	for(int i=1;i<=n;i++) getfa(i);
	for(int i=1;i<=n;i++){
		if(getfa(i)==getfa(a[i])) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int N, M, A, B;

//int gcd(int x, int y){
//    if(x < y) swap(x, y);
//    if(y == 0) return x;
//
//    return gcd(x % y, y);
//}

int main(){
    cin >> N >> M;
    vector<pair <ll, ll>> omise(N);

    REP(i, N){
        cin >> A;
        cin >> B;
        omise.at(i) = make_pair(A, B);
    }

    sort(ALL(omise));

    ll temp = 0;
    for(int i = 0 ; i < N ; i++){
        if(omise.at(i).second <= M) {
            temp += omise.at(i).first * omise.at(i).second;
            M -= omise.at(i).second;
        }else if(M != 0){
            temp += omise.at(i).first * M;
            break;
        }
    }

    cout << temp;

//    sort(ALL(A));
//    sort(ALL(B));

//    ll ansCalc = 0;
//    REP(i, N){
//        ll temp = A.at(i) * B.at(i);
//        ansCalc += temp;
//    }




}

Measured memory_bytes: 1792
from bisect import bisect_left

def solve(s,t):
    indices = [list() for _ in range(26)]
    for i,v in enumerate(s):
        indices[v].append(i)

    loop = 0
    cur = 0
    for c in t:
        l = indices[c]

        if not l:
            loop = 0
            cur = -1
            break
        if l[-1] < cur:
            cur = l[0]+1
            loop += 1
        else:
            cur = l[bisect_left(l, cur)]+1
            if cur == len(s):
                loop += 1
                cur = 0
    return loop*len(s)+cur

s,t = input(),input()
s = [ord(v)-ord('a') for v in s]
t = [ord(v)-ord('a') for v in t]
print(solve(s,t))

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int K;
    cin >> K;
    cout << K/2 * ((K+1)/2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b;
    string s;
    cin>>a>>s>>b;
    if(s=="-") cout<<a-b<<endl;
    else cout<<a+b<<endl;
    return 0;
}

Measured memory_bytes: 256
// Sea the world.

#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// SELF TEMPLATE CODE BGEIN

#define SZ(x) ((int)((x).size()))
#define OUT(x) printf(#x" %d\n", x)
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repf(i,a,b) for (int i = (a); i <= (b); ++i)
#define repd(i,a,b) for (int i = (a); i >= (b); --i)
#define repcase int t, Case = 1; for (scanf ("%d", &t); t; --t)

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

int sgn(double x) { return (x > 1e-8) - (x < -1e-8); }
int count_bit(int x) { return x == 0? 0 : count_bit(x >> 1) + (x & 1); }

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

// SELF TEMPLATE CODE END

void solve(const string& s) {
  // Consider 'S' as '(', 'T' as ')',
  // then the problem becomes calculate the number
  // of unmatched brackets.
  int unmatched_brackets = 0;
  int current_left_brackets = 0;
  for (const char& ch : s) {
    if (ch == 'S') {
      ++current_left_brackets;
    } else if (ch == 'T') {
      if (current_left_brackets == 0) {
        ++unmatched_brackets;
      } else {
        --current_left_brackets;
      }
    }
  }
  // The left left brackets are also treated as unmatched.
  cout << unmatched_brackets + current_left_brackets << endl;
}

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

  string s;
  while (cin >> s) {
    solve(s);
  }
  return 0;
}


Measured memory_bytes: 720
# coding: utf-8
import os
import time
import re
import math


N = int(input())
SP=[]
for a in range(N):
    temp=input().split()
    SP.append([temp[0],int(temp[1]),(a+1)])
#SP=list(map(lambda x: x[0], SP))
SP=sorted(SP, key=lambda x:(x[1]), reverse=True)
SP=sorted(SP, key=lambda x: x[0])
for a in range(N):
    print(SP[a][2])

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

int main(){
	string str;
	getline(cin,str);
	rep(i,0,str.size()){
		if('a'<=str[i]&&str[i]<='z'){
			str[i]+='A'-'a';
		}
	}
	cout<<str<<endl;
}

Measured memory_bytes: 1172
#include <stdio.h>
int n, q;
long long s, a, b, c;
long long x[100001];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a);
		x[a]++;
		s += a;
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%lld%lld", &b, &c);
		s += x[b] * (c - b);
		x[c] += x[b];
		x[b] = 0;
		printf("%lld\n", s);
	}
}

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

struct Elem {
    int val;
    int index;
};

int main() {
    int n;
    cin >> n;
    auto a = vector<Elem>(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].val;
        a[i].index = i;
    }
    sort(a.begin(), a.end(), [](auto x, auto y) { return x.val < y.val; });

    auto ans = vector<int>(n);
    for (int i = 0; i < n - 1; i++) {
        ans[a[i].index] = a[n - 1].val;
    }
    ans[a.back().index] = a[n - 2].val;
    for (auto a : ans) {
        cout << a << "\n";
    }

    return 0;
}


Measured memory_bytes: 3968
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
import std.math;

void main(){
 auto z=readln.split.to!(int[]),a=z[0],b=z[1],c=z[2];
 auto k=readln.chomp.to!int;
  if(a>=b&&a>=c)writeln(b+c+a*(2^^k));
  else if(b>=a&&b>=c)writeln(a+c+b*(2^^k));
  else if(c>=a&&c>=b)writeln(a+b+c*(2^^k));
}    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define mod 1000000007
#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin>>x;
    ll sum=100;
    for(int i=1;i<100000;i++)
    {
    	sum=sum+sum/100;
    	if(sum>=x)
    	{
    		cout<<i;
    		return 0;
    		
		}
	}

}

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

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int n,k;
  cin >> n >> k;
  vi c(n),r(n);
  rep(i,n)cin >> c[i] >> r[i];

  vector<vi> g1(n);
  rep(i,k){
    int a,b;
    cin >> a >> b; a--; b--;
    g1[a].push_back(b);
    g1[b].push_back(a);
  }

  vector< vi > g2(n);
  rep(v,n){
    vi d(n,-1);
    d[v] = 0;
    queue<int> q;
    q.push(v);

    while(q.size()){
      int cur = q.front(); q.pop();
      if(d[cur]==r[v])break;
      for(int nxt : g1[cur]){
	if(d[nxt] < 0){
	  d[nxt] = d[cur] + 1;
	  q.push(nxt);
	  g2[v].push_back(nxt);
	}
      }
    }
  }

  vi dis(n,1e9), use(n,0);
  dis[0] = 0;
  for(;;){
    int v = -1;
    rep(i,n){
      if(!use[i] && (v<0 || dis[v] > dis[i]))v = i;
    }
    if(v<0 || v==n-1)break;
    use[v] = 1;

    for(int u : g2[v]){
      dis[u] = min(dis[u], dis[v] + c[v]);
    }
  }
  cout << dis[n-1] << endl;
}

Measured memory_bytes: 68576
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
const k = input[0].split(' ').map(x => +x)[1];
const hs = input[1]
    .split(' ')
    .map(x => +x)
    .sort((a, b) => b - a)
    .slice(k);
console.log(!hs.length ? 0 : hs.reduce((ac, cu) => ac + cu));


Measured memory_bytes: 37328
M,D = map(int, input().split())

ans = 0

for i in range(1,M+1):
    for j in range(D+1):
        d1,d10 = j%10, j//10
        if d1*d10 == i and d1>= 2 and d10 >= 2:
            ans +=1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
const int maxnum = 100000;
int n; //the number of number
int Array[maxnum];
int main()
{
	cin>>n;
	int	y_max;
	int	y_min;
	long y_sum;
	for (int i = 0 ; i < n ; i++)
	{
		cin>>Array[i];
	}
	y_max = Array[0] ;
	y_min = Array[0];
	y_sum = 0;
	for (int y=0;y<n;y++)
	{
		if(y_min < Array[y])
		{
			y_min=y_min;
		}
		else
			y_min = Array[y];
	}
	for (int z=0;z<n;z++)
	{
		if(y_max > Array[z])
		{
			y_max=y_max;
		}
		else
			y_max = Array[z];
	
	}
	for (int m=0;m<n;m++)
	{
		y_sum = y_sum + Array[m];
	}
	cout<<y_min<<' '<<y_max<<' '<<y_sum<<endl;
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
ll w[110],v[110],dp[105][100005];
ll f(ll x,ll y){
	if(y<=-1)return -10000000000;
	if(x==-1)return 0;
	if(dp[x][y]>=0)return dp[x][y];
	dp[x][y]=max(f(x-1,y-w[x])+v[x],f(x-1,y));
	return dp[x][y];
}

int main(){FIN;
	ll N,W; cin>>N>>W;
	fore(i,0,N){
		cin>>w[i]>>v[i];
	}
	memset(dp,-1,sizeof dp);
	cout<<f(N-1,W);
	
	return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    ll x, y;
    cin >> x >> y;

    ll sum = 0;

    if (abs(y) < abs(x)) {
        // 絶対値を小さくしないといけないから
        // x をマイナスにする
        if (x > 0) {
            sum++;
            x = -x;
        }
    } else if (abs(x) < abs(y)) {
        // 絶対値を大きくしないといけないから
        // xをプラスにする
        if (x < 0) {
            sum++;
            x = -x;
        }
    }
    ll add = abs(abs(x) - abs(y));
    x += add;
    sum += add;

    assert(x == y || (-x) == y);
    if (x != y) {
        sum++;
        x = -x;
    }

    assert(x == y);

    cout << sum << endl;

}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) FOR(i, 0, a)

const int MAX = 100005;
const int MOD = 1000000007;

int a[MAX];
vi g[MAX];
set<pii> dists;

int d[MAX];
int p[MAX][20];

priority_queue<pii> pq;
void dfs(int st) {
    pq.push({d[st], st});
    for (int i : g[st]) { d[i] = d[st] + 1; dfs(i); p[i][0] = st; }
}
void init() {
    FOR(j, 1, 20) {
        F0R(i, MAX) { p[i][j] = p[p[i][j-1]][j-1]; }
    }
}
int anc(int v, int n) {
    for (int j=19; j>=0; j--) {
        if ((1<<j)<=n) {
            v = p[v][j]; n -= (1<<j);
        }
    }
    return v;
}

bool v[MAX];
void dfs2(int st) {
    v[st] = true;
    for (int i : g[st]) {
        if (!v[i]) { dfs2(i); }
    }
}


int main() {
    int ans = 0;
    int n, m; scanf("%d %d", &n, &m);
    FOR(i, 1, n+1) {
        scanf("%d", &a[i]);
        if (i != 1) { g[a[i]].pb(i); }
    }
    if (a[1] != 1) { ans++; a[1] = 1; }
    dfs(1); init();
    while (!pq.empty()) {
        pii p = pq.top(); pq.pop();
        if (v[p.s] || p.f <= m) { continue; }
        int mve = anc(p.s, m-1);
        ans++; dfs2(mve);
    }
    cout << ans << endl;
}


Measured memory_bytes: 21620
n, m, c = map(int, input().split())
b_list = list(map(int, input().split()))

n_correct = 0
for i in range(n):
    sum_eq = sum(
        [a * b_list[j] for j, a in enumerate(list(map(int,
                                                      input().split())))])
    if sum_eq + c > 0:
        n_correct += 1
print(n_correct)

Measured memory_bytes: 3060
n,t= map(int,input().split())
a= list(map(int,input().split()))
mp,mprof = 999999999,0
bid = []
bsus = []
sid = []
nc=0
for i in range(n):
    cp = a[i]-mp
    if cp<0:
        nc += min(len(bid),len(sid))
        mp = a[i]
        sid=[]
        bid=[]
        bsus=[i]
    elif cp>0:
        if mprof <= cp:
            bid += bsus
            bsus = []
            if mprof < cp:
                mprof,sid,nc = cp,[i],0
            else:sid.append(i)
    else:bsus.append(i)
else:
    if len(bid)!=0 and len(sid)!=0:
        nc += min(len(bid),len(sid))
print(nc)

Measured memory_bytes: 15060
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
ts=time.time()
sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True

an=0
k=0
s=list(input())
n=len(s)
d=[['R','U','D'],['L','U','D']]
for i in range(n):
    if s[i] in d[k]:
        0
    else:
        an=1
    k=1-k
    
print(YN[an])


Measured memory_bytes: 39404