akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>
#include <map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> pairs(n);
  REP(i, n)
  {
    ll a, b;
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }
  sort(pairs.begin(), pairs.end());

  ll result = 0;
  ll bought = 0;
  int i = 0;
  while (bought < m)
  {
    if (bought + pairs[i].second > m)
    {
      result += pairs[i].first * (m - bought);
      bought += m - bought;
    }
    else
    {
      result += pairs[i].first * pairs[i].second;
      bought += pairs[i].second;
    }
    i++;
  }
  cout << result << endl;
}

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

n, q = map(int, input().split())

AB = [[int(x) for x in input().split()] for _ in range(n - 1)]
PX = [[int(x) for x in input().split()] for _ in range(q)]

graph = [[] for _ in range(n + 1)]
# 各ノードと連結するノードを要素に持つ配列
# e.g., graph[1] -> ノード１と連結するノードを要素に持つ
for a, b in AB:
	graph[a].append(b)
	graph[b].append(a)

# 根に点数を入れる
value = [0] * (n + 1)
for p, x in PX:
	value[p] += x

# 根から値を流す
q = [(1, 0)]
while q:
	x, parent = q.pop() # (1, 0)
	value[x] += value[parent]
	# 連結する成分について繰り返す
	# このとき、親のノードに流さないように注意
	# ここでの操作は、自分の子のノードを加えること
	for y in graph[x]:
		if y == parent:
			continue
		q.append((y, x)) #(親,子)

res = ' '.join(map(str, value[1:]))
print(res)


Measured memory_bytes: 124260
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

void solve1() {

}

void solve2() {

}

void solve3() {
	int N;
	cin >> N;
	map<int, int> mp;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	

	int ans = 0;
	for (int i = 0; i <= 100000; i++)
	{
		ans = max(ans, mp[i - 1] + mp[i] + mp[i + 1]);
	}
	cout << ans << endl;
}

void solve4() {

}

int main() {
	//solve1();
	//solve2();
	solve3();
	//solve4();

	return 0;
}

Measured memory_bytes: 4992
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	bool ans = a <= c && c <= b;
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


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

typedef double                      ld;
typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define endl                        '\n'
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define kill(x)                     return cout << x << endl , 0;
#define pb                          push_back

const ll MXN = 1e3 + 10;
const ll MXM = 50 + 10;
const ll MX5 = 2e5 + 10;
const ll MX6 = 1e6 + 10;
const ll LOG = 20;
const ll INF = 8e18;
const ld eps = 1e-9;
const ll MOD = 1e9 + 7; //998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}
string base2(ll n){
    string a="";while(n>=2){a+=(char)(n%2+'0');n/=2;}a+=(char)(n+'0');reverse(all(a));return a;
}

ll n, m;

int main(){
    fast_io
    //file_io
    string s, t;
    cin >> n >> m;cout << n * m / bmm(n, m);




    return 0;
}

//! N.N


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

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

   bool judge=true;

   reverse(H.begin(),H.end());
   for(int i=0;i<N;++i){
      if(H[i]-H[i+1] < -1){
         cout << "No" << endl;
         return 0;
      }
      else if(H[i]-H[i+1]==-1) H[i+1]--;
   }
   if(judge) cout << "Yes" << endl;


   return 0;

}


Measured memory_bytes: 640
n, x, y = map(int, input().split())
x -= 1
y -= 1
cnt = [0] * n
for i in range(n-1):
    for j in range(i+1, n):
        direct = j - i
        detour = abs(x-i) + abs(y-j) + 1
        d = min(direct, detour)
        cnt[d] += 1
for k in range(1, n):
    print(cnt[k])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int n,m,a[55],b[55],ans=0;
bool v[55][55]={},vis[55];

void dfs(int i){
  if(vis[i]) return;
  vis[i]=1;
  fr(j,n) if(v[i][j]) dfs(j);
}

bool cnct(){
  fr(i,n) if(!vis[i]) return 0;
  return 1;
}

void clr(){
  fr(i,n) vis[i]=0;
}

int main(){
  cin>>n>>m;
  fr(i,m){cin>>a[i]>>b[i];v[--a[i]][--b[i]]=1;v[b[i]][a[i]]=1;}
  fr(i,m){
    clr();
    v[a[i]][b[i]]=0;v[b[i]][a[i]]=0;
    dfs(0);
    if(!cnct()) ans++;
    v[a[i]][b[i]]=1;v[b[i]][a[i]]=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 380
#include<iostream>

using namespace std;

int N, T;
static const int MAX = 200005;
int A[MAX];

int main(){
	cin >> N >> T;
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}

	long long ans = 0;
	for(int i = 0; i < N - 1; i++){
		ans += min(T, A[i + 1] - A[i]);
	}
	ans += T;

	cout << ans << endl;
	return 0;

}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main( void )
{
  long long d=100000;
  int n;
  cin >> n;
  for( int i=0; i<n; i++ ){
    d += d/20;
    if( d % 1000 > 0 ) d = (d/1000+1)*1000;
  }
  cout << d << endl;
  return 0;
}

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

int main() {
  int a,b,c,a1,b1,c1;
  cin >> a >> b >> c;
  b1=a;
  a1=c;
  c1=b;
  cout<<a1<<" "<<b1<<" "<<c1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, ans;
	char op;
	while (1) {
		cin >> a >> op >> b;
		if (op == '?') break;
		switch (op) {
		case('+') :
			ans = a + b;
			break;
		case('-') :
			ans = a - b;
			break;
		case('*') :
			ans = a * b;
			break;
		case('/') :
			ans = a / b;
			break;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int gcd2(int a,int b,int c){
	return __gcd(__gcd(a,b),c);
}
int main(){
	long long sum=0;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=gcd2(i,j,k);
			}
		}
	}
	cout<<sum<<'\n';
} 

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &e: A) {
    cin >> e;
  }

  auto m = minmax_element(begin(A),end(A));
  cout << *m.second - *m.first << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    string s;
    cin>>s;

    int n=s.length();
    int count=0;

    for(int i=0;i<n/2;i++) {
        if(s[i]!=s[n-1-i])  count++;
    }
    cout<<count<<endl;

 return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int N,W;
int dp[10001];

int main() {
    cin >> N >> W;
    int v[N],w[N];
    for(int i=0;i<N;i++){
        cin >>v[i] >>w[i];
    }
    for(int i=0;i<N;i++){
        for(int j=w[i];j<=W;j++){
                dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout << dp[W] << endl;
}



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

int main(){
  int N,M;cin>>N>>M;
  priority_queue<double>A;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    A.push(a);
  }
  
  for(int i=0;i<M;i++){
    int b;
    b=A.top();
    A.pop();
    b/=2;
    A.push(b);
  }
  
  long long res=0;
  
  for(int i=0;i<N;i++){
    res+=floor(A.top());
    A.pop();
  }
  
  cout<<res;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

using pos = struct {
	int x;
	int y;
};

vi split(string &str, char sep) {
	vi v;
	stringstream ss(str);
	string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer.length());
	}
	return v;
}

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

	string s;
	pos goal = { 0, 0 };
	cin >> s >> goal.x >> goal.y;

	vi v = split(s, 'T');
	goal.x -= v[0];

	vi tate, yoko;
	for (int i = 1; i < v.size(); i++) {
		(i & 1 ? tate : yoko).push_back(v[i]);
	}

	set<int> x = { 0 }, y = { 0 };
	for (auto &i : yoko) {
		set<int> next;
		for (auto &j : x) {
			next.insert(j + i);
			next.insert(j - i);
		}
		swap(x, next);
	}
	for (auto &i : tate) {
		set<int> next;
		for (auto &j : y) {
			next.insert(j + i);
			next.insert(j - i);
		}
		swap(y, next);
	}

	cout << (x.find(goal.x) != x.end() && y.find(goal.y) != y.end() ? "Yes" : "No") << endl;
	return 0;
}


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

int main(){
  int i, j, m, n, cost;
  int d[1001], c[1001], t[1001][1001];
  cin >> n >> m;

  for ( i=0; i<=n; i++){
    t[0][i]=1000000000;
  }
  for ( i=0; i<=m; i++){
    t[i][0]=0;
  }

  for (i=1; i<=n; i++){
    cin >> d[i];
  }

  for (j=1; j<=m; j++){
    cin >> c[j];
  }

  for (i=1; i<=m; i++){
    for (j=1; j<=n; j++){
      cost = t[i-1][j-1]+d[j]*c[i];
      if (cost < t[i-1][j]){
	t[i][j]=cost;
      } else {
	t[i][j]=t[i-1][j];
      }

      //  cout << t[i][j] << endl;

    }
  }

  cout << t[m][n] << endl;

  return 0;

}

Measured memory_bytes: 6984
#include<stdio.h>
#define A 100000;
int main()
{
	int N,M;
	int R_min,L_max,R,L;
	int i;
	scanf("%d %d",&N,&M);
	R_min=N;
	L_max=1;
	for(i=0;i<M;i++){
		scanf("%d %d",&L,&R);
		if(R<R_min){
			R_min=R;
		}
		if(L>L_max){
			L_max=L;
		}
	}
	if(N<=R_min){
		printf("%d\n",N-L_max+1);
	}else if(R_min>=L_max){
		printf("%d",R_min-L_max+1);
	}else{
		printf("0");
	}
}


Measured memory_bytes: 128
import math

n = int(input())
no_sosu = 0

for i in range(n):
    s = int(input())
    
    if s%2 == 0:
        if s != 2:
            no_sosu += 1

    else:
        for j in range(3,s,2):
            if j**2 > s:
                break
            if s%j == 0:
                no_sosu += 1
                break

print(n-no_sosu)
            


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

void func(long long a, long long b, long long c, long long d) {
    ll x = b - b / c - b / d + b / lcm(c, d);
    ll y = a - 1 - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d);
	// 答えはb個とa-1個の差で求まる。
    // a-1,bそれぞれの割り切れる数は、c,dで割った小数点以下切り捨てで求める。
    // 後は、c,dのlcm(最小公倍数)の数だけ重複しているので戻す。

    cout << x - y << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long D;
    scanf("%lld", &D);
    func(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
from collections import deque


def create_group(N, n):
    city = [[] for _ in range(N + 1)]
    for _ in range(n):
        p, q = map(int, input().split(" "))
        city[p].append(q)
        city[q].append(p)

    group_list = [0] * (N + 1)
    gid = 0
    Q = deque()
    for i in range(1, N + 1):
        if group_list[i] == 0:
            gid += 1
            Q.clear()
            Q.append(i)
            group_list[i] = gid
            while len(Q) > 0:
                x = Q.popleft()
                for y in city[x]:
                    if group_list[y] == 0:
                        group_list[y] = gid
                        Q.append(y)

    return group_list

if __name__ == "__main__":
    N, K, L = list(map(int, input().split(" ")))
    rg = create_group(N, K)
    lg = create_group(N, L)

    rg_lg_dict = {}
    for i in range(1, N+1):
        key = (rg[i], lg[i])
        if key in rg_lg_dict:
            rg_lg_dict[key] += 1
        else:
            rg_lg_dict[key] = 1

    print_list = []
    for i in range(1, N+1):
        key = (rg[i], lg[i])
        print_list.append(str(rg_lg_dict[key]))
    print(" ".join(print_list))


Measured memory_bytes: 56492
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d",&n,&q);

  for(i = 1 ; i <= n ; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1; tail = n + 1;

  while( head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;
}



Measured memory_bytes: 11852
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;

int main() {
	std::string s;
	ll k;
	ll ans = 0;
	bool b = false;
	std::cin >> s >> k;
	if (k > s.size()) {
		for (ll i = 0; i < s.size(); ++i) {
			if (s[i] != '1') {
				ans = i;
				b = true;
				break;
			}
		}
	}
	else {
		for (ll i = 0; i < k; ++i) {
			if (s[i] != '1') {
				ans = i;
				b = true;
				break;
			}
		}
	}
	if (b) {
		std::cout << s[ans] << std::endl;
	}
	else {
		std::cout << 1 << std::endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n, h, w; 
		n = scanner.nextInt();
		h = scanner.nextInt();
		w = scanner.nextInt();
		int cnt = 0;
		for (int i=0; i<n; i++) {
			int x, y;
			x = scanner.nextInt();
			y = scanner.nextInt();
			if (x >= h && y >= w) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 24916
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int Y = sc.nextInt();
   boolean yen =false;
   int z =0;
 
   int ansx=-1;
   int ansy=-1;
   int ansz=-1;
   
   for(int x =0;x<=N;x++)
   {
     for(int y=0;y<=N-x;y++)
     {
       z=N-x-y;
       if(10000*x+5000*y+1000*z==Y)
       {
         ansx=x;
         ansy=y;
         ansz=z;
         yen=true;
         break;
       }
     }
     if(yen) break;
   }
   System.out.println(ansx+" "+ansy+" "+ansz);
 }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    bool A[N];
    for(int i = 0; i < N; i++) A[i] = false;
    for(int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++) {
            int a;
            cin >> a;
            A[a - 1] = true;
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++)
        if(!A[i]) ans++;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    string arr[10000];
    int n; cin >> n;
    rep(i, n) cin >> arr[i];
    priority_queue<int> q;
    rep(i, n) rep(j, n){
        if(i == j) continue;
        int k = stoi((arr[i] + arr[j]));
        q.push(k);
        if(q.size()>3) q.pop();
    }
    cout << q.top() << endl;
}

Measured memory_bytes: 1684
len = gets.to_i
arr = gets.split(' ').map(&:to_i)

cnt = 0
0.upto(len-2) do |i|
  minj = i
  (i+1).upto(len-1) do |j|
    minj = j if arr[minj] > arr[j]
  end
  if minj != i
    arr[i], arr[minj] = arr[minj], arr[i]
    cnt += 1
  end
end

puts arr.join(' ')
puts cnt


Measured memory_bytes: 6864
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
function main()
  n=parse(Int,readline())
  r=0
  if n<=500000
    for c=1:n-1
      N=n-c
      for i=1:isqrt(N)
        if N%i!=0
        elseif N==i^2; r+=1
        else; r+=2
        end
      end
    end
  else
    r+=6638407
    for c=1:n-500000
      N=n-c
      for i=1:isqrt(N)
        if N%i!=0
        elseif N==i^2; r+=1
        else; r+=2
        end
      end
    end
  end
  println(r)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 160872
package main

import (
	"fmt"
	"strings"
)

func main() {
	s := "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
	s = strings.Replace(s, ",", "", -1)
	ns := strings.Split(s, " ")

	var n int
	fmt.Scan(&n)
	fmt.Println(string(ns[n-1]))

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using  namespace std;
int main(){
 long long h, w, ans;
 cin >> h >> w;
 if(h==1){
   if(w>1){
     ans=(w-2);
   }else{
     ans=1;
   }
 }else if(w==1){
   if(h>1){
     ans=(h-2);
   }else{
     ans=1;
   }
 }else{
   ans = (h-2)*(w-2);
 }
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstdlib>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;


int main () {
  unsigned long long A, B, num=0;
  cin >> A >> B;
  std::vector<long long> vB(40),vA(40),v(40);
  // long long C = A - B + 1;
  vB[0] = B % 4 == 0 ||  B % 4 == 3 ? 0 : 1;
  for(long long i=1; i< 40; i++ ) {
    if (!(B >> i & 1)) vB[i] = 0;
    else {
      vB[i] = (B%(long long)pow(2,i+1) - (long long)pow(2,i) + 1)%2;
    }
  }
  if(A) {
    A--;
    vA[0] = A % 4 == 0 ||  A % 4 == 3 ? 0 : 1;
    v[0] = abs(vB[0] - vA[0]);
    for(long long i=1; i< 40; i++ ) {
      if (!(A >> i & 1)) vA[i] = 0;
      else {
        vA[i] = (A%(long long)pow(2,i+1) - (long long)pow(2,i) + 1) %2;
      }
      v[i] = abs(vB[i] - vA[i]);
    }
  } else {
    for(long long i=0; i< 40; i++ ) {
      v[i] = vB[i];
    }
  }
  for (long long i = 0; i < 40; i++) {
    num += v[i]%2 * (long long)pow(2,i);
  }
  // for(long long i = 0; i< 9; i++) {
  //   cout << vA[i] << " : " << vB[i] << endl;
  // }
  cout << num << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a;
  cin>>a;
  if(a=='a'||a=='b'||a=='c'||a=='d'||a=='e'||a=='f'||a=='g'||a=='h'||a=='i'||a=='j'||a=='k'||a=='l'||a=='m'||a=='n'||a=='o'||a=='p'||a=='q'||a=='r'||a=='s'||a=='t'||a=='u'||a=='v'||a=='w'||a=='x'||a=='y'||a=='z'){
    cout<<"a"<<endl;
  }
    else{
      cout<<"A"<<endl;
    }
  }

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

int Judge(string WordT, string WordH){
	int c;
	if(WordT.size() < WordH.size()){
		c = WordT.size();
	}else{
		c = WordH.size();
	}
	for(int i = 0; i < c; i++){
		if(WordT[i] != WordH[i]){
			if(WordT[i] > WordH[i]) return 1;
			if(WordT[i] < WordH[i]) return 2;
//			break;
		}
	}
	if(WordT.size() > WordH.size()) return 1;
	if(WordT.size() < WordH.size()) return 2;
	if(WordT.size() == WordH.size()) return 3;
}

int main(){
	//???????????????????????°n????????????
	int n;
	cin >> n;
	//???????????????????????????????????????????????????????????¨????????????????????????
	int PointT = 0;
	int PointH = 0;
	for(int i = 0; i < n; i++){
		string WordT;
		string WordH;
		cin >> WordT;
		cin >> WordH;
		if(Judge(WordT, WordH) == 1) PointT += 3;
		if(Judge(WordT, WordH) == 3) PointT++, PointH++;
		if(Judge(WordT, WordH) == 2) PointH += 3;
	}
	//????¨????????????¨?????????
	cout << PointT << " " << PointH << endl;
	return 0;
}

Measured memory_bytes: 1216
[A,B,M] = list(map(int,input().split()))
AL = list(map(int,input().split()))
BL = list(map(int,input().split()))
XYC = []
for i in range(M):
    XYC.append(list(map(int,input().split())))

out = []
for i in range(0,M):
    X = XYC[i][0]
    Y = XYC[i][1]
    C = XYC[i][2]
    out.append(AL[X-1]+BL[Y-1]-C)

print(min(min(out),min(AL)+min(BL)))

Measured memory_bytes: 88300
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    import itertools

    ind = 1
    brick = 0
    for a in A:
        if a == ind:
            ind += 1
        else:
            brick += 1
    if brick == N:
        print(-1)
    else:
        print(brick)


#     indices = [i for i in range(N)]
#     for i in range(N):
#         for v in itertools.combinations(indices, i):
#             v = list(v)
#             # print(v)
#             tmp_l = get_l(A, v)
#             # print(tmp_l)
#             if judge(tmp_l):
#                 print(i)
#                 exit()
#     print(-1)


# def get_l(l, rm_ind):
#     ans = []
#     for i, a in enumerate(l):
#         if i in rm_ind:
#             continue
#         ans.append(a)
#     return ans


# def judge(l):
#     for i, a in enumerate(l):
#         if i+1 != a:
#             return False
#     return True


if __name__ == "__main__":
    main()


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

namespace _0256
{
    class Program
    {
        static void Main(string[] args)
        {
            int s1 = int.Parse(Console.ReadLine());
            int s2 = int.Parse(Console.ReadLine());
            int s3= int.Parse(Console.ReadLine());
            int s4 = int.Parse(Console.ReadLine());
            int s5 = int.Parse(Console.ReadLine());
            int s6 = int.Parse(Console.ReadLine());
            int s7 = int.Parse(Console.ReadLine());
            int s8 = int.Parse(Console.ReadLine());
            int s9 = int.Parse(Console.ReadLine());
            int s10 = int.Parse(Console.ReadLine());
            int s11 = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10;
            Console.WriteLine(s11);
        }
    }
}



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

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

    sort(T.begin(), T.end());
    int target = T.back();

    vector<int> divs;
    for(int i=1; i*i<=target; i++) {
        if(target % i == 0) {
            divs.emplace_back(i);
            if(target / i != i) divs.emplace_back(target / i);
        }
    }
    sort(divs.begin(), divs.end());

    long long int sum = 0;
    for(int i=0; i<N; i++) {
        for(auto d : divs) {
            if(d < T[i]) continue;
            sum += d - T[i];
            break;
        }
    }
    cout << sum << endl;
    return 0;
}



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

int left(int i){return i * 2;}
int right(int i){return i * 2 + 1;}

int h;

int maxHeapify(int T[], int i){
  int l = left(i);
  int r = right(i);
  int largest = i;
  if ( l <= h && T[i] < T[l]){
    largest = l;
  }
  if ( r <=  h && T[largest] < T[r]){
    largest = r;
  }

  if ( largest != i){
    swap(T[i], T[largest]);
    maxHeapify(T, largest);
  }

  return 0;
}

void buildMaxHeap(int T[]){
  for (int i = h/2; i > 0; i--){
    maxHeapify(T, i);
  }
}

int main(){
  cin >> h;
  int T[h + 1];
  for (int i = 1; i <= h; i++){
    cin >> T[i];
  }

  buildMaxHeap(T);

  for ( int i = 1; i <= h; i++){
    cout << " " << T[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> v(n);
    REP(i,n) cin >> v[i];

    if (n == 1) {
        x = v.back();
    } else {
        if (abs(v[n-2] -v [n-1]) >= abs(v[n-1] - y)) {
            x = v[n-2]; y = v[n-1];
        } else {
            x = v[n-1];
        }
    }

    cout << abs(x - y) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
a,b=reads()
print(a*b)

Measured memory_bytes: 9612
// ayy
// ' lamo
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld; //CARE
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
const ld eps=1e-8;
const int inf=1e9+99;
const ll linf=1e18+99;
const int P=1e9+7;








char z[512][512];
char typ[]="RYGB";



int32_t main() {
	int n,m,d; scanf("%d%d%d",&n,&m,&d);
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) {
		int x=i+j;
		int y=i-j+m;
		assert(x>=0 && y>=0);
		x/=d, y/=d;

		int t=0;
		if(x&1) t+=1;
		if(y&1) t+=2;
		z[i][j]=typ[t];
	}
	for(int i=0;i<n;i++) z[i][m]=0, printf("%s\n",z[i]);
}













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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int n, m, ans = -1, loop, start, temp_s, temp_c, temp, check;
  bool flag;
  vector<int> c(3, -1);

  cin >> n >> m;
  loop = pow(10, n);
  start = (n == 1 ? 0 : pow(10, n - 1));
  flag = true;
  for (int i = 0; i < m; i++)
  {
    cin >> temp_s >> temp_c;
    if (c[temp_s - 1] == -1 || c[temp_s - 1] == temp_c)
      c[temp_s - 1] = temp_c;
    else
      flag = false;
  }
  if (!flag)
  {
    cout << -1 << endl;
    return (0);
  }
  for (int i = start; i < loop; i++)
  {
    temp = i;
    check = 0;
    flag = true;
    if (n == 3)
    {
      if (c[check] != -1 && c[check] != temp / 100)
        flag = false;
      temp -= (temp / 100) * 100;
      check++;
    }
    if (n >= 2)
    {
      if (c[check] != -1 && c[check] != (temp / 10))
        flag = false;
      temp -= (temp / 10) * 10;
      check++;
    }
    if (c[check] != -1 && c[check] != temp)
      flag = false;
    if (flag)
    {
      cout << i << endl;
      return (0);
    }
  }
  cout << -1 << endl;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    reps(i,1,b){
        if((a * i) % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
divisor :: Integral a => a -> [a]
divisor n = foldr f [] $ takeWhile ((<= n) . (^2)) [1..n]
  where
    f x xs
        | r == 0, q /= x = x : q : xs
        | r == 0         = x : xs
        | otherwise      = xs
      where
        (q, r) = n `divMod` x

digitNum :: Integral a => a -> a
digitNum = go 0
  where
    go i 0 = i
    go i x = go (i+1) (x `div` 10)

solve :: Int -> Int
solve n = f a b
  where
    d     = divisor n
    (a,b) = let a = last d
                b = n `div` a
             in (a,b)
    f a b = max (digitNum a) (digitNum b)

main :: IO ()
main = do
    n <- readLn :: IO Int
    print $ solve n

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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int X, A, B;
  cin >> X >> A >> B;
  
  int d = B - A;
  if (d <= 0) cout << "delicious" << endl;
  else if (d <= X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

//Ｏ(log n)
//x^nの高速計算
lint mod_pow(lint x,lint n,lint MOD){
  if(n==0)return 1;
  lint res=mod_pow(x*x%MOD,n/2,MOD);
  if(n%2==1)res=res*x%MOD;
  return res;
}

signed main(){
  int N;cin>>N;
  static int A[100010];
  for(int t=1;t<=N;t++)cin>>A[t];

  map<int,int>mp;
  for(int t=1;t<=N;t++)mp[A[t]]++;

  if(N%2==0){
    if(mp[1]!=2){
      cout<<0<<endl;
      return 0;
    }
  }else{
    if(mp[0]!=1){
      cout<<0<<endl;
      return 0;
    }
  }
  if(N%2==1){
    for(int t=2;t<N;t+=2){
      if(mp[t]!=2){
        cout<<0<<"!"<<endl;
        return 0;
      }
    }
  }else{
    for(int t=3;t<N;t+=2){
      if(mp[t]!=2){
        cout<<0<<endl;
        return 0;
      }
    }
  }

  int ans=mod_pow(2LL,(N-1)/2,MOD);
  if(N%2==0)ans=(ans*2)%MOD;

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

ll rec(int n, vector<vector<int>> &tree, vector<vector<ll>> &dp, int black, int par) {
  if(dp[n][black] != -1) return dp[n][black];
  if(tree[n].size() == 0) return dp[n][black] = 1;
  ll res = 1;
  if(black) {
    for (auto child : tree[n]) {
      if(child != par) {
	res = (res * rec(child, tree, dp, 0, n)) % MOD;
      }
    } 
  } else {
    for(auto child : tree[n]) {
      if(child != par) {
	res = (res * (rec(child, tree, dp, 0, n) + rec(child, tree, dp, 1, n)) % MOD) % MOD;
      }
    }
  }
  return dp[n][black] = res;
}


int main() {
  int N; cin >> N;
  vector<vector<int>> tree(N, vector<int>());
  rep(i, N - 1) {
    int x, y; cin >> x >> y;
    x--; y--;
    tree[x].push_back(y);
    tree[y].push_back(x);    
  }
  vector<vector<ll>> dp(N, vector<ll>(2, -1));
  ll ans = (rec(0, tree, dp, 0, -1) + rec(0, tree, dp, 1, -1)) % MOD;
  cout << ans << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
  public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

typedef Point Vector;

// 内積
double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
};

// 外積
double cross(Vector a, Vector b) {
  return a.x * b.y - a.y * b.x;
};

// 直交判定
bool isOrthogonal(Vector a, Vector b) {
  return equals(dot(a, b), 0.0);
};

// 並行判定
bool isParallel(Vector a, Vector b) {
  return equals(cross(a, b), 0.0);
};

int main() {
  int q;
  cin >> q;
  int x0, y0, x1, y1, x2, y2, x3, y3;
  Vector a, b;
  rep(i, 0, q) {
    cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    a.x = x1 - x0; a.y = y1 - y0;
    b.x = x3 - x2; b.y = y3 - y2;
    if (isOrthogonal(a, b)) {
      cout << 1 << endl;
    } else if (isParallel(a, b)) {
      cout << 2 << endl;
    } else {
      cout << 0 << endl;
    }
  }
};



Measured memory_bytes: 3108
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let n = read::<usize>();
    let mut a: Vec<u128> = vec![0; n];
    for i in 0..n {
        a[i] = read::<u128>();
    }
    let mut zero = false;
    for i in 0..n {
        if a[i] == 0 {
            zero = true;
            break;
        }
    }
    if zero {
        println!("{}", 0);
        return;
    }

    let mut res: u128 = 1;
    let mut over = false;
    for i in 0..n {
        res *= a[i];
        if res > 1000000000000000000 {
            println!("{}", -1);
            over = true;
            break;
        }
    }
    if over {
        return;
    }

    println!("{}", res);
}


Measured memory_bytes: 3584
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            Solve();

        }
        static void Solve()
        {
            var inp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var N = long.Parse(Console.ReadLine());
            //var S = Console.ReadLine();
            var A = inp[0];
            var B = inp[1];
            var C = inp[2];
            var D = inp[3];

            var ans = B * D;
            ans = Max(ans, A * C);
            ans = Max(ans, B * C);
            ans = Max(ans, A * D);
            
            if((A<= 0 && 0 <= B)|| (C <= 0 && 0 <= D))
            {
                ans = Max(ans, 0);
            }
            Console.WriteLine(ans);
        }
    }

    
}


Measured memory_bytes: 28224
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
ans=[]
for i in range(h):
  for j in range(w-1):
    if a[i][j]%2:
      a[i][j]-=1
      a[i][j+1]+=1
      ans+=[(i+1,j+1,i+1,j+2)]
for i in range(h-1):
  if a[i][w-1]%2:
    a[i][w-1]-=1
    a[i+1][w-1]+=1
    ans+=[(i+1,w,i+2,w)]
print(len(ans))
for i in ans:
  print(*i)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    int x, y; cin >> x >> y;

    int k, flag=0;
    for(int i=0; i<=x; i++){
        k = x - i;
        if(y == i*2+k*4) flag=1;
    }
    if(flag) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <math.h>
int main(void) {
	double x[3000], y[3000], sum_distance = 0;
	int n, line_count = 0;

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

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			sum_distance += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
			line_count++;
		}
	}
	
	printf("%lf\n", sum_distance / line_count * (n - 1));
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define INF ((int)1e9)
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define N 200005
int main() {
    SYNC
    ll ans = 1e16;
    int n, a; ll ps[N] = {};
    cin >> n;
    FOR0(i, n) {
        cin >> a;
        ps[i+1] = ps[i] + a;
    }
    FOR(i, 1, n) ans = min(ans, abs(ps[i] - (ps[n]-ps[i])));
    cout << ans;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    string s; cin >> s;
    int y = stoi(s.substr(0,4)), m = stoi(s.substr(5,2));
    bool is_heisei;
    if(y == 2019){
        is_heisei = m < 5;
    }else{
        is_heisei = y < 2019;
    }
    cout << (is_heisei ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll h[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>h[i];
  }

  ll dp[n+2]={};
  for(int i=0;i<=n+1;i++){
    dp[i]=1e10;
  }
  dp[1]=0;
  for(int i=0;i<n;i++){
    if(i<n-1)dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
  }

  cout<<dp[n]<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define inf 0x7fffffff
#define MN 2005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
priority_queue<int,vector<int>,greater<int> >q;
int a[MN],b[MN];
int n,k,qu,cnt=0,dif,res=inf;
int main()
{
	n=in();k=in();qu=in();
	for (int i=1;i<=n;++i) a[i]=in();
	for (int i=1;i<=n;++i){
		while (!q.empty()) q.pop();
		for (int hd=1,tl=0;hd<=n;hd=tl){
			for (;a[hd]<a[i]&&hd<=n;++hd);
			for (tl=hd;a[tl]>=a[i]&&tl<=n;++tl);
			int len=tl-hd;if (len>=k){
				for (int j=hd,l=0;j<tl;++j,++l) b[l]=a[j];sort(b,b+len);
				for (int j=0;j<len-k+1;++j) q.push(b[j]); 
			}
		}
		for (int j=1;j<qu;++j) if (!q.empty()) q.pop();else continue;
		if (q.empty()) continue;
		dif=q.top();q.pop();res=min(res,dif-a[i]);
	}printf("%d",res);return 0;
}

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

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

  ll Minimun, Maximum;

  Maximum = b - b%x;

  if(a%x==0) Minimun = a;
  else Minimun = a-a%x + x;

  ll ans = (Maximum - Minimun)/x + 1;

  cout << ans <<endl;
  

  return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    ll d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;

int n, d, h;
int fac[1000005], pfac[1000005];
int dp[1000005], pdp[1000005];

int main()
{
	scanf("%d%d%d", &n, &h, &d);
	
	fac[0] = 1;
	rep1(i, n) fac[i] = 1LL * fac[i - 1] * i % MOD;
	rep1(i, n) pfac[i] = (pfac[i - 1] + fac[i]) % MOD;
	
	pdp[0] = dp[0] = fac[n];
	rep1(i, h) {
		dp[i] = pdp[i - 1];
		if(i > d) dp[i] = (dp[i] - pdp[i - d - 1] + MOD) % MOD;
		if(i < h) dp[i] = 1LL * dp[i] * pfac[n] % MOD;
		pdp[i] = (pdp[i - 1] + dp[i]) % MOD;
	}
	
	printf("%d\n", dp[h]);
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, 0, N)
    {
        cin >> d.at(i);
    }
    sort(all(d));
    cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a,b,k,x1,y_1,x2,y2,d[500005],v[1005][1005];
bool n[1005][1005],vi[500005];
char c;
struct st{
	int w,v;
	st(int V,int W){
		w=W;
		v=V;
	}
};
struct st1{
	int w,dd;
	st1(){}
	st1(int W,int DD){
		w=W;
		dd=DD;
	}
	friend bool operator < (st1 x,st1 y){return x.dd>y.dd;}
};
priority_queue<st1>q;
vector<st> ans[500005];
int Dijkstra(int s,int t){
	memset(d,0x3f,sizeof(d));
	memset(vi,0,sizeof(vi));
	d[s]=0;
	q.push(st1(s,0));
	while(q.size()){
		int x=q.top().w;
		q.pop();
		if(vi[x]){
			continue;
		} 
		vi[x]=1;
		int siz=ans[x].size();
		for(int i=0;i<siz;i++){
			int vr=ans[x][i].v,w=ans[x][i].w;
			if(d[vr]>d[x]+w){
				d[vr]=d[x]+w;
				q.push(st1(vr,d[vr]));
			}
		}
	}
	return d[t];
}
void dfs(int x,int y){
	if(x>1&&v[x-1][y]==0&&n[x-1][y]==0){
		n[x-1][y]=1;
		v[x-1][y]=k;
		dfs(x-1,y);
		n[x-1][y]=0;
	}
	if(x<a&&v[x+1][y]==0&&n[x+1][y]==0){
		n[x+1][y]=1;
		v[x+1][y]=k;
		dfs(x+1,y);
		n[x+1][y]=0;
	}
	if(y>1&&v[x][y-1]==0&&n[x][y-1]==0){
		n[x][y-1]=1;
		v[x][y-1]=k;
		dfs(x,y-1);
		n[x][y-1]=0;
	}
	if(y<b&&v[x][y+1]==0&&n[x][y+1]==0){
		n[x][y+1]=1;
		v[x][y+1]=k;
		dfs(x,y+1);
		n[x][y+1]=0;
	}
}
int main(){
	scanf("%d %d\n",&a,&b);
	scanf("%d %d\n",&x2,&y2);
	scanf("%d %d",&x1,&y_1);
	for(int i=1;i<=a;i++){
		scanf("\n");
		for(int j=1;j<=b;j++){
			scanf("%c",&c);
			if(c=='#')n[i][j]=1;
		}
	}
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			if(v[i][j]==0&&n[i][j]==0){
				k++;
				v[i][j]=k;
				n[i][j]=1;
				dfs(i,j);
				n[i][j]=0;
			}
		}
	}
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			for(int i1=max(1,i-2);i1<=min(a,i+2);i1++){
				for(int j1=max(1,j-2);j1<=min(b,j+2);j1++){
					if(v[i][j]!=0&&v[i1][j1]!=0&&v[i][j]!=v[i1][j1]){
						ans[v[i][j]].push_back(st(v[i1][j1],1));
						ans[v[i1][j1]].push_back(st(v[i][j],1));
					}
				}
			}
		}
	}
	if(Dijkstra(v[x1][y_1],v[x2][y2])==0x3f3f3f3f){
		printf("-1");
	}else printf("%d",Dijkstra(v[x1][y_1],v[x2][y2]));
	
}

Measured memory_bytes: 65744
import java.util.*;

public class Main {
	static double[] arr;
	static double[][] dp;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		arr = new double[n + 1];
		dp = new double[n + 1][n + 1];
		for (int i = 1; i <= n; i++) {
			arr[i] = sc.nextDouble();
		}
		dp[0][0] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= i; j++) {
				if (j == 0) {
					dp[i][j] = dp[i - 1][j] * (1 - arr[i]);
				} else {
					dp[i][j] = dp[i - 1][j] * (1 - arr[i]) + dp[i - 1][j - 1] * arr[i];
				}
			}
		}
		double ans = 0;
		for (int i = n / 2 + 1; i <= n; i++) {
			ans += dp[n][i];
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 135944