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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x, y;
string s;
ll res = 0;

// < ----------- func eh ---------------- ? //

void split(string s) {
	ll ans = 0;
	string word = "";
	for(auto ch : s) {
		if(ch == '+') {
			ans+=stoll(word);
			word = "";
		}
		else {
			word += ch;
		}
	}
	ans+=stoll(word);
	res+=ans;
}

void recur(ll i, string t ) {
	if(i == n) {
		split(t);
		return;
	} 
	recur(i+1,t + s[i]);
	recur(i+1,t + "+" + s[i]);
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s;
	n = s.length();
	recur(1,s.substr(0,1));
	cout<<res;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

using namespace std;
const int  NMAX = 10;


int main()
{
    int n;
    cin>>n;
    do{
        int c = n%10;
        if(c==7)
        {
            cout<<"Yes"<<"\n";
            return 0;
        }
        n = n/10;

    }while(n!=0);

    cout<<"No";
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}
// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

int64_t count(int *arr, int size, int attack, int64_t cum) {
    int i;
    int64_t cnt = 0;
    for(i = 0; i < size; i++) {
        int64_t hp = arr[i]-cum;
        if(hp<=0) continue;
        cnt += (hp-1)/attack + 1;
    }
#ifdef DEBUG
    printf("%lld -> cnt: %lld\n", cum, cnt);
#endif
    return cnt;
}

#define NUM_MAX 100000
int main(void) {
    int num, center, neigh;
    get_int3(&num, &center, &neigh);

    static int arr[NUM_MAX];
    fget_array(arr, num);

    int low = 0;
    int high = (1e+9)+1;
    while(low + 1 < high) {
        int64_t mid = (low + high) / 2;
        int64_t cum = (int64_t)mid * neigh;
        // lower bound; count maybe higher than INT_MAX if mid is too low
        if(count(arr, num, center-neigh, cum) <= mid) {
            high = mid;
        } else {
            low = mid;
        }
#ifdef DEBUG
        printf("mid: %d\n", mid);
#endif
    }

    printf("%d\n", high);

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int maxN = 87;
int32_t main(){
    SPEED;
    int h, w;
    cin >> h >> w;
    h += 2;
    w += 2;
    char mat[h][w];
    for(int i = 0; i < h; ++i){
        if(i == 0 || i == h - 1){
            for(int j = 0; j < w; ++j){
                mat[i][j] = '#';
            }
        }
    }
    for(int i = 0; i < w; ++i){
        if(i == 0 || i == w - 1){
            for(int j = 0; j < h; ++j){
                mat[j][i] = '#';
            }
        }
    }
    for(int i = 1; i < h - 1; ++i){
        for(int j = 1; j < w - 1; ++j){
            cin >> mat[i][j];
        }
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cout << mat[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>

int main(){
double r ;
double s ;
double l ;
scanf("%lf",&r) ;

if(r>=0){
s = M_PI*r*r ;
l = 2*M_PI*r ;

printf("%lf %lf",s,l) ;

return 0 ;
}
}


/* {を忘れないように!! */

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

int factorial(int x) {
    if (x == 1) return 1;
    return x*factorial(x-1);
}

int main() {
    int n;
    cin >> n;
    vector<int> perm(n);
    rep(i,n) perm[i] = i;
    vector<P> cood(n);
    rep(i,n) {
        double x, y;
        cin >> x >> y;
        cood[i] = P(x,y);
    }
    double sum = 0;
    do {
        rep(i,n-1) {
            double x_i1 = cood[perm[i]].first;
            double x_i2 = cood[perm[i+1]].first;
            double y_i1 = cood[perm[i]].second;
            double y_i2 = cood[perm[i+1]].second;
            sum += sqrt(pow(x_i1-x_i2,2)+(pow(y_i1-y_i2,2)));
        }
    } while (next_permutation(perm.begin(),perm.end()));
    sum /= factorial(n);
    printf("%.10f\n",sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int cnt = 0;
    rep(i, 0, s.size()) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int n;
  while(cin >> n, n){
    string sample[1000];
    for(int i = 0; i < n; i++) cin >> sample[i];
    for(int i = 0; i < n; i++){
      for(int j = 0; sample[i][j] == '.'; j++){
	sample[i][j] = (sample[i][j+1] == '.'?' ':'+');
      }
    }
    for(int i = n-1; i >= 1; i--){
      for(int j = 0; j < sample[i].size(); j++){
	if(sample[i][j] == '+' && sample[i-1][j] == ' '){
	  int idx = i-1;
	  while(sample[idx][j] == ' ') sample[idx][j] = '|', idx--;
	}
      }
    }
    for(int i = 0; i < n; i++) cout << sample[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    ll n; cin >> n;
    ll ans = -(n * (n + 1) / 2);
    FOR(i, 0, n) {
        ll a; cin >> a;
        ans += a;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3120
import java.util.Scanner;
import java.util.Arrays;
class Main{
    // 解答参考にして作った解答

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int indexArray = sc.nextInt();
        int[] array = new int[indexArray];
        // 配列に収納する
        for (int i = 0; i < indexArray; i++) {
            array[i] = sc.nextInt();
        }
    //最小値、最大値、合計値を求める
    int min = array[0];
    int max = array[0];
    long sum = 0;
        for (int i = 0; i < indexArray; i++) {
            min = Math.min(min, array[i]);
            max = Math.max(max, array[i]);
            sum += array[i];
        }
        System.out.println(min + " " + max + " " + sum);
    // System.out.println(Arrays.toString(array));
    }
}


Measured memory_bytes: 42068
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s,p,x;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,f=0;
    cin>>s>>p>>x;
    while(1)
    {
        if(f==0)
        {
            l=s.size();
            if(l>0)
            {
                if(s[0]=='a')
                {
                    f=0;
                }
                else if(s[0]=='b')
                {
                    f=1;
                }
                else
                {
                    f=2;
                }
                s.erase(0,1);
            }
            else
            {
                cout<<"A\n";
                return 0;
            }
        }
        else if(f==1)
        {
            l=p.size();
            if(l>0)
            {
                if(p[0]=='a')
                {
                    f=0;
                }
                else if(p[0]=='b')
                {
                    f=1;
                }
                else
                {
                    f=2;
                }
                p.erase(0,1);
            }
            else
            {
                cout<<"B\n";
                return 0;
            }
        }
        else
        {
            l=x.size();
            if(l>0)
            {
                if(x[0]=='a')
                {
                    f=0;
                }
                else if(x[0]=='b')
                {
                    f=1;
                }
                else
                {
                    f=2;
                }
                x.erase(0,1);
            }
            else
            {
                cout<<"C\n";
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

#include <bits/stdc++.h>
using namespace std;

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag, 
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = 
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
const ld PI = 3.1415926535897932384626;
const ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
const ll MAX = 2e5 + 5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    boost
    ll a, b;
    cin >> a >> b;
    rep(i, 1, 10001) if(ll(ld(i)*0.08) == a && ll(ld(i)*0.1) == b) {
        cout << i << endl;
        return 0;
    }
    cout << "-1\n";
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> broken(n+1);
  rep(i,m) {
    int a;
    cin >> a;
    broken[a] = true;
  }
  vector<int> dp(n+2);
  const int mod = 1000000007;
  dp[n] = 1;
  for(int i = n-1; i >= 0; --i){
    if(broken[i]){
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2]) % mod;
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC161D();

#if 1
int main()
{
	ABC161D();
	fflush(stdout);
	return 0;
}
#endif

static void ABC161D()
{
	int K;
	getint(K);
	
	std::queue<LLONG> lun;

	for (int i = 1; i <= 9; i++) {
		lun.push(i);
	}

	LLONG ans = 0;
	for (int i = 1; i <= K; i++) {
		ans = lun.front(); lun.pop();
		LLONG mod = ans % 10;
		if (mod) {
			lun.push(ans * 10LL + mod - 1LL);
		}
		lun.push(ans * 10LL + mod);
		if (mod != 9) {
			lun.push(ans * 10LL + mod + 1LL);
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 5364
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	enum long Mod = 10L ^^ 9L + 7L;
	auto n = readln.chomp.to!size_t;
	auto a = new long[n];
	auto s = new long[n];

	long ss;
	foreach (i;0..n) {
		long x;
		readf(" %s", &x);
		a[i] = x;
		s[i] = ss;
		ss = (ss + x) % Mod;
	}

	long total;

	foreach (size_t i, e;a) {
		total = (total + s[i] * e) % Mod;
	}

	writeln(total);
}


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

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<int> as(n+1), bs(n);
	for (int& a : as)
		cin >> a;
	for (int &a : bs)
		cin >> a;
	long ans = 0;
	for (int i = 0; i <= n; i++)
	{
		if (i)
		{
			long x = min(as[i], bs[i-1]);
			as[i] -= x;
			ans += x;
		}
		if (i < n)
		{
			long x = min(as[i], bs[i]);
			bs[i] -= x;
			ans += x;
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	vector<int> a(n);

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

		s += a[i];
	}

	sort(a.rbegin(), a.rend());

	s -= a[0];

	if (a[0] < s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int Q = sc.nextInt();
        LinkedList<Character> tmp = new LinkedList<>();
        for (int i = 0; i < S.length(); i++) {
            tmp.add(S.charAt(i));
        }
        boolean reverse = false;
        for (int i = 0; i < Q; i++) {
            int T = sc.nextInt();
            if (T == 1) {
                reverse = !reverse;
            } else {
                int F = sc.nextInt();
                char C = sc.next().toCharArray()[0];
                if (!reverse) {
                    if (F == 1) {
                        tmp.addFirst(C);
                    } else {
                        tmp.add(C);
                    }
                } else {
                    if (F == 1) {
                        tmp.add(C);
                    } else {
                        tmp.addFirst(C);
                    }
                }
            }
        }
        StringBuilder ans = new StringBuilder();
        if (reverse) {
            while (!tmp.isEmpty()) {
                ans.append(tmp.removeLast());
            }
        } else {
            while (!tmp.isEmpty()) {
                ans.append(tmp.removeFirst());
            }
        }

        System.out.println(ans.toString());
    }
}


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

int main() {
	char c[50][50];
	int h, w, cnt = 0;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (c[i][j] == '#'&& c[i][j - 1] == '.'&& c[i - 1][j] == '.' && c[i][j + 1] == '.' && c[i + 1][j] == '.') {
				cnt = 1;
			}
		}
	}
	if (cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H,W;
        while(sc.hasNextLine()){
            String[] str = sc.nextLine().split(" ");
            H = Integer.parseInt(str[0]);
            W = Integer.parseInt(str[1]);
            if(H == 0 && W == 0) break;
            for(int y = 0; y < H; y++){
                for(int x = 0;x < W; x++){
                    if((y + x) % 2 == 0) System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }

}

Measured memory_bytes: 34476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll j,k,n;
    int i,m;
    cin.tie();
    ios::sync_with_stdio(false);
    while(cin>>m)
    {
        ll MAX=-1;
        for(i=0;i<m;i++)
        {
            cin>>j>>k;
            if(MAX<j)
            {
                MAX=j;
                n=k;
            }
        }
        cout<<n+MAX<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[1000500],ans;
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
	n = rd();
	for (int i=1;i<=n;i++) a[i] = rd();
	for (int i=2;i<=n;i++) if (a[i] == a[i-1]) {
		a[i] = -1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(){
    int a, b;
    int d, r;
    double f;
 
    cin >> a >> b;
 
    d = a/b;
    r = a%b;
    f = double(a)/double(b);
 
    printf("%d %d %.5f", d, r, f);
 
    return(0);
}

Measured memory_bytes: 3208
/*
author: shah_entrance
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,i,j,res;
    cin>>n;
    ll arr[n],dp[n+5][2]={};
    for(i=0;i<n;i++)
        cin>>arr[i];
    if(n==2)
        cout<<abs(arr[1]-arr[0])<<endl;
    else
    {
        dp[1][0]=abs(arr[1]-arr[0]);
        dp[1][1]=abs(arr[1]-arr[0]);
        for(i=2;i<n;i++)
        {
            dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(arr[i]-arr[i-1]);
            dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(arr[i]-arr[i-2]);
        }
        cout<<min(dp[n-1][0],dp[n-1][1])<<endl;
    }
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll MOD = 1e9+7;


ll dp[103][2][100005] = {};
int main(){
	ios_base::sync_with_stdio(false);
	ll N, K, ans=0;

	cin >> N >> K;

	ll mid = sqrt(N);
	ll mid_cnt = 0;
	reps(i,mid+1,N+1) if(mid * (ll)i <= N) mid_cnt++; else break;

	dp[0][0][1] = 1;
	rep(i,K){
		ll sum = 0;
		reps(j,1,mid+1){
			sum = (sum + dp[i][0][j]) % MOD;
			ll cnt = (N / j) - (N / (j + 1));
			if( j == mid ) cnt = mid_cnt;
			ll add = (sum * cnt) % MOD;
			dp[i+1][1][j] = (dp[i+1][1][j] + add) % MOD;
		}
		rrep(j,mid+1) if(j) {
			sum = (sum + dp[i][1][j]) % MOD;
			dp[i+1][0][j] = (dp[i+1][0][j] + sum) % MOD;
		}
	}

	rep(k,2) rep(i,mid+1) ans = (ans + dp[K][k][i]) % MOD;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(){

  int N,a=0,c=0;

  cin>>N;

  while(true){
    c=0;
    ++a;
    for(int i=1; i<a+1;++i){
      if(a%i==0) ++c;
    }
    if(N==c){
      cout << a << endl;
      return 0;
    }
  }
  
  
  return 0;
}



Measured memory_bytes: 3092
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  rep(i, m) {
    int numa, numb;
    cin >> numa >> numb;
    a.at(i) = numa;
    b.at(i) = numb;
    //cout << a.at(i) << b.at(i) << endl;
  }
  vector<int> city(n+1, 0);
  rep(i, m) {
    city.at(a.at(i))++;
    city.at(b.at(i))++;
  }
  rep(i, n) {
    cout << city.at(i+1) << endl;
  }
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const string meg[3] = {"Opened by", "Closed by", "Unknown" };

int main()
{
	set<string> id; id.clear();
	ios_base::sync_with_stdio(0);
	int N; cin >> N;
	rep (i, N ){
		string s; cin >> s;
		id.insert (s );
	} // end rep
	bool state = false;	// close state
	int M; cin >> M;
	rep (j, M ){
		string t; cin >> t;
		if (!id.count (t ) ){
			cout << meg[2] << ' ' << t << endl;
		}else{
			cout << meg[state] << ' ' << t << endl;
			state =!state;
		} // end if
	} // end rep
	
	return 0;
}

Measured memory_bytes: 1240
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int sum = 0;
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            sum += x;
        }
        System.out.println(n-sum < 0 ? -1 : n-sum);
        sc.close();

    }

}


Measured memory_bytes: 46204
// beet hieteruka~~~
#include <bits/stdc++.h>

using namespace std;

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

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int X, A, B, N;
  cin >> X >> A >> B >> N;
  int ret = X;
  while(N--) {
    string S;
    cin >> S;
    if(S == "nobiro") {
      ret += A;
    } else if(S == "tidime") {
      ret += B;
    } else {
      ret = 0;
    }
    if(ret < 0) {
      ret = 0;
      continue;
    }
  }
  cout << ret << endl;
}



Measured memory_bytes: 3232
n,m = map(int,input().split())
li = list(map(int,input().split()))
tmp_li = []
for _ in range(m):
    b,c = map(int,input().split())
    tmp_li.append((c,b))
tmp_li.sort(reverse=True)
#print(tmp_li)
for c,b in tmp_li:
    li.extend([c]*b)
    if len(li)>= 2*n:
        break
li.sort(reverse=True)
print(sum(li[:n]))

Measured memory_bytes: 23116
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 200000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

pair<int, int> cnt[MAX_N+1];

int main(){
  int n;cin>>n;
  vector<vector<int> > mp(20, vector<int>(20, 0));
  rep(i, n){
    long double t;cin>>t;
    ll a = ll(ll(1e9)*t+0.5);
    int two=0, five=0;
    while(a%2==0LL){a/=2;two++;}
    while(a%5==0LL){a/=5;five++;}
    two = min(18, two);
    five = min(18, five);
    mp[two][five]++;
    cnt[i] = make_pair(two, five);
  }
  for(int i=19;i>=0;i--){
    for(int j=19;j>=1;j--){
      mp[i][j-1] += mp[i][j];
    }
  }
  for(int i=19;i>=0;i--){
    for(int j=19;j>=1;j--){
      mp[j-1][i] += mp[j][i];
    }
  }
  ll ans=0LL;
  for(int i=0;i<n;i++){
    ans += (ll)mp[18-cnt[i].first][18-cnt[i].second];
    if(cnt[i].first>=9 && cnt[i].second>=9)ans--;
  }
  ans /= 2;
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 5280
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    };
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) };
}

const M: i64 = 1_000_000_007;
fn prime_sieve(n: usize) -> Vec<bool> {
    let mut s = vec![true; n];
    s[0] = false; s[1] = false;
    for i in 2..n {
        if i * i > n { break }
        if s[i] {
            for k in 2..(n+i-1)/i { s[k*i] = false }
        }
    }
    s
}

fn main() {

    let ps = prime_sieve(55555 + 10);
    let primes: Vec<usize> = (2..55555+1).filter(|&i| ps[i]).collect();

    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let ans: Vec<usize> =
        primes.iter().filter(|&p| p % 5 == 1).take(n)
        .map(|&p| p)
        .collect();
    put!(..ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int main(){
    int n,w;
    while(cin>>n>>w){
        vector<int>val(n);
        vector<int>wei(n);
        rep(i,n)cin>>val[i]>>wei[i];
        int dp[n+1][w+1];
        rep(i,n+1)rep(j,w+1)dp[i][j] = 0;
        rep(i,n){
            rep(j,w+1){
                if(j-wei[i]>=0)dp[i+1][j] = max(dp[i+1][j],dp[i+1][j-wei[i]]+val[i]);
                dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            }
        }
        cout<<dp[n][w]<<endl;
    }
}




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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    double a, b;
    cin >> a >> b;

    OP(ceil((b - 1) / (a - 1)));
    return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
h_list = list(map(int, input().split()))
newlist = list(h_list)
for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] < h_list[b-1]:
        newlist[a-1] = 0
    elif h_list[a-1] > h_list[b-1]:
        newlist[b-1] = 0
    else:
        newlist[a-1] = 0
        newlist[b-1] = 0
print(len(h_list) - newlist.count(0))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[303030];
ll B[303030];
int S[303030][2];

int ok(ll v) {
	int i;
	FOR(i,N) B[i]=A[i];
	
	int cur=N-1;
	
	while(cur>0) {
		if(B[cur]>=v && B[cur-1]>=B[cur]) {
			//v -= B[cur-1]-B[cur];
		}
		else {
			B[cur-2]+=B[cur]-B[cur-1];
		}
		cur-=2;
	}
	
	return B[0]>=v;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		S[i+1][0]=S[i][0];
		S[i+1][1]=S[i][1];
		S[i+1][i%2]+=A[i];
	}
	if(N%2==0) {
		cout<<max(S[N][0],S[N][1])<<" "<<min(S[N][0],S[N][1])<<endl;
		return;
	}
	
	ll Z=-1LL<<40;
	for(i=40;i>=0;i--) if(ok(Z+(1LL<<i))) Z+=1LL<<i;
	
	cout<<(S[N][1]+Z)<<" "<<(S[N][0]-Z)<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(){
  int c,q,i,j,z=0,k=1,o=0,m[1001][1001]={0};
  int a[1001]={0},b[1001]={0},w[1001]={0},e[6][2]={0};
  for(i=0;i<6;i++){
    cin>>q>>c;
    w[q]++;
    w[c]++;
    if(q>c)m[q][c]++;
    else m[c][q]++;
  }
  for(i=0;i<1001;i++){
    if(w[i])o++;
      for(j=0;j<1001;j++){
        if(m[i][j]){a[j]+=m[i][j];b[i]+=m[i][j];
      if(m[i][j]==4){e[z][0]=i;e[z++][1]=j;e[z][0]=i;e[z++][1]=j;}
      else if(m[i][j]==6){e[z][0]=i;e[z++][1]=j;e[z][0]=i;e[z++][1]=j;e[z][0]=i;e[z++][1]=j;}
      else{ e[z][0]=i;e[z++][1]=j;}
    }
       }
    }
  if(e[0][0]!=e[2][1]||e[1][0]!=e[2][0]||e[0][1]!=e[1][1])k=0;
  if(k)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  return 0;
}

Measured memory_bytes: 7020
#rating

a = int(input())

if a >= 400 and a < 600:
    print(8)
elif a < 800:
    print(7)
elif a < 1000:
    print(6)
elif a < 1200:
    print(5)
elif a < 1400:
    print(4)
elif a < 1600:
    print(3)
elif a < 1800:
    print(2)
elif a < 2000:
    print(1)



Measured memory_bytes: 9176
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a,b,c,x,ans;
int main()
{
	cin>>a>>b>>c;
	for(int i=1;i<=a;i++)
	{
		cin>>x;
		if(x<b||x>=c)
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  string str;
  while(cin >> str,str[0]!='#'){
    int sum=0;
    int frg=0;
    for(auto i: str){
      switch(i){
      case 'y' : if(frg!=1)++sum;frg=1;break;
      case 'u' : if(frg!=1)++sum;frg=1;break;
      case 'i' : if(frg!=1)++sum;frg=1;break;
      case 'o' : if(frg!=1)++sum;frg=1;break;
      case 'p' : if(frg!=1)++sum;frg=1;break;
      case 'h' : if(frg!=1)++sum;frg=1;break;
      case 'j' : if(frg!=1)++sum;frg=1;break;
      case 'k' : if(frg!=1)++sum;frg=1;break;
      case 'l' : if(frg!=1)++sum;frg=1;break;
      case 'n' : if(frg!=1)++sum;frg=1;break;
      case 'm' : if(frg!=1)++sum;frg=1;break;
      default  : if(frg!=2)++sum;frg=2;break;
      }
    }
    cout << sum-1 << endl;
  }
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
int ans,n,a,k;
int fuck(int n,int k)
{
	if (n<k)return 0;
	if (n%k==0)return n/k;
	int p=n%k;
	int q=n/k+1;
	if (p%q==0)return n/k;
	int o=(n/k)*k+p%q;
	return fuck(o-o/k-1,k);	
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d %d",&a,&k);
		ans^=fuck(a,k);
	}
	if (ans)printf("Takahashi\n");else printf("Aoki\n");
}

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

int main()
{ll A=0,B=0;
 ll a,b,k;
 cin >> a>> b >> k;

 if(a>=k)
 {A=a-k;B=b;}
 else if(a+b>=k)
 {
  A=0;B=b-(k-a);
 }
 else if(a+b<k)
 {A=0;B=0;}

 cout << A <<" "<<B<<endl;
    return 0;
}

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

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for(int i = 0; i < x; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < y; i++){
        cin >> b[i];
    }
    for(int i = 0; i < z; i++)
    {
        cin >> c[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());
    vector<ll> ab;
    for(int i = 0; i < x; i++)
    {
        for(int j = 0; j < y; j++)
        {
            ab.push_back(a[i]+b[j]);
        }
    }
    sort(ab.begin(), ab.end(), greater<ll>());
    vector<ll> abc;
    int cnt=0;
    for(int i = 0; i < z; i++)
    {
        for(int j = 0; j < min((int)ab.size(), k); j++)
        {
            abc.push_back(c[i]+ab[j]);
        }
    }
    
    sort(abc.begin(), abc.end(), greater<ll>());
    if((int)abc.size()<k){
        for(int i = 0; i < (int)abc.size(); i++)
        {
            cout << abc[i] << endl;
        }
        
    }
    else{
        for(int i = 0; i < k; i++)
        {
            cout << abc[i] << endl;
        }
    }

}

Measured memory_bytes: 43368
#include<stdio.h>
int main(){
    int i,j,k,n,m,l,a[100][100],b[100][100];
    long int c[100][100]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            if(j>0){
                printf(" ");
            }
            printf("%ld",c[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2112
/* SmartCoder Apr 7, 2019 */
#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)
#define present(c,x)  ( (c).find(x) !=(c).end())
#define cpresent(c,x) (find(all(c),x)!= (c).end() )
#define minei(x)  min_element(x.begin(),x.end())-(x).begin()
#define maxei(x)  max_element(x.begin(),x.end())-(x).begin()

#define uns(v)     sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define acusum(x)  accumulate(x.begin(),x.end(),0)
#define acumul(x)  accumulate(x.begin(),x.end(),1, multiplies<int>());
#define bits(x)     __builtin_popcount( x )
#define oo INT_MAX
#define inf 1000000000

const double pi = acos(-1.0);
const double eps = 1e-11;
#define MAXN 100007
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
void fastIO() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
vector<int> adj[MAXN];
int nodes[MAXN];
int inDegree[MAXN];
int inDegreeCop[MAXN];
int dp[MAXN];
int res = 0;
void dfs(int a) {
	for (int i = 0; i < sz(adj[a]); i++) {
		int b = adj[a][i];
		dp[b] = max(dp[b], dp[a] + 1);
		res = max(res, dp[b]);
		inDegree[b]--;
		if (inDegree[b] == 0)
			dfs(b);
	}
}
int main() {
	fastIO();
	int n, m, a, b;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		adj[a].pb(b);
		inDegree[b]++;
		inDegreeCop[b]++;
	}

	for (int i = 1; i <= n; i++) {
		if (inDegreeCop[i] == 0)
			dfs(i);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define int long long
const int MOD = 998244353;
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 2e5 + 5;

int n, m, k, fact[maxn];

int mod_expo(int x, int p)
{
    if(!p)
        return 1;
    int res = mod_expo(x, p / 2);
    res *= res;
    res %= MOD;
    if(p & 1)
        res *= x;
    return res % MOD;
}

int mod_inv(int x)
{
    return mod_expo(x, MOD - 2);
}

int nCr_mod(int n, int r)
{
    int num = fact[n];
    int denom = (fact[r] * fact[n - r]) % MOD;
    return (num * mod_inv(denom)) % MOD;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    fact[0] = 1;
    for(int i = 1; i < maxn; i++)
        fact[i] = (fact[i - 1] * i) % MOD;
    cin >> n >> m >> k;
    int ans = 0;
    for(int i = 0; i <= k; i++)
    {
        int pt = (m * mod_expo(m - 1, n - 1 - i)) % MOD;
        pt *= nCr_mod(n - 1, i);
        pt %= MOD;
        ans += pt;
        ans %= MOD;
    }
    cout << ans % MOD << "\n";
    return 0;
}

Measured memory_bytes: 5196
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
N=int(input())
#N, L=input().split()
#S=input()
#T=input()
#S_list=list(S)
a_list=  list(map(int, input().split(" ")))
j=0
times=0

for i  in range(N):
    if a_list[i]==i-times+1:
       pass
    else:
       times=times+1

if times==len(a_list):
    print(-1)
    sys.exit()
print(times)



#for i in range(N):
# print(i,j,times, a_list)

 #if a_list[j]==j+1:
#     j=j+1
#     if j==len(a_list):
#         print(times)
#         sys.exit()

 #if a_list[i]==i+1:
 #i=j
 #print(i, a_list)
 #if i+1==len(a_list):
#    print(times)
#    sys.exit()
# if a_list[j]!=j+1:
#     a_list.pop(j)
     #j=i
     #i=j
#     times+=1
#     if len(a_list)==0:
#      print(-1)
#      sys.exit()
     #elif j+1==len(a_list):
     #print(times)
    #     sys.exit()

#     elif
#print(times)
#


Measured memory_bytes: 25248
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter

N,M = map(int,readline().split())
A = list(map(int,readline().split()))
m = map(int,read().split())
BC = list(zip(m,m))

BC.sort(key = itemgetter(1),reverse=True)

BC.append((N,-1))

change = []
for b,c in BC:
    change += [c] * b
    if len(change) > N:
        break

A += change
A.sort()
answer = sum(A[-N:])
print(answer)

Measured memory_bytes: 31536