akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
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; }

bool dp[10001];

void solve() {
  int N; cin >> N;
  vi32 s(N); cin >> s;
  rep(i, 10001) dp[i] = false;
  dp[0] = true;
  rep(i, N) rrep(j, 10001) {
    if (dp[j]) dp[j + s[i]] = true;
  }
  rrep(i, 10001) if (dp[i]) {
    if (i % 10 == 0) continue;
    cout << i << '\n';
    return;
  }
  cout << 0 << '\n';
}


Measured memory_bytes: 256
def f():
  # n,m = (int(i) for i in input().split()) 
  # p = [int(i) for i in input().split()]
  # d >= then walk
  a,b = (int(i) for i in input().split()) 
  s = b-a
  bh=s*(s+1)//2
  print(bh-b)
f()

Measured memory_bytes: 2940
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;



int main(){

	int n;
	int l;
	int r;
	int e=0;
	cin>>n;

	for(int i=1; i<n+1; i++){
		cin>>l>>r;
		e+=(r-l)+1;
	}
	cout<<e<<endl;








}


Measured memory_bytes: 256
s = list(input())
n = len(s)
if s != list(reversed(s)):
    print("No")
    exit()
if s[:n//2] != list(reversed(s[:n//2])):
    print("No")
    exit()
if s[(n//2)+1:] != list(reversed(s[(n//2)+1:])):
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
	ll n,weight,dp[101][100001],w[101],v[101];
	cin>>n>>weight;
	for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
	for(int i=0;i<=weight;i++)dp[0][i]=0;
	for(int i=1;i<=n;i++){
	    for(int wei=0;wei<=weight;wei++){
	        if(wei-w[i]>=0){
	            dp[i][wei]=max(dp[i-1][wei-w[i]]+v[i],dp[i-1][wei]);
	        }
	        else{
	            dp[i][wei]=dp[i-1][wei];
	        }
	    }
	}
	cout<<dp[n][weight]<<endl;
	return 0;
}

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

const int p = 1e9 + 7;
int n;
long long fast_pow(long long x, long long y)
{
	long long ans = 1, now = x;
	while (y)
	{
		if (y & 1) ans = ans * now % p;
		now = now * now % p;
		y >>= 1;
	}
	return ans;
}
int main()
{
	scanf("%d", &n);
	printf("%lld", (fast_pow(10, n) - fast_pow(9, n) * 2 % p + fast_pow(8, n) + p) % p);
	return 0;
}

Measured memory_bytes: 3812
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n][2];
  int min = 2000000009;
  int minp;
  for(int i = 0; n > i; i++){
    cin >> a[i][0] >> a[i][1];
    if(min > a[i][1]){
      minp = i;
      min = a[i][1];
    }
  }
  cout << a[minp][0] + a[minp][1] << endl;
}

Measured memory_bytes: 1152
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  int64_t N, Q, s = 0, b, c, r;
  map<int64_t, int64_t> cnt{};
  cin >> N;
  vector<int64_t> A(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    cnt[A[i]]++;
    s += A[i];
  }

  cin >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> b >> c;
    r = cnt[b];
    s += (c * r) - (b * r);
    cnt[b] -= r;
    cnt[c] += r;
    cout << s << endl;
  }
}


Measured memory_bytes: 9376
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    A,B,C = (int(_) for _ in input().split())
    if A+B>=C:
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
INF = 110000

n = int(input())
dp = [ INF for _ in range(n+10)]
dp[0] = 0

for i in range(n+10):
    j = 1
    while j<=i:
        dp[i] = min(dp[i],dp[i-j]+1)
        j*=6
    k = 1
    while k<=i:
        dp[i]=min(dp[i],dp[i-k]+1)
        k*=9
print(dp[n])

Measured memory_bytes: 45040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long int ll;
using namespace std;

ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
int main()
{
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll cd_l = c*d/euclidean_gcd(c,d);
  a--;
  ll b_cnt = b - b/c - b/d + b/cd_l;
  ll a_cnt = a - a/c - a/d + a/cd_l;
  cout << b_cnt-a_cnt << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    Set<String> set = new HashSet<String>();
    Scanner scanner = new Scanner(System.in);
    char last = '\0';
    String result = "Yes";

    int N = scanner.nextInt();

    scanner.nextLine();
    for (int i = 0; i < N; i++) {
      String w = scanner.nextLine();

      if (set.contains(w)) {
        result = "No";
        break;
      }

      if (i > 0) {
        if (w.charAt(0) != last) {
          result = "No";
          break;
        }
      }
      set.add(w);
      last = w.charAt(w.length() - 1);
    }
    System.out.println(result);
  }

}


Measured memory_bytes: 23252
from scipy.special import comb
S = int(input())
div = int(S / 3)
if div < 2:
    print(div)
else:
    res = 1

    for i in range(1, div):
        tmp = S - (3 * (i + 1))
        res += comb((tmp + i), i, exact=True)
        res = res % 1000000007
    print(res)

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

const int MOD = (int)1e9+7;

int main(){
	int N,W;
	cin >> N >> W;
	vector<long long> w(N),v(N);
	for(int i=0;i<N;i++)	cin >> w.at(i) >> v.at(i);

	vector<vector<long long>> dp(N+1,vector<long long>(W+1,0));
	for(int i=0;i<N;i++){
		for(int j=0;j<W+1;j++){
			dp.at(i+1).at(j)=dp.at(i).at(j);
			if(j-w.at(i)<0)	continue;
			dp.at(i+1).at(j)=max(dp.at(i+1).at(j),dp.at(i).at(j-w.at(i))+v.at(i));
		}
	}
	cout << dp.at(N).at(W) << endl;

	return 0;
}


Measured memory_bytes: 80256
INF = float('inf')
n, m = map(int, input().split())
coins = list(map(int, input().split()))
dp = [INF] * (n + 1)
dp[0] = 0
for i in range(n+1):
    for c in coins:
        if i + c <= n:
            dp[i+c] = min(dp[i+c], dp[i] + 1)
print(dp[n])



Measured memory_bytes: 7260
#include <stdio.h>
#define MAX 1000 
#define INF 10000000
 
int G[MAX][MAX];
int d[MAX];
char color[MAX];
int n;
 

void initializeSingleSource(void){
  int v;
 
  for(v=0;v<MAX;v++){
    d[v]=INF; 
    color[v]='W';
  }
  d[0]=0;
  color[0]='G';
}
void dijkstra(void){
  int mincost,i,u,v;
 
  initializeSingleSource();
 while(1){
    mincost = INF;
    for(i=0;i<n;i++){
      if((color[i]!='B') && (d[i]<mincost)){
    mincost=d[i];
    u=i;
      }
    }
 
    if(mincost==INF) break;
    color[u]='B';
 
    for(v=0;v<n;v++){
      if(color[v]!='B' && G[u][v]!=INF){     
    if(d[v]>d[u]+G[u][v]){
    d[v]=d[u]+G[u][v];
    color[v]='G';
    }
      }
    }
 
  }
 
 
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
}

int main(){
 
  int u,k,i,j,v,c;
   
  scanf("%d",&n);
 for(i = 0; i < n;i++){
    for(j = 0;j < n;j++){
      G[i][j] = INF;
    }
  }
 
  for(i = 0;i < n;i++){
    scanf("%d %d",&u,&k);
    for(j = 0;j < k;j++){
      scanf("%d %d",&v,&c);
      G[u][v] = c; 
    }
  }
 dijkstra();
   
  return 0;
}
 

Measured memory_bytes: 992
h1,m1,h2,m2,k = map(int,input().split())

if m2 >= m1:
  m = m2 - m1
  h = h2 - h1
  
else:
  m = m2 + 60 - m1
  h = h2 - h1 - 1

res = h*60 + m - k
res = max(0,res)
print(res)

Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int k;
    string s;
    cin>>k>>s;
    int l=s.size();
    if(l<=k)cout<<s;
    else{
        rep(i,k)cout<<s[i];
        cout<<"...";
    }
	return 0;
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline


class UnionFindTree:
    def __init__(self, n: int):
        self.n = n
        self.root = [-1] * n
        self.rank = [0] * n
    def findRoot(self, x: int) -> int:
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.findRoot(self.root[x])
            return self.root[x]
    def unite(self, x: int, y: int):
        x = self.findRoot(x)
        y = self.findRoot(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
    def same(self, x: int, y: int) -> bool:
        if self.findRoot(x) == self.findRoot(y):
            return True
        else:
            return False
    def count(self, x: int) -> int:
        return -self.root[self.findRoot(x)]
    def treeCount(self) -> int:
        cou = 0
        for i in self.root:
            if i < 0:
                cou += 1
        return cou


def main():
    N, M = map(int, input().split())
    UFT = UnionFindTree(N)
    for _ in range(M):
        u, v, __ = map(int, input().split())
        UFT.unite(u-1, v-1)
    ans = UFT.treeCount()
    print(ans)


if __name__ == '__main__': main()

Measured memory_bytes: 7748
N, M = map(int, input().split())
id = [0] * N
ans = 0
for _ in range(M):
  L, R = map(int, input().split())
  id[L-1] += 1
  if R != N:
    id[R] -= 1
for i in range(N):
  if i != 0:
    id[i] += id[i-1]
  if id[i] == M:
    ans += 1
print(ans)

Measured memory_bytes: 12752
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String[] firstLine = s.nextLine().split(" ");
		int vertexCnt = Integer.parseInt(firstLine[0]);
		int edgeCnt = Integer.parseInt(firstLine[1]);
		ArrayList<Integer>[] input = new ArrayList[vertexCnt];
		for(int j=0 ; j<vertexCnt ; j++) {
			input[j] = new ArrayList<Integer>();
		}
		int[] inputEdgeCnt = new int[vertexCnt];
		for(int i=0 ; i<edgeCnt ; i++) {
			String[] line = s.nextLine().split(" ");
			int start = Integer.parseInt(line[0]);
			int end = Integer.parseInt(line[1]);
			input[start].add(new Integer(end));
			inputEdgeCnt[end]++;
		}
		ArrayList<Integer> result = solve(input, inputEdgeCnt);
		Object[] list = result.toArray();
		for(int i=0 ; i<list.length ; i++) {
			System.out.println(list[i]);
		}
	}

	public static ArrayList solve(ArrayList[] input, int[] inputEdgeCnt) {
		boolean[] already = new boolean[input.length];
		int index = 0 ;
		LinkedList<Integer> queue = new LinkedList<Integer>();
		ArrayList<Integer> result = new ArrayList<Integer>();
		outter : while(true) {
			inner : for(int i=0 ; i<already.length ; i++) {
				if(already[i] == false) {
					break inner;
				}
				if(i+1 == already.length)
					break outter;
			}

			if(inputEdgeCnt[index]==0 && !already[index]) {
				Object[] list = input[index].toArray();
				for(int a=0 ; a<list.length ; a++) {
					queue.offer((Integer) list[a]);
				}
				already[index] = true;
				result.add(new Integer(index));
			}
			index++;
			while(!queue.isEmpty()) {
				Integer neig = (Integer) queue.poll();
				inputEdgeCnt[neig.intValue()]--;
				if(inputEdgeCnt[neig.intValue()] == 0 && !already[neig.intValue()]) {
					Object[] list = input[neig.intValue()].toArray();
					for(int a=0 ; a<list.length ; a++) {
						queue.offer((Integer) list[a]);
					}
					already[neig.intValue()] = true;
					result.add(new Integer(neig.intValue()));
				}
			}
		}
		return result;
	}

}

Measured memory_bytes: 94912
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int sum = 0;

		for(int i = a;i<=b;i++){
			if(c%i ==0){
				sum++;
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 26276
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define MAX 101
bool flag;
int x[MAX], y[MAX], h[MAX], N,High;
void search(int, int);
int main() {
	int ansx=0, ansy=0, ansh=0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> h[i];
	for (int i = 0; i < MAX; i++) {
		for (int j = 0; j < MAX; j++) {
			search(i, j);
			if (flag) {
				ansx = i;
				ansy = j;
				ansh = High;
			}
		}
	}
	cout << ansx << " " << ansy << " " << ansh << endl;
	return 0;
}
void search(int cx, int cy) {
	int set=0;
	for (int i = 0; i < N; i++) {
		if (h[i]==0)continue;
		set = i;
		High = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
		break;
	}
	for (int i = 0; i < N; i++) {
		if (i == set)continue;
		if (h[i] != max(High - abs(x[i] - cx) - abs(y[i] - cy), 0)) {
			flag = false;
			break;
		}
		if (i == N - 1)flag = true;
	}
}

Measured memory_bytes: 256
words = input()

first = int(words[0:2])
end= int(words[2:])

MMYY=False
YYMM=False
if(1<=first<=12):
    MMYY=True
if(1<=end<=12):
    if(1<=end<=12):
        YYMM =True

if MMYY:
    if YYMM:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if YYMM:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    string S, T;
    cin >> S >> T;
    ll ans = 0;
    for(ll i = 0; i < 3; i++) ans += S[i] == T[i];
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				printf("yaha aya\n")
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

int main(void)
{
	int h,w;cin>>h>>w;
	char maze[h][w];
	rep(i,0,h-1) rep(j,0,w-1) cin>>maze[i][j];
	ll dp[h][w];
	fill(dp,0);
	rep(i,0,h-1) if(maze[i][0] == '#') break; else dp[i][0] = 1;
	rep(i,0,w-1) if(maze[0][i] == '#') break; else dp[0][i] = 1;
	dp[0][0] = 0;
	rep(i,1,h-1)
		rep(j,1,w-1)
			if(maze[i][j] == '#') dp[i][j] = 0;
			else dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
	int ans = dp[h-1][w-1];
	cout<<ans<<"\n";
}

Measured memory_bytes: 9088
#!python
# -*- coding: utf-8 -*-

n = int(input())
a_s = list(map(int, input().split(' ')))

A1 = max(a_s)
a_s.remove(A1)
A2 = a_s[0]
for a in a_s:
    if abs(A1 / 2 - A2) > abs(A1 / 2 - a):
        A2 = a

print(A1, A2)


Measured memory_bytes: 14428
# coding: utf-8


def solve(*args: str) -> str:
    a, b, c = map(int, args[0].split())
    k = int(args[1])

    ret = False
    for i in range(k+1):
        for j in range(k+1-i):
            ret |= a*pow(2, i) < b*pow(2, j) < c*pow(2, k-i-j)

    return 'Yes' if ret else 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 1e5 + 5;


int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll> value(n),weight(n);
    for(int i=0;i<n;i++)
    {
        cin>>weight[i]>>value[i];
    }
    ll dp[n+1][w+1];
   memset(dp,0,sizeof(dp));
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<w+1;j++)
       {
        if(j>=weight[i])
            dp[i+1][j]=max(dp[i][j],dp[i][j-weight[i]]+value[i]);
        else
            dp[i+1][j]=dp[i][j];
    }

   }

    cout<<dp[n][w]<<endl;
}


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

using namespace std;

#define int long long

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h, ans = 0, cnt = 1;
    cin >> h;
    while (h > 0) {
        if (h == 1) {
            ans += cnt;
            break;
        }
        ans += cnt;
        cnt *= 2, h /= 2;
    }
    cout << ans << '\n';
    return 0;
}



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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
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;

#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()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
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;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        int n, k;
        cin >> n >> k;
        if (n == 0) break;
        int card[k] = {};
        int ans = 0;
        rep(i, k) cin >> card[i];
        sort(card, card + k);
        bool exist = false;
        if (card[0] == 0) exist = true;
        int cnt = 1;
        int pre = 0;
        rep(i, k - 1) {
            if (card[i] == card[i + 1] - 1) cnt++;
            else if (card[i] == card[i + 1] - 2) {
                if (exist) {
                    ans = max(ans, pre + cnt + 1);
                    pre = cnt;
                    cnt = 1;
                }
                else {
                    ans = max(ans, cnt);
                    cnt = 1;
                }
            }
            else {
                if (exist) ans = max(ans, pre + cnt + 1);
                else ans = max(ans, cnt);
                pre = 0;
                cnt = 1;
            }
        }
        if (exist) ans = max(ans, pre + cnt + 1);
        else ans = max(ans, cnt);
        cnt = 1;
        pre = 0;
        rrep2(i, k - 1, 0) {
            if (card[i] == card[i - 1] + 1) cnt++;
            else if (card[i] == card[i - 1] + 2) {
                if (exist) {
                    ans = max(ans, pre + cnt + 1);
                    pre = cnt;
                    cnt = 1;
                }
                else {
                    ans = max(ans, cnt);
                    cnt = 1;
                }
            }
            else {
                if (exist) ans = max(ans, cnt + pre + 1);
                else ans = max(ans, cnt);
                pre = 0;
                cnt = 1;
            }
        }
        if (exist) ans = max(ans, pre + cnt + 1);
        else ans = max(ans, cnt);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3712
#include<cstdio>
int decompose(int n)
{
    int re=1;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            int num=1;
            while (n % i == 0)
            {
                n /= i;
                num++;
            }
            re*=num;
        }
    }
    if (n != 1)
        re*=2;
    return re;
}
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    for (int i = 1; i < n; i++)
        ans+=decompose(i);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    for(ll i = 1; i < s.size(); ++i){
        if(s.at(i) != s.at(i - 1)){
            ans++;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


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

int main() {
  int a, b, c;
  
  cin >> a >> b;
  c = a * b % 2;
  
  if (c == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
n,m = map(int,raw_input().split())

arr = []

for i in range(n):
	arr.append(map(int,raw_input().split()))

v = [[1,1,1],[1,1,-1],[1,-1,-1],[1,-1,1],[-1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1]]

ans = 0

for i in range(8):
	tmp = []
	for j in range(n):
		tmp.append(arr[j][0] * v[i][0] + arr[j][1] * v[i][1] + arr[j][2] * v[i][2])

	tmp.sort()
	ans = max(ans,sum(tmp[n-m:]))

print ans



Measured memory_bytes: 2820
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>k) cout<<k<<endl;
	else if(a+b>=k) cout<<a<<endl;
	else cout<<a-(k-(a+b))<<endl;
}


Measured memory_bytes: 3636
// "7 3"
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var splitInput = input.split(" ");

  var a = parseInt(splitInput[0], 10);
  var b = parseInt(splitInput[1], 10);

  console.log(Number(a % b !== 0));
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define f           first
#define s           second
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll )x.size()
#define hell        10000000000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define prime       54059
using namespace std;
ll i,j,t=1,k,n,sum=0,w,x,l,r,q,a[100005]={0},y;
map<ll,ll> m;
int  main()
{   ios
   cin>>n;
   for(i=0;i<n;i++)
   {
       cin>>x;
       m[x]++;
       m[x-1]++;
       m[x+1]++;
   }
   ll ans=0;
   for(auto i:m)
   {
       if(i.second>ans) ans=i.second;
   }
   cout<<ans;
	return 0;
}


Measured memory_bytes: 6272
s = input()
t = input()
w = len(s)+1
h = len(t)+1
dp = []
for i in range(h):
    L = [0]*w
    dp.append(L)
for i in range(w):
    dp[0][i] = i
for i in range(h):
    dp[i][0] = i
for i in range(h-1):
    for j in range(w-1):
        if t[i] == s[j]:
            dp[i+1][j+1] = min(dp[i][j],dp[i][j+1]+1,dp[i+1][j]+1)
        else:
            dp[i+1][j+1] = min(dp[i][j]+1,dp[i][j+1]+1,dp[i+1][j]+1)
print(dp[h-1][w-1])


Measured memory_bytes: 41844
#include<bits/stdc++.h>
using namespace std;
#define lol long long
int main(){
  lol a,b,c,d;
  string s,s2;
  cin>>a>>s>>s2;
  for(int i=0;i<a;i++){
    cout<<s[i]<<s2[i];
  }
  cout<<"\n";
  return(0);
}

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N, X, Y;
  cin >> N >> X >> Y;
  map<int, int> cnt;
  for (int i = 1; i < N + 1; i++) {
    for (int j = i + 1; j < N + 1; j++) {
      int d = min(j - i, abs(X - i) + 1 + abs(j - Y));
      cnt[d]++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << cnt[i] << endl;
  }
}

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

  solve();

  return 0;
}


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

typedef long long ll;

int main(){
  string S;
  cin >> S;
  int N = S.length();
  ll ans = 0;

  for(ll bit = 0;bit < (1 << N - 1); ++bit){
    ll tmp = S[0] - '0';
    for(int i = 0;i < N-1;++i){
      if(bit & (1 << i)){
        ans += tmp;
        tmp = S[i+1]- '0';
      }else{
        tmp = tmp * 10 + (S[i+1] - '0');
      }
    }
    ans +=tmp;
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=1; i<=n; i++)
#define drep(i, n) for (int i=n; i>=1; i--)
using namespace std;
bool check(string s) {
    if (s[0]!='A') return false;
    int sum=0;
    for (int i=0; i<s.length(); i++) {
        if (s[i]!='A' && s[i]!='C' && (s[i]<='Z' && s[i]>='A'))
            return false;
        if (s[i]=='C') {
            if (i<2 || i>s.length()-2) return false;
            sum++;
        }
    }
    if (sum==1) return true;
    return false;
}
typedef long long ll;
int main() {
    string s;
    cin>>s;
    if (check(s)) printf("AC"); else printf("WA");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
    cin >> n >> m;
    priority_queue<int> aque;
    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        aque.push(a);
    }

    for(int j = 0; j < m; ++j) {
        int aexe = aque.top();
        aque.pop();
        aexe /= 2;
        aque.push(aexe);
    }

    long long sum = 0;

    while(!aque.empty()) {
        int asum;
        asum = aque.top();
        aque.pop();
        sum += asum;
    }

    cout << sum << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

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

	vector<int> y_list(M, 0);
	for (int i = 0; i < M; i++)
	{
		cin >> y_list[i];
	}

	sort(x_list.begin(), x_list.end());
	sort(y_list.begin(), y_list.end());

	for (int Z = X + 1; Z <= Y; Z++)
	{
		if (x_list.back() < Z && Z <= y_list[0])
		{
			cout << "No War";
			return 0;
		}
	}

	cout << "War";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int n = A;
        
        for(int i = A; i < B + 1 ; i++){
            if(i % K == 0){
                System.out.println("OK");
                i = B + 1;
            }else{
            if(n == B){
                System.out.println("NG");
            }
            n++;
            }
        }
    
    }    
}

Measured memory_bytes: 27036
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vll a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    ll maxa = a[0], ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < maxa) ans += maxa - a[i];
        chmax(maxa, a[i]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4780
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int a = x1 - x2;
    int b = y1 - y2;
    cout << x2 + b << " " << y2 - a << " " << x1 + b << " " << y1 - a << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  long long tmp[26];
  vector<long long> v(n, 0);
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;

    for (int j = 0; j < 26; j++) {
      tmp[j] = 0;
    }

    for (char c : s) {
      tmp[c - 'a']++;
    }
    for (int j = 0; j < 26; j++) {
      v[i] = v[i] * 26LL + tmp[j];
    }
  }
  sort(v.begin(), v.end());
  ll tt = 0;
  ll ret = 0;
  for (int i = 0; i < n; i++) {
    if (i == n - 1 || v[i] != v[i + 1]) {
      ret += tt * (tt + 1) / 2;
      tt = 0;

    } else {
      tt++;
    }
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = (1 << 30);

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

    int a, b, c;
    cin >> a >> b >> c;
    if(a + b >= c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define st first
#define nd second
#define FORE(i,a,b) for(int i=(a),b_=(b);i<=b_;++i)
#define FORD(i,a,b) for(int i=(a),b_=(b);i>=b_;--i)
#define TR(c, it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())))
 
const int N = 2e5 + 1;
const int MOD = 1e9 + 7; 
const int INF = 1e9 + 10; 

 
int main() {
    #define TASK "TASK"	
	// freopen(TASK".inp","r",stdin);
	// freopen(TASK".out","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k;
	cin >> n >> k; 
	vector <int> h(n + 1); 
	vector <int> dp(n + 1, INF);
	for (int i = 1; i <= n; ++i) cin >> h[i]; 
	dp[1] = 0;  
	for (int i = 2; i <= n; ++i) {
		for (int j = i - 1; j >= max(1, i - k); --j) {
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i])); 
		}
	}
	cout << dp[n] << endl; 
     
  	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
	if(m == 0) return 1;
	if(i >= n) return 0;
	int res = solve(i+1, m) || solve(i+1, m - A[i]);
	return res;
}

int main() {
	int q, M, i;
	
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for(i=0; i<q; i++) {
		scanf("%d", &M);
		if(solve(0, M)) printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}

Measured memory_bytes: 2672
d[1001],c;
main(w,n,i,C,W)
{
  for(;scanf("%d",&w),w;printf("Case %d:\n%d\n%d\n",++c,d[w],i),bzero(d,4004)){
    for(scanf("%d",&n);i=n--;)
        for(i=w,scanf("%d,%d",&C,&W);i>=W;i--)
            d[i]=fmax(d[i],d[i-W]+C);
    for(;i<w&&d[w]-d[i];)i++;
  }
}

Measured memory_bytes: 0
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
       mut a:i32,mut b:i32,
    }
    if (b + a) % 2 != 0 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (b + a) / 2);
    }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(1000005, 0);
  for (auto&& e : A) {
    cin >> e;
    B[e]++;
  }
  bool pairwise = true;
  for (int i = 2; i < (int)B.size(); i++) {
    int cnt = 0;
    for (int j = i; j < (int)B.size(); j += i) {
      cnt += B[j];
    }
    if (cnt > 1) {
      pairwise = false;
    }
  }
  if (pairwise) {
    cout << "pairwise coprime" << '\n';
  } else {
    int g = 0;
    for (const auto& e : A) {
      g = gcd(g, e);
    }
    if (g == 1) {
      cout << "setwise coprime" << '\n';
    } else {
      cout << "not coprime" << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 11080
import math

N, D = map(int, input().split())
X = []

for _ in range(N):
    tmp = list(map(int,input().split()))
    X.append(tmp)

tmp = 0
cnt = 0

for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for d in range(D):
            tmp += math.pow(abs(X[i][d]-X[j][d]),2)
        tmp = math.sqrt(tmp)
        if tmp.is_integer():
            cnt += 1

print(cnt)

Measured memory_bytes: 3064
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long 
#define rint register int 
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = (x << 3) + (x << 1) + op - '0'; op = getchar(); }
  return neg * x;
}

const int N = 55;
string a[N], mat;
int t[N], n, ans;

int main() {
  cin >> n;
  for (rint i = 1; i <= n; i++) {
    cin >> a[i] >> t[i];
  }
  cin >> mat;
  for (rint i = n; i >= 1; i--) {
    if (mat == a[i]) break;
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}


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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define MAX 500005

template<typename T>
struct RMQ {
  const T INF = numeric_limits<T>::max();
  int n;
  vector<T> dat, lazy;
  RMQ(int _n) : n(_n+1), dat(_n*4,INF), lazy(_n*4,INF) {
    int x = 1;
    while (x < _n) x <<= 1;
    n = x;
  }

  void eval(int k) {
    if (lazy[k] == INF) return;
    if (k < n-1) lazy[k*2+1] = lazy[k*2+2] = lazy[k];
    dat[k] = lazy[k];
    lazy[k] = INF;
  }
  void update(int a, int b, int x, int k, int l, int r) {
    eval(k);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      lazy[k] = x;
      eval(k);
    } else {
      int mid = (l+r)>>1;
      update(a,b,x,k*2+1,l,mid);
      update(a,b,x,k*2+2,mid,r);
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }
  void update(int a, int b, int x) { update(a,b,x,0,0,n); }

  T query(int a, int b, int k, int l, int r) {
    eval(k);
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return dat[k];
    int mid = (l+r)>>1;
    T vl = query(a,b,k*2+1,l,mid);
    T vr = query(a,b,k*2+2,mid,r);
    return min(vl,vr);
  }
  T query(int a, int b) { return query(a,b,0,0,n); }
  inline T operator[](int a) { return query(a,a+1); }
};

int main(int, char**)
{
  int n, q;
  cin >> n >> q;

  RMQ<int> rmq(n);

  vector<int> ans;
  rep(i,q) {
    int command; cin >> command;
    if (command == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      rmq.update(s,t+1,x);
    } else if (command == 1) {
      int s, t; cin >> s >> t;
      ans.push_back(rmq.query(s,t+1));
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 6556
import java.util.*;
import java.lang.Math;

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

    if(b - a + 1 > k*2){
      for(int i = 0; i < k;i++) System.out.println(a + i);
      for(int i = 0; i < k;i++) System.out.println(b - k + i + 1);
    } else{
      for(int i = 0; i < b-a+1;i++) System.out.println(a + i);
    }
  }
}


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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll N, M;
    ll sum = 0;
    cin >> N >> M;
    for(ll i = 0;i < M;i++) {
        ll temp;
        cin >> temp;
        sum += temp;
    }
    ll t = N - sum;
    cout << max((ll)-1, t) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int main(int argc, const char * argv[]) {
    uint64_t N, M;
    cin >> N;
    cin >> M;
    
    vector<uint64_t> h;
    for (uint64_t i = 0; i < N; i++) {
        uint64_t tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    
    bool *good = new bool[N];
    memset(good, true, sizeof(bool) * N);
    
    for (uint64_t i = 0; i < M; i++) {
        uint64_t A, B;
        cin >> A;
        cin >> B;
        uint64_t idx_a = A - 1;
        uint64_t idx_b = B - 1;
        if (h[idx_a] > h[idx_b]) {
            good[idx_b] = false;
        }else if (h[idx_a] < h[idx_b]) {
            good[idx_a] = false;
        }else {
            good[idx_a] = false;
            good[idx_b] = false;
        }
    }
    
    uint64_t ans = 0;
    for (uint64_t i = 0; i < N; i++) {
        if (good[i]) {
            ans++;
        }
    }

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

Measured memory_bytes: 4316
N = int(input())

nx = 0
ny = 0
nt = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    k = abs(nx-x)+abs(ny-y)
    if k > t-nt:
        print("No")
        break
    if (k-(t-nt))%2 != 0:
        print("No")
        break
    nx = x
    ny = y
    nt = t
else:
    print("Yes")

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

ll a[4][1010];
signed main(void)
{
  int n;
  ll v;
  cin >> n >> v;
  REP(j, 4) REP(i, n) cin >> a[j][i];

  vector<ll> b;
  REP(i, n) REP(j, n) {
    b.push_back(a[0][i]+a[1][j]);
  }
  sort(ALL(b));
  ll ret = 0;
  REP(i, n) REP(j, n) {
    ll tmp = v-a[2][i]-a[3][j];
    ret += upper_bound(ALL(b), tmp) - lower_bound(ALL(b), tmp);
  }
  cout << ret << endl;
  return 0;
}

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

int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++ ) cin >> A[i];
    ll MAX = 0, submax  =0;
    map<int,int> MP;
    for(int i = 0; i < N; i++ ){
        MP[A[i]]++;
    }
    auto it = MP.rbegin();
    if(it->second >= 2 ) MAX = submax = it->first;
    else {
        MAX = it->first;
        it++;
        submax = it->first;
    }
    for(int i = 0; i < N; i++){
        if(A[i] == MAX) cout << submax << endl;
        else cout << MAX << endl;
    }
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;

int main() {
	//ios_base::sync_with_stdio(false);
	cout<<setprecision(20);
	ll n,m,d;
	cin>>n>>m>>d;
	double x;
	ll k;
	if(d==0){
	    k=n;
	}
	else{
	    k=(n-d)*2;
	}
	//cout<<k;
	x=(k*1.0)/(n*n*1.0);
	x*=((m-1)*1.0);
	cout<<x;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<time.h>
#include<cmath>
#include<functional>
#include<cassert>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
//using ll = long long;
//using p_i = pair<int, int>;
int main() {
    int a;cin>>a;
    if(a==25){
        cout<<"Christmas"<<endl;
        return 0;
    }
    if(a==24){
        cout<<"Christmas Eve"<<endl;
        return 0;
    }
    if(a==23){
        cout<<"Christmas Eve Eve"<<endl;
        return 0;
    }
if(a==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n;
  std::cin >> n;
  int ai[n], ci[n-1];
  for(int i=0; i<n; i++) std::cin >> ai[i];

  int ans = 0;
  int temp = 0;
  for(int i=0; i<n; i++){
    std::cin >> temp;
    ans += temp;
  }

  for(int i=0; i<n-1; i++) std::cin >> ci[i];

  for(int i=0; i<n - 1; i++){
    if( ai[i] == ai[i+1] - 1 ){
      ans += ci[ai[i] - 1];
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 3e3+7;
string s,t;
int dp[N][N], rev[N][N];

int32_t main()
{
	fast;

	cin>>s>>t;
	int sl = s.length(), tl = t.length();

	for(int i=0;i<sl;i++)
		for(int j=0; j<tl;j++)
			rev[i][j] = -1;

	for(int i=0;i<sl;i++)
	{
		for(int j=0;j<tl;j++)
		{
			if(i>=1&&j>=1)
				dp[i][j] = dp[i-1][j-1];
			if(s[i]==t[j])
				dp[i][j] = dp[i][j] + 1, rev[i][j] = 0;
			if(i>=1 && dp[i][j]<dp[i-1][j])
				dp[i][j] = dp[i-1][j], rev[i][j] = 1;
			if(j>=1 && dp[i][j]<dp[i][j-1])
				dp[i][j] = dp[i][j-1], rev[i][j] = 2;
		}
	}

	string ans = "";
	int i = sl-1, j = tl-1;
	while(i>=0 && j>=0)
	{
		if(rev[i][j]==0)
			ans+=s[i], i--, j--;
		else if(rev[i][j]==1)
			i--;
		else if(rev[i][j]==2)
			j--;
		else
			i--,j--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}

Measured memory_bytes: 141440