akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int check(int *x, int *y, int t) {
  int i;
  for (i = 0; i < t; i++) {
    if(x[i] == x[t]) return 1;
    if(y[i] == y[t]) return 1;
    if(x[i]+y[i] == x[t]+y[t]) return 1;
    if(x[i]-y[i] == x[t]-y[t]) return 1;
  }
  return 0;
}

void search(int *x, int *y, int *t) {
  while(*t < 8) {
    if(y[*t] == 7) {
      x[*t]++;
      y[*t] = 0;
    }
    else {
      y[*t]++;
    }
    if(x[*t] > 7) {
      x[*t] = 0;
      y[*t] = -1;
      (*t)--;
    }
    else if(check(x,y,*t) == 0) {
      (*t)++;
    }

  }
}

void print_board(int *x, int *y) {
  int i,j,t;
  for (i = 0; i < 8; i++) {
    for (t = 0; i != x[t]; t++);
    for (j = 0; j < 8; j++) {
      if(j == y[t]) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

int main()
{
  int i,t,k,*x,*y;
  x = (int*)malloc(sizeof(int) * 8);
  y = (int*)malloc(sizeof(int) * 8);
  for (i = 0; i < 8; i++) {
    x[i] = 0;
    y[i] = -1;
  }
  t = 0;
  scanf("%d",&k);
  for(i = 0; i < k; i++) {
    scanf("%d %d",x+i,y+i);
    t++;
  }

  search(x,y,&t);

  print_board(x,y);
  return 0;
}

Measured memory_bytes: 572
// ※※※ 解答不能 ※※※
// 以下のソースを勉強する.
// yutaka1999氏.
// https://atcoder.jp/contests/jsc2019-qual/submissions/7112552
#include <bits/stdc++.h>
using namespace std;
#define SIZE 200005
using LL = long long;
typedef pair<int, int> P;
typedef pair<int, P> PP;

struct UF{
    int par[SIZE], rank[SIZE], sz[SIZE];
    
    void init(int n){
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 1;
            sz[i] = -1;
        }
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    int get(int v){
        return sz[find(v)];
    }
    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y){
            sz[x]++;
            return;
        }
        if(rank[x] < rank[y]){
            par[x] = y;
            sz[y] += sz[x];
            sz[y]++;
        }else{
            par[y] = x;
            sz[x] += sz[y];
            sz[x]++;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
}uf;

vector<PP> edge;
bool use[SIZE];

int main(){
    int n, h, w;
    scanf("%d %d %d",&n, &h, &w);
    for(int i = 0; i < n; i++){
        int r, c, a;
        scanf("%d %d %d",&r, &c, &a);
        r--, c--;
        edge.push_back(PP(a, P(r, c + h)));
    }
    sort(edge.begin(),edge.end(),greater<PP>());
    uf.init(h + w + 2);
    LL ret = 0;
    for(int i = 0; i < edge.size(); i++){
        P p = edge[i].second;
        int a = uf.get(p.first);
        int b = uf.get(p.second);
        if(a + b + 1 <= 0){
            uf.unite(p.first, p.second);
            ret += edge[i].first;
            use[i] = true;
            // printf("* %d %d : %d\n",p.first,p.second,edge[i].first);
        }
    }
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)

signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}




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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> d(n);
	rep(u,n) scanf("%d",&d[u]);

	if(n==2){
		puts("Possible");
		return 0;
	}

	vector<int> hist(n);
	rep(u,n) hist[d[u]]++;

	int d_min=*min_element(d.begin(),d.end());
	int d_max=*max_element(d.begin(),d.end());

	bool ok;
	if(d_min==1){
		ok=(hist[2]==n-1);
	}
	else{
		ok=(hist[d_min]<=2);
		if(2*(d_max-d_min)+(hist[d_min]==1?0:1)!=d_max) ok=false;
		for(int x=d_min+1;x<=d_max;x++) if(hist[x]<2) ok=false;
	}
	puts(ok?"Possible":"Impossible");

	return 0;
}


Measured memory_bytes: 384
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
using namespace std;
// ¯\_(ツ)_/¯
#define f first
#define s second
#define p push
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define foi(i, a, n) for (i = (a); i < (n); ++i)
#define foii(i, a, n) for (i = (a); i <= (n); ++i)
#define fod(i, a, n) for (i = (a); i > (n); --i)
#define fodd(i, a, n) for (i = (a); i >= (n); --i)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define endl " \n"
#define newl cout<<"\n"
#define MAXN 100005
#define MOD 1000000007LL
#define EPS 1e-13
#define INFI 1000000000             // 10^9
#define INFLL 1000000000000000000ll //10^18
// ¯\_(ツ)_/¯
//#define l long int
//#define d double
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vll>
#define vvld vector<vector<ld>>

//vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.
#define mii map<int, int>
#define mll map<long long, long long>
#define pii pair<int, int>
#define pll pair<long long, long long>

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);

ll tc, n, m, k;
// ll ans = 0, c = 0;
// ll i, j;
// ll a, b;
// ll x, y;



int main()
{
    fast_io();
#ifndef ONLINE_JUDGE
    //freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif
//
    ll w;
    cin>>n>>w;
    vll weight(n, 0), price(n, 0);

    ll pricesum = 0;
    rep(i, 0, n) {
        cin>>weight[i];
        cin>>price[i];
        pricesum += price[i];
    }

    // dp state = {first i elements, max_price} = min weight needed to make max_price from 0 - i elements
    vvll dp(n+1, vll(pricesum+1, INFI));
    dp[0][0] = 0;
    rep(i, 1, n+1) {
        rep(j, 0, pricesum+1) {
            if(j - price[i-1] >= 0) {
                dp[i][j] = min(dp[i-1][j], weight[i-1] + dp[i-1][j-price[i-1]]);
            } else {
                dp[i][j] = min(dp[i][j], dp[i-1][j]);
            }
        }
    }



    // max price for which min weight is less or equal to capacity.
    ll ans = 0;
    rep(i, 0, pricesum+1) {
        if(dp[n][i] <= w) ans = i;
    }

    cout<<ans;

    return 0;
}

/*
2
4
0 1 0 1
5
0 0 1 0 0
*/

Measured memory_bytes: 80256
/**
 *      ABC 110 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-24 07:38:30
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S, T; cin >> S >> T;

    int sizeS = S.size();

    int countS[26] = {}; int countT[26] = {};

    for (auto i = 0; i < sizeS; ++i) {
        ++countS[S[i] - 'a'];
        ++countT[T[i] - 'a'];
    }

    sort(countS, countS + 26);
    sort(countT, countT + 26);

    for (auto i = 0; i < 26; ++i) {
        if (countS[i] != countT[i]){
            cout << "No" << endl; return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 916
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int data[100][100];

int main()
{
	memset(data, 0, sizeof(data));
	char buf[512];
	int yy = 0;
	while (!cin.eof())
	{
		cin.getline(buf, sizeof(buf));
		if (strlen(buf) == 0)
			break;

		int xx = 1;
		for (char* p = strtok(buf, ","); p != NULL; p = strtok(NULL, ","), ++xx)
			data[yy][xx] = atoi(p);
		++yy;
	}

	for (int i = 1; i < yy; ++i)
	{
		int a = -1;
		int b = 0;
		if (i >= (yy+1)/2)
		{
			a = 0;
			b = 1;
		}
		for (int j = 1; j <= (yy+1)/2; ++j)
			data[i][j] += max(data[i-1][j+a], data[i-1][j+b]);
	}

	printf("%d\n", data[yy-1][1]);

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        StringBuilder sb = new StringBuilder();
        sb.append(sharp(w + 2));
        sb.append("\n");
        for (int i = 0; i < h; i++) {
            sb.append(sharp(1));
            sb.append(sc.next());
            sb.append(sharp(1));
            sb.append("\n");
        }
        sb.append(sharp(w + 2));
        sb.append("\n");
        System.out.println(sb.toString());
    }

    private static String sharp(int n) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append("#");
        }
        return sb.toString();
    }
}

Measured memory_bytes: 24404
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

class ModInteger {
	public static long MOD = 1_000_000_007;
	private long x;

	public ModInteger(long n) {
		x = (n % MOD);
	}

	/** 和 */
	public ModInteger add(long augend) {
		return new ModInteger((x + augend) % MOD);
	}

	/** 和 */
	public ModInteger add(ModInteger augend) {
		return add(augend.x);
	}

	/** 逆元 */
	public ModInteger inv() {
		return pow(MOD - 2);
	}

	/** 商 */
	public ModInteger divide(long divisor) {
		return divide(new ModInteger(divisor));
	}

	/** 商 */
	public ModInteger divide(ModInteger divisor) {
		return multiply(divisor.inv());
	}

	/** 積 */
	public ModInteger multiply(long muultiplicand) {
		return new ModInteger((x * muultiplicand) % MOD);
	}

	/** 積 */
	public ModInteger multiply(ModInteger multiplicand) {
		return multiply(multiplicand.x);
	}

	/** 累乗 O(logN) */
	public ModInteger pow(long n) {
		// 繰り返し二乗法
		if (n == 0) {
			return new ModInteger(1);
		}
		ModInteger a = pow(n / 2);
		a = a.multiply(a);
		if (n % 2 == 1) {
			a = a.multiply(x);
		}
		return a;
	}

	/** 差 */
	public ModInteger subtract(long subtrahend) {
		return new ModInteger((x - subtrahend + MOD) % MOD);
	}

	/** 差 */
	public ModInteger subtract(ModInteger subtrahend) {
		return subtract(subtrahend.x);
	}

	@Override
	public boolean equals(Object o) {
		if (o instanceof ModInteger) {
			return x == ((ModInteger) o).x;
		}
		return false;
	}

	public boolean equals(long l) {
		return x == (l % MOD);
	}

	@Override
	public int hashCode() {
		return Long.hashCode(x);
	}

	public int compareTo(long val) {
		return Long.compare(x, val);
	}

	public int compareTo(ModInteger val) {
		return compareTo(val.x);
	}

	public long longValue() {
		return x;
	}

	@Override
	public String toString() {
		return Long.toString(x);
	}

	public static ModInteger valueOf(long x) {
		return new ModInteger(x);
	}

}

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public ModInteger nCr(ModInteger n, ModInteger r) {
		ModInteger ans = new ModInteger(1);

		while (!r.equals(0)) {
			ans = ans.multiply(n);
			ans = ans.divide(r);

			n = n.subtract(1);
			r = r.subtract(1);
		}

		return ans;
	}

	public ModInteger nCr(long n, long r) {
		return nCr(new ModInteger(n), new ModInteger(r));
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		ModInteger.MOD = 1000000007;

		sc.close();

		ModInteger nn = new ModInteger(2).pow(n).subtract(1);
		ModInteger x = nCr(n, a);
		ModInteger y = nCr(n, b);

		ModInteger ans = nn.subtract(x.add(y));
		out.println(ans);

	}

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


Measured memory_bytes: 145812
import sys
import numpy as np


N, K, Q = [int(i) for i in input().split()]
l = np.zeros(N)

x = Q - K
for i in range(Q):
    A = int(input())
    l[A - 1] = l[A - 1] + 1

s = ''
for i in range(N):
    if l[i] > x:
        s += 'Yes\n'
    else:
        s += 'No\n'

print(s.strip())


Measured memory_bytes: 15196
#include<bits/stdc++.h>
using namespace std;
long long int w[105],v[105];
long long int cache[105][100005];
#define max(a,b) ((a>b?a:b))
long long int maxVal(long int W,int n)
{
	long int i,j;
	for(i=0;i<=W;i++)
	{if(i<w[0])
	cache[0][i]=0;
	else break;
}
for(;i<=W;i++)
cache[0][i]=v[0];
for(i=0;i<n;i++)
{
	cache[i][0]=0;
}
for(i=1;i<n;i++)
{
	for(j=1;j<=W;j++)
	{
		if(j>=w[i])
		{
			cache[i][j]=max(v[i]+cache[i-1][j-w[i]],cache[i-1][j]);
		}
		else
		cache[i][j]=cache[i-1][j];
	}
}
return cache[n-1][W];
	
	
	
	
	
	
	
	
}
int main()
{
	int n;
long int W;
cin>>n>>W;
int i;
for(i=0;i<n;i++)
cin>>w[i]>>v[i];
long long int x=maxVal(W,n);
/*
for(int i=0;i<n;i++)
{
for(int j=0;j<=W;j++)
cout<<cache[i][j];
cout<<endl;
}
*/
cout<<x;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> c(9,0);
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    int y=x/400;
    if (y<8){
      c[y]++;
    }
    else {
      c[8]++;
    }
  }
  int ans1=0,ans2;
  for (int i=0;i<8;i++){
    if (c[i]!=0){
      ans1++;
    }
  }
  if (ans1==0&&c[8]>0){
    ans1=1;
    ans2=c[8];
  }
  else {
    ans2=ans1+c[8];
  }
  cout << ans1 << ' ' << ans2 << endl;
}

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

const int N = 2e5 + 5;

LL n, ans, a[N], cnt[N];

int main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]), ++cnt[a[i]];
	for (int i = 1; i <= n; ++i) ans += 1LL * cnt[i] * (cnt[i] - 1) / 2;
	for (int i = 1; i <= n; ++i)
		std::cout << (ans - 1LL * cnt[a[i]] * (cnt[a[i]] - 1) / 2 + 1LL * (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2) << '\n';
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define int long long

using namespace std;

int n,a,b;
int h[100001];

bool solve(int t) {
  int tmp = 0;
  for(int i = 0; i < n; i++) {
    if(h[i] - (b * t) <= 0) continue;
    tmp += (h[i] - (b * t) - 1) / (a-b) + 1;
  }
  return tmp <= t;
}
signed main() {
  cin >> n >> a >> b;

  int r = 0, l = 0;

  for(int i = 0; i < n; i++) {
    cin >> h[i];
    l = max(l,h[i]);
  }

  l = (l-1) / b + 1;
  
  while(l - r > 1) {
   
    int mid = (l + r) / 2;
    if(solve(mid)) l = mid;
    else r = mid;
   
  }

  cout << l << endl;
}


    
  
  


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a>k)cout << ":("<< endl;
  else cout << "Yay!" << endl;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

// type Triple = (i64, i64, i64);

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_tuple() -> (i64, i64, i64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn main() {
    let n: i64 = input();
    let mut current = (0, 0, 0);
    for _ in 0..n {
        let (t, x, y) = input_tuple();
        let dist = (x - current.1).abs() + (y - current.2).abs();
        if dist > t - current.0 {
            println!("No");
            return;
        } else if dist % 2 != (t - current.0) % 2 {
            println!("No");
            return;
        }
        current = (t, x, y);
    }
    println!("Yes");
}


Measured memory_bytes: 2232
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const int sup = 200200;
bool used[26];
map <int,int> mp;


int main(int argc, char *argv[])
{
  string str;
  cin >> str;
  int len = str.size();
  mp[0]=0;
  int mn = 0;
  for (int i = 0; i < len; i++) {
    int c = str[i]-'a';
    used[c]=!used[c];
    int S=0;
    for (int j = 0; j < 26; j++) {
      if(used[j]) S|=1<<j;
    }
    mn = i+1;
    if(mp.count(S)) mn = min(mn,mp[S]+1);

    for (int j = 0; j < 26; j++) {
      if(mp.count(S^(1<<j))){
	mn = min(mn,mp[S^(1<<j)]+1);
      }
    }

    if(!mp.count(S)) {mp[S]=mn;}
    else {mp[S]=min(mp[S],mn);}
  }
  printf("%d\n",mn);
  return 0;
}


Measured memory_bytes: 9860
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code,
  unused_macros
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
//use std::collections::HashSet;
use std::cmp::*;
use std::collections::*;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
fn main() {
  input! {
     H:usize,
     W:usize,
     C:(Usize1, Usize1),
     D:(Usize1, Usize1),
     S:[Chars;H]
  }
  let C: (usize, usize) = (C.0 + 2, C.1 + 2);
  let D: (usize, usize) = (D.0 + 2, D.1 + 2);
  let S: Vec<Vec<char>> = S;
  let mut kabe = vec![vec![true; W + 10]; H + 10];
  for x in 0..H {
    for y in 0..W {
      if S[x][y] == '.' {
        kabe[x + 2][y + 2] = false;
      }
    }
  }
  let kabe: Vec<Vec<bool>> = kabe;
  // Cを基準に幅優先探索。
  // (n=ワープ回数, 位置)
  let mut h = BinaryHeap::new();
  //訪問済み
  let mut v = vec![vec![false; W + 10]; H + 10];
  // ワープ回数
  let mut d = vec![vec![std::u64::MAX; W + 10]; H + 10];
  v[C.0][C.1] = true;
  d[C.0][C.1] = 0;
  h.push((Reverse(0), C.0, C.1));
  while let Some((Reverse(c), x, y)) = h.pop() {
    toho(&kabe, &mut d, &mut h, c, x - 1, y);
    toho(&kabe, &mut d, &mut h, c, x + 1, y);
    toho(&kabe, &mut d, &mut h, c, x, y - 1);
    toho(&kabe, &mut d, &mut h, c, x, y + 1);

    warp(&kabe, &mut d, &mut h, c, x - 2, y - 2);
    warp(&kabe, &mut d, &mut h, c, x - 2, y - 1);
    warp(&kabe, &mut d, &mut h, c, x - 2, y);
    warp(&kabe, &mut d, &mut h, c, x - 2, y + 1);
    warp(&kabe, &mut d, &mut h, c, x - 2, y + 2);
    warp(&kabe, &mut d, &mut h, c, x - 1, y - 2);
    warp(&kabe, &mut d, &mut h, c, x - 1, y - 1);
    warp(&kabe, &mut d, &mut h, c, x - 1, y + 1);
    warp(&kabe, &mut d, &mut h, c, x - 1, y + 2);
    warp(&kabe, &mut d, &mut h, c, x, y - 2);
    warp(&kabe, &mut d, &mut h, c, x, y + 2);
    warp(&kabe, &mut d, &mut h, c, x + 1, y - 2);
    warp(&kabe, &mut d, &mut h, c, x + 1, y - 1);
    warp(&kabe, &mut d, &mut h, c, x + 1, y + 1);
    warp(&kabe, &mut d, &mut h, c, x + 1, y + 2);
    warp(&kabe, &mut d, &mut h, c, x + 2, y - 2);
    warp(&kabe, &mut d, &mut h, c, x + 2, y - 1);
    warp(&kabe, &mut d, &mut h, c, x + 2, y);
    warp(&kabe, &mut d, &mut h, c, x + 2, y + 1);
    warp(&kabe, &mut d, &mut h, c, x + 2, y + 2);
  }
  let ans = d[D.0][D.1];
  if ans < std::u64::MAX {
    println!("{}", ans);
  } else {
    println!("-1");
  }
  let x: u64 = !0;
  debug!(ans, x);
}

fn warp(
  kabe: &Vec<Vec<bool>>,
  d: &mut Vec<Vec<u64>>,
  h: &mut BinaryHeap<(Reverse<u64>, usize, usize)>,
  c: u64,
  x: usize,
  y: usize,
) -> () {
  if kabe[x][y] == false {
    let c = c + 1;
    if d[x][y] > c {
      d[x][y] = c;
      h.push((Reverse(c), x, y));
    }
  }
}

fn toho(
  kabe: &Vec<Vec<bool>>,
  d: &mut Vec<Vec<u64>>,
  h: &mut BinaryHeap<(Reverse<u64>, usize, usize)>,
  c: u64,
  x: usize,
  y: usize,
) -> bool {
  if kabe[x][y] == false {
    if d[x][y] > c {
      d[x][y] = c;
      h.push((Reverse(c), x, y));
    }
    true
  } else {
    false
  }
}


Measured memory_bytes: 17320
div=10**9+7
def modinv(a, m=1000000007): return pow(a, m-2, m)

N,A,B,C=list(map(int,input().split()))
fact=[1]*(2*N+1)
res = 0
invAB = modinv(A+B)
reveven = (modinv(100-C)*100) % div
memoA = [1]*(N+1)
memoB = [1]*(N+1)

for i in range(1, 2*N+1): fact[i] = fact[i-1]*i % div
def ncr(n, r): return fact[n]*modinv(fact[r]*fact[n-r]%div) % div

for i in range(1, N+1): 
    memoA[i] = (memoA[i-1]*A*invAB) % div
    memoB[i] = (memoB[i-1]*B*invAB) % div

for i in range(N, 2*N): res += (((ncr(i-1, N-1)*memoA[N] % div)*memoB[i-N] + (ncr(i-1, N-1)*memoB[N] % div)*memoA[i-N]) % div)*reveven*i % div

print(res % div)


Measured memory_bytes: 18832
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<typename X>
class Graph{
private:
  int n;// 頂点数
  int m;// 辺の数
  //  vector<vector<pair<int,X>>> edge;// コスト付きの辺
  vector<vector<int>> edge; // コストなしの辺
  vector<bool> f;
public:
  // 頂点数_nのグラフを作成
  Graph(int _n){ n = _n; edge.resize(n);  }
  //辺コストなしのグラフ作成、_n頂点、_m辺、a[i]->b[i]の辺がある。
  Graph(int _n,int _m,vector<int> a,vector<int> b){
    n = _n;m = _m;edge.resize(n);
    rep(i,m){
      edge[a[i]].push_back(b[i]);
      edge[b[i]].push_back(a[i]); // 有向グラフ
    }
  }
  // 辺コストありのグラフ作成、_n頂点、_m辺、a[i]->b[i]のコストc[i]の辺がある。
  // Graph(int _n,int _m,vector<int> a,vector<int> b,vector<X> c){
  //   n = _n;m = _m;edge.resize(n);
  //   rep(i,m){
  //     edge[a[i]].push_back({b[i],c[i]});
  //     edge[b[i]].push_back({a[i],c[i]}); //有向グラフ
  //   }
  // }  

  // 辺の追加 コストなし
  //  void add_edge(int from,int to){ edge[from].push_back(to);}
  // 辺の追加 コストあり
  //  void add_edge(int from,int to,X cost){ edge[from].push_back({to,cost});}

  void dfs(int v){
    if(f[v]) return ;
    f[v] = true;
    for(auto w:edge[v]) dfs(w);
  }

  void solve(){
    int res = 0;
    f.assign(n,0);
    rep(i,n){
      if(!f[i]){
	res++;
	dfs(i);
      }
    }
    cout << res << "\n";
  }
  
};

int main()
{
  int n,m;cin >> n >> m;
  vector<int> x(m),y(m),z(m);
  rep(i,m){ cin >> x[i] >> y[i] >> z[i];x[i]--;y[i]--;}
  Graph<int> gp(n,m,x,y);
  gp.solve();
  
  return 0;
}


Measured memory_bytes: 8816
// AOJ 2772: My Number
// 2017.10.8 bal4u@uu

#include <stdio.h>

int q[11] = {6,5,4,3,2,7,6,5,4,3,2};
int p[12];

int calc()
{
	int s, i;
	for (s = 0, i = 0; i < 11; i++) s += p[i]*q[i];
	s %= 11;
	if (s <= 1) s = 0; else s = 11-s;
	return s == p[11];
}

int main()
{
	int i, j, ans;
	char s[13];

	scanf("%s", s);
	for (j = -1, i = 0; i < 12; i++) {
		if (s[i] == '?') j = i;
		else p[i] = s[i]-'0';
	}
	if (j < 0) while (1); // panic
	for (i = 0, p[j] = 0; p[j] < 10; p[j]++) {
		if (calc()) i++, ans = p[j];
	}
	if (i > 1) puts("MULTIPLE");
	else putchar(ans+'0'), putchar('\n');
	return 0;
}

Measured memory_bytes: 1716
def solve
  n, m = gets.split.map!(&:to_i)
  a = gets.split.map!(&:to_i)
  tot_votes = 0
  a.map { |vote| tot_votes += vote }
  cnt = 0
  (0..(n - 1)).each do |i|
    cnt += 1 if (a[i] * (4 * m)) >= tot_votes
  end

  return 'Yes' if cnt >= m

  'No'
end
print solve


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
template<typename A,size_t N,typename T>
void Fill(A (&array)[N],const T &val)
{
    std::fill( (T*)array,(T*)(array+N),val );
}
int main(void)
{
    string s;
    cin >> s;
    int n=int(s.size());
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(i<=n-1-i && s[i]!=s[n-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std; 
int main() { 
  int n; 
  while(1) { 
    int m; 
    string x, y; 
    map<string, string> a;  
    cin >> n; 
    if(n==0) break; 
    for(int i=0; i<n; i++) {   
      cin >> x >> y;   
      a.insert(make_pair(x,y));   
    }   
    cin >> m;  
    for(int i=0; i<m; i++) {  
      cin >> x;   
      map<string, string>::iterator it;  
      it=a.find(x);  
      if(it!=a.end()) cout << it->second;   
      else cout << x;  
    }  
    cout << endl;  
    a.clear(); 
  }  
  return 0;
}


Measured memory_bytes: 1204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_1_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            LinkedList<int> ll = new LinkedList<int>();
            LinkedListNode<int> cur = new LinkedListNode<int>(int.MaxValue);
            ll.AddFirst(cur);

            for (int i = 0 ; i < n ; i++)
            {
                int[] line = ReadIntAr();
                switch (line[0])
                {
                    case 0:
                        {
                           ll.AddBefore(cur, line[1]);
                            cur = cur.Previous;
                            break;
                        }
                    case 1:
                        {
                            if (line[1] > 0) {
                                for (int j = 0 ; j < line[1] ; j++) cur = cur.Next;
                            }
                            else {
                                for (int j = 0 ; j < -1 * line[1] ; j++) cur = cur.Previous;
                            }
                            break;
                        }                     
                    case 2:
                        {
                            cur = cur.Next;
                            ll.Remove(cur.Previous);
                            break;
                        }
                }
            }

            foreach (var item in ll)
            {
                if (item != int.MaxValue) Console.WriteLine(item.ToString());
            }

        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



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

namespace ABC082
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Dictionary<int, int> dict = new Dictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                if (!dict.ContainsKey(a[i])) { dict.Add(a[i], 1); }
                else { dict[a[i]]++; }
            }

            long res = 0;
            foreach (var i in dict)
            {
                if (i.Key <= i.Value) res += i.Value - i.Key;
                else res += i.Value;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 27360
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def pow_r_mod(x, n, mod=10**9+7):
    # 計算量 : log N
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x %= mod
        n //= 2
    return (K * x) % mod

def  mod_pow(a:int, b:int, mod:int)->int:
    if b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

#print((pow_r_mod(2, m)-1-mca-mcb) % P)
print((mod_pow(2, m, P)-1-mca-mcb) % P)

Measured memory_bytes: 52848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		int count = 0;

		for (int i = 0; i < n-2; i++) {
			if (s.substring(i, i + 3).equals("ABC")) {
				count++;
			}
		}

		System.out.println(count);

		sc.close();
	}
}


Measured memory_bytes: 35732
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
int N, M;
vector<vector<int>> G;
int dp[100100];

int rec(int v) {
    if(dp[v] != -1) {
        return dp[v];
    }
    int res = 0;
    for(auto nv : G[v]) {
        chmax(res, rec(nv) + 1);
    }
    return dp[v] = res;
}

int main() {

    cin >> N >> M;
    G.assign(N, vector<int>());
    rep(i, 0, M) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        G[x].push_back(y);
    }

    rep(i, 0, N) dp[i] = -1;

    int res = 0;
    rep(i, 0, N) chmax(res, rec(i));
    cout << res << endl;
}


Measured memory_bytes: 8192
def main():
    N, M = list(map(int, input().split()))
    A = set()
    for i in range(M):
        A.add(int(input()))

    mod = 1000000007

    dp = [0] * (N+1)
    dp[0] = 1
    for now in range(0, N):
        for next in range(now+1, min(N, now+2)+1):
            if next not in A:
                dp[next] += dp[now]
                dp[next] %= mod

    print(dp[N] % mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 51416
#include <stdio.h>
int main (){
int h;
int w;

while (1){
scanf("%d %d",&h,&w);
if (h == 0 && w == 0) break;
for (int i = 0; i<h;i++){
for (int j = 0; j<w;j++){
printf("#");
}
printf("\n");
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

ll k,x;
cin >> k >> x;
if(500 * k >= x) cout << "Yes" << endl;
else cout << "No" << endl;





//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
using P = pair<ll , ll>;
//using map = map<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;

    ll distance0 = abs(b -a);
    ll distance1 = distance0 - (v*t - w*t);
    if(distance1 <= 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3636
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    w, h = reads()
    p = sorted([read() for _ in range(w)])[::-1]
    q = sorted([read() for _ in range(h)])[::-1]

    pi = w-1
    qi = h-1
    res = 0
    while 0<=pi and 0<=qi:
        if p[pi] < q[qi]:
            res += p[pi] * (h+1)
            pi -= 1
            w -= 1
        else:
            res += q[qi] * (w+1)
            qi -= 1
            h -= 1
    res += sum(p[:pi+1]) + sum(q[:qi+1])
    print(res)

main()


Measured memory_bytes: 12208
l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
l3 = [2]
x, y = map( int, input().split() )
if ( x in l1 and y in l1 ) or ( x in l2 and y in l2 ) or ( x in l3 and y in l3 ) : 
   print( "Yes" )
else :
   print( "No" )

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define NODE_MAX  100001
bool used[NODE_MAX]={};
bool can=true;
struct edge{
  ll n,d;
  edge(ll a,ll b){
    n=a;
    d=b;
  };
};
vector<edge> g[NODE_MAX];
ll x[NODE_MAX];
void dfs(ll p,ll loc){
  if(can==false){
    return;
  }
  if(used[p]){
    if(loc!=x[p]){
      can=false;
    }
    return;
  }
  x[p]=loc;
  used[p]=true;
  for(int i=0;i<g[p].size();i++){
    dfs(g[p][i].n,loc+g[p][i].d);
  }
  return;
}
signed main(){
  ll n,m;
  cin >> n >> m;
  ll l[m],r[m],d[m];
  for(int i=0;i<m;i++){
    cin >> l[i] >> r[i]>>d[i];
    l[i]--; r[i]--;
    g[l[i]].push_back(edge(r[i],d[i]));
    g[r[i]].push_back(edge(l[i],-d[i]));
  }
  for(int i=0;i<n;i++){
    if(used[i]==false){
      dfs(i,0);
    }
    if(can==false) break;
  }
  if(can) cout <<"Yes\n";
  else cout <<"No\n";
}


Measured memory_bytes: 21248
#include<stdio.h>

int main(void)
{
    int x, a, b, c;
    int i, j, k;
    int ans=0;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &x);

    for(i=c;0<=i;i--) {
        if(x == (50*i)) {
            ans++;
            continue;
        }
        for(j=0;b>=j;j++) {
            if((x-(50*i)) < (100*j)) {
                break;
            }
            if((x-(50*i)) == (100*j)) {
                ans++;
                continue;
            }
            for(k=0;a>=k;k++) {
                if((x-(50*i)-(100*j)) < (500*k)) {
                    break;
                }
                if((x-(50*i)-(100*j)) == (500*k)) {
                    ans++;
                    break;
                }
            }
        }
    }

    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
inputlist = input().split()
H_list = []
for H in inputlist:
    H_list.append(int(H))
    
answer = 0
clearFrag = 0
for i in range(len(H_list)):
    if i == 0:
        answer += 1
    else:
        for prior in range(i):
            if H_list[prior] > H_list[i]:
                break
            else:
                clearFrag += 1
        if clearFrag == i:
            answer += 1
        clearFrag = 0

print(answer)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static 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 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;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int d = sc.nextInt();
    String s = "Christmas";
    for (int i = d; i < 25; i++) {
      s = s + " Eve";
    }
    System.out.println(s);
  }
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++) {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  if(B<=C || D<=A){
    printf("0");
  }
  else if(A<=C){
    if(B<=D){
      printf("%d",B-C);
    }else{
      printf("%d",D-C);
    }
  }else{
    if(D<=B){
      printf("%d",D-A);
    }else{
      printf("%d",B-A);
    }
  }
  return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	string s;
	cin>>s;
	int c1=0,c2=0,c3=0;
	fo(i,n)
	{
		if(s[i]=='R')
			c1++;
		else if(s[i]=='G')
			c2++;
		else
			c3++;
	}
	int ans=c1*c2*c3;
	fo(i,n)
	{
		for(int j=i+1;j<n;j++)
		{
			if(s[i]==s[j])
				continue;
			int diff=j-i;
			int ind=j+diff;
			if(ind>=n)
				continue;
			if(s[i]!=s[ind] && s[j]!=s[ind])
				ans--;
		}
	}
	cout<<ans<<'\n';
	printclock;
}

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

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	if (A == B) {
		int res = 0;
		for (int i = 0, S; i < N; i++) {
			cin >> S;
			res ^= S % (A + 1);
		}
		cout << (res ? "Hanako" : "Jiro") << endl;
	}
	else if (A > B) {
		bool flag = false;
		int res = 0;
		for (int i = 0, S; i < N; i++) {
			cin >> S;
			if (S > B) flag = true;
			res ^= S % (B + 1);
		}
		cout << (flag || res ? "Hanako" : "Jiro") << endl;
	}
	else {
		int cnt = 0;
		int res = 0;
		vector<int> S(N);
		for (int i = 0; i < N; i++) {
			cin >> S[i];
			if (S[i] > A) cnt++;
			res ^= S[i] % (A + 1);
		}
		if (cnt == 0) {
			cout << (res ? "Hanako" : "Jiro") << endl;
		}
		else if (cnt >= 2 || res == 0) {
			cout << "Jiro" << endl;
		}
		else {
			for (int i = 0; i < N; i++) {
				if (S[i] > A) {
					int tmp = S[i] % (A + 1); tmp ^= res;
					cout << (tmp <= A && S[i] - tmp <= A && S[i] > tmp ? "Hanako" : "Jiro") << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3204
package main

import (
	"fmt"
)

func abs(n int) int {
	if n >= 0 {
		return n
	}
	return -n
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	if abs(a-c) <= d {
		fmt.Println("Yes")
		return
	}
	if abs(a-b) <= d && abs(b-c) <= d {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  int Q;
  cin >> S >> Q;
  bool order = true;
  deque<int> df, db;
  for (int i = 0; i < Q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      order ^= true;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if ((f == 1 && order) || (f == 2 && !order)) {
        df.push_front(c);
      } else {
        db.push_back(c);
      }
    }
  }
  string res = "";
  while (!df.empty()) {
    res += df.front();
    df.pop_front();
  }
  res += S;
  while (!db.empty()) {
    res += db.front();
    db.pop_front();
  }
  if (!order) reverse(res.begin(), res.end());
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1972
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

struct Fenwick {
  i64 n;
  vector<i64> c;
  Fenwick(i64 n) : n(n), c(2 * n + 1) {}
  i64 sum(i64 i) {
    return i > 0 ? c[i] + sum(i - (i & -i)) : 0;
  }
  void add(i64 i, i64 x) {
    if (i <= n) {
      c[i] += x;
      add(i + (i & -i), x);
    }
  }
};

i64 n, k;
vector<i64> a;
int main() {
  cin >> n >> k;
  read_n(a, n);
  for (i64 i = 0; i < n; ++i) a[i] -= k;

  vector<i64> b(n + 1);
  for (i64 i = 1; i <= n; ++i) b[i] = b[i - 1] + a[i - 1];

  set<i64> s;
  for (i64 x : b) s.insert(x);
  map<i64, i64> dic;
  for (i64 x : s) dic[x] = dic.size() + 1;

  i64 ans = 0;
  Fenwick fen(n + 2);
  for (i64 i = 0; i <= n; ++i) {
    i64 j = dic[b[i]];
    ans += fen.sum(j);
    fen.add(j, 1);
    // cerr << b[i] << '\t' << j << '\t' << ans << '\n';
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 28416
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int max = Math.max(A + B, A - B);
            max = Math.max(A * B, max);
            out.println(max);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

Measured memory_bytes: 21332
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int N = scanInt() % 10;
        switch (N) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            out.print("hon");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            out.print("pon");
            break;
        default:
            out.print("bon");
            break;
        }
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

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

const double PI=3.14159265358979323846;

int main() {
	double a,b,h,m;
	cin >> a >> b >> h >> m;
	double jx,jy,fx,fy;
	jx = a * sin(2*PI*(60*h+m)/720);
	jy = a * cos(2*PI*(60*h+m)/720);
	fx = b * sin(2*PI*m/60);
	fy = b * cos(2*PI*m/60);
	//cout << jx << " " << jy << " " << fx << " " << fy <<endl;
	double d = sqrt((jx-fx)*(jx-fx)+(jy-fy)*(jy-fy));
	cout << fixed << setprecision(12) << d << endl;
	return 0;
}


Measured memory_bytes: 4100
#include <iostream>//
#include <set>
using namespace std;
set<int> s;

int main() {
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            s.insert(i * j);
        }
    }
    int t;
    cin >> t;
    if (s.find(t) != s.end()) {
        cout << "Yes";
    }
    else cout << "No";

    return 0;
}
// Created by Kevin Weng on 2019/10/30.
//



Measured memory_bytes: 256
n,m=map(int,input().split())
dp=[False]*n
dp2=[1]*n

dp[0]=True

for i in range(m):
  x,y=map(int,input().split())
  x-=1
  y-=1
  dp2[y]+=1
  if dp[x]==True:
    dp[y]=True
    
  dp2[x]-=1
  if dp2[x]==0:
    dp[x]=False
    
ans=0

for i in range(n):
  if dp[i]==True:
    ans+=1
    
    
print(ans)

Measured memory_bytes: 76068
import sys
input = sys.stdin.readline

def slove():
    x, y = map(int,input().split())
    flag = False
    for i in range(x+1):
        if i*2 + (x-i)*4 == y:
            flag = True
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    slove()


Measured memory_bytes: 9168