akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
// mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());  put as first line of main
ll dp[10005][101][2];
string s;
ll m,n;
ll f(ll i,ll abtakmod,ll flag) // i pe ho, abtakmod is mod till now, f;
{
    if(i==n && abtakmod==0)
        return 1;
    if(i==n && abtakmod!=0)
        return 0;
    if(dp[i][abtakmod][flag]!=-1)
        return dp[i][abtakmod][flag];
    ll ans=0;
    ll till,j;
    if(flag==0)
        {
            till=s[i]-'0';
        }
    else
        {
            till=9;
        }
    for(j=0;j<=till;j++)
    {
        ll newflag=flag;
        if(flag==0 && j<till)
            newflag=1;
        ll x=((abtakmod%m)+(j%m))%m;
        ans=(ans+(f(i+1,x,newflag)%hell))%hell;
    }
    dp[i][abtakmod][flag]=ans;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>s;
    cin>>m;
    n=s.size();
    cout<<(f(0,0,0)+hell-1)%hell;
    return 0;
}


Measured memory_bytes: 16896
#include<iostream>
#include<cstring>
#include<vector>
#include<string>
using namespace std;
string ca;
vector<int> v1;
int main(){
	int a,b,c;
	int i,j,k;
	bool flag;
	while(getline(cin,ca)){
		if(ca[0]=='.')break;
		flag=true;
		v1.clear();
		for(i=0;i<ca.size();i++){
			if(ca[i]=='(')v1.push_back(1);
			if(ca[i]=='[')v1.push_back(2);
			if(ca[i]==')'){
				if(v1.empty() || v1.back()!=1){
					flag=false;
					break;
				}
				v1.pop_back();
			}
			if(ca[i]==']'){
				if(v1.empty() || v1.back()!=2){
					flag=false;
					break;
				}
				v1.pop_back();
			}
		}
		if(!v1.empty())flag=false;
		if(flag)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}



Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc093/tasks/abc093_b

int main() {
    int A, B, K; cin >> A >> B >> K;
    set<int> ans;

    for (int i = A; i < A+K; i++) {
        if (i <= B) ans.insert(i);
    }
    for (int i = B; i > B-K; i--) {
        if (i >= A) ans.insert(i);
    }

    for (int t : ans) {
        cout << t << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
import bisect
 
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
 
for b in B:
    a = bisect.bisect_left(A, b)
    c = bisect.bisect_right(C, b)
    ans += a*(n-c)
 
print(ans)

Measured memory_bytes: 29424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int C = sc.nextInt();
		double h = b * Math.sin(Math.toRadians(C));
		double S = a * h / 2;
		double c = Math.sqrt(a * a + b * b - (2 * a * b * Math.cos(Math.toRadians(C))));
		double L = a + b + c;
		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}

}

Measured memory_bytes: 26284
#include <stdio.h>
#define NIL -1
#define Max 25

typedef struct { int p, l, r; } Node;
Node T[Max];
int n, i;

void preOrder(int u) {
  if ( u == NIL )
    return;
  printf(" %d", u);
  preOrder(T[u].l);
  preOrder(T[u].r);
}

void inOrder(int u) {
  if ( u == NIL )
    return;
  inOrder(T[u].l);
  printf(" %d", u);
  inOrder(T[u].r);
}

void postOrder(int u) {
  if ( u == NIL )
    return;
  postOrder(T[u].l);
  postOrder(T[u].r);
  printf(" %d", u);
}

int main(void) {
  int v, left, right, root;
  scanf("%d", &n);
  for ( i = 0; i < n; ++i ) T[i].p = NIL;
  for ( i = 0; i < n; ++i ) {
    scanf("%d %d %d", &v, &left, &right);
    T[v].l = left;
    T[v].r = right;
    if ( left != NIL ) { T[left].p = v; }
    if ( right != NIL ) { T[right].p = v; }
  }
  for ( i = 0; i < n; ++i )
    if ( T[i].p == NIL)
      root = i;
  puts("Preorder");
  preOrder(root); putchar('\n');
  puts("Inorder");
  inOrder(root); putchar('\n');
  puts("Postorder");
  postOrder(root); putchar('\n');
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#define N 45
using namespace std;

int n, ha, hb, sa, sb, ans, a[N], b[N], c[N], d[405][405];
int main()
{
	int i, j, k, t1, t2;
	cin >> n >> ha >> hb;
	for (i = 0; i < n; i++) {
		scanf ("%d %d %d", &a[i], &b[i], &c[i]);
		sa += a[i];
		sb += b[i];
	}
	for (i = 0; i <= sa; i++) {
		for (j = 0; j <= sb; j++) {
			d[i][j] = 2e9;
		}
	}
	d[0][0] = 0;
	for (i = 0; i < n; i++) {
		for (j = sa; j >= 0; j--) {
			for (k = sb; k >= 0; k--) {
				t1 = j - a[i];
				t2 = k - b[i];
				if (t1 < 0 || t2 < 0) continue;
				d[j][k] = min(d[j][k], d[t1][t2] + c[i]);
			}
		}
	}
	i = ha;
	j = hb;
	ans = 2e9;
	while (i <= sa && j <= sb) {
		if (d[i][j] < ans) {
			ans = d[i][j];
		}
		i += ha;
		j += hb;
	}
	if (ans == 2e9) {
		cout <<-1 << endl;
		return 0;
	}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
lld ar[3005][3005];
lld dp[3005][3005][4];
lld r,c,k;
lld fun(lld a, lld b, lld x)
{
    if(a==r-1 && b==c-1)
        {if(x>0)
        return ar[a][b];
    else
        return 0;}
    if(a>=r || b>=c)
        return -10000000000000000;
    if(dp[a][b][x]!=-1)
        return dp[a][b][x];
    lld ans=LLONG_MIN;
    ans=max(ans,fun(a+1,b,3));
    ans=max(ans,fun(a,b+1,x));
    if(ar[a][b]!=0 && x>0)
        ans=max(ans,fun(a,b+1,x-1)+ar[a][b]);
    if(ar[a][b]!=0 && x>0)
        ans=max(ans,fun(a+1,b,3)+ar[a][b]);
    dp[a][b][x]=ans;
    return ans;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    memset(ar,0,sizeof(ar));
    memset(dp,-1,sizeof(dp));
    while(t--)
    {
        cin>>r>>c>>k;
        for(i=0;i<k;i++)
        {
            lld a,b,c;
            cin>>a>>b>>c;
            a--,b--;
            ar[a][b]=c;
        }
        cout<<fun(0,0,3)<<endl;
    }
}





Measured memory_bytes: 356832
N,K,Q = map(int,input().split())
A = [0]*N
for i in range(Q):
    a = int(input())
    A[a-1] += 1
for i in range(N):
    x = K+A[i]-Q
    if x > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4680
//======================================================================
// Contents    : AOJ ITP1_5_B
//               たてH cm よこ W cm の枠を描く
//               ( 周囲を'#'、内部を'.'で表現 )
// Input       : H , W
// Output      : '#'と'.'
//             : exp) "5 6"の入力時、以下のように出力される
//             :        ######
//             :        #....#
//             :        #....#
//             :        #....#
//             :        ######
// Constraints : 3 ≤ H,W ≤ 300
//             : "0 0" 入力で終了
// Author      : 廣部智也
// LastUpdate  : 2020/06/05
// Since       : 2020/06/05
//======================================================================

#include <stdio.h>
#include <stdlib.h>                                                 // exit 関数を使用するため

#define LOWER_LIMIT   3
#define UPPER_LIMIT 300

int Input_error( int number, int Lower_limit, int Upper_limit );    // 入力エラーを判断する関数

void Drawing_frames( int H, int W );

int main(){

    int H = 0, W = 0;

    while(1){
        
        // データの入力
		scanf("%d %d", &H , &W );

        if( H == 0 && W == 0 ){
            break;
        }

        // 入力エラーの判断
        Input_error( H, LOWER_LIMIT, UPPER_LIMIT );
        Input_error( W, LOWER_LIMIT, UPPER_LIMIT );

        // データの出力
        Drawing_frames( H, W );

	}

	return 0;
}



//============================================================
// Contents    : 入力エラーを判断
// Input       : 調べる変数, 下限, 上限
// Output      : エラーなら強制終了
// Author      : 廣部智也
// LastUpdate  : 2020/06/05
// Since       : 2020/06/05
//============================================================

int Input_error( int number, int Lower_limit, int Upper_limit ){
    
    if( number < Lower_limit || number > Upper_limit ){ 
        printf("Input error\n");
        exit(1);
    }

    return 0;
}



//============================================================
// Contents    : たてH cm よこ W cm の枠を描く
// Input       : H , W
// Output      : '#'と'.'
// Author      : 廣部智也
// LastUpdate  : 2020/06/05
// Since       : 2020/06/05
//============================================================

void Drawing_frames( int H, int W ){

    int i = 0, j = 0;

    for( i = 0; i < H; i++ ){

		for( j = 0; j < W; j++ ){

            if ( i == 0 || i == (H-1) || j == 0 || j == (W-1) ){
                putchar('#');
            }

            else{
                putchar('.');
            }
            
        }

		putchar('\n');                               
    }

    putchar('\n');                                                  // データセット間の空行

    return;  
}                                            


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

template<typename T> struct SegmentTree_sum{
	int n;
	vector<T> node;
	T ZERO;

	SegmentTree_sum(const int &n_=1, const T &ZERO_=0){
		init(n_, ZERO_);
	}

	// n要素で初期化
	void init(const int &n_=1, const T &ZERO_=0){
		n=1;
		while(n<n_){
			n<<=1;
		}
		node.resize(n*2-1);
		ZERO=ZERO_;
		REP(i, n*2-1){
			node[i]=ZERO;
		}
	}

	// k番目(0-indexed)をaに変更
	void update(int k, const T &a){
		k+=n-1;
		node[k]=a;
		while(k>0){
			k=(k-1)/2;
			node[k]=node[k*2+1]+node[k*2+2];
		}
	}

	// [a, b)の和を求める
	// k: 節点の番号、その節点は[l, r)に対応づく
	// 外から呼び出すときはquery(a, b, 0, 0, n)
	T query(int a, int b, int k, int l, int r){
		// [a, b)と[l, r)が交差しなければZERO
		if(r<=a || b<=l){
			return ZERO;
		}
		// [a, b)と[l, r)が完全に含んでいればこの節点の値
		if(a<=l && r<=b){
			return node[k];
		}
		// そうでなければ2つの子の和
		else{
			T v1=query(a, b, k*2+1, l, (l+r)/2), v2=query(a, b, k*2+2, (l+r)/2, r);
			return v1+v2;
		}
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, k;
	ll a[252521];
	pair<ll, int> b[252521];
	cin>>n>>k;
	b[0]=make_pair(0, 0);
	REP(i, n){
		cin>>a[i];
		b[i+1]=make_pair(b[i].first+a[i]-k, i+1);
	}
	sort(b, b+n+1);
	ll c[252521];
	REP(i, n+1){
		c[b[i].second]=i;
	}
	SegmentTree_sum<int> st(n+1);
	ll ans=0;
	st.update(c[0], 1);
	FOR(i, 1, n+1){
		ans+=st.query(0, c[i], 0, 0, st.n);
		int tmp=st.query(c[i], c[i]+1, 0, 0, st.n);
		st.update(c[i], tmp+1);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    for (ll bit = 0; bit < (1 << n - 1); bit++)
    {
        ll num = s[0] - '0';
        for (ll i = 0; i < n - 1; i++)
        {
            if (bit & (1 << i))
            {
                ans += num;
                num = 0;
            }
            num = num * 10 + s[i + 1] - '0';
        }
        ans += num;
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    cin>>N;
    int P[N], Q[N];
    for(int i=0;i<N;++i){
        cin>>P[i];
    }
    for(int i=0;i<N;++i){
        cin>>Q[i];
    }
    queue<vector<int> > que;
    vector<int> state;
    vector<int> tmparr;
    for(int i=1;i<=N;++i){
        tmparr.clear();
        tmparr.push_back(i);
        que.push(tmparr);
    }
    int a, b;
    bool tmpa, tmpb;
    int index = 0;
    map<int, int> tmpmap;
    while(!que.empty()){
        state = que.front();que.pop();
        if(state.size()==N){
            tmpa = true;
            tmpb = true;
            for(int i=0;i<N;++i){
                if(state[i]!=P[i])tmpa = false;
                if(state[i]!=Q[i])tmpb = false;
            }
            if(tmpa) a = index;
            if(tmpb) b = index;
            index++;
            continue;
        }
        for(int i=1;i<=N;++i){
            tmpmap[i] = 0;
        }
        for(int i=0;i<state.size();++i){
            tmpmap[state[i]]++;
        }
        for(int i=1;i<=N;++i){
            if(tmpmap[i]==0){
                state.push_back(i);
                que.push(state);
                state.pop_back();
            }
        }
    }
    if(a<b)cout<<b-a<<endl;
    else cout<<a-b<<endl;
}


Measured memory_bytes: 3200
x, k, d = map(int, input().split())
x = abs(x)
n = x//d
p = x - d*n
m = abs(p-d)

if(k <= n):
  print(x-d*k)
else:
  ama = n-k
  if(ama%2 == 0):
    print(p)
  else:
    print(m)

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

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

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    int R;
    cin >> R;
    cout << 2 * 3.14 * R << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <vector>

using namespace std;

int H, W;
vector<string> m;

void paint(int x, int y, char c) {
	if (x < 0 || x >= W || y < 0 || y >= H) return;
	if (m[y][x] != c) return;
	m[y][x] = ' ';

	paint(x-1, y, c);
	paint(x+1, y, c);
	paint(x, y-1, c);
	paint(x, y+1, c);
}

int main() {
	while ( cin >> H >> W, H || W ) {
		m.clear(); m.resize(H);
		for (int y = 0; y < H; ++y) {
			string str; cin >> str;
			m[y] = str;
		}
		int ans = 0;
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				if (m[y][x] != ' ') {
					paint(x, y, m[y][x]);
					++ans;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1848
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int a = sc.nextInt();
			final String s = sc.next();
			
			System.out.println(a >= 3200 ? s : "red");
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define pr(x) cout<<#x<<" "<<x<<" "
#define prln(x) cout<<#x<<" "<<x<<endl;
const int maxn = 1e5 + 4;
const int inf = 0x3f3f3f3f;
int a[maxn], cnt[maxn];
int main(){
	int n;
	while(scanf("%d", &n) != EOF){
		memset(cnt, 0, sizeof cnt);
		for(int i = 0; i < n; i++)
			scanf("%d", a + i);
		for(int i = 0; i < n; i++){
			cnt[a[i]]++;
			cnt[a[i]+1]++;
			if(a[i]>0) cnt[a[i]-1]++;
		}
		int res = 0;
		for(int i = 0; i < maxn; i++)
			res = max(res, cnt[i]);
		printf("%d\n", res);
	}
} 

Measured memory_bytes: 1024
#include <stdio.h>

void print_array(int *a, int n)
{
	for(int i = 0; i < n - 1; ++i)
	{
		printf("%d ", a[i]);
	}
	printf("%d\n", a[n-1]);
}

int main()
{
	int n, a[100];
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}
	
	print_array(a, n);
	for(int i = 1; i < n; ++i)
	{
		int v = a[i];
		int j = i;
		while((j > 0) && (v < a[j-1]))
		{
			a[j] = a[j-1];
			--j;
		}
		a[j] = v;
		
		print_array(a, n);
	}
}



Measured memory_bytes: 2088
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    sort(ALL(a),greater<int>());
    
    int ans=0;
    REP(i,N){
        if(i%2==0)
            ans+=a[i];
        else
            ans-=a[i];
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    
    ll tot=0;
    rep(i,m) tot+=b[i];

    int j=m;
    int ans=0;
    rep(i,n+1){
      while(j>0 && tot>k){
        --j;
        tot-=b[j];
      }
      if(tot>k) break;
      ans=max(ans,i+j);
      if(i==n) break;
      tot+=a[i];
    }
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 6336
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>

int main() {
    ll q;
    vector<bool> prime(100001,true);prime[1]=false;
    for(int i=2;i<=1000000;i++){
        if(prime[i]==true){
            for(int j=i+i;j<=100000;j+=i)prime[j]=false;
        }
    }
    vl ruiseki(100001,0);
    ll sum=0;
    rep(i,100000){
        if(i%2==0)if(prime[i+1]&&prime[(i+2)/2])sum++;
        ruiseki[i+1]+=sum;
    }
    cin>>q;
    rep(i,q){
        ll l,r;cin>>l>>r;
        cout<<ruiseki[r]-ruiseki[l-1]<<endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = 100000000+7;
const ll MAX_N = 1000;

ll k,s,ans;
int main(){
  cin>>k>>s;

  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(0<=s-i-j && s-i-j<=k)ans++;
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
import math
n = int(input())
s = []
mark = ""
number = 0
for i in range(1,53):
    s.append(i)
l = 0
for i in range(n):
  K = input().split()
  if K[0]== "S":
    l = int(K[1])
  elif K[0] == "H":
    l += 13
    l += int(K[1])
  elif K[0] == "C":
    l += 26
    l += int(K[1])
  elif K[0] == "D":
    l += 39
    l += int(K[1])
  s.remove(l)
  l = 0
for i in range(len(s)):
    T = math.ceil(s[i]/13)
    if T == 1:
        mark = "S"
        number = s[i]
    elif T == 2:
        mark = "H"
        number = s[i]-13
    elif T == 3:
        mark = "C"
        number = s[i]-26
    elif T == 4:
        mark = "D"
        number = s[i]-39
    print(mark,number)
    mark = ""
    number = 0


Measured memory_bytes: 5684
class UnionFind():
    "Either 0-indexed or 1-indexed"

    __slots__ = ["parent"]

    def __init__(self, size):
        self.parent = [-1] * (size + 1)
    
    def find(self, a):
        path = []
        while self.parent[a] > 0:
            path.append(a)
            a = self.parent[a]
        for child in path:
            self.parent[child] = a
        return a

    def union(self, a, b):
        a = self.find(a)
        b = self.find(b)

        if a == b:
            return
        else:
            if self.parent[a] == self.parent[b]:
                self.parent[a] = b
                self.parent[b] -= 1
            elif self.parent[a] < self.parent[b]: #aのほうが大きい
                self.parent[b] = a
            else:
                self.parent[a] = b #bのほうが大きい
        
    def same(self, a, b):
        return self.find(a) == self.find(b)


def main():
    import sys
    input = sys.stdin.buffer.readline
    N, Q = map(int, input().split())
    ans = []
    uf = UnionFind(N)
    for _ in range(Q):
        t, u, v = map(int, input().split())
        if t:
            ans.append('1' if uf.same(u, v) else '0')
        else:
            uf.union(u, v)

    print('\n'.join(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 76160
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

// インスタンスを作成する時は ST st<ll>でTの型を指定してあげる
template <typename T>
struct ST{
    using F = function<T(T,T)>;
    F f;
    vector<T> dat;
    int n;
    T ti;
    ST(F f, int n_, T init = INF) : f(f), ti(init) {
        n = 1;
        while(n < n_) n <<= 1;
        dat.assign(n << 1, init);
    }
    ST(int n_, T init = INF) : ST([](ll a, ll b){return (ll)max(a, b);}, n_, init){}

    void update(int k, T a){
        k += n -1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    // [a, b)
    // 外部からはquery(a,b,0,0,st.n)で呼び出す(インスタンス変数がst)
    T query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return ti;
        if(a <= l && r <= b) return dat[k];
        else{
            T vl = query(a,b,k * 2 + 1, l, (l + r) / 2);
            T vr = query(a,b,k * 2 + 2, (l + r) / 2, r);
            return f(vl, vr);
        }
    }
};

int main(void)
{
    ll N, T;
    cin >> N >> T;
    vector<ll> A(N);
    ST<ll> st(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        st.update(i, A[i]);
    }
    map<ll, int> mp;
    REP(i, N-1){
        ll sa = st.query(i+1, N, 0, 0, st.n) - A[i];
        if(sa < 0) continue;
        mp[sa]++;
    }

    pr((*mp.rbegin()).se);
}

Measured memory_bytes: 9344
n=int(input())
p = []
for _ in range(n):
  p1 = []
  a = int(input())
  for __ in range(a):
    x,y = map(int,input().split())
    x-=1
    p1.append((x,y))
  p.append(p1)

ans = 0
for i in range(2**n):
  ok = True
  for j in range(n):
    if (i>>j) & 1 == 0:continue
    for x,y in p[j]:
      if (i>>x)&1 != y:
        ok = False
        break
    if ok == False:
      break
  if ok:
    #print(i)
    cnt = len([j for j in range(n) if (i>>j)&1])
    ans = max(ans,cnt)
print(ans)
      
      

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(c - (a - b) < 0){
        cout << 0 << endl;
    }else{
        cout << c - (a - b) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a, b, c = io.read("*n", "*n", "*n")
k = io.read("*n")
d = 0
while b <= a do
  b = b * 2
  d = d + 1
end
while c <= b do
  c = c * 2
  d = d + 1
end
print(d <= k and "Yes" or "No")


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

int main(){
    int R[MAX], n, minv, maxv;
    cin >> n;
    rep(i, n){
        cin >> R[i];
    }
    minv = R[0];
    maxv = -2000000000;
    for(int i = 1; i < n; i++){
        maxv = max(maxv, R[i]- minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
}


Measured memory_bytes: 3876
#include <stdio.h>
#include <string.h>

int main( void )
{
	char str[1001];
	char inst[8];
	char q[1001];
	char tmp;
	int i, j, n, a, b;
	
	scanf("%s", str);
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%s %d %d", inst, &a, &b);
		
		if(strcmp(inst, "replace") == 0){
			scanf("%s", q);
			for(j = a; j <= b; j++){
				str[j] = q[j - a];
			}
		} else if(strcmp(inst, "reverse") == 0){
			for(j = a; j < b-(j-a); j++){
				tmp = str[j];
				str[j] = str[b-(j-a)];
				str[b-(j-a)] = tmp;
			}
		} else if(strcmp(inst, "print") == 0){
			for(j = a; j <= b; j++){
				printf("%c", str[j]);
			}
			printf("\n");
		} else {
			// DO NOTHING
		}
	}
	
	return 0;
}

Measured memory_bytes: 1812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        /// <summary>
        /// B - Easy Linear Programming
        /// https://atcoder.jp/contests/abc167/tasks/abc167_b
        /// </summary>
        /// <param name="args"></param>

        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            int[] str_ABCK = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            //カード総枚数
            int num_Sum = str_ABCK[0] + str_ABCK[1] + str_ABCK[2];

            //マイナスカードの枚数
            int num_Minus = str_ABCK[3] - (str_ABCK[0] + str_ABCK[1]);

            int result = 0;

            if (str_ABCK[3] <= str_ABCK[0]) 
            {
                result = str_ABCK[3];
            }
            else if (str_ABCK[3] <= str_ABCK[0] + str_ABCK[1]) 
            {
                result = str_ABCK[0];
            }
            else result = str_ABCK[0] - num_Minus;


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int z = 0;
    int ab = a + b;
    int ans = a * x + b * y;
    // AB2枚の方が安い場合
    if(ab > c * 2){
        int m = max(x, y);
        for(int i = m * 2; 0 < i; i-=2){
            z = i / 2;
            int rx = 0;
            int ry = 0;
            if(0 <= x - z){ rx = x - z; }
            if(0 <= y - z){ ry = y - z; }
            int sum = rx * a + ry * b + i * c;
            ans = min(ans, sum);
        }
    }
    OP(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int k,head=99;
int a[10003];
inline void change()
{
	int j=101;
	for (int k=j-1;k>=head+1;k--)
	{
		if (a[k]!=a[k-1]+1&&a[k]!=9)
		{
			j=k;
			break;
		}
	}
	if (j!=101)
	{
		a[j]++;
		for (int k=j+1;k<=100;k++)
		{
			if (a[k-1]-1>=0)  a[k]=a[k-1]-1;
			else a[k]=a[k-1];
		}
		return;
	}
	if (j==101&&a[head]!=9)
	{
		a[head]++;
		for (int k=head+1;k<=100;k++) if (a[k-1]-1>=0)  a[k]=a[k-1]-1; else a[k]=a[k-1];
		return;
	}
	else if (a[head]==9&&j==101)
	{
		head--,a[head]=1;
		for (int k=head+1;k<=100;k++)  a[k]=0;
	}
}

signed main()
{
	cin>>k;
		
	if (k<=9)  return cout<<k<<endl,0;
	k-=10;
	a[head]=1,a[head+1]=0;
	
	for (int i=1;i<=k;i++)  change();
	for (int i=head;i<=100;i++)  cout<<a[i];
	return 0; 
}

Measured memory_bytes: 256
'use strict';
//main関数を作っておいて、下でmain関数を標準入力を引数として実行する。
function main(input){
    input = input.trim();
    if(input === 'A'){
        console.log('T');
    }else if(input === 'T'){
        console.log('A');
    }else if(input === 'C'){
        console.log('G');
    }else if(input === 'G'){
        console.log('C');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
// import scala.io.{StdIn => in}
import java.io._;

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val Array(h, w) = in.readLine.split(" ").map(_.toInt)
  val n = h * w

  val arr = Iterator.continually(in.readLine)
    .take(h)
    .map(_.toArray)
    .toArray

  def bfs(grid:Array[Array[Char]]):Int = {
    val dist = Array.ofDim[Int](h, w)
    var distMax = 0
    val dx = Array( 0, 1, 0,-1)
    val dy = Array( 1, 0,-1, 0)
    // val que = collection.mutable.Queue.empty[(Int,Int)]
    val que = new java.util.ArrayDeque[Tuple2[Int,Int]]()
    for {
      i <- 0 until h
      j <- 0 until w
      if grid(i)(j) == '#'
    } que.offer(Tuple2(i, j))
  
    while(!que.isEmpty) {
      val(y,x) = que.poll
  
      for(i <- 0 until 4) {
        val ny = y + dy(i)
        val nx = x + dx(i)
        if(0 <= ny && ny < h && 0 <= nx && nx < w && grid(ny)(nx) != '#') {
          val d = dist(y)(x) + 1
          dist(ny)(nx) = d
          grid(ny)(nx) = '#'
          que.offer(Tuple2(ny, nx))
          if(distMax < d) distMax = d
        }
      }
    }
    distMax
  }

  val ans = bfs(arr)
  println(ans)
}

Measured memory_bytes: 107932
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        
        int l = s.length();
        if(s.charAt(l-1)=='s'){
            String s1 = s.concat("es");
            System.out.println(s1);
        }else {
          String s2 =  s.concat("s");

            System.out.println(s2);

        }
        
    }
}

Measured memory_bytes: 35560
program test
implicit none
  integer,allocatable::a(:),b(:),c(:)
  integer :: N,i,ans
  read*,N
  allocate(a(N))
  allocate(b(N))
  allocate(c(N-1))
  read(*,*)(a(i),i=1,N)
  read(*,*)(b(i),i=1,N)
  read(*,*)(c(i),i=1,N-1)
  ans=0
  do i=1,N
  	if(a(i+1)==a(i)+1)then
  		ans=ans+b(a(i))+c(a(i))
    else 
    	ans=ans+b(a(i))
    end if
  
  end do
 print*,ans
end program
  

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = ~(1<<28);

struct Link {
    pii ids;
    int cost;
};

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int nodeNum, linkNum;
    cin >> nodeNum >> linkNum;

    vector<int> parents(nodeNum);
    rep(i, nodeNum) {
        parents[i] = i;
    }

    auto compare = [](Link a, Link b) {
        return a.cost > b.cost;
    };

    std::priority_queue<Link, vector<Link>, decltype(compare)> queue{compare};

    rep(i, linkNum) {
        int s, t, d;
        cin >> s >> t >> d;
        queue.push({.ids=pii(s,t), .cost=d});
    }

    int sum = 0;
    while(!queue.empty()) {
        Link l = queue.top();
        queue.pop();
        if (parents[l.ids.first] != parents[l.ids.second]) {
            sum += l.cost;
            // cout << l.cost << endl;
            int tmp = parents[l.ids.first];
            rep(i, nodeNum) {
                if (parents[i] == tmp) {
                    parents[i] = parents[l.ids.second];
                }
                // cout << parents[i] << " ";
            }
            // cout << endl;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4476
def submit():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    max_a = max(a)
    sieve = [0] * (max_a + 1)

    for e in a:
        sieve[e] += 1

    if sieve[1] == 1:
        print(1) # 他は全て1で割り切れてしまう
        return
    
    if sieve[1] > 1:
        print(0) # 全て割り切れる
        return

    # エラトステネスの篩風に計算する
    for e in range(1, max_a + 1):
        if sieve[e] == 0:
            continue

        coef = 2
        while e * coef <= max_a:
            sieve[e * coef] = 0
            coef += 1
        
    # 数が1の要素を数える
    ans = 0
    for e in sieve:
        if e == 1:
            ans += 1

    print(ans)


submit()


Measured memory_bytes: 101472
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        long m = 0, a = 0, r = 0, c = 0, h = 0;
        for (int i = 0; i < n; i++) {
            switch (scanner.next().charAt(0)) {
                case 'M': m++; continue;
                case 'A': a++; continue;
                case 'R': r++; continue;
                case 'C': c++; continue;
                case 'H': h++;
            }
        }
        System.out.println(m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h);
    }
}

Measured memory_bytes: 46888
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    int n, k;
    cin >> n >> k;
    cout << n - (k-1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x,vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1,s) + f(x - 2,s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b,ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m-1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}

int main() {
	double x=0, n;
	cin >> n;
	for(double i=1;i<n+1;i++){
		if (i * 1.08<n+1&&i*1.08>=n) {
			x = i;
			break;
		}
	}
	if (x == 0)cout << ":(" << endl;
	else cout << x << endl;
	return 0;
}





  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final long D = 1000000007;
		long result = 1;

		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();

		// 壊れ段 スタート直前とゴール直後も登録しておく
		int[] a = new int[M + 2];
		a[0] = -1;
		a[M + 1] = N + 1;

		for ( int i = 1; i <= M; i++ ) {
			a[i] = in.nextInt();
			result = (result * getStepPatterns(a[i] - a[i - 1] - 1)) % D;
		}
		result = (result * getStepPatterns(a[M + 1] - a[M] - 1)) % D;

		System.out.println(result);
		in.close();
	}

	// n段のステップパターンを計算する（nにはスタートとゴールの段を含む）
	private static long getStepPatterns(int ｎ) {
		long D = 1000000007;
		long ptrn = 0;

		if ( ｎ <= 0 ) ptrn = 0;
		else if ( ｎ == 1 || ｎ == 2 ) ptrn = 1;
		else
		// (p+2)段目のパターン = (p+1)段目のパターン + p段目のパターン
		if ( 3 <= ｎ ) {
			long p0, p1, p2;
			p0 = p1 = p2 = 1;

			for ( int i = 2; i < ｎ; i++ ) {
				p2 = (p1 + p0) % D;
				p0 = p1;
				p1 = p2;
			}
			ptrn = p2;
		}
		return ptrn;
	}
}


Measured memory_bytes: 46480
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

S = input().rstrip()

good = True

for i in range(3):
    if S[i] == S[i + 1]:
        good = False

print(["Bad", "Good"][good])


Measured memory_bytes: 3444
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi; ///VECTOR<VECTOR<INT>NAME>NAME 2
typedef vector<vl> vvl;///LONG LONG
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;///VECTOR WITH PAIR
typedef vector<pll> vll;
typedef double dl;

#define endl "\n"
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define over return 0;

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


///--------> YOUR JOURNEY STARTS HERE <-------



int main(){

string s;
cin>>s;
ll sum=0;
if(s=="0"){
        cout<<"Yes"<<endl;
}
else{


for(unsigned int i=0;i<s.length();i++){
    sum+=(s[i]-'0');
}
if(sum%9==0){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
}
over
}


Measured memory_bytes: 3756
#include <stdio.h>

int main(){
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op == '+'){
			printf("%d\n",a + b);
		}else if(op == '-'){
			printf("%d\n",a - b);
		}else if(op == '*'){
			printf("%d\n",a * b);
		}else if(op == '/'){
			printf("%d\n",a / b);
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

struct Info{
	Info(){
		value = depth = 0;
		isOP = false;
		ch = 0;
		used = false;
	}

	int value,depth;
	char ch;
	bool isOP,used;
};

void func(int n){
	char buf[30];

	Info info[30];
	int tmp,index = 0;

	for(int loop = 0; loop < n; loop++){
		scanf("%s",buf);
		tmp = 0;
		for(int i = 0; buf[i] != '\0'; i++){
			if(buf[i] == '.'){
				tmp++;
			}else if(buf[i] >= '0' && buf[i] <= '9'){
				info[index].isOP = false;
				info[index].depth = tmp;
				info[index].value = buf[i] - '0';
				index++;
			}else{
				info[index].isOP = true;
				info[index].depth = tmp;
				info[index].ch = buf[i];
				index++;
			}
		}
	}

	int max_depth,max_loc;

	int pre_loc;

	while(true){
		max_depth = -1;

		for(int i = 0; i < index; i++){
			if(info[i].isOP == true && info[i].used == false && info[i].depth > max_depth){
				max_depth = info[i].depth;
				max_loc = i;
			}
		}
		if(max_depth == -1)break;

		pre_loc = -1;

		for(int i = max_loc+1;(info[i].used == true || info[i].depth == max_depth+1) && i < index;i++){
			if(info[i].used == false && info[i].depth == max_depth+1){
				if(pre_loc == -1){
					pre_loc = i;
					continue;
				}else{
					if(info[max_loc].ch == '*'){
						info[i].value *= info[pre_loc].value;
						info[pre_loc].used = true;
					}else{
						info[i].value += info[pre_loc].value;
						info[pre_loc].used = true;
					}
					pre_loc = i;
				}
			}
			if((i == index - 1) || (info[i+1].used == false && info[i+1].depth != max_depth+1)){
				info[max_loc].value = info[pre_loc].value;
				info[max_loc].isOP = false;
				info[pre_loc].used = true;
			}
		}
	}

	int ans;

	for(int i = 0; i < index; i++){
		if(info[i].used == false && info[i].isOP == false){
			ans = info[i].value;
			break;
		}
	}

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

}

int main(){

	int n;
	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		func(n);
	}

	return 0;
}

Measured memory_bytes: 3228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int[] count = new int[26];
		while ((str = br.readLine()) != null) {
			str = str.toLowerCase();
			for (int i = 0; i < str.length(); i++) {
				char c = str.charAt(i);
				if (Character.isLetter(c)) {
					count[c - 'a']++;
				}
			}
		}
		for (int i = 0; i < count.length; i++) {
			System.out.print((char) ('a' + i));
			System.out.print(" : ");
			System.out.println(count[i]);
		}
	}
}

Measured memory_bytes: 24084