akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

typedef vector<int> vi;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define ALL(a) (a).begin(),a.end()
#define MAXE(a) *max_element(ALL(a))
#define MINE(a) *min_element(ALL(a))

int main(){
	int a,b;
	cin >>a>>b;
	int x = a+b;
	if(x<10) cout << x << endl;
	else cout << "error" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n;
    cin >> n;
    ll x = 0;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) x = i;
    }
    ll y = n / x;
    cout << x + y - 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];
        Map<Integer,Integer>map = new HashMap<>();
        for(int i= 0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
            if(map.containsKey(a[i])) {
                map.remove(a[i]);
            }else {
                map.put(a[i], 1);
            }
        }
        System.out.println(map.size());
        
    }
}

Measured memory_bytes: 46948
#include <stdio.h>

int main(void){
	int n,k,min,max,i,l;
	
	scanf("%d",&n);
	scanf("%d",&l);
	min=l;

	for(i=2;i<=n;i++){
		scanf("%d",&k);
		if(i==2)
			max=k-l;
		if(max<k-min)
			max=k-min;
		if(min > k)
			min=k;
	}
	
	printf("%d\n",max);

	
	return 0;
}



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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
VL A;

int main() {
    cin >> N;
    REP(i, N) A.emplace_back(IN());
    sort(All(A));
    ll idx = 0, sum = 0;
    REP(i, N) {
        if(2 * sum < A[i] && i > 0) idx = i;
        sum += A[i];
    }
    cout << N - idx << "\n";
}


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

#define forn(i,x,y) for(int i = int(x); i<int(y); i++)
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(V) V.begin(), V.end()
#define on(x, b) (x & (1LL << b))
#define trav(x, v) for(auto &x : v)

#define f first
#define s second

const int N = 1e5 + 10;

ll c2(ll x) {
    if(x < 2) return 0;
    return x * (x - 1) / 2;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    ll n; cin >> n;
    vector<ll> a(n); trav(i, a) cin >> i;
    vector<ll> occ(n + 1, 0); trav(i, a) occ[i] ++;
    ll ans = 0;

    forn(i,1,n+1) ans += c2(occ[i]);

    trav(i, a) {
        ans -= c2(occ[i]);
        occ[i]--;
        cout << ans + c2(occ[i]) << "\n";
        occ[i]++;
        ans += c2(occ[i]);
    }

    return 0;
}

/* don't forget to check:
   int overflow
   min/max cases (n = 1)
   printing index of sorted array
   limits for ans (start with inf)
   s = 'x' + s is linear! dont use it!
 */

Measured memory_bytes: 5760
#include <iostream>
#include <cstdlib>
long long f(long long a, long long b) {
    if (a != 0) {
        return f(0, a - 1) ^ f(0, b);
    } else {
        long long result = 0;
        long long x = 1;
        b++;
        while (x < b) {
            long long n = b / (x * 2) * x + std::max(0LL, b % (x * 2) - x);
            if (n % 2) {
                result |= x;
            }
            x <<= 1;
        }
        return result;
    }
}
int main() {
    long long a, b;
    std::cin >> a >> b;
    std::cout << f(a, b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n;
    cin >> n;
    V(string) s(n);
    vi t(n);
    rep(i, n) {
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;

    bool sleep = false;
    int res = 0;
    rep(i, n) {
        if(sleep) res += t[i];
        if(x == s[i]) sleep = true;
    }

    cout << res << endl;

    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    int ans = 2*N;
    for(int i=1; i<=N; i++)
    {
        if(s.substr(N-i, i) == t.substr(0, i)) ans = 2*N-i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll l=s.length();rep(i,l) s[i]='x';
  print(s);
  return 0;
}

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

#define ll long long
#define hh '\n'

using namespace std;

int main()
{
    string s ,t;
    cin>>s>>t;

    int ans=0;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            ans++;
    }

  cout<<ans<<hh;

    return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int d;
    R d;
    co("Christmas");
    rep(i, 25 - d)co(" Eve");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

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

	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i += 2) {
		cout << s[i];
	}
	gc();
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
const int MX = 1e5+5;
int dp[MX];

int n;
vector <int> v;

int solve(int pos){
    if(pos > n) return 1e17;
    if(pos == n) return 0;
    if(dp[pos] != -1) return dp[pos];
    long long ans = 1e17;
    int curr_height = v[pos],next_height;
    next_height = v[pos + 1];
    ans = min(ans, solve(pos+1) + abs(curr_height - next_height));
    if(pos+2 <= n ){
        next_height = v[pos + 2];
        ans = min(ans, solve(pos+2) + abs(curr_height - next_height));
    }
    return dp[pos] = ans;
}

int32_t main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    v.resize(n+1);
    for(int i=1 ; i<=n ; i++) cin>>v[i];
    cout<<solve(1);
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll x;
  rep(i, 0, 5) {
  	cin >> x;
    if (x == 0) {
    	cout << i + 1 << endl;
      	return 0;
    }
  }
}

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

using Lint=long long;
const int mod=1e9+7;

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

    map<int,int> cnt;
    cnt[-1]=3;
    Lint ans=1;
    for(int i=0;i<N;i++){
        ans=ans*cnt[a[i]-1]%mod;
        cnt[a[i]-1]--; cnt[a[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5376
intLine=lambda:map(int,input().split())
h,n=intLine()
dp=[10**9]*(h+1)
dp[0]=0
for _ in range(n):
  a,b=intLine()
  for j in range(h+1):
    dp[j]=min(dp[j],dp[max(0,j-a)]+b)
print(dp[h])

Measured memory_bytes: 44524
Module _20190422

    Sub Main()

        Dim sNextContest() As Char = Console.ReadLine().ToCharArray

        Dim iKuriagariFlg As Integer = 0

        For i As Integer = 1 To sNextContest.Length - 1

            If sNextContest(0) < sNextContest(i) Then

                iKuriagariFlg = 1

                Exit For

            End If

        Next

        If iKuriagariFlg = 0 Then

            Console.WriteLine(sNextContest(0) & sNextContest(0) & sNextContest(0))

        Else

            Dim A As String = (CInt(sNextContest(0).ToString) + 1).ToString

            Console.WriteLine(A & A & A)

        End If

    End Sub

End Module

Measured memory_bytes: 13140
#include<bits/stdc++.h>
    using namespace std;
    int main() {
        int t; cin>>t;
      int ac=0,wa=0,tle=0,re=0;
      while(t--) {
        string s; cin>>s;
        if(s[0]=='A') ac++;
        if(s[0]=='W') wa++;
        if(s[0]=='T') tle++;
        if(s[0]=='R') re++;
      }
      cout<<"AC x "<<ac<<endl;
      cout<<"WA x "<<wa<<endl;
      cout<<"TLE x "<<tle<<endl;
      cout<<"RE x "<<re<<endl;
    }

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

int find(const std::string *v, std::string val) {
    for(int i = 0; i < 7; i++) {
        if(v[i] == val) {
            return i;
        }
    }
    return -1;
}

int main(void) {
    std::string week[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    char str[3];
    std::cin >> str;

    int res = 7 - find(week, str);
    
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 3636
#
import sys
import math
import numpy as np
import itertools


# いくつか入力
n,k = (int(i) for i in input().split())  
answer = 0
answer += (n//k)**3
if k % 2 == 0:
    answer += ( (n + (k//2) ) // k )**3

print(answer)




Measured memory_bytes: 21660
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#define M_PI 3.14159265358979323846
#include <vector>
using namespace std;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m)); //2-d vector a(rows,columns)
    vector<int> c(n);
    //Get the cost into a seperate vector than the skills.
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++)cin >> a[i][j];
    }
    int ans = 12345678;
    int all = 1<<n; // 1<<n == 1 * 2^n. 2^n combinations(either buy book or dont)
    for(int mask = 0; mask < all; mask++){
        vector<int> level(m);
        int cost = 0;
        for(int i = 0; i < n; i++){
            if((1<<i)&mask){ //mask>>i == mask / 2^i
                cost += c[i];  
                for(int j = 0; j < m; j++){
                    level[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for(int j = 0; j < m; j++){
            if(level[j] < x) ok = false;
        }
        if(ok) ans = min(ans,cost);
    }
    if(ans == 12345678) cout << -1 << endl;
    else cout << ans << endl;
}

  


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

#include <assert.h>
#define BUF_SIZE 30

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

struct list {
    struct list *next;
    int v;
};
#define VERTEX_MAX 200000
struct list *create_graph(int size) {
    struct list *graph = malloc(sizeof(struct list)*size);
    int i;
    for(i = 0; i < size; i++) {
        graph[i].next = &graph[i];
    }
    return graph;
}

// be careful, multiply by 2 because execute insert() twice
struct list pool[VERTEX_MAX*2];
int idx = 0;

struct list *get_list(void) {
    assert(idx+1 < VERTEX_MAX*2);
    return &pool[idx++];
}

void insert(struct list *graph, int size, int src, int dst) {
    assert(src < size);
    assert(dst < size);
    struct list *head = &graph[src];
    struct list *elem = get_list();
    elem->v = dst;
    elem->next = head->next;
    head->next = elem;
}

int queue[VERTEX_MAX+1];
static int start = 0;
static int end = 0;

int is_empty(void) {
    return start == end;
}

void enqueue(int node) {
    queue[end++] = node;
}

int dequeue(void) {
    return queue[start++];
}

// 1-indexed
int bfs(struct list *graph, int *profit, int *ans, int size) {
    int node = 1;
    static char checked[VERTEX_MAX+1];
    enqueue(node);
    checked[node] = 1;
    ans[node] = profit[node];
    while(!is_empty()) {
        int v = dequeue();
        struct list *head = &graph[v];
        struct list *elem;
        for(elem = head->next; elem != head; elem = elem->next) {
            int nv = elem->v;
            if(!checked[nv]) {
                // calc ans
                ans[nv] = profit[nv] + ans[v];
                enqueue(nv);
                checked[nv] = 1;
            }
        }
    }
    return 0;
}

int main(void) {
    int vs, queries;
    get_int2(&vs, &queries);

    struct list* graph = create_graph(vs+1);
    int i;
    for(i = 0; i < vs-1; i++) {
        int v1, v2;
        get_int2(&v1, &v2);
        insert(graph, vs+1,v1, v2);
        insert(graph, vs+1,v2, v1);
    }

    // vertex is 1-indexed.
    int map[VERTEX_MAX+1] = {0};
    for(i = 0; i < queries; i++) {
        int v, point;
        get_int2(&v, &point);
        map[v] += point;
    }
    int sum[VERTEX_MAX+1] = {0};
    if(bfs(graph, map, sum, vs) == -1) return 0;

    // presentation
    for(i = 1; i <= vs; i++) {
        int end = (i == vs);
        printf("%d%c", sum[i], end ? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 14208
import collections

n = int(input())
s = str(input())

ans = 0
for i in range(10):
  i_bannme = s.find(str(i))
  if i_bannme == -1:
    continue
  else:
    for j in range(10):
      j_bannme = s.find(str(j), i_bannme+1)
      if j_bannme== -1:
        continue
      else:
        ans += len(collections.Counter(s[j_bannme+1:]))

print(ans)

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define x first
#define y second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const int INF = 1e9 + 9;
const int B = 998244353;

ll pwr(ll a, ll b) {
    ll ans = 1;
    for (; b; b >>= 1, a = a * a % B)
        if (b & 1) ans = ans * a % B;
    return ans;
}

ll f[N], rf[N];

ll c(ll n, ll k) {
    return f[n] * rf[n - k] % B * rf[k] % B;
}

ll gcd(ll &ka, ll a, ll &kb, ll b) {
    if (!b) {
        ka = 1, kb = 0;
        return a;
    }
    ll g = gcd(kb, b, ka, a % b);
    kb -= ka * (a / b);
    assert(ka * a + kb * b == g);
    return g;
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    f[0] = 1, rf[0] = 1;
    forn(i, 1, 3e5) {
        f[i] = f[i - 1] * i % B;
        rf[i] = pwr(f[i], B - 2);
    }

    ll n, a, b, k, ka, kb;
    cin >> n >> a >> b >> k;
    ll g = gcd(ka, a, kb, b);
    if (k % g != 0) {
        cout << "0\n";
        return 0;
    }
    ka *= k / g, kb *= k / g;
    ll l = a * b / g;
    ll qa = l / a, qb = l / b;
    if (ka < kb)
        swap(a, b), swap(ka, kb), swap(qa, qb);
    if (kb < 0) {
        ll d = (-kb + qb - 1) / qb;
        ka -= qa * d, kb += qb * d;
//        if (ka < 0) {
//            cout << "0\n";
//            return 0;
//        }
    }
    if (ka < kb)
        swap(a, b), swap(ka, kb), swap(qa, qb);
    if (ka > n) {
        ll d = ((ka - n) + qa - 1) / qa;
        ka -= qa * d, kb += qb * d;
//        if (ka < 0 || kb > n) {
//            cout << "0\n";
//            return 0;
//        }
    }
    if (ka < kb)
        swap(a, b), swap(ka, kb), swap(qa, qb);
    while (ka + qa <= n && kb - qb >= 0) ka += qa, kb -= qb;
    ll ans = 0;
    for (; 0 <= min(ka, kb) && max(ka, kb) <= n; ka -= qa, kb += qb)
        ans = (ans + c(n, ka) * c(n, kb)) % B;
    cout << ans << "\n";

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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



int main()
{
  int h, w; cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];
  vector<int> rh, rw;
  rep(i, h) {
    bool ok = true;
    rep(j, w) if(a[i][j] == '#') ok = false;
    if(ok) rh.push_back(i);
  }
  rep(j, w) {
    bool ok = true;
    rep(i, h) if(a[i][j] == '#') ok = false;
    if(ok) rw.push_back(j);
  }
  rep(i, h) {
    if(binary_search(ALL(rh), i)) continue;
    rep(j, w) if(!binary_search(ALL(rw), j)) cout << a[i][j];
    cout << endl;
  }
}


Measured memory_bytes: 256
# atcoder -take a rest-(easy)
#typical greedy
def main():
    N, M = map(int, input().split())
    conflict = [tuple(map(int, input().split())) for i in range(M)]
    newest_destroyed = -1
    conflict.sort(key=lambda x: x[1])
    res = 0
    for l, r in conflict:
        if not (l <= newest_destroyed < r):
            res += 1
            newest_destroyed = r-1
    print(res)
    return


if __name__ == "__main__":
    main()




Measured memory_bytes: 23992
/*
[abc138] C - Alchemist
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 50;

int N;
int v[MAX_N];

double solve() {
    sort(v, v + N);
    double ans = (double)v[0] / (1LL << (N - 1));
    for (int i = 1; i < N; i++) {
        ans += (double)v[i] / (1LL << (N - i));
    }

    return ans;
}

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

    cout << setprecision(16) << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    int n, k;
    int i;
    int a[52];
    cin  >> k >> n;

    for(i = 0; i < k; i++){
         cin >> a[i];
    }

    //ソート
    for(int s =0; s < k - 1; s++){
        for(int t = s+1; t<k;  t++){
            if(a[t] > a[s]){
                int temp = a[t];
                a[t] = a[s];
                a[s] = temp;

            }
        }
    }

    int ans = 0;
    for(i = 0; i < n; i++){
        ans = ans + a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;

  auto dat = new int[][][](4, 3, 10);
  foreach (_; 0..n) {
    auto rd = readln.split.map!(to!int);
    auto b = rd[0] - 1, f = rd[1] - 1, r = rd[2] - 1, v = rd[3];
    dat[b][f][r] += v;
  }

  foreach (i, b; dat) {
    foreach (f; b) {
      foreach (r; f)
        writef(" %d", r);
      writeln;
    }
    if (i < dat.length - 1)
      writeln("####################");
  }
}

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

int main()
{
	int a,b;
	char op;
	do{
		cin>>a>>op>>b;
		if (op=='?')
			break;
		switch (op){
			case '+':cout<<a+b<<endl;
				 	break;
			case '-':cout<<a-b<<endl;
					 break;
			case '*':cout<<a*b<<endl;
				 	break;
			case '/':cout<<a/b<<endl;
				 	break;
			default: cout<<"error op"<<endl;
		}
		
	}while(1);
	
	return 0;
}


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

using namespace std;

int arr[1000000],cost[1000000];

long long int modu(long long int a)
{
	if(a>0)
		return  a;
	else
		return -1*a;
}

long long int maxa(long long int a,long long int b)
{
	if(a>b)
		return a;
	else
		return b;
}

long long int mini(long long int a,long long int b)
{
	if(a<b)
		return a;
	else
		return b;
}

int  main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n,a,b,c,d,k;
	cin>>n>>k;

	for (int i = 1; i <=n; ++i)
	{
		cin>>arr[i];
		cost[i]=1000000001;
	}

	cost[1]=0;
	cost[2]=modu(arr[2]-arr[1]);

	for (int i = 3; i <=n; ++i)
	{
		b=1000000001;
		c=0;
		for (long long int ii = i-1; ii>=1; --ii)
		{
			c++;
			a=modu(arr[i]-arr[ii])+cost[ii];
			b=mini(a,b);
			if(c==k)
				break;
		}
		cost[i]=b;
	}
	cout<<cost[n]<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define ALL(a) a.begin(), a.end()
#define REP(i,a) for(ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i,a,b) for(ll i(a), _##i(b); i <= _##i; ++i)
using namespace std;
using ll = long long;

void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for(int &x : a) cin >> x, sum += x;

    double s = sum / (4.0 * m);
    int cnt = 0;

    for(int x : a){
        if (x >= s) ++cnt;
    }

    cout << (cnt >= m ? "Yes\n" : "No\n");

}

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

    int T = 1;
    //cin >> T;
    FOR(i,1,T){
        solve();
    }
}


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

int main()
{
    int A, B, K;

    cin >> A >> B >> K;

    int num[max(A, B)];

    int j = 1;

    for (int i = max(A, B); i > 0; i--)
    {
        if ((A % i == 0) && (B % i == 0))
        {
            num[j] = i;
            j++;
        }
    }

    cout << num[K] << endl;

    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main()
{

  double W, H, x, y;
  cin >> W >> H >> x >> y;

  printf("%.12f", (W / 2) * H);
  // center
  if (x == (W / 2) && y == (H / 2))
    cout << " 1" << endl;
  // not center
  else
    cout << " 0" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int a, b; cin >> a >> b;
	if (a == 1 || b==n) {
		int tmp = b - a;
		tmp--;
		cout << tmp / 2 + 1 << endl; return 0;
	}
	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2 << endl;
	}
	else {
		int ans = b - a;
		int tmp = min(a - 1, n - b) + 1;
		ans--;
		ans /= 2;
		ans += tmp;
		cout << min(ans,min(b - 1, n - a)) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n, m, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
here = 0
if x < a[0] or a[m-1] < x:
  ans = 0
else:
  for i in range(m-1):
    if a[i] < x < a[i+1]:
      ans = min(len(a[:i+1]),len(a[i+1:]))
      break
print(ans)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int c[n - 1], s[n - 1], f[n - 1];
    rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
    rep(i, n - 1) {
        int mini = s[i] + c[i];
        repl(j, i + 1, n - 1) {
            maxch(mini, s[j]);
            mini = (mini / f[j] + (mini % f[j] > 0)) * f[j] + c[j];
        }
        cout << mini << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
box = list(map(int, input().split()))
q = int(input())
for _ in range(q):
    b, m, e = map(int, input().split())
    _box = list(box)
    for k in range(e-b):
        _box[b+(k+(e-m))%(e-b)] = box[b+k]
    box = _box
            
print(*box)


Measured memory_bytes: 5812
char S[5<<17],*p=S,c;
b[5<<17];
I;
main(q)
{
	scanf("%*d%s%*d ",S);
	for(;*p;)b[++I]=1<<*p++-97;
	for(;q=~getchar();)
	{
		if(q&1)
		{
			int l,r,t=0;
			scanf("%d%d ",&l,&r);
			for(int i=l;i<=r;i++)t|=b[i];
			printf("%d\n",__builtin_popcount(t));
		}
		else
		{
			scanf("%d %c ",&I,&c);
			b[I]=1<<c-97;
		}
	}
}


Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
int rui10(int a) {
	if (a == 0) { return 1; }
	return 10 * rui10(a - 1);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
vel mul(vel &a, vel &b) {
	int n = a.size();
	vel c(n,-1);
	rep(i, n) {
		rep(j, n) {
			if (a[i] >= 0 && b[j] >= 0) {
				mmax(c[(i + j) % n], a[i] + b[j]);
			}
		}
	}
	return c;
}
vel rui(vel &a, int n) {
	if (n == 1) { return a; }
	vel b = rui(a, n / 2);
	b = mul(b, b);
	if (n % 2 == 1) {
		b = mul(b, a);
	}
	return b;
}
signed main(){
	int n, m, p; cin >> n >> m >> p;
	vel d(m);
	rep(i, m) {
		int x; cin >> x;
		d[i] = (x + n - p) % n;
	}
	sor(d);
	int ans = min(n - d[0], d[m - 1]);
	rep(i, m - 1) {
		int qans = d[i] + (n - d[i + 1]) + min(d[i], n - d[i + 1]);
		mmin(ans, qans);
	}
	cout << ans*100 << endl;
	return 0;
}


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

public class Main {
  private static long solve(long n, long a, long b) {
    if (n == 1 && a != b) {
      return 0;
    }
    if (n == 1 && a == b) {
      return 1;
    }
    if (a > b) {
      return 0;
    }
    long min = a * (n - 2);
    long max = b * (n - 2);
    return max - min + 1;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long n = reader.nextInt();
    long a = reader.nextInt();
    long b = reader.nextInt();
    out.println(solve(n, a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
  long long a,b,c,d;
  cin >> a >> b >> c;
  if((c-a-b)<0) {
    cout << "No";
    return 0;
  }
  d = (c-a-b)*(c-a-b);
  if(4*a*b < d)cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int n;db a[10005];
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    db ans=a[1];
    for(int i=2;i<=n;i++){
        ans=(ans+a[i])/2;
    }
    printf("%.11f\n",ans);
}

Measured memory_bytes: 256
import java.util.*;



public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char c[] = s.toCharArray();
		int a = 0;
		int b = 0;
		int d = 0;
		
		for(int i = 0; i < 3; i ++) {
			if(c[i] == 'a') {
				a ++;
			}else if(c[i] == 'b') {
				b ++;
			}else if(c[i] == 'c') {
				d ++;
			}
		}
		if(a == 1 && b == 1 && d == 1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, k;
        cin >> n >> k;
        cout << n - k + 1 << '\n';
    }
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
const long long LL_INF = 1LL<<60;
//stoi(s) : string→int stoll(s) :string→longlong
const double PI=3.14159265358979323846;
const int MAXN = 110;
const int MAXV = 100100;
ll dp[MAXN][MAXV] = {LL_INF}; //dp[i][j]価値jを達成できる最小の重さ
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N;
    ll W;
    cin >> N >> W;
    vector<ll> w(N),v(N);
    for(int i=0;i<N;i++){
        cin >> w[i] >> v[i];
    }
    for(int i=0;i<MAXN;i++){
        for(int j=0;j<MAXV;j++){
            dp[i][j] = LL_INF;
        }
    }
    dp[0][0] = 0;

    for(int i=0;i<N;i++){
        for(int sum_v = 0;sum_v<MAXV;sum_v++){

            if(sum_v - v[i] >= 0){
                chmin(dp[i+1][sum_v],dp[i][sum_v-v[i]] + w[i]);
            }
            chmin(dp[i+1][sum_v],dp[i][sum_v]);
        }
    }
    ll res = 0;
    for(int sum_v = 0;sum_v <= MAXV;sum_v++){
        if(dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

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

int main(){
  int n;
  list<int> L;
  char str[15];
  cin >> n;
  for(int i=0,num;i<n;i++){
    cin >> str;
    if(str[0]=='i'){
      cin >> num;
      L.push_front(num);
    }
    else if(str[6]=='F'){
      L.pop_front();
    }
    else if(str[6]=='L'){
      L.pop_back();
    }
    else{
      cin >> num;
      for(list<int>::iterator it=L.begin();it!=L.end();it++){
	if(*it==num){
	  L.erase(it);
	  break;
	}
      }
    }
  }
  int i=0;
  for(list<int>::iterator it=L.begin();it!=L.end();it++){
    if(i++)cout << " ";
    cout << *it;
  }
  cout << "\n";
}



Measured memory_bytes: 34244
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, A[SIZE], B[SIZE];

  cin >> N;

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

  int prev = 0;
  ll ans = 0;

  for (int i=0; i<=N; i++) {
    ans += min(A[i], prev);
    A[i] -= min(A[i], prev);

    if (i < N) {
      cin >> B[i];
      ans += min(A[i], B[i]);
      prev = B[i] - min(A[i], B[i]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
N = int(input())

def solve(x):
    global res
    if x % 2 == 1:
        return res
    x = x // 2
    res += 1
    solve(x)

ans = []
for i in range(1, N+1):
    res = 0
    solve(i)
    ans.append([i, res])

ans = sorted(ans, key=lambda x:x[1], reverse=True)
print(ans[0][0])

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

public class Main{
	public static void main(String[] augs){

	int s, h=0, m=0, a = 0, a1 = 0;

	Scanner scan = new Scanner(System.in);

	s = Integer.parseInt(scan.next());

	if(s < 86400 && s >= 0){
		if(s >= 3600){	
	    		h = (int)s/3600;
			a = (int)s % 3600;
		}else{
			a = (int)s;
		}

		if(s >= 60){
			m = (int)a/60;
			a1 = (int)a % 60;
		}else{
			a1 = (int)a;
		}

		s = (int)a1;

		System.out.println(h + ":" + m +":"+ s);
	
	}

	}
}

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

using namespace std;

int n, a[15], x[15][14], y[15][14];

string to_bin_str(int k) {
    string str;
    while (k > 0) {
        str.push_back('0' + (k & 1));
        k >>= 1;
    }
    int c = n - (int)str.size();
    for(int i = 0; i < c; ++i) str += "0";
		
    reverse(str.begin(), str.end());
    
    return str;
}

int main(){
	int ans = 0;

	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		for(int j = 0; j < a[i]; ++j){
			cin >> x[i][j] >> y[i][j];
		}
	}
	
	for(int b = 0; b < (int)pow(2, n); ++b){
		string bit = to_bin_str(b);
		
		bool isok = true;
		
		for(int i = 0; i < n; ++i){
			if(bit[i] == '1'){
				for(int j = 0; j < a[i]; ++j){
					if((bit[x[i][j]-1]-'0') != y[i][j]){
						isok = false;
					}
				}
			}
		}
		
		if(isok){
			int count = 0;
			for(int i = 0; i < n; ++i) if(bit[i] == '1') count++;
		
			ans = max(ans, count);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#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(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int a,b;
    cin >> a >> b;
    if(b == 1) cout << 0 << endl;
    else cout << (b+a-3)/(a-1) << endl;
}

Measured memory_bytes: 256
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */
/*my variables are anime character */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define vll vector<ll>
#define pll pair<ll , ll> 
#define vpll vector<pll>
#define umpll unordered_map<ll , ll>
#define mpll map<ll , ll>
#define sll set<ll>
#define stll stack<ll>
#define FIO  ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);



ll N,T;
/*ll freq[200005];*/
char pix[100][100];
ll H,W;
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>H>>W;

  for(ll i = 0 ; i<H ; i++){
    for(ll j = 0 ; j<W ; j++)
      cin>>pix[i][j];
  }

  for(ll i = 0 ; i<H ; i++){
    for(ll k = 0 ; k<2 ; k++){
      for(ll j = 0 ; j<W ; j++){
        cout<<pix[i][j]; 
    }
    cout<<'\n';
    }
  }

}



int main(){
  
  FIO 
  
 solve();

  return 0;
}

Measured memory_bytes: 3612