akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
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); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


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

    int n, k;
    cin >> n >> k;

    vector<int> a(n+1);
    vector<vector<int> > table(64, vector<int>(n+1, -1));

    reps(i, 1, n){
        cin >> a[i];
        table[0][i] = a[i];
    }

    rep(j, 63){
        reps(i, 1, n){
            if(table[j][i] == -1){
                table[j+1][i] = -1;
            }else{
                table[j+1][i] = table[j][table[j][i]];
            }
        }
    } 

    int res = 1;

    for(int i = 63; i >= 0; --i){
        if(k & 1ll << i){
            res = table[i][res];
        }
    }

    cout << res << '\n';

    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int alph[30] = {};
	for (int i = 0; i < s.size(); ++i) alph[s[i] - 'a']++;

	int i;
	for (i = 0; i < 26; ++i) {
		if (alph[i] == 0) {
			cout << (char)(i + 'a') << endl;
			break;
		}
	}
	if (i == 26) {
		cout << "None" << endl;
	}
}

Measured memory_bytes: 3256
from collections import deque
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
K = [0 for _ in range(N)]
INF = 10 ** 9
def bfs(n):
    d = deque()
    d.append(n)
    reached = [INF for _ in range(N)]
    reached[n] = 0
    dx = [-1, 1]
    while d:
        x = d.popleft()
        for i in range(2):
            nx = x + dx[i]
            if nx < 0 or nx > N - 1 or reached[nx] != INF:
                continue
            d.append(nx)
            reached[nx] =reached[x] + 1
        if x == X and reached[Y] == INF:
            reached[Y] = reached[x] + 1
            d.append(Y)
        if x == Y and reached[X] == INF:
            reached[X] = reached[x] + 1
            d.append(X)
    for i in range(N):
        K[reached[i]] += 1            

for i in range(N):
    bfs(i)

for i in range(1, N):
    print(K[i]//2)

Measured memory_bytes: 52956
n, m = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
assert len(h) == n
h = [0] + h
bad = set()
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    if h[a] == h[b]:
        bad |= {a, b}
    elif h[a] < h[b]:
        bad |= {a}
    else:
        bad |= {b}
print(n - len(bad))


Measured memory_bytes: 20040
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

string S[2];
char buf[114154];
int imos[2][114514][2];
int as[2];
int bs[2];
int res[2];
int Q;

int main() {
  rep(i, 2) {
    scanf("%s", buf);
    S[i] = buf;
    int N = strlen(buf);
    rep(j, N) {
      rep(k, 2) imos[i][j+1][k] = imos[i][j][k];
      imos[i][j+1][S[i][j]-'A']++;
    }
  }

  scanf("%d", &Q);
  rep(i, Q) {
    rep(j, 2) {
      int l, r;
      scanf("%d%d", &l, &r);
      --l;
      as[j] = imos[j][r][0] - imos[j][l][0];
      bs[j] = imos[j][r][1] - imos[j][l][1];
      res[j] = (as[j] + bs[j]*2)%3;
    }

    if (res[0] == res[1]) puts("YES");
    else puts("NO");
  }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

template<class Abel> struct UnionFind {
   vector<int> par,rank;
   vector<Abel> diff_weight;
   UnionFind(int n=1,Abel SUM_UNITY=0){init(n, SUM_UNITY);}
   void init(int n=1,Abel SUM_UNITY=0) {
      par.resize(n); rank.resize(n); diff_weight.resize(n);
      rep(i,0,n)par[i]=-1,rank[i]=0,diff_weight[i]=SUM_UNITY;
   }
   int root(int x){
      if(par[x]<0)return x;
      int r=root(par[x]); diff_weight[x]+=diff_weight[par[x]];
      return par[x]=r;
   }
   int size(int x){ return -par[root(x)]; }
   Abel weight(int x){root(x); return diff_weight[x];}
   bool issame(int x, int y){return root(x)==root(y);}
   bool merge(int x,int y,Abel w){
      w+=weight(x)-weight(y); x=root(x); y=root(y);
      if(x==y)return false;
      if(rank[x]<rank[y])swap(x,y),w=-w;
      if(rank[x]==rank[y])++rank[x];
      par[x]+=par[y]; par[y]=x; diff_weight[y]=w; return true;
   }
   Abel diff(int x,int y){return weight(y)-weight(x);}
};

int main(){
   int n,q; scanf("%d%d",&n,&q);
   UnionFind<int> uni(n);
   rep(i,0,q){
      int t,u,v; scanf("%d%d%d",&t,&u,&v);
      if(t==0)uni.merge(u,v,1);
      else printf("%d\n",uni.issame(u,v));
   }
   return 0;
}

Measured memory_bytes: 5528
#include<cstdio>
int main()
{
    char s[20];
    scanf("%s",s);
    for(int i=0;i<4;i++) printf("%c",s[i]);
    printf(" ");
    for(int i=4;i<12;i++) printf("%c",s[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mm[1000005];
int tot[1000005];
bool comp1(int x,int y)
{
  return mm[x]>mm[y];
}
bool comp2(int x,int y)
{
  return tot[x]-mm[x]>tot[y]-mm[y];
}

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

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif

  int n;
  cin>>n;
  string a[n];
  vector<int>x,y;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    int len=a[i].length();
    int cur=0,mn=0;
    for(int j=0;j<len;j++)
    {
      if(a[i][j]=='(')
        cur++;
      else
        cur--;
      mn=min(mn,cur);
    }
    tot[i]=cur;
    mm[i]=mn;
    if(cur>=0)
      x.push_back(i);
    else
      y.push_back(i);
  }  

  sort(x.begin(),x.end(),comp1);
  sort(y.begin(),y.end(),comp2);
  int ans=0;
  for(auto i:x)
  {
    if(ans+mm[i]<0)
    {
      cout<<"No";
      return 0;
    }
    ans+=tot[i];
  }

  for(auto i:y)
  {
    if(ans+mm[i]<0)
    {
      cout<<"No";
      return 0;
    }
    ans+=tot[i];
  }
  if(ans!=0)
    cout<<"No";
  else
    cout<<"Yes";

}


Measured memory_bytes: 58068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int x;
    cin >> x;
    if (x >= 1200){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
}



Measured memory_bytes: 256
import sys
import itertools

n, k = map(int, input().split())
comb = (n - 1) * (n - 2) // 2
if k > comb:
    print(-1)
    sys.exit()
s = set()
for i in range(2, n + 1):
    s.add((1, i))
count = 0
max_count = comb - k
for t in itertools.combinations(range(2, n + 1), 2):
    if count == max_count:
        break
    s.add(t)
    count += 1
print(len(s))
for i, j in s:
    print(i, j)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,A,min=1000000000;
  cin >> N;
  for(int i=0;i<N;i++){
    int ans=0;
    cin >> A;
    while(A%2==0){
      A/=2;
      ans++;
    }
  min=(ans<min?ans:min);
  }
  cout << min << endl;
}


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

int main(){
 int N;
 cin >> N;
 std::vector<pair<int,int>> pairs(N);
 for(int i = 0 ; i < N;i++){
   cin >> pairs.at(i).first >> pairs.at(i).second;
 }
 sort(pairs.begin(), pairs.end());
 
 //
 vector<vector<int>> as;
 for(int i = 0; i < N ;i++){
    for(int j = 0; j < N ;j++){
      if(i != j){
        int dx = pairs.at(j).first - pairs.at(i).first;
        int dy = pairs.at(j).second - pairs.at(i).second; 
        bool ret = false;
	    for(auto itr = as.begin() ; itr < as.end(); itr++){
          if((*itr).at(0) == dx && (*itr).at(1) ==dy){(*itr).at(2) +=1; ret = true;}
        }
        if(!ret){
          vector<int> a;
          a.push_back(dx);a.push_back(dy);a.push_back(1);
          as.push_back(a);
        }
      }
 	}
 }
 int max = 0;
 for(auto itr = as.begin() ; itr < as.end(); itr++){
     if((*itr).at(2) > max) {max = (*itr).at(2);}
 }
 
 cout << N - max << endl;
  
 return 0;
}


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

int main() {
  int N, Q;
  cin >> N >> Q;
  
  string S;
  cin >> S;
  
  
  vector<int> a(N, 0);
  for (int i = 1; i < N; i++) {
    if (S[i] == 'C' && S[i-1] == 'A') {
      a[i] = 1;
    }
  }
  
  vector<int> sum(N+1, 0);
  
  for (int i = 0; i < N; i++) {
    sum[i+1] = sum[i] + a[i];
  }
  
  
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    
    cout << sum[r] - sum[l] << endl;
  }
}

Measured memory_bytes: 4304
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0; i<N; i++){
      cin >> p[i];
    }
    long int sum = 0;
    for(int i=0; i<K; i++){
        sum += p[i];
    }
    long int max = sum;
    for(int i=1; i<N-K+1; i++){
        long int sum_2;
        sum_2 = sum - p[i-1] + p[i+K-1];
        sum = sum_2;
        if(sum_2 > max){
            max = sum_2;
        }
    }
    cout << fixed;
    cout << setprecision(7) << K/2.0 + max/2.0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  int64_t result = 0;
  vector<int64_t> H(N);

  rep(i, N) { cin >> H[i]; }
  sort(H.begin(), H.end());

  rep(i, N - K) { result += H[i]; }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main(){
	int N;
	int K;
	int count = 0;

	cin >> N >> K;

	int height[N];

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

	for(int i = 0; i < N; i++){
		if(height[i] >= K){
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

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

using namespace std;

int main(void){
    int N, K; cin >> N >> K;
    vector<pair<int, int>> DT;
    for(int i=0;i<N;++i){
        int t,d; cin >> t >> d;
        --t;
        DT.emplace_back(d,t);
    }
    sort(DT.begin(), DT.end(), greater<pair<int, int>>());

    unordered_set<int> t_check;

    vector<int> trash_box;
    long long su = 0;
    long long color_cnt = 0;

    for(int i=0;i<K;++i){
        int d,t; tie(d,t) = DT[i];
        su += d;
        if(t_check.count(t) == 1){
            trash_box.emplace_back(d);
        }
        else{
            t_check.insert(t);
        }
    }

    color_cnt = t_check.size();

    vector<int> nums;

    for(int i=K;i<N;++i){
        int d,t; tie(d,t) = DT[i];
        if(t_check.count(t) == 1) continue;
        nums.emplace_back(d);
        t_check.insert(t);
    }

    long long res = color_cnt * color_cnt + su;

    for(auto &num:nums){
        color_cnt++;
        if(trash_box.empty()) break;
        su -= trash_box.back();
        trash_box.pop_back();
        su += num;
        long long temp = color_cnt * color_cnt + su;
        if(temp > res) res = temp;
    }

    cout << res << endl;
}

Measured memory_bytes: 5364
A, B, K =map(int, input().split())
A_yaku = []
for i in range(1, int(A/2)+1):
    if A % i == 0:
        A_yaku.append(i)
A_yaku.append(A)
B_yaku = []
for i in range(1, int(B/2)+1):
    if B % i == 0:
        B_yaku.append(i)
B_yaku.append(B)
A_yaku = set(A_yaku)
B_yaku = set(B_yaku)

co_yaku = sorted(list(A_yaku & B_yaku))
for i in range(K):
    tmp = co_yaku.pop(-1)
print(tmp)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef int64_t Int;
const double pi = M_PI;

int main()
{
    while (true)
    {
        int n, x, c = 0, temp = 0;
        cin >> n >> x;
        if (n == 0 && x == 0)
        {
            break;
        }
        n++;

        /*
        総当たり
        - x以上のnは無視
        - 3重ループ
        */

        for (int i = 1; i < n; i++)
        {
            for (int j = 1; j < n; j++)
            {
                for (int k = 1; k < n; k++)
                {
                    if (j == i || k == j || k == i)
                    {
                        continue;
                    }

                    if ((i + j + k) == x)
                    {
                        c++;
                    }
                }
            }
        }

        cout << c / 6 << endl;
    }
}



Measured memory_bytes: 3088
n = gets.to_i
d = n.times.map { gets.split.map(&:to_i) }
# d = a.map(&:dup)
a = Array.new(n) { Array.new(n, true) }
n.times do |k|
  dk = d[k]
  n.times do |i|
    di = d[i]
    dik = di[k]
    ai = a[i]
    next if i == k
    (i + 1...n).each do |j|
      next if i == j || j == k
      tmp = dik + dk[j]
      if (dij = di[j]) > tmp
        puts -1
        exit
      elsif tmp == dij
        ai[j] = a[j][i] = false
      end
    end
  end
end
ans = 0
n.times do |i|
  (i + 1...n).each do |j|
    ans += d[i][j] if a[i][j]
  end
end
p ans


Measured memory_bytes: 5884
def dfs(n, r, now, a, c)
  a |= 1<<now
  if a>= 2**n-1 then
    return 1
  end
  c+=1
  if c>=n then
    return 0
  end
  sum = 0
  r[now].each{|nex|
    sum += dfs(n, r, nex, a, c)
  }
  return sum
end

n,m = gets.split.map(&:to_i)
r = n.times.map{[]}
m.times{
  a,b=gets.split.map(&:to_i)
  r[a-1] << b-1
  r[b-1] << a-1
}

p dfs(n, r, 0, 0, 0)




Measured memory_bytes: 1788
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }
        int[] ans = new int[n+1];
        int m = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = n; i > 0; i--) {
            int d = n / i;
            int c = a[i];
            for (int j = 2; j <= d; j++) {
                c ^= ans[i*j];
            }
            ans[i] = c;
            if(c == 1){
                m++;
                sb.append(i + " ");
            }
        }
        System.out.println(m);
        if(0 < m){
            System.out.println(sb.toString().trim());
        }
        sc.close();

    }

}


Measured memory_bytes: 95428
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve(){
	while (true) {
		int a;
		string b;
		cin >> a >> b;
		if (a == 0) return;
		vector<vector<string>> inputs;
		int now_ans = 0;
		REP(i, (1 << (b.length()  - 1))) {
			int hoge = i + (1 << (b.length()-1));
			vector<string> calc;
			string tmp;
			REP(q, b.length()) {
				tmp.push_back(b[q]);
				if (hoge % 2) {
					calc.push_back(tmp);
					tmp.clear();
				}
				hoge /= 2;
			}
			int geko = 0;
			REP(i, calc.size()) {
				geko += stoll(calc[i]);
			}
			if (geko > a) continue;
			if (geko > now_ans) {
				inputs.clear();
				now_ans = geko;
			}
			if (geko == now_ans) {
				inputs.push_back(calc);
			}
		}
		if (now_ans == 0) {
			cout << "error" << endl;
		}
		else if (inputs.size() >= 2) {
			cout << "rejected" << endl;
		}
		else {
			cout << now_ans;
			REP(i, inputs[0].size()) {
				cout << " " << inputs[0][i];
			}
			cout << endl;
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>

using namespace std;

int main(){
  string S;
  cin >> S;
  int win = 0;
  for (int i=0; i<S.size(); i++){
    if (S[i] == 'o') win++;
  }
  cout << (win + (15 - S.size()) >= 8 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b; cin >> a >> b;
  if(a >12){
    cout << b;
  }else if(a<13 && a > 5){
    cout << b/2;
  }else{
    cout << 0;
  }
  
  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int x, t;
  cin >> x >> t;
  cout << max(0ll, x-t) << endl;

  return 0;
}


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

using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,q,T,k;


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    cin >> n >> m;
    ll ans = 0;
    ll prev = 0;
    for(ll c1 = 0; c1 < n; c1++){
        cin >> a;
        if(c1 > 0){

            ans += min(m , a-prev);

        }
    prev = a;
    }
    ans += m;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#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>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
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)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  long a[n];
  rep(i,n)cin >> a[i];
  long ans=a[0]-1;
  long x=2;
  REP(i,1,n){
    if(a[i]==x){
      x=a[i]+1;
      continue;
    }
    ans+=max((a[i]+x-1)/x-1,0L);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define debug(a) cout << a << endl
using namespace std;

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

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int bignumlen = 2200;
const int Blen = 8;
const ll base = 100000000;
const int baseHash = 31;
const ld PI = acos(-1);

//Remember limit for IT, etc...
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;

ll n;

void solveProblem() {
    ll ans = n / 500 * 1000;
    ll temp = n % 500;
    ans += temp / 5 * 5;
    cout << ans << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n;
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

m = 10000000000
for c in range(0, max(X, Y)*2+1, 2):
  a = max(X - c//2, 0) # to buy
  b = max(Y - c//2, 0) # to buy
  m = min(m, a*A + b*B + c*C)
print(m)

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n,ans;

ll incliment(ll x){
  if(x == 0) return 3;
  else if(x%10 == 7) return 10*incliment(x/10)+3;
  else return x+2;
}

bool is753(ll x){
  bool is7 = false;
  bool is5 = false;
  bool is3 = false;
  while(x > 0){
    if(x%10 == 7) is7 = true;
    if(x%10 == 5) is5 = true;
    if(x%10 == 3) is3 = true;
    x /= 10;
  }
  return is7 && is5 && is3;
}

int main(){
  cin >> n;
  for(ll x = 0;x <= n;x = incliment(x)){
    // cerr << x << endl;
    if(is753(x)) ans++;
  }
  cout << ans << endl;


}


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

int main(){
  int N;
  cin >> N;
  int ans = 1;
  int i = 1;
  
  while(i<N){
    ans = i*i;
    if(ans > N){
      break;
    }
    i++;
  }
  
  if(N == 1){
    cout << N << endl;
  }
  else{
    cout << (i-1)*(i-1) << endl;
  }
}

Measured memory_bytes: 256
import itertools
import math
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
p = []
cnt = 0

for v in itertools.permutations(xy, N):
    p.append(v)

ans = 0
for i in range(len(p)):
    for j in range(N - 1):
        ans += math.sqrt((p[i][j][0] - p[i][j + 1][0]) ** 2 + (p[i][j][1] - p[i][j + 1][1]) ** 2)

print(ans / len(p))

Measured memory_bytes: 7984
#!/usr/bin/env python
# coding: utf-8

# In[1]:


N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))


# In[2]:


answer = 0

for i in range(N):
    if (V[i] - C[i]) >= 0:
        answer = answer + (V[i] - C[i])
        
print(answer)



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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL
#define maxN 2000007

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vll>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int& a, const int& b) {return a > b;}

ll num_len(ll n) {
    ll cnt = 0LL;
    while (n) {
        n /= 10LL;
        ++cnt;
    }
    return cnt;
}


int main() {
//    #ifndef ONLINE_JUDGE
//        freopen("tmp.inp", "r", stdin);
//        freopen("tmp.out", "w", stdout);
//    #endif // ONLINE_JUDGE

    ll n;
    scanf("%lld", &n);

    ll ans = OO;
    for (ll i = 1LL; i <= (ll)sqrtl(n); ++i) {
        if (n%i == 0LL) {
            ans = min(ans, max(num_len(i), num_len(n/i)));
        }
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    ll n = s.size();
    vector<ll> a(n);
    ll hash = 0;
    rep(i,0,n){
        ll t = s[i] - 'a';
        hash ^= (1LL << t);
        a[i] = hash;
    }
    debug(a);
    vector<ll> dp(n+1, INF);
    dp[0] = 0;
    map<ll, ll> mp;
    mp[0] = 0;
    rep(i,0,n){
        ll h = a[i];
        rep(j,0,26){
            if(mp.count((1LL << j) ^ h) == 0)continue;
            chmin(dp[i+1], mp[(1LL << j) ^ h] + 1);
        }
        if(mp.count(h))chmin(dp[i+1], mp[h] + 1);
        if(mp.count(h))chmin(mp[h], dp[i+1]);
        else mp[h] = dp[i+1];
    }
    debug(dp);
    cout << dp[n] << endl;
}

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

int main() {
	int n; cin >> n;
	int alllen = 0, maxlen = 0;
	for (int i = 0; i < n; ++i) {
		int input; cin >> input;
		alllen += input;
		maxlen = maxlen > input ? maxlen : input;
	}
	cout << ((maxlen < alllen - maxlen) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <set>
#include <iostream>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

LL n, a, b, c, d;
int main()
{
	while(scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d) != EOF)
	{
		bool flag = 0;
		for(int i = 0; i < n; i++)
			if((c * (n - 1 - i) - d * i <= b - a) && (b - a <= (n - 1 - i) * d - c * i))
				flag = 1;
		if(flag == 1) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

#define debug(x) cerr << fixed << #x << " = " << x << endl;
#define ll long long

ll mmc(int a, int b)
{
	return 1ll * a * b / __gcd(a, b);
}

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

	int n, m;
	string s, t;
	cin >> n >> m >> s >> t;

	ll ans = mmc(n, m);
	const ll inc_n = ans / m, inc_m = ans / n;
	bool ok = 1;
	for(ll nn = 0, mm = 0; nn < n && mm < m; nn += inc_n, mm += inc_m)
		ok &= (s[nn] == t[mm]);
	cout << (ok ? ans : -1) << endl;

	return 0;
}


Measured memory_bytes: 640
s1, s2, s3 = str(input())
if s1 == "R":
  if s2 == "S":
    result = 1
  else:
    if s3 == "S":
      result = 2
    else:
      result = 3
else:
  if s2 == "S":
    if s3 == "S":
      result = 0
    else:
      result = 1
  else:
    if s3 == "S":
      result = 1
    else:
      result = 2

print(result)

Measured memory_bytes: 9112
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
const LL MOD = 1000000007;
static const size_t MAX_N = 200050;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll& r) { return (x + r.x) % MOD; }
	modll operator+=(const modll & r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll & r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll & r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll & r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll & r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	modll dp[2] = { 0,1 };
	for (char c : s) {
		modll next[2] = { 0,0 };
		if (c == '0') {
			next[0] = dp[0] * 3;
			next[1] = dp[1];
		} else {
			next[0] = dp[0] * 3 + dp[1];
			next[1] = dp[1] * 2;
		}
		dp[0] = next[0];
		dp[1] = next[1];
	}
	modll ans = dp[0] + dp[1];
	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

const int maxn = 100100;
const int maxp = 101;
const int maxps = 200100;

bool prime[maxps];
int n,p;

int main()
{
    prime[0] = 1; prime[1] = 1;
    for(int i=2;i<maxps;i++)if(prime[i]==0)
        for(int j=i*2;j<maxps;j+=i) prime[j]=1;

    vector<int> plist;
    REP(maxps)if(!prime[i])plist.push_back(i);
    int psize = plist.size();
    //REP(psize) cout << plist[i] << endl;
    while(cin>>n >> p &&!(n==-1 && p == -1))
    {
        vector<int> m;
        int start=0;
        REP(psize) if(plist[i] > n){start = i;break;}
        
        for(int i=start;i<=start+100;i++)for(int j=i;j<=start+100;j++)
            m.push_back(plist[i]+plist[j]);


        sort(m.begin(),m.end());
        
        //REP(10) cout << m[i]<<endl;
        cout << m[p-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1308
from collections import deque
n=int(input())
arr=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    arr[a-1].append([b-1,i])
    arr[b-1].append([a-1,i])

que=deque([0])
ans=[0]*(n-1)
par=[0]*n
par[0]=-1
while que:
    x=que.popleft()
    p=par[x]
    color=1
    for tup in arr[x]:
        if p==color:
            color+=1
        if ans[tup[1]]==0:
            ans[tup[1]]=color
            par[tup[0]]=color
            color+=1
            que.append(tup[0])
print(max(ans))
print(*ans,sep='\n')

Measured memory_bytes: 82592
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>

#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>

#include <memory.h>
#include <cassert>
#include <time.h>
#include <functional>

using namespace std;

#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;

const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;

#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif

void prepare(string s) {
#ifdef MY_DEBUG
  freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#endif
}

int a, b, c, d;

void read() {
  scanf("%d %d %d %d", &a, &b, &c, &d);
  printf("%d\n", min(a, b) + min(c, d));
}

void solve() {

}

int main() {
  prepare("");

  read();
  solve();
  dbg("Clock = %.3f\n", clock() / (double)CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
k = inp[0]
even = k/2
odd = k-k/2
p odd*even

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, M, D;
  cin >> N >> M >> D;

  LL X = (N - D) * (D == 0 ? 1 : 2);
  cout << fixed << setprecision(9) << X * (M-1) * 1. / N / N << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2;
}
    

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  //  freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in", "r", stdin);freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out", "w", stdout);
    
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 256
# encoding: utf-8
N = int(input())

def count(pos, val, stat):
    ret = 0
    for i, num in enumerate([3, 5, 7]):
        if val + num * (10 ** pos) <= N: # oh...
            stat_tmp = stat | (1 << i)
            if stat_tmp == 7: ret += count(pos + 1, val + num * (10 ** pos), stat_tmp) + 1
            else: ret += count(pos + 1, val + num * (10 ** pos), stat_tmp)
        else: break
    return ret

print(count(0, 0, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*



*/


void solve(){

    string s;
    cin >> s;

    if(s == "SUN") cout << 7 << endl;
    if(s == "MON") cout << 6 << endl;
    if(s == "TUE") cout << 5 << endl;
    if(s == "WED") cout << 4 << endl;
    if(s == "THU") cout << 3 << endl;
    if(s == "FRI") cout << 2 << endl;
    if(s == "SAT") cout << 1 << endl;
    

}

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    for i in range(1, 1000+1):
        if int(i * 0.08) == A and int(i * 0.1) == B:
            return i
    return -1


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6848
a = list(input())
b = list(input())
c = list(input())
x = a.pop(0)
while True:
  if x == "a":
    if not a:
      print("A")
      break
    x = a.pop(0)
  if x == "b":
    if not b:
      print("B")
      break
    x = b.pop(0)
  if x == "c":
    if not c:
      print("C")
      break
    x = c.pop(0)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, M;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  vector<Tapris> edge;
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    edge.emplace_back(-c, a, b);
  }
  sort(all(edge));
  vint dist(N, inf);
  dist[0] = 0;
  vector<int> nodes;
  rep(i, N) {
    //cout<<i<<endl;
    for(Tapris e : edge) {
      int u, v, c;
      tie(c, u, v) = e;
      if(dist[u] != inf && dist[u]+c < dist[v]) {
	//cout<<u<<" "<<v<<" "<<dist[u]+c<<endl;
	dist[v] = dist[u]+c;
	if(i == N-1) nodes.push_back(v);
      }
    }
  }
  if(nodes.empty()) {
    cout << -dist[N-1] << endl;
    return 0;
  }
  vector<bool> neg1(N, false);
  vector<bool> neg2(N, false);
  for(int v : nodes) {
    neg1[v] = neg2[v] = true;
  }
  rep(i, N) {
    for(Tapris e : edge) {
      int u, v, c;
      tie(c, u, v) = e;
      if(neg1[v] && !neg1[u]) neg1[u] = true;
      if(neg2[u] && !neg2[v]) neg2[v] = true;
    }
  }
  if(neg1[0] && neg2[N-1]) cout << "inf" << endl;
  else cout << -dist[N-1] << endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;
//267630EY
public class Main
{
  static PrintWriter out=new PrintWriter(System.out);

  public static void main(String[] args) throws IOException
  {
    
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int[] a=sc.nextIntArray(n);
    int[] dp=new int[n+1];
    
    dp[0]=0;
    dp[1]=0;
    dp[2]=Math.abs(a[1]-a[0]);
    for(int i=3;i<=n;i++)
    {
      int minValue=Integer.MAX_VALUE;
      for(int j=1;j<=k&&i>j;j++)
      {
        minValue=Math.min(minValue,dp[i-j]+Math.abs(a[i-1]-a[i-j-1]));
      }
      dp[i]=minValue;
    }
    out.println(dp[n]);
    out.flush();

        
   
      
      
                
    
  }
  
  static class Scanner
  {
    BufferedReader br;
    StringTokenizer tk=new StringTokenizer("");
    public Scanner(InputStream is) 
    {
      br=new BufferedReader(new InputStreamReader(is));
    }
    
    public boolean hasNext()
    {
      

      boolean result=false;
      
      try 
      {
        result = br.ready();
      } 
      catch (IOException e)
      {
        System.err.println(e);
      }
      return result;
    }
    
    public int nextInt() throws IOException
    {
      if(tk.hasMoreTokens())
        return Integer.parseInt(tk.nextToken());
      tk=new StringTokenizer(br.readLine());
      return nextInt();
    }
    public long nextLong() throws IOException
    {
      if(tk.hasMoreTokens())
        return Long.parseLong(tk.nextToken());
      tk=new StringTokenizer(br.readLine());
      return nextLong();
    }
    public String next() throws IOException
    {
      if(tk.hasMoreTokens())
        return (tk.nextToken());
      tk=new StringTokenizer(br.readLine());
      return next();
    }
    public String nextLine() throws IOException
    {
      tk=new StringTokenizer("");
      return br.readLine();
    }
    public double nextDouble() throws IOException
    {
      if(tk.hasMoreTokens())
        return Double.parseDouble(tk.nextToken());
      tk=new StringTokenizer(br.readLine());
      return nextDouble();
    }
    public char nextChar() throws IOException
    {
      if(tk.hasMoreTokens())
        return (tk.nextToken().charAt(0));
      tk=new StringTokenizer(br.readLine());
      return nextChar();
    }
    public int[] nextIntArray(int n) throws IOException
    {
      int a[]=new int[n];
      for(int i=0;i<n;i++)
        a[i]=nextInt();
      return a;
    }
    public long[] nextLongArray(int n) throws IOException
    {
      long a[]=new long[n];
      for(int i=0;i<n;i++)
        a[i]=nextLong();
      return a;
    }
    public int[] nextIntArrayOneBased(int n) throws IOException
    {
      int a[]=new int[n+1];
      for(int i=1;i<=n;i++)
        a[i]=nextInt();
      return a;
    }
    public long[] nextLongArrayOneBased(int n) throws IOException
    {
      long a[]=new long[n+1];
      for(int i=1;i<=n;i++)
        a[i]=nextLong();
      return a;
    }
  }
}



Measured memory_bytes: 36320
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n;i++)
main() {
	int t, n,p;priority_queue<int> pq;
	cin >> n >> t;vector<int> x(t);
	if (n >= t) {
		cout << 0 ;
		return 0;
	}
	rep(i, t) cin >> x[i];
	sort(x.begin(), x.end());
	rep(i, t - 1) pq.push(x[i + 1] - x[i]);
	p = x[t - 1] - x[0];
	rep(i, n - 1) {
		p -= pq.top();pq.pop();
	}
	cout << p ;
}

Measured memory_bytes: 1276