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

int n,r[100005],g[100005],b[100005],cntr,cntg,cntb,pos[300005];

long long A,B,C,ans=1,mod=998244353;

char s[300005];

int main(){
	cin>>n>>s+1;A=n;
	for(int i=1;i<=n*3;i++){
		if(s[i]=='R') r[++cntr]=i;
		if(s[i]=='G') g[++cntg]=i;
		if(s[i]=='B') b[++cntb]=i;
	}
	sort(r+1,r+n+1);sort(g+1,g+n+1);sort(b+1,b+n+1);
	for(int i=1;i<=n;i++) pos[min(r[i],min(g[i],b[i]))]=-1,pos[max(r[i],max(g[i],b[i]))]=1;
	for(int i=1;i<=n*3;i++){
		if(pos[i]==-1) ans=ans*A%mod,A--,B++;
		if(pos[i]==0) ans=ans*B%mod,B--,C++;
		if(pos[i]==1) ans=ans*C%mod,C--;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2944
from collections import deque, defaultdict
n, m = map(int, input().split())
group = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  group[a-1].append(b)
  group[b-1].append(a)
rank = [False]*n
rank[0] = True
ans = [0]*(n-1)

queue = deque([1])
while queue != deque([]):
  now = queue.popleft()
  now_group = group[now-1]
  for m in now_group:
    if rank[m-1]:
      continue
    rank[m-1] = True
    ans[m-2] = now
    queue.append(m)
if None in ans:
  print('No')
else:
  print('Yes')
  for i in range(n-1):
    print(ans[i])

Measured memory_bytes: 34764
#include<stdio.h>
int main(void){
	int input[105];
	int cnt[105];
	int i,max_cnt,end;

	for(i=1;i<=100;i++)cnt[i]=0;
	for(i=1;input[i-1]!=EOF;i++){
		scanf("%d ",&input[i]);
		if(input[i]<=0 || input[i]>100)
			break;
	}
	end=i;
	for(i=1;i<end;i++){//ツ禿シツ療債つオツつスツ青板篠堋づ可つオツつスツつェツづづ、ツつサツづ個要ツ素ツ青板づ個づつアツづォツづー++
		cnt[input[i]]++;
	}
	max_cnt=0;
	for(i=1;i<end;i++){
		if(cnt[i]>max_cnt){//ツ催妥・ツ出ツ個サツ嘉アツ青芭ax_cntツつェツ仰づ慊づゥ
			max_cnt=cnt[i];
		}
	}
	for(i=1;i<end;i++){
		if(cnt[i]==max_cnt){
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
int a[200005],h[200005]={0};
int main()
{
    int n,k=1;
    scanf("%d",&n);

    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=k)
        {
            cnt++;
        }
        else
        {
            k++;
        }
    }
    if(k==1)
    {
        printf("-1");
        return 0;
    }
    printf("%d",cnt);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 1000000007;
struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }
	int root(int x) {
		if (par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	bool issame(int x, int y) { return root(x) == root(y); }
	bool merge(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) { return -par[root(x)]; }
};
int main() {
	ll n, m;
	cin >> n >> m;
	int a[m], b[m];
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	UnionFind tree(n);
	vector<ll> ans(m + 1);
	ans[m] = n * (n - 1) / 2;
	for (int i = m - 1; i >= 0; i--) {
		if (tree.issame(a[i], b[i]))
			ans[i] = ans[i + 1];
		else {
			ans[i] = ans[i + 1] - tree.size(a[i]) * tree.size(b[i]);
			tree.merge(a[i], b[i]);
		}
	}
	rep(i, m) cout << ans[i + 1] << endl;
	return 0;
}

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

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define debug(x) cerr << "  - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << "  - " << #x << ": " << x << "\t\t" << #y << ": " << y << endl;
#define debugv(v, n) cerr << #v << " : " << " "; for(int i = 0; i < n; i++) cerr << "\t" << #v << "[" <<  i <<  "]" <<  " : " << v[i] << "\n"; cerr << endl;
#define sep() cerr << "--------------------" << endl;

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

bool is_prime(int x) {
	for(int i = 2; i * i <= x; i++) 
		if(x % i == 0)
			return false;
	return true;
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int x;
	cin >> x;
	for(int i = x; ; i++) {
		if(is_prime(i)) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    vector<tuple<string, int, int>> tup(N);
    for (int i = 0; i < N; ++i) {
        string s; int p; cin>>s>>p;
        get<0>(tup[i]) = s;
        get<1>(tup[i]) = -p;
        get<2>(tup[i]) = i+1;
    }
    sort(tup.begin(), tup.end());

    for (int i = 0; i < N; ++i) {
        cout<<get<2>(tup[i])<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	cout << a[n-1] - a[0] << endl;
}


Measured memory_bytes: 256
# coding: utf-8
N, M = map(int, input().split())
votes = list(map(int, input().split()))
total = sum(votes)
limit = total / (4 * M)
count = 0
for i in votes:
    if i >= limit:
        count += 1

if count >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string s;
    ll n;
    cin>>s>>n;
    if(s.length() == 1)
        cout<<s<<endl;
    else
    {
        if(s[0]!='1')
            cout<<s[0]<<endl;
        else if(s[0] == '1')
        {
            ll x = s.length(),c=0;
            for(ll i=0;i<x;++i)
            {
                if(s[i]!='1')
                    {
                        c=i;
                        break;
                    }
            }

            if(n<=c)
                cout<<'1'<<endl;
            else
                cout<<s[c]<<endl;

        }

    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int tot[3],n;
int main(){
	int t;
	scanf("%d",&n);
	for(int j=1;j<=n;j++){
		scanf("%d",&t);
		if(t&1) tot[0]++;
		else if(!(t%4)) tot[2]++;
		else tot[1]++;
	}
	if(tot[1]) tot[0]++;
	if(tot[2]<tot[0]-1){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
 
t = list(map(int,input().split()))
 
res = [100000000000000000000]*x
res[0] = 0
 
for i in range(x):
    for j in range(i-y, i):
        if j < 0:
            continue
        res[i] = min(res[i], res[j]+abs(t[i]-t[j]))
 
print(res[-1])

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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;


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

    int count=1;
    int ans=0;
    bool flag=true;

    for(int i=0;i<n;i++){
        if(count!=a[i]){
            ans++;
        }else{
            count++;
            flag=false;
        }
    }

    if(flag) ans=-1;

    cout << ans << endl;
    
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int a, b, o;
    char op;
    while(1) {
        cin >> a >> op >> b;
        if(op == '?')
            break;
        if(op == '+') {
            o = a + b;
        } else if(op == '-') {
            o = a - b;
        } else if(op == '*') {
            o = a * b;
        } else {
            o = a / b;
        }
        cout << o << endl;
    }
}


Measured memory_bytes: 3100
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int n,k;
void ev()
{
    vector<pi>vec,v2;
    int last=n;
    for(int i=n-1,j=n;i>=1;i=i-2,j++)
    {
        vec.pb(mp(i+k,j+k));
        last=j;
    }
    reverse(vec.begin(),vec.end());
    for(int i=n-2,j=last+1;i>=0;i=i-2,j++)
    {
         v2.pb(mp(i+k,j+k));
    }
    reverse(v2.begin(),v2.end());
    for(auto x:v2)
    {
        vec.pb(x);
    }
    int cur=2*n+k;
   for(auto x:vec)
   {
       int sum=x.fi+x.si;
       if(sum>cur)return ;
       cur++;
   }
   cur=2*n+k;
   for(auto x:vec)
   {
       cout<<x.fi<<" "<<x.si<<" "<<cur<<endl;
       cur++;
   }
   exit(0);
}
void od()
{
    vector<pi>vec,v2;
    int last=n;
    for(int i=n-1,j=n;i>=0;i=i-2,j++)
    {
        vec.pb(mp(i+k,j+k));
        last=j;
    }
    reverse(vec.begin(),vec.end());
    for(int i=n-2,j=last+1;i>=1;i=i-2,j++)
    {
         v2.pb(mp(i+k,j+k));
    }
    reverse(v2.begin(),v2.end());
    for(auto x:v2)
    {
        vec.pb(x);
    }
    int cur=2*n+k;
   for(auto x:vec)
   {
       int sum=x.fi+x.si;
       if(sum>cur)return ;
       cur++;
   }
   cur=2*n+k;
   for(auto x:vec)
   {
       cout<<x.fi<<" "<<x.si<<" "<<cur<<endl;
       cur++;
   }
   exit(0);
}
 main()

{
    fast
    cin>>n>>k;
    if(n%2==0)ev();
    else od();
    cout<<"-1"<<endl;
    return 0;

}





































Measured memory_bytes: 6088
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>



bool isPrime(int num) {
	if (num == 1)return false;
	if (num == 2)return true;

	for (int i = 2; i * i <= num; i++)
		if (num % i == 0)
			return false;

	return true;
}

int main() {

	int size;
	int num;
	int count = 0;

	std::cin >> size;

	for (int i = 0; i < size; i++) {
		std::cin >> num;
		if (isPrime(num))count++;
	}

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

//	system("pause");
	return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	
	ll n;cin>>n;
	ll a[n];rep(i,0,n)cin>>a[i];
	ll ans=inf,sum=0,pev=0,cnt1=0,cnt=0;
	rep(i,0,n){
		sum+=a[i];
		if(a[i]==1)cnt++;
	}
	rep(i,0,n){
		pev+=a[i];
		ans=min(ans,abs(sum-pev-pev));
	}
	cout<<ans;
	return 0;
}



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

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

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

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

    string S, T;
    cin >> S >> T;
    int result = 0;
    REP(i, S.size()) {
        if (S[i] != T[i]) {
            ++result;
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 3808
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;


signed main(){
	cin>>N;
	bool flag=false;
	int k=(int)sqrt(2*N);
	DEB(k)END
	if(k*(k+1)==2*N){
		cout<<"Yes"<<endl;
		cout<<k+1<<endl;
		int ans=0;
		vector<int> v[k+2];
		int B[k+2][k+2];
		int t=1;
		for(int i=0;i<=k-1;i++){
			for(int j=0;j<=i;j++){
				B[i][j]=t;
				t++;
			}
		}
		DEB(t)END
		for(int i=0;i<=k-1;i++){
			for(int j=0;j<i;j++){
				v[i].push_back(B[i][j]);
			}
			for(int j=i;j<=k-1;j++){
				v[i].push_back(B[j][i]);
			}
		}
		DEB(t)END
		int a=1,b=2;
		v[k].push_back(1);
		for(int j=1;j<=k-1;j++){
			v[k].push_back(a+b);
			a=a+b;
			b++;
		}
		REP(i,k+1){
			cout<<v[i].size();
			REP(j,v[i].size()){
				cout<<" "<<v[i][j];
			}
			cout<<endl;
		}
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 4736
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    st s; cin >> s;
    ll n = s.size();
    bool flag = true;
    rep(i,n / 2){
        if(!(s[i] == s[n - 1 - i] && s[i] == s[(n - 1) / 2 - 1 - i] && s[i] == s[(n + 3) / 2 - 1 + i])){
            flag = false;
        }
    }
    Yes(flag);
}



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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int>> list(H * W, vector<int>(2));  
    int tmp;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> tmp;
            list[tmp - 1][0] = i, list[tmp - 1][1] = j;
        }
    }
    vector<int> length(H * W);
    for (int i = 0; i < H * W; i++)
    {
        if (i < D)
            length[i] = 0;
        else
        {
            tmp = i - D;
            length[i] = length[tmp] + abs(list[tmp][0] - list[i][0]) + abs(list[tmp][1] - list[i][1]);
        }
    }
    int Q, L, R;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        cin >> L >> R;
        cout << length[R - 1] - length[L - 1] << endl;
    }
}

Measured memory_bytes: 8428
import java.util.Comparator

fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt().toIntArray()
    val B = A.sorted()
    val ans = mutableListOf<Pair<Int, Int>>()
    if (B.first().sign() != B.last().sign()) {
        val max = if (-B.first() > B.last()) B.first() else B.last()
        var p = 0; while (A[p] != max) p += 1
        for (n in 0 until N) {
            if (A[n] != max) {
                ans.add(p to n)
                A[n] += max
            }
        }
    }
//System.err.println(A.joinToString(" "))
    if (A.first().sign() == 1) {
        for (n in 1 until N) {
            ans.add(n - 1 to n)
            A[n] += A[n - 1]
        }
    } else {
        for (n in (0 until N - 1).reversed()) {
            ans.add(n + 1 to n)
            A[n] += A[n + 1]
        }
    }
    println(ans.size)
    ans.forEach { println("${it.first + 1} ${it.second + 1}") }
//System.err.println(A.joinToString(" "))
}
fun Int.sign() = if (this >= 0) 1 else -1

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map(String::toLong)


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

int main(){
    int yen;
    cin >> yen;

    int happy = 0;
    happy += (yen / 500)*1000;
    yen -= (yen / 500)*500;
    happy += (yen / 5)*5;

    cout << happy << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>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); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, x;
int s[202];
LL dp[202][101010];
const int mod = 1e9 + 7;

int main(){
    INIT;
    cin >> n >> x;
    REP(i, n)cin >> s[i];
    sort(s, s + n);
    REP(i, x + 1)dp[0][i] = i;
    REP(i, n){
        REP(j, x + 1){
            (dp[i + 1][j] += dp[i][j % s[i]]) %= mod;
            (dp[i + 1][j] += dp[i][j] * i) %= mod;
        }
    }
    cout << dp[n][x] << endl;
}

Measured memory_bytes: 158848
s=input()
temp = 1 if len(s) % 2 != 0 else 2
for i in range(temp, len(s), 2):
  moji = s[:len(s)-i]
  #print(moji[:len(moji)//2], moji[len(moji)//2:])
  if moji[:len(moji)//2] == moji[len(moji)//2:]:
    print(len(moji))
    break


Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
const int inf= (int)(1e19+10LL);
void solve()
{
  int n;
  sl(n);
  Vl dp(n+1,0);
  Vl arr(n+1);
  for(int i=1;i<=n;i++)sl(arr[i]);
  Vl odd(n+1,0);
  odd[1]=arr[1];
  for(int i=3;i<=n;i+=2){
	  odd[i]=odd[i-2]+arr[i];
  }
  for(int i=2;i<=n;i++)
  {
	  if(i%2){
		  dp[i]=max(dp[i-1],arr[i]+dp[i-2]);
	  }
	  else{
		  dp[i]=arr[i]+dp[i-2];
		  dp[i]=max(dp[i],odd[i-1]);
	  }
  }
  cout<<dp[n]<<endl;
		
}
 
signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();
 
   }
  return 0;
}


Measured memory_bytes: 8008
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
const int MOD = 1e9+7;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

    if(n == 1 && a[0] == 0){
        cout << 1 << endl;
        return 0;
    }else if(n == 1 && a[0] != 0){
        cout << 0 << endl;
        return 0;
    }

    sort(a.begin(),a.end());
    
    vector<int> b(n);
    for(int i=n-1;i>=0;i-=2){
        b[i] = i;
        b[i-1] = i;
    }
    
    rep(i,n){
        if(a[i] != b[i]){
            cout << 0 << endl;
            return 0;
        }
    }
    
    ll ans = modPow(2,n/2,MOD);
    cout << ans << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n, ans=0; cin>>n;
    string s; cin>>s;
    rep(i,10){
        ll ind_f=0;
        bool not_found=1;
        for(ll ii=0;ii<s.size();ii++){
            if(s[ii]-'0'==i){
                ind_f=ii+1, not_found=0;
                break;
            }
        }
        if(not_found) continue;
        rep(j,10){
            ll ind_s=ind_f;
            not_found=1;
            for(ll ii=ind_f;ii<s.size();ii++){
                if(s[ii]-'0'==j){
                    ind_s=ii+1, not_found=0;
                    break;
                }
            }
            if(not_found) continue;
            rep(k,10){
                for(ll ii=ind_s;ii<s.size();ii++){
                    if(s[ii]-'0'==k){
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int a;
  cin>>a;
  int i;
  long int sum =0;
  //cout<<a<<endl;
  for(i=1;i<a+1;i++){
  /*  if(i%3==0 && i%5==0){
      break;
    }else */
    if(i%3!=0&&i%5!=0){
      sum+=i;
    }
    
  }
 
         cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n)                                                              \
    for (int64_t i = 0; i < (int64_t)(n); i++)                                 \
        ;
using namespace std;
int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vector<int64_t> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    int64_t tmp_min = 1000000007, res = 0;
    for (int i = 0; i < n; i++) {
        if (p.at(i) < tmp_min) {
            res++;
            tmp_min = p.at(i);
        }
    }
    cout << res << endl;
}

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

int main(){
  int a;
  char b[120];
    cin>>a;
  for(int i=0;i<a;i++)
  cin >>b[i];
  
  
    for(int i=0;i<a;i++){

   if(b[i] == 'Y'){
     cout << "Four" <<endl;
     return 0;
   }
    }
       
    cout << "Three" << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import deque
h,w=map(int,input().split())
MAP=[list(input().strip()) for _ in range(h)]
q=deque()
for i,M in enumerate(MAP):
    for j,m in enumerate(M):
        if m=='#':
            q.append((i,j,0))
delta=[(1,0),(-1,0),(0,1),(0,-1)]
ans=0
while q:
    x,y,d=q.popleft()
    ans=max(ans,d)
    for dx,dy in delta:
        if 0<=x+dx<h and 0<=y+dy<w:
            if MAP[x+dx][y+dy]=='.':
                MAP[x+dx][y+dy]='#'
                q.append((x+dx,y+dy,d+1))
print(ans)

Measured memory_bytes: 160988
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vll as(n);
  rep(i, n) cin >> as[i];

  ll q;
  cin >> q;
  map<ll, bool> mp;
  vll lst(q);
  rep(i, q) {
    ll v;
    cin >> v;
    mp[v] = false;
    lst[i] = v;
  }

  rep(s, 1 << n) {
    ll sum = 0;
    rep(i, n) {
      bool cond = (s >> i) & 1;
      if (cond) {
        sum += as[i];
      }
    }  // i
    if (mp.count(sum) > 0) mp[sum] = true;
  }  // s

  rep(i, q) {
    if (mp[lst[i]])
      puts("yes");
    else
      puts("no");
  }

  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>

using namespace std;

#define int long long

string S;
int cnt, ans;

signed main() {
	
	cin >> S;
	
	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'W') cnt++;
		if (S[i] == 'B') ans += cnt;
	}
	
	cout << ans << endl;
	
	return 0;
	
}

Measured memory_bytes: 640
#include <stdio.h>

main()
{
	int a,b;
	scanf("%d %d",&a,&b);

	if (a < b)
	{
		printf("%s\n", "a < b");
	}
	else if (a > b)
	{
		printf("%s\n", "a > b");
	}
	else if (a = b)
	{
		printf("%s\n", "a == b");
	}
	return 0;
}


Measured memory_bytes: 2100
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] L = new int[N];

		for(int i=0;i<N;i++) {
			L[i] = sc.nextInt();
		}

		Arrays.sort(L);

		int sum = 0;
		for(int i=0;i<L.length-1;i++) {
			sum += L[i];
		}
		if(sum > L[L.length-1]) {
			out.println("Yes");
		}else {
			out.println("No");
		}

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
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; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){
ll a,b;
cin >> a >> b;
cout << a*b << endl;
 
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

int main(){
    int N, C[200000];
    cin >> N;
    for(int i=0; i<N; i++) cin >> C[i];

    int left[200001];
    for(int i=0; i<=200000; i++) left[i] = -1;
    static int64_t dp[200001];
    dp[0] = 1;
    for(int i=0; i<N; i++){
        add(dp[i+1], dp[i]);
        int c = C[i];
        if(left[c] >= 0 && left[c] < i-1) add(dp[i+1], dp[left[c]+1]);
        left[c] = i;
    }
    cout << dp[N] << endl;
    return 0;
}


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

typedef long long ll;

int main(){
	std::ios::sync_with_stdio(false);

	int wa, wb, sa, sb, dissolvepercent, sum;
	std::cin >> wa >> wb >> sa >> sb >> dissolvepercent >> sum;

	int ra = 0, rb = 1;

	for(int i = 0; i <= sum; i += wa * 100){
		for(int j = 0; i + j <= sum; j += wb * 100){
			int water_sum = i + j;
			for(int k = 0; water_sum + k <= sum; k += sa){
				for(int l = 0; water_sum + k + l <= sum; l += sb){
					int sugar_sum = k + l;
					if(water_sum / 100 * dissolvepercent >= sugar_sum){
						if(sugar_sum * (ra + rb) >= ra * (water_sum + sugar_sum)){
							ra = sugar_sum;
							rb = water_sum;
						}
					}
				}
			}
		}
	}

	std::cout << ra + rb << ' ' << ra << std::endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int a;
    cin >> a;
    cout << (a >= 1200 ? "ARC" : "ABC");
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
 
using namespace std;
 
int main() {
	int x;
  	int i = 1;
  	int foundIdx = 0;
  	while (i <= 5) {
      cin >> x;
      if (x == 0) foundIdx = i;
      i++;
    }
  cout << foundIdx << endl;
  return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll INF = (1LL<<60);

int main(){

    ll x; cin >> x;

    ll year=0;
    long double y=100;
    while(y<x){
        y*=1.01;
        y = (ll)y;
        year++;
    }

    cout << year << endl;

    return 0;
}

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

int main(){
	int h,w;
	while(1){
		cin >> h >> w;
		if(h == 0 and w == 0) return 0;
		for(int i = 0; i < h; i++){
			for(int k = 0; k < w; k++){
				if(i == 0 or i == h-1 or k == 0 or k == w-1){
					cout << "#";
				}else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
    
    ll n,i,cn = 1,ans=0;
    cin>>n;
    while(1)
    {
    	if(n==1)
    	{
    		ans += cn;
    		break;
    	}
    	ans += cn;
    	n /= 2;
    	cn *= 2;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef unsigned ui;
signed main(void)
{
	ui a,b;
	scanf("%u%u",&a,&b);
	ui n(a+b);
	if(a<=b)
	{
		puts("Impossible");
		return 0;
	}
	static char ans[5001];
	static ui st[5001],top;
	for(ui i(0);i<n;++i)
		if(!top)
			st[++top]=i;
		else
		{
			printf("? %u %u\n",st[top],i);
			fflush(stdout);
			scanf("%s",ans);
			if(ans[0]=='Y')
				st[++top]=i;
			else
				--top;
		}
	static bool Ans[5001];
	for(ui i(0);i<n;++i)
	{
		printf("? %u %u\n",st[top],i);
		fflush(stdout);
		scanf("%s",ans);
		Ans[i]=ans[0]=='Y';
	}
	printf("! ");
	for(ui i(0);i<n;++i)
		putchar(Ans[i]?'1':'0');
	putchar('\n');
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 724
#include <stdio.h>
int main(void){
  int a,b,c,d,t,k;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  t=c/b;
  k=a/d;
  if(c%b!=0)
    t=t+1;
  if(a%d!=0)
    k=k+1;
  if(t>k)
    printf("No\n");
  else if(t<=k)
    printf("Yes\n");
  return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
#define f(a,b,c) for (int a=b;a<=c;++a)
//暴力专用打法
int ans;
using namespace std;
int main()
{
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	f(i,0,a)
	{
		f(j,0,b)
		{
			f(k,0,c)
			{
				int l=i*500+j*100+k*50;
				if (l==x)
				 ++ans;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------
bool color[200001];
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int r,g,b,n;cin>>r>>g>>b>>n;
    int ans=0;
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            int now=i*r+j*g;
            int y=n-now;
            if(y%b==0&&y>=0)
                ans++;
        }
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------

/*
ll n;cin>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++)
    cin>>a[i];
 
ll n;cin>>s;
string s;cin>>s;

ll n,m;cin>>n>>m;
vector<ll>a(n),b(m);
for(ll i=0;i<n;i++){
    cin>>a[i];
}
for(ll i=0;i<m;i++){
    cin>>b[i];
}

ll n;cin>>n;
vector<Pll>xy;
for(ll i=0;i<n;i++){
    ll x,y;cin>>x>>y;
    xy.pb({x,y});
}
*/


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for h in range(c + 1):
            if 500 * i + 100 * j + 50 * h == x:
                ans += 1
                #print(i, j, h)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const vector<string> targets = {
	"dreameraser",
	"dreamerase",
	"dreamer",
	"dream",
	"eraser",
	"erase"
};

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

	int idx = 0;

	while (idx < s.size()) {
		bool updates = false;
		for (auto t: targets) {
			string u = s.substr(idx, t.size());
			if (u == t) {
				idx += u.size();
				updates = true;
				break;
			}
		}

		if (!updates) {
			break;
		}
	}

	cout << (idx == s.size() ? "YES" : "NO") << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

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

	int r, D, x;
	cin >> r >> D >> x;
	for(int i = 1; i <= 10; i++){
		x = r * x - D;
		cout << x << endl;
	}

}


Measured memory_bytes: 256
N, M = map(int, input().split())
s_locs = [list(map(int, input().split())) for _ in range(N)]
c_locs = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    now_x, now_y = s_locs[i]
    closest_cp_idx = None
    min_dist = float("inf")
    for j in range(M):
        dist = abs(c_locs[j][0]-now_x) + abs(c_locs[j][1]-now_y)
        if dist < min_dist:
            min_dist = dist
            closest_cp_idx = j+1
    print(closest_cp_idx)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);
  
  int max = a + b;
  if (max < a - b) max = a - b;
  if (max < a * b) max = a * b;
  
  printf("%d", max);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int total = 0;
		for (int i = 0; i * r <= n; i++) {
			for (int j = 0; i * r + j * g <= n; j++) {
				if ((n - i * r - j * g) % b == 0) {
					total++;
				}
			}
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 23892
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,t,ans;

main(){
    cin>>n;
    int c[n]={},s[n]={},f[n]={};
    rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
    rep(i,n){
        //ans+=s[i]+c[i];
        //cout<<ans<<endl;
        for(int j=i;j<n-1;j++){
            //ans=max(s[j],ans+(ans%f[j]))+c[j];
            //ans=max(s[j],ans+f[j]-(ans%f[j]))+c[j];
            //cout<<ans<<endl;
			if(ans<s[j])ans=s[j];
			else if(ans%f[j]==0);
			else ans+=f[j]-ans%f[j];
			ans+=c[j];
        }
        dans;
        ans=0;
    }
    //dump(0);
}



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

int main() {
	int n, l;
	cin >> n >> l;

	int app, sum;
	for (int i = 1; i < n + 1; i++) {
		app = l + i - 1;
		sum += app;
	}

	if (l >= 0) {
		sum = sum - l;
	}
	else if (l < 0 && n <= l * -1) {
		sum = sum - (l + n - 1);
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
    K = int(input())
    S = input()
    length_S = len(S)
    if length_S <= K:
        print('{}'.format(S))
    else:

        a = S[0:K]
        a += '...'
        print('{}'.format(a))



if __name__ == "__main__":
    solve()


Measured memory_bytes: 9168
// B - Buffet
#include <stdio.h>

int main(void){
    int a[20], b[20], c[20];
    int n, i, sum=0;
    scanf("%d", &n);
    for(i=0; i<n; i++){scanf("%d", &a[i]);}
    for(i=0; i<n; i++){scanf("%d", &b[i]);}
    for(i=0; i<n-1; i++){scanf("%d", &c[i]);}

    for(i=0; i<n; i++){
        sum+=b[a[i]-1];
        if(i>0 && a[i]==a[i-1]+1){sum+=c[a[i-1]-1];}
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N (1<<18)
#define X 1000000007
#define LT rt<<1,d+1
#define RT rt<<1|1,d+1
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
using namespace std;
int H,L,ans,p[N+5],V[N+5];
I void Work(CI rt,CI d,RI v)
{
	if(v=1LL*v*rt%X,d==H) {RI x=p[rt-L]+L;W(x) v=1LL*v*x%X,Inc(V[x],v),x>>=1;}
	else Work(LT,v),Work(RT,v);
}
I void Calc(CI rt,CI d,RI v)
{
	if(v=1LL*v*rt%X,d==H) {RI x=p[rt-L]+L;W(x^1) v=1LL*v*x%X,ans=(1LL*v*(x>>1)%X*V[x^1]+ans)%X,x>>=1;}
	else Calc(LT,v),Calc(RT,v);
}
I void Travel(CI rt=1,CI d=1)
{
	if(d==H) return;Work(LT,rt),Calc(RT,1),Work(LT,X-rt),Travel(LT),Travel(RT);
}
int main()
{
	RI i;for(scanf("%d",&H),L=1<<H-1,i=0;i^L;++i) scanf("%d",p+i),--p[i];
	return Travel(),printf("%d\n",ans),0;
}

Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b,c;
  cin>>k;
  long long x,y,ans=0;
  for(a=1;a<=k;a++){
    for(b=1;b<=k;b++){
      x=gcd(a,b);
      for(c=1;c<=k;c++){
        y=gcd(x,c);
        ans+=y;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

counter = 0

(0..A).each do |a|
  (0..B).each do |b|
    (0..C).each do |c|
      sum = (500 * a) + (100 * b) + (50 * c)
      counter += 1 if X == sum
    end
  end
end

puts counter


Measured memory_bytes: 1788