akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< VI > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;

template < typename T > inline void input_n( vector< T > &out ) { copy_n( istream_iterator< T >( cin ), out.size(), out.begin() ); };
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) (c).begin(), (c).end()
#define AALL( a, t ) (t*)a, (t*)a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define EM( n ) emplace( n )
#define EB( n ) emplace_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

struct Food
{
	int id;
	string name;
	double w, s;

	Food( const int id, const string &name, const int w, const int s ) :
		id( id ), name( name ), w( w ), s( s )
	{
		return;
	}

	bool operator<( const Food &rhs ) const
	{
		return id < rhs.id;
	}
};

double center( const vector< Food > &foods )
{
	const int N = foods.size();

	for ( int i = N - 1, sum = 0; 0 <= i; sum += foods[ i-- ].w )
	{
		if ( foods[i].s < sum )
		{
			return numeric_limits< double >::max();
		}
	}

	double g = 0, ss = 0;
	REP( i, 0, N )
	{
		g += ( i + 1 ) * foods[i].w;
		ss += foods[i].w;
	}

	return g / ss;
}


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

	for ( int n; cin >> n, n; )
	{
		vector< Food > foods;

		REP( i, 0, n )
		{
			string f;
			int w, s;
			cin >> f >> w >> s;

			foods.emplace_back( i, f, w, s );
		}

		double ming = numeric_limits<double>::max();
		vector< Food > res;

		do
		{
			const double g = center( foods );
			if ( g < ming )
			{
				res = foods;
				ming = g;
			}
		}
		while ( next_permutation( ALL( foods ) ) );

		FOR( r, res )
		{
			cout << r.name << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-
X, K, D = map(int, input().split())
if abs(X) > K*D:
    res = abs(X) - K*D
else:
    q, r = divmod(abs(X), D)
    if (K - q)%2==0:
        res = r
    else:
        res = D - r
print(res)


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


int main(){
    long long n;
    string s;

    cin >> n;
    cin >> s;

    vector<long long> white_sum(n+1, 0);
    vector<long long> black_sum(n+1, 0);

    for(long long i = 0; i < n; i++){
        if(s[i] == '.'){
            white_sum[i+1] = white_sum[i] + 1;
        }
        else{
            white_sum[i+1] = white_sum[i];
        }

        if(s[i] == '#'){
            black_sum[i+1] = black_sum[i] + 1;
        }
        else{
            black_sum[i+1] = black_sum[i];
        }
    }

    long long minv = 1e9;
    for(long long left = 0; left <= n; left++){
        long long tmp = 0;
        tmp += black_sum[left] - black_sum[0];
        tmp += white_sum[n] - white_sum[left];

        minv = min(minv, tmp);
    }
    cout << minv << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int mx = 1000010;
  vector<bool> isp(mx,true);
  isp[0]=false;
  isp[1]=false;
  REP(i,mx){
    if(isp[i]==false)continue;
    int t = i*2;
    while(t<mx){
      isp[t] = false;
      t += i;
    }
  }
  vector<int> sum(mx,0);
  REPR(i,mx) sum[i] = sum[i-1] + isp[i];
  int n;
  while(~scanf("%d",&n))cout<<sum[n]<<endl;
  return 0;
}

Measured memory_bytes: 5164
#include<iostream>
#include<string>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
  int n,a[111],ans=0;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  for(int i=n-1;i>=0;i-=2)
    ans+=a[i];
  for(int i=n-2;i>=0;i-=2)
    ans-=a[i];
  cout<<ans;
  return 0;
}

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

int abs(int a){
  if(a  < 0)
    return -a;
  else
    return a;
}
    

int main(){
  int N;
  cin >> N;
  vector<int> W(N);

  for(int i = 0; i < N; i++){
    int val;
    cin >> val;
    if(i == 0)
      W[i] = val;
    else
      W[i] = W[i-1] + val;
  }
  int diff = 200;                                 //差の最高値はW[i]の上限200
  for(int i = 0; i < N; i++){
    int S1 = W[i];
    int S2 = W[N-1] - W[i];
    if(diff > abs(S1-S2))
      diff = abs(S1-S2);
    if(diff == 0)                                   //もっと計算量を少なくできそうだが面倒 0のときだけ
      break;
  }

  cout << diff << endl;
  return 0;

}


Measured memory_bytes: 256
# Aizu Problem 0085: Joseph's Potato
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


def josephus_survivor(n,k):
    people = list(range(1, n+1))
    current = (k - 1) % n
    while len(people)> 1:
        removed = people.pop(current)
        current = (current + k - 1) % len(people)
    return people[0]

while True:
    n, m = [int(_) for _ in input().split()]
    if n == m == 0:
        break
    print(josephus_survivor(n, m))
          
            

Measured memory_bytes: 7768
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

struct tri
{
    int t,s,d;
    bool operator<(const tri& another) const {
        return t < another.t;
    }
};

class UF {
private:
    int sz; vector<int> par,nrank,size;
public:
    UF(){}
    UF(int node_size){ sz = node_size; par.resize(sz),nrank.resize(sz),size.resize(sz);
        rep(i,sz){ par[i] = i; nrank[i] = 0; size[i] = 1;} }
    int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } }
    void unite(int x,int y)
    { x = find(x),y = find(y); if(x == y) return; if(nrank[x] < nrank[y]) swap(x,y);
        par[y] = x; size[x] += size[y]; if(nrank[x] == nrank[y]) nrank[x]++; }
    int query(int x){ x = find(x); return size[x]; }
    bool same(int x,int y){ return find(x) == find(y); }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0){
            break;
        }
        vector<tri> vec(m);
        rep(i,m){
            int t,s,d;
            cin >> t >> s >> d;
            s--,d--;
            vec[i] = (tri){t,s,d};
        }
        sort(all(vec));
        UF uf(n);
        rep(i,m){
            if(uf.same(0,vec[i].s)){
                uf.unite(0,vec[i].d);
            }
        }
        cout << uf.query(0) << endl;
    }
    return 0;
}

Measured memory_bytes: 3396
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
    int l,j;
    char str[200];
    scanf ("%[^\n]",str);
    l=strlen(str);
    for (j=0; j<l; j++)
    {
        printf ("%c",toupper(str[j]));
    }
    printf ("\n");
    return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    vector<int> n(4);
    string s = "";
    for(int i = 0; i < 4; i++){
        cin >> n[i];
        s += to_string(n[i]);
    }
    sort(begin(s), end(s));
    cout << (s == "1479"? "YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int n, k;
    string s;
    cin >> n >> s >> k;
    char target = s[k-1];
    for(size_t i = 0; i < s.size(); i++)
    {
        if(s[i] == target)continue;
        else s[i] = '*';
    }
    cout << s << endl;
     
    return 0;
}

Measured memory_bytes: 256
n = int(input())
dic = {}
b = []
for i in range(n):
    a = input()
    b.append(a)
for o in b:
    if o in dic:
        dic[o] += 1
    else:
        dic[o] = 1
M = max(dic.values())
for j,k in sorted(dic.items()):
    if k == M:
        print(j)


Measured memory_bytes: 45712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
// constexpr int MOD = 1e9+7;
 
unordered_map<int, int> factors(ll n){
    unordered_map<int, int> d;
    for(ll i = 2; i*i <= n; i ++) while(n % i == 0) d[i] ++, n /= i;
    if(n > 1) d[n] ++;
    return d;
}

int main(void){
    Cin(ll, n);
    const auto d = factors(n);
    int ans = 0;
    for(auto [i, c] : d){
        for(int j = 1; c >= j; j ++){
            c -= j;
            ans ++;
        }
    }
    Cout(ans);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,p;
    string s;
    cin>>n>>p>>s;
    vector<int>v;
    for(int i=n-1;i>=0;i--)
        v.push_back(s[i]-'0');
    if(p==2||p==5){
        int ans=0;
        for(int i=0;i<n;i++)
            if(v[i]%p==0)
                ans+=n-i;
        cout<<ans<<endl;
    }else{
        int arr[200000];
        arr[0]=1;
        for(int i=1;i<n;i++)
            arr[i]=arr[i-1]*10%p;
        for(int i=0;i<n;i++)
            (arr[i]*=v[i])%=p;
        int arr2[10000]={};
        int sum=0;
        for(int i=0;i<n;i++){
            (sum+=arr[i])%=p;
            arr2[sum]++;
        }
        int ans=sum=0;
        for(int i=0;i<n;i++){
            ans+=arr2[sum];
            (sum+=arr[i])%=p;
            arr2[sum]--;
        }
        cout<<ans<<endl;
    }
}


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

#define int long long

main() {
    int sum = 1, ans = 1;
    int n, k; cin >> n >> k;
    while (sum < n) {
        int need = sum / k;
        if (sum % k) need++;
        if (n - sum < need) break;
        sum += need;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
long long binpow(long long a,long long b)
{
    if (b == 1) return a;
    long long res = binpow(a, b/2)%MOD;
    if (b % 2) return (res*((res*a)%MOD))%MOD;
    else return (res * res)%MOD;
}

long long int fact(long long int a)
{
    if(a==0||a==1)
        return 1;
    long long int ans = 1;
    for(int i=a;i>=1;i--)
        ans = (ans * i)% MOD;
    return ans;
}

long long int ivmod(long long int a)
{
    return binpow(a,MOD-2);
}
 
long long int summ[1000005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    long long int n;
    cin>>n;
    vector<long long int> maxx;
    for(long long int i=1;i<=100002;i++)
    {
        if(n%i==0&&i<=n)
        {
            long long int temp = max(i,n/i);
            maxx.push_back(temp);
        }
    }
    long long int minn =9999999999;
    for(int i=0;i<maxx.size();i++)
    {
        minn = min(minn,maxx[i]);
    }
    long long int maxxx = minn;
    int finale = 0;
    while(maxxx)
    {
        finale++;
        maxxx/=10;
    }
    cout<<finale<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    """ ????????? """
    istr = sys.stdin.read()
    wi = istr.splitlines()
    for i in wi:
        a, b, c, d, e, f = list(map(int,i.split()))
        z = (a * e - b * d)
        x = round((c * e - b * f) / z, 3) + 0.0
        y = round((a * f - c * d) / z, 3) + 0.0
        print("{0:.3f} {1:.3f}".format(x,y))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7688
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B, C, K;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B >> C >> K;

	int ans = 0;

	int get = min(A, K);
	ans += get;
	K -= get;

	get = min(B, K);
	K -= get;

	get = min(C, K);
	ans -= get;
	
	cout << ans << endl;
}







Measured memory_bytes: 3648
#!/usr/bin/env python3
N = int(input())
S = [input() for _ in range(N)]
cnt = [[0] * N for _ in range(26)]
for i in range(N):
    for j in S[i]:
        cnt[ord(j) - 97][i] += 1
ans = []
for i in range(26):
    num = min(cnt[i])
    for j in range(num):
        ans.append(chr(97 + i))
ans.sort()
print("".join(ans))


Measured memory_bytes: 64432
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}


int A[20];
int B[20];
int C[20];

int main()
{
  int cnt;
  int64 N;
  int64 i;
  int result = 0;

  get_N(&N);

  for (i=0; i<N; i++){
    cnt = scanf("%d", &A[i]);
  }

  for (i=0; i<N; i++){
    cnt = scanf("%d", &B[i]);
  }

  for (i=1; i<N; i++){
    cnt = scanf("%d", &C[i]);
  }

#if 0
  for (i=0; i<N; i++){
    printf("%d A=%d B=%d C=%d\n", i, A[i], B[i], C[i]);
  }
#endif

  for (i=0; i<N; i++) {
    result += B[A[i]-1];
    if (i==0) continue;
    if ((A[i]- 1) == (A[i - 1])) {
      result += C[A[i]-1];
    }
  }

  printf("%d", result);

  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

const int dx[]={-1,-1,-1,0,0,0,1,1,1},dy[]={-1,0,1,-1,0,1,-1,0,1};
map<pint,ll> t;
vector<ll> vi(10,0);
int main(){
    ll h,w,n,ai,bi;
    cin>>h>>w>>n;
    rep(i,n){
        cin>>ai>>bi;
        --ai,--bi;
        rep(j,9){
            int ty=ai+dy[j],tx=bi+dx[j];
            if(tx>=1&&ty>=1&&tx<w-1&&ty<h-1){
                ++t[mp(tx,ty)];
            }
        }
    }
    for(auto it:t){
        if(it.second>=0&&it.second<=9){
            ++vi[it.second];
        }
    }
    vi[0]=(h-2)*(w-2)-(ll)t.size();
    for(auto it:vi) cout<<it<<endl;
    return 0;
}

Measured memory_bytes: 56448
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define INF (1LL << 61)
#define MAXN (400410)
#define N (1 << 17)

ll tt[N + N];

ll mymin(int l, int r) {
	ll ret = INF;
	l += N;
	r += N;
	while (l <= r) {
		ret = min(ret, tt[l]);
		ret = min(ret, tt[r]);
		l++;
		l >>= 1;
		r--;
		r >>= 1;
	}
	return ret;
}

void myup(int pos, ll val) {
	pos += N;
	while (pos) {
		tt[pos] = min(tt[pos], val);
		pos >>= 1;
	}
}


struct edge {
	int l, r, c;

	edge(int tl = 0, int tr = 0, int tc = 0) {
		l = tl;
		r = tr;
		c = tc;
	}

	void read() {
		cin >> l >> r >> c;
		l--;
		r--;
	}

	bool operator<(const edge & e) const {
		return (l < e.l);
	}

	void print() {
		cerr << l << " " << r << " " << c << endl;
	}
};

int n, m;

edge a[MAXN];
ll ans[MAXN];


int main() {
	for (int i = 0; i < MAXN; i++) {
		ans[i] = INF;
	}
	for (int i = 0; i < N + N; i++) {
		tt[i] = INF;
	}
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		a[i].read();	
	}
	sort(a, a + m);
	ans[0] = 0;
	myup(0, 0);
	int curedge = 0;
	for (int i = 0; i < n; i++) {
		ll & curdist = ans[i];
		curdist = mymin(i, n - 1);
		//cerr << curdist << endl;
		if ((curedge >= m) || (a[curedge].l > i)) {
			continue;
		}
		while ((curedge < m) && (a[curedge].l == i)) {
			myup(a[curedge].r, curdist + a[curedge].c);
			curedge++;
		}
	}
	ll ret = ans[n - 1];
	if (ret == INF) {
		cout << -1 << endl;
	} else {
		cout << ret << endl;
	}

	return 0;
}


Measured memory_bytes: 13508
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
using namespace std;

int H;
vector<int> A;

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

void maxHeapify(int i) {
  int l = left(i);
  int r = right(i);

  int largest;
  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= H && A[r] > A[largest]) largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

void buildMaxHeap() {
  rep1R(i, H / 2) maxHeapify(i);
}

int main() {
  cin >> H;
  A.resize(H + 1);
  rep1(i, H) cin >> A[i];
  buildMaxHeap();
  rep1(i, H) cout << " " << A[i];
  cout << endl;
  return 0;
}



Measured memory_bytes: 4572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);
            int iC = int.Parse(sS[2]);
            int iD = int.Parse(sS[3]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;                                                           // 場合分け6パターン
            if (iB <= iC) { }                                                       // 重なりなし
            if (iA <= iC && iC <= iB && iB <= iD)             { iOut = iB - iC; }   // 重なりあり
            if (iA <= iC && iC <= iB && iA <= iD && iD <= iB) { iOut = iD - iC; }   // 含有
            if (iD <= iA) { }                                                       // 重なりなし
            if (iC <= iA && iA <= iD && iD <= iB)             { iOut = iD - iA; }   // 重なりあり
            if (iC <= iA && iA <= iD && iC <= iB && iB <= iD) { iOut = iB - iA; }   // 含有

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

int main(){

  string str[1111];
  int n;
  int i = 0;

  while(cin >> n){

    int ncp = n;


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

    int dotcnt[1111] = {0};
    for(int i = 0; i < n; i++){
      for(int j = 0; j < (int)str[i].size(); j++){
	if(str[i][j] == '.'){
	  dotcnt[i]++;
	} 
      }
    }

    for(int i = n-1; i > 0; i--){
      for(int j = i-1; j >= 0; j--){
	if(dotcnt[i] < dotcnt[j]){
	  str[j][dotcnt[i]-1] = '|';
	}else break; 
      }
    }

    for(int i = 0; i < n; i++){
      for(int j = 0; j < (int)str[i].size(); j++){
	if(str[i][j] == '.' && str[i][j+1] != '.' && str[i][j+1] != '|' && str[i][j+1] != ' '){
	  str[i][j] = '+';
	}else if(str[i][j] == '.' && str[i][j] != '|' && str[i][j] != '+'){
	  str[i][j] = ' ';
	}
      }
    }

    for(int i = 0; i < n; i++){

      cout << str[i] << endl;

    }

  }



}

Measured memory_bytes: 1992
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = Integer.parseInt(stdIn.next());
        int[] a = new int[n];
        int[][] x = new int[n][];
        int[][] y = new int[n][];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(stdIn.next());
            x[i] = new int[a[i]];
            y[i] = new int[a[i]];
            for (int j = 0; j < a[i]; j++) {
                x[i][j] = Integer.parseInt(stdIn.next());
                y[i][j] = Integer.parseInt(stdIn.next());
            }
        }

        int ans = 0;
        for (int i = 0; i < Math.pow(2, n); i++) {
            boolean ok = true;
            for (int j = 0; j < n; j++) {
                if (((i >> j) & 1) == 1) {
                    for (int k = 0; k < a[j]; k++) {
                        if (((i >> x[j][k] - 1) & 1) != y[j][k]) {
                            ok = false;
                        }
                    }
                }
            }
            if (ok) {
                ans = Math.max(ans, Integer.bitCount(i));
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
string lcs(string &s,string & S){
	int n=s.size(),m=S.size();
	int dp[n+1][m+1];
	for(int i=0;i<=n;++i){
		for(int j=0;j<=m;++j){
			if(i==0||j==0) dp[i][j]=0;
			else if(s[i-1]==S[j-1]) dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	//for(int i=0;i<=n;++i){
	//	for(int j=0;j<=m;++j) cout<<dp[i][j]<<" ";
	//	cout<<"\n";
	//}
	int i=n,j=m;
	string res="";
	while(i>=1&&j>=1){
		if(s[i-1]==S[j-1]){
			res.push_back(s[i-1]);
			--i;
			--j;
		}
		else if(dp[i][j-1]>=dp[i-1][j]) --j;
		else --i;
	}
	reverse(res.begin(),res.end());
	//cout<<"\n"<<res;
	return res;
}
int main(){
	nes;
	string s,S;
	cin>>s>>S;
	cout<<lcs(s,S);
	return 0;
}

Measured memory_bytes: 38760
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <float.h>
using namespace std;

int main()
{
	int q;
	
	cin >> q;
	while( q-- ) {
		long long a,b;

		cin>> a >> b;

		if(a > b) {
			swap(a, b);
		}

		long long ans;
		if( b - a <= 1 ) {
			ans = 2 * (a-1);
		}
		else {
			long long c = sqrt( a * b );
			ans = 2*c - 1;
			if( c*(c+1) >= a*b ) {
				ans--;
			}
			if( c*c >= a*b ) {
				ans--;
			}
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
A = [[int(j) for j in input().split()] for i in range(n)]
for j in range(m):
    b = int(input())
    for i in range(n):
        A[i][j] *= b
        
for row in A:
    print(sum(row))
    


Measured memory_bytes: 6016
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
		{
			ar[i]=scan.nextInt();
		}
		Arrays.parallelSort(ar);
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n-k+1;i++)
		
		{
			min=Math.min(min,ar[i+k-1]-ar[i]);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 50484
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll x; cin >> x;
  if(x<1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,sum=0;
	cin>>a>>b;
	if(a*2>b){
		sum=floor(b/2.0);
	}
	else{
		sum=a+floor((b-a*2)/4.0);
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

bool cmp(Pll a, Pll b)
{
    if(a.second == b.second) return a.first < b.first;
    return a.second < b.second;
}

int main()
{
    int N;
    cin >> N;
    vector<Pll> LR(N);
    for(int i=0; i<N; i++) cin >> LR[i].first >> LR[i].second;

    sort(LR.begin(), LR.end(), cmp);
    vector<ll> lL(N), rL(N);
    lL[0] = LR[0].first;
    rL[N-1] = LR[N-1].first;
    for(int i=1; i<N; i++){
        lL[i] = max(LR[i].first, lL[i-1]);
    }
    for(int i=N-2; i>=0; i--){
        rL[i] = max(LR[i].first, rL[i+1]);
    }

    ll ans = 0;
    for(int i=0; i<N-1; i++){
        ll s1 = max((ll)0, LR[0].second - lL[i] + 1);
        ll s2 = max((ll)0, LR[i+1].second - rL[i+1] + 1);
        ans = max(ans, s1 + s2);

        if(i==0) continue;
        ll l = max(lL[i-1], rL[i+1]);
        ll s3 = max((ll)0, LR[0].second - l + 1);
        ll s4 = max((ll)0, LR[i].second - LR[i].first + 1); 
        ans = max(ans, s3 + s4);
    }
    ll s1 = max((ll)0, LR[0].second - LR[0].first + 1);
    ll s2 = max((ll)0, LR[1].second - rL[1] + 1);
    ans = max(ans, s1 + s2);

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

const int N = 1e5 + 3;
int n, k;
int x[N];
stack<int> neg;
vector<int> pos;
int z = -1, ans = INT_MAX;

void input() {
  scanf("%d %d", &n, &k);
  forn(i, 0, n) {
    scanf(" %d", &x[i]);
  }
}

void solve() {
  int s = (int)pos.size();
  int first = x[0];
  forn(i, 0, n) {
    if (i >= k - 1) {
      first = x[i - k + 1];

      if (first < 0 && x[i] > 0) {
        if (abs(first) < x[i]) {
          ans = min(ans, 2 * abs(first) + x[i]);
        } else {
          ans = min(ans, abs(first) + 2 * x[i]);
        }
      } else if (first < 0) {
        ans = min(ans, abs(first));
      } else {
        ans = min(ans, x[i]);
      }
    }
  }
  printf("%d\n", ans);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
//  freopen("output", "w", stdout);
//  gen();
#endif
  input();
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n; cin >> n;
  vector<int> a(n + 1), b(n);
  rep (i, n + 1) cin >> a[i];
  rep (i, n) cin >> b[i];

  ll cnt = 0;
  int dis = 0;
  rep (i, n) {
    if (dis < a[i]) {
      a[i] -= dis;
      cnt += dis;
    } else {
      cnt += a[i];
      a[i] = 0;      
    }
    dis = 0;

    
    if (b[i] > a[i]) {
      cnt += a[i];
      dis = b[i] - a[i];
    } else cnt += b[i];

    if (i == n - 1) cnt += min(dis, a[i + 1]);
  }
  

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n,k;cin>>n>>k;
  ll ans=k;
  rep(i,n-1){
    ans*=(k-1);
  }
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;

int main(){
    int N;
    string S;
    cin >> S;
    N = S.size();
    int cnt[2] = {0,0};
    rep(i,N) {
        if(S[i]=='0') cnt[0]++;
        if(S[i]=='1') cnt[1]++;
    }
    cout << 2*MIN(cnt[0],cnt[1]);
 	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
int main ()
{
    int n,k,N[100000],ans,sum;
    while(1){
        scanf("%d%d",&n,&k);
        if(n==0&&k==0)break;
        sum=0;
        for(int i=0;i<n;i++){
            scanf("%d",&N[i]);
            if(i<k) sum+=N[i];
        }
        ans=sum;
        for(int i=k;i<n;i++){
            sum=sum+N[i]-N[i-k];
            if(ans<sum) ans=sum;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1420
#include <stdio.h>

int main(void){
    char x[1001];
    int i,s;

    while(1){
        gets(x);
        if(x[0]=='0') break;
        
        i=0;
        s=0;
        while(x[i]!='\0'){
            s+=x[i]-'0';
            i++;
        }

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

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

typedef pair<ll, ll> pll;
// const ll INF = (ll)1e18;

signed main() {
	int N;
	cin >> N;
	int f[N], p[N][10];
	REP(i, N) {
		f[i] = 0;
		REP(j, 10) {
			int t = 0;
			cin >> t;
			f[i] = (f[i] << 1) + t;
			// cout << t;
		}
		// cout << endl << f[i] << endl;
	}

	REP(i, N) {
		REP(j, 11) {
			cin >> p[i][j];
		}
	}

	int m = INT_MIN;
	FOR(i, 1, 1 << 10) {
		int sum = 0;
		int csum = 0;
		REP(j, N) {
			int t = f[j] & i;
			int c = 0;
			REP(k, 10) {
				c += (t >> k) & 1;
				// cout << ((t >> k) & 1);
			}
			// cout << endl << c << endl;
			csum += c;
			sum += p[j][c];
		}
		// cout << ":" << sum << endl;
		// cout << "C: " << csum << endl;
		// cout << "m: " << m << endl << endl;
		if (csum == 0) {
			continue;
		}

		m = max(sum, m);
	}
	cout << m << endl;
}


	// int N, C;
	// cin >> N >> C;
	// int s[N], t[N], c[N];
	// for (size_t i = 0; i < N; i++) {
	// 	cin >> s[i] >> t[i] >> c[i];
	// }


Measured memory_bytes: 256
function main(input) {
  const n = parseInt(input[0]);

  const tag = {"AC":0,"WA":0,"TLE":0,"RE":0}

  for(let i=0;i<n;i++){
    let a = input[i+1];
    tag[a]=tag[a]+1;
  }
  for (let value of Object.keys(tag)) {
    console.log(value+" x "+tag[value])
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 37252
// Contest No.: ABC176
// Problem No.: A
// Solver:      Jinmin Goh
// Date:        20200822

#include <cstring>
#include <iostream>
#include <cstdlib>
#include <list>
#include <array>
#include <atomic>
#include <algorithm>
#include <deque>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <valarray>
#include <vector>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int nums[100010];

int main() {
    int n, x, t, ans;
    scanf("%d %d %d", &n, &x, &t);

    printf("%d", ((n + x - 1) / x) * t);

    return 0;
}

Measured memory_bytes: 3800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        string[] s = new string[n];
        for (int i = 0; i < n; i++)
        {
            s[i] = sc.Next();
        }

        int m = sc.NextInt();
        string[] t = new string[m];
        for (int i = 0; i < m; i++)
        {
            t[i] = sc.Next();
        }

        Dictionary<string, int> dic = new Dictionary<string, int>();
        foreach (string str in s)
        {
            if (!dic.ContainsKey(str))
            {
                dic.Add(str, 0);
            }
            dic[str]++;
        }
        foreach (string str in t)
        {
            if (!dic.ContainsKey(str))
            {
                dic.Add(str, 0);
            }
            dic[str]--;
        }

        int answer = 0;
        foreach (var item in dic)
        {
            answer = Math.Max(answer, item.Value);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13152
def shuffle(card, h)
  card.slice(h..card.length) + card.slice(0, h)
end

loop do
  card = gets.chomp
  break if card == '-'

  count = gets.chomp.to_i
  count.times do
    card = shuffle(card, gets.chomp.to_i)
  end
  puts card
end

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int n;
  ll m;
  cin >> n >> m;
  vector<ll> a(m);
  ll sum = 0;
  rep(i,m) {
    cin >> a[i];
    sum += a[i];
  }
  if( sum <= n )  {
    cout << n - sum << endl;
  } else {
    puts("-1");
  }
		

  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>

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

using namespace std;
using namespace __gnu_pbds; 

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) 
#define boost ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
#define deb(x) debug() << imie(x)

const int MOD =  1e9 + 7;

int parent(vector <int> &dsu,int xx){
            
    if(xx != dsu[xx]){
        dsu[xx] = parent(dsu, dsu[xx]);
    }
    
    return dsu[xx];
}

void solve(){
    int n, m;
    cin >> n >> m;
    
    vector <int> dsu(n+1);
    vector <int> sum(n+1, 1);
    
    for(int i = 0; i <= n; ++i)
        dsu[i] = i;
    
    for(int i =0;i < m; ++i){
        int uu, vv;
        cin >> uu >> vv;
        
        int pre1 = parent(dsu, uu);
        int pre2 = parent(dsu, vv);
        
        if(pre1 != pre2){
            dsu[pre1] = pre2;
            sum[pre2] += sum[pre1];
        }
        
    }
    
    int ans = 0;
    
    for(int i = 1; i <= n; ++i)
        ans = max(ans, sum[i]);
        
    cout << ans;
    
    
}

int32_t main(){

	boost;

	int T;
	
	//cin >> T;
	 T = 1;
	
	for(int i = 1; i <= T; ++i){
		solve();
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 6360
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st= new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        HashSet<String> hs = new HashSet();
        while(n--!=0){
            hs.add(br.readLine());
        }
        System.out.println(hs.size());
        

    }
}

//10 3 10 3

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

int main() {
    long long int a,b,c;
    cin>>a>>b>>c;
    //instead of single for use sub method
    long long c1=0,c2=0;
    c1=a/c;
    c2=b/c;
    if(a%c==0)cout<<c2-c1+1<<endl;
    else cout<<c2-c1<<endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, d = list(map(int, readline().split()))

    while True:
        c -= b
        if c <= 0:
            print("Yes")
            break

        a -= d
        if a <= 0:
            print("No")
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 61696
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;




int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    long long ans = 0;
    long long last = 0;
    for (int i = 0; i + 1 < (int)s.size(); ++i) {
        if (s[i] == 'A') {
            ++last;
            continue;
        }
        if (s[i] == 'B' && s[i + 1] == 'C') {
            ans += last;
            ++i;
        } else last = 0;
    }
    cout << ans << '\n';
    return 0;
}



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

using namespace std;

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

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

  if(k<s.length()){
    for(int i=0;i<k;i++) cout << s[i];
    cout << "..." << endl;
  }else{
    cout << s << endl;
  }
  

}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 3000
long long sum;
int n,a;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
       scanf("%d",&a);
       sum+=a-1;
    }
    printf("%lld\n",sum);
}


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

int main() {
  int A, B, C;
 
  vector<int> v(3);
  for (int i = 0; i < 3; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
   
  cout << v.at(2)*10+v.at(1)+v.at(0) << endl;
  
}


Measured memory_bytes: 256