akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A;
  cin >> A;
  int B;
  cin >> B;
  vector<int> C(A);
  int D;
  string E;
  vector<int> F(A);
  int G = 0;
  while(B > G){
    G = G + 1;
    cin >> D;
    cin >> E;
    if(F.at(D - 1) == 0){
      if(E == "AC"){
        F.at(D - 1) = 1;
      }
      else{
        C.at(D - 1) = C.at(D - 1) + 1;
      }
    }
  }
  D = 0;
  G = 0;
  B = 0;
  while(A > G){
    if(F.at(G) == 1){
      D = D + C.at(G);
      B = B + 1;
    }
    G = G + 1;
  }
  cout << B << endl;
  cout << D << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
 
#define ulli unsigned long long int
 
#define Pi 3.14159265358979323846264338327950288419716939937510
 
int main(){
 
	//ios :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	
	string s;
	
	cin>>s;
	
	if(s == "SUN"){
		
		cout<<"7";
	}
	
	else if(s == "MON"){
		
		cout<<"6";
	}
	
	else if(s == "TUE"){
		
		cout<<"5";
	}
	
	else if(s == "WED"){
		
		cout<<"4";
	}
	
	else if(s == "THU"){
		
		cout<<"3";
	}
	
	else if(s == "FRI"){
		
		cout<<"2";
	}
	
	else if(s == "SAT"){
		
		cout<<"1";
	}
}

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

int main(){
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	string divide[4] = {"maerd","remaerd","esare","resare"};
	rep(i,s.size()){
		bool ok = false;
		rep(j,4){
			if(s.substr(i, divide[j].size()) == divide[j]){
				ok = true;
				i += divide[j].size() - 1;
			}
		}
		if(!ok){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
template<typename T>
inline void read(T& s)
{
    s=0;int f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){s=s*10+c-'0';c=getchar();}
    s*=f;
}
int n,k;
int main()
{
	cin>>n>>k;
	if(k&1)
	{
		long long ans=n/k;
		ans=ans*ans*ans;
		cout<<ans<<endl;
		return 0;
	}
	long long ans=n/k;
	ans=ans*ans*ans;
	long long ans2=(n+(k/2))/k;
	ans2=ans2*ans2*ans2;
	cout<<ans+ans2<<endl;
    return 0;
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);

pvec a;
ll dp[2020][2020];
int n;

int rec(int l,int r){
    if(dp[l][r]!=-1) return dp[l][r];
    if(r-l<1) return dp[l][r]=0;
    
    int t=n-(r-l);
    int ret=max(rec(l+1,r)+a[t].fs*abs(l-a[t].sc),rec(l,r-1)+a[t].fs*abs(r-1-a[t].sc));
    return dp[l][r]=ret;
}

void solve()
{
    
    cin>>n;
    a.resize(n);
    rep(i,n) cin >> a[i].fs,a[i].sc=i;
    sort(rall(a));
    rep(i,2020) rep(j,2020) dp[i][j]=-1;

    ll ans=rec(0,n);
    cout<<ans<<endl;
    
}
//-----------------------------------------------------------------

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    int repeat = 1;
    //cin >> repeat;
    while(repeat--){
        solve();
    }

}

Measured memory_bytes: 39892
using System;
using System.Linq;

static class abc119a
{
    static bool IsTBD(int y, int m, int d)
    {
        if (y > 2019) return true;
        if (y < 2019) return false;

        System.Diagnostics.Debug.Assert(y == 2019);
        if (m > 4) return true;
        return false;
    }

    static void Main(string[] args)
    {
        var date = Console.ReadLine().Split('/').ToList().ConvertAll(int.Parse);
        System.Console.WriteLine(IsTBD(date[0], date[1], date[2]) ? "TBD" : "Heisei");
    }
}


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

int main()
{
    int N;
    vector<int> w;
    cin >> N;
    int ans = 100000;
    for (int i = 0; i < N; i++)
    {
        int n;
        cin >> n;
        w.push_back(n);
    }
    for (int i = 0; i < N; i++)
    {
        int sum1 = 0;
        int sum2 = 0;
        for (int j = 0; j < N; j++)
        {
            if (j <= i)
            {
                sum1 += w[j];
            }
            else
            {
                sum2 += w[j];
            }
        }
        if (abs(sum1 - sum2) < ans)
        {
            ans = abs(sum1 - sum2);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}
int N, T;
int dp1[3010][3010];
int dp2[3010][3010];
vector<int> A;
vector<int> B;
int main() {
    cin >> N >> T;

    rep(i, 0, N) {
        int a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }

    dp1[0][0] = 0;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= T - 1; j++) {
            dp1[i][j] = dp1[i - 1][j];
            if(j - A[i - 1] >= 0)
                dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - A[i - 1]] + B[i - 1]);
        }
    }
    dp2[N + 1][0] = 0;
    for(int i = N; i >= 1; i--) {
        for(int j = 0; j <= T - 1; j++) {
            dp2[i][j] = dp2[i + 1][j];
            if(j - A[i - 1] >= 0)
                dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - A[i - 1]] + B[i - 1]);
        }
    }
    int res = 0;
    rep(i, 0, N) {
        rep(j, 0, T - 1) {
            res = max(res, dp1[i][j] + dp2[i + 2][T - 1 - j] + B[i]);
        }
    }
    cout << res << endl;
}

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

typedef struct {
    int value;
    int weight;
    char type;
    long date;
    char name[21];
} Item;

int cmpitem(const void *i1, const void *i2)
{
    Item *item1 = (Item *)i1;
    Item *item2 = (Item *)i2;
    int diff = item1->value - item2->value;
    if (diff != 0) return diff;
    else {
        diff = item1->weight - item2->weight;
        if (diff != 0) return diff;
        else {
            diff = item1->type - item2->type;
            if (diff != 0) return diff;
            else {
                diff = item1->date - item2->date;
                if (diff != 0) return diff;
                else return strcmp(item1->name, item2->name);
            }
        }
    }
}

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

    Item *A = malloc(sizeof(Item) * n);
    int i;
    for (i = 0; i < n; i++)
        scanf("%d %d %c %ld %s", &(A[i].value), &(A[i].weight),
        &(A[i].type), &(A[i].date), A[i].name);

    qsort(A, n, sizeof(Item), cmpitem);

    for (i = 0; i < n; i++)
        printf("%d %d %c %ld %s\n",
        A[i].value, A[i].weight, A[i].type, A[i].date, A[i].name);

    free(A);

    return 0;
}


Measured memory_bytes: 7728
import sys
N, M = map(int, input().split())
PS = sys.stdin.read().strip().split()
ac, wa = [0] * N, [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w if a > 0 else 0 for a, w in zip(ac, wa))
print(sum(ac), penalties)

Measured memory_bytes: 18124
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        Map<Integer, ArrayList<Integer> > an = new HashMap<Integer, ArrayList<Integer> >();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (an.containsKey(a)) {
                ArrayList al = an.get(a);
                al.add(b);
                an.put(a, al);
            } else {
                ArrayList al = new ArrayList<>();
                al.add(b);
                an.put(a, al);
            }
        }

        for (int b : an.get(1)) {
            if (!an.containsKey(b)) {
                continue;
            }

            if (an.get(b).indexOf(n) != -1) {
                System.out.println("POSSIBLE");
                System.exit(0);
            }
        }

        System.out.println("IMPOSSIBLE");
    }

}

Measured memory_bytes: 129996
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

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

    int len = s.size();

    if (len <= k) {
        cout << s << endl;
    } else {
        string str = "";
        rep(i, k) {
            str += s[i];
        }
        str += "...";
        cout << str << endl;
    }
}

Measured memory_bytes: 3572
import 'dart:io';
 
void main(List<String> args) {
  List<int> x = stdin.readLineSync().split(" ").map((i) => int.parse(i)).toList();
  String ans = "No";
  for(int i=0; i<=x[0]; ++i){
    if(2*i+4*(x[0]-i) == x[1]) ans = "Yes";
  }
  print(ans);
}

Measured memory_bytes: 13064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int n;scanf("%d",&n);
    int a[n];for(int i=0;i<n;i++)scanf("%d",&a[i]);

    for(int i=n-1;i>=0;i-=2){
        printf("%d ",a[i]);
    }
    if(n%2){
        for(int i=1;i<n;i+=2){
            printf("%d ",a[i]);
        }
    }else{
        for(int i=0;i<n;i+=2){
            printf("%d ",a[i]);
        }
    }
    
    printf("\n");
}

Measured memory_bytes: 2816
#include<stdio.h>

int n, a[20];

int solve(int i,int m) {

	if(m==0)return 1;
	if(i>=n)return 0;
	int res = solve(i+1,m)||solve(i+1,m-a[i]);
	return res;
}

int main(void) {

	int q,m;
	scanf("%d",&n);
	for(int i=0; i<n; i++)scanf("%d",&a[i]);
	
	scanf("%d",&q);
	for(int i=0; i<q; i++) {
		scanf("%d",&m);
		if(solve(0,m)==1)printf("yes\n");
		else printf("no\n");
	}
	return 0;

}


Measured memory_bytes: 2144
using System;
using System.Linq;

namespace _2739
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool[] time = new bool[x[2]];
            for (int i = 0; i < x[2]; i++)
            {
                time[i] = true;
            }
            for (int i = 0; i < x[0]; i++)
            {
                for (int j = n[i] - x[1]; j < Math.Min(x[2], n[i] + x[1]); j++)
                {
                    time[j] = false;
                }
            }
            int ret = 0;
            for (int i = 0; i < x[2]; i++)
            {
                if (time[i]) ret++;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 9668
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%d", &n);
	char s[n + 1];
	char t[n + 1];
	scanf("%s %s", s, t);
	REP(i, n) {
		putchar(s[i]);
		putchar(t[i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    ll a[N];
    for(ll i = 0; i < N; i++) cin >> a[i];
    for(ll i = 0; i < N; i++){
        ll b = a[i] - 1;
        ll tmp = 0;
        for(ll j = 0; j < N; j++){
            ll g = gcd(a[i], a[j]);
            tmp += a[j] - g + b % g;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


def in_list():
    return (list(map(int, input().split())))


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))


n = in_int()

a = in_list()

av=  sum(a)//n

ans  = 0

p = 0
for xx in a:
    p += (xx-av)*(xx-av)

ans = p


p = 0
for xx in a:
    p += (xx-av-1)*(xx-av-1)


ans = min(ans, p)

print(ans)

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

int main() {
	// freopen("./input.txt", "r", stdin);
    ll K, A, B;
    cin >> K >> A >> B;

    if (A + 2 >= B || K <= A - 1) {
        cout << K + 1 << endl;
    } else {
        ll cnt = (K - A + 1) / 2;
        ll ans = cnt * B - (cnt - 1) * A;
        if ((K - A + 1) % 2 == 1) {
            ++ans;
        }
        cout << ans << endl;
    }
    
    
    
 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

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

  double a[n];
  double sum = 0;
  for(int i=0; i<n; ++i){
    cin >> a[i];
    a[i] = 1/a[i];
    sum += a[i];
  }

  double ans = 1/sum;
  cout << fixed << setprecision(10) << ans;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;

char in[120];
pair<pair<string, int>, int> p[110];
int main(){
    int a;scanf("%d",&a);
    for(int i=0;i<a;i++){
        int t;
        cin >> in >> t;
        string tmp=in;
        p[i]=make_pair(make_pair(in,-t),i);
    }
    std::sort(p,p+a);
    rep(i, a) out(p[i].second+1);
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
constexpr string join(const V &v, const string &sep) {
  stringstream ss;
  if (v.size()) ss << v[0];
  loop(i, 1, v.size()) ss << sep << v[i];
  return ss.str();
}

void solve() {
  int n;
  set<int> s;
  while (cin >> n) {
    while (n--) {
      int h, m;
      cin >> h >> m;
      s.insert(h * 60 + m);
    }
  }
  vs w;
  transform(all(s), back_inserter(w), [](int x) {
    stringstream ss;
    ss << x / 60 << ':' << setfill('0') << setw(2) << x % 60;
    return ss.str();
  });
  cout << join(w, " ") << endl;
}

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

using namespace std;

//folir'o
const int maxi =1e6+10;
#define pb push_back
#define pii pair<int,int>

int a[maxi];
int d,t,s;
vector<int> v[maxi];

int main()
{
    cin>>d>>t>>s;

    if (d<=t*s) return !printf("Yes\n");

    printf("No\n");

    return 0;
}


Measured memory_bytes: 27112
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
static const int MAX = 100;

int main(){
  int n,R[MAX],minj,v,a;

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> R[i];
  }

  for(int i = 0; i < n; i++){
    minj = i;
    for(int j = i; j < n; j++){
      if(R[j] < R[minj]){
        minj = j;
      }
    }
    if(minj != i){
      swap(R[i], R[minj]);
      a++;
    }
  }
  for(int i = 0; i < n; i++){
    if(i != n-1){
      cout << R[i] << " ";
    }else{
      cout << R[i] << endl;
    }
  }
  cout << a << endl;
  return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;

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

      ll x; cin >> x;
      ll cnt = 100;
      for(int i=1;;i++){
          cnt = cnt * 1.01;
          if(cnt>=x){
              cout << i << endl;
              return 0;
          }
      }

      return 0;
}


Measured memory_bytes: 3652
import math
x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
    position=x-k*d
else:
    kk=math.floor(x/d)
    position=x-kk*d
    if (k-kk)%2==1:
        position=abs(position-d)
print(abs(position))


Measured memory_bytes: 9176
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var hs = new HashSet<string>();
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        hs.Add(s);
        var hd = s[s.Length - 1];
        for (int i = 1; i < n; i++)
        {
            var w = Console.ReadLine().Trim();
            if (!hs.Add(w)) { Console.WriteLine("No"); goto end; }
            if (w[0] != hd) { Console.WriteLine("No"); goto end; }
            hd = w[w.Length - 1];
        }
        Console.WriteLine("Yes");
        end:;
    }
}


Measured memory_bytes: 13280
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll 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;
}

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

    ll res = 0;
    vector<ll> x_list = divisor(N);

    for(auto x: x_list){
        if(x == 1){
            continue;
        }
        if(N / (x-1) == N % (x-1)){
            res += x-1;
        }
    }

    cout << res << endl;




    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define isz(x) (int)(x).size()
using ll = long long;
int main() {
	for (ll a, b; std::cin >> a >> b; std::cout << a/std::__gcd(a,b)*b << std::endl);
}


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    string A;
    cin>>A;
    int N=A.size();
    vector<ll> cnt(26,0);
    vector<ll> dp(N+1,0);
    dp[0]=1;
    REP(i,N){
        dp[i+1]=dp[i];
        dp[i+1]+=(i-cnt[A[i]-'a']);
        cnt[A[i]-'a']++;
    }
    cout<<dp[N]<<endl;
    
}

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

long long myPow(long long x, long long y){
    long long z = 1;
    for(long long i=0; i<y; i++){
        z *= x;
    }
    return z;
}

int main(){
    long long N;
    cin >> N;
    string s;
    long long mod = N%2;
    long long x;
    if(mod != 0){
        s.push_back('1');
        x = 1;
    }else{
        s.push_back('0');
        x = 0;
    }
    for(int i=2;;i++){
        if(N == x){
            break;
        }
        mod = abs(N - x) % myPow(2, i);
        if(mod != 0){
            s.push_back('1');
            if(i%2 == 0){
                x -= myPow(2, i-1);
            }else{
                x += myPow(2, i-1);
            }
        }else{
            s.push_back('0');
        }
    }
    reverse(s.begin(), s.end());
    cout << s;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;

#define MOD 1000000007
#define A first
#define B second

typedef long long ll;

inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}

inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}

inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}

inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}

inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}

inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}

const int N = 1e5 + 5;

int arr[N];

void solve(){
  int n, b;
  cin >> b >> n;
  int s = 0;
  for(int i = 0; i < n; i++){
    cin >> arr[i];
    s += arr[i];
  }
  if(s >= b){
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}


int main(){
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  //cin >> t;
  t = 1;
  while(t--){
    solve();
  }
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000], d[200000];
signed main(){
  int n, m;
  scanf("%lld%lld", &n, &m);
  rep(i,m)scanf("%lld", &a[i]);
  sort(a, a+m);
  rep(i,m-1)d[i] = a[i+1]-a[i];
  sort(d, d+m-1);
  int sum = 0;
  rep(i,m-n)sum += d[i];
  printf("%lld\n", sum);
  // printf("%s\n", a[n-1] < sum ? "Yes" : "No");
  return 0;
}






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

using namespace std;

using ll =  long long;

constexpr int N_MAX = 100000;

int n, m;
vector<int> graph[N_MAX];
vector<int> lp(N_MAX, -1);

int dfs(int node) {
    int max_child_lp = -1;
    for(int child: graph[node]) {
        if(lp[child] != -1) {
            max_child_lp = max(max_child_lp, lp[child]);
        } else {
            max_child_lp = max(max_child_lp, dfs(child));
        }
    }

    return lp[node] = max_child_lp + 1;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> m;
    int x, y;
    for(int i=0;i<m;++i) {
        cin >> x >> y;
        --x; --y;
        graph[x].push_back(y);
    }

    int ans = 0;
    for(int i=0;i<n;++i) {
        if(lp[i] != -1) {
            ans = max(ans, lp[i]);
            continue;
        } else {
            ans = max(ans, dfs(i));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 8832
import math

N,D = list(map(int,input().split()))
list1 = []
all1 = 0
C = 0
for i in range(N):
    X = list(map(int,input().split()))
    list1.append(X)
for i in range(N):
    for j in range(i+1,N):
        a = list1[i]
        b = list1[j]
        for z in range(D):
            all1 = all1 + (a[z] - b[z])**2 
        if math.sqrt(all1).is_integer() :
            C = C + 1
        all1 = 0
print(C)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<vector<bool>> a(N, vector<bool>(N, false));
    bool able = false;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            char in;
            cin >> in;
            if(in == '#'){
                a[i][j] = true;
                able = true;
            }
        }
    }

    if(!able){
        cout << -1 << endl;
        return 0;
    }

    int c = 0;
    for(int j=0;j<N;j++){
        for(int i=0;i<N;i++){
            if(!a[i][j]){
                c++;
                break;
            }
        }
    }

    int ans = 100000000;
    for(int r=0;r<N;r++){
        bool has_black = false;
        for(int k=0;k<N;k++){
            if(a[k][r]){
                has_black = true;
            }
        }
        int x = 0;
        for(int k=0;k<N;k++){
            if(!a[r][k]){
                x++;
            }
        }
        ans = min(ans, c + x + (has_black ? 0 : 1));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a[3];
    int k;
    int max=0;
    int sum=0;
    for(int i=0;i<3;i++){
        scanf("%d",&a[i]);
    }
    scanf("%d",&k);
    for(int i=0;i<3;i++){
        sum=sum+a[i];
        if(max<=a[i]){
            max=a[i];
        }else{

        }
    }
    int x=sum-max;
    for(int i=1;i<=k;i++){
        max=max*2;
    }
    printf("%d\n",x+max);
}

Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n,k,s=MI()
    ans=[]
    if s==10**9:
        for i in range(k):
            ans.append(s)
        for i in range(n-k):
            ans.append(1)
    else:
        for i in range(k):
            ans.append(s)
        for i in range(n-k):
            ans.append(10**9)
    print(*ans)
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 84984
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    s = []
    while n!=0:
        if n<=26:
            s.append(n)
            n = 0
        else:
            x = n % 26
            if x==0:
                x = 26
            s.append(x)
            n = (n-1) // 26
    t = []
    for i in range(len(s)-1,-1,-1):
        t.append(chr(s[i]+96))
    print(''.join(t))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 61868
n, k = map(int, input().split())
p = [list(map(int, input().split())) for i in range(n)]
ans = float("inf")

p.sort()
for i in range(n-k+1):
    for j in range(i+k-1, n):
        x = p[j][0] - p[i][0]
        yl = sorted(p[i:j+1],key=lambda x:x[1])
        for l in range(len(yl)-k+1):
            y = yl[l+k-1][1] - yl[l][1]
            ans = min(ans, y*x)
print(ans)

Measured memory_bytes: 3188
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 10L^^16;
alias Edge = Tuple!(int, "from", int, "to", long, "cap", int, "rev");

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    auto adj = new Edge[][](n + 2);

    void addEdge(int u, int v, long cap) {
        adj[u] ~= Edge(u, v, cap, adj[v].length.to!int);
        adj[v] ~= Edge(v, u, 0, adj[u].length.to!int - 1);
    }

    foreach (i ; 1 .. n + 1) {
        foreach (j ; iota(2*i, n + 1, i)) {
            addEdge(i, j, inf);
        }

        if (a[i - 1] >= 0) {
            addEdge(i, n + 1, a[i - 1]);
        }
        else {
            addEdge(0, i, -a[i - 1]);
        }
    }

    long ans = a.filter!"a > 0".sum(0L);

    ans -= EdmondsKarp(adj, 0, n + 1);

    writeln(ans);
}



long EdmondsKarp(Edge[][] adj, int s, int t) {
    int n = adj.length.to!int;
    long F;

    while (true) {
        auto q = Queue!(int)(n);
        q.push(s);

        auto pred = new Edge*[](n);
        
        while (!q.empty && !pred[t]) {
            auto cur = q.front;
            q.pop();

            foreach (ref e ; adj[cur]) {
                if (!pred[e.to] && e.to != s && e.cap > 0) {
                    pred[e.to] = &e;
                    q.push(e.to);
                }
            }
        }

        if (pred[t]) {
            long df = inf;

            for (auto e = pred[t]; e; e = pred[e.from]) {
                df = min(df, e.cap);
            }

            for (auto e = pred[t]; e; e = pred[e.from]) {
                e.cap -= df;
                adj[e.to][e.rev].cap += df;
            }

            F += df;
        }
        else break;
    }

    return F;
}



struct Queue(T) {
    private {
        int N, head, tail;
        T[] data;
    }

    this (int n) {
        N = n + 1;
        data = new T[](N);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return (tail + 1) % N == head;
    }

    T front() {
        return data[head];
    }

    void push(T x) {
        assert(!full);
        data[tail++] = x;
        tail %= N;
    }

    void pop() {
        assert(!empty);
        head++;
        head %= N;
    }
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 380
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, lim = map(int, readline().split())
WV = np.array(read().split(), np.int64)

W = WV[::2]
V = WV[1::2]

# weight -> value
dp = np.zeros(lim + 1, np.int64)
for w, v in zip(W, V):
    np.maximum(dp[w:], dp[:-w] + v, out=dp[w:])
print(dp.max())

Measured memory_bytes: 28944
K=int(input())
n=6
a=[100,101,102,103,104,105]
m=[1000000,1000000,1000000,1000000,1000000,1000000]

dp=[-1 for i in range(K+1)]
dp[0]=0
for i in range(n):
    for j in range(K+1):
        if dp[j]>=0:
            dp[j]=m[i]
        elif j<a[i] or dp[j-a[i]]<=0:
            dp[j]=-1
        else:
            dp[j]=dp[j-a[i]]-1
    #print(dp)
if dp[K]>=0:
    print(1)
else:
    print(0)
#print(dp)


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

///
int main()
{
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
        if(s[i]==s[i+1])
        {
            cout<<"Bad";
            return 0;
        }
    cout<<"Good";
    return 0;
}


Measured memory_bytes: 256
S=input()

Length=len(S)
Counta=0
Countb=0

if Length%2==0:
    Sa="01"*(Length//2)
    Sb="10"*(Length//2)
else:
    Sa="01"*(Length//2)+"0"
    Sb="10"*(Length//2)+"1"
    
for i in range(Length):
    if S[i]!=Sa[i]:
        Counta+=1
    if S[i]!=Sb[i]:
        Countb+=1
        
print(min(Counta,Countb))

Measured memory_bytes: 3316
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define bas 987625403
#define sqr(x) (x)*(x)  
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> set_t;
#define trace(...) f(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void f(const char* x, t&& val1){
    cout<<x<< " : "<<val1<<endl;
}
template<typename t1, typename... t2> void f(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    f(xd+1, val2...);
}

int main(){

	fastio;
	string cad;
	cin >> cad;
	reverse(cad.begin(),cad.end());
	ll w = 0, ans = 0;
	for(char c : cad){
		if(c == 'W') w++;
		else ans += w;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;

int main(){
   ll N, K;
   std::cin >> N >> K;
   std::vector<ll> A(N);
   for(int i=0; i<N; ++i){
      std::cin >> A[i];
   }
   std::sort(A.begin(), A.end());

   ll ulim = 2e18;
   ll llim = -2e18;
   while(ulim-llim>1){
      ll x = (ulim + llim)/2;
      ll count = 0;
      for(int i=0; i<N; ++i){
	 if(A[i]<0) count += N - (std::upper_bound(A.begin(), A.end(), (long double)x/A[i]) - A.begin()); 
	 else if(A[i]>0) count += std::lower_bound(A.begin(), A.end(), (long double)x/A[i]) - A.begin();
	 else if(x>0) count += N;
	 if(A[i]*A[i] < x) --count;
      }
      (count/2 < K ? llim : ulim) = x;
   }
   std::cout << llim << std::endl;
   return 0;
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a==(b+c)){
        cout << "Yes" << endl;
    }else if(b==(a+c)){
        cout << "Yes" <<endl;
    }else if(c==(a+b)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

int main(){
  // 入力
  int  K, A, B;
  cin >> K >> A >> B;

  
  string  result = "NG";

  for (int i=A; i <= B; i++) {
    if ( i%K == 0 ) {
      result = "OK";
      break;
    }
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>


int main()
{
	int N;
	int i;
	static long long int A[100001];
	static long long int B[100000];
	long long int killedMonsters = 0;

	scanf("%d\n", &N);
	for (i = 0; i < N + 1; i++) {
		scanf("%lld", &A[i]);
	}
	for (i = 0; i < N; i++) {
		scanf("%lld", &B[i]);
	}

	for (i = N - 1; i >= 0; i--) {
		if (B[i] >= A[i + 1]) {
			killedMonsters += A[i + 1];
			B[i] = B[i] - A[i + 1];
			A[i + 1] = 0;
		}
		else {
			killedMonsters += B[i];
			A[i + 1] = A[i + 1] - B[i];
			B[i] = 0;
		}

		if (B[i] >= A[i]) {
			killedMonsters += A[i];
			B[i] = B[i] - A[i];
			A[i] = 0;
		}
		else {
			killedMonsters += B[i];
			A[i] = A[i] - B[i];
			B[i] = 0;
		}
	}

	printf("%lld\n", killedMonsters);
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
  int sum = 0, maxsum = 0;
  for(int i = 0; i < k; i++){
    sum += p[i];
  }
  //cout << sum << " ";

  int target = 0;
  maxsum = sum;
  for(int i = 0; i < n - k; i++) {
    sum -= p[i];
    sum += p[i + k];
    //cout << sum << " ";
    if(maxsum < sum) {
      maxsum = sum;
      target = i + 1;
    }
  }
  //cout << target << "\n";
  double ans = 0;

  for(int i = target; i < target + k; i++){
    for(int j = 1; j <= p[i]; j++){
      ans += (double)j / p[i];
    }
  }
  printf("%.10lf\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long 
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
pair<int, int>a[69]; pair<int, int>b[69]; int n, m, inf = 1e9, ans;
signed main() {
	cin >> n >> m;
	rep(i, n)cin >> a[i].first >> a[i].second;
	rep(i, m)cin >> b[i].first >> b[i].second;
	rep(i, n) {
		rep(j, m) {
			if (abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second) < inf) {
				inf = abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second);
				ans = j + 1;
			}
		}
		cout << ans << endl;
		inf = 1e9;
	}
	getchar(); getchar(); return 0;
}

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

const int N = 200005;
const int INF = 1e9;

int n, a[N];
int lazy[4 * N], it[4 * N];
long long res;
vector<int> val;

void build(int i, int l, int r) {
	if (l == r) {
		it[i] = val[l]; return;
	}
	int mid = (l + r) >> 1;
	build(i << 1, l, mid), build(i << 1 | 1, mid + 1, r);
	it[i] = min(it[i << 1], it[i << 1 | 1]);
}

void push(int i, int l, int r) {
	if (!lazy[i]) return;
	it[i] += lazy[i];
	if (l != r) lazy[i << 1] += lazy[i], lazy[i << 1 | 1] += lazy[i];
	lazy[i] = 0; return;
}

void upd(int i, int l, int r, int L, int R) {
	push(i, l, r);
	if (l > R || L > r) return;
	if (L <= l && r <= R) {
		lazy[i] = 1, push(i, l, r); return;
	}
	int mid = (l + r) >> 1;
	upd(i << 1, l, mid, L, R);
	upd(i << 1 | 1, mid + 1, r, L, R);
	it[i] = min(it[i << 1], it[i << 1 | 1]);
}

int get(int i, int l, int r, int L, int R) {
	push(i, l, r);
	if (l > R || L > r) return INF;
	if (L <= l && r <= R) return it[i];
	int mid = (l + r) >> 1;
	return min(get(i << 1, l, mid, L, R), get(i << 1 | 1, mid + 1, r, L, R));
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i], val.push_back(a[i]);
	sort(val.begin(), val.end()); val.erase(unique(val.begin(), val.end()), val.end());
	int sz = val.size();
	build(1, 0, sz - 1);
	for (int i = 1; i <= n; ++i) {
		int pos = lower_bound(val.begin(), val.end(), a[i]) - val.begin();
		res += get(1, 0, sz - 1, pos, sz - 1) - a[i];
		upd(1, 0, sz - 1, 0, pos - 1);
	}
	cout << res;
}

Measured memory_bytes: 8052
def answer(*inp):

    N = int(inp[0])
    cards = sorted([int(n) for n in inp[1].split()], reverse=True)

    alice = 0
    bob = 0

    for i, card in enumerate(cards):
        if i % 2 == 0:
            alice += card
        else:
            bob += card

    print(alice - bob)


answer(input(), input())

Measured memory_bytes: 3060
#include <stdio.h>

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

	int counter = 0;

	for (int i = 2; i <= k; i += 2) {
		//printf("i:: %d\n", i);
		for (int j = 1; j <= k; j += 2) {
			//printf("j:: %d\n", j);
			if ((i % 2 == 0) && ((j+1) % 2 == 0)) {
				counter++;
				//printf("DDDD\n");
			}
		}
	}

	printf("%d\n", counter);
}

Measured memory_bytes: 128
//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include<bits/stdc++.h>
using namespace std;

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 1e5+7;


int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,x,y,z,u,v;
    cin>>n;
    vector<ll>vec(n);
    bool zero=false;
    for(i=0;i<n;i++)
    {
        cin>>vec[i];
        if(!vec[i])
        {
            zero=true;
        }
    }
    if(zero)
    {
        cout<<0<<endl;
        return 0;
    }
    sort(all(vec));
    ll tem=1;
    for(i=0;i<n;i++)
    {
        if(tem<=(1000000000000000000 / vec[i]))
        {
            tem*=vec[i];
        }
        else
        {
            tem=-1;
            break;
        }
        if(tem==0)
        {
            break;
        }
    }
    cout<<tem<<endl;
    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<long long> a(k),b(n),c(n);
  rep (i,n) cin >> b.at(i);
  rep (i,k) a.at(i)=0;
  sort(b.begin(),b.end());
  c.at(0)=b.at(0);
  for (int i=1;i<n;i++){
    c.at(i)=c.at(i-1)+b.at(i);
  }
  a.at(0)=1;
  for (int i=n-1;i>-1;i--){
    int t=0;
    if (b.at(i)>=k) continue;
  for (int j=k-1;j>-1;j--){
    if (a.at(j)==1) {
      if (j+b.at(i)<k) {
        a.at(j+b.at(i))=1;
        if (j+c.at(i)>=k) t=1;
        }
      else t=1;
    }
  }
  if (t==0) {cout << i+1 << endl;return 0;}
  }
 cout << 0 << endl;
}

Measured memory_bytes: 384