akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	ll N, K;
	cin >> N >> K;
	vl A(N);
	vl Asum(N + 1);
	Asum[0] = 0;
	rep(i, N) {
		cin >> A[i];
		A[i]--;
		Asum[i + 1] = Asum[i] + A[i];
		Asum[i + 1] %= K;
	}
	map<ll, ll> Alist;
	ll ans = 0;
	rep(i, N + 1) {
		ll Asumtmp = Asum[i];
		Alist[Asumtmp]++;
		if (i >= K) {
			ll Asumold = Asum[i - K];
			Alist[Asumold]--;
		}
		ll anstmp = Alist[Asumtmp] - 1;
		ans += anstmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

ll f(ll b,ll n){
    if(n<b)return n;
    return f(b,n/b)+n%b;
}

bool isOK(ll n,ll s,ll b){
    return f(b,n)==s;
}

int main(){
    ll n,s;
    cin>>n>>s;
    if(n<s){
        cout<<-1<<endl;
        return 0;
    }
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    for(ll i=2;i*i<=n;i++){
        if(isOK(n,s,i)){
            cout<<i<<endl;
            return 0;
        }
    }
    ll ans=1e18;
    for(ll i=1;i*i<n;i++){
        ll b=(n-s)/i+1;
        if(b==1)continue;
        if(isOK(n,s,b)){
            ans=min(ans,b);
        }
    }
    if(ans==1e18)cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
class Combination{
public:
  typedef long long ll;
  ll N;
  ll mod;
  vector<ll> fac;
  vector<ll> finv;
  vector<ll> inv;
  
  
  Combination(ll N = 1e6,ll mod = 1e9 + 7): N(N), mod(mod), fac(N+1), finv(N+1), inv(N+1){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(Int i = 2; i <= N; i++){
      fac[i] = fac[i-1] * i % mod;
      inv[i] = mod - inv[mod%i] * (mod / i) % mod;
      finv[i] = finv[i-1] * inv[i] % mod;
    }
  }

  function<ll(ll,ll)> get = [&](ll n,ll r){
    if( n < r ) return 0LL;
    if( n < 0 || r < 0) return 0LL;
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod;
  };
};
auto nCr = (new Combination())->get;


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

  vector<Int> p(1000000);
  p[0] = 1;
  for(Int i=1;i<(Int)p.size();i++) p[i] = p[i-1] * 3 % mod;
  Int N, M, K;
  cin>>N>>M>>K;
  vector<Int> cnt(N+M+K+10);
  {
    cnt[0] = 1;
    for(Int i=0;i<(Int)cnt.size()-1;i++){
      cnt[i+1] = cnt[i]*2 - nCr(i, M) - nCr(i, K);
      cnt[i+1] = (cnt[i+1] + 10*mod) % mod;
    }
  }

  Int ans = 0;
  for(Int X = N; X <= N+M+K; X++){
    ans += nCr(X-1, N-1) * cnt[X-N] % mod * p[N+M+K - X]%mod;
    ans %= mod;
  }
   
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 38528
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			ArrayList<String> names = new ArrayList<String>();
			int[] prices = new int[n];
			for(int i = 0; i < n; i++){
				names.add(sc.next());
				prices[i] = sc.nextInt();
			}
			
			final int m = sc.nextInt();
			
			Map<Integer, HashSet<Integer>> map = new HashMap<Integer, HashSet<Integer>>();
			Map<String, HashSet<String>> map_err = new HashMap<String, HashSet<String>>();
			for(int i = 0; i < m; i++){
				int from = 0;
				String fo = sc.next();
				{
					int count = 0;
					
					for(String name : names){
						if(name.equals(fo)){
							break;
						}else{
							count++;
						}
					}
					
					from = count;
				}
				
				if(from == n){
					continue;
				}
				
				final int num = sc.nextInt();
				
				HashSet<Integer> set = new HashSet<Integer>(num);
				HashSet<String> set_err = new HashSet<String>(num);
				
				for(int j = 0; j < num; j++){
					final String in = sc.next();
					int count = 0;
					
					for(String name : names){
						if(name.equals(in)){
							break;
						}else{
							count++;
						}
					}
					
					if(count != n){
						set.add(count);
						set_err.add(in);
					}
				}
				
				if(set.size() != 0){
					map.put(from, set);
					map_err.put(fo, set_err);
				}
			}
			
			boolean updated = false;
			for(int i = 0; i < m; i++){
				for(Map.Entry<Integer, HashSet<Integer>> entry : map.entrySet()){
					int sum = 0;
					for(int p : entry.getValue()){
						try{
							sum += prices[p];
						}catch(ArrayIndexOutOfBoundsException e){
							//throw new RuntimeException(names + "\n" + map_err + "\n" + names.get(entry.getKey()));
						}
					}
					
					if(prices[entry.getKey()] > sum){
						prices[entry.getKey()] = sum;
						updated = true;
					}
				}
				
				if(!updated){
					break;
				}else{
					updated = false;
				}
			}
			
			final String out = sc.next();
			int count = 0;
			for(String str : names){
				if(str.equals(out)){
					break;
				}else{
					count++;
				}
			}
			
			System.out.println(prices[count]);
		}
		
	}

}

Measured memory_bytes: 25036
import java.util.*;
import java.io.*;

class Main {


  

  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = in.nextInt();
    int W = in.nextInt();
    int[] w = new int[N];
    int[] v = new int[N];
    int sum = 0;
    for (int i = 0; i < N; i++) {
      w[i] = in.nextInt();
      v[i] = in.nextInt();
      sum += v[i];
    }

    long INF = (long) 10e15;

    // dp[i]: the min weight for a knapsack with tt value of i
    long[] dp = new long[sum + 1];
    Arrays.fill(dp, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
      for (int value = sum; value >= v[i]; value--) {
        dp[value] = Math.min(dp[value], dp[value - v[i]] + w[i]);
      }
    }

    for (int i = sum; i > -1; i--) {
      if (dp[i] <= W) {
        System.out.println(i);
        break;
      }
    }
  }

}

Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int INFINITY_HAHA = 999999;

typedef struct edge
{
    int to, limit;
    double dist;
    edge(int x, double y, int z): to(x), dist(y), limit(z) {}
} Edge;


typedef struct status {
    int from, now, speed;
    double time;
    status(int x, int x2, double y, int z): from(x), now(x2), time(y), speed(z) {}
    bool operator< (const status &b) const {
        return time > b.time;
    }
} Status;



int main() {
    // freopen("input.txt", "r", stdin);
 
    int ncities, nroads;
    double d[35][35][35];

    while(scanf("%d%d", &ncities, &nroads) != EOF && !(ncities == 0 && nroads == 0)) {

        // Input
        int start_index, end_index;
        scanf("%d%d" , &start_index, &end_index);

        vector<Edge> paths[100]; // Array of vector
        for(int n = 0; n < nroads; ++n) {
            int x, y, d, c;
            scanf("%d%d%d%d", &x, &y, &d, &c);
            paths[x].push_back(Edge(y, d, c));
            paths[y].push_back(Edge(x, d, c));
        }

        for(int i = 0; i < 35; ++i) {
            for(int j = 0; j < 35; ++j) {
                for(int k = 0; k < 35; ++k) {
                    d[i][j][k]= INFINITY_HAHA;
                }
            }
        }

        double minimun_v = 0;
        priority_queue< Status> Q;
        for(int i = 0; i < paths[start_index].size(); ++i) {
            Edge e = paths[start_index][i];
            Q.push(Status(start_index, e.to, e.dist, 1));
            d[start_index][e.to][1] = e.dist;
        }

        while(!Q.empty()) {
            Status cs = Q.top();
            Q.pop();
 
            if(d[cs.from][cs.now][cs.speed] < cs.time) continue;

            if(cs.now == end_index && cs.speed == 1) {
                minimun_v = cs.time;
                break;
            }

            for(int j = 0; j < paths[cs.now].size(); ++j) {
                Edge s = paths[cs.now][j];
                if(s.to == cs.from) continue;

                for(int z = -1; z <= 1; ++z) {
                    if(cs.speed + z > 0 && cs.speed + z <= s.limit) {
                        double newdist = cs.time + s.dist/((double)(cs.speed + z));
                        if(newdist < d[cs.now][s.to][cs.speed + z]) {
                            d[cs.now][s.to][cs.speed + z] = newdist;
                            Q.push(Status(cs.now, s.to, newdist, cs.speed + z));
                        }
                    }
                }
            }
        }
 
        if(minimun_v) {
            printf("%0.5lf\n", minimun_v);
        } else {
            printf("unreachable\n");
        }
    }
 
    return 0;
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
#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, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) a--;
    if (t == u) b--;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 764
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
S = [input().rstrip() for _ in range(N)]
M = int(input())
T = [input().rstrip() for _ in range(M)]

from collections import defaultdict
dic = defaultdict(int)

for s in S:
    dic[s] += 1
for t in T:
    dic[t] -= 1

ans = 0
for v in dic.values():
    ans = max(ans, v)

print(ans)

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

int main(){
  int h,n,a;
  cin >> h >> n;
  a=0;
  for(int i=0;i<n;i++){
    int b;
    cin >> b;
    a+=b;
  }
  if(a<h){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
   int r;
   cin >> r;
   if (r < 1200) cout << "ABC\n";
   else if (r < 2800) cout << "ARC\n";
   else cout << "AGC\n";
   return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    int l, r;
    cin >> l >> r;
    int ans = 3000;
    for(int i = l; i < r; i++){
        for(int j = i+1; j <= r; j++){
            int t_i = i % 2019, t_j = j % 2019;
            int tmp = (t_i*t_j) % 2019;
            if(ans > tmp) ans = tmp;
            if(ans == 0) break;
        }
        if(ans == 0) break;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

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

    int n; cin>>n;
    ll res=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0) res+=i;
    }
    cout<<res<<endl;
    End;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
double eps=1e-8;
ll mod=1e9+7;
ll inf=1e9;
priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end() , l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

int main(){
  ll x,y;
  cin>>x>>y;
  if(x%y==0)cout<<-1<<endl;
  else cout<<x<<endl;
  return 0;
}


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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

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

    vector<int> A2 = A;
    sort(A2.rbegin(), A2.rend());

    for (int i=0; i<N; ++i) {
        if (A[i] == A2[0]) {
            cout << A2[1] << endl;
        } else {
            cout << A2[0] << endl;  
        }
    }

    return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

struct UnionFind
{
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}

  int root(int x)
  {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

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

  bool merge(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (par[x] > par[y])
      swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x)
  {
    return -par[root(x)];
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M, K;
  cin >> N >> M >> K;
  vector<set<int>> dame(N);
  UnionFind uf(N);
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    dame[a].insert(b);
    dame[b].insert(a);
    uf.merge(a, b);
  }
  for (int i = 0; i < K; i++)
  {
    int c, d;
    cin >> c >> d;
    c--, d--;
    if (!uf.isSame(c, d))
      continue;
    dame[c].insert(d);
    dame[d].insert(c);
  }

  for (int i = 0; i < N; i++)
  {
    int ans = uf.size(i) - 1; // 同じ連結成分の「自分以外」の人数
    ans -= dame[i].size();
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 24704
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){

  int n,i,k,j;
  double a[1005];
  double t,s;

  scanf("%d", &n);

  for(i = 0;i < n;i++) scanf("%lf", &a[i]);

  for(i = 0;i < n - 1;i++){
    for(j = n - 1;j > i;j--){
      if(a[j] < a[j - 1]){
        t = a[j]; a[j] = a[j - 1]; a[j - 1] = t;
      }
    }
  }

  for(i = 0;i < n - 1;i++){
    s = (double)(a[i] + a[i + 1])/2;
    a[i] = 0;
    k = i + 1;
    while(k < n - 1 && a[k + 1] < s) k++;

    for(j = k - 1;j > i;j--){
      t = a[j]; a[j] = a[j - 1]; a[j - 1] = t;
    }
    a[k] = s;
  }

  printf("%.9f\n", a[k]);

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>

const int N_MAX = 100000;

struct Process{
  char name[10];
  int time;
};

Process Queue[N_MAX]; //ring buffer
int head = 0,tail = 0;

bool isEmpty(){
  return head == tail;
}

void enqueue(Process x){
  Queue[tail] = x;
  if(tail + 1 == N_MAX){
    tail = 0;
  }else{
    tail++;
  }
}

Process dequeue(){
  Process x = Queue[head];
  if(head + 1 == N_MAX){
    head = 0;
  }else{
    head++;
  }

  return x;
}

int main(){
  int n,q,sum=0;
  Process p[N_MAX];
  
  std::scanf("%d %d",&n,&q);
  
  for(int i = 0;i < n;i++){
    std::scanf("%s %d",p[i].name,&(p[i].time));
    enqueue(p[i]);
  }

  while(!(isEmpty())){
    Process x = dequeue();
    if(x.time - q <= 0){
      std::printf("%s %d\n",x.name,x.time + sum);
      sum += x.time;
    }else{
      x.time -= q;
      enqueue(x);
      sum += q;
    }
  }
  
  return 0;
}


Measured memory_bytes: 5060
#include <iostream>

using namespace std;

int get_digit(int val)
{
    int res = 0;
    while (val > 0) {
	val /= 10;
	res++;
    }
    return res;
}

int main()
{
    int a, b;
    while (cin >> a >> b) {
	int sum = a + b;
	cout << get_digit(sum) << endl;
    }
    return 0;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
const auto inf=LLONG_MAX; 
int main() 
{
	fastio
	//t_case
	{
		ll sum=0,ans=0,n,m=0,mx=-inf,mn=inf,p,f ;//cin>> n ;
		ld d ,t ,s;
		cin>>d>>t>>s;
		if(t>=d/s) cout<<"Yes";
		else cout<<"No"; 
		//cout<<ans;	
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3736
import java.util.*;

public class Main{
    static final int MOD = 998244353;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long[] d = new long[n];
        int s = sc.nextInt();
        d[s]++;
        for (int i=1; i<n; i++){
            int t = sc.nextInt();
            d[t]++;
        }
        if (s!=0 || d[0]!=1){
            System.out.println(0);
            return;
        }

        long ans = 1;

        for (int i=0; i<n-1; i++){
            ans *= power(d[i], d[i+1]);
            ans %= MOD;
        }
        System.out.println(ans);

    }

    public static long power(long x, long n){
        long sum = 1;
        while (n>0){
            if ((n&1)==1){
                sum *= x;
                sum %= MOD;
            }
            x *= x;
            x %= MOD;
//            if (sum < 0) sum += MOD;
//            if (x < 0) x += MOD;
            n>>=1;
        }
//        return sum;
        return sum%MOD;
    }
}

Measured memory_bytes: 57340
n,m=map(int,input().split())
s=[[]for i in range(n+1)]
t=[1]*(n+1)
for i in range(m):
    a,b=map(int,input().split())
    s[a].append(b)
    s[b].append(a)
a,b=[],[]
p=1
t[1]=0
while 1:
    for i in s[p]:
        if t[i]:
            t[i]=0
            p=i
            a.append(i)
            break
    else:
        break
p=1
while 1:
    for i in s[p]:
        if t[i]:
            t[i]=0
            p=i
            b.append(i)
            break
    else:
        break
print(1+len(a)+len(b))
t=a[::-1]+[1]+b
print(*t)

Measured memory_bytes: 25132
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;	cin >> N;
	vector<int> v(101, 0);
	int gi;
	for (int i = 0; i < N; ++i){
		cin >> gi;
		++v[gi];
	}
	int d = 0, sgn = 1;
	for (int i = 100; i > 0; --i) {
		if (v[i] % 2 == 1){
			d = d + sgn * i;
			sgn = -sgn;
		}
	}
	cout << d << endl;
}


Measured memory_bytes: 256
n=gets.to_i
all=[]
for i in 0..n-1
    all<<gets.split.map(&:to_i)
end
all=all.sort{|k,v| k[1]<=>v[1]}

time=0
for i in 0..all.length-1
    v=all[i]
    time+=v[0]
    
    if time>v[1]
        puts "No"
        exit
    end
end

puts "Yes"

Measured memory_bytes: 32164
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p,
           std::vector<long long> q, std::vector<long long> r) {
  SORT_DESC(p);
  SORT_DESC(q);
  vector<int> d;
  rep(i, X) d.pb(p[i]);
  rep(i, Y) d.pb(q[i]);
  rep(i, C) d.pb(r[i]);
  SORT_DESC(d);
  ll a = 0;
  rep(i, X + Y) a += d[i];
  ANS(a);
}

// clang-format off
int main() {
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  std::vector<long long> p(A);
  for(int i = 0 ; i < A ; i++){
    scanf("%lld",&p[i]);
  }
  std::vector<long long> q(B);
  for(int i = 0 ; i < B ; i++){
    scanf("%lld",&q[i]);
  }
  std::vector<long long> r(C);
  for(int i = 0 ; i < C ; i++){
    scanf("%lld",&r[i]);
  }
  solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
  return 0;
}


Measured memory_bytes: 4724
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define maxn 100010
using namespace std;
char a[maxn];
int b[maxn],c[maxn];
int main(){
	int n;
	scanf("%s",a);
	n=strlen(a);
	for(int i=0;i<n;i++){
		if(a[i]=='L'){
			if(a[i-1]=='R'){
				c[i]=i-1;
			}
			else c[i]=c[i-1];
		}
	}
	for(int i=n-1;i>=0;i--){
		if(a[i]=='R'){
			if(a[i+1]=='L'){
				c[i]=i+1;
			}
			else c[i]=c[i+1];
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]=='L'){
			if((i-c[i])%2==0){
				b[c[i]]++;
			}
			else b[c[i]+1]++;
		}
		else{
			if((c[i]-i)%2==0){
				b[c[i]]++;
			}
			else b[c[i]-1]++;
		}
	}
	for(int i=0;i<n;i++) printf("%d ",b[i]);
    return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
       int a,b;
       int n,i;
       scanf("%d", &n);
       scanf("%d%d", &a, &b);
        
       for(i=a;i<=b;i++){
               if(i%n == 0){
                       printf("OK\n");
                       return 0;
               }
       }
       printf("NG\n");
       return 0;

       
}



Measured memory_bytes: 1660
n=int(input())
table=[]
for i in range(n):
  table.append([int(_) for _ in input().split()])
T=[[1]*n for i in range(n)]
import itertools
chk,ans=True,0
for Com in itertools.combinations(range(n),3):
  a,b,c=Com[0],Com[1],Com[2]
  lab,lbc,lca=table[a][b],table[b][c],table[c][a]
  if lab>=lbc and lab>=lca:
    if lab>lbc+lca:
      chk=False
    elif lab==lbc+lca:
      T[a][b],T[b][a]=0,0
  elif lbc>=lab and lbc>=lca:
    if lbc>lab+lca:
      chk=False
    elif lbc==lab+lca:
      T[b][c],T[c][b]=0,0
  elif lca>=lab and lca>=lbc:
    if lca>lab+lbc:
      chk=False
    elif lca==lab+lbc:
      T[c][a],T[a][c]=0,0
for i in range(n):
  for j in range(i+1,n):
    if T[i][j]==1:
      ans+=table[i][j]
print(ans if chk==True else -1)


Measured memory_bytes: 47324
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    string S = to_string(N);
    int digit = S.size();
    if (digit == 1) {
        write(N);
        return 0;
    }

    int L = 0, p = 1;
    rep(i, digit - 2) L += p, p *= 10;
    int A = S.front() - '0', B = S.back() - '0';
    int M = digit == 2 ? 0 : stoi(S.substr(1, digit - 2));
    // AMB

    ll ans = 0;
    rep(a, 1, 10) rep(b, 1, 10) {
        ll tmp1 = a == b ? 1 : 0;
        tmp1 += L;
        if (a < A) tmp1 += p;
        else if (a == A && b <= B) tmp1 += M + 1;
        else if (a == A && b > B) tmp1 += M;
        
        ll tmp2 = a == b ? 1 : 0;
        tmp2 += L;
        if (b < A) tmp2 += p;
        else if (b == A && a <= B) tmp2 += M + 1;
        else if (b == A && a > B) tmp2 += M;

        ans += tmp1 * tmp2;
    }

    write(ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

//mapの使い方
#include <map>
ll n,q;


int main(){
  ll ans=0;

  map<ll,ll> nums_x;
  map<ll,ll> nums_y;
  
  cin >> n >> q;
  ans=(n-2)*(n-2);
  nums_x[n]=n;
  nums_y[n]=n;

  ll a,b;

  REP(i,q) {
    cin>>a>>b;
    if (a==1)
    {
      auto iter=nums_y.lower_bound(b);
      ll doko=iter->second;
      ans-=doko-2;
      //cout<<(doko-2)<<endl;
      if (nums_x.find(doko)!=nums_x.end()){
        b=min(b,nums_x[doko]);
      }
      nums_x[doko]=b;
    }
    else
    {

      auto iter=nums_x.lower_bound(b);
      ll doko=iter->second;
      ans-=doko-2;
      //cout<<(doko-2)<<endl;
      
      if (nums_y.find(doko)!=nums_y.end()){
        b=min(b,nums_y[doko]);
      }
      nums_y[doko]=b;
    }
  }
    
/*
  cout<<endl;
  for (auto elem : nums_y)
  {
    cout<<elem.first<<" "<<elem.second<<endl;
  }
  cout<<endl;
  for (auto elem : nums_x)
  {
    cout<<elem.first<<" "<<elem.second<<endl;
  }
  */  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 9872
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  int n;
  cin >> n;
  if (n % 2 == 1) cout << (n / 2) + 1  << endl;
  else cout << (n / 2)   << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = [0] + list(map(int, input().split())) + [0]
    S = sum(abs(A[i] - A[i - 1]) for i in range(1, N + 2))

    for i in range(1, N + 1):
        l, r = min(A[i - 1], A[i + 1]), max(A[i - 1], A[i + 1])
        if l <= A[i] <= r:
            print(S)
        elif A[i] <= l:
            print(S - 2 * (l - A[i]))
        else:
            print(S - 2 * (A[i] - r))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14172
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define EPS 1e-6
#define INF 1000000000

// MAXIMIZAR f(x) == MINIMIZAR -f(x)
// It is easy to prove ... 

#define _ ios_base::sync_with_stdio(0), cin.tie(0), cin.tie(0), cout.tie(0), cout.precision(15);
#define FOR(i, a, b) for(int i=int(a); i<int(b); i++)
#define FORC(i, a, b) for(int i=int(a); i>=int(b); i--)
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << (#x) << " = " << x << "\n";
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

clock_t t_;

using namespace std;


template<class T> void print(T s){cout << s << "\n";}
template<class T> void emax(T &a, T b){a = (a<b ? b : a);};
template<class T> void emin(T &a, T b){a = (a>b ? b : a);}
template<class T> void printC(T s){ for(auto &x : s){cout << x << " ";} cout << "\n";}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define maxn 100005
#define mod 1000000007


int dp[maxn][3];

int main(int argc, const char * argv[]) {
     
    #ifdef input
    freopen("input.txt", "r", stdin);
    #endif
    #ifdef output
    freopen("output.txt", "w", stdout);
    #endif
    t_ = clock();
       
    int n;
    cin >> n;
    vector<vi> a(n+1, vi(3));
    dp[0][0] = dp[0][1] = dp[0][2] = 0;

    FOR(i,0,n){
    	FOR(j,0,3) cin >> a[i][j];
    }

    FOR(i,1,n+1){
    	FOR(j,0,3){
    		dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) + a[i-1][j];
    	}
    }

    print(max({dp[n][0], dp[n][1], dp[n][2]}));


    t_ = clock()-t_;
    cerr << setprecision(9) << fixed << ((float)t_ / CLOCKS_PER_SEC) << endl;

        
    return 0;
}





Measured memory_bytes: 6912
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

S = In.str()
T = In.str()

if T[0:len(T)-1]==S:
    Out.str("Yes")
else:
    Out.str("No")

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

int main() {
	int N;
	cin >> N;
	double ans = 0.0;
	for (int i = 0; i < N; ++i) {
		double x;
		cin >> x;
		string u;
		cin >> u;
		if (u == "BTC") ans += 380000.0 * x;
		else ans += x;
	}
	cout << ans;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<string> C(n);
  for(int i = 0; i < n; i++){
    cin >> C.at(i);
  }
  
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  
  for(string x : C){
    if(x == "AC") ac++;
    if(x == "WA") wa++;
    if(x == "TLE") tle++;
    if(x == "RE") re++;
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.a = sc.nextInt();
			o.b = sc.nextInt();
			arr[i] = o;
		}
		sc.close();

		Arrays.sort(arr, (o1, o2) -> o1.a - o2.a);
		int sum = 0;
		long ans = 0;
		for (Obj o : arr) {
			if (sum + o.b >= m) {
				ans += (long) o.a * (m - sum);
				break;
			} else {
				ans += (long) o.a * o.b;
				sum += o.b;
			}
		}
		System.out.println(ans);
	}

	static class Obj {
		int a, b;
	}
}


Measured memory_bytes: 88852
/*
C++14
iloveUtaha
seica
fumiphys
autumn_eel
FF256grhy


Python3 (3.4.3)
maspy

PyPy3 (2.4.0)
blcn
*/

#include <bits/stdc++.h>
using namespace std;

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

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

  if(b > n*a)
    cout << n*a << endl;
  else
    cout << b << endl;

  //cout << CX << " " << CY << " " << H << "\n";
  
}


Measured memory_bytes: 256
S = list(input())
if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2])or (S[0] == S[2] and S[1] == S[3] and S[0] != S[1])or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]):
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3064
import sys

n,m=map(int,input().split())
C=[-1]*3
for i in range(m):
    s,c=map(int,input().split())
    s=s-1
    if C[s]==-1:
        C[s]=c
    elif C[s]==c:
        continue
    else:
        print(-1)
        sys.exit()

if n==1:
    if C[0]==-1:
        print(0)
    else:
        print(C[0])
        
elif n==2:
    if C[0]==0:
        print(-1)
        sys.exit()
    else:
        if C[0]==-1:
            C[0]=1
        if C[1]==-1:
            C[1]=0
        print(C[0]*10+C[1])

elif n==3:
    if C[0]==0:
        print(-1)
        sys.exit()
    else:
        if C[0]==-1:
            C[0]=1
        if C[1]==-1:
            C[1]=0
        if C[2]==-1:
            C[2]=0
        print(C[0]*100+C[1]*10+C[2])

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

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

int main(){
    int n,m,l; cin >> n >> m >> l;

    vi a(n),b(m);
    cin >> a >> b;

    vi x(l),y(l),c(l);
    rep(i,l){
        cin >> x[i] >> y[i] >> c[i];
    }

    int ans = 1e8;
    int mina = 1e8;
    int minb = 1e8;
    rep(i,n){
        mina = min(a[i],mina);
    }
    rep(i,m){
        minb = min(b[i],minb);
    }
    ans = mina + minb;
    //cout << ans << endl;
    rep(i,l){
        ans = min(a[x[i]-1] + b[y[i]-1] - c[i] , ans);
    }

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


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

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>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vvl vector<vector<ll> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define eb emplace_back
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define debug(x) cerr<<x<<endl
#define test(t) int t;cin>>t;while(t--)
#define fordebug(x) cerr<<x<<" "

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference

ll a[MAX],h[MAX],dp[MAX];

ll seg[4*MAX],hi[4*MAX],lo[4*MAX];

void init(int st,int l,int r){
    hi[st] = r;
    lo[st] = l;
    if(l==r){
        return ;
    }
    int mid = (l+r)/2;
    init(2*st,l,mid);
    init(2*st+1,mid+1,r);
}

void uptree(int st){
    seg[st] = max(seg[2*st],seg[2*st+1]);
}

void update(int st,int l,int r,ll val){
    if(hi[st]<l or lo[st]>r){
        return;
    }
    if(l<=lo[st] and hi[st]<=r){
        seg[st] = val;
        return;
    }
    update(2*st,l,r,val);
    update(2*st+1,l,r,val);
    uptree(st);
}

ll query(int st,int l,int r){
    if(hi[st]<l or lo[st]>r){
        return 0LL;
    }
    if(l<=lo[st] and hi[st]<=r){
        return seg[st];
    }
    return max(query(2*st,l,r),query(2*st+1,l,r));
}

int main(){
    int n;
    cin>>n;
    forn(i,1,n+1){
        cin>>h[i];
    }
    forn(i,1,n+1){
        cin>>a[i];
    }
    init(1,1,n);
    forn(i,1,n+1){
        dp[i] = a[i];
        // forn(j,0,i){
        //     if(h[j]<h[i]){
        //         dp[i] = max(dp[i],dp[j]+a[i]);
        //     }
        // }
        dp[i] += query(1,1,h[i]);
        update(1,h[i],h[i],dp[i]);
    }
    cout<<*max_element(dp+1,dp+n+1);
    return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int ket(int x){
 int y=0;
   while(x!=0){
     x/=10;
     y++;
   }
  return y;
}
int main(){
  int n,a,ans=0;
  cin>>n; a=n;
  rep(i,n){
  if(ket(a)%2==1)ans++;
    a--;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
inf = 10 ** 9 + 7
s = input()
n = len(s)
dp = [[0] * 13 for _ in range(n+1)]
dp[0][0] = 1
mul = 1

for i in range(n):
    x = s[-(i+1)]
    if x == '?':
        for k in range(10):
            for j in range(13):
                dp[i+1][(mul*k+j) % 13] += dp[i][j]
                dp[i+1][(mul*k+j) % 13] %= inf
    else:
        k = int(x)
        for j in range(13):
            dp[i+1][(mul*k+j) % 13] += dp[i][j]
            dp[i+1][(mul*k+j) % 13] %= inf
    mul = mul * 10 % 13
print(dp[n][5])


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

int main(){
  int N;
  cin >> N;
  int number;
  int a =40;
  for(int i=0;i<N;i++){
    number = 0;
    int A;
    cin >> A;
    while(A%2==0){
      A/=2;
      number++;
    }
    if(a>number){
      a=number;
    }
  }
  cout << a <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.length();i++) ans+=s[i]-'0';
  for(int i=0;i<s.length();i++){
    int tmp=0;
    for(int j=0;j<i;j++) tmp+=(s[j]-'0');
    if(s[i]!='0') tmp+=(s[i]-'1');
    else continue;
    for(int j=i+1;j<s.length();j++) tmp+=9;
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int a[50];
int b[18];
long long c[51][51];
long long d[51];

int main() {
    int n, k, s, t, i, j, l;
    long long ans = 0;
    vector<int> v, w;
    
    scanf("%d %d %d %d", &n, &k, &s, &t);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i <= 50; i++) {
        c[i][0] = c[i][i] = 1;
        for (j = 1; j < i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }
    
    if (s == t) {
        for (i = 0; i < n; i++) {
            if (a[i] == s) {
                puts("1");
                
                return 0;
            }
        }
        
        puts("0");
        
        return 0;
    }
    
    for (i = 0; i < 18; i++) {
        if (((s >> i) & 1) == 1 && ((t >> i) & 1) == 0) {
            puts("0");
            
            return 0;
        }
        
        if ((s >> i) & 1) {
            b[i] = 0;
        } else if ((t >> i) & 1) {
            b[i] = 1;
            w.push_back(i);
        } else {
            b[i] = 2;
        }
    }
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < 18; j++) {
            if ((a[i] >> j) & 1) {
                if (b[j] == 2) break;
            } else {
                if (b[j] == 0) break;
            }
        }
        
        if (j == 18) v.push_back(a[i]);
    }
    
    for (i = 0; i <= n; i++) {
        for (j = 1; j < k && j <= i; j++) d[i] += c[i][j];
    }
    
    for (i = 0; i < v.size(); i++) {
        for (j = 0; j < (1 << w.size()); j++) {
            int x = 0, c = 0;
            
            for (l = 0; l < w.size(); l++) {
                if ((j >> l) & 1) x |= (1 << w[l]);
            }
            
            for (l = i + 1; l < v.size(); l++) {
                if (((~(v[i] ^ v[l])) & x) == x) c++;
            }
            
            if (__builtin_popcount(j) % 2 == 0) {
                ans += d[c];
            } else {
                ans -= d[c];
            }
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


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

#define MAXN 3005
#define MAXK 1000000
#define int long long
#define LL long long
#define pii pair<long, long>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;

int N;
int mod = 1e9+7;
int a[MAXN];
int sum[MAXN];
int dp[MAXN][MAXN];

signed main() {
    fastio;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> a[i], dp[i][i] = a[i], sum[i] = sum[i-1] + a[i];
    for (int len = 2; len <= N; len++) {
        for (int i = 1; i+len-1 <= N; i++) {
            int j = i + len - 1;
            dp[i][j] = sum[j] - sum[i-1] - min(dp[i+1][j], dp[i][j-1]);
        }
    }
    cout << dp[1][N] - (sum[N ] - dp[1][N]) << endl; 
    return 0;
}

Measured memory_bytes: 70016
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;


int main()
{
	int A,B,T;
	cin>>A>>B>>T;
	int total;
	total = B*(T/A);
	cout<<total<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

main(){

	int T;
	long long int a,b,c,d;/*
	scanf("%lld %lld",&a,&b);
	printf("%lld\n",gcd(a,b));
	return 0;*/
	long long m;
	scanf("%d",&T);
	while(T-->0){
		scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
		if(a<b || d < b){
			puts("No");
			continue;
		}
		a%=b;
		d%=b;
		if(c>b || (a<=c&&d==0)){
			puts("Yes");
			continue;
		}else if(d==0){
			puts("No");
			continue;
		}
//		puts("muzu");
		// b > c
		m=gcd(b,d);
		a+=(c-a)/m*m;
		if(a+m>=b)
			puts("Yes");
		else
			puts("No");
	}
}

Measured memory_bytes: 128
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d,z;
    cin>>n;
    while(n--){
        cin>>a>>b;
        if(a==b){
            l++;
        }
        else{
            l=0;
        }
        if(l==3){
            r=1;
        }
    }
    if(r==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return EXIT_SUCCESS;
}



Measured memory_bytes: 3644