akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int maxn=1e5+5;
vector <int> a[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i)
    {
        int x,y;
        cin>>x>>y;
        x--;y--;
        a[x].push_back(y);a[y].push_back(x);
    }
    bool used[n];
    int is[n];
    int pr[n];
    for(int i=0;i<n;++i)
    {
        used[i]=false;
        is[i]=1e18;
    }
    used[0]=true;
    is[0]=0;
    pr[0]=(-1);
    deque <int> q;
    q.push_back(0);
    while(!q.empty())
    {
        deque <int> q1;
        while(!q.empty())
        {
            int x=q.front();
            //cout<<x<<" x "<<endl;
            q.pop_front();
            for(int i=0;i<a[x].size();++i)
            {
                int v=a[x][i];
                //cout<<v<<" v "<<endl;
                if(!used[v])
                {
                    pr[v]=x;
                    q1.push_back(v);
                    used[v]=true;
                    is[v]=is[x]+1;
                }
            }
        }
        q=q1;
    }
    for(int i=0;i<n;++i)
    {
        if(is[i]==1e18)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;++i)
    {
        cout<<pr[i]+1<<endl;
    }
    return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  pair<int,int> rui[n+100]={};
  for(int i=0;i<n+10;i++)
    rui[i]=mp(0,0);
  ll ans=0;
  vector<vector<int> >del(n+10);
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    rui[a-1].F++;
    rui[b-1].S++;
    del[a-1].pb(b-1);
  }
  int minus=0;
  int now=0;
  vector<int>po;
  for(int i=0;i<n;i++){

    if(rui[i].S>0){
      // cout<<i<<endl;
      ans++;
      for(int j=0;j<po.size();j++){
	for(int k=0;k<del[po[j]].size();k++){
	  //	  cout<<del[po[j]][k]<<endl;
	  rui[del[po[j]][k]].S--;
	}
      }
      po.clear();
    }
    //now+=rui[i].F;
    if(rui[i].F)po.pb(i);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
 
template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }
 
template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}
 
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}
 
const int maxn = 200010;
bool f[maxn];
 
int main() {
    int N; cin >> N;
    for (int i = 1; i <= N; ++i) {
        int x; cin >> x;
        f[i] = x;
    }
    V<int> ans;
    for (int i = N; i >= 1; --i) {
        for (int j = i * 2; j <= N; j += i) {
            f[i] ^= f[j];
        }
        if (f[i]) ans.pb(i);
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
 
    return 0;
}

Measured memory_bytes: 1912
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    vector<int>a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end(),greater<>());
    cout<<a[0]-a[2]<<endl;

    return 0;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
dic=[]
ans=10**18
ans_check=[0]*M
ans_t=0
for _ in range(N):
    dic.append(list(map(int,input().split())))
for i in range(0,2**N):
    tmp=i
    ans_t=0
    flag=0
    ans_check=[0]*M
    for j in range(N):
        index=tmp%2
        tmp=tmp//2
        if index==1:
            ans_t+=dic[j][0]
            for t in range(1,M+1):
                ans_check[t-1]+=dic[j][t]
    #print(ans_check)
    for d in ans_check:
        if d>=X:
            flag=1
        else:
            flag=0
            break
    if flag==1:
        ans=min(ans,ans_t)
    #print("ans",ans)
if ans==10**18:
    print(-1)
else:
    print(min(ans,ans_t))
        

Measured memory_bytes: 9236
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,s=0,q=0;
	cin>>n;
	//int t=n;
//	q=floor(sqrt(n))*floor(sqrt(n));
	for(int i=1;i<n;i++)
	{
	s+=(n-1)/i;
	}
	cout<<s<<endl;
	//cout<<2*s-q<<endl;
	return 0;
}

Measured memory_bytes: 3624
import sys

read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

import numpy as np

N=int(readline())
#print(N)

U=10**6+100
div=np.arange(1,U,dtype=np.int64)
#print(div)

div=div[N%div==0]
#print(div)

div=div+N//div-2
print(div.min())



Measured memory_bytes: 29012
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n;
    cin >> n;
    int x = 800 * n;
    int y = 200 * (n / 15);
    cout << x - y << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
ABs = readlines.map{|l| l.split.map(&:to_i)}

class PriorityQueue
  def initialize
    @q = [nil]
  end

  def bubble_up(i)
    pi = i / 2
    return if i <= 1 || @q[pi] >= @q[i]
    @q[i], @q[pi] = @q[pi], @q[i]
    bubble_up(pi)
  end

  def add(e)
    @q << e
    bubble_up(@q.size - 1)
  end

  def bubble_down(i)
    ci = i * 2
    return if ci > @q.size - 1
    ci += 1 if ci != @q.size - 1 && @q[ci] < @q[ci + 1]
    return if @q[i] >= @q[ci]
    @q[i], @q[ci] = @q[ci], @q[i]
    bubble_down(ci)
  end

  def pop
    @q[1], @q[-1] = @q[-1], @q[1]
    ret = @q.pop
    bubble_down(1)
    ret
  end
end

pq, ans = PriorityQueue.new, 0
h = ABs.group_by(&:first)
(1 .. M).each do |d|
  h[d].each{|a, b| pq.add(b)} if h[d]
  ans += pq.pop || 0
end
puts ans

Measured memory_bytes: 25212
H, W, K = map(int, input().split())
C = []
for i in range(H):
    C.append(input().rstrip())
ans = 0
for h in range(2**H):
    for w in range(2**W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (h>>i)&1 != 1 and (w>>j)&1 != 1 and C[i][j] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

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

int main(){
    int a,b,c,d,p;
    int x,y;
    
    cin >> a >> b >> c >> d >> p;
    
    x = a*p;
    if(p>c){
        y = b + (p-c)*d;
    }else{
        y = b;
    }
    
    if(y>x){
        cout << x << endl;
    }else{
        cout << y << endl;
    }
}

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

int main() {
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  int i;
  for (i=0; i<n; i++) {
    bool flag=true;
    for (int j=i; j<n; j++) {
      if (s[j]!=t[j-i]) {
	flag=false;
	break;
      }
    }
    if (flag) break;
  }
  
  cout<<n+i<<endl;
  return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
 
count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        count += 1
print(count)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int i5=0;
int i7=0;
int data[3];

int main()
{
    for (int i = 0; i < 3; i++) {
      scanf("%d", data + i);
    }
    for (int i = 0; i < 3; i++) {
      if (data[i]==5) i5+=1;
      if (data[i]==7) i7+=1;
    }
    if (i5 == 2 && i7 == 1) {
      puts("YES");
      return 0;
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a);
  Cin(string, s);

  puts(a >= 3200 ? s.c_str() : "red");

  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var n,m,a,b,x int
	fmt.Scan(&n,&m)
	ans := make([]bool, n+1)
	h := make([]int,n+1)
	for i:=1 ; i<=n; i++ {
		fmt.Scan(&h[i])
		ans[i] = true
	}
	for i:=0 ; i<m ; i++ {
		fmt.Scan(&a,&b)
		if h[a] <= h[b] {
			ans[a] = false
		}
		if h[a] >= h[b] {
			ans[b] = false
		}
	}
	for i:=1 ; i<=n ; i++ {
		if ans[i] {
			x++
		}
	}
	fmt.Println(x)
}


Measured memory_bytes: 6392
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int mark[100001],A[100001];
int main()
{
	int n,i,x,c=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>A[i];
	x=1;
	c=0;
	mark[1]=1;
	while(x!=2)
	{
		c++;
		x=A[x];
		if(mark[x])
		break;
		mark[x]=1;
	}
	if(x==2)
		cout<<c;
	else
		cout<<"-1";
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC70(void);
void ABC71(void);
void ABC72(void);
void ABC73(void);
void ABC74(void);
void ABC75(void);
void ABC76(void);
void ABC77(void);
void ABC78(void);
void ABC79(void);

int main(void){
    ABC74();
}

void ABC74(){
    int n,k,i,max,sum=0,x;
    cin>>n>>k;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>x;
        if(x<k-x)sum+=x;
        else sum+=k-x;
    }
    cout<<2*sum<<endl;
}


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

using namespace std;
int N;

void solve() {
    int a, b = 0;
    a = N / 4;
    b = N / 7;
    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            if (4 * i + 7 * j == N) {
                printf("Yes\n");
                return;
            }
        }
    }
    printf("No\n");
}

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


Measured memory_bytes: 256
a,b,m=map(int,input().split())
a_list=list(map(int,input().split()))
b_list=list(map(int,input().split()))

min_num=min(a_list)+min(b_list)
for i in range(m):
  x,y,c=map(int,input().split())
  num = a_list[x-1] + b_list[y-1] -c
  min_num=min(min_num,num)
  
print(min_num)

Measured memory_bytes: 24836
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 2e5;

int n;

int fa[MAXN + 5];
vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i)
	{
		fa[i] = read<int>();
		adj[fa[i]].push_back(i);
	}
}

int cir[MAXN + 5], len = 0, is_cir[MAXN + 5];

inline void find_cir()
{
	static int vis[MAXN + 5];

	int p = 1;
	for(; !vis[p]; p = fa[p]) vis[p] = 1;
	for(; vis[p] != 2; p = fa[p]) is_cir[p] = 1, vis[cir[++len] = p] = 2;
}

int a[MAXN + 5], a0[MAXN + 5];

inline void dfs(int u)
{
	for(auto v : adj[u]) if(!is_cir[v]) dfs(v);

	static int bkt[MAXN + 5];

	for(auto v : adj[u]) if(!is_cir[v]) ++bkt[a[v]];
	for(int i = 0; i <= n; ++i) if(bkt[i] == 0) { a[u] = i; break; }
	for(int i = a[u] + 1; i <= n; ++i) if(bkt[i] == 0) { a0[u] = i; break; }
	for(auto v : adj[u]) if(!is_cir[v]) --bkt[a[v]];
}

inline void solve()
{
	find_cir();

	for(int i = 1; i <= len; ++i) dfs(cir[i]);

	static int b[MAXN + 5];

	b[1] = a[cir[1]];
	for(int i = 2; i <= len; ++i) b[i] = b[i - 1] == a[cir[i]] ? a0[cir[i]] : a[cir[i]];

	int fg = 1;
	for(int i = 1; i <= len; ++i) if(b[i % len + 1] == b[i]) { fg = 0; break; }
	if(fg) { puts("POSSIBLE"); return; }

	b[1] = a0[cir[1]];
	for(int i = 2; i <= len; ++i) b[i] = b[i - 1] == a[cir[i]] ? a0[cir[i]] : a[cir[i]];

	fg = b[len] == a[cir[1]];
	if(fg) for(int i = 1; i <= len; ++i) if(b[i % len + 1] == b[i]) { fg = 0; break; }
	if(fg) { puts("POSSIBLE"); return; }

	puts("IMPOSSIBLE");
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 16384
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        for (int i = A; i <= B; i++) {
            if (i < A + K || B - K < i) {
                System.out.println(i);
            }
        }

    }
}

Measured memory_bytes: 23764
n = int(input())
a = input().split()

point = 0

if n == 2:
  point = int(a[0])*2
else:
  for i in range(n):
    if i == 0:
      point += int(a[0])
    elif i == (n-1):
      point += int(a[i-1])
    else:
      point += min(int(a[i-1]),int(a[i]))
print(point)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n;scanf("%d",&n);
    char s[200000];scanf("%s",s);

    int ans=0;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }

    printf("%d\n",ans+1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  ll a,b,ans=0;
  cin >> n >> a >> b;
  vector<ll> x(n);
  rep(i,n) cin >> x[i];

  for(int i=0; i<n-1; i++){
    ans+=min((x[i+1]-x[i])*a,b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n),b(n);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  ll ans = 0;
  for(int i=n-1; i>=0; i--){
    ans += ((a[i]+ans+b[i]-1)/b[i])*b[i]-(a[i]+ans);
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;
std::map<ll, ll> mp;
ll ans;

int main()
{
  std::cin >> N;
  rep( i, N )
  {
    ll a;
    std::cin >> a;

    ++mp[a];
  }

  for( auto it = mp.begin(); it != mp.end(); ++it )
  {
    if( it->second >= it->first )
      ans += it->second-it->first;
    else
      ans += it->second;
  }

  std::cout << ans << std::endl;

  return 0;
}

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

using namespace std;

const int P = 10010;
int cnt[P];

signed main() {
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<int64_t> ss(n);
    for (int i = 0; i < n; ++i) {
        ss[i] = s[i] - '0';
    }
    if (p == 2 || p == 5) {
        int64_t ans = 0;
        for (int i = 0; i < n; ++i) {
            if (ss[i] % p == 0) {
                ans += n - i;
            }
        }
        cout << ans << endl;
        return 0;
    }
    cnt[0] = 1;
    int64_t ans = 0;
    int64_t pow = 1;
    int64_t curr = 0;
    for (int i = 0; i < n; ++i) {
        curr = (curr + ((s[i] - '0') * pow) % p) % p;
        pow = pow * 10 % p;
        ans += cnt[curr];
        ++cnt[curr];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) (lower_bound(all(s),x)-s.begin())

int n;
vector<int> cnt;

void count_primes() {
    vector<int> rem(n+1);
    cnt.resize(n+1);
    rep1(i,n) rem[i] = i;
    rep1(i,n){
        if(rem[i] == 1) continue;
        for(int j = i; j <= n; j += i){
            while(rem[j] % i == 0){
                rem[j] /= i;
                cnt[i]++;
            }
        }
    }
}

int num(int x){
    return n - lb(cnt,x) + 1;
}

int calc(vector<int> v){
    sort(all(v), greater<int>());
    int res = 1;
    rep(i, v.size()){
        res *= max(num(v[i]-1)-i, 0);
    }
    return res;
}


int main(void){
    cin >> n;
    count_primes();
    sort(all(cnt));
    cout << calc({3,5,5})/2 + calc({3,25}) + calc({5,15}) + calc({75}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
   
    int n,m,p;
    while(cin>>n>>m>>p){
        if(n==0 && m==0 && p==0)break;
       
        int sum=0;
        int num[200]={};
        rep(i,n){
            cin>>num[i];
            sum+=num[i];
        }
        int money;
       
       
        if(num[m-1]!=0){
            money=sum*(100-p)/num[m-1];
            cout<<money<<endl;
        }
        else
            cout<<"0"<<endl;
       
    }
   
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    ll a, b, n; cin >> a >> b >> n;
    ll x = min(b - 1, n);
    cout << a * x / b - a * (x / b) << endl;
}

Measured memory_bytes: 3640
a = [input().split() for a in range(3)]
n = int(input())
b = [input() for i in range(n)]
c = [a[0][0],a[1][1],a[2][2]]
d = [a[0][2],a[1][1],a[2][0]]
tate1 = len(set(a[0]) & set(b))
tate2 = len(set(a[1]) & set(b))
tate3 = len(set(a[2]) & set(b))
yoko1 = len(set([x[0] for x in a]) & set(b))
yoko2 = len(set([x[1] for x in a]) & set(b))
yoko3 = len(set([x[2] for x in a]) & set(b))
naname1 = len(set(c) & set(b))
naname2 = len(set(d) & set(b))
bingo = [tate1,tate2,tate3,yoko1,yoko2,yoko3,naname1,naname2]
if 3 in bingo:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int S; cin >> S;
	int x1 = 1000000000;
	int y2 = S / x1;
	int x2, y1;
	x2 = 1;
	if (S % x1 != 0) {
		y2++;
		y1 = x1 - S % x1;
	}
	else {
		y1 = 0;
	}
	cout << x1 << " " << y1 << " " << x2 << " " << y2 << " 0 0" << endl;
	dump(abs(x1*y2 - x2 * y1));
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  cout << s.at(0) << s.at(1) << s.at(2) << s.at(3) << s.at(4) << " " 
       << s.at(6) << s.at(7) << s.at(8) << s.at(9) << s.at(10) << s.at(11) << s.at(12)
       << " " << s.at(14) << s.at(15) << s.at(16) << s.at(17) << s.at(18) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=min(a,k);
    k-=ans;
    if(k>0)
    {
        k-=b;
    }
    if(k<=0)
        return cout<<ans,0;
    cout<<ans-min(c,k);
    return 0;
}


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

pair<int, int> pd[10000];

int main(){
	
	int n=0,m=0,i,j,tmp,secure=0, ans=0;
	int d[10000];
	int p[10000];
	int idx[10000];
	while(1){
		memset(d,0,sizeof(d));
		memset(p,0,sizeof(d));
		
		cin >> n >> m;
		
		if(n == 0 && m == 0){
			break;
		}
		
		for(i=0;i<n;i++){
			cin >> d[i] >> p[i];
			pd[i] = make_pair(p[i],d[i]);
		}
		
		for(i=0;i<n;i++){
			idx[i] = i;
		}
		
		
		//sort
		sort(pd, pd+n);
		reverse(pd, pd+n);

		
		secure = 0;
		
//		while(m > 0){
//			cout << secure << " (^^) " << idx[secure]  << endl;
//			m--;
//			d[secure]--;
//			if(d[secure] == 0){secure--;}		
//		}
		
		for(i=0;i<n;i++){
			if(m >= pd[i].second){
				m -= pd[i].second;
				pd[i].first = 0;
			}else{
				pd[i].second -= m;
				break;
			}
		}
		
		ans = 0;
		
		for(i=0;i<n;i++){
//			cout << d[i] << " " << p[i] << endl;
			ans += pd[i].first * pd[i].second;
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <set>
#define MAXX 111
#define ll long long
using namespace std;

// 01, 32
// 00, 22

ll Solve(ll A, ll B, ll C, int K) {
    if (K==0)
        return A+B+C;
    return max(Solve(2*A,B,C,K-1),
               max(Solve(A,2*B,C,K-1),Solve(A,B,2*C,K-1)));
}


int main() {
    int A,B,C;
    cin>>A>>B>>C;
    int K;
    cin>>K;
    cout << Solve(A,B,C,K) << endl;
}


Measured memory_bytes: 256
open Batteries
open Tuple
module EnumL = Enum.Labels
module ListL = List.Labels

let dbg x = Printf.eprintf "[debug]%s\n" @@ dump x

let (++) n m = List.range n `To m
let (++^) n m = List.range n `To (pred m)

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then Enum.empty ()
  else
    List.map (fun _ -> scan fmt f) (List.range 1 `To n)
    |> List.enum

let scan_list cnv =
  String.split_on_char ' ' @@ read_line ()
  |> List.map cnv

let scan_array = Array.of_list % scan_list

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (List.range 0 `To (pred n))
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let (n,k) = scan "%d %d" Tuple2.make
let m = scan_array Int.of_string

let () =
  let sets = powerset (0 --^ n) in
  EnumL.map sets ~f:(fun set ->
      if Enum.count @@ Enum.clone set = k then
        Array.fold_lefti
          (fun (h, acc) i a ->
             if Enum.exists ((=) i) (Enum.clone set) then
               if a > h then (a, acc)
               else (h+1, acc + h+1 -a)
             else
               (max h a, acc)) (0,0) m
        |> Tuple2.second
      else
        Int.max_num)
  |> Enum.reduce min
  |> Printf.printf "%d\n"


Measured memory_bytes: 23296
import java.util.*;
import static java.lang.System.*;

public class Main {
	static List<Character> alp = new ArrayList<>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		for(char c = 'a'; c <= 'z'; c++) 
			alp.add(c);
		
		char[] newS = func(S);
		char[] newT = func(T);
		boolean flag = true;
		for(int i = 0; i < newS.length; i++) {
			if (newS[i] != newT[i]) {
				flag = false;
				break;
			}
		}
		if (flag) out.print("Yes");
		else out.println("No");
		
	}
	static char[] func(char[] str) {
		List<Character> seen = new ArrayList<>();
		int num = 0;
		char[] newStr = new char[str.length];
		for(int i = 0; i < str.length; i++) {
			char ch = str[i];
			int res = seen.indexOf(ch);
			if ( res == -1) {
				seen.add(ch);
				newStr[i] = alp.get(num);
				num++;
			} else {
				newStr[i] = alp.get(res);
			}
		}
		return newStr;
	}
}



Measured memory_bytes: 30140
#include <stdio.h>
#include <stdlib.h>
int min(int a, int b) {
    if(a < b) {
        return a;
    }
    else {
        return b;
    }
}

int main(void) {
    int N;
    scanf("%d", &N);
    int *B = (int*)malloc((N-1) * sizeof(int));
    int i;
    for(i=0; i<N-1; i++) {
        scanf("%d", &B[i]);
    }
    int *A = (int*)malloc(N * sizeof(int));
    int sum = 0;
    A[0] = B[0];
    for(i=1; i<N-1; i++) {
        A[i] = min(B[i-1], B[i]);
    }
    A[N-1] = B[N-2];
    for(i=0; i<N; i++) {
        sum += A[i];
    }
    printf("%d\n", sum);
    return 0;
}

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

int main(){
	ll n;
	cin >> n;
	ll h[n];
	for(ll i=0;i<n;i++)
		cin >> h[i];

	ll dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(ll i=2;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[i] << " ";
	}	
	//cout << endl;
	cout << dp[n-1];
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    rep(i, N + 1) {
        if (i * 108 / 100 == N) {
            cout << i << '\n';
            return;
        }
    }
    cout << ":(" << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(n):
    a = s[:i]
    b = s[i:]
    c = []
    count = 0
    for j in a:
        if j in b and j not in c:
            count += 1
            c.append(j)
            ans = max(ans,count)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{   int a,b,s ;
    cin>>a>>b;
    s=a+b;
    if(s%3==0||a%3==0||b%3==0)
        cout<<"Possible";
    else
        cout<<"Impossible";
	return 0;
}

Measured memory_bytes: 3636
from collections import defaultdict
from collections import OrderedDict

N = int(input())

words = dict()
wordsFromValue = defaultdict(list)

for idx in range(N) :
  word = str(input())
  
  if word in words :
    words[word] += 1
  else :
    words[word] = 1
  
for key, value in sorted(words.items()) :
  wordsFromValue[value].append(key)
  
for val in wordsFromValue[max(wordsFromValue)] : 
  print(val)

Measured memory_bytes: 45268
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    cnt = collections.Counter(a)
    for i in range(1, n+1):
        print(cnt[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 35612
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    
    int A=sc.nextInt();
    int B=sc.nextInt();
    
    if(1<=A&&A<=9&&1<=B&&B<=9){
System.out.println(A*B);
    }else{
      System.out.println(-1);
    }
  }
}


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

const int N = 1e5 + 10;

int n, k;  
int a[N];

inline int solve(int a, int b) {
  if (a % b == 0) {
    return a / b;
  } else {
    return a / b + 1;   
  }
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);      
  }      
  printf("%d\n", 1 + solve(n - k, k - 1));
  return 0;     
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
    
int main() {
  int N;
  cin >> N;
  vector<int> Brick(N);
  for (int i=0; i<N; i++) {
    cin >> Brick.at(i);
  }
  
  int count = 1;
  int ans = 0;
  for (int i=0; i<N; i++) {
    if (count == Brick.at(i)) {
      count++;
    }
    else {
      ans++;
    }
  }
  
  if (ans == N) {
    ans = -1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出,オーバーフローする入力を投げるとよい
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
bool comp(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
        // return a.first < b.first; // 昇順
        return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}


int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,stra="CODEFESTIVAL2016";
    ll k;
    ll w,x,y;
    ll h;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    map<ll,ll> m1;
    map<ll,ll> m2;
    set<ll> s1;
    set<ll> s2;
    rep(i,n){
        if(i%2) {
            s1.insert(v[i]);
            m1[v[i]]++;
        }else{
            s2.insert(v[i]);
            m2[v[i]]++;
        }
    }
    vector<pair<ll,ll>> p1(s1.size()+1);
    vector<pair<ll,ll>> p2(s2.size()+1);
    p1[s1.size()]=make_pair(0,-1);
    p2[s2.size()]=make_pair(0,-2);
    ll i=0;
    for(auto itr=s1.begin();itr!=s1.end();itr++,i++){
        p1[i]=make_pair(m1[*itr],*itr);
    }
    i=0;
    for(auto itr=s2.begin();itr!=s2.end();itr++,i++){
        p2[i]=make_pair(m2[*itr],*itr);
    }
    sort(all(p1),comp);
    sort(all(p2),comp);
    if(p1[0].second==p2[0].second){
        cout<<n-max(p1[1].first+p2[0].first,p1[0].first+p2[1].first)<<endl;
    }else{
        cout<<n-(p1[0].first+p2[0].first)<<endl;
    }


    
    return 0;
}


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

using namespace std;

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

	string s;
	int res=1000000000;

	cin >> s;

	for(int i=0;i<=s.length()-3;i++)
	{
		int num = 0;
		for(int j=0;j<3;j++)
		{
			num = num*10 + (s[i+j]-'0');
		}
		res = min(res,abs(753-num));
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;
using ll = int64_t;
using vecint = vector<ll>;

int main()
{
  int p;
  cin>>p;
  vecint pf(p+1);
  pf[0] = 1;
  REP(i,p) {
    vecint tmp(p+1);
    REP(j,p+1) {
      tmp[j] = pf[j] * (p-i);
      if (j) tmp[j] += pf[j-1];
      tmp[j] %= p;
    }
    swap(pf, tmp);
  }
  vecint poly(p);
  REP(i,p) {
    int a;
    cin>>a;
    if (a == 0) continue;
    vecint tmp(p);
    vecint r = pf;
    for (int j=p-1; j>=0; --j) {
      tmp[j] = r[j+1];
      r[j] += r[j+1] * (p+i);
      r[j] %= p;
    }
    ll val = 0;
    ll mul = 1;
    REP(j,p) {
      val += tmp[j] * mul;
      val %= p;
      mul *= i;
      mul %= p;
    }
    ll inv = 0;
    REP(j,p) {
      if ((j*val)%p == 1) inv = j;
    }
    REP(j,p) {
      poly[j] += inv*tmp[j];
      poly[j] %= p;
    }
  }
  REP(i,p) {
    if(i)cout<<' ';
    cout<<poly[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 512
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    int s,w;
    cin>>s>>w;
    w>=s?cout<<"unsafe\n" : cout<<"safe\n";
    return 0;
}



Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(){
    int n,a,b; cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int sum = 0;
        int cnt = i;
        while (cnt) {
            if (cnt < 10) { sum += cnt; cnt /= 10; }
            else { sum += cnt % 10; cnt /= 10; }
        }
        if (a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
}

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

int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(s == u) {
    a--;
  }
  else{
    b--;
  }
  
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;
using Q = pair<P,ll>;

/*
SegmentTree st(vector<ll> a,ll b);
で初期化．uは単位元(例:区間最小→INF，区間和→0，最大公約数→0)
mergeの中身を適宜書き換える
*/

class SegmentTree{
public:
    ll N, unit; 
    vector<ll> data, tree;
    SegmentTree(vector<ll> v, ll u){
        unit = u;
        data = v;
        ll n = data.size();
        N = 1;
        while(N<n)N*=2;
        tree = vector<ll>(N*2,u);
        build();
    }
    void build(){rep(i,N)update(i,data[i]);}
    void update(ll i, ll x){
        i += N-1;
        //tree[i]+=x;
        tree[i]=x;
        while(i){
            i = (i-1)/2;
            tree[i]=merge(tree[i*2+1],tree[i*2+2]);
        }
    }
    ll query(ll start, ll end){return query(start, end, 0, 0, N);}
private:
    ll query(ll a, ll b, ll k, ll l, ll r){
        if(r<=a||b<=l)return unit;
        if(a<=l&&r<=b)return tree[k];
        else{
            ll lv = query(a,b,2*k+1,l,(l+r)/2);
            ll rb = query(a,b,2*k+2,(l+r)/2,r);
            return merge(lv,rb);
        }
    }
    ll merge(ll l, ll r){
        return min(l,r);
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    vector<Q> lrc(m);
    rep(i,m){
        ll l,r,c;cin>>l>>r>>c;
        lrc[i]={{r-1,l-1},c};
    }
    sort(lrc.begin(),lrc.end());
    ll idx = 0;
    vector<ll> dp(n,INF);dp[0]=0;
    bool flag = true;
    SegmentTree st(vector<ll>(n,INF), INF);
    st.update(0,0);

    //cout<<"min"<<st.query(0,n)<<endl;

    for(ll pos = 0; pos<n; pos++){
        ll mini = INF;
        
        if(lrc[idx].first.first!=pos)continue;
        while(lrc[idx].first.first==pos){
            //cout<<pos<<" "<<idx<<endl;
            mini = min(mini,st.query(lrc[idx].first.second,lrc[idx].first.first+1)+lrc[idx].second);
            //cout<<mini<<endl;
            idx++;
        }
        dp[pos]=mini;
        st.update(pos,mini);
    }
    if(dp[n-1]>INF/2)cout<<-1<<endl;
    else cout<<dp[n-1]<<endl;
    //rep(i,n)cout<<dp[i]<<" ";
    //cout<<idx;
    return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    int building,floor,room,v;
    int a[][][] = new int[4][3][10];

    for(int x = 0; x < 4; x++){
      for(int y = 0; y < 3; y++){
        for(int z = 0; z < 10; z++){
          a[x][y][z] = 0;
        }
      }
    }

    for(int x = 0; x < number; x++){
      building = sc.nextInt();
      floor = sc.nextInt();
      room = sc.nextInt();
      v = sc.nextInt();
      a[building-1][floor-1][room-1] = a[building-1][floor-1][room-1]+v;
    }

    for(int x = 0; x < 4; x++){
      for(int y = 0; y < 3; y++){
        for(int z = 0; z < 10; z++){
          System.out.print(" "+a[x][y][z]);
        }
        System.out.println("");
      }
      if(x < 3){
        System.out.println("####################");
      }
    }
  }
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define loop(i, n) for(int i = 0;i < n;i++)
#define INF 1000000000

int n, m, x;

int ans = INF;


void dfs(int i, vector<int> c, vector<vector<int>> a, int total, vector<int> check){
    bool ok = true;
    loop(j, m){
        if(check[j] < x) ok = false;
    }
    if(ok) ans = min(ans, total);

    if(i == n) return;

    dfs(i+1, c, a, total, check);

    loop(j, m){
        check[j] += a[i][j];
    }
    total += c[i];
    dfs(i+1, c, a, total, check);

    
}

int main(void){

    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> check(m);
    loop(i, n){
        cin >> c[i];
        loop(j, m){
            cin >> a[i][j];
        }
    }

    dfs(0, c, a, 0, check);

    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define pi 3.141592653589793238462
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll n;
 cin>>n;
 ll p=100;
 for(ll i=1;i<=100000;i++)
 {
  p=p+p/100;

  if(p>=n)
  {
   cout<<i<<"\n";
   break;
  }

 }
 return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a;
string s;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> s;
	if(a >= 3200) cout << s << "\n";
	else cout << "red\n";
	return 0;
}

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

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

	string s, t;
	cin >> s >> t;

	sort( s.begin(), s.end() );
	sort( t.begin(), t.end(), greater<>() );

	cout << (s < t ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
a=input().split()
N=int(a[0])
W=int(a[1])
wv_list=[]
for i in range(N) :
  b=input().split()
  w=int(b[0])
  v=int(b[1])

  wv_list.append([w,v])

n_list=  [[0 for i in range(W+1)] for j in range(N)]


if wv_list[0][0]<=W :
    n_list[0][wv_list[0][0]]=wv_list[0][1]

for i in range(1,N) :
    for j in range(W) :
        s=j+wv_list[i][0]
        if s<=W :
            n_list[i][s]=max(n_list[i-1][j]+wv_list[i][1],n_list[i][s])

        n_list[i][j] = max(n_list[i - 1][j],n_list[i][j])

print(max(n_list[-1]))


Measured memory_bytes: 171528
#include <iostream>

using namespace std;

#include<string.h>

int main()
{
    string c;
    int l;
    cin>>c;
    l=c.length();
    int y=0;
    int x=0;
    for(int i=0;i<l;i++)
    {
        if(y==0)
        {
            if(c[i]=='R'||c[i]=='U'||c[i]=='D')
            {
                x++;
                y++;
                continue;
            }
        }
        else if(y==1)
        {
            if(c[i]=='L'||c[i]=='U'||c[i]=='D')
            {
                x++;
                y--;
            }
        }
    }
    if(x==l)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int a[100000];
int main()
{
	int n;
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	cout<<ans-n;
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

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

	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;

	ll ans = min({q*4, h*2, s});
	if(n == 1){
		cout << ans << endl;
		return 0;
	}

	while(n >= 2){
		ans += min({q*8, h*4, s*2, d});
		n -= 2;
	}

	if(n != 1) ans -= min({q*4, h*2, s});
	
	cout << ans << endl;

	return 0;
}


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

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long ll;

int N;

ll W;
ll weights[110], vs[110];
ll dp[110][100100] = {0};
ll inf = 1LL << 60;
int main() {
  cin >> N >> W;
  for (int i = 0; i < N; ++i) {
    cin >> weights[i] >> vs[i];
  }

  for (int i = 0; i < 110; ++i) {
    for (int y = 0; y < 100100; ++y) {
      dp[i][y] = inf;
    }
  }

  dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int v = 0; v < 100100; ++v) {
      if(v - vs[i] >= 0) {
	dp[i + 1][v] = min(dp[i + 1][v], dp[i][v - vs[i]] + weights[i]);
      }
      dp[i + 1][v] = min(dp[i + 1][v], dp[i][v]);
    }
  }

  ll ans = 0;
  for (int v = 0; v < 100100; ++v) {
    if (dp[N][v] <= W) {
      ans = v;
    }
  }

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


Measured memory_bytes: 86272