akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
vector<int>p;
int main(){
    int n;
    cin >> n;
    for(int i = 2; i <= 100; i++){
        bool f = true;
        for(int j = 2; j*j <= i; j++){
            if(i%j==0){
                f = false;
                break;
            }
        }
        if(f)p.push_back(i);
    }
    vector<int>a(p.size(),0);
    for(int i = 2; i <= n; i++){
        rep(j,p.size()){
            int k = i;
            while(k%p[j]==0){
                a[j]++;
                k/=p[j];
            }
        }
    }
    //rep(i,p.size())show(a[i]);
    int ans = 0;
    rep(i,p.size()){
        rep(j,p.size()){
            rep(k,p.size()){
                
                if(i != j and j != k and k!= i and a[i]>=2 and a[j] >= 4 and a[k] >= 4)ans++;
            }
        }
    }
    ans /= 2;
    rep(i,p.size()){
        rep(j,p.size()){
                if(i != j and a[i]>=14 and a[j] >= 4 )ans++;
        }
    }
    rep(i,p.size()){
        rep(j,p.size()){
            if(i != j and a[i]>=24 and a[j] >= 2)ans++;
        }
    }
    if(a[0]>=74)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)
	var cost int
	if (c < a && c < b) || ((c < a || c < b) && c*2 < a+b) {
		n := Min(x, y)
		cost += c * 2 * n
		x -= n
		y -= n
	}
	if c*2 < a {
		cost += c * 2 * x
		x = 0
	}
	if c*2 < b {
		cost += c * 2 * y
		y = 0
	}
	cost += a * x
	cost += b * y

	fmt.Println(cost)
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long mod = (long)Math.pow(10,9)+7;
        int n = sc.nextInt();
        if(n < 1200){
            System.out.println("ABC");
        }else if(n < 2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
    }
}

class Combination {
    final static long mod = (long)Math.pow(10,9)+ 7;
    private static long[] fact, ifact;
    public Combination(int n){
        fact = new long[n+1];
        ifact = new long[n+1];
        fact[0] = 1;
        long ln = n;
        for (long i = 1; i <= ln; ++i){
            int ii = (int)i;
            fact[ii] = fact[ii-1]%mod * i % mod;
        }
        ifact[n] = pow(fact[n],this.mod-2);
        for (int i = n; i >= 1; --i){
            int ii = (int)i;
            ifact[ii-1] = ifact[ii]%mod*i%mod;
        }
    }
    
    public static long comb(int n, int k){
        if (k < 0 || k > n) return 0;
        return fact[n] % mod * ifact[k] % mod * ifact[n-k] % mod;
    }
    
    public static long perm(int n, int k){
        return comb(n,k) * fact[k] % mod;
    }
    
    public static long pow(long a,long b) {
        long ret = 1;
        long tmp = a;
        while(b>0) {
            if((b&1)==1){
                ret = (ret * tmp) % mod;
            }
            tmp = (tmp * tmp) % mod;
            b = b>>1;
        }
        return ret;
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25240
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, a[310000], b[310000];
string str[10000];
bool f;
char c[1100][1100];
int main() {
	cin >> n >> m;
	m += n * 3;
	cout << m / 2 << endl;
	return 0;
}


Measured memory_bytes: 384
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


K = int(input())

L = [[0] * (K+1) for _ in range(K+1)]
ans = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        x, y = sorted([a, b])
        if L[x][y] == 0:
            d = gcd(a, b)
            L[x][y] = d
        else:
            d = L[x][y]
        for c in range(1, K+1):
            x, y = sorted([d, c])
            if L[x][y] == 0:
                t = gcd(d, c)
                L[x][y] = t
                ans += t
            else:
                ans += L[x][y]


print(ans)

Measured memory_bytes: 69400
from heapq import heappush, heappop
X, Y, Z, K, *L = map(int, open(0).read().split())
A = L[:X]
B = L[X:X+Y]
C = L[X+Y:]
ab = []
for i in range(X):
  for j in range(Y):
    ab += [A[i]+B[j]]
ab.sort(reverse=True)
ls = []
for i in range(Z):
  heappush(ls,(-ab[0]-C[i],i,0))
for i in range(K):
  m, j, cnt = heappop(ls)
  print(-m)
  if cnt+1<X*Y:
    heappush(ls,(-ab[cnt+1]-C[j],j,cnt+1))

Measured memory_bytes: 55308
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

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

	ll n, i, d, x, y, ans = 0;
	cin >> n >> d;
	rep(i, 0, n)
	{
		cin >> x >> y;
		if(sqrt(x * x + y * y) <= d)
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
"""
例2:
R R L L L L R L R R L L
0 3 3 0 0 0 1 1 0 2 2 0

入力が 10 ** 5 以下なので行けるところまで移動が行われる。
最終的には"RL"の部分で行ったり来たりすることになるので、
これらには必ずそれぞれ1人以上いる。
'RL'の左側の'R'と右側の'L'の個数によって、間の'RL'の人数が決まる。
10 ** 100 は偶数なので、'RL'すぐ左隣の'R'に位置していた人は、
最終的には'R'の'L'の部分に行く(偶数のやつは偶数に、奇数のやつは奇数に移動)。
"""
S = input()
ans = [0] * len(S)
cnt_even = 0
cnt_odd = 0
r_idx = 0
l_idx = 0
S += 'R'    # 'LR'で終わらせたいため
for i in range(1, len(S)):
    if S[i - 1] == 'R' and S[i] == 'L':
        # 'RL'発見。'R'数え上げ終わり
        l_idx = i   # l_idx決定
        cnt_even += 1
        cnt_odd += 1
    elif S[i - 1] == 'R' and S[i] == 'R':
        # 'R'数え上げ
        r_idx = i   # r_idx決定
        if (i - 1) % 2 == 0:
            cnt_even += 1
        else:
            cnt_odd += 1
    elif S[i - 1] == 'L' and S[i] == 'L':
        # 'L'数え上げ
        if i % 2 == 0:
            cnt_even += 1
        else:
            cnt_odd += 1
    else:
        # 'LR'発見。'L'数え上げ終わり
        ans[r_idx] += cnt_even if r_idx % 2 == 0 else cnt_odd
        ans[l_idx] += cnt_even if l_idx % 2 == 0 else cnt_odd

        # カウントリセット
        cnt_even = 0
        cnt_odd = 0

        r_idx = i   # r_idx決定
print(*ans)


Measured memory_bytes: 79036
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
int main()
{
    ll n;cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    sort(arr,arr+n);
    ll res=1,mx=1000000000000000000;
    for(int i=0;i<n;i++)
    {
        if((res>1000000000 && arr[i]>=1000000000)||(res>=1000000000 && arr[i]>1000000000))
        {
            res=-1;
           break;
        }
        else
            res*=arr[i];
    }
    if(res>mx)
        res=-1;
    cout<<res<<endl;
}


Measured memory_bytes: 4332
use proconio::{input, marker::Chars};

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let t_length = t.len();
    let sub = s.len() - t_length;
    let mut nnn = 0;

    for n in 0..(sub + 1) {
        let mut nn = 0;
        for i in 0..t_length {
            if s[n + i] == t[i] {
                nn += 1;
            }
        }
        if nnn < nn {
            nnn = nn;
        }
    }
    println!("{}", t_length - nnn);
}

Measured memory_bytes: 2160
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

ll mod_pow(ll x, ll e) {
    ll y = 1;
    while(e) {
        if(e&1) y = (y * x)%MOD;
        x = (x*x)%MOD;
        e >>= 1;
    }
    return y;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll m,n; cin >> m >> n;
    cout << mod_pow(m,n) << endl;
    return 0;
}


Measured memory_bytes: 3168
import Foundation

func readTwoInts(separator: String.Element = " ") -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func mainB() {
    let (N, D) = readTwoInts()

    var count = 0
    for i in 0..<N {
        let (x, y) = readTwoInts()

        if sqrt(Double((x * x) + (y * y))) <= Double(D) {
            count += 1
        }
    }

    print(count)
}
mainB()

Measured memory_bytes: 13596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  int answer = 0;
  std::vector<int> V(N);
  std::vector<int> C(N);
  std::vector<int> sa(N);
  /*int V[N];
  int C[N];
  int sa[N];
  */
  for(int i=0;i<N;i++){
    std::cin >> V[i];
  }
  for(int i=0;i<N;i++){
    std::cin >> C[i];
  }
  for(int i=0;i<N;i++){
    sa[i] = V[i] - C[i];
  }
  std::sort(sa.begin(), sa.end());
  std::reverse(sa.begin(), sa.end());
  for(int i=0;i<N;i++){
    if (sa[i] > 0) {
     answer=answer+sa[i];
    }
  }
std::cout << answer << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {

  int a, b, c;
  cin >> a >> b >> c;
  int ans = max({10*a+b+c, a+10*b+c, a+b+10*c});
  
  cout << ans << endl;
  return 0;
}

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

int main(){
    int a, b, k;
    cin>>a>>b>>k;
    for(int i=0;i<k;i++){
        if(a+i<=b)cout<<a+i<<endl;
    }
    for(int i=0;i<k;i++){
        if(b-k+i+1>a+k-1)cout<<b-k+i+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repm(i,m,n) for (int i = (m); i < (n); i++)
#define rrep(i,n) for (int i = (n); i >= 0; i--)
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  
  rep(i,9) {
    if (111*(i+1) - N >= 0) {
      cout << 111*(i+1) << endl;
      return 0;
    }
  }
   
  return 0;
}

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

using namespace std;



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

  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W));

  for (auto& row : A)
    for (auto& aij : row)
      cin >> aij;

  vector<tuple<int,int,int,int>> res;
  for (int i = 0; i < H; ++i)
    for (int j = 0; j+1 < W; ++j)
      if (A[i][j] & 1)
      {
        A[i][j]--; A[i][j+1]++;
        res.emplace_back(i+1, j+1, i+1, j+2);
      }

  for (int i = 0; i+1 < H; ++i)
    if (A[i][W-1] & 1)
    {
      A[i][W-1]--; A[i+1][W-1]++;
      res.emplace_back(i+1, W, i+2, W);
    }

  cout << res.size() << "\n";
  for (auto& r : res)
    cout << get<0>(r) << " " << get<1>(r) << " " << get<2>(r) << " " << get<3>(r) << "\n";

  return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e3 + 5;

int cnt[MAXN][MAXN];

map<ll, ll> st2_ans;
map<ll, ll> mem;

ll rec_sol(ll val){
	if (val == 0){
		return 0ll;
	}
	if (mem.find(val) != mem.end()){
		//printf("! %lld %lld\n", val, mem[val]);
		return mem[val];
	}
	if (st2_ans.find(val) != st2_ans.end()){
		//printf("@ %lld %lld\n", val, st2_ans[val]);
		return mem[val] = st2_ans[val];
	}
	ll st2 = st2_ans.lower_bound(val)->_1;
	/*if (val == st2 - 1){
		printf("# %lld %lld\n", val, st2_ans[st2] - 1);
		return mem[val] = st2_ans[st2] - 1;
	}*/
	st2 = st2 / 2;
	ll v1 = rec_sol(st2);
	ll v2 = rec_sol(val - st2);
	ll v3 = rec_sol(2 * st2 - val - 1);
	ll v4 = ((2 * v1 + v2 - v3 - 1) % MOD + MOD) % MOD;
	//printf("$ %lld %lld\n", val, v4);
	return mem[val] = v4;
}

void solve(){
	ll n;
	cin >> n;
	n++;
	st2_ans[1ll] = 1;
	for(ll a = 1; a <= n; a = a * 2ll){
		st2_ans[a * 2ll] = (3ll * st2_ans[a] - 1 + MOD) % MOD;
	}
	
	ll ans = rec_sol(n);
	printf("%lld\n", ans);
	
	/*FA(it, st2_ans){
		printf("%lld %lld\n", it->_1, it->_2);
	}*/
	
	/*int n = 31;
	REPN(a, 0, 31){
		REPN(b, 0, 31){
			cnt[a ^ b][a + b] = 1;
		}
	}
	REPN(a, 0, 31){
		REPN(b, 0, 31){
			printf("%d ", cnt[a][b]);
		}
		putchar('\n');
	}
	
	REPN(i, 0, 31){
		int c = 0;
		REPN(a, 0, i){
			REPN(b, 0, i){
				c += cnt[a][b];
			}
		}
		printf("%d %d\n", i, c);
	}*/
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}



int main() {
	int a, b; cin >> a >> b;
	cout << (a-1) * (b-1) << endl;

}


Measured memory_bytes: 256
'''
Created on 2020/08/21

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  a=list(map(int,pin().split()))
  cnt=0
  before=0
  for i in a:
    if before==i:
      before=0
      cnt+=1
    else:
      before=i
  print(cnt)
  return
main()

Measured memory_bytes: 9128
import java.util.Scanner;

public class Main {
    private static final String YES = "YES";
    private static final String NO  = "NO";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 鬼の初期位置
        long a = sc.nextLong();
        // 鬼の速度
        long v = sc.nextLong();
        // 逃げる子供の初期位置
        long b = sc.nextLong();
        // 速度
        long w = sc.nextLong();
        
        long t = sc.nextLong();
        
        boolean isCatch = false;

        if (a == b) {
            isCatch = true;
        } else if (v <= w) {
            isCatch = false;
        } else if (a < b) {
            // 正の方向
            long aPoint = v * t + a;
            long bPoint = w * t + b;
            
            isCatch =  bPoint <= aPoint; 
        } else {
            // 負の方向
            long aPoint = (-v * t) + a;
            long bPoint = (-w * t) + b;
            isCatch = bPoint >= aPoint;
        }

        System.out.println(isCatch ? YES : NO);
    }
}

Measured memory_bytes: 26976
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		for (int i = n - 1; i >= 0; i--) {
			System.out.print(array[i]);
			if (i != 0) { System.out.print(" "); }
			else System.out.print("\n");
		}
	}
}


Measured memory_bytes: 26296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

int A, P;

signed main() {
    cin >> A >> P;

    int piece = P + A * 3;
    int ans = piece / 2;
    cout << ans << endl;

    return 0;
}


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



int main() {
    int N, K;
    cin >> N >> K;
    vector<long> H(N);
    for(int i=0;i<N;i++) cin >> H.at(i);
    long ans=0;
    if(N<=K) cout << ans << endl;
    else{
        sort(H.begin(), H.end());
//        sort(H.begin(),H.end(),greater<int>());
////        reverse(H.begin(), H.end());
//        for(int i=0;i<K;i++) H.erase(H.begin());
        for(int i=0;i<N-K;i++) ans+=H.at(i);
        cout << ans << endl;
   }
}


Measured memory_bytes: 1792
n,m,x = gets.split.map(&:to_i)
book = []
n.times do
  a = gets.split.map(&:to_i)
  book << a
end
min = 10**8
for i in 0..(2**n - 1)
  pr = Array.new(m+1,0)
  for j in 0..(n-1)
    if i[j] == 1
      for k in 0..m
        pr[k] += book[j][k]
      end
    end
  end
  bb = true
  for l in 1..m
    bb = false if pr[l] < x
  end
  if bb && pr[0] < min
     min = pr[0]

  end
end

if min == 10**8
  puts -1
else
  puts min
end

Measured memory_bytes: 14372
from bisect import*
a,b,q=map(int,input().split())
a1=[int(input())for i in range(a)]
b1=[int(input())for i in range(b)]
q=[int(input())for i in range(q)]

mama=max(a1[-1],b1[-1])
mami=min(a1[-1],b1[-1])
mimi=min(a1[0],b1[0])
mima=max(a1[0],b1[0])

a1=[-20**10]+a1+[20**10]
b1=[-20**10]+b1+[20**10]

#print(mama,mami,mima,mimi)
for i in q:
    if i>=mama:
        print(i-mami)
    elif i<=mimi:
        print(mima-i)
    else:
        x=bisect_left(a1,i)
        y=bisect_left(b1,i)
        #print(a1[x-1],a1[x],b1[y-1],b1[y])
        low =i-min(a1[x-1],b1[y-1])
        high=max(a1[x],b1[y])-i
        turn1=min(a1[x]-i,i-b1[y-1])+abs(a1[x]-b1[y-1])
        turn2=min(b1[y]-i,i-a1[x-1])+abs(b1[y]-a1[x-1])
        print(min(low,high,turn1,turn2))
#print(a1,b1,q)

Measured memory_bytes: 16784
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> cnt(M,0);
  for (int i=0; i<N; i++) {
    int K;
    cin >> K;
    for (int j=0; j<K; j++) {
      int A;
      cin >> A;
      A--;
      cnt[A]++;
    }
  }
  int ans = 0;
  for (int i=0; i<M; i++) {
    if (cnt[i] == N) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC157B - Bingo

        Scanner sc = new Scanner(System.in);

        int[][] a = new int[3][3];
        int[][] x = new int[3][3];

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int n = sc.nextInt();

        int[] b = new int[n];

        for (int k = 0; k < n; k++) {
            b[k] = sc.nextInt();
            for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    if (a[i][j] == b[k]) {
                        x[i][j] = 1;
                    }
                }
            }
        }

        String ans = "No";
        if ((1 == x[0][0] && 1 == x[0][1] && 1 == x[0][2]) ||
            (1 == x[1][0] && 1 == x[1][1] && 1 == x[1][2]) ||
            (1 == x[2][0] && 1 == x[2][1] && 1 == x[2][2]) ||
            (1 == x[0][0] && 1 == x[1][0] && 1 == x[2][0]) ||
            (1 == x[0][1] && 1 == x[1][1] && 1 == x[2][1]) ||
            (1 == x[0][2] && 1 == x[1][2] && 1 == x[2][2]) ||
            (1 == x[0][0] && 1 == x[1][1] && 1 == x[2][2]) ||
            (1 == x[0][2] && 1 == x[1][1] && 1 == x[2][0])) {
               ans = "Yes";
           }

        System.out.println(ans);
    }
}

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


int main(void){
    int n,x;
    cin>>n>>x;
    int mn=INF,sum=0;
    rep(i,n){
        int m;
        cin>>m;
        mn = min(mn,m);
        sum += m;
    }
    cout<<n + (x-sum)/mn<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
a_z = 'abcdefghijklmnopqrstuvwxyz'
D1 = dict(zip([c for c in a_z],[-1 for _ in range(len(a_z))]))
D2 = dict(zip([c for c in a_z],[-1 for _ in range(len(a_z))]))
for x, y in zip(s, t):
    if D1[x] == -1:
        D1[x] = y
    else:
        if D1[x] != y:
            print('No')
            exit()
    if D2[y] == -1:
        D2[y] = x
    else:
        if D2[y] != x:
            print('No')
            exit()
else:
    print('Yes')

Measured memory_bytes: 3632
def solve(string):
    l, r = map(int, string.split())
    if r - l >= 2019:
        return "0"
    return str(min([i * j % 2019 for i in range(l, r + 1) for j in range(i+1, r + 1)]))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 75392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;


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

    if(N == 1){
        cout << "Yes" << endl;
        cout << "2" << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
        return 0;
    }

    ll k = 3;
    while(k * (k - 1) / 2 < N){
        k++;
    }
    ll M = k * (k - 1) / 2;
    if(N != M){
        cout << "No" << endl;
        return 0;
    }

    vector<vector<ll>> ans(k);
    int v = 1;
    for(int i=0;i<k;i++){
        for(int j=i + 1;j<k;j++){
            ans[i].push_back(v);
            ans[j].push_back(v);
            v++;
        }
    }
    cout << "Yes" << endl;
    cout << k << endl;
    for(int i=0;i<k;i++){
        cout << ans[i].size();
        for(auto j : ans[i]){
            cout << " " << j;
        }
        cout << endl;
    }

    return 0;
}

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

//#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","w",stdout);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n;
    cin>>n;
    vector <int> a(n);
    int g;
    vector <int> f(1000000+5);
    loop(i,0,n)
    {
        cin>>a[i];
        f[a[i]]++;

        if(i==0) g=a[i];

        else g=__gcd(g,a[i]);
    }


    if(g>1)
    {
        cout<< "not coprime";
        return 0;
    }
    bool fl=0;
    vector <int> freq(1000000+5);
    loop(i,2,1000000+1)
    {
        for(int j=i;j<=1000000;j+=i)
        {
            freq[i]+=f[j];
        }
        if(freq[i]>1)
        {
            fl=1;
            break;
        }
    }
    if(!fl)
    {
        cout<< "pairwise coprime";
        return 0;
    }

    if(g==1)
        cout<< "setwise coprime";
    else
        cout<< "not coprime";




    return 0;
}


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

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  int n;
  string s;
  cin >> n >> s;

  unsigned long long r = 0, g = 0, b = 0;
  for (char c : s) {
    if (c == 'R') {
      r++;
    } else if (c == 'G') {
      g++;
    } else if (c == 'B') {
      b++;
    }
  }

  unsigned long long answer = r * g * b;

  Rep(i, n) {
    For(j, i + 1, n) {
      int k = j + j - i;
      if (k < n && s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
        answer--;
      }
    }
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 3620
#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(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i+1];
  
  int ans = 0, now = a[1];
  rep(i,n){
  	++ans;
  	if(now == 2){
  		cout << ans << endl;
  		return 0;
  	}
  	if(now == 1){
  		break;
  	}
  	now = a[now];
  }
  cout << -1 << endl;
  return 0;
}

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

int main()
{
    string S;
    cin >> S;

    if (S == "ABC")
        cout << "ARC";
    else
        cout << "ABC";

    return 0;
}

Measured memory_bytes: 3600
async function main(){
    const n = await input();
    const ans = (parseInt(n) <= 999) ? 'ABC' : 'ABD';
    console.log(ans);
}

function input(){
    const readline = require('readline')
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    return new Promise((resolve, reject) => {
        rl.on('line', (line) => {
            resolve(line);
            rl.close();
        })
    })
}

main()

Measured memory_bytes: 31000
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	double a, b;
	cin >> a >> b;
	for (int i=0; i<1010; i++) {
		if ((i*8/100 == a) && (i*1/10 == b)){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 888
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 2e6 + 200;
const long long MNN = 2e3 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong m, k;
llong b[MXN];

int main () {
    ios;
    cin >> m >> k;
    if(m == 1) {
        if(k == 0) cout << "0 0 1 1";
        else cout << -1;
        return 0;
    }
    if(m == 0) {
        if(k == 0) cout << "0 0";
        else cout << -1;
        return 0;
    }
    llong xr = 0;
    for(int i = 0; i < (1 << m); i++){
        if(i != k) xr ^= i;
    }
    if(xr != k) return cout << -1, 0;
    for(int i = 0; i < (1 << m); i++){
        if(i != k) cout << i << ' ';
    }
    cout << k << ' ';
    for(int i = (1 << m) - 1; i >= 0; i--){
        if(i != k) cout << i << ' ';
    }
    cout << k;
    return 0;
}

/*
9 7 2
3 4 1 9 4 1 7 1 3
*/


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int c[10][10];

int main(){
    cin.sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(i, 10)rep(j, 10) cin >> c[i][j];
    rep(i, 10)rep(j, 10)rep(k, 10) minch(c[j][k], c[j][i] + c[i][k]);
    int ans = 0;
    rep(i, h * w) {
        int a;
        cin >> a;
        if (a != -1) ans += c[a][1];
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define nl cout<<"\n";
#define sp cout<<" ";

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    string s;
    cin>>s;
    int n=sz(s),cnt=0;
    lo(i,0,n)
    {
       if(s[i]!=s[n-1-i])
         cnt++;
    }
    cout<<cnt/2;
    nl;
    return 0;
}


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

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0))
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

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

int main(){
  int n,ac=0,wa=0,tle=0,re=0;
  cin >> n;
  string s[n];
  for(int i=0;i<n;i++)
    cin >> s[i];
  for(int i=0;i<n;i++){
    if(s[i]=="AC"){
      ac++;
    }
    else if(s[i]=="WA"){
      wa++;
    }
    else if(s[i]=="TLE"){
	  tle++;
    }
    else{
      re++;
    }
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

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

using i32 = int;
using i64 = long long;
constexpr i32 maxn = 100000;

inline i32 in() {
	static i32 n;
	scanf("%d", &n);
	return n;
}

i32 a[maxn + 1];

i32 main() {
	const i32 n = in(), T = in();
	for (i32 i = 1; i <= n; ++i)
		a[i] = in();
	
	std::pair<i32, i32> ans = std::make_pair(0, 0);
	for (i32 i = n, mx = 0; i > 0; --i) {
		mx = std::max(mx, a[i]);
		const i32 val = mx - a[i];
		if (val > ans.first) ans = std::make_pair(val, 1);
		else if (val == ans.first) ++ans.second;
	}
	printf("%d\n", ans.second);
	
	return 0;
}

Measured memory_bytes: 3540
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int h,w,n;
int x,y,dx,dy;
string s,t;
int main()
{
    scanf("%d%d%d",&h,&w,&n);
    scanf("%d%d",&x,&y);
    dx=x; dy=y;
    cin>>s; cin>>t;
    bool f=true;
    x=dx; y=dy;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='U') x--;
        if(x<1) f=false;
        if(t[i]=='D') x++;
        if(x>h) x=h;
    }
    x=dx; y=dy;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='D') x++;
        if(x>h) f=false;
        if(t[i]=='U') x--;
        if(x<1) x=1;
    }
    x=dx; y=dy;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='L') y--;
        if(y<1) f=false;
        if(t[i]=='R') y++;
        if(y>w) y=w;
    }
    x=dx; y=dy;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R') y++;
        if(y>w) f=false;
        if(t[i]=='L') y--;
        if(y<1) y=1;
    }
    if(f) puts("YES"); else puts("NO");
    return 0;
}



Measured memory_bytes: 776
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int x = scanner.nextInt();
			int n = scanner.nextInt();
			int e = scanner.nextInt();
			if ((x | n | e) == 0)
				break;
			int[] v = new int[x];
			for (int i = 0; i < x; i++) {
				v[i] = scanner.nextInt();
			}
			int[][] ev = new int[n + 1][2];
			while (e-- > 0) {
				int p = scanner.nextInt();
				int k = scanner.nextInt();
				int val = scanner.nextInt();
				ev[p][0] = k;
				ev[p][1] = val;
			}
			Map<Integer, List<Double>> map = new HashMap<Integer, List<Double>>();

			List<Double> list = new ArrayList<Double>();
			for (int i = 0; i <= n; i++) {
				list.add(0d);
			}
			list.set(0, 1.0);
			map.put(0, list);
			for (int i = 0; i < n; i++) {
				Map<Integer, List<Double>> tmpMap = new HashMap<Integer, List<Double>>();
				tmpMap.putAll(map);
				for (Entry<Integer, List<Double>> entry : map.entrySet()) {
					int j = entry.getKey();
					if (entry.getValue().get(i) == 0)
						continue;
					for (int k = 0; k < x; k++) {
						int np = Math.min(n, i + v[k]);
						int nm = j;
						if (ev[np][0] == 1)
							np = Math.min(n, np + ev[np][1]);
						else if (ev[np][0] == 2)
							nm += ev[np][1];
						else if (ev[np][0] == 3)
							nm = Math.max(0, nm - ev[np][1]);
						List<Double> tmp;
						if (!tmpMap.containsKey(nm)) {
							tmp = new ArrayList<Double>();
							for (int l = 0; l <= n; l++) {
								tmp.add(0d);
							}
						} else {
							tmp = tmpMap.get(nm);
						}
						double t = tmp.get(np);
						tmp.set(np, t + entry.getValue().get(i) / x);
						tmpMap.put(nm, tmp);
					}
					
				}
				map = tmpMap;

			}
			double ans = 0;
			for (Entry<Integer, List<Double>> enty : map.entrySet()) {
				ans += enty.getKey() * enty.getValue().get(n);
			}
			System.out.println((int) ans);
		}
	}
}

Measured memory_bytes: 79776
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, x;
  cin >> x >> n;
  int v;
  map<int, int> vis;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vis[v] = 1;
  }
  int ans = x, mx = inf;
  for (int i = -1000; i <= 1000; i++) {
    if (vis[i]) continue;
    int d = abs(i - x);
    if (d < mx) {
      mx = d;
      ans = i;
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main()
{
  string s;
  cin >> s;
  if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
    cout << "Yes" << "\n";
  }else{
    cout << "No" << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int N,M,Y,P,F,FEE,i,res,tmp;
double RATE;

int h(int m,int y)
{
	if(y==Y)
		return m;
	else
		return h(m+m*RATE-FEE,y+1);
}

int t(int m,int y)
{
	if(y==Y)
		return 0;
	return t(m-FEE,y+1)+m*RATE;
}

int main()
{
	for(scanf("%d",&N);N--;)
	{
		scanf("%d%d%d",&M,&Y,&P);
		for(res=0;P--;)
		{
			scanf("%d%lf%d",&F,&RATE,&FEE);
			tmp=F?h(M,0):M-Y*FEE+t(M,0);
			res=res<tmp?tmp:res;
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 632
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int A[110000],n;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&A[i]);
	int ans=0;
	for (int i=1;i<=n;i++)
		if (A[i]>i&&A[A[i]]==i) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    int k,a,b;
    cin >> k;
    cin >> a >> b;
    if((b/k)-((a-1)/k)>0) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3620
require 'set'

n=gets.to_i

hist=[]
r="Yes"

(1..n).each_with_index{|_,i|
    w=    gets.chomp
    r="No" if hist.include?(w)
    r= "No" if i > 0 && hist[i-1].slice(hist[i-1].length-1) != w.slice(0)
    hist << (w)
    break if r=="No"
  }

print(r)


Measured memory_bytes: 3964
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 100000
#define MAX 1000000000000000000

int compareInt(const void* a, const void* b)
{
    int aNum = *(int*)a;
    int bNum = *(int*)b;

    return aNum - bNum;
}

int main (void)
{
    int n, k, i;
    int p[N];
    int sum = 0;

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

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

    qsort(p, n, sizeof(int), compareInt);

    for (i = 0; i < k; i++) {
        sum += p[i];
    }

    printf("%d", sum);

    return 0;
}


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

using namespace std;
typedef long long ll;

struct S
{
    int w,s,v;
    void read()
    {
        cin >> w >> s >> v;
    }

    bool operator <(const S& b)
    {
        return w+s<b.w+b.s;
    }
};

int main()
{
    //freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector <S> in(n);

    int mx_v=0;
    for (int i=0;i<n;i++)
    {
        in[i].read();
        mx_v=max(mx_v,in[i].w+in[i].s);
    }

    sort(in.begin(),in.end());
    vector <ll> dp (mx_v+1);

    for (S block:in)
    {
        for (int i=min(mx_v-block.w,block.s);i>=0;i--)
        dp[i+block.w]=max(dp[i+block.w],dp[i]+block.v);
    }

    ll ans=0;
    for (int i=0;i<=mx_v;i++)
        ans=max(ans,dp[i]);

    cout << ans;
}



Measured memory_bytes: 384
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min((a + b), min((a + c), (b + c)));
	return 0;
}



Measured memory_bytes: 3580
#!/usr/bin/env python3
# coding: utf-8
# import sys
# import pprint
# import numpy as np
# import code


if __debug__:
    debug = lambda *x: None
else:
    import logging
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ch.setFormatter(formatter)
    logger.addHandler(ch)
    debug = logger.debug

x = int(input())

debug(x)

c500 = int(x / 500)
xx = x % 500
c5 = int(xx / 5)

u = c500 * 1000 + c5 * 5

print(u)



Measured memory_bytes: 3060
m, d = map(int, input().split())
d10 = d // 10
d1 = d - d10
ans = 0
for i in range(1,m+1):
    for j in range(1, d + 1):
        j = str(j).zfill(4)
        j1 = int(j[-1])
        j10 = int(j[-2])
        if j1 >= 2 and j10 >= 2 and j1 * j10 == i:
            ans+=1
print(ans)


Measured memory_bytes: 3060
if __name__ == '__main__':
    N, M, X = map(int, input().split())
    A_list = list(map(int, input().split()))

    answer1 = 0
    answer2 = 0
    for i in range(M):
        if X < A_list[i]:
            answer1 += 1
        if X > A_list[i]:
            answer2 += 1
    print(min(answer1, answer2))


Measured memory_bytes: 3060