akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int a,b,c,x;
    int count = 0;
    cin >> a >> b >> c >> x;
    
    for(int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                int  total = 500*i + 100*j + 50*k;
                if(total  == x) count++;
            }
        }
    } 
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,raw_input().split())
S=raw_input()
T=raw_input()

def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
            

X=N*M/gcd(N,M)
double=[[(X/M)*i,(X/N)*i] for i in range(N*M/X)]
print X if all(S[d[0]]==T[d[1]] for d in double) else "-1"

Measured memory_bytes: 7044
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,v,e,s,t;
  queue<int> que;
  vector<int> indgree(10010);
  vector<vector<int> > g(10010);
  vector<int> to;
  scanf("%d %d\n",&v,&e);
  for(i=0;i<e;i++){
    scanf("%d %d\n",&s,&t);
    g[s].push_back(t);
    indgree[t]++;
  }
  for(i=0;i<v;i++){
    if(indgree[i]==0){
      que.push(i);
    }
  }
  while(!que.empty()){
    int x=que.front();
    que.pop();
    for(i=0;i<g[x].size();i++){
      int us=g[x][i];
      indgree[us]--;
      if(indgree[us]==0){
        que.push(us);
      }
    }
    to.push_back(x);
  }
  for(i=0;i<to.size();i++){
    printf("%d\n",to[i]);
  }
  return 0;
}


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

int g[15][15];

int main(){
    int n; cin >> n;
    rep(i,n)rep(j,n) g[i][j] = -1;
    rep(i,n){
        int m; cin >> m;
        rep(j,m){
            int x, y;
            cin >> x >> y;
            --x;
            g[i][x] = y;
        }
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n) if(i>>j&1){//j番目のbitが立ってる
            d[j] = 1;
        }
        bool ok = true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(g[j][k] == -1) continue;//言及なし
                    if(g[j][k] != d[k]) ok = false;//矛盾
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long sum = 0;
	long long maxn = 0;
	for(int i=0;i<n;i++){
		long long j;
		cin>>j;
		sum+=j;
		maxn = max(maxn,j);
	}
	sum-=maxn/2;
	cout<<sum<<endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cerr<<v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll res = 0;
    if(K<=A){
        res = K;
    }else if(K<=A+B){
        res = A;
    }else{
        res = A - (K-(A+B));
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int MAX = 2e5+4;
const ll INF = 1e18;
vector<ll> dp(MAX,INF);
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,w;
	cin >> n >> w;
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin >> a >> b;
		for(int j=100000;j>=b;j--)
		{
			dp[j]=min(dp[j],dp[j-b]+a);
		}
	}
	int ans=0;
	for(int i=0;i<=100000;i++)
	{
		if(dp[i]<=w)
		ans=max(ans,i);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
using namespace std;
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main() {
	int elaps = 0, c;
	int q;
	P u;
	cin >> n >> q;

	for (int i = 1; i <= n; ++i) {
		cin >> Q[i].name >> Q[i].t;
	}
	head = 1;
	tail = n + 1;

	while (head != tail) {
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t > 0) enqueue(u);
		else {
			cout << u.name << " " << elaps << endl;
		}
	}
}


Measured memory_bytes: 13160
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef MY_PROJECT
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    ll n,x,y;
    cin>>n>>x>>y;
    int arr[n]{0};
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int dist=j-i;
            int dist1=abs(j-y)+abs(x-i)+1;
            int dist2=abs(i-y)+abs(x-j)+1;
            int mini=min(dist,min(dist1,dist2));
            arr[mini]++;
        }
    }
    for(int i=1;i<n;i++)
    {
     cout<<arr[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int w = sc.nextInt();
			
			if(w == -1){
				break;
			}
			
			int sum = 1150;
			sum += w > 10 ? (10 - (20 - Math.min(20, w))) * 125 : 0;
			sum += w > 20 ? (10 - (30 - Math.min(30, w))) * 140 : 0;
			sum += w > 30 ? (w - 30) * 160 : 0;
			
			System.out.println(4280 - sum);
		}

	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin>>S;
  cin>>T;
  string k=T.substr(0,S.size());
  if(k==S){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> //works like magic, but at cost.
using namespace std;
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout<<x<<endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define fk(i, k, n) for(int i=k; i<n; i++)
#define fn(i, n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<lli, lli>	pl;
typedef vector<int>		vi;
typedef vector<lli>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

int main() {
    // 1. C++ Productivity Tips
    // 2. To be used while Coding Interview Prep
    // 3. Solving Problems can take time
    // 4. Writing for loops, reading multiple variables is boring.
    // 5. Debugging Tools are not present in Coding Interviews.
    int n,k,p,price=0;
    cin>>n>>k;
    vector<int> v;
    fo(i, n){
       cin>>p;
       v.pb(p);
    }sort(v.begin(), v.end());
    
    for(int i=0; i<k;i++){
        price += v[i];
    }cout<<price<<"\n";

    
    return 0;
}

Measured memory_bytes: 3140
#include <cstdio>
#include <iostream>
#include <vector>
#define pb push_back
using namespace std;

int primes(int n) {
  int cnt=0;
  vector<bool> pri(n+1,false);
  for(int i=2;i<=n;i++) {
    if(pri[i]==false) {
      cnt++; pri[i]=true;
      for(int j=i*2;j<=n;j+=i) {
	pri[j]=true;
      }
    }
  }
  return cnt;
}


main() {
  int n;
  while(cin>>n) {
    cout << primes(n) << endl;
  }
}

Measured memory_bytes: 1024
#import math
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if N == 1:
  print(0)
  exit()
lst = factorization(N)
res = 0
for i in range(len(lst)):
  a = lst[i][1]
  for k in range(1, 10** 5):
    if a >= k:
      a -= k
      res += 1
    else:
      break
print(res)



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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string T; cin >> T;
    rep(i, T.length()) if(T[i] == '?') T[i] = 'D';
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 3776
dic = {}
for b in range(1,5):
    for f in range(1,4):
        for r in range(1,11):
            dic[(b,f,r)] = 0

n = int(raw_input())
for k in range(n):
    b,f,r,v = map(int,raw_input().split())
    dic[(b,f,r)] += v

j = 0
for b in range(1,5):
    for f in range(1,4):
        ls = []
        for r in range(1,11):
            ls.append(dic[(b,f,r)])
        print ' ' + ' '.join(map(str,ls))
        
    else:
        if j < 3:
            print '#'*20
        j +=1

Measured memory_bytes: 4256
#include<stdio.h>
#include<stdlib.h>

struct player{
    int n,p;
}pl[40];

int cmp(const struct player *a,const struct player *b){
    if(a->p==b->p)return a->n-b->n;
    else return b->p-a->p;
}

int main(){
    int i,j,k,t,score,cnt;
    int m,pin[21];
    char c;

    while(scanf("%d",&m),m){
        for(i=0;i<21;i++)pin[i]=0;
        for(i=0;i<m;i++){
            scanf("%d",&pl[i].n);
            for(j=0;;j++){
                scanf("%d%c",&pin[j],&c);
                if(c=='\n')break;
            }
            t=j;

            for(cnt=0,score=0,j=0;j<=t;j++){
                if(cnt<9){
                    if(pin[j]<10){
                        j++;
                        score+=pin[j-1];
                        score+=pin[j];
                        if(pin[j-1]+pin[j]==10){
                            score+=pin[j+1];
                        }
                    }else{
                        score+=pin[j];
                        score+=pin[j+1];
                        score+=pin[j+2];
                    }
                    cnt++;
                }else{
                    score+=pin[j];
                }
            }
            pl[i].p=score;
        }
        qsort(pl,m,sizeof(struct player),cmp);

        for(i=0;i<m;i++){
            printf("%d %d\n",pl[i].n,pl[i].p);
        }
    }
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

void problemA()
{
    int N;
    vector<int> A, B;

    cin >> N;
    A.reserve(N);
    B.resize(N);

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

    vector<int> inverseOrderOps;

    while (!B.empty()) {
        int maxV = -1, maxIdx = -1;
        for (int bi = int(B.size()) - 1; bi >= 0; bi--) {
            // Is this valid operation?
            if (bi + 1 != B[bi]) continue;

            // Find max value from B
            if (maxV < B[bi]) {
                maxV = B[bi];
                maxIdx = bi;
            }
        }

        if (maxV < 0) {
            cout << "-1" << endl;
            return;
        }

        inverseOrderOps.push_back(maxIdx+1);
        B.erase(B.begin() + maxIdx);
    }

    for (int i = int(inverseOrderOps.size()) - 1; i >= 0; --i) {
        cout << inverseOrderOps[i] << endl;
    }
}

int main()
{
    problemA();
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,a,b,c,x,y;
int main(void){
  while(cin >> n >> a >> b >> c >> x && n){
    int t = 0;
    for(int i = 0; i < n; i++){
      cin >> y;
      while(y != x && t <= 10000){
	x = (a*x+b)%c;
	t++;
      }
      x = (a*x+b)%c;
      t++;
    }
    t--;
    if(t > 10000) cout << -1 << endl;
    else cout << t << endl;
  }
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>

#define MAX_INT 2147483647
#define MOD 998244353
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::string;
using std::pair;
using std::cin;
using std::cout;

// @author: pashka

vector<long> fact;
vector<long> inv_fact;

long mult(long a, long b) {
    return (a * b) % MOD;
}

long calc_c(int n, int k) {
    return mult(mult(fact[n], inv_fact[k]), inv_fact[n - k]);
}

long pow(long a, int pow) {
    long res = 1;
    while (pow > 0) {
        if (pow & 1) {
            res = mult(res, a);
        }
        a = mult(a, a);
        pow /= 2;
    }
    return res;
}

long calc_g(int n, int k) {
    if (n == 0) return 1;
    if (k == n) return 0;
    if (k == 0) return 1;
    long res = calc_c(n, k);
    res -= calc_c(n - 1, k - 1);
    if (res < 0) res += MOD;
    res %= MOD;
    return res;
}

void calc(string &left, string &up, string &down, vector<long> &res) {
    int n = left.size();
    int m = up.size();
    int k = 0;
    for (int i = 0; i < n; i++) {
        if (left[i] == '1') k++;
    }
    res[0] = 1;
    int t = 0;
    for (int i = 0; i < m; i++) {
        if (up[i] == '1') t++;
        if (down[i] == '1') t++;
        res[i + 1] = calc_g(t + k, t);
    }
}

long calc(string a, string b, string c, string d) {
    int n = a.size();
    int m = c.size();
    vector<long> left(m + 1);
    vector<long> right(m + 1);
    calc(a, c, d, left);
    std::reverse(c.begin(), c.end());
    std::reverse(d.begin(), d.end());
    calc(b, c, d, right);
    std::reverse(c.begin(), c.end());
    std::reverse(d.begin(), d.end());

    long ll = 0;
    long res = 0;
    for (int i = 0; i < m; i++) {
        int t = 0;
        if (c[i] == '1') t++;
        if (d[i] == '1') t++;
        if (t == 0) continue;
        ll = t * (ll + left[i]);
        ll %= MOD;
        res += mult(ll, right[m - 1 - i]);
        res %= MOD;
//        std::cerr << i << " " << ll << " " << t << " " << left[i] << " " << right[m - 1 - i] << " " << res << "\n";
    }
    return res;
}

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

    int n, m;
    cin >> n >> m;

    fact.resize(2 * (n + m) + 2);
    inv_fact.resize(2 * (n + m) + 2);
    fact[0] = inv_fact[0] = 1;
    for (int i = 1; i < fact.size(); i++) {
        fact[i] = mult(fact[i - 1], i);
        inv_fact[i] = pow(fact[i], MOD - 2);
    }

    string a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int k = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == '1') k++;
        if (b[i] == '1') k++;
    }
    for (int i = 0; i < m; i++) {
        if (c[i] == '1') k++;
        if (d[i] == '1') k++;
    }
    
    if (k == 0) {
        cout << "1\n";
        return 0;
    }

    long res = (calc(a, b, c, d) + calc(c, d, a, b)) % MOD;

    cout << res;

    return 0;
}

Measured memory_bytes: 9392
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	long long int k,a,b;
	long long int ans=0;
	cin >>k>>a>>b;
	if (b-1<=a||k<a+1){
		cout <<k+1<<endl;
		return 0;
	}
	else {
		k-=a+1;
		ans+=b;
		ans+=k%2;
		ans+=(b-a)*(k/2);
		cout <<ans<<endl;
	}
}

Measured memory_bytes: 256
'use strict'
const Main = (input) => {
  let tmp = input.split('\n');
  let CardN = tmp[0].split(' ').map(Number)[0];
  let GateN = tmp[0].split(' ').map(Number)[1];
  let NumTop = 1;
  let NumBtm = CardN;
  // console.log({ CardN, GateN });

  for (let i = 1; i <= GateN; i++) {
    let top = tmp[i].split(' ').map(Number)[0];
    let btm = tmp[i].split(' ').map(Number)[1];
    // console.log({ top, btm });
    NumTop = NumTop <= top ? top : NumTop;
    NumBtm = NumBtm >= btm ? btm : NumBtm;
    // console.log({ NumTop, NumBtm });
  }
  let Ans = NumBtm - (NumTop - 1);
  console.log(Ans > 0 ? Ans : 0);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 200000
#define INF 0x3f3f3f3f
int N,M;
int Ans[MAXN+5];
set<pair<int,int> > P;
tuple<int,int,int> A[MAXN+5];

int main(){
    //freopen("road.in" ,"r", stdin);
    //freopen("road.out","w",stdout);
    N=read(),M=read();
    for(int i=1;i<=N;i++){
        int l=read(),r=read(),p=read();
        l=max(l-p,0),r=max(r-p,0);
        A[i]=tie(p,l,r);
    }
    sort(A+1,A+N+1);
    for(int i=1;i<=M;i++)
        P.insert({read(),i});
    memset(Ans,-1,sizeof Ans);
    for(int i=1;i<=N;i++){
        int l,r,p;
        tie(p,l,r)=A[i];
        set<pair<int,int> > tmp;
        auto it=P.lower_bound({l,-INF});
        while(it!=P.end()&&it->first<r){
            Ans[it->second]=p;
            tmp.insert(*it++);
        }
        for(auto i:tmp)
            P.erase(i);
    }
    for(int i=1;i<=M;i++)
        printf("%d\n",Ans[i]);
}


Measured memory_bytes: 20480
def solve():
    n = int(input())
    if 0 <= n < 10:
        print(n)
    elif 10 <= n < 100:
        print(9)
    elif 100 <= n < 1000:
        print(9 + n - 99)
    elif 1000 <= n < 10000:
        print(909)
    elif 10000 <= n < 100000:
        print(909 + n - 9999)
    else:
        print(90909)


if __name__ == '__main__':
    solve()


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

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

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

    int N;
    cin >> N;

    vector<int> d(N);
    ll minus_sum = 0, minus_cnt = 0;
    rep(i, N) {
        cin >> d[i];
    }
    int B;
    rep(i, N) {
        cin >> B;
        d[i] -= B;
        if (d[i] < 0) {
            minus_sum += d[i];
            minus_cnt++;
        }
    }

    int ans = -1;
    if (minus_cnt == 0) {
        ans = 0;
    } else {
        sort(d.begin(), d.end(), greater<int>());
        for (int i = 0; i < N; i++) {
            minus_sum += d[i];
            if (minus_sum >= 0) {
                ans = minus_cnt + i+1;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath> 
using namespace std;
int main()
{
	int n,a,b,i,t=0,p,s=0;
	cin>>n>>a>>b;
	for(i=1;i<=n;i++){
		p=i;t=0;
		while(p!=0){
			t+=p%10;
			p/=10;
		}
		if(t>=a && t<=b) s+=i;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
N = float("INF")
ans = 0
for i in range(1,n):
    if abs(a[i]-(a[0]-a[i])) < N:
        N = abs(a[i]-(a[0]-a[i]))
        ans = a[i]
print(a[0], ans)

Measured memory_bytes: 14428
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = 0
i = 0
j = 0
while i < n:
    if s+a[i] <= k:
        s += a[i]
        i += 1
    else:
        break
while j < m:
    if s+b[j] <= k:
        s += b[j]
        j += 1
    else:
        break
ans = i+j
i -= 1
while i >= 0:
    if j == m:
        break
    if s+b[j] <= k:
        s += b[j]
        j += 1
        ans = max(ans, i+1+j)
    else:
        s -= a[i]
        i -= 1
while j < m:
    if s+b[j] <= k:
        s += b[j]
        j += 1
    else:
        break
ans = max(ans, i+1+j)
print(ans)

Measured memory_bytes: 111012
#include<cstdio>
using namespace std;
long long n,k;
int main(){
	scanf("%lld%lld",&n,&k);
	if(!k) return printf("%lld\n",n*n),0;
	long long ans=0;
	for(int i=1;i<=n-k;i++){
		long long b=k+i;
		ans+=(n/b)*i;
		if(n%b>=k)ans+=n%b-k+1; 
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3216
//#include <atcoder/all>
#include <bits/stdc++.h>


#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
//using namespace atcoder;


typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 +7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = static_modint<MD>;
struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false; //閉路検出
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	
	UF ufa(n);
	rep(i, m){
		int a,b;
		cin >>a >>b;
		ufa.unite(a-1, b-1);
	}
	int ans =0;
	rep(i, n) if(ufa.root(i)) ans++;
	cout << ans - 1 <<"\n";
	return 0;
}



Measured memory_bytes: 3728
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
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)


int main() {

	int N, K; cin >> N >> K;

	if (K == 0) {
		cout << (ll)N*N << endl;
		return 0;
	}


	ll ans = 0;
	for (int b = 1; b < N + 1; b++) {
	
		if (b - 1 >= K) {

			//[nb,nb-1]の区間の数×一個の区間に含まれるK以上の数
			ans += N / b*(b - K);

			//完全な区間にならなかった余り
			ans += max(0, (N%b) - K + 1);
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;
    vector<int> count(2019, 0);
    ll res = 0, tmp = 0, b = 1;

    count[0] = 1;
    cin >> s;
    rep(i, s.length())
    {
        tmp += (s[s.length() - 1 - i] - '0') * b;
        tmp %= 2019;
        b = (b * 10) % 2019;
        res += count[tmp];
        count[tmp]++;
        //cout << tmp << ": " << count[tmp] << endl;
    }

    cout << res << endl;
}

Measured memory_bytes: 3732
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define endl "\n"
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[26];

int main(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	rep(i,0,s.sz){
		d[s[i]-'a']++;
		d[s[i]-'a']%=MOD;
	}
	ll ans = 1;
	rep(i,0,26){
		ans *= d[i]+1;
		ans %= MOD;
	}
	cout << ((ans+MOD)-1)%MOD << endl;
	return 0;	
}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string a;
	cin >> a;
	string b;
	cin >> b;
	string c;
	cin >> c;

		if( a.back() == b.front() && b.back() == c.front())
		cout << "YES" << endl;
		else
		cout << "NO" << endl;
		return 0;
}

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

using namespace std;

#define MAX 514

int main()
{
    int N;
    int dp[MAX] = {};
    dp[0] = 1;
    for (int i = 1; i <= 17; i++) {
        for (int j = 0; j < MAX-i*i; j++) {
            dp[j+i*i] += dp[j];
        }
    }
    
    while (cin >> N, N) {
        cout << dp[N] << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
import itertools

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    l = [i for i in range(1, N+1)]
    l = list(itertools.permutations(l))
    
    a = 0
    b = 0
    for k, v in enumerate(l):
        v = list(v)
        if v == A:
            a = k+1
        if v == B:
            b = k+1
    
    return abs(a-b)

print(solve())

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


using namespace std;

#define endl '\n'
#define PB push_back
#define MP make_pair
#define LL long long
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

typedef long long ll;

bool file=0,rt=1;
clock_t tStart ;
void FAST_IO();
////////////////////////

int main() {

    //FAST_IO();
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout << setprecision(5);
    cout << fixed;

    int H, W;
    int h, w;

    cin >> H >> W;
    cin >> h >> w;

    cout << abs(H-h) * abs(W-w) << endl;

    return 0;
}

void FAST_IO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);
    if(rt && file){ tStart = clock(); }
    if(file){
    #ifndef _offline
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    }
}




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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(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 long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
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;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;
const ll inf = 1e18;

int n;
pair <ll, ll> a[maxN];
ll ans = 0;

void opt(int lo, int hi)
{
    if (lo == hi)
    {
        return;
    }
    int mid = (lo + hi) / 2;
    opt(lo, mid);
    opt(mid + 1, hi);
    vector <pair <ll, ll>> prefix, suffix;
    prefix.eb(-inf, -inf);
    fore(i, mid + 1, hi)
    {
        prefix.eb(a[i].se, a[i].fi - a[i].se);
        suffix.eb(a[i].se, a[i].fi + a[i].se);
    }
    suffix.eb(inf, -inf);
    sort(all(prefix));
    sort(all(suffix));
    int sz = hi - mid;
    for1(i, sz)
    {
        uax(prefix[i].se, prefix[i - 1].se);
    }
    ford(i, sz)
    {
        uax(suffix[i].se, suffix[i + 1].se);
    }
    fore(i, lo, mid)
    {
        auto it = lower_bound(all(suffix), make_pair(a[i].se, -inf));
        uax(ans, it->se - a[i].fi - a[i].se);
        it = upper_bound(all(prefix), make_pair(a[i].se, inf));
        it--;
        uax(ans, it->se - a[i].fi + a[i].se);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(i, n)
    {
        cin >> a[i].fi >> a[i].se;
    }
    sort(a + 1, a + n + 1);
    opt(1, n);
    cout << ans;
    return 0;
}


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

const int N=1005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val

 
int32_t main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/
 int n,m;
 cin>>n>>m;
 cout<<n%m;

  
  
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  for(int a=1;a<=3500;a++)
    for(int b=1;b<=3500;b++)
      if(4*a*b-a*N-b*N>0 && N*a*b%(4*a*b-a*N-b*N)==0){
        cout<<a<<' '<<b<<' '<<N*a*b/(4*a*b-a*N-b*N)<<endl;
        return 0;
      }
}

Measured memory_bytes: 3624
#
# File    : C.rb
# Author  : Kazune Takahashi
# Created : 2018-7-7 21:49:44
# Powered by Visual Studio Code
#

n, m, d = gets.chomp.split(" ").map{|i| i.to_f}

if d >= 1
  ans = 2 * (n - d) * (m - 1) / (n * n)
else
  ans = n * (m - 1) / (n * n);
end

puts sprintf("%.12f", ans)

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  ll n, x; cin >> n >> x;
  vector<ll> a(n); rep(i,n) cin >> a[i];

  ll ans = 0;
  if(x < a[0]){
    ans += a[0] - x;
    a[0] = x;
  }
  rep(i,n-1){
    if(a[i] + a[i + 1] > x){
      ans += a[i] + a[i + 1] - x;
      a[i + 1] = x - a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
  register char c = getchar();x = 0;
  int neg = 0;
  for(; ((c<48 || c>57) && c != '-'); c = getchar());
  if(c=='-'){neg = 1;c = getchar();}
  for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
  if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
  long long ret = 1;
  for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 3e3+5;
int a[N];
LL dp[N][N];
int main()
{
  int n;
  in(n);
  for(int i = 0; i < n; i ++ ) {
    in(a[i]);
  }

  for(int i = 0; i < n; i ++) dp[i][i] = a[i];
  for(int i = 0; i + 1 < n; i ++) dp[i][i+1] = abs(a[i] - a[i+1]);

  for(int len = 3; len <= n; len ++) {
    for(int j = 0; j + len <= n; j ++) {
      int k = j + len - 1;
      dp[j][k] = max(
          min(a[j] - a[j+1] + dp[j+2][k], a[j] - a[k] + dp[j+1][k-1]), 
          min(a[k] - a[j] + dp[j + 1][k-1], a[k] - a[k-1] + dp[j][k-2])
      );
    }
  }
  cout << dp[0][n-1] << endl;
}


Measured memory_bytes: 70016
using System;
using System.Linq;

namespace abc135_c
{
    static class Program
    {
        static void Main(string[] args)
        {
            // 勇者の数
            var n = Console.ReadLine().ToLong();
            // 街の数
            var c = n + 1;
            // それぞれの街を襲っているモンスターの数
            var a = Console.ReadLine().ToLongArray();
            // それぞれの勇者が倒せるモンスターの数
            var b = Console.ReadLine().ToLongArray();

            // はじめの街のモンスターははじめの勇者でしか倒せない
            // →はじめの街のモンスターはすべてはじめの勇者が倒しておくべき

            // はじめの街から順に、討伐数を確定していく

            // 討伐数合計
            var sum = 0L;
            for (int i = 0; i < b.Length; i++)
            {
                // iでの討伐数
                var mon1 = Math.Min(a[i], b[i]);
                // 残りの討伐数
                var sub = b[i] - mon1;
                // i+1での討伐数
                var mon2 = Math.Min(a[i + 1], sub);
                // i+1での討ち漏らし
                a[i + 1] -= mon2;
                // 合計数を加算
                sum += mon1 + mon2;
            }

            Console.WriteLine($"{sum}");
        }

        static long ToLong(this string s)
        {
            return long.Parse(s);
        }

        static long[] ToLongArray(this string s, char separator = ' ')
        {
            return s.Split(separator).Select(m => m.ToLong()).ToArray();
        }
    }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;cin >> n;
    vector<int> p(n+1);rep(i,n)cin >> p[i+1];
    int counter = 0;
    for (int i = 1; i < n; i++)
    {
        if(i==p[i])
        {
            swap(p[i],p[i+1]);
            counter++;
        }
    }
    if(p[n]==n)
    {
        counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007
#define ll long long int
vector<ll> adj[100001],nodes;
ll c[100001],dp[100001];
bool vis[100001];
ll n,m;
void dfs2(ll i){
  vis[i]=true;
  for(ll j=0;j<adj[i].size();j++){
    if(!vis[adj[i][j]]) dfs2(adj[i][j]);
    dp[i]=max(dp[i],1+dp[adj[i][j]]);
  }
}
  
void dfs(ll i){
  c[i]=-1;
  for(ll j=0;j<adj[i].size();j++){
    if(!c[adj[i][j]]) dfs(adj[i][j]);
  }
  c[i]=1;
  nodes.push_back(i);
}
void topo(){
  memset(c,0,sizeof c);
  for(int i=1;i<=n;i++){
    if(!c[i]) dfs(i);
  }
}
  
int main(){
  
  cin>>n>>m;
  while(m--){
  	ll u,v;
    cin>>u>>v;
    adj[u].push_back(v);
   }
  /* topo();
  reverse(nodes.begin(),nodes.end());
  	for(ll i=0;i<n;i++) cout<<nodes[i]<<" ";
  cout<<endl;
  
  int dist[n+1];
  for(ll i=1;i<=n;i++) dist[i]=1000000;
  for(ll i=0;i<n;i++){
    for(ll j=0;j<adj[nodes[i]].size();j++){
      if(dist[adj[nodes[i]][j]]<
      */
  memset(vis,false,sizeof vis);
  memset(dp,0,sizeof dp);
  for(ll i=1;i<=n;i++){
    if(!vis[i]) dfs2(i);
  }
  ll maxx=0;
  for(ll i=1;i<=n;i++) maxx=max(maxx,dp[i]);
  cout<<maxx;
    
  
  
}

Measured memory_bytes: 8704
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int a,b;
  int t;
  cin >> a >> b >>t;
  cout << ((10*t+5)/(10*a))*b << endl;
return 0;}

Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static  void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        
        long total1 = a - k;
        if (total1 >= 0) {
            System.out.println(total1+" "+b);
            return;
        }
        
        long total2 = b + total1;
        if (total2 >= 0) {
            System.out.println(0 + " " + total2);
            return;
        }
        
        System.out.println(0 + " " + 0);
        
        
    }
}
        

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

int isprime(int x){
  if(x==2) return x;
  if(x<2||x%2==0) return 0;
  int i;
  for(i=3;i<=sqrt(x);i+=2)
    if(x%i==0)
      return 0;
  return x;
}

int main(void){

  int a,d,n,i;

  for(;;){

    scanf("%d %d %d",&a,&d,&n);
    if(a==0&&d==0&&n==0)break;

    int num=0;
    for(i=1;num<n;i++)
      if(isprime(a+d*(i-1)))num++;
    
    printf("%d\n",a+d*(i-2));
    
  }

  return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

int main(){
	lint n;cin>>n;
	liv a(n),s(n+1);rep(i,n)cin>>a[i],s[i+1]=s[i]+a[i];
	map<lint,lint> m;
	rep(i,n+1)m[s[i]]++;
	lint ans=0;
	for(auto i:m){
		ans+=i.second*(i.second-1)/2;
	}cout<<ans<<endl;
}

//sub-EOF


Measured memory_bytes: 15872
N = int(input())
src = [0] + list(map(int,input().split())) + [0]
cums = [0]
for a,b in zip(src,src[1:]):
    cums.append(cums[-1] + abs(a-b))

for i in range(N):
    print(cums[i] + abs(src[i] - src[i+2])   - cums[i+2] + cums[-1])


Measured memory_bytes: 14048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = in.nextInt();
		}
		int ans = 0;
		while (true) {
			int left = -1;
			for (int i = 0; i < N; i++) {
				if (h[i] != 0) {
					left = i;
					break;
				}
			}
			if (left == -1) {
				break;
			}
			int right = left;
			while (right + 1 < N && h[right] <= h[right + 1]) {
				right++;
			}
			for (int j = left; j <= right; j++) {
				h[j] -= 1;
			}
			ans += 1;
		}
		System.out.println(ans);
		in.close();
	}
}

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

int main() {
	
	int n; cin>>n;
	vector<vector<int>> a(1);
	int next{1};
	while(1){
		int tmp{next};
		for(int j=0; j<a.size(); j++){
			a.at(j).push_back(tmp++);
		}
		a.push_back({});
		tmp = next;
		for(int j=0; j<a.size()-1; j++){
			a.back().push_back(tmp++);
		}
		next = tmp;
		if(next-1>n){
			cout<<"No"<<endl;
			return 0;
		}
		if(next-1==n){
			cout<<"Yes"<<endl;
			cout<<a.size()<<endl;
			for(auto k:a){
				cout<<k.size()<<' ';
				for(auto l:k) cout<<l<<' ';
				cout<<endl;
			}
			return 0;
		}
	}
	
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

const ll D = 80*160 + 10; // abs(A-B) * (H+W) + 10
const ll D2 = D*2;

typedef bitset<D2> bs;

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll h, w;
  cin >> h >> w;
  vector<vector<ll>> a(h, vector<ll>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> a[i][j];
    }
  }
  rep(i, h) {
    rep(j, w) {
      ll x;
      cin >> x;
      a[i][j] = abs(a[i][j] - x);;
    }
  }
  // Here, a contains the diff of A and B

  vector<vector<bs>> dp(h, vector<bs>(w));
  dp[0][0][D-a[0][0]] = 1;
  dp[0][0][D+a[0][0]] = 1;
  rep(i, h) {
    rep(j, w) {
      if (i) {
        dp[i][j] |= dp[i-1][j] << a[i][j];
        dp[i][j] |= dp[i-1][j] >> a[i][j];
      }
      if (j) {
        dp[i][j] |= dp[i][j-1] << a[i][j];
        dp[i][j] |= dp[i][j-1] >> a[i][j];
      }
    }
  }
  // Here, dp[i][j][k] means the reachability of k at (i,j)

  ll ans = D;
  rep(k, 2*D) {
    if (dp[h-1][w-1][k]) { // reachable to k
      ans = min(ans, abs(k-D));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 20736
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 200005




// Driver code to test above functions
int32_t main()
{
    
 
  
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    string s = "";
    for(int i=0;i<n;i++)
    {
        char ch;
        cin >> ch;
        if(i==0)
            s += ch;
        else if(s.back()!=ch)
            s += ch; 
    }

    cout << s.size();

    return 0;
    
} 

Measured memory_bytes: 512
import sys
def sum_n(n):
    if n>36:return 0
    return sum([1 for i in range(10) for j in range(10) for k in range(10) for l in range(10) if i+j+k+l==n])
    
[print(sum_n(i)) for i in [int(line) for line in sys.stdin]]




Measured memory_bytes: 5612
#include <iostream>
#include <cmath>

using namespace std;

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

    int k = abs(a - b);
    if(k % 2 == 1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    else{
        if(a > b) cout << b + k / 2 << endl;
        else cout << a + k / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
if B > 0:
    if B == 1:
        val = A + B
    elif B >= 2:
        if A <= 1:
            val = A + B
        else:
            val = A * B
elif B == 0:
    if A > 0:
        val = A - B
    else:
        val = A * B
else:
    if A >= 0:
        val = A - B
    else:
        val = A * B
        
print("%d"%val)

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

//再帰関数による最大公約数
int gcd(int x, int y){
    return y ? gcd(y, x % y) : x;
}

int main(){
    int x,y;
    cin >> x >> y;
    cout << gcd(x,y) << endl;

    return 0;
}


Measured memory_bytes: 3108
n, m = list(map(int, input().split()))
X = [-1] * n
flag = False
for _ in range(m):
    s, c = list(map(int, input().split()))
    i = s - 1
    if X[i] != -1 and X[i] != c:
        flag = True
    else:
        X[i] = c
if flag:
    print('-1')
else:
    if n > 1:
        if X[0] == -1:
            X[0] = 1
    if n > 1 and X[0] == 0:
        print('-1')
    else:
        print(''.join([str(max(x, 0)) for x in X]))

Measured memory_bytes: 38452