akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    if (2 * C <= A && 2 * C <= B) {
        print(2 * C * max(X, Y));
    } else if (2 * C < A + B) {
        int ans = 2 * C * min(X, Y);
        if (X > Y) {
            ans += (2 * C <= A) ? 2 * C * (X - Y) : A * (X - Y);
        } else {
            ans += (2 * C <= B) ? 2 * C * (Y - X) : B * (Y - X);
        }

        print(ans);
    } else {
        print(A * X + B * Y);
    }
    
}


Measured memory_bytes: 3608
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007

int a,b,c,d;
int x=0,y=0,z=0,w=0;
int main(int argc, char const *argv[]) {

  int a[10]={0,0,0,0,0,0,0,0,0,0};
  for(int i=0; i<4; i++){
    int m; std::cin >> m;
    a[m]++;
  }
  if(a[1]==1 && a[4]==1 && a[7]==1 && a[9]==1)std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int W = scanner.nextInt();
		int H = scanner.nextInt();
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int r = scanner.nextInt();
                if(0 <= x -r && x + r <= W && 0 <= y - r && y + r <= H)
		{
  			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}
		


Measured memory_bytes: 26364
K, N = map(int, input().split())
A = list(map(int, input().split()))

#0と最後
max_ = [0, K+A[0]-A[-1]]

#iとi+1
for i in range(1, N):
    tmp = A[i] - A[i-1]
    if tmp > max_[1]:
        max_[0] = i
        max_[1] = tmp
print(K-max_[1])

Measured memory_bytes: 32232
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

int main() {
    int64 n;
    cin >> n;
    vector<int64> t(n);
    for (int i=0; i<n; i++) cin>>t[i];
    int64 ans = 1;

    for (int i=0; i<n; i++)
        ans = lcm(ans, t[i]);

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

string s, t;
ll n, m, cur = -1, ans;
map<char, vi> pos;

int main() {
	fastio; cin >> s >> t;
	n = s.length(), m = t.length();
	FOR(i, 0, n-1) pos[s[i]].pb(i);
	FOR(i, 0, m-1) {
		#define v pos[t[i]]
		if (v.empty()) {
			cout << -1;
			return 0;
		}
		auto it = upper_bound(all(v), cur);
		if (it != v.end()) cur = *it;
		else cur = v[0], ans += n;
	}
	cout << ans + cur + 1;
}


Measured memory_bytes: 4696
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int N,P;
    string S;
    cin>>N>>P;
    cin>>S;
    ll ans=0;
    if(P==2){
        rep(i,N){
            if((S[i]-'0')%2 == 0) ans += (i+1);
        }
    }else if(P==5){
        rep(i,N){
            if(S[i]=='0' || S[i] == '5') ans+=(i+1);
        }
    }else{
        int ten_pow=1;
        int val;
        int sums[200000];
        rep(i,N){
            val = S[N-1-i]-'0';
            val = (val * ten_pow)%P;
            ten_pow = (ten_pow*10)%P;
            if(i==0) sums[i] = val;
            else sums[i] = (sums[i-1]+val)%P;
        }
        map<int,ll> hoge;
        hoge[0] = 1;
        rep(i,N) hoge[sums[i]] += 1;
        // rep(i,N)cout<<sums[i]<<" ";
        rep(i,N){
            // if(hoge[sums[i]]!=0) cout<<sums[i]<<" "<<hoge[sums[i]]<<endl;
            ans += (hoge[sums[i]]*(hoge[sums[i]]-1))/2;
            hoge[sums[i]]=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int 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);
    }
}

int main()
{
	int a = inputValue();
	string s;
	cin >> s;
	if(a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;
}


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

string table = "abcdefghijklmnopqrstuvwxyz";

string ToAlphabet(ll self)
{
  if (self <= 0)
    return "";
  ll n = self % 26;
  n = (n == 0) ? 26 : n;
  string s = {table[n-1]};
  if (self == n)
    return s;
  return ToAlphabet((self - n) / 26) + s;
}

int main()
{
  ll n;
  cin >> n;
  string ans = ToAlphabet(n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, M;
    scan(N, M);

    auto PS = new Tuple!(long, string)[](M);
    foreach (i; 0 .. M)
    {
        long p;
        string s;
        scan(p, s);
        p--;
        PS[i] = Tuple!(long, string)(p, s);
    }

    auto ac = new bool[](N);
    auto wa = new long[](N);
    foreach (Tuple!(long, string) t; PS)
    {
        if (t[1] == "AC")
        {
            ac[t[0]] = true;
            continue;
        }
        if (t[1] == "WA" && !ac[t[0]])
        {
            wa[t[0]]++;
        }
    }
    long[2] ans;
    ans[0] = ac.sum();
    ans[1] = zip(ac, wa).map!"a[0]?a[1]:0".sum();
    arywrite(ans[]);
}


Measured memory_bytes: 15328
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    for(int i = 0; i < s.length() - 1; i++) {
      if(s.charAt(i) != s.charAt(i + 1)) ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 39352
import java.io.*;
public class Main {
	 public static void main(String[] args)throws IOException {
		 BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		 while(true)
		 {
			 String str=input.readLine();
			 if(str.equals("-"))break;
			 int n=Integer.parseInt(input.readLine());
			 for(int i=0;i<n;i++){
				 int h=Integer.parseInt(input.readLine());
				 str=str.substring(h,str.length())+str.substring(0,h);
			 }
			 System.out.println(str);
		 }
	 }
}


Measured memory_bytes: 24376
sum = 0
num = [0] * (10 ** 5 + 1)
N = int(input())
A = [int(a) for a in input().split()]
for i in range(0, N):
    sum += A[i]
    num[A[i]] += 1

Q = int(input())
for i in range(0, Q):
    B, C = (int(x) for x in input().split())
    sum += (C - B) * num[B]
    num[C] += num[B]
    num[B] = 0
    print(sum)

Measured memory_bytes: 21300
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

void printArray(vector<int> v){
    rep(i, v.size()){
        if(i) cout << " ";
        cout<< v[i];
    }
    cout << endl;
}

void print2dArray(vector<vector<int> > vv){
    rep(i, vv.size()){
        rep(j, vv[i].size()){
            if(j) cout << " ";
            cout << vv[i][j];
        }
        cout << endl;
    }
}

//--global--//


/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    cin >> n;
    const int n_max = 200001;
    int a[n_max];

    //cout << n_max << endl;
    rep(i, n){
        cin >> a[i];
    }

    vector<int> v;
    int now = 1;
    rep(i, n){
        if(a[i] == now){
            now++;
            v.push_back(now);
        }
    }

    if(v.empty()){
        cout << -1 << endl;
        return 0;
    }

    cout << n - v.size() << endl;
    
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(a==13&&b==1){
		p("Bob");
	}
	else if(a==1&&b==13){
		p("Alice");
	}
	else if(a>b){
		p("Alice");
	}
	else if(a<b){
		p("Bob");
	}
	else p("Draw");

	return 0;
}



Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,a,b] <- getIntList
    xs <- getIntList
    print . sum $ zipWith (\x y -> min (a * (y-x)) b) xs (tail xs)

Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int main(){
    
    int a[12],go =0,na=0;
    for(int i=0;i<3;i++) cin>>a[i];
    for(int i=0;i<3;i++){
        if(a[i]==5) go++;
        if(a[i]==7) na++;
    }
    if(go == 2 && na == 1) cout <<"YES";
    else cout << "NO";
}

Measured memory_bytes: 256
N = int(input())
footing = list(map(int, input().split()))


dp = [10 ** 10] * N
dp[0] = 0

# give
'''
for i in range(N-1):
    if dp[i+1] > dp[i] + abs(footing[i+1] - footing[i]):
        dp[i+1] = dp[i] + abs(footing[i+1] - footing[i])

    if i < N-2:
        if dp[i+2] > dp[i] + abs(footing[i+2] - footing[i]):
            dp[i+2] = dp[i] + abs(footing[i+2] - footing[i])

print(dp[N-1])
'''
# get

for i in range(1,N):
    if dp[i] > dp[i-1] + abs(footing[i]-footing[i-1]):
        dp[i] = dp[i-1] + abs(footing[i]-footing[i-1]) 

    if i > 1:
        if dp[i] > dp[i-2] + abs(footing[i]-footing[i-2]):
            dp[i] = dp[i-2] + abs(footing[i]-footing[i-2]) 

print(dp[N-1])

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

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

	string s, t;
	cin >> s >> t;
	int n = s.length(), m = t.length();
	vector<vector<int>> dp(n + 1, vector<int>(m + 1));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}
	string ans;
	int cur = dp[n][m];
	for(int i = n; i >= 1; i--) {
		for(int j = m; j >= 1; j--) {
			if(dp[i - 1][j - 1] == cur - 1 && s[i - 1] == t[j - 1]) {
				ans += s[i - 1];
				cur--;
				break;
			}
		}
	}
	cout << string(ans.rbegin(), ans.rend()) << endl;
	return 0;	
}

Measured memory_bytes: 35584
#include<stdio.h>
#include<math.h>
const double hRAD=0.00872664625997164773718584029893463593907654285431L;
signed main(void)
{
  int A,B,H,M;
  if(~scanf("%d %d %d %d",&A,&B,&H,&M))
  {
    double theta=(60*H-11*M)*hRAD,x=A-B*cos(theta),y=B*sin(theta);
    return printf("%.20f",sqrt(x*x+y*y)),0;
  }
}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

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

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 500005;

int N, Q;
char S[MX];
int t[4*MX];

void build(char a[], int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = pow(2, a[tl] - 97);
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = (t[v*2] | t[v*2+1]);
    }
}

int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return (sum(v*2, tl, tm, l, min(r, tm))
            | sum(v*2+1, tm+1, tr, max(l, tm+1), r));
}

void update(int v, int tl, int tr, int pos, char new_val) {
    if (tl == tr) {
        t[v] = pow(2, new_val - 97);
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = (t[v*2] | t[v*2+1]);
    }
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i, N) cin >> S[i];
    build(S, 1, 0, N - 1);    
    // F0R(i, 4*N) cout << t[i] << " ";
    // cout << "\n";
    cin >> Q;
    while(Q--) {
        int type; cin >> type;
        if (type == 1) {
            int index; char c;
            cin >> index >> c; index--;
            update(1 , 0, N - 1, index, c);
            // F0R(i, 4*N) cout << t[i] << " ";
        } else {
            int a, b; cin >> a >> b;
            a--; b--;
            ll totalCnt = sum(1, 0, N - 1, a, b);
            // cout << totalCnt << "\n";
            int sum = 0;
            F0R(bits, 26) if ((1 << bits) & totalCnt) sum++;
            cout << sum << "\n";
        }
    }
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


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

using namespace std;

int main(){
int N,D; cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> X[i][j];}}
  int ans = 0;
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N ; j++){
      //i番目の組みとj番目の組みについて調べる
      int length2 = 0;
      for(int k = 0; k < D; k++){
        length2 += (int)pow( X[i][k] - X[j][k],2.0);}
      int l = (int) sqrt((double) length2);
      if( l * l == length2){ ans++;} 
    }}
  
  cout << ans << endl; return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
long long mod = 1000000007;
 
long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}
 
void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
 
int main() {
    int n, m, k, sum = 0;
    cin >> n;
    if (n == 1){
        cout << 1 << endl;
        return 0;
    }
    for (int i = 1; i <= n; i++){
        sum += i;
        if (sum > n){
            k = i;
            break;
        }
    }
    for (int i = 1; i <= k; i++){
        if(i == sum - n){
            continue;
        }else{
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll jo(ll a, ll b) {
  ll t = 1;
  for(ll i = 0; i < b; i++) {
    t *= a;
  }
  
  return t;
}

ll score(vector<ll> &p, vector<ll> &c, ll &D, ll &G, ll &x, vector<ll> &ss) {
  for(ll y = 0; y < x; y++) {
    ll Gg = G;
    //cout << y << ":y" << endl;
    ll z = y;
    ll s = 0;
    ll sum = 0;
    vector<ll> count(D);
    for(ll i = 0; i < D; i++) {
      count.at(i) = z % 2;
      z /= 2;
      //cout << count.at(i) << "count" << y << endl;
    }
    
    for(ll i = 0; i < D; i++) {
      if(count.at(i) == 1) {
        s += p.at(i);
        sum += (100 * (i + 1) * p.at(i) + c.at(i));
      }
      
    }
    Gg -= sum;
    if(sum < G) {
      ll a = 0, b = 101;
      for(ll i = 0; i < D; i++) {
        if(count.at(i) == 0 && Gg <= 100 * (i + 1) * p.at(i) + c.at(i)) {
          if(Gg / (100 * (i + 1)) + 1 <= p.at(i)) {
            a = Gg / (100 * (i + 1));
            if(Gg % (100 * (i + 1)) != 0) {
              a += 1;
            }
            
          }
          
          else{
            a = p.at(i);
          }
          
          if(a < b) {
            b = a;
          }
          
        }
        
      } 
      
      if(b != 101) {
        s += b;
      }
      
      if(b == 101) {
        s = 0;
      }
    
    }
    
    ss.at(y) = s;
    //cout << ss.at(y) << "ss" << y << endl;
    if(y == (x - 1)) {
      sort(ss.begin(), ss.end());
      for(ll i = 0; i < ss.size(); i++) {
        if(ss.at(i) > 0) {
          return ss.at(i);
        }
        
      }
    }
    
  }
}

int main() {
  ll D, G;
  cin >> D >> G;
  //cout << D << G << endl;
  vector<ll> p(D), c(D);
  for(ll i = 0; i < D; i++) {
    cin >> p.at(i) >> c.at(i);
    //cout << i << p.at(i) << c.at(i) << endl;
  }
  vector<ll> ss(jo(2, D), 0);
  ll x = jo(2, D);
  cout << score(p, c, D, G, x, ss) << endl;
  
}


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

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[n];
        nums[0]=sc.nextInt();
        for(int i=1;i<n;i++){
            nums[i]=nums[i-1]+sc.nextInt();
        }
        int ans=Integer.MAX_VALUE;
        for(int i=0;i<n;i++){
            ans=Math.min(ans,Math.abs(nums[n-1]-nums[i]*2));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N, K, Q; 
    cin >> N >> K >> Q;
    vector<int> A(Q);
    for(int i = 0; i < Q; i++) cin >> A[i];
    vector<int> point(N, K - Q);
    for(int a : A) point[a - 1]++;
    for(int p : point){
        if(p <= 0) puts("No");
        else puts("Yes");
    }

}

Measured memory_bytes: 4028
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string a,b,c;
  cin >> a >> b >> c;

  string ans;

  ans.append(1,a[0]);
  ans.append(1,b[0]);
  ans.append(1,c[0]);

  ans = upper(ans);

  cout << ans << endl;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }

  return str;
}

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

int main()
{
    //system("chcp 65001");

    long long A,B;

    cin >> A >> B;

    if(A % 2 != B % 2)
    {
        cout << "IMPOSSIBLE";
    }
    else
    {
        cout << (A + B) / 2;
    }
    

    return 0;
}
//解説見た

Measured memory_bytes: 256
#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;
    int a[n+1];
    int b[n];
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];

    ll tot = 0;
    rep(i,n) {
        int dmg1 = min(a[i], b[i]);
        a[i] -= dmg1;
        b[i] -= dmg1;
        tot += dmg1;

        int dmg2 = min(a[i+1], b[i]);
        a[i+1] -= dmg2;
        tot += dmg2;
    }

    cout << tot << endl;
    return 0;
}


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

int main(){

    int N;
    cin >> N;

    if( N == 1 ) cout << "Hello World" << endl;
    else if( N == 2 ){
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }

    return 0;

}

Measured memory_bytes: 256
import itertools
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

X = list(itertools.permutations(range(1,n+1)))

a=None
b=None
for i, x in enumerate(X):
    if list(x) == p:
        a=i
        
    if list(x) == q:
        b=i
        
print(abs(a-b))  

Measured memory_bytes: 13852
#include <iostream>

using namespace std;

int main(){
	int A, B;
	int sum = 0;

	cin >> A >> B;

	sum = A + B;

	switch(sum){
	case 3:
		cout << 3 << endl;
		break;
	case 5:
		cout << 1 << endl;
		break;
	case 4:
		cout << 2 << endl;
		break;
	default:
		break;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
import math

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = INT()
    x0 = 0
    y0 = 0
    x1 = 10**9
    y1 = 1
    if S % 10**9 == 0:
        y2 = S // 10**9
        x2 = 0
    else:
        y2 = S // 10**9 + 1
        x2 = 10**9 - S % 10**9
    X = [x0, y0, x1, y1, x2, y2]
    print(*X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38432
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

double calcDist(pdd p1, pdd p2){
    double diff_x = p1.first - p2.first;
    double diff_y = p1.second - p2.second;

    diff_x *= diff_x;
    diff_y *= diff_y;

    return sqrt(diff_x + diff_y);
}

double calcFac(ll n){
    if(n == 1)return 1.0;
    return n*calcFac(n-1);
}

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

    vector<pdd> pos(n);
    rep(i, n)cin >> pos[i].first >> pos[i].second;

    vector<ll> ary(n);
    iota(ALL(ary), 0);

    double ans = 0.0;
    
   do{
        rep(i, n-1){
            ans += calcDist(pos[ary[i]], pos[ary[i+1]]);
        }
    }while(next_permutation(ALL(ary)));

    ans /= calcFac(n);

    printf("%.9f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll T, X;
  cin >> T >> X;

  printf("%.15lf\n", (double) T / X);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 2000010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


struct UF {
	vector<int> par, ran;
	void init(int n) {
		par.resize(n); ran.resize(n);
		for(int i = 0; i < n; i++) {
			par[i] = i;
			ran[i] = 0;
		}
	}
	UF(int mx = 0) { init(mx); }

	int find(int x) {
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(ran[x] < ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if(ran[x] == ran[y]) ran[x]++;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
};
int N, Q;
int A[MAX_N];
int ans[MAX_N];
int parval[MAX_N];

UF uf;

void solve() {
	cin >> N;
	rep(i, 0, N - 1) cin >> A[i];
	uf.init(2000000 + 1);

	int prev = 0;
	rer(i, N - 1, 2) {
		int nv = A[i];
		for(int j = 1; j <= nv; j++) {
			uf.unite(prev + nv - j, prev + nv + j);
		}
		prev += nv;
	}
	rep(i, 0, 1000000 + 1) {
		parval[uf.find(prev + i)] = i;
	}
	rep(i, 0, prev + 1) {
		ans[i] = parval[uf.find(i)];
	}
	cin >> Q;
	while(Q--) {
		int x; cin >> x;
		if(prev <= x) cout << A[0] - A[1] + x - prev << "\n";
		else cout << A[0] - A[1] + ans[x] << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 32128
def a_colorful_subsequence(N, S):
    from collections import Counter
    from functools import reduce
    from operator import mul
    return (reduce(mul, map(lambda x: x + 1, Counter(S).values())) - 1) % (10**9 + 7)

N = int(input())
S = input()
print(a_colorful_subsequence(N, S))

Measured memory_bytes: 3692
#include<iostream>
int main(){
 int r,g,b;
 std::cin>>r>>g>>b;
 r=g*10+b;
 if(r%4==0){
  std::cout<<"YES"<<std::endl;
 }
 else if(r%4!=0){
  std::cout<<"NO"<<std::endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
//=============================
void input()
{
    cin>>N>>K;

}
//=============================
void func(){}
//=============================
void solve()
{
    cout<<N-K+1<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        #define REP(i, n) for(int i = 0;i < n;i++)
        using namespace std;
        int main()
        {
        int n;
        cin>>n; int cnt=1;
        vector<int> h(n,0);
        REP(i,n)
        {
            cin >> h[i];
        }
            int d=h[0];
        for(int i=0; i<n-1; i++)
        {
           d=max(d,h[i]);
           if(d<=h[i+1]) ++cnt;
        }
        cout<<cnt<<endl;
        }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 111
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX],mx,vis[MAX];
void Out(){puts("Impossible");exit(0);}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)mx=max(mx,a[i]=read());
	for(int i=1;i<=n;++i)vis[a[i]]++;
	if(mx&1)
	{
		for(int i=mx-mx/2;i<=mx;++i)if((vis[i]-=2)<0)Out();
		for(int i=mx-mx/2;i;--i)if(vis[i])Out();
	}
	else
	{
		if(!vis[mx/2])Out();vis[mx/2]-=1;
		for(int i=mx/2+1;i<=mx;++i)if((vis[i]-=2)<0)Out();
		for(int i=mx/2;i;--i)if(vis[i])Out();
	}
	puts("Possible");
	return 0;
}


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

using namespace std;
const int inf = 1e9 + 7;
const int N = 1e6 + 1;
vector <int> gr[N];
signed main () {
    int n, k;
    cin >> n >> k;

    vector <pair <int, int> > e;

    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        gr[x].push_back(y);
        gr[y].push_back(x);
        e.push_back({x, y});
    }

    int ans = inf;

    for (int i = 0; i < n && k % 2 == 0; i++) {
        vector <int> d(n, inf); queue <int> q; vector <int> used(n, 0);
        d[i] = 0; used[i] = true;q.push(i);
        while (!q.empty()) {
            int cur = q.front(); q.pop();
            for (auto it : gr[cur]) {
                d[it] = min(d[it], d[cur] + 1);
                if (!used[it]) {used[it] = true; q.push(it);}
            }
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) if (d[i] > k / 2) cnt++;
        ans = min(ans, cnt);
    }
    for (int i = 0; i < n - 1 && k % 2; i++) {
        int x = e[i].first, y = e[i].second;
        vector <int> d(n, inf); queue <int> q; vector <char> used(n, 0);
        d[x] = d[y] = 0; used[x] = used[y] = true; q.push(x);q.push(y);
        while (!q.empty()) {
            int cur = q.front(); q.pop();
            for (auto it : gr[cur]) {
                d[it] = min(d[it], d[cur] + 1);
                if (!used[it]) {used[it] = true; q.push(it);}
            }
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) if (d[i] > k / 2) cnt++;
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
}


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

using namespace std;

#define int long long
#define forn(i,n) for(int i = 0; i <(int)n; ++i)
const int MOD = 1000000007; // opsi : 998244353, 1000000007,

int32_t main()
{
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    if(c <= 'Z') cout << "A\n";
    else cout << "a\n";
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>

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

  // p is short for price, n is short for number
  // n_cakes * p_cakes + n_doughnuts * p_doughnuts = N
  const int p_cakes = 4, p_doughnuts = 7;

  bool found = false;
  for (int n_cakes = 0; n_cakes <= (N / 4); n_cakes++)
    for (int n_doughnuts = 0; n_doughnuts <= (N / 7); n_doughnuts++)
      if (p_cakes * n_cakes + p_doughnuts * n_doughnuts == N) found = true;

  if (found)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,x[SZ],y[SZ],id[SZ];
bool cmpx(int a,int b)
{
	return x[a]<x[b];
}
bool cmpy(int a,int b)
{
	return y[a]<y[b];
}
int dis(int a,int b)
{
	return min(abs(x[a]-x[b]),abs(y[a]-y[b]));
}
int dis(pii x)
{
	return dis(x.fi,x.se);
}
pii ps[SZ];
bool cmp(pii a,pii b)
{
	return dis(a)<dis(b);
}
int ff[SZ];
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",x+i,y+i);
		id[i]=i;
	}
	int g=0;
	sort(id+1,id+1+n,cmpx);
	for(int i=2;i<=n;i++)
		ps[++g]=pii(id[i-1],id[i]);
	sort(id+1,id+1+n,cmpy);
	for(int i=2;i<=n;i++)
		ps[++g]=pii(id[i-1],id[i]);
	sort(ps+1,ps+1+g,cmp);
	ll ans=0;
	for(int i=1;i<=g;i++)
	{
		int a=ps[i].fi,b=ps[i].se,c=dis(ps[i]);
		int ga=gf(a),gb=gf(b);
		if(ga==gb) continue;
		ff[ga]=gb; ans+=c;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 13056
#include <iostream>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::max;

// Number of points as white. Area [(0,0)..(2K,2K)]
int plane[2'010][2'010];
// cumulative[x][y] := Number of points in [(0,0)..(x,y))
int cumulative[2'010][2'010];

/* Return number of points in
 * [(lx,ly)..(hx..hy))
 * lx/ly: low x/y
 * hx/hy: high x/y
 */
int query(int lx, int ly, int hx, int hy) {
	if(lx > hx || ly > hy) return 0;
	return cumulative[hx][hy]
			- cumulative[lx][hy]
			- cumulative[hx][ly]
			+ cumulative[lx][ly];
}

int main() {
	// Input
	int N;
	int K;
	cin >> N >> K;
	const int k2 = 2 * K;
	// ... and Preparation
	for(int i = 0; i < N; ++i) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if(c == 'B') x += K;
		x %= k2;
		y %= k2;
		++plane[x][y];
	}
	// Preparation
	for(int x = 1; x <= k2; ++x) {
	for(int y = 1; y <= k2; ++y) {
		cumulative[x][y] = cumulative[x-1][y]
							+ cumulative[x][y-1]
							- cumulative[x-1][y-1]
							+ plane[x-1][y-1];
	}
	}
	// Calculation
	int ans = 0;
	for(int x = 0; x <= K; ++x) {
	for(int y = 0; y <= K; ++y) {
		// 0       x           x+K 2K
		// +---+---+---+---+---+---+ 0
		// |/A/|///|   |   |   |/B/|
		// +---+---+---+---+---+---+ y
		// |   |   |/D/|///|///|   |
		// +---+---+---+---+---+---+
		// |   |   |///|///|///|   |
		// +---+---+---+---+---+---+
		// |   |   |///|///|///|   |
		// +---+---+---+---+---+---+ y+K
		// |/C/|///|   |   |   |/E/|
		// +---+---+---+---+---+---+
		// |///|///|   |   |   |///|
		// +---+---+---+---+---+---+ 2K
		int a = query(0,   0,   x,   y);
		int b = query(x+K, 0,   k2,  y);
		int c = query(0,   y+K, x,   k2);
		int d = query(x,   y,   x+K, y+K);
		int e = query(x+K, y+K, k2,  k2);
		int w = a + b + c + d + e;
		ans = max(ans, max(w, N-w));
	}
	}
	// Output
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 31744
package main

import "fmt"

var (
	d, g int
	p, c []int
	cpt  []bool
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func dfs(i int) int {
	if i < len(cpt) {
		cpt[i] = true
		x := dfs(i + 1)
		cpt[i] = false
		y := dfs(i + 1)
		return min(x, y)
	}

	cnt, total := 0, 0
	for i := 0; i < d; i++ {
		if cpt[i] {
			total += (i+1)*100*p[i] + c[i]
			cnt += p[i]
		}
	}
	if total >= g {
		return cnt
	}

	maxB, maxP := 0, 0
	for i := 0; i < d; i++ {
		if !cpt[i] {
			if b := (i + 1) * 100; b > maxB {
				maxB = b
				maxP = p[i]
			}
		}
	}
	n := (g - total + maxB - 1) / maxB
	if n >= maxP {
		return 10000
	}
	return cnt + n
}

func main() {
	fmt.Scan(&d, &g)

	p = make([]int, d)
	c = make([]int, d)
	for i := 0; i < d; i++ {
		fmt.Scan(&p[i], &c[i])
	}

	cpt = make([]bool, d)
	fmt.Println(dfs(0))
}


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    int x = 800 * n, y = 200 * (n / 15);
    cout << x - y << endl; 

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#include<math.h>
#include<string.h>
int main()
{
    long long int ch[100000];
    char arr[1000000];
    char kh,bh,ag[100];
    int cp[400000]= {0};
    int a,b,c,d,e=0,g,i=0,tep=0,temp=0,j=0,k=0,l=0,m=0,n=0;
    scanf("%d %d",&a,&b);
    j=0;
    if(b%2==0)
    {
        if(2*a<=b && 4*a>=b)
            printf("Yes\n");
        else
            printf("No\n");

    }
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String inputed[] = new String[2];

		try {
			inputed = br.readLine().split("\\s+");
			int N = Integer.parseInt(inputed[0]);
			int M = Integer.parseInt(inputed[1]);

			UnionFind unionTree = new UnionFind(N);
			unionTree.init();

			for(int loop = 0; loop < M; loop++){
				inputed = br.readLine().split("\\s+");
				unionTree.unite(Integer.parseInt(inputed[0]),Integer.parseInt(inputed[1]));
			}

			int Q = Integer.parseInt(br.readLine());

			StringBuilder ans = new StringBuilder();

			for(int loop = 0; loop < Q; loop++){
				inputed = br.readLine().split("\\s+");
				if(unionTree.is_same(Integer.parseInt(inputed[0]),Integer.parseInt(inputed[1]))){
					ans.append("yes\n");
				}else{
					ans.append("no\n");
				}
			}

			System.out.print(ans.toString());

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class UnionFind{
	private int boss[];
	private int height[];
	private int size;

	UnionFind(int size){
		boss = new int[size];
		height = new int[size];
		this.size = size;
	}

	public void init(){
		for(int i = 0; i < size; i++){
			boss[i] = i;
			height[i] = 0;
		}
	}

	public int get_boss(int id){
		if(boss[id] == id)return id;
		else{
			return boss[id] = get_boss(boss[id]);
		}
	}

	public boolean is_same(int x,int y){
		return get_boss(x) == get_boss(y);
	}

	void unite(int x,int y){
		int boss_x = get_boss(x);
		int boss_y = get_boss(y);

		if(boss_x == boss_y)return;

		if(height[x] > height[y]){

			boss[boss_y] = boss_x;

		}else if(height[x] < height[y]){

			boss[boss_x] = boss_y;

		}else{ //height[x] == height[y]

			boss[boss_y] = boss_x;
			height[x]++;
		}
	}
}




Measured memory_bytes: 71692
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
long long yk(long long a,long long b){
	long long tmp;
  //cout<<1<<endl;
	while(b){
            a%=b;
            tmp=b;
            b=a;
            a=tmp;
        }
		return a;
}
int main(){
	long long n,x;
	long long tmp,ans;
	cin>>n>>x;
	vector<long long> city;
	city.push_back(x); 
	for(int i=0;i<n;i++){
		cin>>tmp;
		city.push_back(tmp);
	}
	sort(city.begin(),city.end());
	vector<long long> sa;
	for(int i=1;i<=n;i++){
		sa.push_back(city[i]-city[i-1]);
      //cout<<sa[0]<<endl;
	}
	for(int i=0;i<n;i++){
		ans=yk(sa[i+1],sa[i]);
		sa[i+1]=ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6644
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int small=200000,big=0;
  int size=s.size();
  for(int i=0;i<size;i++){
    if(s.at(i)=='A'){
      small=min(small,i);
    }
    if(s.at(size-i-1)=='Z'){
      big=max(big,size-i-1);
    }
  }
    cout<<big-small+1<<endl;
  }

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

#define pb push_back

using namespace std;

int data[20][20],n;
long long dp[1<<16];
vector<int> rem[17];

void generate(int bitmask,int lv)
{
  if (lv==n)
  {
    rem[__builtin_popcount(bitmask)].pb(bitmask);
    for(int c=0;c<n;c++)
    {
      if (bitmask&(1<<c))
      for(int c2=c+1;c2<n;c2++)
      {
        if (bitmask&(1<<c2))
        dp[bitmask]+=data[c][c2];
      }
    }
  }
  else
  {
    generate(bitmask,lv+1);
    generate(bitmask|(1<<lv),lv+1);
  }
}

int main()
{
  scanf("%d",&n);
  for(int c=0;c<n;c++)
  for(int c2=0;c2<n;c2++)
  scanf("%d",&data[c][c2]);
  generate(0,0);
  // for(int c=0;c<1<<n;c++)
  // {
  //   char tmp[100];
  //
  //   itoa(c,tmp,2);
  //   printf("%0*s %lld\n",n,tmp,dp[c]);
  // }
  for(int c=1;c<=n;c++)
  {
    for(int c2=0;c2<rem[c].size();c2++)
    {
      for(int c3=ceil((double)c/2);c3<c;c3++)
      {
        for(int c4=0;c4<rem[c3].size();c4++)
        {
          if ((rem[c][c2]|rem[c3][c4])==rem[c][c2])
          dp[rem[c][c2]]=max(dp[rem[c][c2]],dp[rem[c3][c4]]+dp[rem[c][c2]^rem[c3][c4]]);
        }
      }
    }
  }
  printf("%lld\n",dp[(1<<n)-1]);
}
/*
generate 2^16 score if they in same group
for 1->16 (1 bit of 1 -> 16 bit of 1)
foreach find minimum of sub 2 group
eg 1 bit -> not do anything
   2 bit -> get from some 1 bit + 1 bit that not intercept
   3 bit -> get from some 1 bit + 2 bit that not intercept

000 001 010 100  011 101 110 111
  0   0   0   0 -100  20  10 -90

0000 1000 0100 0010 0001 1100 1010 1001 0110 0101 0011 1110 1101 1011 0111 1111
   0    0    0    0    0   1M   1M   1M   1M   1M   -1   3M   3M 2M-1 2M-1 1M+2M+2M-1
*/


Measured memory_bytes: 1152
#include<iostream>

using namespace std;

int main() {
	long long n, i, res = 0;

	cin >> n;

	for (i = 1; i <= n; i++) {
		bool fb = true;
		if (i % 3 == 0)fb = false;
		if (i % 5 == 0)fb = false;

		if (fb)res += i;
	}

	cout << res;
	return 0;
}


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

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

int c[101][101];
int t[101][101];

int main() {
    while(true) {
        int n, m;
        cin >> n >> m;
        if(!n && !m) break;

        rep(i, 101) {
            rep(j, 101) {
                c[i][j] = t[i][j] = (i != j ? 1e9 : 0);
            }
        }

        rep(i, n) {
            int a, b, cost, time;
            cin >> a >> b >> cost >> time;
            a--; b--;
            c[a][b] = c[b][a] = cost;
            t[a][b] = t[b][a] = time;
        }

        rep(i, m) {
            rep(j, m) {
                rep(k, m) {
                    c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
                    t[j][k] = min(t[j][k], t[j][i] + t[i][k]);
                }
            }
        }

        int k;
        cin >> k;
        rep(i, k) {
            int p, q, r;
            cin >> p >> q >> r;
            p--; q--;
            if(r) cout << t[p][q];
            else cout << c[p][q];
            cout << endl;
            //cout << (r == 0 ? c[p][q] : t[p][q]) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1240
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try {
	   		BufferedReader br = createBufferedReader();
	        String line = br.readLine();
	       	System.out.println(method(line));
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
	}

	private static String method(final String str) {
		if (str.equals("Sunny")) {
			return "Cloudy";
		} else if (str.equals("Cloudy")) {
			return "Rainy";
		} else if (str.equals("Rainy")) {
			return "Sunny";
		}
		return "";
	}

	// 以下問題問わずに共通部分
	// 標準入力の BufferedReader を返す.
	private static BufferedReader createBufferedReader() {
		InputStreamReader isr =new InputStreamReader(System.in);
	   	return new BufferedReader(isr);
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rng(i,a,b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define repd(i, n) for(ll i = (ll)(n)-1;i>=0;--i)
#define rngd(i,b,a) for(ll i = (ll)(b);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())

int main() {
  int ans=0;
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ans=a*x+b*y;
  int m=max(x,y);
  rep(i,2*m+1){
    int x1=(x-i/2>=0)?x-i/2:0;
    int y1=(y-i/2>=0)?y-i/2:0;
    ans=min(ans,a*x1+b*y1+c*(int)i);
    ++i;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256