akhauriyash/Code-Regression huggingface dataset:
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<lli>/*------------------*/vlli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()
#define makepair/*---------------------*/make_pair
#define pushback/*---------------------*/push_back

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	string s;
	cin >> s;
	s[3] = '8';
	cout << s;
	return 0;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)

using namespace std;

void solve(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans =  0;
  ll one = min(k,a);
  ans += one;
  k -= one;
  ll zero = min(k,b);
  k-=zero;
  ll minu = min(k,c);
  ans-=minu;
  g(ans);
}
int main()
{
#ifndef ONLINE_JUDGE
input_from_file
#endif
 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
    //cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
      solve();
        
    }
return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> q(n);
    rep(i,n) {
        int x, y, h;
        cin >> x >> y >> h;
        q[i] = {x,y,h};
    }
    int min_h = 1e9;
    int max_h = 0;
    rep(i,n) min_h = min(min_h,q[i][2]);
    rep(i,n) max_h = max(max_h,q[i][2]);

    for (int Cx = 0; Cx <= 100; Cx++) {
        for (int Cy = 0; Cy <= 100; Cy++) {
            for (int H = min_h; H <= 200+max_h; H++) {
                bool ok = true;
                rep(i,n) {
                    if (max(H-abs(q[i][0]-Cx)-abs(q[i][1]-Cy),0) != q[i][2]) {
                        ok = false;
                    }
                }
                if (ok) {
                    cout << Cx << " " << Cy << " " << H << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const long N=2e5;
long n,k,cnt[N+2],ans;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>n>>k;
  for(long i=1;i<=n;i++)
    cnt[i%k]++;
  for(long i=1;i<=n;i++)
  {
    long r1=(k-(i%k))%k;
    long r2=(k-(r1%k))%k;
    if(r1==r2)ans+=cnt[r1]*cnt[r2];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,a,b;
	cin>>n>>a>>b;

	vector<lli> h(n);
	REP(i,0,n)cin>>h[i];

	sort(h.begin(),h.end(),greater<lli>());

	lli small = 0,large = 1e9;
	while(small+1<large){
		if(DEBUG)cout<<"small="<<small<<" large="<<large<<endl;
		lli middle = (small+large)/2;
		lli allDamage = b * middle;
		vector<lli> nowH(n);
		REP(i,0,n){
			nowH[i] = h[i]-allDamage;
		}
		lli nowCnt = middle;

		REP(i,0,n){
			if(nowH[i]>0){
				nowCnt -= ((nowH[i])/(a-b)) + (nowH[i]%(a-b)!=0);
			}
		}
		if(nowCnt >= 0){
			large = middle;
		}
		else{
			small = middle;
		}
	}
	cout<<large<<endl;

	return 0;
 
}

Measured memory_bytes: 1792
function main(input) {
  const inp = input.split(' ');
	const n = Number(inp[0]);
	const x = Number(inp[1]);
	const y = Number(inp[2]);
	
  function dist(a, b) {
		return Math.min(b-a, Math.abs(x-a)+Math.abs(y-b)+1);
	}
  
  for(var i=1;i<n; i++) {
    var cnt = 0;
    
    for(var a=1; a<=n-i; a++) {
			var s = a+i;
			if(s <= n && dist(a,s) === i)
				cnt++; 
			
			var rmn = i - 1 - Math.abs(x-a);
			
			if(rmn > 0) {
				var prev = y - rmn;
				if(prev !== s && dist(a, prev) === i)
					cnt++; 
				
				var next = y + rmn;
				if(next !== s && next <= n && dist(a, next) === i)
					cnt++; 
			} else if(rmn === 0 && y !== s && dist(a, y) === i)
				cnt++; 
		}
		
    console.log(cnt);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9644
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
int main() {
	ll A, B;
	cin >> A >> B;
 
	if (A == B)puts(0);
	else if ((A + B) % 2 == 0)puts((A + B) / 2);
	else puts("IMPOSSIBLE");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int A, P;

int main(){
    
    cin>>A>>P;
    
    int ans = (A*3+P)/2;
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int ans=0;
  cin >> N ;
  int N_1=N;
  int a[3];
  for(int i =0;i<3; i++){
    a[i] = N_1 %10;
    N_1 = N_1/10;
    if(a[i]==1)
      ans +=1;
  }
  
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a, b, c;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		b.push_back(tmp);
	}
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		c.push_back(tmp);
	}
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	long long ans = 0;
	for (int i = 0; i < n; i++)
		ans += (lower_bound(a.begin(), a.end(), b[i])-a.begin())*(c.end()-upper_bound(c.begin(),c.end(),b[i]));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N,X;
LL b[100001];
LL l[100001];
LL u[100001];
LL a[100001];
LL en=0;
typedef pair<LL,LL>P;
vector<P>v;
LL S[100001];
bool check(LL mid){
	LL c=mid/X;
	c--;
	LL d=mid%X;
	REP(i,N){
		LL ans=0;
		if(a[i]<=c){
			ans=S[c+1]-(b[i]*l[i]+(X-b[i])*u[i]);
		}else{
			ans=S[c];
		}
		if(d>b[i]){
			ans+=b[i]*l[i]+(d-b[i])*u[i];
		}else{
			ans+=d*l[i];
		}
		if(ans>=en){
			//cout<<mid<<" "<<ans<<endl;
			return true;
		}
	}
	return false;
}

LL binary_search(){
	LL lb=-1;
	LL ub=N*X;
	while(ub-lb>1){
		LL mid=(ub+lb)/2;
		if(check(mid)){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	return ub;
}
int main(){
	cin>>N>>X;
	REP(i,N){
		cin>>b[i]>>l[i]>>u[i];
		en+=b[i]*l[i];
		v.push_back(P(b[i]*l[i]+(X-b[i])*u[i],i));
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	REP(i,v.size()){
		P p=v[i];
		int x=p.second;
		LL now=p.first;
		if(i==0){
			S[i]=now;
		}else{
			S[i]=now+S[i-1];
		}
		a[x]=i;
	}
	cout<<binary_search()<<endl;
}

Measured memory_bytes: 5872
#include<stdio.h>
int main(){
    int a, b, c, num;
    scanf("%d %d %d", &a, &b, &c);
    if(a >= b){
        num = a;
        a = b;
        b = num;
        }
    if(b >= c){
        num = b;
        b = c;
        c= num;
    }
    if(a >= b){
        num = a;
        a = b;
        b = num;
        }
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}


Measured memory_bytes: 2040
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 09/06/2017 13:00:54
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ull unsigned long long
using namespace std;

int main(){
	string s;
	cin>>s;
	map<char, int> mapp;
	bool flag = true;
	for(int i = 0; i < s.size(); ++i){
		if(++mapp[s[i]] >= 2) {
			flag = false;
			break;
		}
	}
	if(flag) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

s = input()
n = len(s)
ans = 0
for si in s:
    ans = (ans+int(si))%9
if ans == 0:
    print("Yes")
else:
    print("No")


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

using namespace std;

int main(){
    
    int N,M;
    cin >> N >> M;
    vector<int> X(M);
    
    for (int i = 0; i < M; i++) {
        cin >> X[i];
    }
    
    sort(X.begin(), X.end());
    reverse(X.begin(), X.end());
    
    vector<int> dx(M-1);
    
    for (int i = 1; i < M; i++) {
        dx[i-1] = X[i-1] - X[i];
    }
    
    sort(dx.begin(), dx.end());
    
    
    int ans = 0;
    
    for (int i = 0; i < M-N; i++) {
        
        ans += dx[i];
        
    }
    
    cout << ans << endl;
    
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int func(ll num){
    int count = 0;
    while(num % 2 == 0){
        num /= 2;
        count++;
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    ll a[N];
    int sum = 0;
    rep(i, N){
        cin >> a[i];
        sum += func(a[i]);
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
    int N, X; cin >> N >> X;
    int m = 1000;
    for (int i=0; i<N; i++) {
        int tmp; cin >> tmp;
        X -= tmp;
        m = min(tmp, m);
    }
    cout << N + X / m << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    
    if ((a+b)%2 == 0){
        cout << (a+b)/2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    string ans = "NO";

    REP(i, n-1){
        ll l = c * i - d * (n - 1 - i);
        ll u = d * i - c * (n - 1 - i);
        if(b - a >= l && b - a <= u){
            ans = "YES";
        }
    }

    cout << ans << endl;

    return 0;
}


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

int arr[100];

int main(void){
    
    int n,k,res = 0;
    cin >> n >> k;
    
    for(int i = 0; i < n; i++)cin >> arr[i];
    
    sort(arr,arr+n);
    
    for(int i = n-k; i < n; i++)
        res += arr[i];
    
    cout << res << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<double> a(n + 1);
    //vector<vector<double>> dp(n + 1, vector<double>(n + 1));
    vector<double> dp(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];

    dp[0]=1;
    /*
    3
    0.30 0.60 0.80
    */
    for (int i = 1; i <= n; i++){
       // for (int j = 0; j <= n; j++){
        for (int j = i; j >= 0; j--){
            //dp[i][j] = dp[i-1][j]*(1 - a[i]) + dp[i-1][j-1]*a[i];
            if (j == 0) dp[j] = dp[j]*(1 - a[i]);
            else
            dp[j] = dp[j]*(1 - a[i]) + dp[j - 1]*a[i];
        }
    }

    int mid = (n + 1) / 2;
    double res = 0;
    for (int i = mid; i <= n; i++) res += dp[i];
    //cout << setprecision(10) << res;
    printf("%.10lf", res);
}


Measured memory_bytes: 256
K=int(input())
A=["1","2","3","4","5","6","7","8","9"]
B=[]
C=A[:]
count=9
if(K<10):
  print(K)
else:
  while(count<K):
    B=[]
    for i in range(len(C)):
      if(int(C[i][len(C[i])-1])==0):
        B.append(C[i]+str(0))
        B.append(C[i]+str(1))
        count+=2
      elif(int(C[i][len(C[i])-1])>0 and int(C[i][len(C[i])-1])<9):
        B.append(C[i]+str(int(C[i][len(C[i])-1])-1))
        B.append(C[i]+str(int(C[i][len(C[i])-1])))
        B.append(C[i]+str(int(C[i][len(C[i])-1])+1))
        count+=3
      else:
        B.append(C[i]+str(8))
        B.append(C[i]+str(9))
        count+=2
    C=B[:]
    A.extend(B)
  print(A[K-1])

Measured memory_bytes: 19564
#define _GLIBCXX_DEBUG //提出時に消す
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  ll a, b;
  cin >> a >> b;

  cout << a * b << endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(void)
{
  int N;
  scanf("%d", &N);
  vector<int> a;
  vector<int> b;
  priority_queue<int> c;
  a.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", a.data() + i);
  }
  sort(a.begin(), a.end());
  // unique_copy(a.begin(), a.end(),back_inserter(b));
  // for (auto e: b) {
  //   c.push(count(a.begin(), a.end(), e));
  // }
  {
    int lst = a.front();
    int cnt = 0;
    for (auto e: a) {
      if (e == lst) {
        cnt++;
      } else {
        c.push(cnt);
        lst = e;
        cnt = 1;
      }
    }
    c.push(cnt);
  }

  while (c.size() != 1) {
    int x,y;
    x = c.top();
    c.pop();
    y = c.top();
    c.pop();
    c.push(1);
    if (y == 1) {
      c.push(x);
      break;
    } else {
      c.push(x - y + 1);
    }
  }
  
  int x = c.top();
  c.pop();
  x = x & 1 + (((x >> 1) * !(x & 1)) << 1);
  if (x != 1) {
    x -= 2;
  }
  c.push(x);
  int num = 0;
  while (!c.empty()) {
    num += c.top();
    c.pop();
  }

  printf("%d\n", num);
  return 0;
}



Measured memory_bytes: 1276
N, M = map(int, input().split())
# if N >= M:
#     print()
X = sorted(list(map(int, input().split())))

# 使えるコマが1つだけだとして考えると
# X[0]にコマを置いて、右に向かって順番に移動していくのが最善(一度通った道をもう一度通るのは無駄)
# "ジャンプ[i]"：X[i]から[i+1]への移動 と定義する
# ジャンプはM-1回
# 総移動回数はsum(ジャンプ[i]での移動回数)

# 使えるコマが1つ増えると、1ジャンプ減らすのと同じ
# コマがN個使えるとき、"操作"をN-1回減らすことができる
# sum((ジャンプ[i]での移動回数 (i<=0<M-1))のうち小さい方からM-N個)が答え

print(sum(sorted([X[i + 1] - X[i] for i in range(M - 1)])[: max(M - N, 0)]))


Measured memory_bytes: 13968
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;
ll dpn[2001001];
ll dp0[2001001];
ll dp9[2001001];
ll dp[2001001];

int main(){
    int n;
    cin>>n;
    dpn[0]=1;
    for(int i=1;i<=n;i++){
        dpn[i]+=dpn[i-1]*8;
        dpn[i]%=MOD;
        dp0[i]+=dpn[i-1];
        dp0[i]%=MOD;
        dp9[i]+=dpn[i-1];
        dp9[i]%=MOD;
        dp0[i]+=dp0[i-1]*9;
        dp0[i]%=MOD;
        dp9[i]+=dp9[i-1]*9;
        dp9[i]%=MOD;
        dp[i]+=dp[i-1]*10;
        dp[i]%=MOD;
        dp[i]+=dp0[i-1];
        dp[i]%=MOD;
        dp[i]+=dp9[i-1];
        dp[i]%=MOD;
    }
    cout<<dp[n]<<endl;

}

Measured memory_bytes: 34204
n,a,b = map(int,input().split())
vs = sorted([int(v) for v in input().split()],reverse=True)
print(sum(vs[:a])/a)
binom = [1]
for k in range(vs.count(vs[a-1])):
    binom = [x+y for (x, y) in zip(binom+[0],[0]+binom)]
if vs[a-1] == vs[0]:
    print(sum(binom[a:b+1]))
else:
    print(binom[a-vs.index(vs[a-1])])

Measured memory_bytes: 3064
/********************************************************************
* @brief https://atcoder.jp/contests/abc175/tasks/abc175_d
* @date 2020/08/16
*********************************************************************/

#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   int n, x, t;
   cin >> n >> x >> t;
   if(n%x==0) cout << ((n/x))*t << endl;
   else cout << ((n/x)+1)*t << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

/* 文字から数値に変換 */
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

/* 文字列から数値へ変換して key を生成する */
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) % M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str);
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16012
<?php

while($n = trim(fgets(STDIN))) {
  
  $y = trim(fgets(STDIN));
  
  $result = array();
  $cash = 10000;
  
  
  for($i=1; $i <= $n; $i++) {
  
    $line = trim(fgets(STDIN));
    $line = explode(' ', $line);
  
    
    $b = $line[0];
    $r = $line[1];
    $t = $line[2];
  
  
    if ($t == 1) {
      $result[$b] = $cash * (1+ $y * $r /100);
    } else {
      $result[$b] = $cash * pow((1 + $r /100), $y);
    }
  }
  $ans = array_search(max($result), $result);

   //   if (strlen($mozi) <= 6 && strlen($mozi) >= 3) {
          printf($ans."\n");
   //   }
}

Measured memory_bytes: 15604
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 200010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

pii a[N];
bool cmp(pii a,pii b){
    if(a.y!=b.y)return a.y<b.y;
    return a.x<b.x;
}
int main(){
    //srand(time(NULL)+clock());
    int ca=0,T,k,i,j,m=0,n,K;
    double start=clock();
    int h,w;
    scanf("%d%d%d",&h,&w,&n);
    rep(i,0,n)scanf("%d%d",&a[i].x,&a[i].y);
    sort(a,a+n,cmp);
    int x=1,y=1,res=h,ans=0;k=0;
    while(x<=h){
        //cerr<<x<<" "<<y<<" "<<ans<<"\n";
        while(k<n&&a[k].y<y)k++;
        while(k<n&&a[k].y==y&&a[k].x<=x)k++;
        //if(k<n)cerr<<a[k].x<<" "<<a[k].y<<"\n";
        if((k<n&&a[k]==mp(x+1,y))||x==h){ans++;break;}
        ans++;x++;
        if(k<n&&a[k].y==y){
            Min(res,ans+a[k].x-x);
        }
        else Min(res,ans+h-x+1);
        while(k<n&&a[k].y==y)k++;
        while(k<n&&a[k].y==y+1&&a[k].x<x)k++;
        if(!(k<n&&a[k]==mp(x,y+1))&&y<w)y++;
    }
    Min(res,ans);
    printf("%d\n",res);
    cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


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

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

  bool flg = true;
  int A = 0;
  for (int i=0; i<N; i++) {
    cin >> A;
    if (A % 2 == 0) {
      if (A % 3 != 0 && A % 5 != 0) {
        flg = false;
        break;
      }
    }
  }
  
  string res = "DENIED";
  if (flg) {
    res = "APPROVED";
  } 
  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
#define N 100005
 
 struct Node{
  int p;
  int l;
  int r;
};
struct Node A[N];

int depth(int);
int child(int);
 
int main()
{
 
 
  int i,j;
  int n,id,d,c,k;
  scanf("%d",&n);
   
  for(i = 0; i < n; i++){
   A[i].p = NIL;
   A[i].l = NIL;
   A[i].r = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d",&id,&d);
    for(j = 0; j < d; j++){
      scanf("%d",&c);
       
      A[c].p = id;
       
      if(j == 0){
    A[id].l = c;
      }
      
      else {
    A[k].r = c;
      }
      
      k = c;
    }
  }
 
  for(i = 0; i < n; i++){
 
    printf("node %d: parent = %d, depth = %d, ",i,A[i].p,depth(i));
     
    
    if(A[i].p == NIL){
      printf("root, [");
    }
    else if(A[i].l == NIL){
      printf("leaf, [");
    }
    
    else {
    printf("internal node, [");
    }
    child(A[i].l);
    printf("]\n");
  }
  return 0;
}
 
 
int depth(int x)
{
  int a;
   
  if(A[x].p == NIL){
    return 0;
  }
  else {
  	
    a = depth(A[x].p) + 1;
    return a;
  }
}
 
int child(int x)
{
  if(x==NIL){
    return 0;
  }
  
  else {
    if(A[x].r == NIL){
      printf("%d",x);
    }
    else {
      printf("%d, ",x);
      child(A[x].r);
    }
   }
}

Measured memory_bytes: 1784
#!/usr/bin/env python3

from pprint import pprint
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)


# s, t \in V (s < t) に対して、s から t への最短経路を d_min(s, t) とすると、
# d_min(s, t) は、
# d_min(s, t) = min(t - s, abs(x - s) + 1 + abs(t - y))
# で与えられる。
# なので、s, t の全ての組み合わせに対して d_min(s, t) を計算し、条件を満たすような s, t の組を数え上げればよい。


N, X, Y = map(int, input().split())
# 0-index
X -= 1
Y -= 1

count_dict = defaultdict(int)

# O(N^2)
for s in range(N - 1):
    for t in range(s + 1, N):
        dist = min(t - s, abs(X - s) + 1 + abs(t - Y))
        count_dict[dist] += 1

for k in range(1, N):
    ans = 0
    if k in count_dict:
        ans = count_dict[k]
    print(ans)


Measured memory_bytes: 76724
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        親が同じか判別する
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        yをxの根に繋ぐ
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        """
        xとyが同じ連結成分か判別する
        """
        return self.find(x) == self.find(y)

    def size(self, x):
        """
        xの連結成分の大きさを返す
        """
        return -self.parents[self.find(x)]

    def kruskal(self, edge):
        """
        :param edge: edge = [(コスト, 頂点1, 頂点2),...]の形で重み付き隣接リストを渡して下さい
        :return: 最小全域木のコストの和
        """
        edge.sort()
        cost_sum = 0
        for cost, node1, node2 in edge:
            if not self.same(node1, node2):
                cost_sum += cost
                self.union(node1, node2)
        return cost_sum


def resolve():
    V, E = map(int, input().split())
    edge = []
    for _ in range(E):
        s, t, w = map(int, input().split())
        edge.append([w, s, t])

    uf = UnionFind(V)
    res = uf.kruskal(edge)
    print(res)


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 24828
object Main extends App {
  import scala.io.StdIn._

  val Array(h, w, x, y) = readLine.trim.split(' ').map(_.toInt)
  println(
    if ((h * w) % 2 == 1 && (x + y) % 2 == 1) "No" else "Yes"
  )
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}



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

using namespace std;

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

    bool Ok = false;

    for(int x = a; x <= b; x++)
        if(x % k == 0)
            Ok = true;

    puts(Ok ? "OK" : "NG");
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll inN;
vector<int> N;
ll dp[100][10];
ll mod = 1e9+7;
int main(){
	cin >> inN;

	while(inN) {
		N.pb(inN % 2);
		inN /= 2;
	}
	reverse(N.begin(),N.end());

	ll n = N.size();

	dp[0][0] = 1;

	REP(i,n) {
		if(N[i] == 1) {
			(dp[i + 1][0] += dp[i][0]) %= mod;
		}
		(dp[i + 1][N[i]] += dp[i][0]) %= mod;
		(dp[i + 1][N[i]] += dp[i][1]) %= mod;
		(dp[i + 1][N[i] + 1] += dp[i][1]) %= mod;
		(dp[i + 1][2] += dp[i][1]) %= mod;
		(dp[i + 1][2] += 3 * dp[i][2]) %= mod;
	}
	ll ans = 0;
	REP(j,3) {
		(ans += dp[n][j]) %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

i64 up_div(i64 numer, i64 denom) { return (numer + denom - 1) / denom; }

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  VAR(int, N);

  vector<i64> c(N + 5), s(N + 5), f(N + 5);
  rep(i, N - 1) {
    IN(c[i], s[i], f[i]);
  }

  vector<i64> res;
  rep(i, N) {
    i64 t = 0;
    for (int j = i; j < N - 1; ++j) {
      i64 leave = max(s[j], f[j] * up_div(t, f[j]));
      t = leave + c[j];
    }
    res.emplace_back(t);
  }

  OUTL(res);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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(){
  ll r, d, x;
  cin >> r >> d>>x;
  rep(i,10){
    x = r * x - d;
    print(x);
  }
}

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

using namespace std;

int sz, a, b, c, Sb, Sc, N, M, ap[100009];
bool Bip;
vector < int > v[100009];

void dfs (int nod, int col)
{
    if (ap[nod])
    {
        if (ap[nod] != col) Bip = 0;
        return ;
    }
    ap[nod] = col, sz ++;
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        dfs (*it, 3 - col);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
for (int i=1; i<=N; i++)
    if (ap[i] == 0)
    {
        Bip = 1, sz = 0, dfs (i, 1);
        if (sz == 1) a ++;
        else
        if (Bip) b ++, Sb += sz;
        else c ++, Sc += sz;
    }
long long ans = 1LL * c * c + 1LL * a * a + 2LL * b * b + 2LL * b * c + 2LL * a * (Sb + Sc);
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 9088
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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() {
 
    string s, t;
    cin >> s >> t;

    int len_s = s.size(), len_t = t.size();
    vector<vector<int>> dp(len_t+1, vector<int>(len_s+1, 0));

    rep(i, len_t+1){
        rep(j, len_s+1){
            if(i == 0 || j == 0) continue;
            if(t[i-1] == s[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    
    string ans = "";
    int x = len_t, y = len_s;
    while(x > 0 && y > 0){
        if(dp[x][y] == dp[x-1][y]){
            x--;
        }else if(dp[x][y] == dp[x][y-1]){
            y--;
        }else{
            x--;
            y--;
            ans.push_back(s[y]);
        }
    }

    reverse(all(ans));
    cout << ans << ln;
}
 

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    string t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N,M;
    cin >> N;
    vll D(N);
    cin >> D;
    cin >> M;
    vll T(M);
    cin >> T;
    sort(D.begin(),D.end());
    sort(T.begin(),T.end());
    queue<ll> d,t;
    for(auto i:D)d.push(i);
    for(auto i:T)t.push(i);
    while(!d.empty() && !t.empty()){
        if(t.front() == d.front()){
            t.pop();
        }
        d.pop();
    }
    if(t.empty()){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 9548
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;
    int index = k;
    while(index <= n){
        ans++;
        index++; 
    }
    OUT(ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    if (a%3==0 || b%3==0 || (a+b)%3 == 0)
    {
      cout << "Possible" << endl;
    }
    else
    {
      cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll ;
const long long mod = 1000000007;

void solve(long long N){
ll ans=1;
for(ll i=1; i<=N; i++){
    ans*=i;
    ans%=mod;
}
cout<< ans <<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

set<int>st;

int main() {
    
    int n,m,i,x;
    string str;
    long ca = 0, wa = 0;
    
    cin>>n>>m;
    
    int arr[n+5][2] = {0};
    
    for(i=0; i<m; i++) {
        cin>>x>>str;
        st.insert(x);
        if(str == "WA" && arr[x][0] == 0) {
            arr[x][1]++;
        } else if(str == "AC") {
            arr[x][0] = 1;
        }
    }
    
    for (auto eml: st) {
        if(arr[eml][0] == 1) {
            ca++;
            wa+=arr[eml][1];
        }
    }
    
    printf("%ld %ld", ca, wa);
}


Measured memory_bytes: 5760
import heapq

from typing import List


def main():
    n, m = map(int, input().split())
    v = map(int, input().split())
    print(pdt(v, m))


def pdt(v: List[int], m: int) -> int:
    vv = [-a for a in v]
    heapq.heapify(vv)

    for _ in range(m):
        k = -heapq.heappop(vv)
        k = k // 2
        heapq.heappush(vv, -k)

    return -sum(vv)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21808
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    for x in range(60000):
        if int(x * 1.08) == N:
            print(x)
            return

    print(":(")
    return


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9896
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    int N;
    cin >> N;
    long long a[3 * N];
    REP(i, 3 * N) cin >> a[i];
    sort(a, a + 3*N, greater<long long>());
    long long ans = 0;
    REP(i,N){
        ans += a[2 * i + 1];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N;
  	cin >> N;
  	vector<int> A(N);
  	for(int i=0; i<N; i++) cin >> A.at(i);
  
  	vector<int> B(N);
  	for(int i=0; i<N; i++) cin >> B.at(i);
  
  	vector<int> C(N-1);
  	for(int i=0; i<N-1; i++) cin >> C.at(i);
  
  	int total = 0;
  	for(int i=0; i<N; i++){
      total += B.at(A.at(i)-1);
      if( i >= 1 && A.at(i)-1 == A.at(i-1)) total += C.at(A.at(i)-2);
    }
  cout << total << endl;
}

Measured memory_bytes: 256
#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>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;

        vector<Int> x(N), y(N);
        for (int i = 0; i < N; ++i) {
            cin >> x[i] >> y[i];
        }

        vector<Int> perm;
        for (int i = 0; i < N; ++i) {
            perm.push_back(i);
        }

        double ans = 0;
        do {
            double tmp = 0;
            for (int i = 0; i + 1 < N; ++i) {
                double d = sqrt(pow(x[perm[i + 1]] - x[perm[i]], 2) + pow(y[perm[i + 1]] - y[perm[i]], 2));
                tmp += d;
            }
            ans += tmp;
        } while (next_permutation(all(perm)));

        Int div = 1;
        for (int i = 1; i <= N; ++i) {
            div *= i;
        }

        ans /= div;

        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
long long a[111111];
long long b[111111];
long long res=0;
int main()
{
	int n; 
	cin>>n;
	for(int i=0;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
		if(b[i]>=a[i])
		{
			res+=a[i];
			b[i]=b[i]-a[i];
			res+=min(a[i+1],b[i]);
			a[i+1]=max(a[i+1]-b[i],(long long)0);
			
		}
		else
		{
			res+=b[i];
		}	
		
	}
	cout<<res;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define Mod (1000000000+7)
int main(void)
{
  int n, m;
  long long ans = 1;
  scanf("%d %d", &n, &m);

  if(abs(n-m) > 1){
    printf("0\n");
    return 0;
  }
  if(n == m){
    while(n != 1){
      ans *= n;
      ans %= Mod;
      n--;
    }
    printf("%d\n", (ans * ans * 2)%Mod);
  }
  else{
    while(n != 1){
      ans *= n;
      n--;
      ans %= Mod;
    }
    while(m != 1){
      ans *= m;
      m--;
      ans %= Mod;
    }
    printf("%d\n", ans%Mod);
  }
  return 0;
}

Measured memory_bytes: 128
def hantei(n, m, l, d ):
    if (n*500+m*100+l*50)==d:
#        print("GO n,m,l",n,m,l)
        return True
    return False

a = int(input()) #five
b = int(input()) #hund
c = int(input()) #fift
d = int(input()) #

n=m=l=0
result=0

while(n <= a):
    while(m <= b):
        while(l <= c):
            # print("n,m,l",n,m,l)
            if hantei(n,m,l,d)==True:
                result += 1
            l+=1
        l=0
        # if hantei(n,m,l,d)==True:
        #     result += 1
        m+=1
    # if hantei(n,m,l,d)==True:
    #     result += 1
    m=l=0
    n+=1

print(result)



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

bool is_valid(vector<pair<int, int>> l)
{
    int sum = 0;
    for (auto &&p : l)
    {
        if (sum + p.first < 0)
        {
            return false;
        }
        sum += p.second;
    }
    return true;
}

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }

    int total = 0;
    vector<pair<int, int>> inc;
    vector<pair<int, int>> dec;
    for (int i = 0; i < N; i++)
    {
        int mn = 0;
        int d = 0;
        for (int j = 0; j < S.at(i).size(); j++)
        {
            int c = (S.at(i).at(j) == '(') ? 1 : -1;
            d += c;
            mn = min(mn, d);
        }
        total += d;
        if (d < 0)
        {
            dec.push_back(make_pair(mn - d, -d));
        }
        else
        {
            inc.push_back(make_pair(mn, d));
        }
    }
    sort(inc.rbegin(), inc.rend());
    sort(dec.rbegin(), dec.rend());
    if (total == 0 && is_valid(inc) && is_valid(dec))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 50032