akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int yakusu(int n){
    int s = 0;
    FOR(i, 1, n + 1){
        if(n % i == 0) s++;
    }
    return s;
}

signed main(){

    int N;
    cin >> N;

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

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b;
	cin >> a >> b;
	cout << (a+b)/2 + TO((a+b)%2==1,1,0) << endl;
}


Measured memory_bytes: 256
while n = gets.to_i
  break if n == 0
  day = 31.times.map{ [] }
  res = -1
  n.times do |i|
    gets.split.map(&:to_i)[1..-1].each{ |d| day[d] <<i }
  end
  pce = n.times.map{ |i| 1<<i }
  day.each_with_index do |d, i|
    cur = 0
    pce.each_with_index{ |p, i| cur |= p if d.include?(i) }
    if cur == (1<<n) - 1
      res = i
      break
    end
    pce.each_with_index{ |p, i| pce[i] = cur if d.include?(i) }
  end
  p res
end

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
 
int main() {
  int A = 0, N, Z, a;
  cin >> N;
  int B[N];
  for (int i = 0; i < N; i++) {
	  cin >> B[i];
  }
  N -= 1;
  for (int s = 0; s < N ; s++) {
    Z = 0;
    a = s + 1;
    if (A < N - s) {
    for (int x = s;B[x] >= B[a] && x < N; x++) {
      Z++;
      a++;
    }
    if (A < Z) {
     A = Z; 
    }
    }
  }
  cout << A;
  return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(a-c) <= d)||(abs(a-b) <= d && abs(b-c)<=d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int H,W;

	while(1)
	{


	cin >> H >> W;
    if (H == 0 && W == 0)break;
	for (int i = 0; i < H; i++)
	{
		for(int j = 0; j < W; j++)
		{
			cout << '#';
		}
	cout << endl;
	}
	cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string.h>
#include <stack>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    rep(x,0,N+1){
        rep(y, 0, N+1){
            int tmp = N - R*x - G*y;
            if(tmp >= 0 && tmp %B==0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int h,w;

  while(1){
    cin >> h >> w;
    if (h==0 && w==0){
      break;
    }
    for (int i=0; i < h; i++){
      for (int j=0; j < w; j++){
      cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
n = gets.to_i
array = gets.chomp.split(' ').map(&:to_i)
stack_array = [0]
array.each.with_index do |v, i|
  stack_array << stack_array[-1] + v
end
puts stack_array.group_by(&:itself).map { |_, v| v.count }.select { |c| c > 1 }.group_by(&:itself).map { |k, v| (k * (k - 1) / 2 * v.count)}.reduce(0, :+)


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

typedef long long ll;
typedef pair <int, int> pii;
const int maxn = 1e5 + 10;
bool vis[maxn];
int n, a1[maxn], a2[maxn];

struct node {
  int l, r;
} a[maxn];

inline int get(int x, node &p) {
  if (p.r < x) return x - p.r;
  if (x < p.l) return p.l - x;
  return 0;
}

ll solve1() {
  memset(vis, 0, sizeof vis);
  ll ans = 0;
  int pos = 0, cnt = 0, p1 = 1, p2 = 1;
  while (cnt < n) {
    while (p1 <= n && vis[a1[p1]]) p1++;
    if (p1 <= n) {
      int x = a1[p1];
      if (a[x].r < pos) {
        goto GG;
      }
      vis[x] = 1, cnt++;
      ans += max(0, a[x].l - pos);
      pos = max(pos, a[x].l);
    }
    GG :
    while (p2 <= n && vis[a2[p2]]) p2++;
    if (p2 <= n) {
      int x = a2[p2];
      if (a[x].l > pos) {
        continue;
      }
      vis[x] = 1, cnt++;
      ans += max(0, pos - a[x].r);
      pos = min(pos, a[x].r);
    }
  }
  ans += abs(pos);
  return ans;
}

ll solve2() {
  memset(vis, 0, sizeof vis);
  ll ans = 0;
  int pos = 0, cnt = 0, p1 = 1, p2 = 1;
  while (cnt < n) {
    while (p2 <= n && vis[a2[p2]]) p2++;
    if (p2 <= n) {
      int x = a2[p2];
      if (a[x].l > pos) {
        goto GG;
      }
      vis[x] = 1, cnt++;
      ans += max(0, pos - a[x].r);
      pos = min(pos, a[x].r);
    }
    GG :
    while (p1 <= n && vis[a1[p1]]) p1++;
    if (p1 <= n) {
      int x = a1[p1];
      if (a[x].r < pos) {
        continue;
      }
      vis[x] = 1, cnt++;
      ans += max(0, a[x].l - pos);
      pos = max(pos, a[x].l);
    }
  }
  ans += abs(pos);
  return ans;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    a1[i] = a2[i] = i;
    scanf("%d %d", &a[i].l, &a[i].r);
  }
  sort(a1 + 1, a1 + n + 1, [] (int x, int y) {
    return a[x].l > a[y].l;
  });
  sort(a2 + 1, a2 + n + 1, [] (int x, int y) {
    return a[x].r < a[y].r;
  });
  printf("%lld", max(solve1(), solve2()));
  return 0;
}

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

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
  ll A,B; cin>>A>>B;
  map<ll,int>a=prime_factor(A),b=prime_factor(B);
  
  map<ll,int>ab;
  
  for(auto p:a)
    ab[p.first]++;
  for(auto p:b)
    ab[p.first]++;
  
  ll res=1;
  
  for(auto p:ab){
    if(p.second==2)
      res++;
  }
  
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a, b, c, d;
  int temp1, temp2;
  int ans;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  temp1 = (a < c) ? c : a;
  temp2 = (b < d) ? b : d;
  if(temp1 > temp2){
    ans = 0;
  }else{
    ans = temp2 - temp1;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int i,ans,b,n;
  int a[20];
  int c[20];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&b);
    ans+=b;
  }
  for(i=0;i<n-1;i++){
    scanf("%d",&c[i]);
  }
  for(i=0;i<n-1;i++){
    if (a[i+1]-a[i]==1){
      ans+=c[a[i]-1];
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())
grid = []
for i in range(h):
    grid.append(input())
dp = [[-1 for i in range(w)] for i in range(h)]
for i in range(w):
    if grid[0][i]!='#':
        dp[0][i] = 1
    else:
        break
for i in range(h):
    if grid[i][0]!='#':
        dp[i][0] = 1
    else:
        break
mod = 10**9+7
for i in range(1, h):
    for j in range(1, w):
        if grid[i][j] == '#':
            continue
        if dp[i][j-1] == -1 and dp[i-1][j] == -1:
            continue
        elif dp[i-1][j] == -1:
            dp[i][j] = dp[i][j-1]
        elif dp[i][j-1] == -1:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod
print(max(dp[h-1][w-1], 0))

Measured memory_bytes: 44596
#include<stdio.h>
int main(void){
    int a,b,c,d,e,f;
    while(1){
    scanf("%d %d",&a,&b);
            if(a==0&&b==0)break;
    for(c=0;c<a;c++){
        for(d=0;d<b;d++){
            if(c%2==0){
            e=d%2;
            if(e==0){
            printf("#");
            }else{
                printf(".");
            }
        }else{
            f=d%2;
            if(f==0){
            printf(".");
            }else{
            printf("#");
            }
        }}printf("\n");
    }printf("\n");

    }

return 0;
}

Measured memory_bytes: 572
// Copyright 2020 yaito3014
#include <iostream>
#include <vector>
int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  for (auto& e : A) std::cin >> e;
  for (int i = K; i < N; ++i)
    std::cout << (A[i - K] < A[i] ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

int main(){

    double n,k;
    cin >> n >> k;

    vector<double> count(n + 1);

    double ans = 0.0;

    for(int i = 1; i <= n; i++){
        count[i] = ceil(log2(k / i));
        //cerr << count[i] << endl;
        count[i] = pow(0.5, max(count[i], 0.0));

        ans += count[i] / n;
    }

    cout << setprecision(12) << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
def main():
    n, m = map(int, input().split())
    p = (m+1)//2
    q = m//2
    l = 0
    r = 2*p-1
    for i in range(p):
        print(l+1, r+1)
        l += 1
        r -= 1
    l = 2*p
    r = l+2*q
    for i in range(q):
        print(l+1, r+1)
        l += 1
        r -= 1


main()


Measured memory_bytes: 9268
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  int count = 0;
  ans = 0;
  
  rep_s(i, 105, N+1){
    if (i%2==0) continue;
    int i_2=3, count= 1;
    while(i_2 <= i){
      if(i%i_2==0) count++;
      i_2+=2;
    }
    //cout <<"count: " << count << endl;
    if (count==8) {
      //cout << i << endl;
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main(){
    
    int r,c,n;
    cin >>r >>c;
    int views[r+1][c+1];
    //入力と横の合計
    for(int i =0;i<r;i++){
        int sum=0;
        for(int j =0;j<c;j++){
            
            cin >> n;
            views[i][j] =n;
            sum += n;
            if(j==c-1){
                views[i][c] = sum;
                //cout << sum << endl;
            }
        }
    }
    for(int j=0;j<=c;j++){
        int sum =0;        
        for(int i=0;i<r;i++){
            sum += views[i][j];
        }
        views[r][j] =sum;
    }
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j!=0)cout << " ";
            cout << views[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main(){
    ll h, n, a;
    cin >> h >> n;
    rep(i, n){
        cin >> a;
        h -= a;
    }

    if(h <= 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
     
    public class Main {
     
    	public static void main(String[] args) throws IOException, Exception{
    		BufferedReader st = new BufferedReader(new InputStreamReader(System.in));
    		int n = getInt(st);
    		long t = 0;
    		for (int i = 1;i<n;i++) {
    			t+=i;
    		}
    		System.out.println(t);
    	}
     
    	private static int getInt(BufferedReader st) throws Exception, IOException {
    		int num = Integer.parseInt(st.readLine());
    		return num;
    	}
    }

Measured memory_bytes: 20564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int A,B,X;
   cin>>A>>B>>X;
   if(X-A>B||X<A){
       cout<<"NO"<<endl;
   }
   else{
       cout<<"YES"<<endl;
   }
   
}

Measured memory_bytes: 3576
def main():
    s = input()
    k = int(input())
    ans = 0
    tyou = 500000000000000
    for v in s:
        if v == '1':
            ans += 1
        else:
            ans += tyou ** int(v)
        if ans >= k:
            print(v)
            exit()


if __name__ == '__main__':
    main()

Measured memory_bytes: 9072
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;

}


Measured memory_bytes: 256
n = gets.chomp.to_i
s = []
for i in 1..n do
    s.push(gets.chomp)
end

startB = 0
endA = 0
isBstart = false
wordBA = 0
cnt = 0
for i in 1..n do
    isBstart = false
    if s[i-1].match(/^B/)
        startB += 1
        isBstart = true
    end
    if s[i-1].match(/A$/)
        endA += 1
        if isBstart 
            wordBA += 1
        end
    end
    cnt += s[i-1].scan("AB").size
end

if startB == wordBA and endA == wordBA and wordBA > 0
    cnt += wordBA -1
else
    cnt += [startB,endA].min
end

p cnt

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str;
	cin>>str;
	if(str=="ABC")puts("ARC");
	else puts("ABC"); 
	return 0;
} 

Measured memory_bytes: 3568
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000


N,M = map(int,input().split())
L,R = [0 for i in range(M)],[0 for i in range(M)]
for i in range(M):
    L[i],R[i] = map(int,input().split())

ans_max = -1
ans_min = mod
for i in range(M):
    ans_max = max(ans_max,L[i])
    ans_min = min(ans_min,R[i])

ans = max(ans_min-ans_max+1,0)
print(ans)


Measured memory_bytes: 13512
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int n ;
    int cnt = 0;
    cin >> n;
    vector<int> v (n,0);
    for(int i ;i < n ;i++){
        cin >> v.at(i);
    }
    for (int i = 1; i< n-1 ;i++){
        if (((v.at(i) < v.at(i-1))&&(v.at(i) > v.at(i+1))) || ((v.at(i) > v.at(i-1))&&(v.at(i) < v.at(i+1)))){
            cnt += 1;
        }
    }
    cout << cnt << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n;
        cin>>n;
        int arr[n],brr[n];
        bool x = 0;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i]>>brr[i];
            if(i>=2)
            {
                if(arr[i]==brr[i] &&
                arr[i-1]==brr[i-1] && arr[i-2]==brr[i-2])
                {
                    x = 1;
                }
            }
        }
        if(x)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    return 0;
}


Measured memory_bytes: 3652
l, r = gets.chomp.split.map(&:to_i)

if r - l + 1 >= 2019
  ans = 0
else
  ans = 2019
  l.upto(r-1) do |p1|
    (p1+1).upto(r) do |p2|
      q = p1 * p2 % 2019
      ans = q if q < ans
    end
  end
end

puts ans

Measured memory_bytes: 1788
def main():
    n,m=map(int,input().split())
    s=input()
    
    route=[]
    i=n
    visited=n
    while True:
        if i-m<=0:
            route.append(i)
            break
        else:
            flag=False
            for j in range(i-m,visited):
                if flag:
                    break
                if s[j]=='0':
                    route.append(i-j)
                    visited=i-m
                    i=j
                    flag=True
            if flag:
                continue
            else:
                print(-1)
                exit()
    
    print(*route[::-1])
if __name__=='__main__':
    main()



Measured memory_bytes: 6372
#include<bits/stdc++.h>
namespace imzzy{
	#define endl '\n'
	#define ccf std::cout<<"f**k"<<endl
	#define rgi register int
	#define ll long long
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL);
	#endif
}}using namespace imzzy;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=2004,maxm=27;
const ll mod=201010091201201201ll,inf=1201201201;

int n,m;
std::vector<int>e[maxn];
int dfs(int p,int f,int dep=m/2) {
	if(dep<0) return 0;
	int res=1;
	for(rgi i=0;i<e[p].size();++i) if(e[p][i]!=f)
		res+=dfs(e[p][i],p,dep-1);
	return res;
}
signed main()
{P_INIT();
	// freopen("yy.in","r",stdin);
	// freopen("yy.out","w",stdout);
	int u,v;
	fin>>n>>m;
	for(rgi i=1;i<n;++i) fin>>u>>v,e[u].push_back(v),e[v].push_back(u);
	int ans=inf;
	if(m%2==0)
		for(rgi i=1;i<=n;++i) ans=std::min(ans,n-dfs(i,i));
	else
		for(rgi i=1;i<=n;++i) for(rgi j=0;j<e[i].size();++j)
			ans=std::min(ans,n-dfs(i,e[i][j])-dfs(e[i][j],i));
	fout<<ans;
	return 0;
}
// ----------------------------
// by imzzy

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  string s;
  cin >> s;
  int n = s.size();
  ll ans = 0;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') ++cnt;
    if (s[i] == 'W') ans += cnt;
  }
  cout << ans << '\n';
}



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

int main(){
    int N;
    cin >> N;
    set<int> nums;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        nums.insert(A);
    }
    cout << N - (N - nums.size() + 1) / 2 * 2 << endl;
}


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

int main()
{
    int H, W;
    string A;
    cin >> H >> W;
    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
  cout<<endl;
    for (int i = 0; i < H; i++)
    {
      cin >>A;
        cout << "#" << A << "#" << endl;
    }
    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
}


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

typedef long long ll;
typedef unsigned long long ull;

#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(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  REP(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  REP(i, k) ans+= p[i];
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3664
s = input()
ans = [0 for _ in s]
odd = 0
even = 0
prev = None
for i, c in enumerate(s):
    if c == "L":
        if i%2:
            ans[i] += odd
            ans[i-1] += even
            odd, even = 0, 0
        else:
            ans[i] += even 
            ans[i-1] += odd
            odd, even = 0, 0
    if c == "R":
        if i%2:
            odd += 1
        else:
            even += 1
offset = len(ans)-1
for i, c in enumerate(s[::-1]):
    if c == "L":
        if i%2:
            odd += 1
        else:
            even += 1

    if c == "R":
        if i%2:
            ans[offset-i] += odd
            ans[offset-i+1] += even
            odd, even = 0, 0
        else:
            ans[offset-i] += even 
            ans[offset-i+1] += odd
            odd, even = 0, 0
print(" ".join([str(x) for x in ans]))



Measured memory_bytes: 10612
n=int(input())
s=input()
R=[0]*n
G=[0]*n
B=[0]*n
rcnt=0;gcnt=0;bcnt=0
ans=0
for i in range(n):
    if s[i]=="R":R[i]=R[i-1]+1;B[i]=B[i-1];G[i]=G[i-1];rcnt+=1
    elif s[i]=="G":G[i]=G[i-1]+1;R[i]=R[i-1];B[i]=B[i-1];gcnt+=1
    else:B[i]=B[i-1]+1;R[i]=R[i-1];G[i]=G[i-1];bcnt+=1
for i in range(n-1):
    for j in range(i+1,n):
        if s[i]==s[j]:continue
        if "R"!=s[i] and "R"!=s[j]:
            if 2*j-i>=n:
                ans+=rcnt-R[j]
            else:
                ans+=rcnt-R[j]
                if s[2*j-i]=="R":ans-=1
        elif "B"!=s[i] and "B"!=s[j]:
            if 2*j-i>=n:
                ans+=bcnt-B[j]
            else:
                ans+=bcnt-B[j]
                if s[2*j-i]=="B":ans-=1
        else:
            if 2*j-i>=n:
                ans+=gcnt-G[j]
            else:
                ans+=gcnt-G[j]
                if s[2*j-i]=="G":ans-=1
print(ans)

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll dfs(vvl &dp,  vl &a, int i, int j) {
	if (dp[i][j] != -1)return dp[i][j];
	if (i == j)return dp[i][j] = 0;
	ll ret = INF * INF;
	ll sum = a[j + 1] - a[i];
	FOR(k, i, j) {
		ret = min(ret, dfs(dp, a, i, k) + dfs(dp, a, k + 1, j));
	}
	return dp[i][j] = ret + sum;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl v(n);
	REP(i, n)cin >> v[i];
	vl a(n + 1, 0);
	REP(i, n)a[i + 1] = a[i] + v[i];
	vvl dp(n, vl(n, -1));
	dfs(dp, a, 0, n - 1);
	cout << dp[0][n - 1] << endl;
}

Measured memory_bytes: 1536
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  def same(self, x, y):
    return self.find(x) == self.find(y)

def main():
    N = int(readline())

    X = []
    Y = []
    for i in range(N):
        x, y = map(int, readline().split())
        X.append([i,x])
        Y.append([i,y])
    X.sort(key=lambda x:x[1])
    Y.sort(key=lambda x:x[1])

    L = []
    for i in range(N-1):
        u, x1 = X[i]
        v, x2 = X[i+1]
        L.append([u,v,x2-x1])
        u, y1 = Y[i]
        v, y2 = Y[i+1]
        L.append([u,v,y2-y1])
    L.sort(key=lambda x:x[2])

    uf = UnionFind(N)
    ans = 0
    for i in range(2*(N-1)):
        u,v,w = L[i]
        if not uf.same(u,v):
            uf.union(u,v)
            ans += w

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 63664
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    {
        return false;
    }
    if(n<=3)
    {
        return true;
    }
    if(n%2==0 || n%3==0)
    {
        return false;
    }
    for(ll i=5; (i*i)<=n; i+=6)
    {
        if(n%i==0 || n%(i+2)==0)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y)
{
    return ((x%mod)*(P(y,mod-2,mod)%mod))%mod;
}
int main()
{
    FAST
    FO
    FI
    int x;
    IN x;
    for(int i=x; ;i++)
    {
        if(isPrime(i))
        {
            OUT i<<endl
            break;
        }
    }
    return 0;
}


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

unordered_map<long long int, long long int> pfum(long long int n) {
    unordered_map<long long int, long long int> res;
    for (long long int i = 2; i * i <= n; i++)
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    if (n != 1) res[n]++;
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<long long int> plist(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        unordered_map<long long int, long long int> t = pfum(i);
        for (auto itr = t.begin(); itr != t.end(); itr++) {
            pair<long long int, long long int> factor = (*itr);
            plist[factor.first] += factor.second;
        }
    }
    long long int ans = 0;
    // 75
    for (int i = 2; i <= n; i++) {
        if (plist[i] >= 74) {
            ans++;
        }
    }
    for (int i = 2; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            // 3*25
            if (plist[i] >= 2 && plist[j] >= 24) {
                ans++;
            }
            if (plist[j] >= 2 && plist[i] >= 24) {
                ans++;
            }
            // 5*15
            if (plist[i] >= 4 && plist[j] >= 14) {
                ans++;
            }
            if (plist[j] >= 4 && plist[i] >= 14) {
                ans++;
            }
        }
    }
    // 3*5*5
    for (int i = 2; i <= n - 2; i++) {
        for (int j = i + 1; j <= n - 1; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (plist[i] >= 2 && plist[j] >= 4 && plist[k] >= 4) {
                    ans++;
                }
                if (plist[k] >= 2 && plist[i] >= 4 && plist[j] >= 4) {
                    ans++;
                }
                if (plist[j] >= 2 && plist[k] >= 4 && plist[i] >= 4) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int days(int m)
{
    if(m == 2) return 28;
    else if(m == 4 || m == 6 || m == 9 || m == 11)
        return 30;
    else return 31;
}
int main()
{
    int x, y;
    cin >> x >> y;
    cout << (days(x) == days(y) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,j,N,M,c,ans=0,check,x;
  cin>>N>>M>>c;
  vector<int> b(M);
  for(i=0;i<M;i++)cin>>b[i];
  for(i=0;i<N;i++){
    check=0;
    for(j=0;j<M;j++){
      cin>>x;
      check+=b[j]*x;
      }
    if(check+c>0)ans++;
    }
  cout <<ans;
  }

Measured memory_bytes: 256
A, B, C = map(int,input().split())
s = 0 
for i in range(101):
    s += i
check = 0
for i in range(5051):
    if (A * i  - C ) % B == 0:
        check = 1

if check == 0:
    print('NO')
else:
    print('YES')



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define	INF	0x3f3f3f3f
#define	LL	long long
#define	MAXN	310
#define	mod	998244353
using namespace std;
int n, f[2][MAXN * MAXN / 2], sum, a[MAXN], ans;

template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

int mul(const int &x, const int &y){return 1ll * x * y % mod;}
int inc(const int &x, const int &y){return (x + y >= mod) ? (x + y - mod) : (x + y);}
void update(int &x, const int &y){x = (x + y >= mod) ? (x + y - mod) : (x + y);}
int dec(const int &x, const int &y){return (x - y < 0) ? (x - y + mod) : (x - y);}

int qpow(int a, int b){
	int ret = 1;
	while (b) {
		if (b & 1) ret = mul(ret, a);
		a = mul(a, a);
		b >>= 1;
	}
	return ret;
}

int main(){
	read(n);
	for (int i = 1; i <= n; ++i)
		read(a[i]), sum += a[i];
	int cur = 0, old = 1;
	f[cur][0] = 1;
	for (int i = 1; i <= n; ++i){
		swap(cur, old);
		memset(f[cur], 0, sizeof(f[cur]));
		for (int j = 0; j <= sum / 2; ++j){
			if (!f[old][j]) continue;
			int tmp = f[old][j];
			if (j + a[i] <= sum / 2) update(f[cur][j + a[i]], mul(tmp, 2));
			update(f[cur][j], tmp);
		}
		/*for (int j = 0; j <= sum / 2; ++j)
			printf("%d ", f[cur][j]);
		puts("");*/
	}
	for (int i = 0; i <= sum / 2; ++i)
		update(ans, f[cur][i]);
	//printf("%d\n\n", ans);
	ans = mul(ans, 3);
	ans = dec(qpow(3, n), ans);
	if (!(sum & 1)){
		memset(f, 0, sizeof(f));
		int cur = 0, old = 1;
		f[cur][0] = 1;
		for (int i = 1; i <= n; ++i){
			swap(cur, old);
			memset(f[cur], 0, sizeof(f[cur]));
			for (int j = 0; j <= sum / 2; ++j){
				if (!f[old][j]) continue;
				int tmp = f[old][j];
				if (j + a[i] <= sum / 2) update(f[cur][j + a[i]], tmp);
				update(f[cur][j], tmp);
			}
		}
		ans = inc(ans, mul(f[cur][sum / 2], 3));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const ll MAXN=1e5+10;
const ll INF=0x7fffffff;

int main()
{
	int n;
	cin>>n;
	int x,y;
	ll ans=0;
	for(int i=1;i<=n;i++){
		cin>>x>>y;
		ans+=y-x+1;
	}
	cout<<ans<<endl;
	return 0;
}	 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int x=in(),t=in();
	print(x-t>0?x-t:0);
	return 0;
}

Measured memory_bytes: 128
import heapq

def main():
    n, m, *ab = map(int, open(0).read().split())

    ab_dict = {}
    for a, b in zip(*[iter(ab)] * 2):
        if a > m:
            continue
        if a in ab_dict:
            ab_dict[a].append(-b)
        else:
            ab_dict[a] = [-b]

    cand = []
    ans = 0
    for day in range(1, m+1):
        if day in ab_dict:
            for cand_b in ab_dict[day]:
                heapq.heappush(cand, cand_b)
        if cand:
            ans += -heapq.heappop(cand)

    print(ans)
    return()

if __name__ == '__main__':
    main()


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int a, b, c, d, e, f; scan(a, b, c, d, e, f);
      double res = -1.0;
      Int resX = a, resY = 0;
      for(Int x1 = 0; x1 <= f; x1+=100*a) {
         for(Int x2 = 0; x2 <= f; x2+=100*b) {
            dumpll(x1, x2);
            if( x1 + x2 == 0 ) continue;
            Int dp[3200] = {};
            dp[0] = 1;
            for(Int i = 0; i <= 3100; ++i) {
               if( dp[i] == 1 ) dp[i+c] = 1, dp[i+d] = 1;
            }
            for(Int i = 0; i <= 3100; ++i) {
               if( i + x1 + x2 == 0 ) continue;
               if( not ( dp[i] == 1 ) ) continue;
               if( not ( i + (x1 + x2) <= f ) ) continue;
               if( not ( (x1 + x2) * e >= i * 100 ) ) continue;
               double t = (double)(100 * i) / (i + x1 + x2);
               if( res < t ) {
                  res = t;
                  resX = x1 + x2;
                  resY = i;
               }
            }
         }
      }
      printf("%ld %ld\n", resX + resY, resY);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const double PI=3.14159265358979323846;
int main() {
    int n,k;
    cin >> n >> k;
    vector <int> h(n);
    for(int i=0;i<n;++i) cin >> h[i];
    sort(h.begin(),h.end(),greater<int>());
    int i=0,cnt=0;
    while(h[i]>=k) {
        ++i;
        ++cnt;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int A[200005];

int S;
int X[200005];

signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>A[i];
        S+=A[i];
    }
    X[0]=S;
    for(int i=0;i<N;++i)X[0]-=2*A[2*i+1];
    for(int i=1;i<N;++i)X[i]=2*A[i-1]-X[i-1];
    for(int i=0;i<N;++i)cout<<X[i]<<endl;

}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;
//柱の並び方が美しい場合 YES を、そうでない場合 NO を 

int main(void) {
    int  A, B, C;
    cin  >> A >> B >> C;
    if ((B - A) == (C - B))
        cout << "YES\n";
    else
        cout << "NO\n";
    
    return 0;
}

Measured memory_bytes: 256
X = int(input())

if 400 <= X < 600:
    print(8)
else:
    if 600 <= X < 800:
        print(7)
    else:
        if 800 <= X <1000:
            print(6)
        else:
            if 1000 <= X < 1200:
                print(5)
            else:
                if 1200 <= X < 1400:
                    print(4)
                else:
                    if 1400 <= X < 1600:
                        print(3)
                    else:
                        if 1600 <= X < 1800:
                            print(2)
                        else:
                            print(1)


Measured memory_bytes: 9180
#include<iostream>

int main() {
	int n;
	std::cin >> n;

	if (n == 1) {
		std::cout << "Hello World" << std::endl;
		exit(0);
	}

	if (n == 2) {
		int a, b;
		std::cin >> a >> b;
		std::cout << a + b << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int mod2 = 998244353;
  const int N = 20005;
  const int INF = 1e16;
  const double PI = acos(-1);




int fun(int x,int k)
{
  return abs(x-k);
}


int32_t main()
{
       

    IOS




    int n,k;
    cin >> n >> k;


    if(n >= k)
    {
      n%=k;
      while(true)
    { 
      int x = fun(n,k);
      if(x < n)n = x;
      else break;
    }

    }
    else
    {
      if(n > k - n)n = k - n;

            while(true)
    { 
      int x = fun(n,k);
      if(x < n)n = x;
      else break;
    }

    }

    cout << n;

  return 0;
} 

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

int main() {
  int N;
  cin >> N;
  int A[N];
  int count = 0;
  int64_t sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    if(A[i] < 0) {
      A[i] *= -1;
      count++;
    }
    sum += A[i];
  }
  sort(A, A + N);
  if(count % 2 == 0) cout << sum << endl;
  else cout << sum - 2 * A[0] << endl;
}

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

using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto& it : v)
        cin >> it;
    sort(v.begin(), v.end());
    cout << v[n / 2] - v[n / 2 - 1] << endl;
    return 0;
}


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

main(){
  int x;
  cin>>x;
  vector<int>a(x);
  for(int i=0;i<x;i++){
    cin>>a.at(i);
  }




  sort(a.begin(),a.end());

  for(int j=0;j<x-1;j++){
    if(a.at(j)==a.at(j+1)){
      cout<<"NO"<<endl;
    return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 1024