akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

class ModInt{
private:
  long long val;
  static const int default_mod = 1e9 + 7;
  static int mod;
  static vector<ModInt> facts;
public:
  ModInt(long long val)
  {
    if(mod == 0){
      mod = default_mod;
    }
    this->val = ((val % mod) + mod) % mod;
  }
  ModInt()
    : ModInt(0)
  {
  }
  static void setMod(int mod){
    if(ModInt::mod != 0){
      throw "The modulo is already set.";
    }
    ModInt::mod = mod;
  }

  const ModInt operator* (const ModInt& another) const{
    return ModInt(val * another.val);
  }
  ModInt operator+ (const ModInt& another){
    return ModInt(val + another.val);
  }
  ModInt operator- (const ModInt & another){
    return ModInt(val - another.val + mod);
  }
  ModInt operator/(const ModInt& rhs){
    return (*this) * rhs.inv();
  }
  ModInt& operator*=(const ModInt& rhs){
    (*this) = (*this) * rhs;
    return *this;
  }
  ModInt& operator+=(const ModInt& rhs){
    (*this) = (*this) + rhs;
    return *this;
  }
  ModInt& operator-=(const ModInt& rhs){
    (*this) = (*this) - rhs;
    return *this;
  }
  ModInt& operator/=(const ModInt& rhs){
    (*this) = (*this) / rhs;
    return *this;
  }
  ModInt pow(long long exponent) const{
    exponent %= mod - 1;
    if(exponent == 0){
      return ModInt(1);
    }else{
      if(exponent % 2){
        return ((*this) * (*this)).pow(exponent / 2) * (*this);
      }else{
        return ((*this) * (*this)).pow(exponent / 2);
      }
    }
  }
  ModInt inv() const{
    return this->pow(mod - 2);
  }
  static ModInt fact(long long n){
    if(n >= mod){
      return 0;
    }
    if(facts.size() < static_cast<size_t>(n + 1)){
      if(facts.size() == 0){
        facts.push_back(1);
      }
      for(int i = facts.size(); i <= n; i++){
        facts.push_back(facts[i - 1] * i);
      }
    }
    return facts[n];
  }
  static ModInt comb(long long n, long long r){
    if(r > n){
      return 0;
    }
    return ModInt::fact(n) * ModInt::fact(r).inv() * ModInt::fact(n - r).inv();
  }
 
  friend ostream& operator<< (ostream& os, const ModInt& modint){
    os << modint.val;
    return os;
  }
  friend istream& operator>>(istream& is, ModInt& modint){
    long long val;
    is >> val;
    modint.val = val % modint.mod;
    return is;
  }
  friend ModInt operator*(const long long lhs, const ModInt& rhs){
    return ModInt(lhs) * rhs;
  }
};
int ModInt::mod = 0;
vector<ModInt> ModInt::facts;


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

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

  vector<int> last_idx(2e5 + 1, -1);

  vector<ModInt> dp(N);
  dp[0] = 1;
  last_idx[C[0]] = 0;
  for(int i = 1; i < N; i++){
    ModInt prev = 0;
    if(C[i] != C[i - 1] && last_idx[C[i]] != -1){
      prev = dp[last_idx[C[i]]];
    }
    last_idx[C[i]] = i;
    dp[i] = dp[i - 1] + prev;
  }
  /*
  for(auto x: dp){
    cout << x << endl;
  }
  */
  
  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 3960
#include<stdio.h>
 
int main(void){
  
  int a,b;
 
  scanf("%d%d",&a,&b);
  if(a > b){
   printf("a > b\n");
  }
  else if(a < b){ 
     printf("a < b\n");
  }
  else if(a == b){
    printf("a == b\n"); 
  }

return 0;
 
}



Measured memory_bytes: 2112
class Solution:
    def solve(self, A: int, B: int) -> str:

        if max(A, B) <= 8:
            return "Yay!"
        else:
            return ":("


if __name__ == '__main__':

    # standard input
    A, B = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(A, B))


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 */

signed main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while(1){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc143/tasks/abc143_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<ll> d(N); for(auto& in:d) cin >> in;
    
    
    for(int i = 0; i < N;i++){
        for(int j = i+1; j < N;j++){
            res += d[i]*d[j];
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const string words[4] = {"dream", "dreamer", "erase", "eraser"};
const string rword[4] = {"maerd", "remaerd", "esare", "resare"};

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	reverse(ALL(S));

	int n = (int)S.length();
	string s = "";	
	int i = 0;
	while(i < n){
		if (S[i] == 'r'){	// "dreamer"
			bool ok = false;
			if (i + 6 < n){
				s = S.substr(i,6+1);
//				cerr << "s: " << s << endl;
				if (s == rword[1]){
					i += 7;
					ok |= true;
				} // end if
			} // end if
			if (i + 5 < n){ // "eraser"
				s = S.substr(i,5+1);
//				cerr << "s: " << s << endl;
				if (s == rword[3]){
					i += 6;
					ok |= true;
				} // end if
			} // end if
			if (!ok){
				break;
			} // end if
		}else
		if (S[i] == 'm'){	// "dream"
			if (i + 4 < n){
				s = S.substr(i,4+1);
//				cerr << "s: " << s << endl;
				if (s == rword[0]){
					i += 5;
				}else{
					break;
				} // end if
			} // end if
		}else
		if (S[i] == 'e'){	// "erase"
			if (i + 4 < n){
				s = S.substr(i,4+1);
//				cerr << "s: " << s << endl;
				if (s == rword[2]){
					i += 5;
				}else{
					break;
				} // end if
			} // end if
		} // end if
	} // end while

	cout << (i == n ? "YES" : "NO") << endl;

	return 0;
}

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

vector<int> primeList(int n) {
    vector<bool> isPrime(n + 1, true);
    vector<int> prime;
    if(n >= 0) isPrime[0] = false;
    if(n >= 1) isPrime[1] = false;
    for(int i = 2; i <= n; ++i) {
        if(isPrime[i]) {
            prime.push_back(i);
            for(int j = i * 2; j <= n; j += i) {
                isPrime[j] = false;
            }
        }
    }
    return prime;
}

int main() {
    int X; cin >> X;
    auto p = primeList(2 * X + 10);
    rep(i, 2 * X) {
        if(p[i] >= X) {
            cout << p[i] << '\n';
            return 0;
        }
    }
    return 0;
}


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

l = []
for i in range(N):
    s, p = input().split()
    l.append([s, int(p), i+1])

l = sorted(l, key=lambda x: x[1], reverse = True)
l = sorted(l, key=lambda x: x[0])

for j in range(N):
    print(l[j][2])


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b) cout << c << endl;
	else if(b == c) cout << a << endl;
	else cout << b << endl;
}

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

int main(){
    constexpr long MOD = 1000000007;
    auto modinv = [&MOD](unsigned long t, unsigned long a){
        unsigned long ret = t % MOD, n = MOD - 2;
        while(n){
            if(n & 1){
                ret *= a;
                ret %= MOD;
            }
            a *= a;
            a %= MOD;
            n >>= 1;
        }
        return ret;
    };
    unsigned long B, W;
    cin >> B >> W;

    vector<unsigned long> tapi(B), tapu(W);
    tapi[0] = 1;
    tapu[0] = MOD - 1;
    for(unsigned long i = 1, j = W; i != B; ++i, ++j)tapi[i] = modinv(tapi[i - 1] * j, i);
    for(unsigned long i = 1, j = B; i != W; ++i, ++j)tapu[i] = modinv(tapu[i - 1] * j, i);

    unsigned long ans(1), den(500000004);
    for(unsigned long i = 0; i != B + W; ++i){
        cout << ans * den % MOD << endl;
        ans *= 2;
        if(i >= B - 1)ans += tapu[i - B + 1];
        if(i >= W - 1)ans += tapi[i - W + 1];
        ans %= MOD;
        den += MOD * (den & 1);
        den >>= 1;
    }
    return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b % a == 0){
			System.out.println(a+b);
		}else{
			System.out.println(b-a);
		}
	}
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
#dp5 #Knapsack 2
#個数制限ありナップサック
#1≤W≤10**9

def e():
    n,W = map(int,input().split())
    wv = [list(map(int,input().split())) for _ in range(n)]
    #横:価値　縦:品物
    dp = [[float("inf") for _ in range(10**5+1)] for _ in range(n+1)]
    dp[0][0] = 0
    for i in range(1,n+1):
        for j in range(10**5+1):
            #i番目の品物の価値より価値の制限が小さいとき(i番目の品物が使えないとき)
            if j < wv[i-1][1]:
                #i-1番目の品物の重さと同じ
                dp[i][j] = dp[i-1][j]
            else:
                #i番目の品物を使い、重さを追加する場合と使わない場合の重さを比較
                dp[i][j] = min(dp[i-1][j],dp[i-1][j - wv[i-1][1]] + wv[i-1][0])
    ans = 0
    #重さWまでの価値最大値
    for i in range(10**5+1):
        if dp[n][i] <= W:
            ans = i
    print(ans)
if __name__ == '__main__':
    e()


Measured memory_bytes: 313412
#![allow(non_snake_case)]

use std::cmp::{max, min};

fn main() {
    for _ in 1..10001 {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let A = iter.next().unwrap().parse::<isize>().unwrap();
        let B = iter.next().unwrap().parse::<isize>().unwrap();
        if A == 0 && B == 0 { break; }

        let (mx, mi) = (max(A, B), min(A, B));
        println!("{} {}", mi, mx);
    }
}



Measured memory_bytes: 5032
import java.util.*;
class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N =	sc.nextInt();
	int K =	sc.nextInt();
	if(N%K != 0) {
            System.out.println(1);
	}else {
            System.out.println(0);
	}
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
    int N;
    cin >> N;
    vector<int> cnt(N);
    for (int i = 0; i < N - 1; ++i) {
        int A;
        cin >> A;
        cnt[A - 1]++;
    }
    for (int i = 0; i < N; ++i) {
        cout << cnt[i] << endl;
    }
    return 0;
}


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

int main(){
 int a,b;
 char op;

 while(1){
  cin >> a >> op >> b;
  if(op=='+')cout << a+b << endl;
  if(op=='-')cout << a-b << endl;
  if(op=='/')cout << a/b << endl;
  if(op=='*')cout << a*b << endl;
  if(op=='?')break;
 }
 return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

vector<int> to[100005];
int dist[100005];
vector<int> path;

bool dfs(int v, int p, int x) {
    bool flg = false;
    for (int e: to[v]) {
        if (e==p) continue;
        dist[e] = dist[v] + 1;
        flg |= dfs(e, v, x);
    }
    if (v==x) flg = true;
    if (flg) {
        path.push_back(v);
    }
    return flg;
}

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};


int main(){
    int n;
    cin >> n;
    
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].emplace_back(b);
        to[b].emplace_back(a);
    }
    
    bool flg = dfs(0, -1, n-1);
    UnionFind u(n);
    reverse(whole(path));
    int m = path.size();
    int l = path[(m+1)/2-1];
    int r = path[(m+1)/2];
    if (l>r) swap(l, r);
    
    rep(i, n) {
        for (int e: to[i]) {
            if (i>e) continue;
            if (i==l && e==r) continue;
            u.unite(i, e);
        }
    }
    int x = u.size(0);
    int y = u.size(n-1);
    x += (m+1)/2;
    y += m - (m+1)/2;
    if (x>y) {
        cout << "Fennec" << endl;
    }
    else {
        cout << "Snuke" << endl;
    }
    return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

void solve() {
    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    for (int i = 1;; i++) {
        ans += a;
        if (i % 7 == 0)
            ans += b;
        if (ans >= c) {
            cout << i << endl;
            return;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3216
//Bottom up solution
//Space complexity = O(sum(v[i]))
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
	ll N, W;
	ll sum_val =0;
	cin>>N>>W;
	std::vector<ll> wt(N,0);
	std::vector<ll> v(N,0);
	for(ll i=0; i<N; i++){
		cin>>wt[i]>>v[i];
		sum_val += v[i];
	}
	vector<ll> memo(sum_val+1, INT_MAX);
	memo[0] = 0;
	for(ll i=0; i<N; i++){
		for(ll j=sum_val; j>= v[i]; j--){
			// if(j >= v[i]){
				memo[j] = std::min(memo[j-v[i]] + wt[i], memo[j]);
			// }
		}
	}

	for(ll i=sum_val; i>0; i--){
		if(memo[i] <= W){
			cout<<i<<"\n";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INT long long int
using namespace std;
INT n, a[200020], b[200020], t;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ )
        cin>>t, a[t] = i+1;
    for(int i = 1 ; i <= n ; i++ ) cout<<a[i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 1664
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N=intput()
S=input()
L1=set()
L2=set()
L3=set()
for i in range(N-1,-1,-1):
    x=int(S[i])
    for y in L2:
        L3.add(100*x+y)
    for y in L1:
        L2.add(10*x+y)
    L1.add(x)
print(len(L3))

Measured memory_bytes: 74964
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int main(void){
   int N;
   cin>>N;
   long F[N][10],P[N][11];
   for(int i=0;i<N;i++){
       for(int j=0;j<10;j++){
           cin>>F[i][j];
       }
   }
   for(int i=0;i<N;i++){
       for(int j=0;j<=10;j++){
           cin>>P[i][j];
       }
   }
   long ans=-(1<<30);
   for(int i=1;i<(1<<10);i++){
       long sum=0;
       for(int j=0;j<N;j++){
           int count=0;
           for(int k=0;k<10;k++){
              if((i>>k&1)&&F[j][k]) {
                  count++;
              }
           }
           sum+=P[j][count];
       }
       if(sum>ans){ans=sum;}
   }
   cout<<ans;
   return 0;
}


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

using ll = long long;
#define mod 1000000007
#define init ios::sync_with_stdio(0), cin.tie(0);
typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x, y) memset(x, y, sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main()
{
    init;
    int n;
    cin >> n;

    vector<long long> dp(n + 1);

    for (int i = 3; i <= n; i++)
    {
        for (int j = i - 3; j >= 0; j--)
        {
            dp[i] += dp[j];
            dp[i] %= mod;
        }
        dp[i]++;
    }

    cout << dp[n] % mod;
}

Measured memory_bytes: 3640
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int x,y;
    cin>>x>>y;
    if(y&1)
    {
        cout<<"No";
        return;
    }
    int cr=y/2-x;
    int tur=2*x-y/2;
    if(cr>=0 && tur>=0)
    {
        cout<<"Yes";
        return;
    }
    cout<<"No";
}
int main()
{
    FIO;
    //int t;
    //cin>>t;
    //while(t--)
    go();
    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex <double> point;

double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}

double get_area(vector <point> &po){
  double res=0;
  for(int i=0;i<po.size();i++)res+=cross(po[i],po[(i+1)%po.size()])/2;
  return res;
}


int main(){
  int n;
  cin>>n;
  vector <point> po;
  for(int i=0,a,b;i<n;i++)cin>>a>>b,po.push_back(point(a,b));
  printf("%.1f\n",get_area(po));
  return 0;
}

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

int main(){
  int N;
  int t[110000], x[110000], y[110000];
  cin >> N;
  for(int i=0; i < N; ++i){
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  bool can = true;
  for(int i = 0;i < N;++i){
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1] -x[i]) + abs(y[i+1] - y[i]);
    if (dt < dist) can =false;
    if (dist % 2 != dt % 2) can = false;
  }
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1408
s = input()[::-1]
l = len(s)
c = [0] * 2019
c[0] = 1
ten = 1
mod = 0
ans = 0

for i in range(l):
    mod = (mod + int(s[i]) * ten) % 2019
    ten = ten * 10 % 2019
    c[mod] += 1

for i in c:
    ans += i * (i - 1) // 2

print(ans)

Measured memory_bytes: 9288
/* C++14(GCC5.4.1) */
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main(void){
    double n; cin >> n;
    int a = (n/2.0)+1;
 
    if((int)n%2==0) cout << 0.50;
    else cout << a/n;
    return 0;
}

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

const int D = 365;
int c[26], s[D][26];

long long calc_score(int *ans, int d0) {
    long long score = 0;
    int last[26] = {};
    fill(last, last+26, -1);
    for (int d = 0; d < d0; d++) {
        score += s[d][ans[d]];
        last[ans[d]] = d;
        for (int i = 0; i < 26; i++)
            score -= c[i] * (d - last[i]);
    }
    return score;
}

int main() {
    scanf("%*d");
    for (int i = 0; i < 26; i++) cin >> c[i];
    for (int d = 0; d < D; d++)
        for (int i = 0; i < 26; i++) cin >> s[d][i];

    int ans[D];
    for (int d = 0; d < D; d++) {
        long long best_score = -(1LL<<60);
        int best_type = -1;
        for (int i = 0; i < 26; i++) {
            ans[d] = i;
            long long score = calc_score(ans, d+1);
            if (best_score < score) {
                best_score = score;
                best_type = i;
            }
        }
        ans[d] = best_type;
    }
    for (int d = 0; d < D; d++) cout << ans[d] + 1 << endl;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005];
map<llint, llint> mp;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		ans += mp[a[i]-i];
		mp[-(a[i]+i)]++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 27896
#import<atcoder/all>
#define f(i)std::cout<<i<<' '
#define g(x)f(size(x));for(auto i:x)
int u,v;main(){std::cin>>u>>v;atcoder::scc_graph G(u);for(;std::cin>>u>>v;)G.add_edge(u,v);g(G.scc()){g(i)f(i);}}

Measured memory_bytes: 40080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 100
#define Pair pair<int,int>
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int dist[MAP][MAP];
int H, W; 
char s[MAP][MAP];

int bfs(){
    queue<Pair> que;
    que.push(Pair(0,0));

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dist[i][j] = MAX;
        }
    }
    dist[0][0] = 0;
    while(que.size()){
        Pair p = que.front();
        que.pop();
        if(p.first == W-1 && p.second == H-1) break;
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(s[nx][ny]=='.' && dist[nx][ny] == MAX){
                que.push(Pair(nx,ny));
                dist[nx][ny] = dist[p.first][p.second]+1;
            }
        }
    }
    return dist[H-1][W-1];
}
int main(){
    cin >> H >> W;
    int sum_dot = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> s[i][j];
            if(s[i][j] == '.') sum_dot++;
        }
    }
    int shortest_load = bfs();
    if(dist[H-1][W-1] == MAX){
        cout << -1 << endl;
        return 0;
    }
    int ans = sum_dot - (shortest_load + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

let N = stdin.ReadLine() |> int
let S = stdin.ReadLine()

let R = new List<int>()
let G = new List<int>()
let B = new List<int>()

for i in [ 0..N - 1 ] do
    match S.[i] with
    | 'R' -> R.Add(i)
    | 'G' -> G.Add(i)
    | 'B' -> B.Add(i)

let mutable result = 0L
let mutable count = ref 0

for i in 0..R.Count - 1 do
    let ix = R.[i]
    for j in 0..G.Count - 1 do
        let jx = G.[j]

        let m = (ix, jx) |> Math.Min
        let M = (ix, jx) |> Math.Max
        let d = M - m

        if B.Contains(M + d) then incr count
        if B.Contains(m - d) then incr count
        if (M + m) % 2 = 0 && B.Contains((M + m) / 2) then incr count
        result <- result + (B.Count |> int64)

result - (!count |> int64) |> stdout.WriteLine


Measured memory_bytes: 29060
#include <stdio.h>
#define N 600

int main(void)
{
	int d[100],i=0,j=0,k=0;
	int s;
	
	while(scanf("%d",&d[i])!=EOF)
	{
		i++;
	}
	
	for(j=0;j<i;j++)
	{
		k=N/d[j]-1;
		s=k*(k+1)*(2*k+1)/6*d[j]*d[j]*d[j];
		printf("%d\n",s);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, T; cin >> n >> T;
    vector<int> cost;
    rep(i, n) {
        int c, t;
        cin >> c >> t;
        if (t <= T) cost.push_back(c);
    }
    if (sz(cost) == 0) {
        cout << "TLE" << endl;
        return 0;
    }
    sort(all(cost));
    cout << cost[0] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main() {

	int n, a[200001], i;
	unsigned long long int sum = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (i > 0) {
			if (a[i - 1] > a[i]) {
				sum = sum + (a[i - 1] - a[i]);
				a[i] = a[i] + (a[i - 1] - a[i]);
			}
		}
	}

	printf("%lld", sum);

	return 0;
}

Measured memory_bytes: 2920
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
#define maxn 200010
using namespace std;
LL ans;
int a[maxn];
int cmp(int a,int b){
	return a>b;
}
int main(){
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	ans+=a[1];
	for(i=3;i<=n;i++)
		ans+=a[(i+1)/2];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2516
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for p in range(1, 4):
 sum = 0
 for i in range(n):
  sum += math.fabs(x[i]-y[i])**p
 print(sum**(1/p))

a = []
for i in range(n):
 a.append(math.fabs(x[i]-y[i]))
a.sort()
print(a[n-1])

Measured memory_bytes: 7828
#include <iostream>

using ll = long long;
template<class H> void print(H head) {std::cout << head << std::endl;}

int main()
{
  ll A, B, C;
  std::cin >> A >> B >> C;

  ll ans = std::max(0LL, C - A + B);
  print(ans);

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

double dp[202020] = {0};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, d, x;
  cin >> n >> d >> x;
  ll t = 0;
  for (int i = 0; i < 2 * n; i++) {
    t += d;
    d += x;
  }
  for (int i = 1; i <= n; i++)
    dp[i] = 1. / 2 / i + (i - 1.) / i * (1 + 1. / i) * dp[i - 1];
  printf("%.12lf\n", dp[n] * t);
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define pqueue priority_queue
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    typedef pair<int,int> P;
    ldouble L;
    cin>>L;
    cout<<setprecision(10)<<(L/3)*(L/3)*(L/3)<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
cm = []
llm = []
lf = []
for i in range(n):
    lm = [int(k) for k in input().split()]
    c = lm.pop(0)
    llm.append(lm)
    cm.append(c)
    lf.append(False)
mc = 10000000
fc = False
while True:
    #calc
    c = 0
    lx = [0 for j in range(m)]
    for i in range(n):
        if lf[i]:
            for j in range(m):
                lx[j] += llm[i][j]
            c += cm[i]
    fx = True
    for j in range(m):
        if lx[j] < x:
            fx = False
            break
    if fx:
        if mc > c:
            mc = c
            fc = True
    #next
    f = False
    for i in range(n):
        if f:
            break
        lf[i] = not lf[i]
        f = lf[i]
    if not f:
        break
if fc:
    print(mc)
else:
    print(-1)
    






Measured memory_bytes: 9200
#include <stdio.h>
int main(void){
    int a,b,c;
    int tmp;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a>b){
        tmp=a,a=b,b=tmp;
    }
    
    if(b>c){
        tmp=b,b=c,c=tmp;
    }
    
    if(a>b){
        tmp=a,a=b,b=tmp;
    }
    
    printf("%d %d %d\n",a,b,c);
    
    return 0;
    
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
using namespace std;

int main()
{
	vector<int> v(5);
	for (int i = 0; i < 5; ++i)
	{
		cin>>v[i];
		if(v[i] == 0){
			cout<<(i+1)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

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

    string c = a + b;
    bool flag = false;

    for (int i = 1; i <= sqrt(100100); ++i) {
        if(stoi(c) == i * i){
            flag = true;
            break;
        }
    }
    if(flag)print("Yes");
    else print("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define SIZE 100000

typedef struct {
	int n, c;
	int *arr;
} list;

void ladd(list *l, int x) {
	if (l->n+1 > l->c) {
		l->c = l->c*2 + !l->c;
		l->arr = realloc(l->arr, l->c * sizeof *l->arr);
	}
	l->arr[l->n++] = x;
}

int seen[3][SIZE];
list vert[SIZE];
int q[3][SIZE], qi[3][2];

void qpush(int p, int x) {
	q[p%3][qi[p%3][1]++] = x;
}

int qpop(int p) {
	return q[p%3][qi[p%3][0]++];
}

void qreset(int p) {
	qi[p%3][0] = qi[p%3][1] = 0;
}

int qempty(int p) {
	return qi[p%3][0] == qi[p%3][1];
}

int main(void) {
	int n, m;
	scanf("%d%d", &n, &m);

	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		ladd(&vert[u-1], v-1);
	}

	int s, t;
	scanf("%d%d", &s, &t);
	s--; t--;

	int p = 0;
	qpush(0, s);
	while (!seen[0][t]) {
		if (qempty(p)) {
			qreset(p++);
			if (qempty(p)) {
				break;
			}
		}

		int cur = qpop(p);
		for (int i = 0; i < vert[cur].n; i++) {
			if (!seen[(p+1)%3][vert[cur].arr[i]]) {
				seen[(p+1)%3][vert[cur].arr[i]] = 1;
				qpush(p+1, vert[cur].arr[i]);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		free(vert[i].arr);
	}

	if (seen[0][t]) printf("%d\n", (p+1)/3);
	else puts("-1");
}


Measured memory_bytes: 6016
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
#define bp __builtin_popcount
typedef long long ll;
const ll MAX_N = 1e5+100;
using namespace std;

vector<int> g[MAX_N];
ll dp[MAX_N];
ll pd[MAX_N];
ll n , MOD;

void dfs1(int v,int p)
{
    dp[v] = 1;
    for(auto x:g[v])
    {
        if (x!=p)
            dfs1(x,v);
    }
    for(auto x:g[v])
    {
        if (x==p)
            continue;
        dp[v] *= dp[x]+1;
        dp[v] %= MOD;
    }
}

void dfs2(int v,int p)
{
    pd[v]++;
    pd[v] %= MOD;
    vector<ll> v1,v2;
    vector<int> temp;
    for(auto x:g[v])
    {
        if (x!=p)
            temp.push_back(x);
    }
    ll mul = 1;
    v1.push_back(1);
    for(auto x:temp)
    {
        mul *= dp[x]+1;
        mul %= MOD;
        v1.push_back(mul);
    }
    mul = 1;
    v2.push_back(1);
    reverse(temp.begin(),temp.end());
    for(auto x:temp)
    {
        mul *= dp[x]+1;
        mul %= MOD;
        v2.push_back(mul);
    }
    reverse(v2.begin(),v2.end());
    reverse(temp.begin(),temp.end());
    for(int i = 1;i<=temp.size();++i)
    {
        int u = temp[i-1];
        pd[u] = (((pd[v]*v1[i-1])%MOD)*v2[i])%MOD;
    }
    for(auto x:temp)
        dfs2(x,v);
}

int main()
{
    cin >> n >> MOD;
    for(int i = 2;i<=n;++i)
    {
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs1(1,0);
    dfs2(1,0);
    for(int i = 1;i<=n;++i)
        cout << ( dp[i]*pd[i] )%MOD << "\n";
    return 0;
}


Measured memory_bytes: 26496
#include <bits/stdc++.h>
 using namespace std;
int main() {
long long A, B;
cin >> A >> B;
if(A % 2 != B % 2) {
cout << "IMPOSSIBLE" << endl;
} else {
 cout << (A + B) / 2 << endl;
 }
 return 0;
 }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC121_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];

            var AB = new List<Model>();

            for (int i = 0; i < N; i++)
            {
                var ab = Console.ReadLine().Split().Select(long.Parse).ToArray();
                AB.Add(new Model() { A = ab[0], B = ab[1] });
            }

            AB = AB.OrderBy(x => x.A).ToList();

            long ans = 0;
            long sum = 0;

            var n = 0;
            while (sum < M)
            {
                if (ans + AB[n].A * AB[n].B < M)
                {
                    ans += AB[n].A * AB[n].B;
                    sum += AB[n].B;
                    AB[n].B = 0;
                }
                else
                {
                    ans += AB[n].A;
                    AB[n].B--;
                    sum++;
                }
                if (AB[n].B == 0) n++;
            }

            Console.WriteLine(ans);
        }
    }

    class Model
    {
        public long A { get; set; }
        public long B { get; set; }
    }
}


Measured memory_bytes: 28084
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	# 隣接行列読み込み　リンク情報は後々使うため別に保持
	n,m = readline() |> split |> parseMap
	g = zeros(Int,n,n)
	e = Array{Int}(2,m)
	for i in 1:m
		e[:,i] = readline() |> split |> parseMap
		g[e[1,i],e[2,i]] = 1
		g[e[2,i],e[1,i]] = 1
	end

	# ラプラシアン作成
	l = diagm(g*ones(Int,n))-g

	count = 0
	for i in 1:m
		l[e[1,i],e[2,i]] += 1
		l[e[2,i],e[1,i]] += 1
		l[e[1,i],e[1,i]] -= 1
		l[e[2,i],e[2,i]] -= 1
		if rank(l) < n-1
			count += 1
		end
		l[e[1,i],e[2,i]] -= 1
		l[e[2,i],e[1,i]] -= 1
		l[e[1,i],e[1,i]] += 1
		l[e[2,i],e[2,i]] += 1
	end
	println(count)
end

main()

Measured memory_bytes: 124912
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;
int MOD;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

vector<int> G[MAX_N];
int black[MAX_N];
vi ldp[MAX_N], rdp[MAX_N];
int dp[MAX_N];

void dfs(int u, int p)
{
    vi num;
    black[u] = 1;
    each(v,G[u]){
        if(v != p){
            dfs(v,u);
            num.pb(add(black[v], 1));
            black[u] = mul(black[u], add(black[v], 1));
        }
    }
    ldp[u].resize(len(num)+1), rdp[u].resize(len(num)+1);
    ldp[u][0] = rdp[u][len(num)] = 1;
    rep(i,len(num)){
        ldp[u][i+1] = mul(ldp[u][i], num[i]);
    }
    rrep(i,len(num)){
        rdp[u][i] = mul(rdp[u][i+1], num[i]);
    }
}

void redfs(int u, int p)
{
    int id = 0;
    each(v,G[u]){
        if(v != p){
            id++;
            dp[v] = mul(mul(ldp[u][id-1], rdp[u][id]), add(dp[u], 1));
            redfs(v, u);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n >> MOD;
    rep(i,n-1){
        int u,v;
        cin >> u >> v;
        G[u-1].pb(v-1), G[v-1].pb(u-1);
    }
    dfs(0, -1);
    redfs(0, -1);
    rep(i,n){
        cout << mul(black[i], add(dp[i], 1)) << "\n";
    }
    return 0;
}

Measured memory_bytes: 25088
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    
    
    int a,b,c,d,p,e,n,f,x,y,z;
    
    cin>>n>>a>>b>>c>>d;
    
    if(n%a==0){
        x=n/a;
    }
    else if(n%a>0){
        x=n/a+1;
    }
    if(n%c==0){
        y=n/c;
    }
    else if(n%c>0){
        y=n/c+1;
    }
    
    z=min(x*b,y*d);
    cout<<z<<endl;
    
    return 0;
}


Measured memory_bytes: 3112
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    h, w = map(int, input().split())
    c_h, c_w = map(int, input().split())
    d_h, d_w = map(int, input().split())
    s = [input() for _ in range(h)]

    #output
    from collections import deque

    INF = pow(10, 10)
    dp = [[INF] * w for _ in range(h)]

    trans_a = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    trans_b = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + trans_a]

    q = deque([])
    q.append((c_h-1, c_w-1, 0))
    dp[c_h-1][c_w-1] = 0

    while q:
        x, y, t = q.popleft()

        for dx, dy in trans_a:
            nx, ny = x + dx, y + dy
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != "#" and dp[nx][ny] > t:
                q.appendleft((nx, ny, t))#ここを変更
                dp[nx][ny] = t#ここを変更

        for dx, dy in trans_b:
            nx, ny = x + dx, y + dy
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != "#" and dp[nx][ny] > t + 1:
                q.append((nx, ny, t+1))
                dp[nx][ny] = t + 1

    answer = dp[d_h-1][d_w-1]

    # %%
    if answer == INF:
        print(-1)
    else:
        print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 100836
n,m=map(int,input().split())
height=list(map(int,input().split()))
li=[]
check=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  li.append([a,b])
for i in li:
  a=i[0]
  b=i[1]
  ah=height[a-1]
  bh=height[b-1]
  if ah>bh:
    check[b-1]+=1
  elif ah<bh:
    check[a-1]+=1
  elif ah==bh:
    check[b-1]+=1
    check[a-1]+=1
print(check.count(0))

Measured memory_bytes: 28908
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int A, B, C, X;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {

    cin>>A>>B>>C>>X;
    int ans = 0;
    REP(i,0,A+1){
        REP(j,0,B+1){
            REP(k,0,C+1) {
                if(500*i + 100*j + 50*k == X) ans++;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

const i64 MOD = 1e9 + 7;

// O(log a)
int64_t powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for (int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if (p & 1) value = (value * mul) % MOD;
    }
    return value;
}

int64_t invmod(int64_t x) {
    return powmod(x, MOD - 2);
}

i64 dp[5001][5001];

int main() {
    int K, C;
    cin >> K;
    string s;
    cin >> s;
    C = s.size();
    i64 ans = 0;
    for(int k = 0; k <= K; k++) {
        for(int t = 0; t <= 5000; t++) {
            if(k == 0) {
                dp[k][t] = t == 0 ? 1 : 0;
            } else {
                dp[k][t] = 0;
                if(t < 5000) {
                    dp[k][t] += dp[k - 1][t + 1];
                }
                if(t > 0) {
                    dp[k][t] += 2 * dp[k - 1][t - 1];
                } else {
                    dp[k][t] += dp[k - 1][t];
                }
                dp[k][t] %= MOD;
            }
        }
    }
    ans = (dp[K][C] * invmod(powmod(2, C))) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)
int t[mex];

void update(int v, int tl, int tr, int l, int r, int add) {
    if (l > r)
        return;
    if (l == tl && r == tr) {
        t[v] += add;
    } else {
        int tm = (tl + tr) / 2;
        update(v*2+1, tl, tm, l, min(r, tm), add);
        update(v*2+2, tm+1, tr, max(l, tm+1), r, add);
    }
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr)
        return t[v];
    int tm = (tl + tr) / 2;
    if (pos <= tm)
        return t[v] + get(v*2+1, tl, tm, pos);
    else
        return t[v] + get(v*2+2, tm+1, tr, pos);
}
int main(){
	fast
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	 cin>>a[i];
	
	while(k--){
		memset(t,0,sizeof(t));
		for(int i=0;i<n;i++){
		 update(0,0,n-1,max(0,i-a[i]),min(n-1,i+a[i]),1);
		 //cout<<max(0,i-a[i])<<" "<<min(n-1,i+a[i])<<endl;
	    }
		int b[n];
		for(int i=0;i<n;i++)
		 b[i]=get(0,0,n-1,i);
		
		int q=0;
		for(int i=0;i<n;i++){
			if(a[i]!=b[i]){
				q=1;
				break;
			}
		}
		if(q==0)
		 break;
		for(int i=0;i<n;i++)
		 a[i]=b[i];
	 }
	 for(int i=0;i<n;i++)
	  cout<<a[i]<<" ";
	      
				   	 
}


Measured memory_bytes: 9116
#editorial参照
#星状グラフに追加するのは連結性や総数の把握が困難
#最大の星状グラフから減らすほうがよい
import sys
n,k = map(int,input().split( ))

cnt = (n-2)*(n-1)//2-k

if cnt<0:
    print(-1)
    sys.exit()
edg_ad = []
for v in range(2,n+1):
    if cnt == 0:
        break
    for u in range(2,v):
        if cnt == 0:
            break
        edg_ad.append((u,v))
        cnt -= 1
ans = []
for v in range(2,n+1):
    ans.append((1,v))
ans2 = set(ans)|set(edg_ad)
ans2 = list(ans2)
ans2.sort()
print(len(ans2))####これ
for e in ans2:
    print(*e)

    
   

Measured memory_bytes: 43504
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll n;
    cin >> n;
    ll a[n];
    F0R(i,n) cin >> a[i];
    ll firstOrder = 0;
    ll secondOrder = 0;
    F0R(i,n)
      if(firstOrder <= a[i]){
        secondOrder = firstOrder;
        firstOrder = a[i];
      }
      else if(secondOrder < a[i]){
        secondOrder = a[i];
      }
    F0R(i,n){
      if(a[i] == firstOrder) cout << secondOrder << endl;
      else cout << firstOrder << endl;
    }
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 3200
#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()
{
    ll n,k;
    cin >> n >> k;
    ll ans = 1;
    rep(i,n){
        if(i == 0) ans *= k;
        else ans *= k-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652