akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int a, b, m; cin >> a >> b >> m;
  vector<int> A(a), B(b);
  REP(i, a) cin >> A[i];
  REP(i, b) cin >> B[i];
  int ans = *min_element(ALL(A)) + *min_element(ALL(B));
  while (m--) {
    int x, y, c; cin >> x >> y >> c; --x; --y;
    chmin(ans, A[x] + B[y] - c);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

#include<iostream>
#include<map>
#include<queue>
#include<vector>
#include<string>
#include<cstring>

using namespace std;

int const N = 1e7 + 5;
int const MOD = 1e9 + 7;
int p[N];

void pre(){
    for(int i = 1; i < N; i++){
        p[i] = (i + p[i - 1]);
        if(p[i] >= MOD) p[i] -= MOD;
    }
}

inline long long mul(long long a, long long b){
    a *= b;
    a %= MOD;
    return a;
}

int main(){
    int n, d;
    cin >> n >> d;
    
    d <<= 1;
    d++;
    
    int res = (n / d) + bool(n % d);
    cout << res << endl;
}


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

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

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

int H,W,N;
vector<int> vec[200009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W>>N;
    
    rep(i,N){
        int x,y; cin>>x>>y;
        if(x<y) continue;
        vec[y].push_back(x);
    }
    
    rep1(i,W) sort(all(vec[i]));
    
    int mn=H, nowx=1;
    rep1(i,W){
        nowx++;
        for(auto x:vec[i]){
            if(x<nowx) continue;
            chmin(mn,x-1)
            if(x==nowx){
                cout1(mn)
                return 0;
            }
            break;
        }
        
        bool f=true;
        if(i<W&&vec[i+1].size()){
            f=false;
            vec[i+1].push_back(H+1);
            for(auto x:vec[i+1]){
                if(x<nowx) continue;
                if(x==nowx) nowx++;
                else{
                    f=true;
                    break;
                }
                if(nowx>=mn) break;
            }
        }
        if(!f) break;
    }
    cout1(mn)
}


Measured memory_bytes: 7552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;


vector<int> x(100001);

class Problem
{
private:
	// Variables
	int l, r;
	
public:
	// Methods
	void input ()
	{
		cin >> l >> r;
	}
	
	void process ()
	{

	}
	
	void output ()
	{
		cout << x[r] - x[l-1] << endl;
	}
};

int main ()
{
	vector<bool> is_prime;
	is_prime.resize(100001, true);
	is_prime[0] = false;
	is_prime[1] = false;
	int count = 0;
	for (int i=2; i<100001; ++i) {
		if (!is_prime[i]) continue;

		for (int j=i+i; j<100001; j+=i) {
			is_prime[j] = false;
		}
	}
	for (int i=0; i<100001; ++i) {
		if (is_prime[i] && is_prime[(i + 1) >> 1]) {
			++count;
		}
		x[i] = count;
	}

	int q;
	cin >> q;
	for (int i=0; i<q; ++i) {
		Problem problem;
		problem.input();
		problem.process();
		problem.output();
	}
	return 0;
}

Measured memory_bytes: 1024
h, w, n = gets.split.map(&:to_i)
ps = Hash.new { 0 }
n.times do
  a, b = gets.split.map(&:to_i)
  (a-1..a+1).each do |i|
    (b-1..b+1).each do |j|
      ps["#{i}:#{j}"] += 1 if 1 < i && i < h && 1 < j && j < w
    end
  end
end

rs = Array.new(10) { 0 }
s = 0
ps.each do |_, n|
  s += 1
  rs[n] += 1
end
rs[0] = (h-2)*(w-2) - s

puts rs

Measured memory_bytes: 127740
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll N;
    string S;
    in >> N;
    in >> S;
    // solution here
    REP(i, S.size()) {
        S[i] = 'A' + ((S[i] + N - 'A') % 26);
    }

    out << S << endl;
    return 0;
}


int main() {
    return run(cin, cout);
}


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

using namespace std;
typedef long long ll;

ll MOD = 1e9+7;

class mint{
    ll n;
public:
    mint(ll m = 0){
        n = ((m % MOD) + MOD) % MOD;
    }
    mint operator-() const {
        return mint(-n);
    }
    mint& operator+=(const mint& m){
        n += m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator-=(const mint& m){
        n += MOD - m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& m){
        n *= m.n;
        n %= MOD;
        return *this;
    }
    mint operator+(const mint& m) const{
        mint res(*this);
        res += m;
        return res;
    }
    mint operator-(const mint& m) const{
        mint res(*this);
        res -= m;
        return res;
    }
    mint operator*(const mint& m) const{
        mint res(*this);
        res *= m;
        return res;
    }
    mint pow(ll t) const{
        if(t == 0) return mint(1);
        mint m = pow(t>>1);
        m *= m;
        if(t & 1 == 1) m *= *this;
        return m;
    }
    // for prime modulo
    mint inv() const{
        return pow(MOD-2);
    }
    mint& operator/=(const mint& m){
        (*this) *= m.inv();
        n %= MOD;
        return *this;
    }
    mint operator/(const mint& m) const{
        mint res(*this);
        res /= m;
        return res;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.n;
        return os;
    }
};

vector<vector<ll>> G;
ll N;
ll a[200000];
ll b[200000];
mint ans(0);

ll dfs(ll n, ll p = -1){
    ll chs = 1;
    vector<ll> v;
    for(auto &e : G[n]){
        if(e==p) continue;
        ll c = dfs(e,n);
        chs += c;
        v.push_back(c);
    }
    if(p != -1) v.push_back(N - chs);
    mint all = mint(2).pow(N-1) - 1;
    for(auto &t : v){
        all -= mint(2).pow(t) - 1;
    }
    ans += all;
    return chs;
}

int main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N-1;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    dfs(0);
    cout << ans / mint(2).pow(N) << endl;
    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  
  int sum = 0;
  int sum_L = L;
  
  for(int i = 0; i < N; i++){
    sum += sum_L;
    sum_L++;
  }
  
  if(L * (L + N - 1) <= 0){
    cout << sum << endl;
  }
  else if (L > 0){
    cout << sum - L << endl;
  }
  else if (L < 0){
    cout << sum - (L + N - 1) << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  double ans = 0;

  rep(i, n) {
    if (i % 2== 0) {
      ans++;
    }
  }

  printf("%.6lf", ans/n);
}


Measured memory_bytes: 256
N, K = map(int, input().split())
d = list(map(int, input().split()))

for i in range(N, 100000):
    flag = True
    tmp = i
    for j in reversed(range(len(str(i)))):
        if (tmp // (10 ** j)) in d:
            flag = False
            break
        else:
            tmp = tmp % (10 ** j)

    if flag:
        print(i)
        break
            

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = (N / (A + B)) * A;
    ans += min(N % (A+B),A);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
const int N = 100005;
set<int> g[N];
int p[N];
int num = 0;
int find(int x){
    return x == p[x] ? x : p[x]=find(p[x]);
}
void merge(int u, int v){
    u = find(u), v = find(v);
    if (u == v) return;
    if (g[u].size() < g[v].size()) swap(u,v);
    //printf("merge %d to %d\n",v,u);
    set<ii> que;
    for (auto &x: g[v]){
        if (x == u) continue;
        //printf("%d connected to %d\n",x,v);
        g[x].erase(v);
        if (g[x].count(u)){
            que.insert({x,u});
        }
        g[u].insert(x);
        g[x].insert(u);
    }
    g[u].erase(v);
    g[v].clear();
    p[v] = u;
    for (auto cur : que){
        merge(cur.first,cur.second);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    iota(p,p+N,0);
    for (int i = 1; i < n; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        g[a].insert(b);
        g[b].insert(a);

    }
    for (int i = 1; i < n; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        a = find(a); b = find(b);
        if (g[a].count(b)) merge(a,b);
        else{
            g[a].insert(b);
            g[b].insert(a);
        }
    }
    int c = find(1);
    for (int i = 2; i <= n; i++){
        if (c != find(i)){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
}


Measured memory_bytes: 24064
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N - 1];
		int[] b = new int[N - 1];
		int[] deg = new int[N];
		ArrayList<Integer>[] g = new ArrayList[N];
		for (int i = 0; i < N; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < N - 1; ++i) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			--a[i];
			--b[i];
			g[a[i]].add(b[i]);
			g[b[i]].add(a[i]);
			++deg[a[i]];
			++deg[b[i]];
		}

		ArrayDeque<Integer> que = new ArrayDeque<>();
		for (int i = 0; i < N; ++i) {
			if (deg[i] == 1) {
				que.add(i);
			}
		}
		boolean[] used = new boolean[N];
		while (!que.isEmpty()) {
			int v = que.poll();
			if (used[v])
				continue;
			boolean update = false;
			for (int dst : g[v]) {
				if (used[dst])
					continue;
				for (int u : g[dst]) {
					if (!used[u]) {
						--deg[u];
						if (deg[u] == 1) {
							que.add(u);
						}
					}
				}
				used[dst] = true;
				update = true;
				--deg[dst];
			}
			if (!update) {
				System.out.println("First");
				return;
			}
		}
		System.out.println("Second");
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


Measured memory_bytes: 106696
#include<stdio.h>
int main(void) {
	int N,a,b=2;
	scanf("%d", &N);
	while (1) {
		if (b <= N && N < b * 2) {
			break;
		}
		b = b*2;
	}
	printf("%d\n", b);
	return 0;
}


Measured memory_bytes: 2760
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int S;
int main(){
    cin >> S;
    if(S%100 <=12 && S % 100>0){
        if(S/100 ==0){
            printf("YYMM\n");
            return 0;
        }else if(S/100 <= 12){
            printf("AMBIGUOUS\n");
            return 0;
        }else{
            printf("YYMM\n");
             return 0;  
        }
        
    }else{
        if(S/100 ==0){
            printf("NA\n");
            return 0;
        }else if(S/100 <= 12){
            printf("MMYY\n");
            return 0;
        }else{
          printf("NA\n");
          return 0;  
        }
    }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

string s;
ll n,k;

void init(){
	cin>>n>>k>>s;
	k--;
}

int main(void){
	init();
	s[k]=(s[k]-'A')+'a';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(i64);
    println!("{}", n * 800 - 200 * (n / 15));
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]int, n+1)
	x := make([]int, n+1)
	y := make([]int, n+1)
	t[0], x[0], y[0] = 0, 0, 0
	for i := 1; i <= n; i++ {
		fmt.Scan(&t[i], &x[i], &y[i])
	}

	for i := 1; i <= n; i++ {
		dt := t[i] - t[i-1]
		dist := int(math.Abs(float64(x[i]-x[i-1])) + math.Abs(float64(y[i]-y[i-1])))
		if dt < dist || dt%2 != dist%2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

using namespace std;

const long long MOD = 1e9 + 7;
const long long MAXN = 1e3 + 10;


vector<vector<long long>> fact(MAXN, vector<long long> (MAXN, 0)), invFact(MAXN, vector<long long> (MAXN, 0));

long long gcdex(long long a, long long b, long long *x, long long *y)
{
  if(a == 0)
  {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long g = gcdex(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return g;
}

long long invMod(long long a)
{
  long long x, y;
  long long g = gcdex(a, MOD, &x, &y);
  assert(g == 1);
  long long ans = (x % MOD + MOD) % MOD;
  return ans;
}

void calc()
{
  fact[0][1] = invFact[0][1] = 1;
  for(long long i = 1; i < MAXN; i++)
  {
    fact[i][1] = (fact[i - 1][1] * i) % MOD;
    invFact[i][1] = invMod(fact[i][1]);
  }
  for(long long i = 2; i < MAXN; i++)
  {
    for(long long j =  0; j < MAXN; j++)
    {
      fact[j][i] = (fact[j][i - 1] * fact[j][1]) % MOD;
      invFact[j][i] = (invFact[j][i - 1] * invFact[j][1]) % MOD;
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  calc();
  long long n;
  cin >> n;
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<vector<long long>> dp(n + 1, vector<long long> (b - a + 2, 0));
  dp[0][0] = 1;
  for(long long i = 1; i <= b - a + 1; i++)
  {
    for(int k = 0; k <= n; k++)
    {
      dp[k][i] += dp[k][i - 1];
    }
    long long box = i + a - 1;
    for(long long j = c; j <= d && (j * box) <= n; j++)
    {
      for(long long k = 0; k <= n; k++)
      {
        if(j * box + k <= n)
        {
          long long add = (fact[n - k][1] * invFact[n - k - j * box][1]) % MOD;
          (add *= invFact[box][j]) %= MOD;
          (add *= dp[k][i - 1]) %= MOD;
          (add *= invFact[j][1]) %= MOD;
          (dp[j * box + k][i] += add) %= MOD;
        }
      }
    }
  }
  cout << dp[n][b - a + 1] << endl;
  return 0;
}


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

using P = pair<long, long>;
using D = pair<long, P>;

vector<D> vs;
void make() {
  for (int i = 1; i < 151; i++) {
    for (int j = i + 1; j < 151; j++) {
      vs.push_back(D(i * i + j * j, P(i, j)));
    }
  }
  sort(vs.begin(), vs.end());
}

void solve(long h, long w) {
  long diag = h * h + w * w;
  for (auto v: vs) {
    if (diag < v.first || (diag == v.first && h < v.second.first)) {
      cout << v.second.first << " " << v.second.second << endl;
      return;
    }
  }
}

int main() {
  long h, w;
  make();
  while (1) {
    cin >> h >> w;
    if (h + w == 0) return 0;
    solve(h, w);
  }
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int N;
  string s = "No";
  vector<vector<int>> a(3, vector<int>(3));
  vector<vector<bool>> judge(3, vector<bool>(3, false));
  rep(i, 3){
    rep(j,3){
      cin>>a[i][j];
    }
  }
  cin >> N;
  
  vector<int> b(N);
  
  rep(i, N) cin>>b[i];
  
  rep(i, N){
    rep(j, 3){
      rep(k, 3){
        if(b[i] == a[j][k]) {
          judge[j][k] = true;
        }
      }
    }
  }
  
  int count = 0;
  rep(i, 3){
    rep(j, 3){
      if (judge[i][j] == true) count ++;
    }
    if (count==3) s = "Yes"; 
    count = 0;
  }
  
  count = 0;
  rep(i, 3){
    rep(j, 3){
      if (judge[j][i] == true) count ++;
    }
    if (count==3) s = "Yes"; 
    count = 0;
  }
  
  if(judge[0][0] == true && judge[1][1] == true && judge[2][2] == true) s = "Yes";
  
  if(judge[0][2] == true && judge[1][1] == true && judge[2][0] == true) s = "Yes";
  
  cout<<s<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string X;
  cin >> X;
  ll N, S, W, E;
  N = S = W = E = 0;
  rep(i, X.size()) {
    if(X.at(i) == 'W') {
      W++;
    }
    if(X.at(i) == 'E') {
      E++;
    }
    if(X.at(i) == 'S') {
      S++;
    }
    if(X.at(i) == 'N') {
      N++;
    }
  }
  if((N > 0 && S > 0) && (W == 0 && E == 0)) {
    cout << "Yes" << endl;
  }
  else if((N == 0 && S == 0) && (W > 0 && E > 0)) {
    cout << "Yes" << endl;
  }
  else if((N > 0 && S > 0) && (W > 0 && E > 0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
	int i,strlong;
	char str[21] = { 0 };
	scanf("%s",str);
	strlong = strlen(str) - 1;
	for(i=strlong;i>=0;i--){
		printf("%c",str[i]);
	}
	printf("\n");
	return 0;
}

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

char s[2010][10100];
int n,K,len[2010],T;
bitset<10100>F[2010];
vector<pair<int,int> >vec[2];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>K;
	for(int i=1;i<=n;++i)cin>>(s[i]+1),len[i]=strlen(s[i]+1);
	F[n+1][0]=1;
	for(int i=n;i;--i)F[i]=F[i+1]|(F[i+1]<<len[i]);
	for(int i=1;i<=n;++i)
		if(F[i+1][K-len[i]])vec[0].emplace_back(i,1);
	for(int i=1;i<=K;++i){
		char res='z';
		T^=1;vec[T].clear();
		for(auto j:vec[!T])res=min(res,s[j.first][j.second]);
		cout<<res;
		int pre=n;
		for(auto j:vec[!T]){
			if(s[j.first][j.second]!=res)continue;
			if(j.second!=len[j.first])vec[T].emplace_back(j.first,j.second+1);
			else pre=min(pre,j.first);
		}
		for(int j=pre+1;j<=n;++j)
			if(len[j]+i<=K&&F[j+1][K-i-len[j]])vec[T].emplace_back(j,1);
		while(vec[T].size()>=15000)vec[T].pop_back();
	}
	return 0;
}

Measured memory_bytes: 22016
#include<stdio.h>

int search(int A[], int n, int key);

int main(){
  int i, n, A[10000], q, key, cnt = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ){
    scanf("%d", &key);
    if ( search(A, n, key) ) cnt++;
  }
  printf("%d\n", cnt);


  return 0;
}

int search(int A[], int n, int key){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( A[i] == key ) return 1;
  }
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110;
int N;
int B[Max];
int A[Max];

int main(int argc, const char * argv[]) {
    cin >> N;
    inputArray(B, N-1);

    pair<int, int> Bp[Max];
    rep(i, N-1) {
        Bp[i] = make_pair(B[i], i);
    }
    sort(Bp, Bp+N-1);
    rep(i, N) {
        A[i] = -1;
    }
    
    rep(i, N-1) {
        auto& p = Bp[i];
        int j = p.second;
        if (A[j] == -1) {
            A[j] = p.first;
        }
        if (A[j+1] == -1) {
            A[j+1] = p.first;
        }
    }

    int ans = 0;
    rep(i, N) {
        ans += A[i];
    }
    output(ans);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <set>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<pair<string, int>> s(n);
    for(int i=0; i<n; i++){
        cin >> s.at(i).first >> s.at(i).second;
    }
    string x;
    cin >> x;
    bool sleep = false;
    int ans = 0;
    for(int i=0; i<n; i++){
        if(sleep){
            ans += s.at(i).second;
        }
        if(s.at(i).first == x){
            sleep = true;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string a , b , c;
  cin >> a >> b >> c;
  int k = 0;
  int l = 0;
  int m = 0;
  for(int i = 0;i < 25; i++){
    if(a[0] == alphabet[i])break;
    k++;
  }
  for(int i = 0;i < 25; i++){
    if(b[0] == alphabet[i])break;
    l++;
  }
  for(int i = 0;i < 25; i++){
    if(c[0] == alphabet[i])break;
    m++;
  }
  cout << ALPHABET[k] << ALPHABET[l] << ALPHABET[m] << endl;
}



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

int main() {
  int N,A = 0,B = 0;
  cin >> N;
  vector<int> V(N);
  for ( int i = 0 ; i < N ; i++ )
    cin >> V.at(i);
  sort ( V.begin() , V.end() );
  reverse ( V.begin() , V.end() );
  for ( int j = 0 ; j < N ; j++ ) {
    if ( j % 2 == 0 )
      A += V.at(j);
    else
      B += V.at(j);
  }
  cout << A - B << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// 最大公約数: greatest common divisor
ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); }
// 最小公倍数: least common multiple
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

  cout << lcm(a,b) << endl;
}


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

		if(a<1200){
          System.out.print("ABC");
        }else{
          System.out.print("ARC");
        }
       
       
      
    }
}

Measured memory_bytes: 23636
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    edge = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)

    res = k
    que = deque([0])
    visited = [False] * n
    visited[0] = True
    while que:
        v = que.popleft()
        cnt = 0
        for u in edge[v]:
            if not visited[u]:
                visited[u] = True
                cnt += 1
                que.append(u)
        if v == 0:
            for i in range(cnt):
                res *= (k - 1 - i)
                res %= mod
        else:
            for i in range(cnt):
                res *= (k - 2 - i)
                res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 28020
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int X_max = -200;
    int Y_min=200;
    boolean war=true;
    for(int i=0;i<N;i++){
      int x=sc.nextInt();
      if(x>X_max){
        X_max=x;
      }
    }
    for(int i=0;i<M;i++){
      int  y=sc.nextInt();
      if(y<Y_min){
        Y_min=y;
      }
    }

    for(int Z=X+1;Z<Y;Z++){
      if(X_max<Z && Z<=Y_min){
        war=false;
        break;
      }
    }
  
  if(war){
    System.out.println("War");
  }else{
    System.out.println("No War");
  }
}


}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

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

const ll INF = 1e18;

ll sum(ll n, ll b) {
    ll res = 0;
    while (n) {
        res += n%b;
        n /= b;
    }
    return res;
}

ll check(ll n, ll s, ll b) {
    if (sum(n,b) == s) return b;
    return INF;
}

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

    ll n,s;
    cin >> n >> s;
    if (s > n) cout << -1 << endl;
    else if (s == n) cout << n+1 << endl;
    else {
        ll res = INF;
        ll x = n-s;
        for (ll d = 1; d*d <= x; d++) if (x%d == 0) {
            ll d2 = x/d;
            res = min(res, check(n,s,d+1));
            res = min(res, check(n,s,d2+1));
        }
        if (res == INF) res = -1;
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 256
MOD=1000000007
S=input()[::-1]
N=len(S)
pows=list(range(10))
dp=[[0]*13 for _ in range(N+1)]
dp[0][0]=1
for i in range(N):
    for src in range(13):
        for j,p in enumerate(pows):
            if S[i]=='?' or int(S[i])==j:
                dst = (src+p)%13
                dp[i+1][dst] = (dp[i+1][dst]+dp[i][src])%MOD
    for i in range(10):
        pows[i]=(pows[i]*10)%13
print(dp[N][5])


Measured memory_bytes: 63452
#include<map>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using mint=modint998244353;
map<int,int>c,d;
int N,h;
main(){
	for(cin>>N;cin>>h;)c[h]++;
	for(auto[_,v]:c)d[v]++;
	vector<mint>D(1,1);
	for(auto[k,v]:d)if(k>1){
		vector<mint>E(k/2+1,1);
		for(int i=0;i<k/2;i++)E[i+1]=E[i]*(k-i*2)*(k-i*2-1)/2/-~i;
		for(;v;E=convolution(E,E),v/=2)if(v&1)D=convolution(D,E);
	}
	mint S=0,T=1;
	for(int i=0;i<N;)T*=1+2*i++;
	for(int i=0;i<D.size();T/=2*(N-i++)-1)S+=D[i]*T*(1-i%2*2);
	cout<<S.val();
}

Measured memory_bytes: 8100
/*
 * @Author: BilyHurington
 * @Date: 2020-03-21 20:21:44
 * @LastEditors: BilyHurington
 * @LastEditTime: 2020-03-21 20:43:01
 */
#include<bits/stdc++.h>
using namespace std;
int n,m,f[110][110][2],a[110][110],lst[2][2]={{0,-1},{-1,0}};
int main(){
    char ch;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) scanf(" %c",&ch),a[i][j]=(ch=='#');
    }
    for(int i=0;i<=n+1;i++){
        for(int j=0;j<=m+1;j++){
            f[i][j][0]=f[i][j][1]=1e9;
        }
    }
    if(!a[1][1]) f[1][1][0]=0;
    else f[1][1][1]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            for(int k=0;k<=1;k++){
                int lx=i+lst[k][0],ly=j+lst[k][1];
                if(a[i][j]){
                    f[i][j][1]=min(f[i][j][1],f[lx][ly][0]+1);
                    f[i][j][1]=min(f[i][j][1],f[lx][ly][1]);
                }
                else{
                    f[i][j][0]=min(f[i][j][0],f[lx][ly][0]);
                    f[i][j][0]=min(f[i][j][0],f[lx][ly][1]);
                }
            }
            // printf("%d ",f[i][j][a[i][j]]);
        }
        // printf("\n");
    }
    printf("%d\n",f[n][m][a[n][m]]);
    return 0;
}

Measured memory_bytes: 384
from sys import stdin
n = int(stdin.readline())
s = list(stdin.readline().strip())
def chk(x):
    for i in xrange(n):
        ne = (i + 1)%n
        pr = (i + n-1)%n
        if x[i]=='S':
            if s[i]=='o':
                if x[ne]!=x[pr]:
                    return 0
            else:
                if x[ne]==x[pr]:
                    return 0
        else:
            if s[i]=='o':
                if x[ne]==x[pr]:
                    return 0
            else:
                if x[ne]!=x[pr]:
                    return 0
    return 1                
res = '-1'
op  ={}
op['S'] = 'W'
op['W'] = 'S'
def get(ty,u,v):
    if ty == 'S':
        if v=='o':
            return u
        return op[u]
    if v=='x':
        return u
    return op[u]
def gen(u,v):
    cur = ['*'] * n
    cur[0] = u
    cur[1] = v
    cur[-1] = get(u,v,s[0])
    for i in xrange(1,n):
        pr = (n + i-1)%n
        ne = (i + 1)%n
        if cur[ne]=='*':
            cur[ne]= get(cur[pr],cur[i],s[i])
    return cur

arr = [('S','S'),('S','W'),('W','W'),('W','S')]
ans = '-1'
for x,y in arr:
    my = gen(x,y)
    if chk(my)==1:
        ans = ''.join(my)
        break
print ans        
    


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std; 
typedef long long LL;
const int mod = 1000000007;
const int MAXN = 100005;
LL num[MAXN],fact[MAXN];
LL my_pow(LL a, LL b){    
	LL sum=1;    
	while(b>0){        
		if(b&1){
			sum=sum*a%mod;
		}
		a=a*a%mod;        
		b>>=1;    
	}    
	return sum%mod;
}
void init(){    
	fact[0]=1;    
	for(int i=1;i<MAXN;++i){
		fact[i]=fact[i-1]*i%mod;
	}     
}
LL comb(LL a, LL b){    
	if(b>a){
		return 0;
	}   
	return fact[a]* my_pow(fact[b]*fact[a-b]%mod,mod-2)%mod;
}
int main(){   
	int n,k;   
	init();   
	cin>>n>>k;   
	for(int i=0;i<n;++i)       
		cin>>num[i];   
	LL ans=0;   
	sort(num, num+n);   
	for(int i=0;i<n-k+1;++i){       
		ans=(ans+(num[n-i-1]-num[i])%mod*comb(n-i-1,k-1)%mod)%mod;          
	}   
	cout<<(ans%mod+mod)%mod<<endl;
	return 0;
}


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

int main(void){
    int d;
    cin >> d;
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    
    vector<vector<int>> s (d, vector<int> (26));
    for(int j = 0; j < d; j++) for(int i = 0; i < 26; i++) cin >> s.at(j).at(i);
    
    int score = 0;
    vector<int> last(26,-1);
    
    for(int i = 0; i < d; i++) {
        int t;
        cin >> t;
        t--;
        score += s.at(i).at(t);
        last.at(t) = i;
        for(int j = 0; j < 26; j++) {
         score -= c.at(j) * (i - last.at(j));
        }
        cout << score << endl;
    }
}


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

int main(void)
{
  int num[3] = {0};
  cin >> num[0] >> num[1] >> num[2];

  int count5 = 0;
  int count7 = 0;
  for (int i = 0; i < 3; i++)
  {
    if (num[i] == 5)
    {
      count5++;
    }
    if (num[i] == 7)
    {
      count7++;
    }
  }

  if (count5 == 2 && count7 == 1)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }

  return 0;
}

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

void disp(vector<int>& v) {
    for (int i=0; i<v.size()-1; i++) {
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
}

void bubbleSort(vector<int>& v) {
    bool flag = true;
    int swapCount = 0;
    while (flag) {
        flag = false;
        for (int i=v.size()-1; i>=1; i--) {
            if (v[i] < v[i-1]) {
                swap(v[i], v[i-1]);
                swapCount++;
                flag = true;
            }
        }
    }
    disp(v);
    cout << swapCount << endl;
}

int main() {
    int i, n, tmp;
    vector<int> v;

    cin >> n;
    for (i=0; i<n; i++) {
        cin >> tmp;
        v.push_back(tmp);
    }

    bubbleSort(v);
    return 0;
}

Measured memory_bytes: 1220
h,w=map(int,input().split())
p=[["."]*(w+2)]+[["."]+list(map(str,input()))+["."]for i in range(h)]+[["."]*(w+2)]
print(["No","Yes"][int(all([any([p[i+x[0]][I+x[1]]=="#"for x in [[0,1],[0,-1],[1,0],[-1,0]]])for I in range(1,w+1)for i in range(1,h+1)if p[i][I]=="#"]))])

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int gcd(int a,int b){
  while(true){
    if(a % b == 0)return b;
    else{
      int tmp = a % b;
      a = b;
      b = tmp;
    }
  }
}
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int kekka = gcd(max(a,b),min(a,b));
  int nuk = 0;
  for(int i = kekka; 0 < i; i--){
    if(kekka % i == 0)nuk++;
    if(nuk == c){
      cout << i << endl;
      break;
    }
  }
}

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

int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(a>0 && c>0){
        c-=b;
        if(c>0)a-=d;
    }
    if(c<=0){
        printf("Yes\n");
    }
    if(a<=0){
        printf("No\n");
    }
    return(0);
}

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstdio>

using namespace std;

typedef complex<double> P;
const double PI = acos(-1);
const double EPS = 1e-9;

struct circle/*{{{*/
{
  P o;
  double r;
  circle() {}
  circle(const P& p, double x) : o(p), r(x) {}

  // POJ 1418 Viva Confetti
  // POJ 2149 Inherit the Spheres
  inline bool intersects(const circle& c) const
  {
    return !contains(c) && !c.contains(*this) && abs(o - c.o) <= r + c.r;
  }

  pair<P,P> intersection(const circle& c) const
  {
    // assert(intersects(c))
    const double d = abs(o - c.o);
    const double cos_ = (d*d + r*r - c.r*c.r) / (2*d);
    const double sin_ = sqrt(r*r - cos_*cos_);
    const P e = (c.o - o) / d;
    return make_pair(o + e*P(cos_, -sin_), o + e*P(cos_, sin_));
  }

  inline bool contains(const circle& c) const
  {
    return abs(o - c.o)+c.r <= r;
  }
};/*}}}*/

bool solve() {
    int N;
    cin >> N;
    if(!N) return false;

    vector<circle> cs;
    for(int i = 0; i < N; ++i) {
        double x, y, r;
        cin >> x >> y >> r;
        cs.push_back(circle(P(x, y), r));
    }
    double ans = 0;
    for(int i = 0; i < N; ++i) {
        vector<pair<double,int>> ps;
        const circle &c1 = cs[i];
        ps.push_back(make_pair(-PI, 0));
        ps.push_back(make_pair(PI, 0));
        for(int j = 0; j < N; ++j) {
            if(i == j) continue;
            const circle &c2 = cs[j];
            if(c2.contains(c1)) {
                ps.clear();
                break;
            }
            if(c1.intersects(c2)) {
                const auto tmp = c1.intersection(c2);
                const double arg1 = arg(tmp.first - c1.o);
                const double arg2 = arg(tmp.second - c1.o);
                //cout << i << ' ' << j << ' ' << arg1 << ' ' << arg2 << endl;
                ps.push_back(make_pair(arg1, 1));
                ps.push_back(make_pair(arg2, -1));
                if(arg1 > arg2) {
                    ps.push_back(make_pair(-PI, 1));
                }
            }
        }
        sort(ps.begin(), ps.end());
        int cur = 0;
        double prev = -PI;
        for(const auto &p : ps) {
            if(abs(prev-p.first) > EPS) {
                if(cur == 0) ans += c1.r * abs(p.first - prev);
            }
            cur += p.second;
            prev = p.first;
        }
    }
    printf("%.8f\n", ans);
    return true;
}

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

    while(solve()) ;

    return 0;
}

Measured memory_bytes: 1344
#[allow(dead_code)]
fn main() {
    let (n, k) = i::u2();
    let a = i::uv(n);
    println!("{}", 1 + (n - 2) / (k - 1));
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main(){
  int ans=0;
  int a,b,c; cin>>a>>b>>c;
  for(int i=0;i*a<a*b;++i){
    if(i){
      if((i*a)%b==c){ ans=1; break; }
    }
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int a,b,cnt,cnt2=0;

  while(1){
    
    cin >>a>>b;
    if(a == 0 && b == 0)break;
    if( cnt2 != 0 )cout <<endl;
    cnt2++;
    cnt=0;
    
    for(int i=a; i <= b ; i++){
      
      if( i % 100 == 0 && i % 400 != 0 )continue;
      
      else{
	
	if( i%4 == 0 ){
	  cout <<i<<endl;
	  cnt++;
	}
	
      }
      
    }
    
    if(cnt ==0){
      cout <<"NA"<<endl;
    }

   
    
  }
  return 0;
}

Measured memory_bytes: 1160
void main() {
	auto ip = readAs!(long[]), N = ip[0], M = ip[1], K = ip[2];
	auto A = readAs!(long[]);
	auto B = readAs!(long[]);
	auto arr = new long[](N+1);
	auto arr2 = new long[](M+1);
	arr[0] = 0;
	arr2[0] = 0;
	foreach(i; 0..N) arr[i+1] = arr[i] + A[i];
	foreach(i; 0..M) arr2[i+1] = arr2[i] + B[i];
	ulong res;
	foreach(i; 0..N+1) {
		if(arr[i] > K) break;
		auto tmp = i + arr2.assumeSorted.lowerBound(K - arr[i] + 1).count - 1;
		debug arr2.assumeSorted.lowerBound(K - arr[i] + 1).writeln;
		res = max(res, tmp);
		debug writefln("i: %d, tmp: %d", i, tmp);
	}
	debug arr.writeln;
	debug arr2.writeln;
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readmatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readmatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 22044
def solve():
    N, *p = map(float, open(0).read().split())
    N = int(N)

    dp = [[0] * (N+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(N):
            dp[i+1][j+1] += dp[i][j] * p[i]
            dp[i+1][j] += dp[i][j] * (1 - p[i])

    ans = 0
    for i in range((N+1) // 2, N+1):
        ans += dp[N][i]
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 259976
import sys
import math

stdin = sys.stdin

nm = lambda: map(int, stdin.readline().split())

a, b = nm()

n = math.gcd(a,b)

count = 1 # 1
for i in range(2, int(n**(1/2))+1):
    if n%i ==0:
        count +=1
        while n%i == 0:
            n = n/i
    if n ==1:
        break
if n != 1:
    count += 1

print(count)

Measured memory_bytes: 9360
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100000

int main()
{
    char b[N+1];
    int i, j = 0, n = 0, m = 0, l = 0, max;
    gets(b);
    i = strlen(b);
    while(j<i)
    {
        switch(b[j])
        {
            case 'a': n++;break;
            case 'b': m++;break;
            case 'c': l++;break;
            default:break;
        }
        j++;
    }
    max = n;
    if(m>max&&m>l)
    {
        n = m;
        m = max;
    }
    if(l>max&&l>m)
    {
        n = l;
        l = max;
    }
    if(n>m+1||n>l+1)
    {
        printf("NO");
    }
    else if(m-l>1||m-l<-1)
    {
        printf("NO");
    }
    else
        printf("YES");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
using namespace std;

long long x[100005];
long long dp[100005];

long long min(long long a, long long b){ return a < b ? a : b; }

priority_queue<long long> q; // -dp
priority_queue<pair<long long, int>> qwait; // {-dp, ind}

int main(){
    int N, E, T;
    scanf("%d%d%d", &N, &E, &T);
    for(int i=1; i<=N; i++) scanf("%lld", &x[i]);
    qwait.push({-T, 0});
    for(int i=1; i<=N; i++){
        while(!qwait.empty()){
            if(T-2*(x[i]-x[qwait.top().second+1]) > 0) break;
            int pos = qwait.top().second;
            q.push(-(dp[pos] - 2*x[pos+1] - x[pos]));
            qwait.pop();
        }
        dp[i] = dp[i-1] + x[i] - x[i-1] + T;
        if(!qwait.empty()) dp[i] = min(dp[i], -qwait.top().first + x[i]);
        if(!q.empty()) dp[i] = min(dp[i], -q.top() + 3*x[i]);
        //printf("%lld ", dp[i]);
        qwait.push({-T-dp[i]+x[i], i});
    }
    /*
    for(int i=1; i<=N; i++){
        for(int j=0; j<=i; j++) printf("%lld ", dp[i][j]);
        printf("\n");
    }
     */
    printf("%lld", dp[N]+E-x[N]);
    return 0;
}

Measured memory_bytes: 4340