akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

const int N = 2050;

int n, k, ans = 1e9, tot, a[N], b[N], vis[N], dep[N];
vector<int> g[N];

void dfs(int u, int f) {
	dep[u] = dep[f] + 1;
	if(dep[u] > k / 2) tot ++;
	for(auto v : g[u]) {
		if(v == f || vis[v]) continue;
		dfs(v, u);
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i < n; i++) {
		scanf("%d%d", a + i, b + i);
		g[a[i]].push_back(b[i]), g[b[i]].push_back(a[i]);
	}
	dep[0] = -1;
	if(k & 1) {
		for(int i = 1; i < n; i++) {
			vis[a[i]] = vis[b[i]] = 1;
			tot = 0, dfs(a[i], 0), dfs(b[i], 0);
			ans = min(ans, tot);
			vis[a[i]] = vis[b[i]] = 0;
		}
	} else {
		for(int i = 1; i <= n; i++) {
			tot = 0, dfs(i, 0);
			ans = min(ans, tot);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<stdarg.h>
#include<math.h>
using ll = long long;

using namespace std;




int main()
{/*7日目*/
//少数も使いたい割り算はしない方がいい
// 数値の大きさ
//for文で0代入する場所はforの一文下
//オーバーフローする一手手前を分解して作る・ 割り算で減らしていく
//for文いつも間違える/ i<nなら最後はa[n-1]
	ll n, k; cin >> n >> k;
	ll am = n % k;
	ll ma = am - k;
	if (am > -ma)
		cout << -ma;
	else
		cout << am;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int R;
    cin >> R;
    double ret = R * 2 * M_PI;
    printf("%.8f\n", ret);
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main(){
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while (x <= y) {
        x *= 2;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  //freopen("input.txt","r",stdin);
#endif

  int n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  ll ans=0;
  for(int i=0;i<n-1;i+=2)
  {
    ans=ans^(a[i]^a[i+1]);
  } 
  for(int i=0;i<n;i++)
  {
    cout<<(a[i]^ans)<<" ";
  }

  return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int cnts[3];

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

	for (int i = 1; i <= 2000000; i++) {
		int x = i;
		int cnt = 0;
		while (x % 100 == 0) {
			x /= 100;
			cnt++;
		}
		cnts[cnt]++;

		if (cnts[D] == N) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int n, a, b;
int main() {  
  cin >> n >> a >> b;
  int ans = 0;
  REP (i, 1, n + 1) {
    int sum = 0, tmp = i;
    rep (j, 5) {
      sum += tmp % 10;
      tmp = tmp / 10;
    }
    if ( a <= sum && sum <= b){
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
s=[tuple(map(int, input().split())) for i in range(N)]
def me(x,y,z):
    l=[None]*(M+1)
    l[0]=0
    for i,tu in enumerate(s):
        for j in range(M-1,-1,-1):
            if l[j]==None:
                continue
            t=l[j]+tu[0]*x+tu[1]*y+tu[2]*z
            if l[j+1]==None or t>l[j+1]:
                l[j+1]=t
    return l[-1]
print(max(me(1,1,1),me(1,1,-1),me(1,-1,1),me(-1,1,1),me(1,-1,-1),me(-1,-1,1),me(-1,1,-1),me(-1,-1,-1)))


Measured memory_bytes: 41708
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int l, r, d;
	cin>>l>>r>>d;
	int cnt = 0;
	for(int i=l; i<=r; i++)
	{
		if(i%d==0)
			cnt++;
	}
	cout<<cnt<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll K;
pair<int,int> P[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) {
		cin>>P[i].first>>P[i].second;
	}
	sort(P,P+N);
	FOR(i,N) {
		if(K<=P[i].second) {
			cout<<P[i].first<<endl;
			break;
		}
		K-=P[i].second;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 1024
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n;
	cin >> n;
	print((int)pow(n, 3));
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
ll a[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  sort(a, a + n);

  ll fst = a[n - 1];

  ll max_elem = fst / 2;

  ll snd = -1LL;

  for (int i = 0; i < n; ++i) {
    ll other = fst - a[i];

    if (max_elem >= a[i]) {
      snd = max(snd, a[i]);
    }

    if (max_elem >= other && other > snd) {
      snd = a[i];
    }
  }

  printf("%lld %lld\n", fst, snd);

  return 0;
}


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

using Graph = vector<vector<int>>;
// using Graph = vector<vector<Edge>>;

int A[100050], B[100050];
int N, taka, ao;

//深さ優先探索
vector<bool> seen, seen1;
void dfs(const Graph &G, int v){
  seen[v] = true; // v を訪問済みにする

  // vから行ける各頂点 next_v について
  for(auto next_v : G[v]){
    if (seen[next_v]) continue; // next_v が探索済みだったらスルー
    // if(next_v == ao) break;
    A[next_v] = A[v] + 1;
    dfs(G, next_v); // 再帰的に探索
  } 
}

void dfs1(const Graph &G, int v){
  seen1[v] = true; // v を訪問済みにする

  // vから行ける各頂点 next_v について
  for(auto next_v : G[v]){
    if (seen1[next_v]) continue; // next_v が探索済みだったらスルー
    B[next_v] = B[v] + 1;
    dfs1(G, next_v); // 再帰的に探索
  } 
}


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

  cin >> N >> taka >> ao;
  A[taka] = 0;
  B[ao] = 0;

  Graph G(N+1);
  for(int i=0;i<N-1;i++){
    int A, B;
    cin >> A >> B;
    G[A].push_back(B);
    G[B].push_back(A);
  }

  seen1.assign(N+1, false); // 全頂点を「未訪問」にして初期化
  dfs1(G, ao);

  seen.assign(N+1, false); // 全頂点を「未訪問」にして初期化
  dfs(G, taka);

  int ans1 = 0;
  for(int i=1;i<=N;i++){
    int Z = 0;
    if(A[i] < B[i]){
      Z = B[i]-1;
    }
    ans1 = max(ans1, Z);
  }

  cout << ans1 << endl;

}

Measured memory_bytes: 10368
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque([])
for i in range(n):
    if i&1:
        b.appendleft(a[i])
    else:
        b.append(a[i])

if n&1:
    b = list(b)[::-1]
    print(*b)
else:
    print(*b)

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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < ((int)n); ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1000000000;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

vector<int> A;
vector<int> route;
vector<int> visited;

void rec(int v) {
    route.push_back(v);
    if (visited[v - 1]) return;
    visited[v - 1] = true;
    rec(A[v - 1]);
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    llong k;
    cin >> n >> k;
    A.resize(n);
    rep(i, n) cin >> A[i];
    if (A[0] == 1) {
        cout << 1 << endl;
        return 0;
    }

    visited.resize(n, false);
    rec(1);
    // rep(i, (int)route.size()) cout << route[i] << endl;

    int t = (int)route.size();
    int target = route[t - 1];
    route.pop_back();
    --t;
    int sidx;
    rep(i, n) {
        if (route[i] == target) {
            sidx = i;
            break;
        }
    }

    if (k <= sidx) {
        cout << route[k] << endl;
    } else {
        llong p = (k - sidx) % (t - sidx);
        cout << route[sidx + p] << endl;
    }

    return 0;
}

Measured memory_bytes: 5824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;


#define x first
#define y second

double naiseki(pair<double,double> a,pair<double,double> b){
	return (a.x*b.x+a.y*b.y);
}

double nijo(pair<double,double> a){
	return naiseki(a,a);
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	pair<double,double> p1,p2,p,a,b,c;
	ll q;
	cin>>p1.x>>p1.y>>p2.x>>p2.y;
	cin>>q;
	FOR(tt,0,q){
		cin>>p.x>>p.y;
		a.x=p2.x-p1.x;
		a.y=p2.y-p1.y;
		b.x=p.x-p1.x;
		b.y=p.y-p1.y;
		c.x=(naiseki(a,b)/nijo(a))*a.x;
		c.y=(naiseki(a,b)/nijo(a))*a.y;
		printf("%.10lf %.10lf\n",p1.x+c.x,p1.y+c.y);
	}
	return 0;
}


Measured memory_bytes: 3288
import java.io.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
	    int i,n=0,start=-1,end=-1,keyi,sp2;
	    String[] sp = new String[2];
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
       	try{
       	n=Integer.parseInt(sc.readLine());
 	   }catch(IOException e){
		System.out.println(e);
	   }		    
     int[] data = new int[n];
     int[] next = new int[n];
     int[] befo=  new int[n];
     for(i=0;i<n;i++){
	 try{
    	 sp=(sc.readLine()).split("[\\s]+");
	 }catch(IOException e){
		System.out.println(e);
	     }
	     if(sp[0].equals("insert")){
	     data[i]=Integer.parseInt(sp[1]);
    	  if(start!=-1){
    		  next[i]=start;
    		  start=i;
    	   	  befo[next[i]]=i;
    	 }else{
    		 start=i;
    		 end=i;
    	 }
    	 }
    	 if(sp[0].equals("delete")){
	     if((keyi=search(data,next,start,Integer.parseInt(sp[1]),end))!=-1){
       	         if(start ==end){start =end = -1;
       			 continue;
       			 }
    		 if(keyi==end){
    			 end=befo[end];
    			 next[end]=-1;
    	 }else if(keyi==start){
    		 start=next[start];
    		 befo[start]=-1;
    	 }else{
    		 next[befo[keyi]]=next[keyi];
    		 befo[next[keyi]]=befo[keyi];
    	 }
    	 }
    	 }
    	 if(sp[0].equals("deleteFirst")){
   	      if(start ==end){
   	    	start =end = -1;
   			 continue;
   			 }
    		 if(start!=-1){
    		 start=next[start];
    		 }
    	 }
    	 if(sp[0].equals("deleteLast")){
    		 if(start!=-1){
    			 if(start ==end){start =end = -1;
    			 continue;
    			 }
    			 if(befo[end]!=-1)
    			 end=befo[end];
    		 }else{
    			 start=-1;
    		 }
    			 next[end]=-1;
    		 }
     }
     for(i=start;i!=next[end];i=next[i]){
    	 if(i!=end){
    		 System.out.print(data[i]+" ");
    	 }else{
    		 System.out.println(data[i]);
    	 }
    	 }
	}
	public static int search(int []data,int[]next,int start,int key,int end){
		int x;
		x=start;
		while(x !=end&&data[x]!=key){
			x=next[x];
		}
		if(x==end&& data[x]!=key) return -1;
		return x;
	}
}



Measured memory_bytes: 568640
#include <iostream>

using namespace std;
long long dp[3010][3010],a[3010],mod = 998244353;
int main(){
    int i,j,n,s;
    cin >> n >> s;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    dp[0][0] = 1;
    for(i=1;i<=n;i++){
        for(j=0;j<=s;j++){
            (dp[i][j] += dp[i - 1][j]) %= mod;
            if(j + a[i - 1]>s) continue;
            if(j==0){
                (dp[i][j + a[i - 1]] += i*dp[i - 1][j]%mod) %= mod;
            }else{
                (dp[i][j + a[i - 1]] += dp[i - 1][j]) %= mod;
            }
        }
    }
    long long ans = 0;
    for(i=0;i<=n;i++){
        (ans += dp[i][s]) %= mod;
    }
    cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> v(n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			v[j]++;
		}
	}
	long long ans = 0;
	for (int i = i; i <= n; i++) {
		ans += (long long) i * v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 42260
import java.util.Scanner;

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

		int a[] = new int[N];
		int b[] = new int[N];
		int c[] = new int[N-1];

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < N-1; i++) {
			c[i] = sc.nextInt();
		}

		int ans = 0;
		for (int i = 0; i < N; i++) {
			ans += b[a[i]-1];
			if (i!= N-1 && a[i] + 1 == a[i+1]) {
				ans += c[a[i]-1];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <regex>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    int f = 0;
    for(auto c : s){
        if(f == 0 && c == 'A') f++;
        else if(f == 1 && c == 'B') f++;
        else if(f == 2 && c == 'C') {ans++;f=0;}
        else f = (c == 'A'?1:0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, a[1000000], i, q, tmp, count = 0;

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

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &tmp);

    int left = 0, right = n, mid;
    while ( left < right ) {
      mid = (left + right) / 2;
      if ( tmp == a[mid] ) {
        count++;
        break;
      }
      if ( tmp > a[mid] ) left = mid + 1;
      else if ( tmp < a[mid] ) right = mid;
    }
  }

  printf("%d\n", count);
}



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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int n;
    cin >> n;
    int c[n], v[n];
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int sum = 0;
    rep(i, n) {
        if (v[i] > c[i]) sum += v[i] - c[i];
    }

    cout << sum << endl;

    return 0;
}

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

ll a[200100];

void solve(){

    ll n,k;
    cin >> n >> k;
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }

    set<ll> st;
    vector<ll> v;
    v.eb(0);
    st.insert(0);
    ll pointer = 0;
    ll t1=0;
    ll count1=1;
    while(true){
        //cout << pointer << endl;
        decltype(st)::iterator it = st.find(a[pointer]);
        if (it != st.end()) { // 見つかった
            //cout << "find" << *it << std::endl;
            t1 = *it;
            break;
        }
        st.insert(a[pointer]);
        pointer = a[pointer];
        count1++;
        v.eb(pointer);
    }

    ll count2=1;
    ll tm = 0;
    while(true){
        if(a[tm]!=t1){
            tm = a[tm];
            count2++;
        }
        else{
            break;
        }
    }

    /*
    for(auto e:v){
        cout << e << "!" << endl;
    }
    */

    //cout << count1 << " " << count2 << endl;

    ll y,x;
    if(count1==count2){
        y = count1;
        x=0;
    }
    else{
        y = count1-count2;
        x = count2;
    }
    
    if(k<x){
        cout << v[k]+1 << endl;
        return;
    }
    
    /*
    cout << v.size() << endl;
    cout << k << endl;
    cout << x << endl;
    cout << y << endl;
    
    cout << (k-x)%y+x << endl;
    */
    cout << v[(k-x)%y+x]+1 << endl;
    
}

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


Measured memory_bytes: 15420
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    int a[n+1];
    a[0]=0;
    int k;
    for(int i =0;i<n;i++){
        cin >> k;
        a[i+1]=a[i]+k;
    }
    sort(a,a+(n+1));
    k =1;
    int ans =0;
    for(int i =0 ;i<n;i++){
        if(a[i]==a[i+1]){
            k++;
        }else{
            ans+= k*(k-1)/2;
            k =1;
        }
    }
    ans+= k*(k-1)/2;
    cout << ans;

    return 0;
} 

Measured memory_bytes: 1792
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,m;
	cin >> n >> m;
	ll s = 0;
	for(int i = 1;i <= m;i++){
		ll x;cin >> x;
		s += x;
	}
	if(s > n)cout << -1;
	else cout << n-s;
	return 0;
}


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

int main() {
  const uint16_t N_max = 200;
  uint16_t N = 0;
  uint32_t A[N_max];

  std::cin >> N;
  for (size_t i = 0; i < N; i++) {
    std::cin >> A[i];
  }

  uint16_t min_manip = 32;
  for (size_t n = 0; n < N; n++) {
    for (size_t m = 0; m < min_manip; m++) {
      if ((A[n] == 0) || (A[n] % 2) != 0) {
        min_manip = (m < min_manip) ? m : min_manip;
        break;
      }
      A[n] /= 2;
    }
  }

  std::cout << min_manip << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int n,t;
int tree[500005];
int s = 0;
int p,q;
int maxl,sum;

void build(int l,int r,int node)
{
    if(l==r)
    {
        char ch;
        scanf("%c",&ch);
        if(ch == 'C' && s == 1)
        {
            tree[node] = 1;
        }
        else
            tree[node] = 0;
        if(ch == 'A')
            s = 1;
        else
            s = 0;
        return;

    }
    int mid=(l+r)/2;
    build(l,mid,2*node);
    build(mid+1,r,2*node+1);
    tree[node]=tree[2*node]+tree[node*2+1];
}

int query(int ql,int qr,int l,int r,int node)
{
    if(l>=ql&&r<=qr)
        return tree[node];
    int ans=0;
    int mid=(l+r)/2;
    if(ql<=mid)
    {
        ans+=query(ql,qr,l,mid,2*node);
    }
    if(mid<qr)
    {
        ans+=query(ql,qr,mid+1,r,2*node+1);
    }
    return ans;
}

int main()
{
    scanf("%d%d",&n,&t);
    getchar();
    build(1,n,1);
    while(t--)
    {
        scanf("%d%d",&p,&q);
        if(query(p,q,1,n,1) == query(p + 1,q,1,n,1))
            printf("%d\n",query(p,q,1,n,1));
        else
            printf("%d\n",query(p,q,1,n,1)-1);
    }
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(e) (e).begin(), (e).end()
typedef long long ll;
ll n;
vector<ll> tubo28;
 
void make(ll m,int digit) {
    if(m) tubo28.push_back(m);
    if(digit==5) {
        return;
    }
    make(m*10+2,digit+1);
    make(m*10+8,digit+1);
}
bool ok(vector<ll> &vec,ll m) {
    ll t=m;
    rep(i,vec.size()) {
        if(vec[i]==t) continue;
        while(m%vec[i]==0) m/=vec[i];
    }
 
    return m==1;
}
vector<ll> vec;
ll dfs(int idx,ll n) {
    if(n==1) {
        return 0;
    }
    if(idx==tubo28.size()) return -1;
    ll ret=-1;
 
    ret=max(ret,dfs(idx+1,n));
    if(n%tubo28[idx]==0) {
        ll t=dfs(idx,n/tubo28[idx]);
        if(t>=0) ret=max(ret,t+1);
    }
     
    return ret;
}

bool ok(ll m) {
    while(m) {
        if(m%10!=2&&m%10!=8) return false;
        m/=10;
    }

    return true;
}
 
int main() {
    make(0,0);
    sort(all(tubo28));
    cin>>n;
    ll ans=dfs(0,n);
    if(n==1) ans=-1;
    if(ans==-1&&ok(n)) {
        ans=1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>
#include <map>

using namespace std;

int main(){
	long long int n;
	long long int ans=0;
	int cnt=1;
	cin >> n ;
	long long int v[51];
	long long int temp=1;
	for(int i=0;i<50;i++){
		v[i] = temp;
		temp *= 2;
	}
	
	for(int i=0;i<50;i++){
		if(n > 1){
			n = n/2;
			cnt++;
		}
		
		else break;
	}
	
	for(int i=0;i<cnt;i++){
		ans += v[i];
	}
	
	cout << ans << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

static const ll max_v = 1e15;
vector<ll> as;
ll K, N;

bool is_ok(ll value){
    ll cut_n = 0;
    rep(i, N){
        cut_n += (as[i] - 1)/ value;
        if(cut_n > K){
            return false;
        }
    }

    return true;
}


void Main(){
    cin >> N >> K;
    as.resize(N);
    rep(i, N){
        sll(as[i]);
    }

    ll left_v = 0;
    ll right_v = 1e9;
    while(right_v - left_v>1){
        ll mid = (right_v + left_v) / 2;
        // cout << "mid=" << mid <<endl;
        bool ok = is_ok(mid);
        if(ok){
            right_v = mid;
        }else{
            left_v = mid;
        }
    }

    cout << right_v <<endl;
}

int main(){
    Main();
}

Measured memory_bytes: 4468
while 1:
  s,t= map(int,input().split())
  if s+t == 0:break
  c=0
  for i in range(1,s+1):
    for j in range(i+1,s+1):
      for k in range(j+1,s+1):
        if i+j+k ==t:c+=1
  print(c)




Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    while(cin >> n >> m, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        sort(v.begin(),v.end(), greater<>());
        int ans = accumulate(v.begin(),v.end(), 0);
        for (int i = m-1; i < n; i += m) {
            ans -= v[i];
        }
        cout << ans << "\n";
    }
    return 0;
}


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

using namespace std;

int dp[100005];

vector < int > ad[100005];

int func(int src)
{
    if(dp[src]!=-1) return dp[src];
    int mx=0;
    for(int v: ad[src])
    {
        mx=max(mx,1+func(v));
    }
    return dp[src]=mx;
}


int main()
{
    int n,m,i,j;
    cin>>n>>m;
    for(i=1; i<=m; i++)
    {
        int u,v;
        cin>>u>>v;
        ad[u].push_back(v);
    }

    int mx=0;
    memset(dp, -1, sizeof dp);
    for(i=1; i<=n; i++)
    {
        if(func(i)>mx)
        {
            mx=func(i);
        }
    }

    cout<<mx<<endl;
    return 0;

}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

ll n,m,li[110][110],a[1010],b[1010],c[1010];

int main(){
	cin >> n >> m;
	REP(i,0,n) REP(j,0,n) li[i][j] = li[j][i] = LINF;
	REP(i,0,n) li[i][i] = 0;
	REP(i,0,m){
		cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--;
		li[a[i]][b[i]] = li[b[i]][a[i]] = c[i];
	}
	REP(k,0,n) REP(i,0,n) REP(j,0,n) li[i][j] = min(li[i][j], li[i][k] + li[k][j]);
	
	int cou = 0;
	REP(i,0,m){
		bool f = true;
		REP(j,0,n){
			REP(k,0,n){
				if(li[j][k] == li[j][a[i]] + c[i] + li[b[i]][k]) f = false;
			}
		}
		if(f) cou++;
	}
	
	cout << cou << endl;
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n; cin >> n;

        //n = ab + c
        //n - c = ab


        int ans = 0;
        for (int c = 1; c <= n; c++) {
                int x = n - c;
                for (int div = 1; div * div <= x; div++) {
                        if (x % div == 0) {
                                ans++;
                                if (div * div != x) ans++;
                        }
                }
        }

        cout << ans;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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



int main() {
    int a,b;
    cin >> a >> b;
    int x=1;
    for(int i = 0; i < b; i++) {
        x *= 2;
    }
    cout << ((a-b)*100+b*1900)*x << endl;

    return 0;
}

Measured memory_bytes: 3492
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int maxn = -1E18;
	maxn = max(max(a * c, b * d), max(a * d, b * c));
	cout << maxn << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    string s;
    cin >> s;
    ll N = s.length();
    vector<ll> c(26, 0);
    for (int i = 0; i < N; i++) {
        c[s[i] - 'a']++;
    }

    ll ans = 1;
    ans += N*(N+1)/2;
    for (int i = 0; i < 26; i++) {
        ans -= c[i]*(c[i]+1)/2;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3816
/*----------------------------------------------------*
* लेखक --> अमित सिंह
* संस्थान --> राष्ट्रीय प्रौद्योगिकी संस्थान, कुरुक्षेत्र
*-----------------------------------------------------*/
   #include <bits/stdc++.h>
   using namespace std;
   #define ll long long
   #define w(t) int t; cin>>t; while(t--)
   #define fo(i,n) for(int i=0;i<n;i++)
   #define endl "\n" 
   #define MOD 1000000007
   void Tez(){
      ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
   }
   int main(){
      Tez();
      int n,k;
      cin>>n>>k;
      int ans=1;
      fo(i,n){
         if(ans*2<=ans+k){
            ans=ans*2;
         }else{
            ans+=k;
         }
      }
      cout<<ans;
      return 0;
   }



Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;

struct priority_queue{
    int A[2001005];
    int fact;
    priority_queue(){
        for(int i=0;i<2001005;i++){
            A[i]=-1;
        }
        fact = 0;
    }
    int extract(){
        int ret = A[0];
        A[0]=A[--fact];
        A[fact]=-1;
        int start = 0;
        while(start*2+1<fact){
            int c1=start*2+1,c2=start*2+2;
            int next=c2;
            if(A[c1]>A[c2]){
                next = c1;
            }
            if(A[next]>A[start]){
                int temp=A[next];
                A[next]=A[start];
                A[start]=temp;
                start = next;
            }else{
                break;
            }
        }
        return ret;
        
        return ret;
    }
    void insert(int x){
        int start = fact;
        fact++;
        A[start]=x;
        while(start>0){
            int p = (start-1)/2;
            if(A[start]>A[p]){
                int temp =A[start];
                A[start]=A[p];
                A[p]=temp;
            }
            start = p;
        }
        return;
    }
};

int main(){
    priority_queue pq;
    char s[100];
    while(1){
        scanf("%s",s);
        if(!strcmp(s,"extract")){
            printf("%d\n",pq.extract());
        }else if(!strcmp(s,"end")){
            break;
        }else{
            int x;
            scanf("%d",&x);
            pq.insert(x);
        }
    }
    return 0;
                 
}

Measured memory_bytes: 9008
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N,M = LI()
pS = [LS() for _ in range(M)]
set_AC = set()
count_WA = collections.defaultdict(int)
ans_AC,ans_WA = 0,0
for x in pS:
    p,S = int(x[0]),x[1]
    if p in set_AC:
        continue
    if S=='AC':
        set_AC.add(p)
        ans_AC += 1
        ans_WA += count_WA[p]
    else:
        count_WA[p] += 1
print(ans_AC,ans_WA)


Measured memory_bytes: 42468
import sys
import fractions


def input():
    return sys.stdin.readline()[:-1]


def main():
    a, b, c, d = map(int, input().split())
    x = c*d//fractions.gcd(c, d)
    ans = b-a+1
    ans -= (b//c-a//c)
    ans -= (b//d-a//d)
    ans += (b//x-a//x)
    if a % c == 0:
        ans -= 1
    if a % d == 0:
        ans -= 1
    if a % x == 0:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63980
from collections import Counter

N = int(input())

data = list()

for i in range(N):
    data.append(input())


c = Counter(data)

print('AC x {}'.format(c['AC']))
print('WA x {}'.format(c['WA']))
print('TLE x {}'.format(c['TLE']))
print('RE x {}'.format(c['RE']))


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

int main()
{
  int k,n;
  cin>>k>>n;
  int arr1[n];
  int i;
  for(i=0;i<n;i++)
  {
    cin>>arr1[i];
  }
  int arr2[n];
  for(i=0;i<n-1;i++)
  {
   arr2[i]=arr1[i+1]-arr1[i]; 
  }
  arr2[n-1]=k-arr1[n-1] + arr1[0];
  int max=0;
  int temp;
  int sum=0;
  for(i=0;i<n;i++)
  {
    temp=arr2[i];
    if(temp>max)
    {
      max=temp;
    }
    sum=sum+arr2[i];
  }
  cout<<sum-max;
}


Measured memory_bytes: 1792
import java.util.*;

/**
 * B Main
 *
 * @date 2020.09.19
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    int n = sc.nextInt();

    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 27160
#!python3

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

# input
A, B, C, K = LI()


def main():
    a = min(A, K)
    k = K - a
    b = min(B, k)
    k -= b
    c = min(C, k)
    ans = a - c
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
def Sum(n):
    s = str(n)
    sli = list(map(int , s))

    return sum(sli)

def DigitSums(n):

    digitsum = Sum(n)

    return "Yes" if n % digitsum == 0 else "No"

def main():
    n = int(input())
    print(DigitSums(n))

if __name__ == '__main__':
    main()

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;

	int a, b;
	cin >> a >> b;
	if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
		cout << a * b << '\n';
	}
	else {
		cout << -1 << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[25][25];
int dp[2100000];

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)for (int j = 0; j < n; j++)cin >> a[i][j];
	dp[0] = 1;
	for (int i = 0; i < (1 << n); i++) {
		if (!dp[i])continue;
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if (i&(1 << j))cnt++;
		}
		for (int j = 0; j < n; j++) {
			if (i&(1 << j))continue;
			if (a[cnt][j]) {
				dp[i + (1 << j)] += dp[i];
				dp[i + (1 << j)] %= mod;
			}
		}
	}
	cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (1e9 + 7)

int main(void){
    ll X;
    cin >> X;
    ll A,B;
    for(ll a=-1024;a<=1024;a++){
        for(ll b=-1024;b<=1024;b++){
            if(a*a*a*a*a-b*b*b*b*b==X){
                A = a;
                B = b;
            }
        }
    }
    cout << A << " " << B << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;
int x, y, z;
int mask = (1<<18) - 1;
int nx[1<<18][11];
ll dp[45][1<<18];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> x >> y >> z;
    rep(j, 1<<18) {
        rep2(k, 1, 11) {
            nx[j][k] = (((j<<k)|(1<<k)) & mask);
        }
    }
    dp[0][0 ] = 1;
    rep(i, n) {
        rep(j, 1<<18) {
            rep2(k, 1, 11) {
                if ((j>>z & 1) && (j>>(y + z) & 1) && (j>>(x + y + z) & 1)) {
                    continue;
                }
                addm(dp[i + 1][nx[j][k]], dp[i][j]);
            }
        }
    }
    ll ans = 1;
    rep(i, n) ans = ans * 10 % mod;
    rep(j, 1<<18) {
        if ((j>>z & 1) && (j >> (y + z) & 1) && (j >> (x + y + z) & 1)) continue;
        addm(ans, -dp[n][j]);
    }
    cout << ans << endl;
}


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

int main(void){
    long h, w, n;
    cin >> h >> w >> n;
    vector<long> v(static_cast<size_t>(h+1), LONG_MAX);
    for(long i=0; i<n; i++){
        long x, y;
        cin >> x >> y;
        v[x] = min(v[x], y);
    }
    long right = 1;
    for(long x=1; x<h; x++){
        if(v[x+1]<=right){
            cout << x << endl;
            return 0;
        }
        if(v[x+1]!=right+1){
            right++;
        }
    }
    cout << h << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define lll unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




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

#define linf 3000000000000000000ll
#define inf 999999999
#define MX 1000006
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int ele1,ele2,ele3;
    data() {}
    data(int a,int b,int c)
    {
        ele1=a,ele2=b,ele3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.ele1> b.ele1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;


int main()
{
    int t,tc=1;
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length()){
		pf("GREATER\n");
		return 0;
	}
	else if(a.length()<b.length()){
		pf("LESS\n");
		return 0;
	}
	else{
		if(a==b){
			pf("EQUAL\n");
		}
		else{
			if(a>b){
				pf("GREATER\n");
		
			}
			else{
				pf("LESS\n");
			}
		}
		return 0;
	}
	

    return 0;
}

/*



*/


Measured memory_bytes: 256
def resolve():
    N, M = [int(i) for i in input().split()]
    aabb = [list(map(int, input().split())) for _ in range(N)]
    ccdd = [list(map(int, input().split())) for _ in range(M)]
    for i in range(N):
        a, b = aabb[i]
        minPoint = -1
        minV = 10**9
        for j in range(M):
            c, d = ccdd[j]
            v = abs(a - c) + abs(b - d)
            if v < minV:
                minPoint = j + 1
            minV = min(minV, v)
        print(minPoint)


resolve()


Measured memory_bytes: 3316
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int,ins()))
def lin(): return list(input())
def iin(): return map(int,ins())

n, k, q = iin()
t = k - q
ans = [t]*n
for _ in range(q):
    ans[ii()-1] += 1
for j in ans:
    print('Yes' if j>0 else 'No')

Measured memory_bytes: 6616
N = int(input())
minus_bit = ''
if N == 0:
    minus_bit = '00'
while N != 0:
    mod = N % 4
    if mod == 0:
        minus_bit = minus_bit + '00'
        N = N//4
    elif mod == 1:
        minus_bit = minus_bit + '10'
        N = (N-1)//4
    elif mod == 2:
        minus_bit = minus_bit + '01'
        N = (N+2)//4
    else:
        minus_bit = minus_bit + '11'
        N = (N+1)//4

if minus_bit[-1] == '0':
    minus_bit = minus_bit[:-1]
print(minus_bit[::-1])

Measured memory_bytes: 3064