akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void solve(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    //いつか限界が来る
    if(b>d){
        cout<<"No"<<endl;
        return ;
    }
    //最初から無理やん
    if(a<b){
        cout<<"No"<<endl;
        return ;
    }
    //b>dをふまえると超余裕
    if(b<=c+1){
        cout<<"Yes"<<endl;
        return ;
    }

    //c<x<bかつx=A+gcd(b,d)となるようなxが存在するか
    ll g=gcd(b,d);
    ll k;
    if(c-a>=0){
        k=(c-a)/g+1;
    }else{
        if((c-a)%g==0){
            k=(c-a)/g+1;
        }else{
            k=(c-a)/g;
        }
    }
    ll x=a+k*g;
    if(x<b){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

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

    int q;cin>>q;
    while(q--) solve();
    return 0;
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long n;
	cin >> n;
	cout << (n * (n - 1)) / 2 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int x;
  cin >> x;
  string ans = "NO";
  if (x == 7 || x == 5 || x == 3) ans = "YES";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  A = A - 1;
  ll N = (B / C) + (B / D) - B / lcm(C, D);
  ll M = (A / C) + (A / D) - A / lcm(C, D);
  cout << (B - N) - (A - M) << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

void init_com() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll indices[100005];

int main() {
  fill_n(indices, 100005, -1);
  init_com();
  // std::cout << std::fixed << std::setprecision(10);

  ll N;
  scanf("%lld", &N);

  ll same_index1 = -1;
  ll same_index2 = -1;

  vector<ll> list;
  for (ll i = 0; i < N + 1; i++) {
    ll v;
    scanf("%lld", &v);
    list.emplace_back(v);

    if (indices[v] >= 0) {
      same_index1 = indices[v];
      same_index2 = i;
    }

    indices[v] = i;
  }

  ll rest1 = same_index1;
  ll rest2 = N - same_index2;

  ll rest = rest1 + rest2;

  for (ll i = 1; i <= N + 1; i++) {
    ll count_all = com(N + 1, i);

    ll dup = com(rest, i - 1);

    ll ans = ((count_all - dup) + MOD) % MOD;
    cout << ans << endl;
  }
}


Measured memory_bytes: 16952
#include<iostream>
#include<bits/stdc++.h>
int main()
{
	int a[21];
	int n, num = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 1; i < n - 1; i++){
		if((a[i] < a[i - 1] && a[i] > a[i + 1]) || (a[i] > a[i - 1] && a[i] < a[i + 1])){
			num++;
		}
	}
	printf("%d", num);
	return 0;
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n,k;
string s;

int main(){
    cin >> n >> k;
    cin >> s;
    if(s[k-1] == 'A') s[k-1] = 'a';
    if(s[k-1] == 'B') s[k-1] = 'b';
    if(s[k-1] == 'C') s[k-1] = 'c';
    cout << s << endl;
}

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

int main() {
  string a,b;
  cin >>a >> b;
  int n = stoi(a+b);
  
  bool flag = false;
  for(int i = 1;i<=n;i++){
    if(n == i*i){
      flag = true;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
mod=10**9+7

m,n=map(int,input().split())
# def pow(m,n):
#     # mのn乗をmodを方にしてO(logn)で計算
#     if n==0:return 1
#     elif n%2==0:
#         return pow(m**2%mod,n//2)%mod
#     else:
#         return (pow(m**2%mod,n//2)*m)%mod

def pow(m,n,mod):
    rem=1
    while n>0:
        if n%2==1:
            rem=rem*m%mod
        m=m**2%mod
        n//=2
    return rem%mod

print(pow(m,n,mod))


Measured memory_bytes: 5600
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=998244353
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  p=20010
  h,n=LI()
  a=[]
  b=[]

  for _ in range(n):
    x,y=LI()
    a.append(x)
    b.append(y)

  dp=[[inf]*p for _ in range(n+1)]
  dp[0][0]=0

  for i in range(n):
    for j in range(p-5):
      dp[i+1][j]=min(dp[i+1][j],dp[i][j])
      if j+a[i]<p:
        dp[i+1][j+a[i]]=min(dp[i+1][j+a[i]],dp[i+1][j]+b[i])

  # print(dp)
  ans=inf
  for i in range(h,20010):
    ans=min(ans,dp[n][i])
  return ans

# main()
print(main())


Measured memory_bytes: 541068
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAX = 1000000;

int a0, L;
int data[MAX], x[6];

void solve() {
	for (int i=0; i<MAX; i++) data[i] =-1;
	int i=0, a=a0;
	while (data[a] == -1) {
		data[a] = i;
		for (int j=0; j<L; j++) {
			x[j] = a%10;
			a/=10;
		}
	sort(x, x+L);
	int max=0, min=0, c=1;
	for (int j=0; j<L; j++) {
	       max += x[j] *c;
	       min += x[L-j-1] *c;
	       c*=10;
	  }
	  a = max-min;
	  i++;
     }
     cout << data[a] << " " << a << " " << (i - data[a]) << endl;
}

int main() {
	while (cin >> a0 >> L, L) solve();
}

Measured memory_bytes: 5084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  int K; cin>>K;
  string T=S+S;
  int ans=0;
  rep(i,1,T.size()){
    if(T[i]==T[i-1]){
      ans++;
      T[i]='?';
    }
  }
  int count=1;
  rep(i,1,S.size()){
    if(S[i]==S[i-1]) count++;
    else break;
  }
  if((count%2==1||count==S.size())&&T[T.size()-1]==S[0]){
    ans++;
    ans*=K/2;
    S[0]='?';
    if(K%2==1){
      rep(i,1,S.size()){
        if(S[i]==S[i-1]){
          S[i]='?';
          ans++;
        }
      }
    }
    else ans--;
  }
  else{
    ans*=K/2;
    if(K%2==1){
      rep(i,1,S.size()){
        if(S[i]==S[i-1]){
          S[i]='?';
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var N int 
  var i int = 1
  var h int
  var height int = 0
  
  fmt.Scan(&N)
  fmt.Scan(&h)
  height = h

  for i < N {
    fmt.Scan(&h)
    if h > height {
      height = h - 1
    } else if h == height {
    } else if ( h - 1 ) >= height {
      height = h - 1
    } else {
      fmt.Println("No")
      break
    }
    i++
  }
  
  if i == N {
    fmt.Println("Yes")
  }
}

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

const int INF = 1e9+7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    for(int i = 0; i < m; i++){
        vector<int> next = dp;
        int a, b;
        cin >> a >> b;
        int bit = 0;
        while(b-- > 0){
            int x;  cin >> x;
            x--;
            bit += (1<<x);
        }
        for(int j = 0; j < 1<<n; j++){
            next[j|bit] = min(next[j|bit], next[j] + a);
        }
        dp = next;
    }
    cout << (dp[(1<<n)-1]==INF ? -1 : dp[(1<<n)-1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(a, n) rep(hoge, n) printf("%d%c", a[hoge], hoge == n - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ln(a) cout << (a) << endl
#define INF 1000000000

using namespace std;
using ll = long long;
using P = pair<int, int>;

struct segtree {
    int n;
    int* dat;

    segtree(int _n) {
        n = 1;
        while(n < _n) n *= 2;
        dat = new int[n * 2 - 1];
        fill(dat, dat + n * 2 - 1, INT_MAX);
    }

    void update(int i, int x) {
        i += n - 1;
        dat[i] = x;
        while(i > 0) {
            i = (i - 1) / 2;
            dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    int find(int s, int t, int i, int l, int r) {
        if(t <= l || r <= s) return INT_MAX;
        if(s <= l && r <= t) return dat[i];
        int lv = find(s, t, i * 2 + 1, l, (l + r) / 2);
        int rv = find(s, t, i * 2 + 2, (l + r) / 2, r);
        return min(lv, rv);
    }
};

signed main() {
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    int point[] = {p, r, s};
    string t;
    cin >> t;
    vector<int>* tv = new vector<int>[k];
    rep(i, n) {
        if(t[i] == 'r') tv[i % k].pb(0);
        else if(t[i] == 's') tv[i % k].pb(1);
        else tv[i % k].pb(2);
    }

    int ans = 0;
    rep(i, k) {
        int sz = tv[i].size();
        int** dp = new int*[sz + 1];
        rep(j, sz + 1) dp[j] = new int[3];
        dp[0][0] = dp[0][1] = dp[0][2] = 0;
        rep(j, sz) {
            rep(k, 3) {
                dp[j + 1][k] = 0;
                rep(l, 3) {
                    if(k == l) {
                        continue;
                    }
                    int tmp = dp[j][l];
                    if(tv[i][j] == k) tmp += point[k];
                    dp[j + 1][k] = max(dp[j + 1][k], tmp);
                }
            }
        }
        int res = 0;
        rep(j, 3) res = max(res, dp[sz][j]);
        ans += res;
    }

    ln(ans);
}


Measured memory_bytes: 13824
import sys
import copy
import string
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial

from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)


stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n = ni()
st, sa = na()
for i in range(1, n):
    t, a = na()
    if st <= t and sa <= a:
        st = t
        sa = a
    elif st > t and sa <= a:
        if st % t == 0:
            k = st // t
        else:
            k = st // t + 1
        st = t * k
        sa = a * k
    elif st <= t and sa > a:
        if sa % a == 0:
            k = sa // a
        else:
            k = sa // a + 1
        st = t * k
        sa = a * k
    elif st > t and sa > a:
        if st % t == 0:
            k = st // t
        else:
            k = st // t + 1
        if sa % a == 0:
            l = sa // a
        else:
            l = sa // a + 1
        st = t * max(k, l)
        sa = a * max(k, l)
print(st + sa)


Measured memory_bytes: 5456
# -*- coding: utf-8 -*-

N, W = list(map(int, input().split()))
W_l = []
V_l = []
for i in range(N):
    w, v = list(map(int, input().split()))
    W_l.append(w)
    V_l.append(v)

V_max = sum(V_l)+1
W_max = sum(W_l) +1

#print(V_max, W_max)
dp = [[W+1] * V_max for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    #print(i)
    for v in range(V_max):
        if v -V_l[i] >= 0:
            dp[i+1][v] = min(dp[i][v-V_l[i]]+W_l[i], dp[i][v])
        else:
            dp[i+1][v] = dp[i][v]
    #print(dp)
ans = 0
#print(dp[-1])
for v, w in enumerate(dp[-1]):
    if w <= W and ans <= v:
        ans = v
print(ans)


Measured memory_bytes: 120300
n = gets.to_i
candies = []
2.times do
  candies << gets.split.map(&:to_i)
end

array = []
0.upto(n - 1) do |turning|
  sum = 0
  current = [0, 0]
  0.upto(n - 1) do |now|
    sum += candies[current[0]][current[1]]
    if turning == now
      current[0] += 1
      sum += candies[current[0]][current[1]]
    end
    current[1] += 1
  end
  array << sum
end
puts array.max


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define lol long long
using namespace std;
signed main(){
  int sum=0;
  int m=100000;
  int n,l;
  cin >>n>>l;
  for(int i=0;i<n;i++){
    int k;
    k=l+i;
    sum+=k;
    if(abs(m)>abs(k)) m=k;
  }
  cout <<sum-m<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n,d,x;
    scanf("%d %d %d",&n,&d,&x);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0;; j++){
            if(j * a[i] + 1 <= d){
                sum++;
            }else{
                break;
            }
        }
    }
    printf("%d\n",sum + x);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n,m,e,j,i,cls[10000],flg;
	while(1){
		scanf("%d",&n);
		if(n<1)break;
		for(i=0;i<n;i++){
			flg=0;
			scanf("%d %d %d",&m,&e,&j);
			if(m==100||e==100||j==100){
				cls[i]=1;
			}
			else if(m+e>=90*2){
				cls[i]=1;
			}
			else if(m+e+j>=80*3){
				cls[i]=1;
			}
			else if(m+e+j>=70*3){
				cls[i]=2;
			}
			else if(m+e+j>=50*3&&(m>=80||e>=80)){
				cls[i]=2;
			}
			else if(flg<1){
				cls[i]=3;
			}
		}
		for(i=0;i<n;i++){
			if(cls[i]==1){
				printf("A\n");
			}
			if(cls[i]==2){
				printf("B\n");
			}
			if(cls[i]==3){
				printf("C\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1020
#include <iostream>
using namespace std;
int main()
{
	unsigned long long n,a,s,g=0,q[100001];
	cin>>n>>a>>s;
	for(int i=1;i<=n;i++)
		cin>>q[i];
	for(int i=2;i<=n;i++)
		if((q[i]-q[i-1])*a>s)
			g+=s;
		else
			g+=(q[i]-q[i-1])*a;
	cout<<g<<endl;
	return 0;
}

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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

signed main(){
	int x,y; cin>>x>>y;
	bool fail=y%2;
	int b=y/2-x;
	int a=x-b;
	fail|=a<0 or b<0;
	cout<<(fail?"No":"Yes")<<endl;
	return 0;
}



Measured memory_bytes: 3652
import sys

N = int(input())
stemp = input()
s = [True if stemp[i]== 'o' else False for i in range(N)]

T = [True, True] #Sheap, Sheap

for i in range(2,N+1):
    if s[i-1]^T[i-1]==True:
        T.append( not T[i-2])
    else:
        T.append( T[i-2])

if T[N] == T[0] and ((T[1]==T[N-1]) != (T[0] != s[0])):
    output = ['S' if T[i] == True else 'W' for i in range(N)]
    for i in range(N):
        print(output[i], end='')
    print()
    sys.exit()

T = [True, False] #Sheap, Wolf

for i in range(2,N+1):
    if s[i-1]^T[i-1]==True:
        T.append( not T[i-2])
    else:
        T.append( T[i-2])

if T[N] == T[0] and ((T[1]==T[N-1]) != (T[0] != s[0])):
    output = ['S' if T[i] == True else 'W' for i in range(N)]
    for i in range(N):
        print(output[i], end='')
    print()
    sys.exit()

T = [False, True] #Wolf, Sheap

for i in range(2,N+1):
    if s[i-1]^T[i-1]==True:
        T.append( not T[i-2])
    else:
        T.append( T[i-2])

if T[N] == T[0] and ((T[1]==T[N-1]) != (T[0] != s[0])):
    output = ['S' if T[i] == True else 'W' for i in range(N)]
    for i in range(N):
        print(output[i], end='')
    print()
    sys.exit()

T = [False, False]

for i in range(2,N+1):
    if s[i-1]^T[i-1]==True:
        T.append( not T[i-2])
    else:
        T.append( T[i-2])

if T[N] == T[0] and ((T[1]==T[N-1]) != (T[0] != s[0])):
    output = ['S' if T[i] == True else 'W' for i in range(N)]
    for i in range(N):
        print(output[i], end='')
    print()
    sys.exit()

print(-1)


Measured memory_bytes: 7244
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

vector<string> s;
int cnt[2010][2010][4];
int h,w;

int main() {
    cin>>h>>w;
    string str;
    for(int i=0;i<h;++i)cin>>str,s.push_back(str);
    int left=0,right=1,up=2,down=3;
    for(int i=0;i<h;++i){
        int p=-1;
        for(int j=0;j<w;++j){
            p=s[i][j]=='#'?-1:p+1;
            cnt[i][j][left]=p;
        }
    }
    for(int i=0;i<h;++i){
        int p=-1;
        for(int j=w-1;j>=0;--j){
            p=s[i][j]=='#'?-1:p+1;
            cnt[i][j][right]=p;
        }
    }
    for(int j=0;j<w;++j){
        int p=-1;
        for(int i=0;i<h;++i){
            p=s[i][j]=='#'?-1:p+1;
            cnt[i][j][up]=p;
        }
    }
    for(int j=0;j<w;++j){
        int p=-1;
        for(int i=h-1;i>=0;--i){
            p=s[i][j]=='#'?-1:p+1;
            cnt[i][j][down]=p;
        }
    }
    int ans=0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(s[i][j]=='#')continue;
            int k=0;
            for(int ii=0;ii<4;++ii)k+=cnt[i][j][ii];
            ans=max(k+1,ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 67200
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var ar []int
var br []bool
var ans int
var g map[int][]int
var qr []int

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	q := ri()
	g = map[int][]int{}
	for i := 1; i < n; i++ {
		a := ri()
		b := ri()
		if v, ok := g[a]; ok {
			g[a] = append(v, b)
		} else {
			g[a] = []int{b}
		}
		if v, ok := g[b]; ok {
			g[b] = append(v, a)
		} else {
			g[b] = []int{a}
		}
	}
	qr = make([]int, n+1)
	for i := 0; i < q; i++ {
		a := ri()
		b := ri()
		qr[a] += b
	}
	ar = make([]int, n+1)
	br = make([]bool, n+1)
	dfs(1, 0)
	for i := 1; i <= n; i++ {
		if i != 1 {
			fmt.Printf(" %d", ar[i])
		} else {
			fmt.Printf("%d", ar[i])
		}
	}
	fmt.Println()
}

func dfs(key, sum int) {
	if br[key] {
		return
	}
	br[key] = true
	sum += qr[key]
	ar[key] = sum
	ret := g[key]
	for i := 0; i < len(ret); i++ {
		dfs(ret[i], sum)
	}
}

var sc = bufio.NewScanner(os.Stdin)

func rs() string {
	sc.Scan()
	return sc.Text()
}

func ri() int {
	s := rs()
	a, _ := strconv.Atoi(s)
	return a
}


Measured memory_bytes: 55424
#!/usr/bin/python
import sys
import heapq
R=lambda:map(int,sys.stdin.readline().split())
xa,xb,xc,k=R()
a=sorted(R())
b=sorted(R())
c=sorted(R())
h=set()
q=[[-(a[-1]+b[-1]+c[-1]),xa-1,xb-1,xc-1]]
for _ in range(k):
	x,ya,yb,yc=heapq.heappop(q)
	print(-x)
	if ya>0 and (ya-1,yb,yc) not in h:
		h.add((ya-1,yb,yc))
		heapq.heappush(q,[x+a[ya]-a[ya-1],ya-1,yb,yc])
	if yb>0 and (ya,yb-1,yc) not in h:
		h.add((ya,yb-1,yc))
		heapq.heappush(q,[x+b[yb]-b[yb-1],ya,yb-1,yc])
	if yc>0 and (ya,yb,yc-1) not in h:
		h.add((ya,yb,yc-1))
		heapq.heappush(q,[x+c[yc]-c[yc-1],ya,yb,yc-1])

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

int c = 0;

void InsertSort(int *A,int n,int g);

int main(){
  int n;
  int i,j;
  int *A;
  int G[20];

  scanf("%d", &n);
  A = malloc(n * sizeof(int));
  for( i = 0 ; i < n ; i++ ) {
    scanf("%d", &A[i]);
  }
  
  int m;
  G[0] = 0;
  while(1){
    if( n < 3*G[m]+1) {
      break;
    }
    G[m+1] = 3*G[m] + 1;
    m++;
 }

  for( i = m ; i > 0 ; i--) {
    InsertSort(A,n,G[i]);
  }

  printf("%d\n", m);
  for( i = m ; i >= 1 ; i-- ){
    printf("%d ", G[i]);
  }
  printf("\n%d\n",c);

  for( i = 0 ; i < n ; i++ ){
    printf("%d\n", A[i]);
  }
  return 0;
}

void InsertSort(int *A,int n,int g){
  int i,j;
  int key;
  for( i = g ; i < n ; i++){
    j = i;
    key = A[i];
    while( 0 <= j - g){
      if( A[j-g] <= key){
	break;
      }
      A[j] = A[j-g];
      j -= g;
      c++;
    }
   A[j] = key;
 }
}



Measured memory_bytes: 5572
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll n;
ll A[N+5];
int main()
{
  finp;
  cin>>n;
  ll ans = 0;
  afor(i,1,n)
  {
    cin>>A[i];
    ans+= llabs(A[i] - A[i-1]);
  }
  ans+= llabs(0 - A[n]);



  afor(i,1,n)
  {
    ll curr = ans - llabs(A[i] - A[i-1]) - llabs(A[i+1] - A[i]) + llabs(A[i+1] - A[i-1]);



    cout<<curr<<"\n";
  }
return 0;
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n, k; cin >> n >> k;
	ll a[200005];
	bool flag[20005];
	vector<pll> p;
	p.push_back(make_pair(0,0));
	for(ll i=1LL;i<=n;i++){
		cin >> a[i];
		flag[i] = true;
		p.push_back(make_pair(i, a[i]));
	}
	vector<ll> v;
	ll s;
	ll loop_s = 0;
	v.push_back(1);
	flag[1] = false;
	for(ll i=1;i<=n;i++){
		s = p[v.back()].second;
		if(flag[s]){
			v.push_back(s);
			flag[s] = false;
		}else{
			loop_s = s;
			break;
		}
	}
	ll idx = 0;
	for(int i=0;i<v.size();i++){
		if(v[i]==loop_s){
			idx = i;
			break;
		}
	}
	if(k<=v.size()-1){
		cout << v[k] << endl;
		return 0;
	}
	ll ans = (k-idx)%(v.size()-idx)+idx;
	cout << v[ans] << endl;
	return 0;
}

Measured memory_bytes: 11528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139_Virtual
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(' ');
            int A = Convert.ToInt32(AB[0]);
            int B = Convert.ToInt32(AB[1]);
            int tap = 1;
            int get = 0;

            while (tap < B)
            {
                tap = tap + A -1;
                get++;

            } 
                Console.WriteLine(get);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL L, R;
  cin >> L >> R;
  LL M = 2019;
  LL mi = 2020;
  REP(b, L + 1, min(R + 1, L + M + 1)) {
    REP(a, L, b) {
      // DUMP(a, b);
      mi = min(mi, a * b % M);
    }
  }
  cout << mi << 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;
typedef long long ll;
const int INF = 1e9 + 7;

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> cnt(1000005);

  for (ll x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i <= 1000005; i += x) cnt[i]++;
  }
  for (ll x : a)
    if (cnt[x] == 1) ans++;

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


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

int P[10010];
void init(int N){
  for (int i=0;i<=N;i++) P[i]=i;
}

int root(int a){
  if(P[a]==a) return a;
  return(P[a] = root(P[a]));
}

bool is_same_set(int a,int b){
  return root(a) == root(b);
}
void unite(int a,int b){
  P[root(a)] = root(b);
}

int main(){
  int n,q;
  cin >> n>>q;
  init(n);
  for(int i=0;i<q;i++){
    int com,x,y;
    cin>>com>>x>>y;
    if(com==0){
      unite(x,y);
    }else{
      int k;
      k=is_same_set(x,y);
      cout << k<<endl;
    }
  }
}

Measured memory_bytes: 3244
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0;
            while ((line = br.readLine()) != null) {
            	double r=Double.parseDouble(line);
            	System.out.println(String.format("%.6f",r*r*Math.PI)+" "+String.format("%.6f",2*r*Math.PI));
            	
            	break;
            }
        }
    }
}

Measured memory_bytes: 24596
#include <iostream>

int main() {
  int A,B;
  std::cin >> A >> B;
  int sum = 0;
  for(int i=0;i<2;i++){
  if (A > B){
    sum += A;
    A--;
  }
  else {
    sum += B;
    B--;
  }}
  std::cout <<sum<< std::endl;
  return 0;
}


Measured memory_bytes: 256
#D - Xor Sum 4

import math
n=int(input())
al=list(map(int,input().split()))
a=['{:060b}'.format(x) for x in al]
a=''.join(a)
 
m=math.ceil(math.log(max(1,max(al)),2))
 
ans=0
for i in range(m):
  sum1=a[59-i::60].count('1')
  sum0=n-sum1
  ans+=2**i*sum1*sum0
 
print(ans%(10**9+7))

Measured memory_bytes: 73172
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	_ = readInt()
	s := readString()

	var r, b int
	for _, h := range []byte(s) {
		if h == 'R' {
			r++
		} else {
			b++
		}
	}

	if b < r {
		println("Yes")
	} else {
		println("No")
	}
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
from collections import deque
n,m = map(int,input().split())
l = [list() for i in range(n+1)]
ans = [0]*(n+1)
x = deque()
for i in range(m):
    a,b = map(int,input().split())
    if a == 1 :
        x.append(b)
        ans[b] = 1 
    elif b == 1:
        x.append(a)
        ans[a] = 1
    else:
        l[a] += [b]
        l[b] += [a]
while len(x) > 0:
    y = x.popleft()
    for num in l[y] :
        if ans[num] == 0:
            x.append(num)
            ans[num] = y
ans = ans[2:]
if 0 in ans :
    print('No')
else:
    print('Yes')
    for answer in ans:
        print(answer)

Measured memory_bytes: 95180
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve(n int64, as []int64) (ret []int64) {
	ret = make([]int64, n)
	for i, a := range as {
		ret[a - 1] = int64(i + 1)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	as := nextInts(n)
	res := solve(n, as)
	for i, r := range res {
		if i != 0 {
			fmt.Fprint(out,  " ")
		}
		fmt.Fprint(out, r)
	}
	fmt.Fprintln(out)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	ll n,ans=1;
	cin>>n;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=1000000007;
	}
	cout <<ans<<endl;
 	return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
#define mp make_pair

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形


int main(){
    int n,k;
    cin >> n>> k;
    int maxk=(n-1)*(n-2)/2;
    if(maxk<k){
        cout<<-1<<endl;
        return 0;
    }
    vector<pair<int,int> > edges;
    rep(i,n-1){
        edges.push_back(mp(i+1,n));
    }
    vector<pair<int,int> >temp;
    rep(i,n-1){
        if(n==2)continue;
        for(int j=i+1;j<n-1;j++){
            temp.push_back(mp(i+1,j+1));
        }
    }
    rep(i,maxk-k){
        edges.push_back(temp[i]);
    }
    cout<<edges.size()<<endl;
    rep(i,edges.size()){
        cout<<get<0>(edges[i])<<" "<<get<1>(edges[i])<<endl;
    }
    return 0;
}
    


Measured memory_bytes: 384
#include <iostream>
#include <bits/c++io.h>
#include <vector>
#include <tuple>
#include <queue>
#define N 100
#define INF 1e9 + 5
using namespace std;

#include <iostream>
#include <bits/c++io.h>
#include <vector>
#include <tuple>
#include <queue>
#define N 100
#define INF 1e9 + 5
using namespace std;
 
int solve(int k, vector<int> &c,vector<int> &dp){
    if(k==1)return 0;
    if(k<1)return INF;
    if(dp[k]!=-1) return dp[k];
    return dp[k] = min( solve(k-1,c,dp)+abs(c[k]-c[k-1]), solve(k-2,c,dp)+abs(c[k]-c[k-2]));
}

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> c(n+1);
    vector<int> dp(n+1,-1);
    for (int i=1;i<=n;i++){
        scanf("%d", &c[i]);
    }
    //재귀로 풀어봅시다. 
    //solve 는 n일 때 최소가 되는 값을 반환하는 함수라고 합시다. 
    dp[0]=INF;
    printf("%d",solve(n, c, dp));
    //선형으로 풀어봅시다.
    // dp[0]=0; 
    // for(int i =0;i<n;i++){
    //     for(auto j:{i+1,i+2}){
    //         dp[j] = min( dp[j], dp[i]+abs(v[j]-v[i]) );
    //     }
    // }
    // cout<<dp[n-1];

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin>>K>>S;
  int ans=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j>=0&&S-i-j<=K) {
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int n,k,x,y;

int main(){
    cin >> n >> k >> x >> y;

    ll ans = 0;

    ans += min(n,k) * x;
    ans += max(n - k,0) * y;
    cout << ans << endl;
    return 0;
}



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

public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        long[] inpt = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
        if(inpt[2] == 1) {
            Console.WriteLine(inpt[1]-inpt[0]+1);
            return;
        }

        long fromNum = (inpt[0]/inpt[2])*inpt[2];
        if(inpt[0] % inpt[2] > 0) {
            fromNum = (inpt[0]/inpt[2]+1)*inpt[2];
        }
        long toNum = (inpt[1]/inpt[2]+1)*inpt[2];

        Console.WriteLine((toNum-fromNum)/inpt[2]);
    }


    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"

2 10 3

";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 2904
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//AtCoder Beginner Contest 130
//B	Bounding
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		sc.nextLine();
		List<Integer> Ls = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			Ls.add(sc.nextInt());
		}
		sc.close();

		int ans = 1;

		int d = 0;
		for (Integer l : Ls) {
			d += l;
			if (d <= X) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}


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

class Program
{
    static void Main(string[] args)
    {
        //入力
        int a = crI();
        int b = crI();

        Console.WriteLine(6-a-b);
    }

  
    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}

}

Measured memory_bytes: 27436
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    a=a%b
    flg=0
    for i in range(1,b+1):
        if (a*i)%b==c:
            flg=1
    if flg==0:
        print('NO')
    else:
        print('YES')
if __name__ == '__main__':
    do()

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

#ifdef LOCAL

template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<template<class, class...> class C, class... A>
typename enable_if<!is_same<C<A...>, string>::value, ostream&>::type
operator<<(ostream& os, const C<A...> &c) {
	auto i = c.begin();
	while (i != c.end()) {
		os << " {"[i == c.begin()] << *i;
		os << ",}"[++i == c.end()];
	}
	return os;
}

#define debug(x) cerr << #x << " = " << x << endl;

#else
#define debug(...) {}
#endif

const int N = 1e6 + 5;

#define st first
#define nd second

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

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i ++) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> M >> D;
    for (int m = 1; m <= M; m++) {
        for (int d = 10; d <= D; d++) {
            int x = d / 10;
            int y = d % 10;
            if (x >= 2 && y >= 2 && x * y == m) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
	ll W, H;
	cin >> W >> H;
	
	vector<ll> p(W);
	vector<ll> q(H);
	for (int i = 0; i < W; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < H; i++) {
		cin >> q[i];
	}
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	ll a = 0;
	ll b = 0;
	p.push_back(1000000000);
	q.push_back(1000000000);
	ll res = 0;
	while (true) {

		if (p[a] < q[b]) {
			res += p[a] * (H + 1 - b);
			a++;
		}
		else {
			res += q[b] * (W + 1 - a);
			b++;

		}
		if (a == W&&b == H) {
			break;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2688
nu = gets.chomp.split("").map(&:to_i)
le = nu.length
ans = 1000
for i in 0..le - 3
  inst = nu[i]*100 + nu[i + 1]*10 + nu[i + 2]
  if (inst - 753).abs < ans
    ans = (inst - 753).abs
  end
end

puts ans


Measured memory_bytes: 1788
def resolve():
  s = input()
  num_b = 0
  num_r = 0
  for c in s:
    if c == '0':
      num_r += 1
    else:
      num_b += 1
  print(min(num_b, num_r) * 2)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,N) for(ll (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;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();

  int ans = INF;
  for (int i = 0; i < n - m + 1; ++i) {
    int cur = 0;

    rep(j, m) {
      int nj = i + j;
      if (s[nj] != t[j]) cur++;
    }

    ans = min(ans, cur);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
// 2015/05/30 Tazoe

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	while(true){
		char r[10], a[10];
		cin >> r >> a;

		if(strcmp(r, "0")==0 && strcmp(a, "0")==0)
			break;

		int h = 0, b = 0;

		for(int i=0; i<4; i++){
			for(int j=0; j<4; j++){
				if(r[i]==a[j]){
					if(i==j){	// ヒット
						h++;
					}
					else{		// ブロー
						b++;
					}
				}
			}
		}

		cout << h << ' ' << b << '\n';
	}

	return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

int main()
{
  int n, k, i;
  ll ans1 = INF, ans2 = INF;
  cin >> n >> k;
  vector<ll> x(n), dist1(n - k + 1), dist2(n - k + 1);
  for (i = 0; i < n; ++i)
  {
    cin >> x[i];
  }
  if (n == k)
  {
    ans1 = abs(x[0]) + abs(x[n - 1] - x[0]);
    ans2 = abs(x[n - 1]) + abs(x[n - 1] - x[0]);
  }
  else
  {
    for (i = 0; i <= n - k; ++i)
    {
      dist1[i] = abs(x[i]) + abs(x[i + k - 1] - x[i]);
      dist2[i] = abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]);
    }
    for (i = 0; i <= n - k; ++i)
    {
      ans1 = min(ans1, dist1[i]);
      ans2 = min(ans2, dist2[i]);
    }
  }
  cout << min(ans1, ans2) << "\n";
  return 0;
}

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

using namespace std;

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

  sort(A.begin(), A.end());
  int numUnique = unique(A.begin(), A.end()) - A.begin();
  int numDuplicated = N - numUnique;
  int numRemove = (numDuplicated % 2 == 0) ? numDuplicated : numDuplicated + 1;
  int numRemain = N - numRemove;
  printf("%d\n", numRemain);

  return 0;
}


Measured memory_bytes: 640