akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;

class ADDCCFinals {
public:
	void solve(std::istream& in, std::ostream& out) {
        int x,y;
        in >> x >> y;
        int ans = 0;
        vector<int> a={0,300000,200000,100000};
        if(x<4){
            ans+=a[x];
        }
        if(y<4){
            ans+=a[y];
        }
        if(x==1&&y==1) {
            ans += 400000;
        }
        out << ans << endl;
	}

};


int main() {
	ADDCCFinals solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;

    vi odd, even;
    rep(i, n){
        int e = a[i];
        if(i % 2){
            odd.emplace_back(e);
        }
        else {
            even.emplace_back(e);
        }
    }

    if(n % 2){
        swap(even, odd);
    }
    reverse(_all(odd));

    bool fst = true;
    for(auto& b : {odd, even}){
        for(auto& e : b){
            cout << (fst ? "":" ") << e;
            fst = false;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4724
n = int(input())
t,a = tuple(map(int,input().split()))
h = tuple(map(int,input().split()))
ans = n
m = abs(t-h[-1]*0.006-a)
for i in range(n-1):
  t_i = t-h[i]*0.006
  diff = abs(t_i-a)
  m = min(diff,m)
  if m==diff:
    ans = i+1
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


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

edges = []
for _ in range(M):
    u, v = map(int, input().split())
    edges.append([u-1, v-1])
# pprint(edges)


# ある辺iを除いた残りの辺にそれぞれに対してuniteの操作を行ったのち、異なるparentsの数を数える
# 連結グラフであれば、異なるparentsの数は1になる
# 非連結グラフであれば、異なるparentsの数は2以上になる


def root(v):
    if parents[v] == v:
        return v
    parents[v] = root(parents[v])
    return parents[v]


def unite(u, v):
    u_root = root(u)
    v_root = root(v)
    if u_root == v_root:
        return
    parents[u_root] = v_root


def same(u, v):
    return root(u) == root(v)


ans = 0
for e_i in edges:
    parents = [i for i in range(N)]
    for e_j in edges:
        if e_i == e_j:
            continue
        u, v = e_j
        if not same(u, v):
            unite(u, v)
    count = 0
    for v in range(N):
        if parents[v] == v:
            count += 1
    if count > 1:
        ans += 1

print(ans)


Measured memory_bytes: 75764
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
int nums[109];
map<int,int> dic;
int mx=0,mn=INF;

void pr(int ans){
    cout1((ans?"Possible":"Impossible"))
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N){
        int x; cin>>x;
        dic[x]++;
        nums[i]=x;
        chmax(mx,x);
        chmin(mn,x);
    }
    
    sort(nums,nums+N);
    rep1(i,N-1) if(nums[i]-nums[i-1]>1) pr(0);
    
    if(mx%2==0){
        if(mn!=mx/2) pr(0);
        if(dic[mn]!=1) pr(0);
        else dic[mn]++;
    }else{
        if(mn!=mx/2+1) pr(0);
        if(dic[mn]!=2) pr(0);
    }
    
    for(auto d:dic){
        if(d.second<=1) pr(0);
    }
    
    pr(1);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = sum(B)
for i in range(N-1):
    if A[i] == A[i+1] -1:
        ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 38384
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a;
a= sc.nextInt();
int b;
b= sc.nextInt();
if (a < b)
System.out.println("a < b");
else if(a > b)
System.out.println("a > b");
else
System.out.println("a == b");
}
}



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

using namespace std;


int main()
{
  int a, b;

  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 N;
  cin >> N;
  vector<string> blue(N);
  for (int i=0; i<N; i++) {
	  cin >> blue.at(i);
	}
  int M;
  cin >> M;
  vector<string> red(M);
  for (int i=0; i<M; i++) {
	  cin >> red.at(i);
	}
  
  int mx    = 0;
  int mx_tp = 0;
  string str_tp;
  
  for (int i=0; i<N; i++) {
	  str_tp=blue.at(i);
	  for (int j=0; j<N; j++) {
		  if (str_tp==blue.at(j)) {
			  mx_tp++;
			}
		}
	  for (int k=0; k<M; k++) {
		  if (str_tp==red.at(k)) {
			  mx_tp--;
			}
	    }
	  if (mx_tp>mx) {
		  mx = mx_tp;
		}
	  mx_tp=0;   
	}
  cout << mx << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<pii> v(n);
	For(i,1,n){
		cin>>v[i-1].F;
		v[i-1].S=i;
	}
	sort(all(v));
	For(i,0,n-1){
		cout<<v[i].S<<" \n"[i==n-1];
	}
	return 0;
}





























Measured memory_bytes: 2432
#include<iostream>
using namespace std;
const int INF = (1<<25);

bool dp[1000001];
int price[31];
int n, x;

int checkprime(int num) {
  for(int i=2; i*i<=num; i++) {
    if( num%i == 0 ) return true;
  }
  return x == 1;
}

int main() {
  while( cin >> n >> x, n || x ) {
    for(int i=0; i<n; i++) {
      cin >> price[i];
    }

    dp[0] = true;
    for(int i=1; i<=x; i++) {
      dp[i] = false;
    }

    for(int i=0; i<n; i++) {
      for(int j=price[i]; j<=x; j++) {
	if( dp[j-price[i]] ) {
	  dp[j] = true;
	}
      }
    }

    int ans = INF;
    for(int i = x; i>0; i--) {
      if( dp[i] && !checkprime(i) ) {
	ans = i;
	break;
      }
    }

    if( ans == INF ) cout << "NA" << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 2136
#include<iostream>
using namespace std;
int main() {
  int n,w,t,i,m,sum;
  string s;
  while(1){
    cin>>i;
    n=2,w=3,t=1;
    sum=1;
    if(i==0)break;
    for(int j=0;j<i;j++){
      cin>>s;
      if(s=="South")m=n,n=t,t=7-m;
      if(s=="North")m=t,t=n,n=7-m;
      if(s=="East")m=t,t=7-w,w=m;
      if(s=="West")m=t,t=w,w=7-m;
      if(s=="Left")m=w,w=n,n=7-m;
      if(s=="Right")m=n,n=w,w=7-m;
      sum+=t;
    }
    cout<<sum<<"\n";
  }
}

Measured memory_bytes: 0
import java.util.*

fun main() {
    val n = nextInt()
    nextLine()
    val a = nextIntList()
    val count = IntArray(n+1)
    var total = 0L
    for (i in a) {
        total += count[i]
        count[i]++
    }
    for (i in 0 until n) {
        println(total - (count[a[i]] - 1))
    }
}

val scanner = Scanner(System.`in`)
fun next(): String = scanner.next()
fun nextInt() = scanner.nextInt()
fun nextLong() = scanner.nextLong()
fun nextLine() = scanner.nextLine()
fun nextList() = nextLine().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")

fun main(args: Array<String>) = main()

Measured memory_bytes: 110008
# 2行として上にa下にbを並べた時にai<biなら確実に同じ数にできる(同じインデックス同士だと1ずつ狭まるので)
# ai>biのときはai-bi回加算しなくてはならない 加算できる数はai<biの全てのiの(bi-ai)/2回分
n = int(input())
a, b = list(map(int, input().split())), list(map(int, input().split()))

pool = 0
use = 0
for i in range(n):
    if a[i] < b[i]:
        pool += (b[i] - a[i]) // 2
    elif b[i] < a[i]:
        use += a[i] - b[i]

print("Yes" if pool >= use else "No")


Measured memory_bytes: 4600
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    int n;
    cin >> n;
    vit a(n + 5), sum(n + 5, 0);
    reps(i, n){
      cin >> a[i];
    }
    a[0] = 0;
    a[n + 1] = 0;
    reps(i, n + 1){
      sum[i] += sum[i - 1] + abs(a[i], a[i - 1]);
    }
    reps(i, n){
      cout << (sum[n + 1] - sum[i + 1]) + sum[i - 1] + abs(a[i - 1], a[i + 1]) << '\n';
    }
    return 0;
}


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


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

  int l, r;
  int sum = 0;

  for (int i=0; i<N; i++){
    cin >> l >> r;
    sum += (r- l +1);
  }

  cout << sum << endl;


}


Measured memory_bytes: 256
#define _'  '
M=1e9+7;A[_];F[_];long I[_],P[_],t,x,y;i,j,k;
f(a,b){return F[a+b]*I[a]%M*I[b]%M;}
main(s){
	for(;++x<_;I[x]=y,~scanf("%d",A+i)&&i++%2&&gets(P))
		for(*I=y=1,k=M-2,t=s=F[x]=s*x%M;k;t=t*t%M,k/=2)y=k%2?y*t%M:y;
	for(qsort(A,i/2,8,"H\x8b\7H+\6t\5H\x99\x92\f \xc3");j<i;P[j++-1]=x)
		for(x=f(t=--A[++j],s=--A[k=j]);k;x=s<A[k-=2]?x:(x-f(s-A[k],t-A[k+1])*P[k]%M+M)%M);
	printf("%d",x);
}/////////////////////////////////////////////

Measured memory_bytes: 4260
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	int N;
	int s[100];

	scanf("%d",&N);

	int ans = 0;

	for(int i=0;i<N;i++){
		int t;
		scanf("%d",&t);
		s[i] = t;
		ans += t;
	}

	if(ans%10!=0){
		printf("%d\n",ans);
		return 0;
	}

	int min = ans;
	for(int i=0;i<N;i++){
		if(s[i]%10!=0 && min > s[i]) min = s[i];
	}

	printf("%d\n",ans-min);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long INF = MOD*MOD;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;

int main(){
  cin >> s >> k;
  rep(i,s.size()){
    if((int)('z'-s[i])+1 <= k){
      k -= (26-(s[i] - 'a')) %26;
      s[i] = 'a';
    }
  }
  k %= 26;
  s[s.size()-1] += k;
  cout << s << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

int dx[9]={1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9]={0, 0, 1, -1, 1, -1, 1, -1, 0};

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                int d, s, t;
                cin>>d>>s>>t;
                if(s*t >= d) cout<<"Yes";
                else cout<<"No";       
        }
        return 0;
}

Measured memory_bytes: 3540
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

int A, B, C;

int main() {
  cin >> A >> B >> C;
  repe(i, 1, B) {
    if (A * i % B == C) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
    int h,w,count = 0;
    cin >> h >> w;
    string s[h+1];
    rep (i,h) {
      cin >> s[i];
    for (auto a : s[i]){
      if (a == '#') count++;
    }
    }
    if (count == h + w - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>

int main(void)
{
	char o[50];
	char e[50];
	int i;
	
	scanf("%s", o);
	scanf("%s", e);
	
	for(i=0; i<strlen(o); i++){
		putchar(o[i]);
		
		if(strlen(o)-strlen(e)==1 && i==strlen(o)-1)
			break;
		else
			putchar(e[i]);
	}
	
	return 0;
}


Measured memory_bytes: 128
import numpy as np
import sys
n=int(input())
s=input().split()
ans=1
d=1;
e=1
for i in s:
    if i=='0':
        e=0


for i in range(n):
    ans=ans*int(s[i])
    if ans>np.power(10,18):
        d=0
        break;

if d==0 and e==1:
    print(-1)
elif e==0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 37772
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<stack>
#include<bitset>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	//queue
	llint n,i,q;cin>>n>>q;
	queue<pair<int,string>>que;
	for(i=0;i<n;i++){
		string name;
		int time;
		cin>>name>>time;
		que.push(mp(time,name));
	}
	llint gen=0;
	while(que.size()){
		auto it=que.front();
		que.pop();
			if(it.fir>q){it.fir-=q;gen+=q;que.push(it);}
		else{gen+=it.fir;cout<<it.sec<<" "<<gen<<endl;}
	}
	return 0;
}


Measured memory_bytes: 6344
N,K=map(int,input().split())
ar= list(map(int, input().split()))
ans=0
ar.sort()

if N<=K:
    print(ans)
else:
    for i in range(1,K+1):
        f=-1*i
        ar[f]=0

    for i in range(N):
        ans+=ar[i]

    print(ans)

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

int main(void)
{
    int n, k;
    cin >> n >> k;
    cout << (n + k - 1) / k - n / k << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll x, y;
    cin >> x >>y;
    int a[] = {0, 1 , 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    if (a[x] == a[y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
  long long num;
  long long cnt = 0;
  long long kekka = 0;
  
  cin >> num;
  
  for(long long i = 0; i < num; i++){
    cin >> cnt;
    kekka += cnt-1;
  }
  
  cout << kekka;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vp=vector<P>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n,m;
    cin>>n>>m;
    vp x(m);
    rep(i,m){
        cin>>x[i].first>>x[i].second;

    }
    sort(x.begin(),x.end());
    int mx=INF;
    int ans=0;
    rep(i,m){
        P now=x[i];
        if(now.first>=mx){
            ans++;
            mx=INF;
        }

        mx=min(mx,now.second);
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+2;
const int M=2e5+2;
int ar[N],val[M],lis[N],color[N];
vector<pair<int,int> > adj[N];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,m,v;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		lis[i]=i;
		color[i]=-1;
	}
	for(i=1;i<=m;i++){
		cin>>j>>k;
		adj[j].push_back({k,i});
		adj[k].push_back({j,i});
	}
	sort(lis+1,lis+1+n,[&](int x,int y){
		return ar[x]<ar[y];	
	});
	for(i=1;i<=n;i++){
		v=lis[i];
		if(color[v]!=-1){
			continue;
		}
		bool cac=true;
		for(auto x:adj[v]){
			j=x.first; k=x.second;
			if(ar[v]>=ar[j]){
				if(color[j]!=-1){
					color[v]=1-color[j];
				}
				else{
					color[v]=0;
					color[j]=1;
				}
				val[k]=ar[v];
				cac=false;
				break;
			}
		}
		if(cac){
			cout<<-1;
			return 0;
		}
	}
	for(i=1;i<=n;i++){
		if(!color[i]){
			cout<<'B';
		}
		else{
			cout<<'W';
		}
	}
	cout<<'\n';
	for(i=1;i<=m;i++){
		if(!val[i]){
			val[i]=1000000000;
		}
		cout<<val[i]<<'\n';
	}
}

Measured memory_bytes: 12288
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int n,y,b,r,t,no;
  double ans,max;
  while(1){
    cin >> n;
    if(n==0)break;
    cin >> y;
    max=0;
    for(int i=0;i<n;i++){
      cin >> b >> r >> t;
      if(t==2){
	ans = pow(1.0+(double)r/100.0,y);
      }else{
	ans = 1.0 + y*(double)r/100.0;
      }
      if(max<ans)max=ans,no=b;
    }
    cout << no <<endl;
  }
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define pb push_back
#define all(x) x.begin(),x.end() 
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a)) 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const int mod = 1e9+7;
const int N = 1e5 + 10; 
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
int n;
string s;
int f(int k){
	int curr = 0;
	FOR(i,0,k - 1){
		int x = s[i] - '0';
		x ^= curr;
		if(x == 1){
			if(i + k - 1 >= n)return 0;
			curr ^= 1;
		}
	}
	return 1;
}
int main(){
    fast;
   cin >> s;
   n = sz(s);
   int l = 1,r = n;
   while(l < r){
   		int md = (l + r + 1) >> 1;
   		if(f(md))l = md;
   		else r = md - 1;
   }
   cout << l << "\n";
    return 0; 
}


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

static const int NIL = -1;

int D[30];
int H[30];

struct Node {
	int p, l, r;
} T[30];

void Depths(int id, int d) {
	D[id] = d;
	if (T[id].l != NIL) Depths(T[id].l, d + 1);
	if (T[id].r != NIL) Depths(T[id].r, d + 1);
}

int getSibling(int id) {
	if (T[id].p == NIL) return NIL;
	if (id == T[T[id].p].l) return T[T[id].p].r;
	else return T[T[id].p].l;
}

int getDegree(int id) {
	int cnt = 0;
	if (T[id].l != NIL) cnt++;
	if (T[id].r != NIL) cnt++;
	return cnt;
}

int Heights(int id) {
	int h1 = 0, h2 = 0;
	if (T[id].l !=NIL) h1 = Heights(T[id].l) + 1;
	if (T[id].r !=NIL) h2 = Heights(T[id].r) + 1;	
	return H[id] = max(h1, h2); //???????????\???????????¨?????????????????????
}

string type(int id) {
	if (T[id].p == NIL) return "root";
	if (T[id].l == NIL && T[id].r == NIL) return "leaf";
	else return "internal node";
}

void print(int id) {
	cout << "node " << id << ':';
	cout << " parent = " << T[id].p << ", ";
	cout << "sibling = " << getSibling(id) << ", ";
	cout << "degree = " << getDegree(id) << ", ";
	cout << "depth = " << D[id] << ", ";
	cout << "height = " << H[id] << ", ";
	cout << type(id) << endl;
}

int main() {
	int n, r;
	cin >> n;
	for (int i = 0; i < n; i++) {
		T[i].p = T[i].l = T[i].r = NIL; //?????????
	}

	for (int i = 0; i < n; i++) {
		int id, tl, tr;
		cin >> id >> tl >> tr;
		T[id].l = tl;
		T[id].r = tr;
		T[tl].p = T[tr].p = id;
	}

	for (int i = 0; i < n; i++) {
		if (T[i].p ==NIL) r = i;
	}
	Depths(r, 0);
	Heights(r);

	for (int i = 0; i < n; i++) {
		print(i);
	}

	return 0;
}

Measured memory_bytes: 1204
use proconio::input;
use proconio::marker::Usize1;

fn f(m: usize, n: usize) -> usize {
    if m > n {
        m - n
    } else {
        n - m
    }
}

fn main() {
    input! {
        n: usize,
        p: [Usize1; n],
    };
    let mut q = p
        .iter()
        .enumerate()
        .map(|(i, &p_i)| f(i, p_i))
        .collect::<Vec<usize>>();
    let mut ans = 0;
    for i in 0..n - 1 {
        if q[i] == 0 {
            let p_i = p[i];
            let p_j = p[i + 1];
            q[i] = f(i, p_j);
            q[i + 1] = f(i + 1, p_i);
            ans += 1;
        }
    }
    for i in (0..n - 1).rev() {
        if q[i + 1] == 0 {
            let p_i = p[i];
            let p_j = p[i + 1];
            q[i] = f(i, p_j);
            q[i + 1] = f(i + 1, p_i);
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4056
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int n, m;
    cin >> n >> m;
    vi a(m);
    REP(i, m) cin >> a[i];

    int sum = accumulate(ALL(a), 0);

    if (sum > n) {
        cout << -1 << endl;
    } else {
        cout << n-sum << endl;
    }


    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
    int K, A, B, b, i;
    scanf("%d%d%d", &K, &A, &B);
    b=0;
    for (i=A; i<=B; i++) {
        if (i%K==0) {
            b=1;
            break;
        }
    }
    if (b) printf("OK");
    else printf("NG");
    return 0;
}


Measured memory_bytes: 1708
nums = input()
length = len(nums)

num = int(nums[:3])
dif = abs(num - 753)

for i in range(1, length - 2):
   num_ = int(nums[i:i+3])
   dif_ = abs(num_ - 753)
   if dif_ < dif:
       num = num_
       dif = dif_

print(dif)

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
long long a[10005],b[10005],n,x=0,y=0;
int main(){
	scanf("%lld",&n);for(int i=1;i<=n;i++) scanf("%lld",&a[i]);for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
	for(int i=1;i<=n;i++){
		if(a[i]>b[i]) x+=(a[i]-b[i]);
		if(a[i]<b[i]) y+=(b[i]-a[i])>>1;
	}
	if(x<=y) printf("Yes\n");else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int A, B, T;
    scanf("%d%d%d", &A, &B, &T);

    int time = A;
    int cnt = 0;

    while (time <= T){
        cnt += B;
        time += A;
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
# ABC057_B
N, M = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(N)]
checkpoints = [list(map(int, input().split())) for _ in range(M)]

def manhattan(x1,y1,x2,y2):
    res = abs(x1-x2) + abs(y1-y2)
    return res

for i in range(N):
    memo = [float("inf")]*M
    for j in range(M):
        memo[j] = manhattan(*students[i],*checkpoints[j])
    ans = memo.index(min(memo)) + 1
    print(ans)


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

int main() {
  int P,Q,R;
  cin >>P>>Q>>R;
  
  int abc = P+Q;
  int bca = Q+R;
  int cab = R+P;
  
  cout << min(min(abc,bca),cab) << endl;
}


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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;

  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      int rem = n - r * i - g * j;
      if (rem >= 0 && rem % b == 0)
        ++ans;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0
#define all(v) begin(v),end(v)
#define inf 1LL<<55

lli n,z,w;


signed main(){

	cin>>n>>z>>w;

	vector<lli> a(n);
	REP(i,n)cin>>a[i];

	if(n==1)cout<<abs(w-a[n-1])<<endl;
	else{
		cout<<max(abs(w-a[n-1]),abs(a[n-2]-a[n-1]))<<endl;
	}

	return 0;
}

Measured memory_bytes: 764
max_n=10**6
mod=10**9+7

frac=[1]
for i in range(1,max_n+1):
  frac.append((frac[-1]*i)%mod)

inv=[1,1]
inv_frac=[1,1]
for i in range(2,max_n):
  inv.append((mod-inv[mod%i]*(mod//i))%mod)
  inv_frac.append((inv_frac[-1]*inv[-1])%mod)
  
def perm(m,n):
  if m<n:
    return 0
  if m==1:
    return 1
  return (frac[m]*inv_frac[m-n])%mod

def comb(m,n):
  if m<n:
    return 0
  if m==1:
    return 1
  return (frac[m]*inv_frac[n]*inv_frac[m-n])%mod

x,y=map(int,input().split())
if (x+y)%3:
  print(0)
else:
  s=(x+y)//3
  t=(s-x+y)//2
  if t<0 or t>s:
    print(0)
  else:
    print(comb(s,t))
  

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

typedef long long ll;
const int N = 55;

int n, A, a[N]; ll mm[N][N][N * N];

ll dp(int i, int cnt, int sum) {
	if (i == n) {
		if (cnt == 0)return 0;
		if ((sum / cnt == A) && (sum % cnt == 0))return 1;	
		return 0;
	}

	ll &ret = mm[i][cnt][sum];
	if (ret != -1)return ret;
	return ret = dp(i + 1, cnt, sum) + dp(i + 1, cnt + 1, sum + a[i]);
}

int main() {
	cin >> n >> A;
	for (int i = 0; i < n; i++)cin >> a[i];
	memset(mm, -1, sizeof mm);
	cout << dp(0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 71680
#include <cstdio>
#include <algorithm>

using namespace std;

int n, x, a[300000];

int main() {

    scanf("%d %d", &n, &x);

    if (x == 1 || x == 2 * n - 1) {
        puts("No");
    } else {
        puts("Yes");
        for (int i = 1, j = 0; i <= 2 * n - 1; i++) {
            if (i != x) {
                a[++j] = i;
            }
        }
        if (x <= n) {
            for (int i = 2 * n - 2; i >= n; i--) {
                printf("%d\n", a[i]);
            }
            printf("%d\n", x);
            for (int i = 1; i < n; i++) {
                printf("%d\n", a[i]);
            }
        } else {
            for (int i = 1; i < n; i++) {
                printf("%d\n", a[i]);
            }
            printf("%d\n", x);
            for (int i = 2 * n - 2; i >= n; i--) {
                printf("%d\n", a[i]);
            }
        }
    }

    return 0;

}


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

int main() {
  string S;
  int cnt=0;
  cin >> S;
  rep(i, S.size()) if(S.at(i)=='?') S.at(i)='D';
  cout << S << endl;    
}

Measured memory_bytes: 3728
a,b,c,x,y = map(int,input().split())
if 2*c-a-b >= 0:
  print(a*x+b*y)
else:
  s = 0
  if x >= y:
    s += 2*c*y
    x -= y
    s += min(2*c,a)*x
    print(s)
  else:
    s += 2*c*x
    y -= x
    s += min(2*c,b)*y
    print(s)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;

string func(bool b)
{
	return b ? "Yes" : "No";
}


int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;

	bool b = (0 <= x - r) && (x + r <= w);
	b &= (0 <= y - r) && (y + r <= h);

	cout << func(b) << endl;
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ll x, p = 100;
  cin >> x;
  int year = 0;
  while (p < x) {
    p += p/100;
    ++year;
  }
  cout << year << "\n";
}

Measured memory_bytes: 3592
#!/usr/bin/env python

def solve(A: int, B: int, C: int, K: int):
    if A >= K:
        return K
    K -= A
    if B >= K:
        return A
    K -= B
    return A - K


def main():
    A, B, C, K = map(int, input().split())
    answer = solve(A, B, C, K)
    print(answer)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long lint;


int ap[200009];

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

    int dr = n / 2;
    int st = 1;
    int dist = dr - st;
    dist = dist & 1;
    while(m > 0 && st < dr)
    {
        if(ap[st] == 0 && ap[dr] == 0)
            ap[st] = ap[dr] = 1;

        cout << st << " " << dr << "\n";
        st ++;
        dr --;
        m --;
    }

    st = n / 2 + 1;
    dr = n;
    if(((dr - st) & 1) == dist)
        dr --;

    while(m > 0 && st < dr)
    {
        if(ap[st] == 0 && ap[dr] == 0)
            ap[st] = ap[dr] = 1;

        cout << st << " " << dr << "\n";
        st ++;
        dr --;
        m --;
    }

    return 0;
}


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

int main(){
   string s,t;
   cin >> s >> t;
   cout << t+s << endl;
   return 0;  
}

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

int main()
{
  int N ;
  cin>>N ;
  vector<vector<int>>A(2,vector<int>(N)) ;
  for(int i=0;i<2;i++) for(int j=0;j<N;j++) cin>>A.at(i).at(j) ;
  
  int MAX=0 ;
  for(int i=0;i<N;i++){
    int sum_up=0 ;
    int sum_down=0 ;
    for(int j=0;j<N;j++){
      if(j<=i) sum_up+=A.at(0).at(j)  ;
      if(i<=j) sum_down+=A.at(1).at(j) ;
    }
    if(sum_up+sum_down>MAX) MAX=sum_up+sum_down ;
  }
  
  cout<<MAX<<endl ;

  return 0 ;
}

Measured memory_bytes: 256
s = list(input())
digits = len(s)
lists = []
answer = 0

for bit in range(2 ** (digits - 1)):
    formula = s[0]
    for i in range(digits - 1):
        if ((bit >> i) & 1):
            formula += "+"
        formula += s[i + 1]
    lists.append(formula)

for i in range(len(lists)):
    answer += eval(lists[i])
print(answer)







Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<LL,LL>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL n,m,k;
    cin >> n >> m >> k;
    LL a[n+5], b[m+5];
    memset (a,0,sizeof(a));
    memset (b,0,sizeof(b));
    for (LL i=1;i<=n;i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    for (LL i=1;i<=m;i++) {
        cin >> b[i];
        b[i] += b[i-1];
    }
    
    LL ansreal = 0;
    for (LL i=0;i<=n;i++) {
        LL x = i;
        LL rem = k - a[x];
        if (rem < 0) continue;
        LL l = 1, r = m, ans = 0;
        while (l <= r) {
            LL mid = (l+r) / 2;
            if (b[mid] <= rem) {
                ans = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        ansreal = max(ansreal, i+ans);
    }
    cout << ansreal << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 6776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

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

Measured memory_bytes: 3636
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b, c) = listOfInt()
    println(if (a+b >= c) "Yes" else "No")
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

	int x;
	cin >> x;

	cout << x * 360 / __gcd(360, x) / x;

	return 0;
}

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

typedef long long ll;

ll mod = 1e9 + 7, fac[1000005], v[1000005];

ll modRec(ll a, ll b) {
	if (b == 0)return 1;
	if (b % 2 == 0)return modRec((a * a) % mod, b / 2);
	return ((a % mod) * modRec((a * a) % mod, b / 2)) % mod;
}

int main() {
	fac[0] = 1, v[0] = 1;
	for (int i = 1; i <= 1000000; i++) {
		fac[i] = (i * fac[i - 1]) % mod;
		v[i] = modRec(fac[i], mod - 2);
	}
	ll h, w, a, b, ans = 0; cin >> h >> w >> a >> b;
	for (ll i = b; i < w; i++) {
		ll p = i, q = h - a - 1, r = w - i - 1, s = a - 1;
		ll x = (((fac[p + q] * v[p]) % mod) * v[q]) % mod;
		x *= (((fac[r + s] * v[r]) % mod) * v[s]) % mod;
		ans = (ans + x) % mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 2005

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

	int a, p;
	cin >> a >> p;
	int ans = 3 * a + p;
	cout << ans / 2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    string s;
    cin>>s;
    int ans=0;
    int i=0,j=s.size()-1;
    while(i<j){
        if(s[i]==s[j]) i++,j--;
        else if(s[i]=='x') ans++,i++;
        else if(s[j]=='x') ans++,j--;
        else{
            cout<<-1<<endl;
            return 0;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,c=0;;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)if(a[a[i]-1]==i+1)c++;
        cout<<c/2<<endl;
        return 0;
}
 

Measured memory_bytes: 640
#include <stdio.h>

int main()
{

  int x,y,z;

  while(1){
  scanf("%d%d",&x,&y);
  if(x==0&&y==0) break;

  if(x>y){
  z=x;
  x=y;
  y=z;
  }


  printf("%d %d\n",x,y);

  }

  return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;


signed main(){
    int n;
    cin >> n;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int b = 0;
    FOR(i,1,a.size()){
        if(a[i] == a[i-1]){
            b++;
        }
    }
    if(b%2 == 1){
        b += 1;
    }
    cout << a.size()-b << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>



using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main()
{
	int sum = 0;
	int n; cin >> n;
	vector<int> b(n - 1);
	vector<int> a(n);
	rep(i, n - 1) cin >> b[i];
	for (int i = 0;i < n;i++) {
		if (i == 0) //最初
			a[i] = b[i];
		else if(i==n-1){//最後
			a[i] = b[i - 1];
		}
		else {
			a[i] = min(b[i - 1], b[i]);
		}
	}
	rep(i, n) sum += a[i];
	cout << sum;
}


Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
	char a;
	char dna[4]={'A', 'C', 'G', 'T'};
	scanf("%c",&a);
	for (int i=0;i<4;i++){
		if (a == dna[i]){
			printf("%c\n", dna[3-i]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
def main():
    n = int(input())
    a = list(map(int, input().split()))

    even = a[1::2]
    odd = a[::2]
    ans = []
    if n % 2 == 0:
        even.reverse()
        ans = even + odd
    else:
        odd.reverse()
        ans = odd + even

    to_str = map(str, ans)
    return " ".join(to_str)

print(main())

Measured memory_bytes: 31140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
typedef struct Node{
    ll a,b;
    bool operator < (const Node &t)const {
        return a<t.a;
    }
}Node ;
Node p[N];

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&p[i].a,&p[i].b);
    }
    sort(p+1,p+1+n);
    ll ans=0;
    ll cur=0;
    for(int i=1;i<=n;i++){
        if(cur+p[i].b<=m){
            ans=ans+p[i].a*p[i].b;
            cur=cur+p[i].b;
        }else {
            ll t= ( m-cur ) * p[i].a;
            ans=ans+t;
            break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  int N;
  double D, x, y;
  cin >> N >> D;
  int point = 0;
  for (int i = 0; i < N; i++){
    cin >> x >> y;
    if (D >= sqrt(x * x + y * y)) point++;
  }
  cout << point << endl;
}


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

int main(void){
  int n, x, r=0;
  while (true) {
    cin >> n >> x;
    if (n==0&&x==0) {
      break;
    }
    for (int a=1; a<=n; a++) {
      for (int b=a+1; b<=n; b++) {
        for (int c=b+1; c<=n; c++) {
          if (a+b+c==x) {
            // cout << a << ' ' << b << ' ' << c << endl;
            r++;
          }
        }
      }
    }
    cout << r << endl;
    r=0;
  }
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	string ans = "";
	int n = (int)s.size();
	
	for(int i = 0; i < n; ++i) {
		if( s[i] == 'B' && !ans.empty() ) ans.pop_back(); 
		else if( s[i] == '0' || s[i] == '1' ) ans += s[i]; 
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3592
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  s <- BS.getLine
  let n = BS.length s
  v <- VM.new 2019
  VM.set v (0::Int)
  VM.write v 0 1

  let countN x y i | i > n = return ()
                   | otherwise = do
                       let c = s `BS.index` (n-i)
                           x' = (x + y * read [c]) `mod` 2019
                           y' = y * 10 `mod` 2019
                       t <- VM.read v x'
                       VM.write v x' (t+1)
                       countN x' y' (i+1)

  countN 0 1 1

  let f x = (x - 1) * x `div` 2
      solve i res | i == 2019 = return res
                  | otherwise = do
                      x <- VM.read v i
                      solve (i+1) (res + f x)

  ans <- solve 0 0

  print ans

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

// macro
#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 MOD 1000000007
#define ll long long
#define INF 1e9+7

using namespace std;
// Warshall Floyd (O(n^3))
void WarshallFloyd(ll n, vector<vector<ll> > &dist) {
    REP(k, n) REP(i, n) REP(j,n) {
        if (dist[i][k] + dist[k][j] < dist[i][j]) {
            dist[i][j] = dist[i][k] + dist[k][j];
        }
    }
}

int main() {
    ll N,M;
    cin >> N >> M;
    vector<vector<ll> > dist(N, vector<ll>(N));
    vector<vector<pair<ll, ll> > > path(N);
    REP(i, N) REP(j, N) {
        if(i == j) dist[i][j] = 0;
        else dist[i][j] = INF;
    }
    ll a,b,c;
    REP(i, M) {
        cin >> a >> b >> c;
        a--;
        b--;
        dist[a][b] = c;
        dist[b][a] = c;
        path[a].emplace_back(b, c);
        path[b].emplace_back(a, c);
    }
    WarshallFloyd(N, dist);
    ll cnt = 0;
    REP(i, N) for (auto it : path[i]) {
        int j;
        int cost;
        tie(j, cost) = it;
        if(i > j) continue;
        bool isUsed = false;
        REP(k, N) {
            if(dist[i][k] == cost + dist[j][k]) {
                isUsed = true;
                break;
            }
        }
        if(isUsed == false) cnt++;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)




int main(){
	int n,t;
	cin >> n >> t;
	int ans = 100000;
	rep(i,n){
		int a,b;
		cin >> a >> b;
		if (b <= t){
			ans = min(ans,a);
		}
	}
	if (ans == 100000) cout << "TLE" << endl;
	else cout << ans << endl;
	
	
	return 0; 
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<queue>
#include<string>
using namespace std;

struct Process
{
    string name;
    int time;
    int left;
}pro[100000];

int main()
{
    int t=0;
    int n,q;
    cin >> n >> q;
    queue<Process> Q;
    for(int i=0;i<n;i++)
    {
        cin >> pro[i].name >>pro[i].time;
        pro[i].left=pro[i].time;
        Q.push(pro[i]);
    }
    while(!Q.empty())
    {
        Process job=Q.front();
        Q.pop();
        if(job.left>q)
        {
            t+=q;
            job.left-=q;
            Q.push(job);
        }
        else
        {
            t+=job.left;
            cout << job.name << ' ' << t << endl;
        }
    }
}


Measured memory_bytes: 7780