akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b;
  if(a>=13)cout<<b<<endl;
  else if(a<=5)cout<<0<<endl;
else
  cout<<b/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  
  cout<<s.size();
 return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int m,f,r;

  while(1){
    scanf("%d %d %d",&m,&f,&r);
    if((m==-1)&&(f==-1)&&(r==-1)) break;
    if((m!=-1)&&(f!=-1)){
      if((m+f)>=80) printf("A\n");
      else if((m+f)>=65) printf("B\n");
      else if(((m+f)>=50)||(r>=50)) printf("C\n");
      else if((m+f)>=30) printf("D\n");
      else printf("F\n");
    } else printf("F\n");
  }

  return 0;
}

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

int main() {
	int i,j;
	int N;
	cin>>N;
	
	int A[N];
	int key;
	for(i=0;i<N;i++){
		cin>>A[i];
	}
	
	for(i=0;i<N;i++){
		key=A[i];
		j=i-1;
		while(j>=0&&A[j]>key){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=key;
		for(int n=0;n<N;n++){
			cout<<A[n];
			if(n!=N-1)cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
sysIn = list(map(int, input().split()))
n,k,q = sysIn[0],sysIn[1],sysIn[2]
score = [k for x in range(n)]
for i in range(q):
    win = int(input())
    score[win-1]+=1
for i in range(n):
    if (score[i] - q > 0):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 6580
n = int(input())
dp = [[0] * 3 for _ in range(n + 1)]
for i in range(n):
    abc = list(map(int, input().split()))
    for j in range(3):
        for k in range(1, 3):
            k = (j + k) % 3
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abc[k])
print(max(dp[-1]))

Measured memory_bytes: 22816
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define test(t) int t ; cin>>t ; while(t--)
#define mod 1000000007


int n,m;
int main(){
	cin>>n>>m;
	int sum = 0 ;
	for(int i = 1 ; i < 999 ; ++i){
		sum += i;
		if(i+1==m-n){
			cout<<sum-n;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);

		int x = sc.nextInt();

		if (x < 1200) {
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX_N 101

#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef pair<int, int> pii;

struct edge { int to, c; };

vector<edge> G[MAX_N];
int color[MAX_N];
int	minc[MAX_N];

void dijkstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> >PQ; //minc v

	memset(color, WHITE, sizeof(color));
	fill(minc, minc + MAX_N, INF);

	//?§????
	PQ.push(pii(0, s));
	minc[s] = 0;
	color[s] = GRAY;

	//PQ???????´????????????°
	while (!PQ.empty()) {
		//minc???????°??????¨??????????´????????????????
		pii p = PQ.top(); PQ.pop();

		int u = p.second;
		color[u] = BLACK;
		//????????§???????????°??????
		if (minc[u] < p.first) continue;

		//??£??\????????????????????¨????????????
		for (int j = 0; j < G[u].size(); j++) {
			edge e = G[u][j];
			if (color[e.to] == BLACK)continue;
			if (minc[e.to] > minc[u] + e.c) {
				minc[e.to] = minc[u] + e.c;
				PQ.push(pii(minc[e.to], e.to));
				color[e.to] = GRAY;
			}
		}
	}
}

int main() {
	for (int n, k; cin >> n >> k&&n;) {
		for (int i = 0; i < k; i++) {
			int f, a, b, c, d, e;
			cin >> f;
			if (f == 0) {
				cin >> a >> b;
				dijkstra(a);
				cout << (minc[b] == INF ? -1 : minc[b]) << endl;
			}
			else {
				cin >> c >> d >> e;
				edge E; E.to = d; E.c = e;
				G[c].push_back(E);
				E.to = c; E.c = e;
				G[d].push_back(E);
			}
		}

		for (int i = 0; i <= n; i++) {
			G[i].clear();
		}
	}
	return 0;
}

Measured memory_bytes: 1252
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(int, N, K);
    int cnt = 0;
    rep(i, N) {
        var(int, h);
        if (h >= K) ++cnt;
    }

    print(cnt);

    return 0;
}


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

typedef long long ll;

const int MOD = 1e9+7;

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

  ll pair=0;
  if(abs(n-m)==1) pair = 1;
  else if(abs(n-m)==0) pair = 2;

  //階乗テーブルを用意
  ll table[max(n, m)+1]; table[0]=1;
  for(ll i=1; i<=max(n, m); i++){
    table[i] = i*table[i-1]%MOD;
  }

  ll ans = pair*table[n]*table[m]%MOD;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define forn(i,x,y) for(int i=x;i<y;++i)
#define fornr(i,x,y) for(long long i=x;i>=y;--i)
#define testcase int _t; cin >> _t; while(_t--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 2e5;
int dp[MAXN][3];

int main()
{
	ios_base :: sync_with_stdio(false);
  	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	forn(i,0,n){
		cin >> a[i] >> b[i] >> c[i];
	}	
	forn(i,0,n){
		if(!i){
			dp[0][0] = a[0];
			dp[0][1] = b[0];
			dp[0][2] = c[0];			
		}else{
			dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
			dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
			dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c[i];			 
		}
	}    
  	cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
  	
  	return 0;
}

 	/* 















 	*/


Measured memory_bytes: 6008
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;

LL N, X;

LL f(LL a, LL b){
    if (a <= 0 || b <= 0) return 0;
    if (a%b == 0) return ((a+b)/b-1)*2*b;
    LL c = (a+b)%b;
    return (a+b)/b*b*2 + (b-1)/c*c + f(c - (b%c), b%c);
}

int main(){
    scanf("%lld %lld", &N, &X);
    if (X > N-X) printf("%lld", N+X+(X-1)/(N-X)*(N-X)+f((N-X)-X%(N-X), X%(N-X)));
    else printf("%lld\n", N+X+f(N-2*X, X));
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a==b && a!=c)||(b==c && b!=a)||(a==c&& a!=b))
     cout<<"Yes";
  else
     cout<<"No";
  return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int N = (int) 1e6 + 10;
int n, k;
char S[N];

int main() {
    #ifdef LOCAL
        freopen("Data.inp", "r", stdin);
        freopen("Data.out", "w", stdout);
    #endif

    scanf("%s", S + 1); n = strlen(S + 1);
    scanf("%d", &k);

    for (int i = 1; i <= n; ++i) {
        if (S[i] == 'a') continue;
        int d = 'z' + 1 - S[i];
        if (d <= k) S[i] = 'a', k -= d;
    }
    k %= 26;
    while (k--) {
        S[n]++;
        if (S[n] == 'z' + 1) S[n] = 'a';
    }

    puts(S + 1);
    return 0;
}


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

typedef pair<int,int> P;

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)

int gcd(int x,int y){
	if(y==0)return x;
	return gcd(y,x%y);
}

int main(){
	int n,k;
	int a[100010];
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int g=0,M=0;
	for(int i=0;i<n;i++){
		g=gcd(g,a[i]);
		chmax(M,a[i]);
	}
	if(k<=M&&k%g==0){
		puts("POSSIBLE");
	}
	else {
		puts("IMPOSSIBLE");
	}
}


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

typedef long long ll;
using namespace std;

ll N, K;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    sort(H.begin(), H.end());
    ll ans = 0;
    for (int i = 0; i < N - K; i++) {
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys

sys.setrecursionlimit(100000000)

N, M = list(map(int, input().split()))

AB = [tuple(map(int, input().split())) for _ in range(N + M - 1)]

dprint = print


def BellmanFord(edges, num_v, source):
    # グラフの初期化
    inf = float("inf")
    dist = [inf for i in range(num_v)]
    dist[source - 1] = 0

    # 辺の緩和
    for i in range(num_v):
        for edge in edges:
            if edge[0] != inf and dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]:
                dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2]
                if i == num_v - 1: return -1

    return dist


class Tree:
    def __init__(self, n):
        self.parent = set()
        self.child = set()
        self.rank = -1
        self.rank_fix = None
        self.current_parent = -1
        self.n = n

    def add_parent(self, i):
        self.parent.add(i)

    def add_child(self, i):
        self.child.add(i)

    def update_rank(self, v, parent_no):
        if self.rank >= v:
            return
        self.rank = v
        if self.current_parent != -1 and self.current_parent in self.parent:
            self.parent.remove(self.current_parent)
            trees[parent_no].child.remove(self.n)
        self.current_parent = parent_no
        for t in tuple(self.child):
            trees[t].update_rank(v + 1, self.n)

    def get_rank(self):
        if self.rank_fix:
            return self.rank_fix
        rank =  -1
        for p in self.parent:
            tmp_rank = trees[p].get_rank()
            if tmp_rank >rank:
                self.current_parent = p
                rank = tmp_rank
        self.rank_fix = rank + 1
        return self.rank_fix

    def __repr__(self):
        return "child" + str(self.child) + "rank:" + str(self.rank_fix) + " p:" + str(self.current_parent)


trees = [Tree(i) for i in range(N + 1)]
ans = [-1 for _ in range(N + 1)]
for a, b in AB:
    trees[a].add_child(b)
    trees[b].add_parent(a)

for i, t in enumerate(trees):
    if i != 0 and not t.parent:
        trees[0].add_child(i)
        trees[i].add_parent(0)
        break
# print(trees)
for i in range(N):
    (trees[i + 1].get_rank())
    print(trees[i+1].current_parent)



Measured memory_bytes: 149928
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int c[200005];
	int i;
	for (i = 0; i < n; i++)
		scanf("%d", &c[i]);
	int m = 0;
	int d[200005];
	d[m] = c[0];
	m++;
	for (i = 1; i < n; i++)
	{
		if (d[m - 1] != c[i])
		{
			d[m] = c[i];
			m++;
		}
	}
	long long int p = 1000000007;
	long long int dp[200005];
	for (i = 0; i < 200005; i++)
		dp[i] = 0;
	dp[d[0]] = 1;
	for (i = 1; i < m; i++)
		dp[d[i]] = (dp[d[i]] + dp[d[i - 1]]) % p;
	printf("%lld\n", dp[d[m - 1]]);
	return 0;
}

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


void solve(long long N, long long K, std::vector<long long> A){
    cout << (long long)ceil(((double)N-1)/(double)(K-1)) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll n,k;
  cin >> n;
  
  ll a;
  ll count = 0;
  for(int i=0;i<n;i++){
    cin >> a;
    while(a%2==0){
      a /= 2;
      count++;
    }
  }

  cout << count << endl;
         
  return 0;
}



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

void solve(vector<int> as, vector<int>& res) {
    assert(as.size());
    for (int i = as.size() - 1; i >= 0; i--) {
        if (as[i] == i + 1) {
            res.insert(res.begin(), i + 1);
            if (as.size() == 1) return;
            vector<int> bs;
            for (int j = 0; j < as.size(); j++) {
                if (i != j) {
                    bs.push_back(as[j]);
                }
            }
            solve(bs, res);
            return;
        }
    }
    cout << -1 << endl;
    exit(0);
}

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    vector<int> res;
    solve(as, res);
    for (int a : res) {
        cout << a << '\n';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 10000000000000000
#define MAX 510000
#define Rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)

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

//cout << fixed << setprecision(10);//
//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}


//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n

ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	
	   k/=i;
	
	}

	return k;
}


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



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

ll d[n+1][n+1];
for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
		d[i][j]=INF;
		if(i==j) d[i][j]=0;
	}
}

for(int i=1;i<=m;i++){
	ll p,q,r;
	cin>>p>>q>>r;
	d[p][q]=r;
	d[q][p]=r;

}

  rep(u,7){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
	for(int k=1;k<=n;k++){
d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

	}
}
}
  }

ll dd[n+1][n+1];
for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
		if(d[i][j]<=l){
		dd[i][j]=1;
		dd[j][i]=1;}
		if(d[i][j]>l) {dd[i][j]=INF; dd[j][i]=INF;}
		if(i==j) dd[i][j]=0;
	}
}

  rep(u,7){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
	for(int k=1;k<=n;k++){

dd[i][j]=min(dd[i][j],dd[i][k]+dd[k][j]);


	}
}
}
  }

int cnt;
cin>>cnt;
for(int i=1;i<=cnt;i++){
int t,s;
cin>>t>>s;
if(dd[t][s]<INF)
cout<<dd[t][s]-1<<endl;
else cout<<-1<<endl;
}

return 0;

}







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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    char C; cin >> C;
    char ans = C + 1;
    cout << ans << "\n";
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define F first
#define S second
#define show(x) cout<<#x<<" "<<x<<" ";
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define ll long long
#define all(A)  A.begin(),A.end()  
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
const int MSIZE = 4e2+5;
const int MOD = 1e9+7;


int arr[MSIZE];
ll dp[MSIZE][MSIZE];
ll cs[MSIZE];

int main(){

    FIO
    int n; cin>>n;

    cs[0] = 0;
    f(i,1,n)    { cin>>arr[i]; cs[i] = cs[i-1] + arr[i]; } 

    memset(dp,0,sizeof(dp));
    
    f(k,2,n) for(int i=1,j=k; j<=n ;i++,j++) {
        dp[i][j] = 1e15;
        for(int l=i; l<j;l++)
            dp[i][j] = min(dp[i][j], cs[j]-cs[i-1]+dp[i][l]+dp[l+1][j]);
    }

    cout<<dp[1][n]<<endl;


    return 0;

}
    


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> d(k);
    rep(i, 0, k) cin >> d[i];
    rep(i, n, 11*n) {
        bool ok = true;
        ll m = i;
        while (m > 0) {
            ll dig = m % 10;
            m /= 10;
            for (auto di : d) if (di == dig) ok = false;
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T=int> inline T in() { T x; cin >> x; return x; }

#include <iomanip>
int main() {
    cout << fixed << setprecision(12);
    int N = in();
    int K = in();
    int T = in();
    int U = in();
    int V = in();
    int L = in();
    vector<bool> carrot(L + 1, false);
    for (int i = 0; i < N; i++) carrot[in()] = true;

    double ans = 0;
    int hav = 0;
    int dur = 0;
    for (int pos = 1; pos <= L; pos++) {
        if (dur) {
            dur--;
            ans += 1.0 / V;
        } else {
            ans += 1.0 / U;
        }
        if (carrot[pos]) {
            if (!dur or hav == K) {
                carrot[pos] = false;
                dur = V * T;
            } else {
                hav++;
            }
        } else {
            if (!dur && hav) {
                hav--;
                dur = V * T;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
ll n;
string k;
void displ()
{
	cin>>n;
	while(n){
		k = char(n%26?(n%26)+'a'-1:'z')+k,n--;
	    	n/=26;
	}
	cout<<k<<"\n";
}

int main()
{
	displ();
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int h, w;
    string s[100];
    cin >> h >> w;

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

    for(int i=0; i<h; i++){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[200010];

int main(){
    int n, k;
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    sort(a, a+n);

    int l = 0, r = n - 1, flag = 1;
    ll ans = 1;

    if (k % 2 == 1){
        ans = a[r];
        r--;
        k--;
        if (ans < 0) flag = -1;
    }

    while(k > 0){
        ll x = a[l] * a[l+1], y = a[r] * a[r-1];
        // cout << x << " " << y << endl;
        if (x * flag > y * flag){
            x %= MOD;
            ans *= x;
            ans %= MOD;
            l += 2;
        }
        else {
            y %= MOD;
            ans *= y;
            ans %= MOD;
            r -= 2;
        }
        k -= 2;
    }

    cout << (ans + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin>>A.at(i);
    
    long long cnt=0;
    int m=0;
    int hoge=1;
    while(hoge<=n){
        m++;
        hoge=hoge*3+1;
    }
    vector<int> G(m);
    for(int i=0;i<m;i++){
        hoge--;
        hoge/=3;
        G.at(i)=hoge;
    }
    
    for(int i=0;i<m;i++){
        for(int j=G.at(i);j<n;j++){
            int v=A.at(j);
            int k=j-G.at(i);
            while(k>=0 && v<A.at(k)){
                A.at(k+G.at(i))=A.at(k);
                k-=G.at(i);
                cnt++;
            }
            A.at(k+G.at(i))=v;
        }
    }
    
    cout<<m<<endl;
    
    for(int i=0;i<m;i++){
        cout<<G.at(i);
        if(i<m-1) cout<<" ";
    }
    
    cout<<endl<<cnt<<endl;
    
    for(auto at:A) cout<<at<<endl;
    
    return 0;
}


Measured memory_bytes: 6796
from collections import deque


N, u, v = map(int, input().split())
u -= 1
v -= 1
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    A, B = map(int, input().split())
    edge[A - 1].append(B - 1)
    edge[B - 1].append(A - 1)

INF = 10 ** 6
lenA = [INF] * N
q = deque()
q.append((v, 0))
lenA[v] = 0
while len(q) > 0:
    p, step = q.popleft()
    for np in edge[p]:
        if lenA[np] == INF:
            lenA[np] = step + 1
            q.append((np, step + 1))


lenT = [INF] * N
q = deque()
q.append((u, 0))
lenT[u] = 0
ans = 0
while len(q) > 0:
    p, step = q.popleft()
    if len(edge[p]) == 1:
        ans = max(ans, step + (lenA[p] - step) - 1)
    for np in edge[p]:
        if lenT[np] == INF and lenA[np] > step + 1:
            lenT[np] = step + 1
            q.append((np, step + 1))

print(ans)


Measured memory_bytes: 65056
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#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 FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, ll> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 1010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, m;
ll a[3][MAXN], dp[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,n) cin >> a[0][i] >> a[1][i] >> a[2][i];
    ll res = -1e18;
    FOR(mask,0,7) {
        FOR(i,0,2)
            if (mask & (1<<i))
                FOR(j,1,n) a[i][j] = -a[i][j];

        FOR(i,0,n)
            FOR(j,0,m) dp[i][j] = -1e18;
        dp[0][0] = 0;
        FOR(i,1,n)
            FOR(j,0,m) {
                dp[i][j] = dp[i-1][j];
                if (j) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + a[0][i] + a[1][i] + a[2][i]);
            }
        res = max(res, dp[n][m]);
        // FOR(i,0,n) {
        //     FOR(j,0,m) cout << dp[i][j] << ' ';
        //     cout << endl;
        // }
        // cout << endl;

        FOR(i,0,2)
            if (mask & (1<<i))
                FOR(j,1,n) a[i][j] = -a[i][j];
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 8192
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<3; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        int K = sc.nextInt();
        int max = list.get(2);
        for(int i=0; i<K; i++){
            max *= 2;
        }
        System.out.println(list.get(0) + list.get(1) + max);
    }
}

Measured memory_bytes: 21716
from collections import defaultdict, deque, Counter
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))
    color = defaultdict(int)
    god = 0
    for i in A:
        if i < 400:
            color['gray'] = 1
        elif i < 800:
            color['brown'] = 1
        elif i < 1200:
            color['green'] = 1
        elif i < 1600:
            color['light_blue'] = 1
        elif i < 2000:
            color['blue'] = 1
        elif i < 2400:
            color['yellow'] = 1
        elif i < 2800:
            color['orange'] = 1
        elif i < 3200:
            color['red'] = 1
        else:
            god += 1
    print(max(1, len(color)), len(color) + god)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

bool ch(ll a, ll b)
{
    ll x=(1ll<<b);
    a=a/x;
    return (a&1);
}

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a,b,c,sum,ans;
    cin>>a>>b;
    c=0;
    ans=0;
    for(int i=2;i<n;i++)
    {
        cin>>sum;
        c=(c^sum);
    }
    sum=a+b;
    ll an=(sum-c);
    if(an<0 || (an&1) || an>2*a)
    {
        cout<<-1;
        return 0;
    }
    an=an/2;
    ll te=a-an;
    ans=an;
    bool bb=0;
    for(int i=45;i>=0;i--)
    {
        if(ch(an,i) && ch(c,i))
            bb=1;
    }
    if(bb)
    {
        cout<<-1;
        return 0; 
    }
    bb=0;
    te--;
    for(int i=45;i>=0;i--)
    {
        if(bb)
        {
            if(ch(c,i))
                ans+=(1ll<<i);
        }
        else
        {
            if(ch(te,i) && ch(c,i))
                ans+=(1ll<<i);
            if(!ch(c,i) && ch(te,i))
                bb=1;
        }
    }
    if(ans!=0)
        cout<<a-ans;
    else
        cout<<-1;
    subt;
    return 0;
}

Measured memory_bytes: 3704
N = int(input())
lis = list(map(int,input().split()))
x = 0
for i in lis:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            x += 1
if x == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 2; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

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

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

  string ans = "NG";
  for (int i = a; i <= b; i++)
  {
      /* code */
      if (i%k == 0) ans = "OK";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
abc = list(map(int, input().split()))
abc.sort()

if abc[0]%2 + abc[1]%2 + abc[2]%2 == 0:
	answer = abc[2] - (abc[0] + abc[1])/2
if abc[0]%2 + abc[1]%2 + abc[2]%2 == 3:
	answer = abc[2] - (abc[0] + abc[1])/2
	
if abc[0]%2 + abc[1]%2 + abc[2]%2 == 1:
	if abc[2]%2 == 1:
		answer = abc[2] - (abc[0] + abc[1]+2)/2 + 1
	if abc[2]%2 == 0:
		answer = (abc[2] + 1) - (abc[0] + abc[1]+1)/2 + 1

if abc[0]%2 + abc[1]%2 + abc[2]%2 == 2:
	if abc[2]%2 == 1:
		answer = (abc[2] + 1) - (abc[0] + abc[1]+1)/2 + 1
	if abc[2]%2 == 0:
		answer = abc[2] - (abc[0] + abc[1]+2)/2 + 1

print(int(answer))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >>N;
  if(N%2==0){
    cout<<1.0/2<<endl;
  }
  else{
    cout<<(double)(N - N / 2) / (double)N<<endl;
  }
 
 
}

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

#define MAX 50022

int main(void)
{
	bool p[MAX];
	vector <int> prime;
	int i, j;
	
	for (i = 0; i < MAX; i++){
		p[i] = true;
		if (i % 2 == 0) p[i] = false;
	}
	prime.push_back(2);
	for (i = 3; i < MAX; i += 2){
		if (p[i]){
			prime.push_back(i);
			for (j = 1; i * j < MAX; j++){
				p[i * j] = false;
			}
		}
	}
	/*
	for (i = 0; i < prime.size(); i++){
		printf("%d ", prime[i]);
	}*/
	
	int n;
	while (cin >> n){
		if (n == EOF) return 0;
		int a, b;
		for (i = 0; i < prime.size(); i++){
			if (prime[i] < n) a = prime[i];
			if (n < prime[i]) {
				b = prime[i];
				break;
			}
		}
		printf("%d %d\n", a, b);
	}
	
	return 0;
}

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


Python3 (3.4.3)
maspy

PyPy3 (2.4.0)
blcn
*/

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

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

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

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b;
  cin >> a >> b;
  if(a % 2 == 0 || b % 2 == 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

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

int main()
{
  	int r,c;
  
 	cin >> r >> c;

  	int rc[r+1][c+1] = {0};
  	
    for(int i = 0;i < r;i++){
      rc[i][c] = 0;
     for(int j = 0;j < c;j++){
       cin >> rc[i][j];
       rc[i][c] += rc[i][j];
       rc[r][j] += rc[i][j];
       rc[r][c] += rc[i][j];
     }
    }

  	for(int i = 0;i < r+1;i++){
     for(int j = 0;j < c+1;j++){
       cout << rc[i][j];
       if(j < c)
         cout << " ";
     }
      cout << endl;
    }
  	
}


Measured memory_bytes: 3128
h,w = map(int,input().split())
a = [input() for i in range(h)]
cnt = 0
b = []
for i in a:
  if i.count('.') != w:
    b.append(i)
  else:
    cnt += 1
if len(b) == 1:
    print(b[0].replace('.',''))
else:
    b = list(map(list,b))
    transpose = []
    c = []
    d = []
    for i in range(len(b[0])):
        tmp = []
        for v in b:
            tmp.append(v[i])
        transpose.append(tmp)
    for i in transpose:
        c.append(''.join(i))
    for i in c:
        if i.count('.') != h-cnt:
            d.append(i)
    d = list(map(list,d))
    transpose = []
    c = []
    for i in range(len(d[0])):
        tmp = []
        for v in d:
            tmp.append(v[i])
        transpose.append(tmp)
    for i in transpose:
        print(''.join(i))

Measured memory_bytes: 3316
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const long long MOD = 1000000007;

typedef long long ll;

ll d[400][400];
vector<int> g[400];

void wf(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++)  {
	if (d[i][j] > d[i][k] + d[k][j]) {
	  d[i][j] = d[i][k] + d[k][j];
	}
      }
    }
  }
}

int color[1000];
bool dfs(int i, int c) {
  for (int j = 0; j < g[i].size(); j++) {
    color[i] = c;
    if (color[g[i][j]] != 0) {
      if (color[g[i][j]] == c) return false;
      continue;
    }

    if (!dfs(g[i][j], -c)) return false;
  }
  return true;
}
  

int
main(int argc, char *argv[])
{
  
  int n;
  int s[400][400];
  scanf("%d", &n);

  rep(i, n)rep(j, n) {
    d[i][j] = 10000000000;
    if(i == j) d[i][j] = 0;
  }
  
  rep(i, n) rep(j, n) {
    scanf("%1d", &s[i][j]);
    if (s[i][j] == 1) {
      d[i][j] = 1;
      g[i].push_back(j);
      g[j].push_back(i);
    }
  }

  wf(n);

  int Max = 0;
  rep(i, n) rep(j, n) {
    if (Max < d[i][j]) Max = d[i][j];
  }

  if (dfs(0, 1)) printf("%d\n", Max + 1);
  else printf("-1\n");

  return 0;
}
	  
	  


Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
import itertools
N = int(input())
Ls = map(int, input().split())
res = 0
for data in itertools.combinations(Ls, 3):
    data = list(data)
    if len(set(data))==3:
        max_num = data.pop(data.index(max(data)))
        if max_num < sum(data):
            res += 1
print(res)


Measured memory_bytes: 9120
n,a,b = map(int, input().split())
m1 = n // (a + b)
m2 = n % (a + b)

if a ==0:
  print(0)
elif a >= n:
  print(n)
elif a + b >n:
  print(a)

else:
  if m2 >= a:
    print((m1 + 1) * a )
  else:
    print(m1 * a + m2)

Measured memory_bytes: 9188
ALPHA = "abcdefghijklmnopqrstuvwxyz"
import math


def solve(a, b, c, d):
    if -d <= a - c <= d:
        return "Yes"

    if -d <= a - b <= d and -d <= b - c <= d:
        return "Yes"
    return "No"


def main():
    a, b, c, d = [int(a) for a in input().split()]
    res = solve(a,b,c,d)
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e5+5;


main(){
    IOS();
    int m; cin>>m;
    ll ds = 0;
    ll nd = 0;
    REP(i,m){
        ll d, c; cin>>d>>c;
        ds += d*c; 
        nd += c;
    }
    cout<<nd-1+ (ds-1)/9<<endl;
} 


Measured memory_bytes: 256
shift = int(input())
X = input()
ans=''
#print(X)

LIST = ['A', 'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
DIC = {'A':0, 'B':1,'C':2,'D':3,'E':4,'F':5,'G':6,'H':7,'I':8,'J':9,'K':10,'L':11,'M':12,'N':13,'O':14,'P':15,'Q':16,'R':17,'S':18,'T':19,'U':20,'V':21,'W':22,'X':23,'Y':24,'Z':25}

#print(DIC)

for i in X:
    ans += LIST[(DIC[i] + shift) % 26]
    
print (ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=110;
int N,K;
bool a[MAXN][MAXN];

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

	cin>>N>>K;
	rep(i,1,N) a[0][i]=true;
	
	int cur=(N-1)*(N-2)/2;
	if (cur<K) {
		cout<<-1<<"\n";
		return 0;
	}
	
	int M=N-1;
	while (cur>K) {
		M++;
		cur--;
		rep(i,1,N) rep(j,i+1,N) if (!a[i][j]) {
			a[i][j]=true;
			goto con;
		}
		con:continue;
	}
	
	cout<<M<<"\n";
	rep(i,0,N) rep(j,i+1,N) if (a[i][j]) cout<<i+1<<" "<<j+1<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
unordered_map<int,bool> vis;
vector<int> g[100005];

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

    ll h[n+5];
    for(int i=1;i<=n;i++)
    {
	    cin>>h[i];
    }

    //vector<int> g[n+5];

    for(int i=0;i<100005;i++)
    {
	    g[i].clear();
    }
    while(m--)
    {
	    ll u,v;
	    cin>>u>>v;

	    g[u].push_back(v);
	    g[v].push_back(u);
    }
	ll count=0;
    for(int i=1;i<=n;i++)
    {
	    if(g[i].size()==0)
		    count++;
    }
    count=0;

    for(int i=1;i<=n;i++)
    {
	    bool flag=true;
	    for(int j=0;j<g[i].size();j++)
	    {
		    if(h[g[i][j]]>=h[i])
			    flag=false;
	    }
	    if(flag)
	    {
		   // cout<<i<<endl;
		    count++;
	    }
    }
    cout<<count<<endl;


    return 0;
}

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

int main(){
  long x, k, d;  cin >> x >> k >> d;
  x = abs(x);

  long ans;
  if(k < (long)(x/d)){
    ans = x - d * k;
  }else{
    k = k - (long)(x/d);
    if(k % 2 == 0){
      ans = x % d;
    }else{
      ans = abs((x%d)-d);
    }
  }

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


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<double, double>> town(N);
	for (int i = 0; i < N; ++i) {
		cin >> town[i].first >> town[i].second;
	}

	double bar_L = 0;
	int count = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i == j)continue;
			bar_L += sqrt(pow(town[i].first - town[j].first, 2) + pow(town[i].second - town[j].second, 2));
			++count;
		}
	}

	printf("%07lf\r\n", bar_L / N);



	return 0;
}

Measured memory_bytes: 256
S = input().strip()
N = len(S)
flag = 0
if S=="keyence":
    flag = 1
else:
    for i in range(N):
        for j in range(i,N):
            x = S[:i]
            y = S[j+1:]
            if x+y=="keyence":
                flag = 1
                break
        if flag==1:break
if flag==1:
    print("YES")
else:
    print("NO")

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

ll n, ans, r;
int x, m, s, t;
int a[100000];

int main() {
	cin >> n >> x >> m;
	fill(a, a + m, -1);
	r = n;
	for (int i = 0; i < n; ++i) {
		if (a[x] < 0) {
			a[x] = i;
			ans += x;
			x = (ll) x * x % m;
			--r;
		} else {
			s = a[x];
			t = i - a[x];
			break;
		}
	}
	ll c = 0;
	for (int i = 0; i < t; ++i) {
		c += x;
		x = (ll) x * x % m;
	}
	ans += c * (r / t);
	r %= t;
	for (int i = 0; i < r; ++i) {
		ans += x;
		x = (ll) x * x % m;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
char o;
cin>>o;
if (isupper(o))
{
  cout<<"A"<<endl;
}
else
{
    cout<<"a"<<endl;
}

    return 0;
}

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

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

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

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

    ll x = N % K;
    ll x2 = abs(x - K);

    cout << min(x, x2) << endl;
}


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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n;
      string s;
      cout<<(n^1);
      
	return 0;
}

Measured memory_bytes: 3600