akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
const ll mod=MOD;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  vl money(n+1);
  vector<P>p(n+1);
  money[0]=1000;
  p[0].first=0;
  p[0].second=0;
  rep(i,n){
    money[i+1]=max(p[i].first*a[i]+p[i].second,money[i]);
    P p1;
    p1.first=money[i]/a[i];
    p1.second=money[i]%a[i];
    p[i+1]=max(p1,p[i]);
  }
  cout<<money[n]<<endl;
}

Measured memory_bytes: 3660
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

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

    ll count = n / (a+b);
    ll rem = n % (a+b);
    cout << (count*a + min(a,rem));
}

Measured memory_bytes: 256
from collections import deque

n=int(input())
que=deque()

for i in range(n):
    command=list(map(str,input().split()))
    if command[0]=="0":
        if command[1]=="0":
            que.appendleft(int(command[2]))
        elif command[1]=="1":
            que.append(int(command[2]))
    elif command[0]=="1":
        print(que[int(command[1])])
    elif command[0]=="2":
        if command[1]=="0":
            que.popleft()
        elif command[1]=="1":
            que.pop()


Measured memory_bytes: 21908
n = int(input())
x = list(map(int, input().split()))

x.sort()

minD = 0
for x_i in x:
    minD += (x_i-1) ** 2
# print(minD)

for i in range(2, 101):
    nowD = 0
    for x_j in x:
        nowD += (abs(x_j-i)) ** 2
    minD = min(nowD, minD)
print(minD)

Measured memory_bytes: 3064
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n = readline() |> parseInt
  a = zeros(Int, n)
  a = readline() |> split |> parseArray

  b = falses(10^6)
  for i in 1:n
    b[a[i]] = true
  end
  for i in 1:10^6
    b[i] || continue
    for j in 2i:i:(10^6 ÷ i) * i
      b[j] = false
    end
  end
  sort!(a)
  for i in 1:n
    i > 1 && a[i] == a[i - 1] && (b[a[i]] = false)
  end
  ans = count(b)

  println(ans)
end

main()


Measured memory_bytes: 197224
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    vector<int> P(N);
    REP(i,N){cin>>P[i];}
    auto max=max_element(ALL(P));
    int sum=accumulate(ALL(P),0);
    cout<<sum-*max/2<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

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

typedef long long ll;

class path {
public:
  int t;
  ll c;
  int p;
};

class dinic {
public:
  int n;
  vector<path> p;
  vector<int>* v;
  int* l;
  int* o;
  dinic(int nw) {
    n = nw;
    v = new vector<int>[n];
    l = new int[n];
    o = new int[n];
  }
  void add(int from, int to, ll cap) {
    assert(from < n);
    assert(to < n);
    path w1, w2;
    w1.t = to;
    w1.c = cap;
    w1.p = p.size() + 1;
    v[from].push_back(p.size());
    w2.t = from;
    w2.c = 0;
    w2.p = p.size();
    v[to].push_back(p.size() + 1);
    p.push_back(w1);
    p.push_back(w2);
  }
  void dics(int from) {
    rep(i, n) {
      l[i] = inf;
    }
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;
    pq.push(make_pair(0, from));
    while(!pq.empty()) {
      int k = pq.top().first;
      int m = pq.top().second;
      pq.pop();
      if(l[m] > k) {
        l[m] = k;
        rep(i, v[m].size()) {
          int x = v[m][i];
          if(p[x].c > 0) {
            pq.push(make_pair(k + 1, p[x].t));
          }
        }
      }
    }
  }
  ll dfs(int now, int to, ll mi) {
    if(now == to) {
      return mi;
    }
    ll all = 0;
    while(o[now] < v[now].size()) {
      int x = v[now][o[now]];
      if(l[p[x].t] == l[now] + 1) {
        ll w = dfs(p[x].t, to, min(mi - all, p[x].c));
        p[x].c -= w;
        p[p[x].p].c += w;
        all += w;
        if(mi - all == 0) {
          break;
        }
      }
      o[now]++;
    }
    return all;
  }
  ll solve(int from, int to) {
    assert(from < n);
    assert(to < n);
    ll all = 0;
    while(1) {
      dics(from);
      rep(i, n) {
        o[i] = 0;
      }
      ll w = dfs(from, to, inf);
      all += w;
      if(w == 0) {
        break;
      }
    }
    return all;
  }
  ~dinic() {
    delete[] v;
    delete[] l;
    delete[] o;
  }
};

ll gcd(ll a, ll b) {
  if(a > b) {
    return gcd(b, a);
  }
  if(b % a == 0) {
    return a;
  }
  else {
    return gcd(b % a, a);
  }
}

ll nd[1000], md[1000];

int main() {
  while(1) {
    int n, m;
    scanf("%d%d",&n,&m);
    if(n == 0) {
      break;
    }
    rep(i, n) {
      scanf("%lld", nd + i);
    }
    rep(i, m) {
      scanf("%lld", md + i);
    }
    dinic s(2 + n + m);
    rep(i, n) {
      s.add(n + m, i, 1);
    }
    rep(i, m) {
      s.add(n + i, n + m + 1, 1);
    }
    rep(i, n) {
      rep(j, m) {
        if(gcd(nd[i], md[j]) > 1) {
          s.add(i, n + j, 1);
        }
      }
    }
    printf("%lld\n", s.solve(n + m, n + m + 1));
  }
}

Measured memory_bytes: 12596
h,w = map(int, input().split())
if h%3==0 or w%3==0:
  print(0)
else:
  d = v = 10**5
  for i in range(h//4,h//2+1):
    cur = [i*w,(h-i)*(w//2),(h-i)*(w-w//2)]
    d = min(max(cur)-min(cur),d)
  for j in range(w//4,w//2+1):
    cur = [j*h,(w-j)*(h//2),(w-j)*(h-h//2)]
    v = min(max(cur)-min(cur),v)
  print(min(h,w,d,v))

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
// Problem Specific Parameter:
const int inf=1<<28;

// Description: グラフの型定義(これは最小費用流)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
vector<edge> graph[100010];

//Appropriately Changed
inline void add_edge(int from,int to){ 
	graph[from].push_back({to});
	graph[to].push_back({from});
}

vector<int> node;

bool check(int v,int p,int d){
	if(node[v]!=-1 and node[v]%2!=d) return false;
	bool ret=true;
	for(auto &e:graph[v]){
		if(e.to==p) continue;
		ret&=check(e.to,v,d^1);
	}
	return ret;
}

using pii=pair<int,int>;
vector<pii> ret;

pii dfs(int v,int p){
	if(node[v]!=-1){
		chmax(ret[v].first,node[v]);
		chmin(ret[v].second,node[v]);
	}

	for(auto &e:graph[v]){
		if(e.to==p) continue;
		pii tmp=dfs(e.to,v);
		chmax(ret[v].first,tmp.first-1);
		chmin(ret[v].second,tmp.second+1);
	}

	return ret[v];
}

void rest(int v,int p,int d){
	if(node[v]==-1){		
		if(p==-1){
			node[v]=ret[v].first;
			if(node[v]%2!=d) node[v]++;
		}else{
			if(ret[v].first<= node[p]-1 and node[p]-1<= ret[v].second) node[v]=node[p]-1;
			if(ret[v].first<= node[p]+1 and node[p]+1<= ret[v].second) node[v]=node[p]+1;
		}
	}

	for(auto &e:graph[v]){
		if(e.to==p) continue;
		rest(e.to,v,d^1);
	}
	return;
}



int main(void){
	int n;
	scanf("%d",&n);

	rep(i,n-1){
		int a,b;
		scanf("%d%d",&a,&b);
		add_edge(a-1,b-1);
	}

	node.assign(n,-1);
	ret.assign(n,pii(-inf,inf));
	int k;
	scanf("%d",&k);
	rep(i,k){
		int v,p;
		scanf("%d%d",&v,&p);
		node[v-1]=p;
	}

	int ok=-1;
	rep(d,2) if(check(0,-1,d)) ok=d;

	dfs(0,-1);
	//rep(v,n) cout << ret[v].first << " " << ret[v].second << endl;
	rep(v,n) if(ret[v].first>ret[v].second) ok=-1;
	
	if(ok==-1){
		puts("No");
	}else{
		puts("Yes");
		rest(0,-1,ok);
		rep(v,n) printf("%d\n",node[v]);
	}
	return 0;
}

Measured memory_bytes: 13824
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int r = scn.nextInt();
		String ans = "AGC";
      	if(r<1200) ans = "ABC";
      	if(r>=1200 && r<2800) ans = "ARC";
      	System.out.println(ans);
	}
}

Measured memory_bytes: 35604
#include<iostream>
#include<map>

using namespace std;

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

    map<char, int> rgb_num;
    rgb_num['R'] = 0;
    rgb_num['G'] = 0;
    rgb_num['B'] = 0;
    for(int i = 0; i < n; i++) {
        rgb_num[s[i]]++;
    }

    int64_t ans = 0;
    int r_num = rgb_num['R'], g_num = rgb_num['G'], b_num = rgb_num['B'];
    map<char, int> through_rgb_num;
    through_rgb_num['R'] = 0;
    through_rgb_num['G'] = 0;
    through_rgb_num['B'] = 0;
    int through_r_num, through_g_num, through_b_num;
    for(int i = 0; i < n - 2; i++) {
        char si = s[i];
        rgb_num[si]--;
        through_r_num = r_num - rgb_num['R'];
        through_g_num = g_num - rgb_num['G'];
        through_b_num = b_num - rgb_num['B'];
        for(int j = i + 1; j < n - 1; j++) {
            char sj = s[j];
            if(sj == 'R')      through_r_num++;
            else if(sj == 'G') through_g_num++;
            else               through_b_num++;
            
            if(sj == si) continue;
            
            char sk;
            if((si == 'R' && sj == 'G') || (si == 'G' && sj == 'R'))       sk = 'B';
            else if ((si == 'G' && sj == 'B') || (si == 'B' && sj == 'G')) sk = 'R';
            else                                                           sk = 'G';

            if(sk == 'R')      ans += r_num - through_r_num;
            else if(sk == 'G') ans += g_num - through_g_num;
            else               ans += b_num - through_b_num;

            //cout << "sk: " << sk << ", ans: " << ans << endl;

            if(2 * j - i < n) {
                if(s[2 * j - i] == sk) ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int  va, num;
    char p;

    int sum = 0, cnt = 0;
    double ave = 0;
    while( cin >> va >> p >> num )
    {
        sum += va * num;
        ave += num;
        cnt++;
    }

    cout << sum << endl;

    if( ave / cnt - (int)ave / cnt >= 0.5)
        ave = (int)ave / cnt + 1;
    else
        ave = (int)ave / cnt;
    
    cout << ave << endl;
    
    return 0;
}


Measured memory_bytes: 3188
w, h, n = map(int, input().split())


d = []
for _ in range(n):
  a = [int(i) for i in input().split()]
  d.append(a)



x1 = [0]
x2 = [w]
y1 = [0]
y2 = [h]

for i in range(n):
  if d[i][2] == 1:
    x1.append(d[i][0])
  if d[i][2] == 2:
    x2.append(d[i][0])
  if d[i][2] == 3:
    y1.append(d[i][1])
  if d[i][2] == 4:
    y2.append(d[i][1])

x1 = sorted(x1, reverse = True)[0]
x2 = sorted(x2)[0]
y1 = sorted(y1, reverse = True)[0]
y2 = sorted(y2)[0]

sum = (x2 - x1)*(y2 - y1)
if x2 - x1 >= 0 and y2 - y1 >= 0:
  print(sum)
else:
  print(0)


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

int countDivisors(int n) {
    int res = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res++;
            if (i != n / i) {
                res++;
            }
        }
    }
    return res;
}

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

    int res = 0;
    for (int i = 1; i <= N; i += 2) {
        if (countDivisors(i) == 8) {
            res++;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  int min,max;

  vector<int> li;
  int i = 1;
  
  cin >> a >> b;
  double f1 = 1.0 * a / b;
  cout << a/b << " " << a%b << " ";
  cout << std::fixed << std::setprecision(8) << f1 << endl;
}


Measured memory_bytes: 3252
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  string w;
  cin>>w;
  vl v(26);
  rep(i,w.size()){
    v[w[i]-'a']++;
  }
  rep(i,26){
  if(v[i]%2==1){
    print("No");return 0;
  }
  }
  print("Yes")
}

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

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

i64 a[3];
int main() {
  read_n(a, 3);
  set<i64> s;
  for (i64 x : a) s.insert(x);
  cout << s.size() << endl;
  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


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

  ll ok = 1000000000, ng = 0;
  while(abs(ok-ng) > 1) {
    ll mid = (ok+ng)/2;


    ll count = 0;

    rep(i, n) {
      if(a[i] <= mid) continue;
      count += (a[i]/mid);
      if(a[i]%mid == 0) --count;
    }

    if(count <= k) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}


Measured memory_bytes: 4756
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, W;
	cin >> N >> W;
	vector<int> weight(N), value(N);
	int sumvalue = 0;
	for (int i = 0; i < N; ++i) {
		cin >> weight[i] >> value[i];
		sumvalue += value[i];
	}
	vector<long long> dp(sumvalue + 1, -1);
	dp[0] = 0;
	sumvalue = 0;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		sumvalue += value[i];
		for (int j = sumvalue; j >= value[i]; --j) {
			if (dp[j - value[i]] != -1) {
				long long nxt = dp[j - value[i]] + weight[i];
				if (nxt <= W) ans = max(ans, j);
				dp[j] = (dp[j] == -1 || dp[j] > nxt ? nxt : dp[j]);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    char C;
    cin >> C;

    // output
    cout << (char)(C+1) << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
s = 0
d = {}
for k in C.keys():
    v = C[k]
    t = v*(v-1)//2
    s += t
    d[k] = t
for a in A:
    print(s-d[a]+((C[a]-1)*(C[a]-2)//2))


Measured memory_bytes: 96204
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;

int A[110];

int selection_sort(int a[], int n) {
    int cnt = 0;
    for(int i=0; i < n; ++i) {
        int minj = i;
        for(int j=i; j < n; ++j) {
            if(a[minj] > a[j]) {
                minj = j;
            }
        }
        swap(a[i], a[minj]);
        if(i != minj) ++cnt;
    }
    return cnt;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n; cin >> n;
    rep(i,n) cin >> A[i];

    int cnt = selection_sort(A,n);

    rep(i,n) {
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl << cnt << endl;

    return 0;
}



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

using namespace std;

int main(){
    long n;
    cin >> n;

    long tmp;
    long num=1;

    bool flg=false;

    for(long i=0; i<n; i++){
        cin >> tmp;
        if(tmp==0){
            cout << 0 << endl;
            return 0;
        }

        if(num >= LONG_MAX/tmp){
            flg = true;
        }
        num *=tmp;
        if(num > 1000000000000000000){
            flg = true;
        }

        
    }

    if(flg){
        cout << -1 << endl;
    }
    else{
        cout << num << endl;
    }

}

Measured memory_bytes: 3636
def main():
    x=int(input())
    flg = 1
    ans = 0
    if x == 2:
        print(2)
        return
    while flg == 1:
        if x % 2 == 0:
            x+=1
            continue
        else:
            flg=0
            for i in range(3,int(x**0.5)+1):
                if x % i == 0:
                    flg = 1
                    break
            if flg == 0:
                ans = x
                print(ans)
                return
            x+=1


if __name__=='__main__':
    main()


Measured memory_bytes: 38896
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   string s; cin >> s;
   if(s=="ABC"){
      cout << "ARC" << endl;
   }
   else{
      cout << "ABC" << endl;
   }
   return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <map>
#include <cmath>
typedef long long int ll;
using namespace std; 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n,m;cin>>n>>m;
	if(m==n){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0; i<n; i++)
        cin >> a[i];

    vector<vector<ll>> G(n);
    for(ll i=0; i<n-1; i++) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll l;
    {
        auto dfs = [&](auto dfs, ll cur, ll pre) -> void {
            if(G[cur].size() == 1) l = cur;
            for(auto &v: G[cur]) {
                if(v == pre) continue;
                dfs(dfs, v, cur);
            }
        };
        dfs(dfs, 0, -1);
    }

    bool ok = true;
    auto dfs = [&](auto dfs, ll cur, ll pre) -> ll {
        ll s = 0;
        vector<ll> sub;
        for(ll v: G[cur]) {
            if(v == pre) continue;
            ll r = dfs(dfs, v, cur);
            s += r;
            sub.push_back(r);
        }
        if(s == 0) return a[cur];

        ll x = s - a[cur];
        if(x < 0) ok = false;

        ll t = sub[0], v = 0;
        for(ll i=1; i<sub.size(); i++)
            v += min(t, sub[i]), t = abs(t - sub[i]);
        if(x > v) ok = false;
        return s - 2*x;
    };
    if(dfs(dfs, l, -1) == a[l] && ok)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


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

#define pb push_back
const int maxn = 10000;
const int INF = 0x3f3f3f3f;
int K, X;
vector<int> vec;

void solve()
{
	vec.push_back(X);
	for(int i = 1; i <= K-1; i++)
	{
		int a = X-i;
		int b = X+i;
		//cout << a << endl;
		//cout << b << endl;
		if(a >= -1000000) vec.push_back(X-i);
		if(b <= 1000000) vec.push_back(X+i);
	}
	sort(vec.begin(), vec.end());
	for(int i = 0; i < 2*K-1; i++) printf("%d ", vec[i]);
	printf("\n");
}

int main()
{
	cin >> K >> X;
	solve();
}

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

int main(){
    int n;
    scanf("%d",&n);
    int i;
    char s[n];
    scanf("%s",s);
    int max=0,num=0;
    for(i=0;i<=n-1;i++){
        if(s[i]=='I')num++;
        else num--;
        if(num>max)max=num;
    }
    printf("%d",max);
    return 0;
    
}

Measured memory_bytes: 128
import math

def function(items, item):
  num = sorted(items)
  num.reverse()
  return num.index(item)+1
   
n = int(input())
p = input().split()
p = [int(_) for _ in p]
q = input().split()
q = [int(_) for _ in q]

items = []
for i in range(n-1):
  items.append(math.factorial(n-i-1))

p_temp = []
for i in range(len(p)):
  p_temp.append((len(p[i:])+1) - function(p[i:], p[i]))

q_temp = []
for i in range(len(q)):
  q_temp.append((len(q[i:])+1) - function(q[i:], q[i]))


p_num = 0
for i in range(len(p)-1):
  t = p_temp[i]-1
  p_num += t*items[i]
  
q_num = 0
for i in range(len(q)-1):
  t = q_temp[i]-1
  q_num += t*items[i]

print(abs(p_num - q_num))



Measured memory_bytes: 3064
#include<stdio.h>

int main(){
		int i,ab[3][2],mati[5]={0};
		for(i=0;i<3;i++)scanf("%d%d",&ab[i][0],&ab[i][1]);
		for(i=0;i<3;i++){
				mati[ab[i][0]]++;
				mati[ab[i][1]]++;
		}
		for(i=1;i<5;i++){
				if(mati[i]==3){
						puts("NO");
						return 0;		
				}		
		}
		puts("YES");
		return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
    int N, L[15];
    int sum = 0;
    scanf("%d", &N);
    for (int c = 0; c < N;c++){
        scanf("%d", &L[c]);
    }
     qsort(L, N, sizeof(int), compare_int);
     
        for (int d = 0; d < N-1;d++){
         sum += L[d];
                }
                if (sum > L[N - 1] ){
                        printf("Yes");
                    }else{
                        printf("No");
                    }

                    return 0;
}

Measured memory_bytes: 128
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize};

    let mut v: Vec<Vec<i64>> = vec![vec![-1; 15]; 15];

    for i in 0..n {
        input! {a: usize};
        for _ in 0..a {
            input! {x: usize, y: i64};
            v[i][x - 1] = y;
        }
    }

    let mut ans = 0;

    for i in 0..1 << n {
        let mut d = vec![0; n];

        for j in 0..n {
            if i >> j & 1 == 1 {
                d[j] = 1;
            }
        }
        let mut ok = true;

        for j in 0..n {
            if d[j] == 1 {
                for k in 0..n {
                    if v[j][k] == -1 {
                        continue;
                    };

                    if v[j][k] != d[k] {
                        ok = false;
                    }
                }
            }
        }
        if ok {
            ans = std::cmp::max(ans, (i as i64).count_ones());
        }
    }

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


Measured memory_bytes: 2108
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>

typedef long long LL;
using namespace std;

#define MAXN 200005

char s[MAXN];

signed main() {
	int n, a, b, c, d;
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	scanf("%s", s);
	bool succ = true;
	a--;
	b--;
	c--;
	d--;
	for (int i = b; i < d; i++) {
		if (s[i] == '#'&&s[i + 1] == '#') succ = false;
	}
	for (int i = a; i < c; i++) {
		if (s[i] == '#'&&s[i + 1] == '#') succ = false;
	}
	if (d < c) {
		for (int i = b; i <= d; i++) {
			if (s[i - 1] == '.'&&s[i] == '.'&&s[i + 1] == '.') {
				goto L;
			}
		}
		succ = false;
	L:;
	}
	if (succ) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 384
from collections import deque

n = int(input())

def dfs(n):
  stack = deque()
  stack.append("a")
  while stack:
    q = stack.popleft()
    if len(q) == n:
      ans.append(q) 
    if len(q) < n:
      for i in range(ord("a"), ord(max(q)) + 2):
        stack.append(q + chr(i))
    
ans = []
dfs(n)

print("\n".join(ans))

Measured memory_bytes: 16312
#include <bits/stdc++.h>
using namespace std;
#define iinf 2000000000
#define linf 1000000000000000000LL
#define ulinf 10000000000000000000ull
#define MOD1 1000000007LL
#define mpr make_pair
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef unsigned short US;
typedef pair < int , int > pii;
clock_t __stt;
inline void TStart(){__stt=clock();}
inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);}
template < typename T > T MIN(T a,T b){return a<b?a:b;}
template < typename T > T MAX(T a,T b){return a>b?a:b;}
template < typename T > T ABS(T a){return a>0?a:(-a);}
template < typename T > void UMIN(T &a,T b){if(b<a) a=b;}
template < typename T > void UMAX(T &a,T b){if(b>a) a=b;}
LL A,B,C,K,S;
int main(){
    // inputting start
    // 数据结构记得初始化！ n，m别写反！
    cin>>A>>B>>C>>K;
    #ifdef LOCAL
        TStart();
    #endif
    // calculation start
    // 数据结构记得初始化！ n，m别写反！
	S=A+B+C;
    if(K&1LL){
		A=S-A;B=S-B;C=S-C;
		--K;
	}
	cout<<A-B;
	return 0;
	if(A==B){
		cout<<0;
		return 0;
	}
	A-=B;
	while(K--){
		if(ABS(A)>linf){
			printf("Unfair");
			return 0;
		}
		A*=2LL;
	}
	cout<<A;
    #ifdef LOCAL
        TReport();
    #endif
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    vector<int> X(5);
    for(int i=0; i<5; i++) cin >> X[i];

    for(int i=0; i<5; i++) {
        if(X[i] == 0) {
            printf("%d\n", i+1);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3660
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int n, a, b, p=0, q=0, r=0, s=0,t=0, sum=0,tmp;
	cin >> n >> a >> b;
	FOR(i, 1, n+1) {
		tmp = i;
		t = tmp / 10000;
		tmp %= 10000;
		p = tmp / 1000;
		tmp %= 1000;
		q = tmp / 100;
		tmp %= 100;
		r = tmp / 10;
		tmp %= 10;
		s = tmp;
		tmp = p + q + r + s+t;
		if (a <= tmp and tmp <= b) {
			sum += i;
		}
	}
	cout << sum << endl;
}


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

int main() {
	int N, K;
  	std::cin >> N >> K;
  
  	std::vector<int> data(N);
	for(int i = 0; i < K; ++i) {
    	int n;
      	std::cin >> n;
      	for(int j = 0; j < n; ++j) {
        	int idx;
          	std::cin >> idx;
          	++data[idx-1];
        }
    }
  
	std::cout << std::count(data.begin(), data.end(), 0) << std::endl;
}

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

int main() {
		string s;
		cin >> s;
		string s_reverse = s;
		reverse(s_reverse.begin(), s_reverse.end());
		int n = s.size();
		string t = s.substr(0, (n - 1) / 2);
		string t_reverse = t;
		reverse(t_reverse.begin(), t_reverse.end());
			bool flag = false;
		if (s == s_reverse && t == t_reverse)flag = true;
		if (flag)cout << "Yes" << endl;
		else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif


namespace Solver{
using namespace std;

struct Problem{
    int n,a,b;
    Problem(LL n):n(n){};

    void solve(){
        cin >>a >> b;
        if(abs(a-b)%2==1)cout << "Borys" << "\n";
        else cout << "Alice" <<"\n";
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Solver::Problem p(n);
    p.solve();
    return 0;
}



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

int main(){
    int x;
    cin >> x;
    int n;
    cin >> n;
    vector<int> p(102,0); //0~101まで用意
    for(int i=0; i<n; i++){
        int num;
        cin>>num;
        p[num]=1; //p[num]=1のとき数列pのなかにnumが存在
    }
    for(int i=0; i<1000; i++){ //p[0],p[101]で必ず終わるのでループ回数は十分に大きくしておけばよい
        if(p[x-i]==0){ //もしpのなかにx-iが存在しなかったら
            cout << x-i << endl;
            return 0;
        }
        if(p[x+i]==0){ //もしpのなかにx+iが存在しなかったら
            cout << x+i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int h1 = scanner.nextInt();
        int h2 = scanner.nextInt();
        int dp1 = 0;
        int dp2 = Math.abs(h2 - h1);
        for (int i = 2; i < n; i++) {
            int h3 = scanner.nextInt();
            int dp3 = Math.min(dp1 + Math.abs(h3 - h1), dp2 + Math.abs(h3 - h2));
            h1 = h2;
            h2 = h3;
            dp1 = dp2;
            dp2 = dp3;
        }
        System.out.println(dp2);
    }
}


Measured memory_bytes: 58688
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	if (N + M >= K) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return (0^_^0);
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
   string a;
   cin>>a;
   string b;
   b=a;
   reverse(b.begin(),b.end());
   if(a==b) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
 
   return 0;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int h[100001] = {0};

int main()
{
	int N = 0, K = 0, i = 0, ans = 0;
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i ++) {
		int hight = 0;
		scanf("%d", &hight);
		if (K <= hight) {
			ans++;
		}
	}
	printf("%d\n", ans);
    return 0;
}


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

int main(){
	int H,W,N;
	cin >> H >> W >> N;
	
	set<pair<int,int>> ab;
	for(int i=0;i<N;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		ab.insert(make_pair(a,b));
	}
	
	vector<long long> ans(10,0);
	
	set<pair<int,int>> visited;
	
	for(auto p:ab){
		int a=p.first,b=p.second;
		for(int x=a-2;x<=a;x++)for(int y=b-2;y<=b;y++){
			if(x<0 || H-3<x || y<0 || W-3<y)continue;
			if(visited.count(make_pair(x,y))==0){
				int c=0;
				for(int v=x;v<x+3;v++)for(int w=y;w<y+3;w++)c+=ab.count(make_pair(v,w));
				if(c>0)ans[c]++;
				visited.insert(make_pair(x,y));
			}
		}
	}
	
	ans[0]=(long long)(H-2)*(W-2)-accumulate(ans.begin(),ans.end(),0LL);
	for(int i=0;i<10;i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 47104
import java.util.*;
public class Main{

	
	  public static void main(String[] args)
	  {
	    Scanner sc=new Scanner(System.in);
	    int i=sc.nextInt();
	    int j=sc.nextInt();
	    int flag=0;
        if(j%2!=0)
        {
          System.out.println("No");
          return;
        }
	    if(i==1)
	    {
	    	if(j==4||j==2)
            {
	              System.out.print("Yes");
            }
	    }
	    else
	    {
	    for(int k=1;k<=i;k++)
	    {
	   
	      if(((k*2+(i-k)*4)==j)||((k*4+(i-k)*2)==j))
	      {
	        System.out.println("Yes");
	        flag=1;
	        break;
	      }  
	    } 
	    if(flag==0)
	    {
	      System.out.println("No");
	    }
	    }
	  }
	}  


Measured memory_bytes: 35760
n = int(input())
h = list(map(int, input().split()))
max1 = 0
count = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        count = 0
    if count > max1:
        max1 += 1
print(max1)

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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; ++i)
    cin >> A[i];
  cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end()) << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
p = gets.split.map(&:to_i)
hikaku = [*(1..n)]
cnt = 0
(0..(n-1)).each do |i|
  cnt += 1 if hikaku[i] != p[i]
end

if cnt == 0 || cnt == 2
  puts 'YES'
else
  puts 'NO'
end

Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
    int n,h,w,i,j;

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

  }
return 0;

}



Measured memory_bytes: 2060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    int x=a+b;
    int y=c+d;
    
    if(x>y){
        cout<<"Left";
    }else if(x==y){
        cout<<"Balanced";
    }else{
        cout<<"Right";
    }
    
    
}


Measured memory_bytes: 3024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

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

using namespace std;


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

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

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

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

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


int main(int argc, const char * argv[]) {
    long long N = inputValueLongLong();
    int i=0;
    int X[N];
    long sum = 0;
    for(i=0;i<N;i++){
        X[i] = inputValue();
        sum += X[i];
    }
    long fact = (double)sum / (double)N + 0.5;
    long ans=0;
    for(i=0;i<N;i++){
        ans += (X[i]-fact)*(X[i]-fact);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
  vector<int> c(5);
  while(~scanf("%d", &c[0])){
    int p = 0; int tc = 0;
    for(int i = 1; i < 5; i++) scanf(",%d", &c[i]);
    sort(c.begin(), c.end());
    for(int i = 0; i < 5; i++){
      if(i != 0 && c[i] == c[i-1])p++;
      if(i != 1 && c[i] == c[i-2])tc++;
    }
    if(p == 1) puts("one pair");
    else if(tc == 1 && p == 3)puts("full house");
    else if(tc && p == 2) puts("three card");
    else if(p == 2)  puts("two pair"); 
    else if(p == 3) puts("four card");
    else if(c[4] - c[0] == 4 || (c[0] == 1 && c[1] == 10 && c[4] == 13)) puts("straight");
    else puts("null");
  }
  return 0;
}

Measured memory_bytes: 1184
a = list(map(int,input().split()))
b = a[0]//a[1]
if a[1] % 2 != 0:
  print(b**3)
else:
  if a[0]%a[1] >= a[1]//2:
    print(b**3 + (b+1)**3)
  else:
    print(2*b**3)
  


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

int main(){
	int N, K;
	cin >> N >> K;
	int p[1010];
	
	for(int i=0;i<N;i++){
		cin >> p[i];
	}
	
	sort(p,p+N);
	
	int sum=0;
	for(int j=0;j<K;j++){
		sum=sum+p[j];
	}
	cout << sum << endl;
	return 0;
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def main():
    N, M = [int(x) for x in input().split()]

    d = make_divisors(M)
    ma = -1
    for i in d:
        if M // i >= N:
            ma = max(ma, i)

    print(ma)


    


if __name__ == '__main__':
    main()



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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> t(N + 1, 0), x(N + 1, 0), y(N + 1, 0);
    string ans = "Yes\n";
    rep(i, N) {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
        if (abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]) > t[i + 1] - t[i]) ans = "No\n";
        if ((x[i] + x[i + 1] + y[i] + y[i + 1] + t[i] + t[i + 1]) % 2) ans = "No\n";
    }
    cout << ans;
}

Measured memory_bytes: 1408
H,W,d=map(int, input().split())
A={}
B={}
M={}
for i in range(d):
  a,b=map(int, input().split())
  if a not in A:
    A[a]=1
  else:
    A[a]+=1
  if b not in B:
    B[b]=1
  else:
    B[b]+=1
  if (a,b) not in M:
    M[(a,b)]=1
  else:
    M[(a,b)]+=1
AA=sorted(A.items(), key=lambda x:x[1],reverse=True)
BB=sorted(B.items(), key=lambda x:x[1],reverse=True)
AAA,BBB=[],[]
maa=AA[0][1]
for x,y in AA:
  if maa>y:
    break
  else:
    AAA.append((x,y))
mab=BB[0][1]
for x,y in BB:
  if mab>y:
    break
  else:
    BBB.append((x,y))
ans=AAA[0][1]+BBB[0][1]
for a,cnta in AAA:
  for b,cntv in BBB:
    if (a,b) not in M:
      print(ans)
      exit()
print(ans-1)

Measured memory_bytes: 163192
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define reep(i,n) for(ll i = n; i >-1; i--)
#define deb(variable) cout<<#variable<<"="<<variable<<endl
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999999;
const ll MOD=128;
const ll MAX_N=500010;
ll a,b,c,d,e,x,y,z,k,m,n,l,q,ans=0;
vl v,vans,beki;
vp p[100010];
string s;
ll solve(void){
    if(m==1&&k==1)return -1;
    if(beki[m]-1<k)return -1;
    rep(i,beki[m]){
        vans.push_back(i);
    }
    rep(i,beki[m]){
        vans.push_back(beki[m]-i-1);
    }
    
    if(k>0){
    	if(k!=beki[m]-1){
        swap(vans[k],vans[beki[m]-1]);
        swap(vans[beki[m+1]-k-1],vans[beki[m]]);
    	}
        swap(vans[beki[m]-1],vans[beki[m+1]-1]);
    }

    rep(i,beki[m+1]){
        cout<<vans[i];
        if(i!=beki[m+1]-1)cout<<" ";
        else cout<<endl;
    }
    return 0;
}
int main(){
    cin>>m>>k;
    beki.push_back(1);
    rep(i,20){
        beki.push_back(beki.back()*2);
    }
    
  
    if(solve()==-1)cout<<-1<<endl;
}

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

using namespace std;

typedef long long ll;

ll n;
ll a[112123];
ll ans;

int main()
{
	cin >> n;
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	ll mp = 1;
	ans = max(0ll, a[0]-1);
	for (ll i = 1; i < n; i++)
	{
		if (a[i] <= mp + 1)
		{
			mp = max(mp, a[i]);
			continue;
		}
		ans += a[i] / (mp + 1);
		if (a[i] % (mp + 1) == 0) ans--;
	}
	cout << ans << '\n';
	return 0;
}



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

using namespace std;

#define int long long

const int N = 1e6 + 5, mod = 1e9 + 7;
int n, f[N];

main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  f[0] = 0, f[1] = n, f[2] = n * n % mod;
  int tot = 0;
  for(int i = 3; i <= n; ++i) {
    f[i] = (f[i - 1] + (n - 1) * (n - 1) % mod) % mod;
    f[i] = (f[i] + tot + n - i + 2) % mod;
    tot = (tot + f[i - 2]) % mod;

  }
  cout << f[n] << '\n';
}


Measured memory_bytes: 8064