akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
namespace io
{
#define SIZ (1 << 21 | 1)
#define gc() (io::iS == io::iT ? (io::iT= (io::iS= io::ibuff) + fread(io::ibuff, 1, SIZ, stdin), (io::iS == io::iT ? EOF : *io::iS++)) : *io::iS++)
#define putc(x) (io::oS == io::oT ? (fwrite(io::obuff, 1, io::oS - io::obuff, stdout), io::oS= io::obuff, (*io::oS++= x)) : *io::oS++= x)
#define exit                                          \
	fwrite(io::obuff, 1, io::oS - io::obuff, stdout); \
	return 0;
	char *iS, *iT, ibuff[SIZ], obuff[SIZ], *oS= obuff, *oT= oS + SIZ - 1, fu[110], c;
	int fr;
	template <class Type>
	inline void read(Type &x)
	{
		x= 0;
		Type y= 1;
		for(c= gc(); (c > '9' || c < '0') && c != '-'; c= gc())
			;
		c == '-' ? y= -1 : x= (c & 15);
		for(c= gc(); c >= '0' && c <= '9'; c= gc()) x= x * 10 + (c & 15);
		x*= y;
	}
	inline void reads(char *x)
	{
		for(c= gc(); c == ' ' || c == '\n'; c= gc())
			;
		for(; c != ' ' && c != '\n' && c != EOF; *x= c, c= gc(), ++x)
			;
	}
	template <class Type>
	inline void print(Type x, char text= '\n')
	{
		if(x < 0) putc('-'), x*= -1;
		if(x == 0) putc('0');
		while(x) fu[++fr]= x % 10 + '0', x/= 10;
		while(fr) putc(fu[fr--]);
		putc(text);
	}
	inline void prints(char *x, char *y= NULL, char text= '\n')
	{
		for(; *x && x != y; ++x) putc(*x);
		putc(text);
	}
}  // namespace io
using io::print;
using io::prints;
using io::read;
using io::reads;
long long n, x, a, b, ans;
signed main()
{
	read(n), read(x);
	ans= n, a= x, b= n - x;
	while(1)
	{
		if(a < b) swap(a, b);
		if(a % b == 0)
		{
			ans+= a * 2 - b;
			break;
		}
		else
		{
			ans+= a / b * 2 * b;
			a%= b;
		}
	}
	print(ans);
	exit;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll tmp=0,r=0,g=0,b=0;
    rep(0,i,n){
        if(s[i]=='R')++r;
        else if(s[i]=='G')++g;
        else if(s[i]=='B')++b;
        rep(i+1,j,n){
            ll k=i+2*(j-i);
            if(k<n){
                if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k])++tmp;
            }
        }
    }
    cout<<r*g*b-tmp;
}

Measured memory_bytes: 3624
n=int(input())
work=[]
for i in range(n):
    a,b=map(int,input().split())
    work.append((b,a))
work.sort()
a_sum=0
import sys
for i in work:
    b=i[0]
    a_sum=a_sum+i[1]
    if b<a_sum:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 65240
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 10010000000
//#define NIL -1
//#define INFTY 1000000000000000000

LL labs(LL x){
    if(x>0){
        return x;
    }else{
        return x*(-1);
    }
}

int main(){
    LL a;
    LL b;
    LL q;
    cin >> a >> b >> q;
    vector<LL> s(a);
    vector<LL> t(b);
    vector<LL> x(q);
    for(LL i=0; i<a; i++){
        cin >> s[i];
    }
    for(LL i=0; i<b; i++){
        cin >> t[i];
    }
    for(LL i=0; i<q; i++){
        cin >> x[i];
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    LL tmp0;
    LL tmp1;
    LL tmp2;
    LL tmp3;
    for(LL i=0; i<q; i++){
        auto itr_s=lower_bound(s.begin(), s.end(), x[i]);
        auto itr_t=lower_bound(t.begin(), t.end(), x[i]);
        LL dist_s=distance(s.begin(), itr_s);
        LL dist_t=distance(t.begin(), itr_t);
        if(dist_s!=0){
            if(dist_t!=t.size()){
                tmp0=min(labs(x[i]-s[dist_s-1]),labs(t[dist_t]-x[i]))+labs(t[dist_t]-s[dist_s-1]);
            }else{
                tmp0=2*MAX;
            }
            if(dist_t!=0){
                tmp1=x[i]-min(s[dist_s-1], t[dist_t-1]);
            }else{
                tmp1=2*MAX;
            }
        }else{
            tmp0=2*MAX;
            tmp1=2*MAX;
        }
        if(dist_s!=s.size()){
            if(dist_t!=t.size()){
                tmp2=max(s[dist_s],t[dist_t])-x[i];
            }else{
                tmp2=2*MAX;
            }
            if(dist_t!=0){
                tmp3=min(labs(x[i]-t[dist_t-1]),labs(s[dist_s]-x[i]))+labs(s[dist_s]-t[dist_t-1]);
            }else{
                tmp3=2*MAX;
            }
        }else{
            tmp2=2*MAX;
            tmp3=2*MAX;
        }
        //cout << dist_s << " " << dist_t << endl;
        //cout << tmp0 << " " << tmp1 << " " << tmp2 << " " << tmp3 << endl;
        cout << min(min(tmp0,tmp1),min(tmp2,tmp3)) << endl;
    }

    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N;
ll a[20][20];
ll sum[1000000]; // sum[S]: 集合Sに含まれる要素の和
ll dp[1000000]; // dp[S]: 集合Sの要素をグループ分けした時の得点の最大値

signed main() {
  cin >> N;
  rep(i, N) rep(j, N) cin >> a[i][j];
  for (ull S = 0; S < (1 << N); S++)
    for (int i=0; i<N; i++)
      for (int j=i+1; j<N; j++)
        if ((S & (1 << i)) && (S & (1 << j)))
          sum[S] += a[i][j];
  dp[0] = 0; // 空集合
  for (ull S = 1; S < (1 << N); S++) {
    dp[S] = sum[S];
    for (ull U = (S-1) & S; ; U = (U-1) & S) { // Sの真部分集合
      chmax(dp[S], dp[U] + sum[S - U]);
      if (U == 0) break;
    }
  }
  cout << dp[(1 << N) - 1] << endl;
  return 0;
}


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

int main(void)
{
	int H,W;
	int i,j;

	while (1) {
		cin >> H;
		cin >> W;

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

		for (i = 0; i < H; i++) {
			for ( j = 0; j < W; j++) {
				if ((i%2) == 0) {
					if ((j%2) == 0) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				else {
					if ((j%2) == 0) {
						cout << ".";
					}
					else {
						cout << "#";
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}



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

int main() {
  int N;
cin>>N;
vector<string> v(N);
  for(int i=0;i<N;i++){
   cin>>v.at(i); 
  }
  sort(v.begin(),v.end());
map<string,int> c;
	for(int i;i<N;i++){
if(c.count(v.at(i))){
 c.at(v.at(i))++;
  v.at(i)="0";
}
  else{
   c[v.at(i)]=1; 
  }
}
int cmn=0,cmt=-1;
for(auto i:v){
  if(c.count(i)){
 if(cmt<c.at(i)){
   cmt=c.at(i);
}
  }
}
for(auto i:v){
   if(c.count(i)){
 if(cmt==c.at(i)) {
   cout<<i<<endl;
 }
 }
}
}


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

int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int answer = 0;
    for(int i = 0; i < 2; i++)
    {
        if(A > B){
            answer += A;
            A--;
        }else{
            answer += B;
            B--;
        }
    }
    cout << answer << endl;
    return 0;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()

#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("d",&a,&b)
#define sfff(a,b,c)     scanf("d%d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define PRINT_CASE printf("Case %d: ",z)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)1e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

ll DP[maxn];
int n,arr[maxn];

ll cal(int pos){

    if(pos==n-1) return 0LL;

    ll &res=DP[pos];

    if(res!=-1){
        return res;
    }

    res = cal(pos+1) + abs(arr[pos+1]-arr[pos]);
    if(pos+2<n) res=min(res, cal(pos+2)+abs(arr[pos+2]-arr[pos]));
    return res;
}


int main() {
    //CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin>>n;

    f0(i,n){
        cin>>arr[i];
    }

    memset(DP, -1, sizeof(DP));

    cout<<cal(0)<<endl;

    return 0;
}


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

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef pair<int, int>pii; typedef pair<long, long>pll; typedef pair<string, int>psi;
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<long long>vll; typedef vector<pair<int,int> > vii;
typedef set<int> si; typedef set<string> ss; typedef set<bool> sb; typedef set<long long>sll; typedef set<pair<int, int> > sii;
typedef list<int> li; typedef list<string> ls; typedef list<bool> lb; typedef list<long long>lll; typedef list<pair<int, int> > lii;
typedef map<string, int> msi;
void fastIO(){ ios_base::sync_with_stdio(false); cin.tie(0); }
ll sss(ll a)
{
	return a*(a - 1) / 2;
}
int arr[26];
int main() {
	string s;
	cin >> s;
	ll l = s.size(), sum=0;
	for (char ch='a';ch<='z';ch++)
	{
		arr[ch - 97]=count(s.begin(), s.end(),ch);
	}
	for(auto e: arr)
	{
		sum += sss(e);
	}
	std::cout << sss(l)-sum+1;
}


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

int n, c;
int ans = 1e9+7;
vector<vector<int> > a, b, v;

int func(int x, int y){
	int res = 0;
	for(int i=0; i<c; ++i){
		if(i != y){
			res += v[x][i] * a[i][y];
		}
	}
//	cout << x << " " << y << " " << res << "\n";
	return res;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> c;
	a.resize(c);
	for(int i=0; i<c; ++i)
		for(int j=0; j<c; ++j){
			int t;
			cin >> t;
			a[i].push_back(t);
		}
	b.resize(n);
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j){
			int t;
			cin >> t;
			b[i].push_back(t-1);
		}
	v.resize(3);
	for(int i=0; i<c; ++i){
		v[0].push_back(0);
		v[1].push_back(0);
		v[2].push_back(0);
	}
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			++v[(i+j)%3][b[i][j]];
/*	for(int i=0; i<3; ++i){
		for(int j=0; j<c; ++j){
			cout << v[i][j] << " ";
		}
		cout << "\n";
	}
*/	for(int i=0; i<c; ++i)
		for(int j=0; j<c; ++j)
			for(int k=0; k<c; ++k){
				if(i == j || j == k || k == i) continue;
				int tmp = 0;
				tmp += func(0, i);
				tmp += func(1, j);
				tmp += func(2, k);
//				if(tmp == 1) cout << i << " " << j << " " << k << "\n";
				ans = min(ans, tmp);
			}
	cout << ans << "\n";
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 36
 
 
main(){
 
  char nul;
  char C1[N],C2[N];
  char tmpc;
 
 
  int A1[N],A2[N];
  int n,i,j,k=0;
  int tmp;
  int flag,mini,min;
 
 
 
  scanf("%d%c",&n,&nul);
  if(n<1||n>36)return 0;
 
  for(i=0;i<n;i++){
    scanf("%c%d%c",&C1[i],&A1[i],&nul);
    C2[i]=C1[i];
    A2[i]=A1[i];
  } 
 
 for(i=0;i<n;i++){
   for(j=1;j<n;j++){
 
     if(A1[j]<A1[j-1]){
       tmp=A1[j];
       tmpc=C1[j];
       A1[j]=A1[j-1];
       C1[j]=C1[j-1];
       A1[j-1]=tmp;
       C1[j-1]=tmpc;
     }
   }
 }
  
 for(i=0;i<n;i++){
   printf("%c%d",C1[i],A1[i]);
   if(i<n-1)printf(" ");
   if(i==n-1)printf("\n");
 }
 printf("Stable\n");
 
 
  
  
  min=A2[0];
 
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(min>A2[j]){
    min=A2[j];
    mini=j;
    flag=1;
      }
    }
 
    if(flag==1){
    tmp=A2[i];
    tmpc=C2[i];
    A2[i]=A2[mini];
    C2[i]=C2[mini];
    A2[mini]=tmp;
    C2[mini]=tmpc;
    flag=0;
      }
    min=A2[i+1];
  }
 
for(i=0;i<n;i++){
   printf("%c%d",C2[i],A2[i]);
   if(i<n-1)printf(" ");
   if(i==n-1)printf("\n");
   if(C1[i]!=C2[i]){
     k=1;
   }
 }
 
 if(k==1)printf("Not stable\n");
 else printf("Stable\n");
 return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, T;
    cin >> n >> T;
    int cost = INF;
    rep(i, n) {
        int c, t;
        cin >> c >> t;
        if(t > T) continue;
        else {
            chmin(cost, c);
        }
    }
    if(cost == INF) cout << "TLE" << endl;
    else cout << cost << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> m(n);
    rep(i, n) cin >> m[i].first >> m[i].second;
    ll ans = 0;
    ll cura = 0;
    sort(ALL(m));
    deque<pair<int, int>> que;
    rep(i, n)
    {
        ll curx = m[i].first;
        ll curh = m[i].second;
        while (!que.empty() && que.front().first < curx)
        {
            cura -= que.front().second;
            que.pop_front();
        }

        curh -= cura * a;
        if (curh <= 0)
        {
            continue;
        }
        ll need = (curh + a - 1) / a;
        cura += need;
        ans += need;
        que.push_back({curx + 2 * d, need});
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
n,q=map(int,input().split())
s=input()
l=[0]*n
tmp=0
for i in range(n-2,-1,-1):
    if s[i:i+2]=="AC":
        tmp+=1
    l[i]+=tmp
#print(l)
for i in range(q):
    L,R=map(int,input().split())
    print(l[L-1]-l[R-1])

Measured memory_bytes: 13084
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;

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

	if(a == b){
		if(b!=c)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	else if(a == c){
		if(b!=c)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}

	else if(b == c){
		if(a!=b)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}

	else
		cout<<"No\n";
	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int count=0;
	for(int i=0;i<n;i++){
		if(a[i]%2==0){
			if((a[i]%3!=0)&&(a[i]%5!=0)){
				cout << "DENIED" << endl;
				count++;
				break;
			}
		}
	}
	if(count==0){
		cout << "APPROVED" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int n;
    cin >> n;
    vector<int> a(n);
    int maxi=0;
    int mini=0;
    rep(i,n){
        cin >> a[i];
        if(a[maxi]<a[i]){
            maxi = i;
        }
        if(a[mini]>a[i]){
            mini = i;
        }
    }
    int cnt=0;
    vector<pair<int,int>> ans;

    cout << 2*n-1 << endl;

    if(abs(a[maxi])>abs(a[mini])){
        int x = a[maxi];
        rep(i,n){
            a[i]+=x;
            cout << maxi+1 << " " << i+1 << endl;
        }
        rep(i,n-1){
            a[i+1]+=a[i];
            cout << i+1 << " " << i+2 << endl;
        }
    }
    else{
        int x = a[mini];
        for(int i=n-1;i>=0;i--){
            a[i]+=x;
            cout << mini+1 << " " << i+1 << endl;
        }
        for(int i=n-1;i>0;i--){
            a[i-1]+=a[i];
            cout << i+1 << " " << i << endl;
        }

    }
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pb push_back
#define mk make_pair
//#define REP(i,a,b) for(int i=a; i<=b; i++)
#define mod 1000000007

int main()
{
    ll n;
    float ans;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    // for(int x : v)
    //     cout << x << " ";
    stack<float> a;
    for(int i=n-1;i>=0;i--)
    {
        a.push(v[i]);
    }
    while(a.size()!=1)
    {
        float p=a.top();
        a.pop();
        float q=a.top();
        a.pop();
        ans=(p+q)/2;
        a.push(ans);
       // cout << a.size() << endl;
    }
    cout<<a.top();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;

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

    //dp[i][j] := i番目までで未確定の個数がj個の場合の数
    vector<vector<lli> > dp(n+1, vector<lli>(n+2, 0));
    dp[0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=n; j++){
            if(dp[i][j] == 0) continue;
            if(c[i] == '-'){
                dp[i+1][j] = dp[i][j];
            }
            if(c[i] == 'U'){
                //単純に未定が1つ増える
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= mod;
                //未定の一つを今見ている順位で確定する
                dp[i+1][j] += dp[i][j]*j %mod;
                dp[i+1][j] %= mod;
            }
            if(c[i] == 'D'){
                //未定のどれかを割り当てる
                dp[i+1][j] += dp[i][j]*j %mod;
                dp[i+1][j] %= mod;
                //さらに未定の一つを今見ている順位で確定する
                dp[i+1][j-1] += dp[i][j]*j*j %mod;
                dp[i+1][j-1] %= mod;
            }
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
    int a, b;
    cin >> a >> b;
    int t = a+b, h = a-b, k=a*b;
    if(t >= h && t >= k){
        cout << t << endl;
    }else if(h >= t && h >= k){
        cout << h << endl;
    }else{
        cout << k << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const int INF = 1000000009;

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

  vector<set<int>> a(26, set<int>({INF})); // INF は番兵のようなもの
  for (int i = 0; i < n; i++) { a[s[i]-'a'].insert(i); }

  int q; cin >> q;
  while (q--) {
    int type; cin >> type;
    if (type == 1) {
      int idx; char c; cin >> idx >> c; idx--;
      a[s[idx]-'a'].erase(idx);
      a[c-'a'].insert(idx);
      s[idx] = c;
    }
    if (type == 2) {
      int l, r; cin >> l >> r; l--;
      int ret = 0;
      for (int i = 0; i < 26; i++) {
        int lid = *a[i].lower_bound(l);
        if (lid < r) ret++;
      }
      cout << ret << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inrange(a, x, b) (a <= x && x <= b)
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print(T x,bool cl=1){cout<<(cl?"\x1b[36m":"")<<x<<(cl?"\x1b[39m":"")<<'\n';}
template<class T> void print1d(T x,ll n=-1,bool cl=true){if(n==-1)n=x.size();rep(i,0,n){cout<<(cl?"\x1b[36m":"")<<x[i]<<(i==n-1?'\n':' ');}cout<<(cl?"\x1b[39m":"");}
template<class T> void print2d(T x,ll r=-1,ll c=-1,bool cl=1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c,cl);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}



int main()
{
        ll N, M;
        cin >> N >> M;
        vll cnt(N+1);
        dsu d(N);
        rep(i, 0, M) {
                ll a, b;
                cin >> a >> b;
                --a; --b;
                d.merge(a, b);
        }

        auto x = d.groups();
        ll sz = len(x);

        cout << sz - 1 << endl;
}


Measured memory_bytes: 9500
#include <iostream>
#define NIL -1
using namespace std;

class node{
public:
  int parent, left, right;
  int depth;
  int num;
  string tag;
  node* parentn;
  node* leftn;
  node* rightn;
  node(){
    parent = NIL;
    left = NIL;
    right = NIL;
    depth = NIL;
    parentn = NULL;
    leftn = NULL;
    rightn = NULL;
  }

  void init_depth(int n){
    depth=n;
    if(leftn!=NULL){
      leftn->init_depth(n+1);
    }
    if(rightn!=NULL){
      rightn->init_depth(n);
    }
  }

  void init_tag(){
    if(parentn==NULL) tag = "root";
    else if(leftn==NULL) tag = "leaf";
    else tag = "internal node";

    if(leftn!=NULL){
      leftn->init_tag();
    }
    if(rightn!=NULL){
      rightn->init_tag();
    }
  }

  void print_info(){
    cout << "node " << num << ": parent = " << parent << ", depth = " << depth << ", "+tag+", ";
    cout << "[";
    if(leftn!=NULL){
      cout << leftn->num;
      node* r = leftn->rightn;
      while(r!=NULL){
        cout << ", " << r->num;
        r = r->rightn;
      }
    }
    cout << "]" << endl;
  }
};

int main(){
  int n; cin >> n;
  node nodes[n];

  int v, dv, k, l;
  for(int i=0; i<n; i++){ //各頂点について情報を読み込む
    cin >> v >> dv;       //頂点番号の読み込み
    nodes[v].num = v;

    for(int j=0; j<dv; j++){
      cin >> k;                    //子頂点の読み込み
      if(j==0){                    //もし一番左の頂点ならば
        nodes[v].left = k;
        nodes[v].leftn = &nodes[k];
      }
      else {                        //左でないならば
        nodes[l].right = k;
        nodes[l].rightn = &nodes[k];
      }
      l = k;
      nodes[k].parent = v;
      nodes[k].parentn = &nodes[v];      //子頂点の親を自身に設定
    }
  }

  int ne; //根
  for(int i=0; i<n; i++){ //根を探す
    if(nodes[i].parent==NIL) ne = i;
  }

  nodes[ne].init_depth(0); //neを基準として深さを設定
  nodes[ne].init_tag(); //ノードの種類を決定

  for(int i=0; i<n; i++) nodes[i].print_info();

  return 0;
}



Measured memory_bytes: 13236
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, L;
ll apples[205];
ll sum = 0;
ll minVal = 1e8;
ll minInd = 0;
ll maxVal = -1e8;

int main() {
	scanf("%lld %lld", &N, &L);
	for(int i = 1; i <= N; i++) {
		apples[i] = L + i - 1;
		sum += apples[i];
	}
	// cout << sum << " ";
	sort(apples + 1, apples + N + 1);
	minInd = 1;
	for(int i = N; i >= 1; i--) {
		if(apples[i] <= 0) {
			minInd = i;
			break;
		}
	}

	printf("%lld\n", sum - apples[minInd]);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int a,b,x,val;
   cin>>a>>b>>x;
   val=b;
   bool flag=false;

   if(a>x)cout<<"NO";
   else
   {
       for(int i=0 ;i<b ;i++)
       {


    val=val-1;
    if(val+a==x){ flag=true; break; }

       }
       if(flag==true)cout<<"YES";
       else{cout<<"NO";}

   }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

const int N = 3030;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
ll dp[N][N][4];
ll v[N][N];
int r, c, k;

void upd(int rw, int co, int a, ll va) {
  if (a > 3) return;
  if (rw > r) return;
  if (co > c) return;
  dp[rw][co][a] = max(dp[rw][co][a], va);
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> r >> c >> k;
  for (int i=1; i<=k; ++i) {
    int a, b, x;
    cin >> a >> b >> x;
    v[a][b] = x;
  }

  dp[1][1][1] = v[1][1];

  for (int sum=2; sum<r+c; ++sum) {
    for (int i=1; i<=r; ++i) {
      int j = sum-i;
      if (j > c || j < 1) {
        continue;
      }
      for (int a=0; a<4; ++a) {
        upd(i+1, j, 1, dp[i][j][a]+v[i+1][j]);
        upd(i+1, j, 0, dp[i][j][a]);
        upd(i, j+1, a+1, dp[i][j][a]+v[i][j+1]);
        upd(i, j+1, a, dp[i][j][a]);
      }
    }
  }

  ll ans = max(max(max(dp[r][c][0], dp[r][c][1]), dp[r][c][2]), dp[r][c][3]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 358600
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll a[100001][3];
ll n;
ll dp[100001][3];
ll solve(ll i,ll f)
{
	if(i==n+1) return 0;
	if(f!=-1&&dp[i][f]!=-1) return dp[i][f];
	ll ans1=0,ans2=0,ans3=0;
	if(f!=0) ans1=a[i][0]+solve(i+1,0);
	if(f!=1) ans2=a[i][1]+solve(i+1,1);
	if(f!=2) ans3=a[i][2]+solve(i+1,2);
	return dp[i][f]=max(ans1,max(ans2,ans3));
}
int main()
{
	boost
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}
	cout<<solve(0,-1)<<endl;
	return 0;
}

Measured memory_bytes: 11264
#include<stdio.h>

int main(void){

  int N;
  int A,B;
  int P[100];
  
  int c1=0,c2=0,c3=0;
  
  scanf("%d",&N);
  scanf("%d %d",&A,&B);
  int i=0;
  for(i=0;i<N;i++){
  	scanf("%d",&P[i]);
    
    if(P[i]<=A){
    	c1++; 
    }
    else if(P[i]>=B+1){
    	c3++;
    }
    else{
    	c2++;
    }
    
  }

  if(c1==0||c2==0||c3==0){
    printf("0");
    
  }else if(c1<=c2 && c1<=c3){
    printf("%d",c1);
  }else if(c2<=c1 && c2<=c3){
    printf("%d",c2);
  }else{
   printf("%d",c3); 
  }
  
  return 0;
  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin>>N>>K;

    int A[N];
    rep(i,N){
        cin>>A[i];
    }

    
    int ans=0;
    rep(t,K){
        ans=0;
        bool w=true;
        int a[N+10]{};
        rep(i,N){
            int x=A[i]*2+1;
            int y=max(0LL,i-A[i]);
            int z=min(N,i+A[i]);
            a[y]++;
            a[z+1]--;

            
        }
        rep(i,N){
            ans+=a[i];
            A[i]=ans;
            if(ans!=N)w=false;
        }
        if(w) break;
    }
    
    rep(i,N){
        cout << A[i] << " ";
    }
    cout << endl;

    

    



}


Measured memory_bytes: 6732
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

int arr[2000100], c[100001], ans[2000100];

int main()
{
    int i, n;
    scanf("%d", &n);

        memset(c, 0, sizeof(c));

        for(i = 1; i <= n; ++i)
        {
            scanf("%d", &arr[i]);
            ++c[arr[i]];
        }

        for(i = 1; i < 100001; ++i)
            c[i] = c[i] + c[i - 1];

        for(i = n; i > 0; --i)
        {
            ans[c[arr[i]]] = arr[i];
            --c[arr[i]];
        }

        for(i = 1; i < n; ++i)
            printf("%d ", ans[i]);
            printf("%d\n", ans[n]);

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<tuple<string,int,int>> a;
    for(int i = 1;i <= n;i++){
        string s;
        int p;
        cin >> s >> p;
        p = -p;
        a.push_back(tie(s,p,i));
    }
    sort(a.begin(),a.end());
    for(auto t : a){
        cout << get<2>(t) << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	
	class Seg implements Comparable<Seg>{
		int start, end;

		public Seg(int start, int end) {
			this.start = start;
			this.end = end;
		}

		@Override
		public int compareTo(Seg o) {
			return this.start- o.start;
		}

		@Override
		public String toString() {
			return "Seg [start=" + start + ", end=" + end + "]";
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int MAX = 1000000000;
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			ArrayList<Seg> emptylist = new ArrayList<Seg>();
			emptylist.add(new Seg(0, MAX));
			HashMap<Integer, ArrayList<Seg>> sector = new HashMap<Integer, ArrayList<Seg>>();
			while(n-- > 0){
				char c = sc.next().charAt(0);
				if(c == 'W'){
					int name = sc.nextInt();
					int size = sc.nextInt();
					ArrayList<Seg> newsector  = new ArrayList<Main.Seg>();
					for(int i = 0; i < emptylist.size(); i++){
						Seg nows = emptylist.get(i);
						if(nows.end - nows.start + 1 > size){
							Seg afterS = new Seg(nows.start, nows.start + size - 1);
							newsector.add(afterS);
							emptylist.set(i, new Seg(nows.start + size, nows.end));
							break;
						}
						else if(nows.end - nows.start + 1 == size){
							newsector.add(nows);
							emptylist.remove(i);
							break;
						}
						else{
							newsector.add(nows);
							emptylist.remove(i);
							size = size - (nows.end - nows.start + 1);
							i--;
						}
					}
					sector.put(name, newsector);
				}
				else if(c == 'D'){
					int name = sc.nextInt();
					for(int i = 0; i < sector.get(name).size(); i++){
						emptylist.add(sector.get(name).get(i));
					}
					Collections.sort(emptylist);
					sector.remove(name);
				}
				else if(c == 'R'){
					int sectornum = sc.nextInt();
					int ind = -1;
					for(int key: sector.keySet()){
						for(int i = 0; i < sector.get(key).size(); i++){
							Seg nowS = sector.get(key).get(i);
							if(nowS.start <= sectornum && sectornum <= nowS.end){
								ind = key;
								break;
							}
						}
						if(ind != -1) break;
					}
					System.out.println(ind);
				}
			}
			System.out.println();
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 180848
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int K;
    scanf("%d", &K);
    vector<int> a(K);
    int i;
    for (i = 0; i < K; i++) {
        scanf("%d", &a[i]);
    }
    if (a[K-1] != 2) {
        printf("-1\n"); return;
    }
    ll min = 2, max = 2;
    int step = 1;
    for (i = K - 2; i >= 0; i--) {
        min = min;
        if (min%a[i]) {
            min += (a[i] - min % a[i]);
        }        
        max = max + a[i + 1] - 1;
        if (max%a[i]) {
            max = max - (max%a[i]);
        }
        if (min > max) {
            printf("-1\n"); return;
        }
    }

    {
        min = min;      
        max = max + a[0] - 1;
    }
    printf("%lld %lld\n", min, max);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

typedef long long ll;

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

    int n,k,r,s,p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(i<k){
            if(t[i]=='r') ans += p;
            if(t[i]=='s') ans += r;
            if(t[i]=='p') ans += s;
        }else{
            if(t[i]!=t[i-k] && t[i]=='r') ans += p;
            else if(t[i]!=t[i-k] && t[i]=='s') ans += r;
            else if(t[i]!=t[i-k] && t[i]=='p') ans += s;
            else if(t[i]==t[i-k]) t[i] = 'z';
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int  x, a, b;
    cin >> x >> a >> b;
    int disa = abs(x-a);
    int disb = abs(x-b);
    if(disa > disb){
        cout << "B";
    }
    else{
        cout << "A";
    }   
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int A,B,sum;
    scanf("%d %d",&A,&B);
    if(A==B)
        sum=A+B;
    else if(A>B)
        sum=A+A-1;
    else
        sum=B+B-1;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin >> a;
    vector<pair<int,int>>vec;
    while(a--)
    {
        cin >> b >> c;
        vec.push_back({b,c});
    }
    bool y=false;
    for(int i=0;i<=vec.size()-3;i++)
    {
       if(vec[i].first==vec[i].second && vec[i+1].first==vec[i+1].second && vec[i+2].first==vec[i+2].second )
       {
           y=true;
           break;
       }
    }
    if(y)
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }




}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d, e;
    int r;
    cin >> a >> b >> c>> d>> e;

    if (a == 0)  r = 1;
    if (b == 0)  r = 2;
    if (c == 0)  r = 3;
    if (d == 0)  r = 4;
    if (e == 0)  r = 5;
    cout << r;
}

Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n,d,sum=0;
    cin >> n >> d;
    vector<ll> x(n), y(n); 
    rep(i,n){
        cin >> x[i] >> y[i];
        ll tmp=x[i]*x[i]+y[i]*y[i];
        if(tmp<=d*d) sum++;
    }
    cout <<sum<< endl;
    

    return 0;
}


Measured memory_bytes: 6268
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll h;
	cin >> h;
	ll cnt = 1;
	ll ans = 1;
	while (h > 1) {
		cnt *= 2;
		ans += cnt;
		h = floor(h / 2);
	}
	cout << ans;
}
 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    while (n % 2 == 0)
    {
        v.pb(2);
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            v.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
        v.pb(n);
    return v;
}
int f(int a,int b,int x)
{
    return ((a*x)/b)-(a*(x/b));
}
void solve()
{
int a,b,n;
cin>>a>>b>>n;
int ans=f(a,b,n);
n=n/b*b;
cout<<max(ans,f(a,b,n-1));
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}


Measured memory_bytes: 3636
N,K = map(int,input().split())
A = list(map(int,input().split()))

S = sum(A)
ans = 0

for i in range(1,int(S**0.5)+1):
    if S%i != 0:
        continue
        
    for j in range(2):
        d = i if j else S//i
        B = sorted(map(lambda a:a%d,A))
        C = [0]
        for k in range(N):
            C.append(C[-1]+B[k])
            
        for k in range(N+1):
            if ((N-k)*d-(C[-1]-C[k])-C[k])%d == 0:
                if max(C[k],(N-k)*d-(C[-1]-C[k])) <= K:
                    ans = max(ans,d)
                    
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    ll N;
    cin >> N;
    vector<ll>A(N);
    for(ll i = 0;i < N;i++)
        cin >> A.at(i);

    ll res = 0;
    ll hako;
    for(ll i = 1;i < N;i++){
        if(A.at(i-1) > A.at(i)){
            hako = A.at(i-1) - A.at(i);
            A.at(i) += hako;
            res += hako;
        }
    }

    cout << res << endl;

}





    

Measured memory_bytes: 4808
#include<iostream>
#include<string>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,l;
	cin>>n>>l;
	string s[n];
	rep(i,n)cin>>s[i];
	sort(s,s+n);
	string ans="";
	rep(i,n)ans+=s[i];
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
int n,rmq[200005][25],x[200005],l,q;
signed main()
{
	queue<ii> que;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]; 
	}
	cin>>l>>q;
	for(int j=0;j<=20;j++)
	{
		for(int i=1;i<=n;i++)
		{
			rmq[i][j]=200003;
		}
	}
	int cnt=0;
	while(1)
	{
		if(cnt==n+1) break;
		cnt++;
		que.push(ii(x[cnt],cnt));
		while(1)
		{
			if(x[cnt]-que.front().first>l)
			{
				rmq[que.front().second][0]=cnt-1;
				que.pop();
			}
			else break;
		}
	}
	while(!que.empty())
	{
		rmq[que.front().second][0]=n;
		que.pop();
	}
	for(int j=1;j<=20;j++)
	{
		for(int i=1;i<=n;i++)
		{
		    rmq[i][j]=rmq[rmq[i][j-1]][j-1];
		}
	}
	while(q--)
	{
		int u,v,res=0;
		cin>>u>>v;
		if(u>v) swap(u,v);
		for(int i=20;i>=0;i--)
		{
			if(rmq[u][i]<v)
			{
				res+=(1<<i);
				u=rmq[u][i];
			}
		}
		if(u!=v) res++;
		cout<<res<<"\n";
	}
}

Measured memory_bytes: 23808
#include<stdio.h>

int linearSearch(int S[],int T[],int n,int q){
	int k = 0;
	for (int i = 0; i < q; i++){
		for (int j = 0; j < n; j++){
			if (T[i] == S[j]){
				k++;
				break;
			}
		}
	}
	return k;
}

int main(){
	int n, q;
	int S[10000], T[500];
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		scanf("%d", &T[i]);
	}
	printf("%d\n", linearSearch(S, T, n, q));
	return 0;
}

Measured memory_bytes: 2752
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto p = iota(n).map!(i => readln.chomp.to!int - 1).array;

    auto a = new int[](n);

    foreach (i ; 0 .. n) {
        if (p[i] == 0) {
            a[0] = 1;
            continue;
        }
        a[p[i]] = a[p[i] - 1] + 1;
    }

    debug {
        writeln(a);
    }

    auto ans = n - a.reduce!max;

    writeln(ans);
}








void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4732
from collections import defaultdict
def main():
    def pair(n):
        a = n % 10
        b = str(n)[0]
        return '{},{}'.format(a, b)

    N = int(input())
    freq = defaultdict(int)
    for i in range(1, N+1):
        p = pair(i)
        freq[p] += 1
    
    res = 0
    for i in range(1, N+1):
        p = pair(i)
        q = ','.join(p.split(',')[::-1])
        res += freq[q]
    print(res)

main()

Measured memory_bytes: 3444
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  int n,y;
  cin >> n >> y;
  REP(i,n+1){
    REP(j,n-i+1){
      if (i*10000+j*5000+(n-i-j)*1000==y) {
        cout << i << ' ' << j << ' ' << (n-i-j);
        return 0;
      }
    }
  }
  cout << "-1 -1 -1";
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [0]*n
t = [0]*n
for i in range(n):
  s[i],t[i] = input().split()
  t[i]=int(t[i])
x = input()


f=False
count=0

for i in range(n):

  if f:
    count+=t[i]
  if s[i]==x:
    f=True

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
  a = max(a,b);
}

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

  
  int ans = 0;
  int n = t/a;
  for(int i=0; i<n ;i++){
    ans +=b;
  }

  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256