akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

const int MAX=510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        //???
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

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

 
//n!
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
}
 
// 繰り返し二乗法 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
 
//nCr O(r) nがでかくても安心
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    //a=n!/(n-r)!=n~n-r+1までの総積->O(r)
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    //b=inv(r!)
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
 
ll inv_mod(ll n){
    // フェルマーの小定理
    return pow_mod(n,mod-2);
}


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

    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    if(n==1){
        cout<<(a[0]+a[0])%mod<<endl;
        return 0;
    }
    sort(ALL(a));
    ll ans=0;
    ll p2=pow_mod(2,n-2);
    rep(i,n){
        ll x=i,y=n-i-1;
        ll res=p2*(y+2)%mod;
        res=(res*a[i])%mod;
        ans=(ans+res)%mod;
    }
    ans=(ans*pow_mod(2,n));
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
/*
* Problem URL:
*/

#include <bits/stdc++.h>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
using namespace std;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(w) (int) w.size()

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

typedef vector<int> vi;
typedef long long int lli;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;

int main() {
	int n;
	cin>>n;
	vi arr(n);
	FOR(i, 0, n) cin>>arr[i];
	vi dp(n+1);
	dp[0] = 0;
	dp[1] = abs(arr[0]-arr[1]);
	FOR(i, 2, n){
		dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1], abs(arr[i]-arr[i-2])+dp[i-2]);
	}
	//FOR(i, 0, n) cout<<dp[i]<<" "; cout<<endl;
	cout<<dp[n-1]<<endl;
	return 0;
}


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

int main(){
  int n;  cin >> n;
  double t, a; cin >> t >> a;
  vector<int> h(n);  rep(i,n) cin >> h[i];
  int ans = 0;
  double res = abs(a-(t-h[0]*0.006));
  rep(i,n){
    if(res > abs(a-(t-h[i]*0.006))){
      ans = i;
      res = abs(a-(t-h[i]*0.006));
    }
  }
  cout << ans+1;
  return 0;
}

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

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

int main(void) {
    string c, ans = "";

    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 3) {
        cin >> c;
        ans += c[i];
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef struct _data
{
    int num;
    int idx;
}Data;
Data Num[200005];
int N, result[200005];

bool comp(Data t, Data u)
{
    return t.num < u.num;
}

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d", &Num[i].num);
        Num[i].idx = i;
    }
    sort(Num, Num + N, comp);
    for(int i = 0; i < N; i++)
    {
        int temp;
        temp = Num[N / 2].num;
        if(i >= N / 2)
        {
            temp = Num[N / 2 - 1].num;
        }
        result[Num[i].idx] = temp;
    }
    for(int i = 0; i < N; i++)
    {
        printf("%d\n", result[i]);
    }
}

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

class lazy_segtree {
    private:
        int size;
        vector<int> node,lazy;
    public:
        lazy_segtree(int n_) {
            size=1;
            while (size<n_) size*=2;
            node.resize(2*size, INT_MAX);
            lazy.resize(2*size, -1);
        }

        void setlazy(int k, int v) {
            if (2*size-1<=k) return ;
            lazy[k] = v;
            node[k] = v;
        }

        void push(int k) {
            if (lazy[k] == -1) return ;
            setlazy(k * 2 + 1, lazy[k]);
            setlazy(k * 2 + 2, lazy[k]);
            lazy[k] = -1;
        }

        void merge(int k) {
            node[k]=min(node[k*2+1],node[k*2+2]);
        }

        void range_update(int queryL,int queryR,int val,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return ;
            if (queryL<=nodeL && nodeR<=queryR) {
                setlazy(k,val);
                return ;
            }
            else {
                push(k);
                int nodeM=(nodeL+nodeR)/2;
                range_update(queryL,queryR,val,k*2+1,nodeL,nodeM);
                range_update(queryL,queryR,val,k*2+2,nodeM,nodeR);
                merge(k);
                return ;
            }
        }

        int get_node(int queryL,int queryR,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return INT_MAX;
            if (queryL<=nodeL && nodeR<=queryR) return node[k];
            else {
                push(k);
                int nodeM=(nodeL+nodeR)/2;
                int vl=get_node(queryL,queryR,k*2+1,nodeL,nodeM);
                int vr=get_node(queryL,queryR,k*2+2,nodeM,nodeR);
                return min(vl,vr);
            }
        }
};

int n,q;

int main(){
    cin >> n >> q;
    lazy_segtree ls(n);
    for (int i=0; i<q; i++) {
        int que,s,t,x,idx;
        cin >> que;
        if (que==0) {
            cin >> s >> t >> x;
            ls.range_update(s,t+1,x);
        }
        else {
            cin >> s >> t ;
            cout << ls.get_node(s,t+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4880
import sys
l, r = (int(x) for x in input().split())
tmpmin = 2019
if r-l >= 2019:
    print(0)
else:
    for i in range(l, r):
        for j in range(l+1, r+1):
            tmp = (i*j)%2019
            if tmp < tmpmin:
                tmpmin = tmp
                if tmpmin == 0:
                    print(tmpmin)
                    sys.exit()
    print(tmpmin)

Measured memory_bytes: 3060
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[] p = new int[n];
    int count = 0;
  for (int i = 0; i < n; i++){
    p[i] = Integer.parseInt(sc.next());
  }
  int arrayMin = Integer.MAX_VALUE;
  for (int i = 0; i < n; i++){
    arrayMin = Math.min(p[i],arrayMin);
    if(arrayMin == p[i]){
            count++;
    }
  }
  System.out.println(count);
  }
}


Measured memory_bytes: 49448
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
using namespace std;
#define ll long long
#define MST(vis,x) memset(vis,x,sizeof(vis))
int main()
{
    char a,b,c;
    char s1[20],s2[20],s3[20];
    scanf("%s%s%s",s1,s2,s3);
    a=s1[0];
    b=s2[0];
    c=s3[0];
    printf("%c%c%c\n",a-32,b-32,c-32);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	double a, b, c, d;
	while (~scanf("%lf%lf%lf%lf", &a, &b, &c, &d))
	{
		printf("%lf ", a * b / 2);
		if (c == a / 2 && d == b / 2)
			printf("1\n");
		else
			printf("0\n");
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main()
{
    int i, n, tp=0, hp=0, j;
    char tc[128], hc[128];
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf(" %s %s", tc, hc);
        j=strcmp(tc, hc);
        if(j==0) tp++, hp++;
        else if(j>0) tp+=3;
        else hp+=3;
    }
    printf("%d %d\n", tp, hp);
    return 0;
}


Measured memory_bytes: 2044
#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <algorithm> 
#include <cmath> 
#include <string> 
#include <vector> 
#include <list> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <bitset> 
#include <numeric> 
#include <climits> 
#include <cfloat> 
using namespace std; 

class Dice
{
public:
    vector<char> pip; // ì¼kãºÌÚ
    Dice(){
        pip.assign(6, -1);
    }
    void roll(int d){ // ì¼kE¶Éñ]
        int dir[][4] = {{4,2,5,0},{4,3,5,1},{4,0,5,2},{4,1,5,3},{0,3,2,1},{0,1,2,3}};
        char tmp = pip[dir[d][0]];
        for(int i=0; i<3; ++i)
            pip[dir[d][i]] = pip[dir[d][i+1]];
        pip[dir[d][3]] = tmp;
    }
};

vector<Dice> dice(8);
vector<vector<vector<Dice> > > cube(2, vector<vector<Dice> >(2, vector<Dice>(2)));

bool solve(int curr, bitset<8> used)
{
    if(curr == 8)
        return true;
    int x = curr % 2;
    int y = curr / 2 % 2;
    int z = curr / 4 % 2;

    for(int i=0; i<8; ++i){
        if(used[i])
            continue;
        used[i] = true;
        for(int j=0; j<6; ++j){
            if(j < 4)
                dice[i].roll(0);
            else{
                dice[i].roll(1);
                if(j == 5)
                    dice[i].roll(1);
            }
            for(int k=0; k<4; ++k){
                dice[i].roll(4);
                if(x == 1 && abs(cube[0][y][z].pip[0] - dice[i].pip[2]) != abs('A' - 'a'))
                    continue;
                if(y == 1 && abs(cube[x][0][z].pip[4] - dice[i].pip[5]) != abs('A' - 'a'))
                    continue;
                if(z == 1 && abs(cube[x][y][0].pip[3] - dice[i].pip[1]) != abs('A' - 'a'))
                    continue;
                cube[x][y][z] = dice[i];
                if(solve(curr + 1, used))
                    return true;
            }
        }
        used[i] = false;
    }

    return false;
}

int main()
{
    for(;;){
        for(int i=0; i<8; ++i){
            string s;
            cin >> s;
            if(s == "0")
                return 0;

            dice[i].pip[4] = s[0];
            dice[i].pip[0] = s[1];
            dice[i].pip[1] = s[2];
            dice[i].pip[3] = s[3];
            dice[i].pip[2] = s[4];
            dice[i].pip[5] = s[5];
        }

        if(solve(0, 0))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

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



int main() {
    int N, K;
    char S[20];
    cin >> N;
    cin >> S;
    cin >> K;

    char sk = S[K-1];
    for(int i = 0; i < N; i++) {
        if (S[i] != sk) {
            S[i] = '*';
        }
    }
    cout << S << "\n";

    
}


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

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

  vector<int> a(n),b(n);
  rep(i,n) {
    cin >> a[i] >> b[i];
  }

  bool flag = false;
  for (int i = 1; i < n - 1; i++) {
    if(a[i - 1] == b[i - 1] && a[i] == b[i] && a[i + 1] == b[i + 1]) flag = true;
  }
  if(flag) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, bool> w_map;
    char prev_c = 0;
    REP(i, n) {
        string w;
        cin >> w;
        if(w_map[w] == true) {
            cout << "No" << endl;
            return 0;
        }
        if(prev_c != 0 and prev_c != w[0]) {
            cout << "No" << endl;
            return 0;
        }
        prev_c = w.back();
        w_map[w] = true;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)
 
ll n;
int main(){
	scanf("%lld",&n);
	printf("%lld",10-n/200);
}

Measured memory_bytes: 1704
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_dedges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_wedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define in_dwedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C);}
#define endl "\n"

const ll MOD = 1000000007;
const ll INF = 1e18;

vector<ll> v[200005];
bool vis[200005];

ll sz, mx;

void dfs(ll s){
    sz++;
    vis[s] = 1;
    for(auto i : v[s]) if(!vis[i]) dfs(i);

}


int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ll n, m;
    cin >> n >> m;
    in_edges(m);

    repp(i, 1, n) if(!vis[i]){
        sz = 0;
        dfs(i);

        mx = max(sz, mx);
    }

    cout << mx;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 20924
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,i,a[1000],q,k,b,e,cnt,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)	{
		scanf("%d %d",&b,&e);
		e--;
		while(b<e)	{
			swap(a[b],a[e]);
			b++;	e--;
		}
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++)	printf(" %d",a[i]);
	printf("\n");
	return 0;
}



Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, a;
  in2(n, k);
  a = 99999999999;
  vector<ll> h(n);
  rep(i, n)
    in(h[i]);
  sort(all(h));
  rep(i, n - k + 1)
    a = min(a, h[i + k - 1] - h[i]);
  out(a);
  memi;
}

Measured memory_bytes: 1024
N,K = map(int,input().split())
x_list = list(map(int,input().split()))

split_idx = None
for i,x in enumerate(x_list):
    if x >= 0:
        split_idx = i
        break
if split_idx == None:
    lefts = x_list
    rights = []
else:
    lefts = x_list[:split_idx]
    rights = x_list[split_idx:]

if len(rights)>0:
    if rights[0]==0:
        K -= 1
        rights = rights[1:]

if K == 0:
    print(0)
else:
    min_time = 10**9
    for left_cnt in range(K+1):
        right_cnt = K-left_cnt
        if left_cnt > len(lefts) or right_cnt > len(rights):
            continue
        if left_cnt ==0 and right_cnt == 0:
            tmp_time = 0
        elif left_cnt == 0:
            tmp_time = rights[right_cnt-1]
        elif right_cnt == 0:
            tmp_time = -lefts[-left_cnt]
        elif -lefts[-left_cnt] >= rights[right_cnt-1]:
            tmp_time = rights[right_cnt-1]*2 + (-lefts[-left_cnt])
        else:
            tmp_time = rights[right_cnt-1] + (-lefts[-left_cnt]) * 2
        if tmp_time < min_time:
            min_time = tmp_time
    print(min_time)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	string N=in<string>();

	for(auto& x:N){
	cout << (x=='1' ? '9' : '1');
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long N = scan.nextLong();

        long answer = 1000000000000l;

        for(long i = 1; i <= Math.sqrt((double) N); i++) {
            if(N % i == 0) {
                long j = N / i;
                long tempAns = i + j - 2;
                if(tempAns < answer) {
                    answer = tempAns;
                }
            }
        }

        os.println(answer);

    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int a,b,c,d;
vector<lint> ret;
lint n;
int main(){
  cin >> n;
  for(lint 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));
  if(ret.size()%2==1){
    int k = ret[ret.size()/2];
    cout << to_string(k).size() << endl;
    return 0;
  }
  else{
    int k = ret[ret.size()/2];
    cout << to_string(k).size() << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
S = input()
Q = int(input())
Q_list = list()
for i in range(Q):
    Q_list.append(input().split())
 
from collections import deque
def operate(i):
    global count, str_list
    if Q_list[i][0] == '1':
        count += 1
    else:
        if count % 2 == 0:
            if Q_list[i][1] == '1':
                str_list.appendleft(Q_list[i][2])
            else:
                str_list.append(Q_list[i][2])
        else:
            if Q_list[i][1] == '1':
                str_list.append(Q_list[i][2])
            else:
                str_list.appendleft(Q_list[i][2])
 
check = 0
for i in range(Q):
    if Q_list[i][0] == '1':
        check += 1
 
S_list = [i for i in S]
if check % 2 == 1:
    S_list = list(reversed(S_list))
 
S_n = ''.join(S_list)
 
str_list = deque()
str_list.append(S_n)
count = check%2
for i in range(Q):
    operate(i)
print(''.join(str_list))

Measured memory_bytes: 43900
a,b,c=map(int,input().split())
d=0
e=0
ok=False

total=int(a/(b+c))
sa=a-(b+c)*total
if total==0:
    if a>=b:
        print(b)
    else:
        print(a)
else:
    if sa>=b:
        print(b+b*total)
    else:
        print(sa+b*total)

Measured memory_bytes: 3064
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        R: i32,
        G: i32,
        B: i32,
        N: i32,
    }

    let mut ans: i32 = 0;
    for r in 0..(N / R) + 1 {
        for g in 0..(N / G) + 1 {
            let b = N - R * r - G * g;
            if 0 <= b && b % B == 0 {
                ans += 1;
            }
        }
    }

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


Measured memory_bytes: 2116
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

// 区間更新、区間最小の遅延セグメントツリー
struct RMQRUQ {
  int n;
  vector<int> dat, lazy;

  RMQRUQ(){}
  RMQRUQ(int n_) {
    n = 1; while(n < n_) n *= 2;
    dat.assign(n*2, INT_MAX);
    lazy.assign(n*2, INT_MAX);
  }

  void eval(int len, int k) {
    if(lazy[k] == INT_MAX) return;
    if(k*2+1 < n*2-1) {
      lazy[2*k+1] = lazy[k];
      lazy[2*k+2] = lazy[k];
    }
    dat[k] = lazy[k];
    lazy[k] = INT_MAX;
  }

  // [a, b)
  ll update(int a, int b, ll x, int k, int l, int r) {
    eval(r-l, k);
    if(b <= l || r <= a) return dat[k];
    if(a <= l && r <= b) {
      lazy[k] = x;
      return lazy[k];
    }
    return dat[k] = min(update(a, b, x, 2*k+1, l, (l+r)/2), update(a, b, x, 2*k+2, (l+r)/2, r));
  }
  ll update(int a, int b, ll x) { return update(a, b, x, 0, 0, n); }

  // [a, b)
  ll query(int a, int b, int k, int l, int r) {
    eval(r-l, k);
    if(b <= l || r <= a) return INT_MAX;
    if(a <= l && r <= b) return dat[k];
    ll vl = query(a, b, 2*k+1, l, (l+r)/2);
    ll vr = query(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
  ll query(int a, int b) { return query(a, b, 0, 0, n); }
};

signed main(void)
{
  int n, q;
  cin >> n >> q;
  RMQRUQ seg(n);
  REP(i, q) {
    int type;
    cin >> type;
    if(type == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      seg.update(s, t+1, x);
    } else {
      int s, t;
      cin >> s >> t;
      cout << seg.query(s, t+1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 4952
#include <stdio.h>

int main(void) {
	int max, min;
	int n, s[128];
	int i;
	int temp;

	do {
		scanf("%d", &n);
		if(!n)
			break;

		max = 0;
		min = 1000;
		temp = 0;

		for(i = 0; i < n; i++) {
			scanf("%d", &s[i]);
			if(s[i] > max)
				max = s[i];
			if(min > s[i])
				min = s[i];

			temp += s[i];
		}

		printf("%d\n", (temp - max - min) / (n - 2));
	} while(1);

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,k,n;
  cin >> n >> k;
  long long a[n+1];
  for(i=0;i<n;i++)
  {
  	cin >> a[i];
  }
  i=0;j=k;
  while(j<n)
  {
    if(a[j]>a[i])
    {
    	 cout << "Yes" << endl;
    }
    else
    {
    	cout << "No" << endl;
    }
    i++;
    j++;
  }
  
}
  

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

int main(void){
  string input = "";
  int n = 3;
  int answer = 0;
  cin >> input;

  for(int i = 0; i < 3; i++){
    if(input[i] == '1'){
      answer++;
    }
  }

  cout << answer;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll mod=1000000007;
ll add(ll a,ll b){
    return (a+b)%mod;
}
ll mul(ll a, ll b){
    return (a*b)%mod;
}
struct node
{
    ll x,y;    
};
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;T=1;
    // cin>>T;
    while(T--){
        ll n;
        ll ans=0;cin>>n;
        if(n%2==0){
            n=n/2;
            ll p=5;
            while(1){
                ll t;
                t=n/p;
                p=p*5;
                ans=ans+t;
                if(t==0)break;
            }
        }
        cout<<ans;
    }
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const long double eps=1e-7;
int n;
long double tmp,ans;
struct node {
	long double x,y;
	friend node operator - (node a,node b) {
		return (node){a.x-b.x,a.y-b.y};
	}
	friend long double operator * (node a,node b) {
		return a.x*b.y-a.y*b.x;
	}
} d[60];
long double sqr(long double x) { return x*x; }
long double dis(node a,node b) {
	return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
}
bool check(long double a,long double b,long double c) {
	if (a*a+b*b<c*c||a*a+c*c<b*b||b*b+c*c<a*a) return 1;
	return 0;
}
long double R(node x,node y,node z) {
	long double a=dis(x,y),b=dis(y,z),c=dis(x,z);
	if (check(a,b,c)) return max(a,max(b,c))*0.5;
	long double s=fabs((y-x)*(z-x))*0.5;
	return a*b*c/(4.0*s);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(d[i].x),read(d[i].y);
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j++)
	for (int k=j+1;k<=n;k++) {
		tmp=R(d[i],d[j],d[k]);
		if (tmp>ans) ans=tmp;
	}
	if (n==2) ans=dis(d[1],d[2])*0.5;
	printf("%.10Lf\n",ans);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
m = -1 * 10 ** 9 
for i in range(1, n+1):
    place = p[i-1]
    sm = [c[place-1]]
    while place != i:
        place = p[place-1]
        sm += [c[place-1] + sm[-1]]

    if len(sm) < k:
        m = max(m, 
            max(max(sm), 
                sm[-1] * ((k-1) // len(sm)) + sm[min((k-1) % len(sm), sm.index(max(sm)))]
                )
        )
    else:
        for j in range(k):
            m = max(m, sm[j])

print(m)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, K; cin >> N >> K;
  ll A[N]; rep(i,N) { cin >> A[i]; A[i]--; A[i]%=K; }
  ll sum[N+1]={}; rep(i,N) sum[i+1] = (sum[i] + A[i])%K;
  map<ll, ll> mo;

  ll result = 0;
  rep(i,N+1) {
    if (i>=K) mo[sum[i-K]]--;
    result += mo[sum[i]];
    mo[sum[i]]++;
    // cout << result << endl;
  }
  
  // for (auto x: mo) cout << x.first << "->" << x.second << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;


int main(void) {
    vector<pair<int, int> >menu(5);
    for(int i = 0; i < 5; i++) {
        cin >> menu[i].second;
        menu[i].first = menu[i].second % 10;
    } 
    int min_mod = 500;
    int last = 0;
    for(int i = 0; i < 5; i++) {
        if(menu[i].first < min_mod && menu[i].first != 0) {
            last = i;
            min_mod = menu[i].first;
        }
    } 
    int time = 0;
    for(int i = 0; i < 5; i++) {
        if(i == last) {
            time += menu[i].second;
        } else if (menu[i].first == 0){
            time += menu[i].second;
        } else {
            int a = menu[i].second - menu[i].first + 10;
            time += a;
        }
    }
    
    cout << time << endl;
    return 0;
    
}

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

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> a(N+1, vector<int>(2));
  int flag = 0;
  int i = 1;
  int count = 1;
  
  for(int i=1; i<N+1; i++)
  {
    cin >> a.at(i).at(0);
    a.at(i).at(1) = 0; //non-visited
  }
  
  do
  {
    if(a.at(i).at(0) == 2)
    {
      flag = 1;
      break;
    }
    else if(a.at(i).at(1) == 1) //すでに訪れましたよ
    {
      break;
    }
    a.at(i).at(1) = 1;
    count++;
    i = a.at(i).at(0);
  }while(a.at(i).at(0) != 1);
  
  if(flag == 0) cout << -1 << endl;
  else cout << count << endl;
}
    
  

Measured memory_bytes: 8796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int Count = 0;
  if(A == B) {
    Count++;
  }
  if(A == C) {
    Count++;
  }
  if(B == C) {
    Count++;
  }
  if(Count == 1) {
    cout << "Yes" << endl;
  }
  if(Count != 1) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
#define INFTY 1<<29
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 10000007;
// static const int MAX = 100005;
static const int NMAX = 1005;
static const int KEY = 4096;


// typedef priority_queue<int, greater<int>> RevQ;
int N, M;
int a, b;
vector<int> q[NMAX], p(NMAX), C(NMAX);


// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }

int main(){
  cin >> a >> b;
  cout << max(0, a - 2*b) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
double x[210];
double y[210];
double ABS(double a){return max(a,-a);}
double EPS=1e-9;
double PI=acos(-1.0);
double th[210];
int main(){
  int w,h,a;
  while(scanf("%d%d%d",&w,&h,&a),a){
    for(int i=0;i<2*a;i++)scanf("%lf%lf",x+i,y+i);
    x[2*a]=w;
    y[2*a]=0;
    x[2*a+1]=w;
    y[2*a+1]=h;
    vector<double>v;
    for(int i=0;i<2*a+2;i++)for(int j=i+1;j<2*a+2;j++){
	if(ABS(x[i]-x[j])<EPS)continue;
	double tmp=y[i]-x[i]*(y[i]-y[j])/(x[i]-x[j]);
	if(tmp<0||tmp>h)continue;
	v.push_back(tmp);
      }
    v.push_back(0);
    v.push_back(h);
    std::sort(v.begin(),v.end());
    double ret=0;
    for(int i=0;i<v.size()-1;i++){
      if(v[i+1]-v[i]<EPS)continue;
      double M=(v[i]+v[i+1])/2;
      for(int j=0;j<2*a+2;j++)th[j]=atan2(y[j]-M,x[j]);
      std::sort(th,th+2*a+2);
      if(th[a]<-PI/2+EPS)th[a]+=EPS;
      if(th[a+1]<-PI/2+EPS)th[a+1]+=EPS;
      if(th[a]>PI/2-EPS)th[a]-=EPS;
      if(th[a+1]>PI/2-EPS)th[a+1]-=EPS;
			
      double L=max(0.0,M+w*tan(th[a]));
      double R=min((double)h,M+w*tan(th[a+1]));
      ret+=max(0.0,R-L)*(v[i+1]-v[i]);
    }
    printf("%.12f\n",ret/h/h);
  }
}

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

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i <= n; i++) {
        int j = n - i;
        if (s.substr(i, j) == t.substr(0, j)) {
            cout << n + i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(), Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n,q) = input!(usize, usize);
    let (s,) = input!(String);

    let mut cumulative_sum = vec![];

    let mut a = false;
    let mut total = 0;

    for (i, c) in s.char_indices() {
        match c {
            'A' => {
                a = true;
            },
            'C' => {
                if a {
                    total += 1;
                }
                a = false;
            },
            _ => {
                a = false;
            },
        }
        cumulative_sum.push(total);
    }

    for i in 0..q {
        let (l, r) = input!(u32, u32);
        let (l, r) = (l-1, r-1);
        println!("{}", cumulative_sum[r as usize] - cumulative_sum[l as usize]);
    }

}

fn main() {
    solve();
}


Measured memory_bytes: 4860
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int A = int.Parse(str[1]);
		int B = int.Parse(str[2]);
		int C = int.Parse(str[3]);
		long a1 = 1;
		long a2 = 1;
		long mod = 1000000007;
		long S = 0;
		long[]NS = new long[200010];
		long[]NA = new long[200010];
		NS[0] = 1;
		NA[0] = 1;
		for(var i=1;i<200010;i++){
			NS[i] = NS[i-1] * i % mod;
			NA[i] = NA[i-1] * Mpow(i,mod-2,mod) % mod;
		}
		for(var i=N-1;i<=(N-1)*2;i++){
          	long c1 = NS[i] * NA[N-1] % mod * NA[i-(N-1)] % mod;
          	long a0 = A * 100 * Mpow(A+B,mod-2,mod) % mod * Mpow(100,mod-2,mod) % mod;
          	long b0 = B * 100 * Mpow(A+B,mod-2,mod) % mod * Mpow(100,mod-2,mod) % mod;
          	long d1 = Mpow(a0,N,mod) % mod * Mpow(b0,i+1-N,mod) % mod;
          	long d2 = Mpow(a0,i+1-N,mod) % mod * Mpow(b0,N,mod) % mod;
          	S = (S + (i+1) * c1 % mod * (d1 + d2) % mod) % mod;
		}
      	S = S * 100 % mod * Mpow(A+B,mod-2,mod) % mod;
		Console.WriteLine(S);
	}
	
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
}

Measured memory_bytes: 14048
def main():
    S = list(input())
    T = list(input())


    anss = []
    for i in range(max(0, len(S)-len(T)+1)):
        ans = ""
        for j in range(i):
            if S[j] == "?":
                ans += "a"
            else:
                ans += S[j]

        for j in range(i, i+len(T)):
            if S[j] == T[j-i]:
                ans += S[j]
            elif S[j] == "?":
                ans += T[j-i]
            else:
                break

        for j in range(i+len(T), len(S)):
            if S[j] == "?":
                ans += "a"
            else:
                ans += S[j]

        if len(ans) == len(S):
            anss.append(ans)

    if len(anss):
        print(min(anss))
    else:     
        print("UNRESTORABLE")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int n, ans = 1, flag = 0; cin >> n;
    int a[n];
    For(i, 0, n) cin >> a[i];
    For(i, 1, n) {
        For(j, 0, i) {
            if(a[i] >= a[j]) flag = 1;
            else {flag = 0; break;}
        }
        if(flag) ans++;
    }

    cout << ans;

    
    
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    long long n,m;std::cin>>n>>m;
    std::vector<std::vector<int>>g(2*n);
    for(int i=0;i<m;i++){
        int u,v;std::cin>>u>>v;u--,v--;
        g.at(u).push_back(v+n);
        g.at(v).push_back(u+n);
        g.at(u+n).push_back(v);
        g.at(v+n).push_back(u);
    }
    std::vector<int>ckd(2*n);
    std::queue<int>que;
    que.push(0);
    while(!que.empty()){
        int x=que.front();que.pop();
        ckd.at(x)=true;
        for(int y:g.at(x)){
            if(ckd.at(y))continue;
            que.push(y);
        }
    }
    long long k=std::accumulate(ckd.begin(),ckd.begin()+n,0ll);
    std::cout<<(ckd.at(n)?n*(n-1)/2:k*(n-k))-m<<'\n';
}


Measured memory_bytes: 12160
n, m = map(int, input().split())
not_broken = [True] * (n + 1)
for i in range(m):
    not_broken[int(input())] = False
dp = [1, 1] + [0] * (n - 1)
for i in range(2, n + 1):
    if not_broken[i]:
        if not_broken[i - 1]:
            dp[i] += dp[i - 1]
        if not_broken[i - 2]:
            dp[i] += dp[i - 2]
print(dp[n] % 1000000007)

Measured memory_bytes: 463460
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]


def dfs(x):
    if len(x) == N + 1:
        res = 0
        for a, b, c, d in X:
            if x[b] - x[a] == c:
                res += d
        return res

    res = 0
    for i in range(max(1, x[-1]), M + 1):
        x.append(i)
        res = max(res, dfs(x))
        x.pop()

    return res


print(dfs([0]))


Measured memory_bytes: 80248
#include<bits/stdc++.h>
using namespace std;
typedef  long long   ll;
ll inf=1000000000000000000,mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        ll n,m;cin>>n>>m;vector<ll> arr[n];ll ans[n];
        for(ll i=0;i<n;i++)cin>>ans[i];ll a,b;
        for(ll i=0;i<m;i++){
            cin>>a>>b;a--;b--;
            arr[a].push_back(b);
            arr[b].push_back(a);
        }
        ll sum=0;
        for(ll i=0;i<n;i++){
            ll ma=0;
            for(ll j=0;j<arr[i].size();j++){
                ma=max(ma,ans[arr[i][j]]);
            }
            if(ans[i]>ma)sum++;
        }
        cout<<sum;
}


Measured memory_bytes: 10236
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


N = inp()
for nnnnnnn in range(N):
    S = input()
    stacks = [[] for _ in range(10000)]
    num = ''
    d = 0
    for s in S:
        if s == '[':
            d += 1
        elif s == ']':
            if num != '':
                num = int(num)
                stacks[d-1].append(num//2+1)
                num = ''
            else:
                stacks[d].sort()
                L = len(stacks[d])
                stacks[d-1].append(sum(stacks[d][:L//2+1]))
                stacks[d] = []
            d -= 1
        else:
            num = num + s
    print(stacks[0][0])



Measured memory_bytes: 8740
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 105000;
const int INF = (int) 1e9;

int n, k;
int h[MAXN];
int dp[MAXN];

int main() {

  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
     scanf("%d", &h[i]);
     dp[i] = INF;
  } 

  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i + j < n) {
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
      }
    }
  }

  cout << dp[n - 1] << endl;

  return 0;
}


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

string s;
vector<char> ans;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			ans.push_back('0');
		}
		else if (s[i] == '1') {
			ans.push_back('1');
		}
		else {
			if (!ans.empty()) {
				ans.pop_back();
			}
		}
	}

	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i];
	}
	cout << '\n';

	return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min(n, b - 1);
    cout << (a * x / b) - (a * (x / b)) << endl;
}


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

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

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ok = 0;
  for (int i = 0; i < k; i++) {
    if (a >= b) {
      b *= 2;
      continue;
    }
    if (b >= c) {
      c *= 2;
      continue;
    }
    if (a < b && b < c) {
      ok = true;
      break;
    }
  }
  if (a < b && b < c) {
    ok = true;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3628
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n){
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
    string s;
    cin >> s;
    int cnt= 0;
    char start = s[0];
    int j = 1;
    while(j < s.size()){
        if(s[j] == start){
            while(j < s.size() && s[j] == start){
                j++;
            }
        }
        else{
            start = s[j];
            cnt+=1;
            j++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
asum=0
for i in range(n):
    asum+=a[i]
    asum%=mod
ans=0
#print(asum)
for i in range(n):
    asum-=a[i]
    ans+=asum*a[i]
    ans%=mod
print(ans)

Measured memory_bytes: 94184