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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    vector<int> a(2*n);
    for (int i = 0; i < 2*n; i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int ans = 0;
    for (int i = 0; i < a.size(); i += 2) {
        ans += a[i];
    }
    cout << ans << '\n';
}



Measured memory_bytes: 256
// AOJ ITP1_11_A Dice I
// 2018.4.29 bal4u
 
#include <stdio.h>
 
int rot[5][7] = {
{0,1,2,3,4,5,6},{0,2,6,3,4,1,5},{0,4,2,1,6,5,3},{0,3,2,6,1,5,4},{0,5,1,3,4,6,2}};
int assign[7];      // サイコロの1～6の各面に割り当てる数字
int tr['Z'];
 
void dice_init(int *a)
{
    int i;
    int t[5] = {0,'N','E','W','S'};
    for (i = 1; i <= 6; i++) assign[i] = a[i];
    for (i = 1; i <= 4; i++) tr[t[i]] = i;
}
 
char s[102];
int main()
{
    int i, k1, k2;
    int a[7], dice[2][7];
    char *p;
 
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    dice_init(a);
    scanf("%s", p=s);
    for (i = 1; i <= 6; i++) dice[0][i] = rot[0][i];
    for (k1 = 0, k2 = 1; *p; k1 = k2, k2 = !k2) {
        for (i = 1; i <= 6; i++) dice[k2][i] = dice[k1][rot[tr[*p]][i]];
        p++;
    }
    printf("%d\n", assign[dice[k1][1]]);
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);


int main(){
  string s;
  cin >> s;
  rep(i,2){
    rep(j,2){
      rep(k,2){
        int ans=s[0]-'0';
        if(i==0)ans+=s[1]-'0';
        else ans-=s[1]-'0';
        if(k==0)ans+=s[3]-'0';
        else ans-=s[3]-'0';
        if(j==0)ans+=s[2]-'0';
        else ans-=s[2]-'0';
        if(ans==7){         
          cout << s[0];
          if(i==0)cout<<'+';
          else cout<<'-';
          cout << s[1];
          if(j==0)cout<<'+';
          else cout<<'-';
          cout << s[2];
          if(k==0)cout<<'+';
          else cout<<'-';
          cout << s[3];
          cout<<'=';
          cout<<7;
          return 0;
        }
      }
    }
  }

        
        
  
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <set>

using namespace std;

vector<pair<long long, long long>> PrimeFac(long long N){
    vector<pair<long long, long long>> res;

    for(long long i =2; i * i <= N; ++i){
        if(N % i != 0) continue;

        long long ex = 0;
        while( N%i == 0){
            ex++;
            N /= i;
        }
        res.push_back({i,ex});
    }

    if(N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    long long A, B; cin >> A >> B;
    const auto& peA = PrimeFac(A);
    const auto& peB = PrimeFac(B);

    set<long long> s;


    for(auto pe: peA){
        s.emplace(pe.first);
    }

    long long ans = 0;
    for(auto pe: peB){
        if( s.count(pe.first) > 0) ans++;
    }

    cout << ans+1 << endl;

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    string s;cin>>s;
    int n=s.size();
    int res=n;
    REP(i,26){
        string t=s+(char)('a'+i);
        int cnt=0;
        int tmp=0;
        REP(j,n+1){
            if(t[j]==(char)('a'+i)){
                tmp=max(cnt,tmp);
                cnt=0;
            }else cnt++;
        }
        res=min(res,tmp);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない




int main() {

	string a;
	cin >> a;
	char c = a[0];
	int n = 0;
	int ans = 0;
	
	rep(i, 0, a.size()) {
		if (a[i] == c) {
			n++;
		}
		else {
			if (n - 1 >= 0) {
				n = n - 1;
				ans++;
			}
			else {
				n = 1;
				c = a[i];
			}
		}
	}

	cout << ans * 2 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;

#define INF 1e18
#define int long long

const int MAX = 1000100;
const int MOD = 998244353;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
    COMinit();

    int n, a, b, k;
    cin >> n >> a >> b >> k;

    int ans = 0;
    for(int i = 0; i <= n; i++) {
        int j = (k - a * i) / b;
        if(j >= 0 && (k - a * i) % b == 0) {
            ans += COM(n, i) * COM(n, j) % MOD;
        }
    }

    ans %= MOD;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int K; cin >> K;
cout << (K/2)*(K-(K/2)) << endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if(a < b){
		printf("a < b\n");
	}
	else if(a > b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

vector<int> bit;
int bitmax;

void init(int n) {
  bitmax = 1;
  while (bitmax < n) bitmax <<= 1;
  bit.assign(bitmax+1, 0);
}

int getSum(int x) {
  int s = 0;
  while (x > 0) {
    s += bit[x];
    x -= x&-x;
  }
  return s;
}
int getSum(int l, int r) {
  return getSum(r)-getSum(l-1);
}
void add(int i, int x) {
  while (i <= bitmax) {
    bit[i] += x;
    i += i&-i;
  }
}

int main(int, char**)
{
  int n, q;
  cin >> n >> q;
  init(n);

  vector<int> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int x, y;
      cin >> x >> y;
      add(x,y);
    } else {
      int x, y;
      cin >> x >> y;
      ans.push_back(getSum(x,y));
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 3720
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

// #define int long long int
// constexpr int INF = std::numeric_limits<int>::max();
// constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;

  int sum = 0;
  int k = 0;
  while (sum < N) {
    sum += k++;
  }

  if (sum != N) {
    cout << "No" << endl;
    return;
  }

  vector<int> s[k];

  cout << "Yes" << endl;
  cout << k << endl;

  int idx = 1;

  for (int i = 0; i < k; i++) {
    for (int p = i+1; p < k; p++) {
      s[i].push_back(idx);
      s[p].push_back(idx);
      idx++;
    }
  }

  for (auto &v:s) {
    cout << k-1 << " ";
    for (int a:v) {
      cout << a << " ";
    }
    cout << endl;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 3864
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int a[27];
int b[27];
int main(void){
  char s[200001],t[200001];
  scanf("%s %s",s,t);
  int l=strlen(s);
  FOR(l)a[s[i]-'a']++;
  FOR(l)b[t[i]-'a']++;
  qsort(a,27,sizeof(int),u);
  qsort(b,27,sizeof(int),u);
  int flg=1;
  FOR(27)if(a[i]!=b[i])flg=0;
  char c[2][4]={"No","Yes"};
  PRS(c[flg]);
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 89;
	while (kkt) {
		int n; scanf("%d", &n);
		int cnt = 0;
		bool flag = true;
		for (int i = 0; i < n; i++) {
			string s; cin >> s;
			if (s == "A") cnt++;
			else {
				cnt--;
				if (cnt < 0) flag = false;
			}
		}
		flag &= (cnt == 0);
		if (flag) puts("YES");
		else puts("NO");
		break;
	}
	return 0;

}


Measured memory_bytes: 3248
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int swap(int **a, int **b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int gcd(x, y) {
	int tmp;
	if (x < y) {
		swap(&x, &y);
	}
	while (y > 0) {
		tmp = x%y;
		x = y;
		y = tmp;
	}
	return x;
}

/* ソート関数 */
int int_sort(const void * a, const void * b) {
	/* 引数はvoid*型と規定されているのでint型にcastする */
	if (*(int *)a < *(int *)b) {
		return -1;
}
	else
		if (*(int *)a == *(int *)b) {
			return 0;
		}
	return 1;
}
int main(){
#ifdef DEBUG
	
#endif
	int A, B, C, D, E, F;
	scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);

	int i,j,k;
	int kobaiM = 100*A*100*B/gcd(100*A, 100*B);
	int kobaiS = C*D / gcd(C,D);
	int mizu[30], sato[1501];
	int cntM=0, cntS=0;
	double nodo, maxNodo = 0;
	int ansM, ansS;

	/*あり得る水の量*/
	//0~最大値/水1,2の公倍数分繰り返す
	for (i = 0; i <= F / kobaiM; i++) {
		//ある公倍数から次の公倍数までの水1と水2の組み合わせ
		for (j = 0; j <= kobaiM/(100*A)-1 && (F-kobaiM*i)-(100*A*j)>=0; j++) {
			for (k = 0; k <= kobaiM / (100 * B) - 1 && (F - kobaiM*i) - ((100 * A*j)+(100 * B*k)) >= 0; k++) {
				if (!(i == 0 && j == 0 && k == 0)) {
					mizu[cntM] = kobaiM*i + 100 * A*j + 100 * B*k;
					cntM++;
				}
			}
		}
	}
	for (i = 0; i <= F / 2 / kobaiS; i++) {
		for (j = 0; j <= kobaiS / C - 1 && (F - kobaiS*i) - (C*j) >= 0; j++) {
			for (k = 0; k <= kobaiS / D - 1 && (F/2 - kobaiS*i) - ((C*j) + (D*k)) >= 0; k++) {
				sato[cntS] = kobaiS*i + C*j + D*k;
				cntS++;
			}
		}
	}
	qsort((void *)mizu, cntM, sizeof(mizu[0]), int_sort);
	qsort((void *)sato, cntS, sizeof(sato[0]), int_sort);

	for (i = 0; i < cntM; i++) {
		for (j = 0; j < cntS; j++) {
			if (mizu[i] + sato[j] <= F) {
				if (sato[j] <= E*mizu[i] / 100) {
					nodo = (double)100 * sato[j] / (mizu[i] + sato[j]);
					if (nodo >= maxNodo) {
						maxNodo = nodo;
						ansM = i;
						ansS = j;
						//printf("i=%d, j=%d, nodo=%f\n", i, j, maxNodo);
					}
				}
			}
			else {
				break;
			}
		}
	}

	/* ソート後のデータを参照する */
	/*for (i = 0; i < cntM; i++) {
		printf("mizu[%d]=%d\n", i, mizu[i]);
	}
	for (i = 0; i < cntS; i++) {
		printf("sato[%d]=%d\n", i, sato[i]);
	}*/

	printf("%d %d\n", mizu[ansM] + sato[ansS], sato[ansS]);
}

Measured memory_bytes: 128
using System;
 
namespace aizu
{
    class OnlineJudge
    {
        const int Max = 1000000;
        static void Main()
        {
            int[] prime = new int[Max];
            int count = 1;
            for(int i=3; i < Max; i += 2) {
                if(prime[i] == 0) {
                    ++count;
                    if(i <= 1000) {
                        for(int l = i; i * l < Max; ++l) {
                            prime[l * i] = -1;
                        }
                    }
                }
                prime[i] = count;
            }
            prime[2] = 1;
            string num;
            while((num = Console.ReadLine()) != null) {
                int val = int.Parse(num);
                if(val != 2 && (val & 1) == 0) {
                    --val;
                }
                Console.WriteLine(prime[val]);
            }
        }
    }
}

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

using namespace std;

typedef long long ll;

#define x first
#define y second

const int N = 100010;

int n; ll sf[N];
pair <ll, ll> p[N];

int main() {
  cin >> n;
  ll ans = INT_MIN;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld %lld", &p[i].x, &p[i].y);
    ans = max(ans, p[i].y - p[i].x + 1);
  }
  sort(p + 1, p + n + 1, [] (pair <ll, ll> a, pair <ll, ll> b) {
    return a.x == b.x ? a.y > b.y : a.x < b.x;
  });
  set <pair <ll, int>> st;
  sf[n] = p[n].second;
  for (int i = n - 1; i; --i) {
    sf[i] = min(sf[i + 1], p[i].second);
  }
  ll mn_y = INT_MAX;
  for (int i = 1; i < n; ++i) {
    ll cur_x = p[i].first, cur_y = p[i].second;
    ll nxt_x = p[n].first, nxt_y = sf[i + 1];
    ans = max(ans, max(0LL, cur_y - cur_x + 1) + max(0LL, min(mn_y, nxt_y) - nxt_x + 1));
    ans = max(ans, max(0LL, min(mn_y, cur_y) - cur_x + 1) + max(0LL, nxt_y - nxt_x + 1));
    mn_y = min(mn_y, p[i].second);
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 2560
x,k,d = map(int,input().split())
x = abs(x)
i = int(x / d)
if k < i:
  print(x - k * d)
  exit()
if (k - i) % 2 == 0:
  print(x - i * d)
  exit()
print(abs(x - (i + 1) * d))

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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 tuple<string,int,int> T;

int main () {
  int n = in();
  vector<T> t(n);
  rep(i,n) {
    string s;
    int p;
    cin >> s >> p;
    t[i] = T(s,-p,i+1);
  }
  sort(t.begin(), t.end());
  vi ans(n);
  rep(i,n) {
    ans[i] = get<2>(t[i]);
  }
  printv(ans);
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    if (S.size() % 2 == 1) {
        cout << "No" << "\n";
        return 0;
    }
    for (int i = 0; i < S.size()/2; ++i) {
        if (S[2*i] == 'h' && S[2*i+1] == 'i') continue;
        cout << "No" << "\n";
        return 0;
    }
    cout << "Yes" << "\n";
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())

L = list(map(int,input().split()))

LL= list(itertools.combinations(L, 3))

cnt = 0

for suji in LL:
    a = suji[0]
    b = suji[1]
    c = suji[2]

    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            cnt = cnt + 1

print(cnt)


Measured memory_bytes: 20584
// 2014/06/03 Tazoe

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	char S[11];
	cin >> S;

	int N;
	cin >> N;

	int cnt = 0;

	for(int i=0; i<N; i++){
		char R[11];
		cin >> R;

		char R2[21];
		strcpy(R2, R);
		strcat(R2, R);

		if(strstr(R2, S)!=0){
			cnt++;
		}
	}

	cout << cnt << '\n';

	return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
typedef long long ll;
int N,L;
ll s[100002];
int ans[100002];
int main(){
  int i,j;
  int a;
  scanf("%d %d",&N,&L);
    scanf("%d",&a);
    s[1] = a;
  for(i = 2; i <= N; i++){
    scanf("%d",&a);
    s[i] = s[i-1]+a;    
  }
 
  for(i = 2; i <= N; i++){
    if(s[i]-s[i-2] >= L)break;
  }
  if(i == N+1)printf("Impossible\n");
  else {
    printf("Possible\n");
    for(j = 1; j < i-1; j++){
      printf("%d\n",j);
    }
    for(j = N-1; j >= i; j--){
      printf("%d\n",j);
    }
    printf("%d\n",i-1);
  }
    return 0;
}

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

using namespace std;
#define int long long

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int  h , w , n;
    cin >> h >> w >> n;
    h = max(h , w);
    int ans = n / h;
    if(n % h != 0)
        ans ++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 2e5+7;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n,k;cin>>n>>k;
	vi32 p(n);
	for(int &x:p)cin>>x;
	sort(all(p));
	int sum=0;
	for(int i=0;i<k;i++)sum+=p[i];
	cout<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int ppow(int a,int b,int MOD){
	a %= MOD;
	ll res = 1;
	while(b){
		if(b & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

int main(void){
    ll n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(p == 2 || p == 5){
        ll ans = 0;
        rep(i,n){
            if((s[i]-'0')%p == 0){
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<int> cum(n+1,0);
    map<int,ll> dict;
    dict[0]++;
    for(int i=n-1; i>=0; i--){
        cum[i] = (cum[i+1] + (s[i]-'0') * ppow(10,n-1-i, p)) % p;
        dict[cum[i]]++;
    }
    ll ans = 0;
    for(auto ob: dict){
        ll sec = ob.sc;
        ans += sec * (sec-1) /2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1796
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
W=[0]*N
ans = 1
for i in range(N):
    W[i] = input()
    if i != 0 and W[i-1][-1] != W[i][0]:
        ans = 0

import collections
Wc = collections.Counter(W).most_common()
if Wc[0][1] != 1:
    ans = 0

yn(ans)


Measured memory_bytes: 3512
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();

		while(m-- > 0){
			int n=sc.nextInt(), k=sc.nextInt();
			int[] x = new int[n];
			PriorityQueue<MyInteger> pq = new PriorityQueue<MyInteger>();

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

			if(n == 0 || n == 1 || k >= n){
				System.out.println(0);
				continue;
			}

			Arrays.sort(x);
			int d = x[n-1] - x[0];
			for(int i=1;i<n;i++){
				pq.add(new MyInteger(x[i] - x[i-1]));
			}

			k--;
			while(k-- > 0){
				d -= pq.poll().value;
			}
			System.out.println(d);
		}
	}
}

class MyInteger implements Comparable<MyInteger>{
	int value;

	MyInteger(int value){
		this.value = value;
	}

	public int compareTo(MyInteger x){
		return x.value - this.value;
	}
}

Measured memory_bytes: 17000
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

namespace
{
	ll ModPow(ll a, ll p, ll mod)
	{
		if (p == 0)
			return 1;
		if (p % 2 == 0)
		{
			ll halfp = p / 2;
			ll half = ModPow(a, halfp, mod);
			return (half * half) % mod;
		}
		else
		{
			return (a * ModPow(a, p - 1, mod)) % mod;
		}
	}

	ll Combination(int n, int r, ll mod)
	{
		r = min(r, n - r);
		ll num = 1;
		ll den = 1;
		for (int i = 0; i < r; ++i)
		{
			num *= (n - i);
			num %= mod;
			den *= (i + 1);
			den %= mod;
		}
		ll ret = (num * ModPow(den, mod - 2, mod)) % mod;
		return ret;
	}
}
void ABC110D()
{
	int N, M;
	cin >> N >> M;

	map<int, int> primeFactorization;
	for (int i = 2; i * i <= M; ++i)
	{
		while (M % i == 0)
		{
			M /= i;
			++primeFactorization[i];
		}
	}
	if (M > 1)
	{
		primeFactorization[M] = 1;
	}

	ll num = 1;
	int MODBASE = 1000000007;
	for (auto& x : primeFactorization)
	{

		num *= Combination(x.second + N - 1, min(x.second, N - 1), MODBASE);
		if (num > MODBASE)
		{
			num %= MODBASE;
		}
	}
	cout << num << endl;
}

int main()
{
	ABC110D();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
  int n; cin >> n;
  int ans = n%1000;
  
  if(ans == 0){
    ans = 0;
  } else {
  
    ans = 1000 - ans;
  } 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

string s;
cin>>s;
  
char a[]="Sunny";
char b[]="Cloudy";
char c[]="Rainy";

if(5==s.size()&& s[0]=='S'){
    cout<<b<<endl;
}

if(6==s.size()){
    cout<<c<<endl;
}
if(5==s.size()&& s[0]=='R'){
    cout<<a<<endl;
}

 return 0;
}

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

int main(){
    int N, M, T, X;
    cin >> N >> M;
    vector<vector<int>> vec_a(M, vector<int>(2,0));
    vector<int> vec_b(N, 0);
    T =0;

    for(int i = 0; i < M; i++){
    for (int j = 0; j < 2; j++){
        cin >> vec_a[i][j];
    }
      if(vec_a[i][0] == 1 && vec_a[i][1]==0 && N != 1){
     T =1;
     }
}

for(int i = 0; i < M-1; i++){
        for(int j = i+1; j < M; j++){
            if(vec_a[i][0] == vec_a[j][0] && vec_a[i][1] != vec_a[j][1]){
                T = 1; 
            }
    }
}


   for(int i = 0; i < M; i++){
     X = vec_a[i][0] - 1;
       vec_b[X] = vec_a[i][1];
     
   } 

   if(N != 1 && vec_b[0] == 0){
       vec_b[0] = 1;
   }

   if(T == 0){
   for (int i = 0; i < N; i++){  
    cout << vec_b[i];
    }
    cout << endl;
   }
   if(T == 1){
    cout << "-1" << endl;
    }

}


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

vector<int> check;

void printVector(const vector<int>& vec) {
  string v = "";
  for (int value : vec) {
    v += to_string(value);
  }
  check.push_back(atoi(v.c_str()));
}
 
int main() {

  int N;
  cin >> N;

  string P;
  string Q;

  for (int i = 0; i < N; i++) {
    string p_;
    cin >> p_;
    P += p_;
  } 

  for (int i = 0; i < N; i++) {
    string q_;
    cin >> q_;
    Q += q_;
  }

  int p = atoi(P.c_str());
  int q = atoi(Q.c_str());

  vector<int> v;

  for (int i = 0; i < N; i++) {
    v.push_back(i+1);
  }

  do {
    printVector(v);
  } while (next_permutation(v.begin(), v.end()));

  int a = 0;
  int b = 0;
  for (int i = 0; i < check.size(); i++) {
    if (check[i] == p) {
      a = i + 1;
    }
    if (check[i] == q) {
      b = i + 1;
    }
  }

  cout << abs(a - b) << endl;

}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
# import numpy as np

S = input().rstrip()

MOD = 10 ** 9 + 7
n = len(S)

# dp = np.zeros((100005, 13), dtype=np.uint64)

dp = [[0 for i in range(13)] for j in range(100005)]

dp[0][0] = 1

for i in range(n):
    if S[i] == '?':
        c = -1
    else:
        c = int(S[i])
    
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i+1][(ki * 10 + j) %13] += dp[i][ki]
            
    for j in range(13):
        dp[i+1][j] %= MOD
        
        
    res = dp[n][5]
    
print(res)


Measured memory_bytes: 66780
n = int(input())
c = []
d = []
e = []

for i in range(0, n):
    a, b = map(int, input().split())
    c.append(a)
    d.append(b)
    e.append(a + b)

li1, li2 = sorted(e), sorted(range(len(e)), key=lambda k: e[k])

turn = 0
happy = 0

for i in range(n - 1, -1, -1):
    now = li1[i]
    if (turn == 0):
        max = 0
        maxKey = 0
        for j in range(i, -1, -1):
            if (now == li1[j] and max < c[li2[j]]):
                max = c[li2[j]]
                maxKey = j
            else:
                li2[i], li2[maxKey] = li2[maxKey], li2[i]
                break
        happy += c[li2[i]]
    else:

        max = 0
        maxKey = 0
        for j in range(i, -1, -1):
            if (now == li1[j] and max < d[li2[j]]):
                max = d[li2[j]]
                maxKey = j
            else:
                li2[i], li2[maxKey] = li2[maxKey], li2[i]
                break

        happy -= d[li2[i]]
    turn = (turn + 1) % 2
print(happy)

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

#define llong long long 
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define rand __rand
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
template<class T = int> T rand(T range = numeric_limits<T>::max()) { return (T)(rng() % range); }

#define CONCAT_(x, y) x##y/*{{{*/
#define CONCAT(x, y) CONCAT_(x, y)
#ifdef LOCAL_DEBUG   
int __db_level = 0;
bool __db_same_line = false;
#define clog cerr << string(!__db_same_line ? __db_level * 2 : 0, ' ')
struct debug_block {
    function<void()> fn;
    void print_name() { __db_same_line = true; fn(); clog << endl; __db_same_line = false;  }
    debug_block(function<void()> fn_): fn(fn_) { clog << "{ "; print_name(); ++__db_level; }
    ~debug_block() { --__db_level; clog << "} "; print_name(); }
};
#define DB(args...) debug_block CONCAT(dbbl, __LINE__)([=]{ clog << args; })
#define deb(...)  if (1) { (clog << "[" #__VA_ARGS__ "] = [" << __VA_ARGS__) << "]"; if (!__db_same_line) clog << endl; }
#else
#define clog if (0) cerr
#define DB(...)
#define deb(...)
#endif
template<class T>
ostream& operator,(ostream& out, const T& thing) { return out << ", " << thing; }
template<class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) { return (out << "(" << p.first, p.second) << ")"; }
template<class A, class B>
ostream& operator<<(ostream& out, const tuple<A, B>& t) { return (out << "(" << get<0>(t), get<1>(t)) << ")"; }
template<class A, class B, class C>
ostream& operator<<(ostream& out, const tuple<A, B, C>& t) { return (out << "(" << get<0>(t), get<1>(t), get<2>(t)) << ")"; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& container) { 
    out << "{";
    if (len(container)) out << container[0];
    rep1(i, len(container) - 1) out, container[i];
    return out << "}";
}
template<class x> vector<typename x::value_type> $v(const x& a) { return vector<typename x::value_type>(a.begin(), a.end()); }
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION BELOW ////////////////////////////////////////////////////////////

const int maxn = 100;
int n;
llong a[maxn];
int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    rep(i, n) cin >> a[i];
    
    llong cur = 1000;
    llong cnt_stock = 0;
    
    rep(i, n - 1) {
        if (a[i] < a[i + 1]) {
            cnt_stock += cur / a[i];
            cur %= a[i];
        } else {
            cur += cnt_stock * a[i];
            cnt_stock = 0;
        }
    }
    
    cur += a[n - 1] * cnt_stock;
    cout << cur;
    

    return 0;
}

// Remember:
// - Multitest? REFRESHING the data!!!
// - Constrains for each set of data may differs. Should NOT USE the same max constant (maxn)
//   for all of them.
// vim: foldmethod=marker


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		sum+=a[i];
	}
	double ave=sum*1.0/n;
	int ans=0;
	double diff=ave-a[0];
	if(diff<0)diff*=(-1);
	for(int i=1;i<n;i++)
	{
		double tmp=ave-a[i];
		if(tmp<0)tmp*=(-1);
		if(diff>tmp)
		{
			ans=i;
			diff=tmp;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int maximum = 100000;
int dp[100001];

int main(){

	vector<int> V;

	V.push_back(1);

	int num = 6;

	for(int i = 1; ;i++){
		V.push_back(num);
		num *= 6;
		if(num > maximum)break;
	}

	num = 9;
	for(int i = 1; ;i++){
		V.push_back(num);
		num *= 9;
		if(num > maximum)break;
	}

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

		dp[i] = BIG_NUM;
	}
	dp[0] = 0;

	//ダブリングナップザック
	for(int i = 0; i < V.size(); i++){
		num = V[i];
		for(int k = 1; num <= maximum; k*=2){
			for(int a = maximum; a-num >= 0; a--){
				if(dp[a-num] == BIG_NUM)continue;

				dp[a] = min(dp[a],dp[a-num]+k);
			}
			num *= 2;
		}
	}

	int N;
	scanf("%d",&N);

	printf("%d\n",dp[N]);

	return 0;
}


Measured memory_bytes: 4128
#include <cstdio>
using namespace std;

int main() {
	double sum = 0;
	int n; scanf("%d", &n);
	while (n--) {
		char s[5]; double m;
		scanf("%lf%s", &m, s);
		if (s[0] == 'J') sum += m;
		else sum += m * 380000;
	}
	printf("%.6f", sum);
	return 0;
}

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

#define int long long
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)

struct Data {
    int id, l, r;
    Data *pre;
    Data *nxt;
    Data(int id, int l, int r) : id(id), l(l), r(r), pre(NULL), nxt(NULL) {}
};
void show(Data *fir) {
    Data *now = fir;
    while (now != NULL) {
        cout << now->id << " " << now->l << " " << now->r << endl;
        now = now->nxt;
    }
}
bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;
    Data fir(-1, 0, 0), las(-1, 1e18, 1e18);
    fir.nxt = &las;
    las.pre = &fir;
    // vector<Data> v;
    // v.emplace_back(-1, 0, 0);
    // v.emplace_back(-1, (int)1e18, (int)1e18);

    REP(_, N) {
        // show(&fir);
        char sign;
        cin >> sign;
        if (sign == 'W') {
            int id, siz;
            cin >> id >> siz;
            Data *now = &fir;
            while (now->nxt != NULL) {
                int d = now->nxt->l - now->r;
                if (d > 0) {
                    if (d >= siz) {
                        Data *tmp;
                        tmp = new Data(id, now->r, (now->r) + siz);
                        // Data tmp(id, now->r, (now->r) + siz);
                        tmp->nxt = now->nxt;
                        tmp->pre = now;
                        now->nxt->pre = tmp;
                        now->nxt = tmp;
                        break;
                    } else {
                        Data *tmp;
                        tmp = new Data(id, now->r, (now->r) + d);
                        tmp->nxt = now->nxt;
                        tmp->pre = now;
                        now->nxt->pre = tmp;
                        now->nxt = tmp;
                        siz -= d;
                    }
                }
                now = now->nxt;
            }
        } else if (sign == 'D') {
            Data *now = &fir;
            int id;
            cin >> id;
            while (now->nxt != NULL) {
                // cout << now->id << endl;
                if (now->id == id) {
                    now->nxt->pre = now->pre;
                    now->pre->nxt = now->nxt;
                }
                now = now->nxt;
            }
        } else if (sign == 'R') {
            int pos;
            cin >> pos;
            Data *now = &fir;
            bool found = false;
            while (now != NULL) {
                // cout << now->id << " " << now->l << " " << now->r << endl;
                if (now->l <= pos && now->r > pos) {
                    found = true;
                    cout << now->id << endl;
                    break;
                }
                now = now->nxt;
            }
            if (!found) cout << -1 << endl;
        }
    }
    cout << endl;
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 84276
import heapq
n,k=map(int,input().split())
v=[int(x) for x in input().split()]

p = list()
m = min(n,k)
t = 0

for h in range(1,m+1):
  for i in range(0,h+1):
    a = b = 0
    p.clear()
    for j in range(0,i):
      if v[j]<0:
        p.append(v[j])
      a += v[j]
    for j in range(1,h-i+1):
      if v[-j]<0:
        p.append(v[-j])
      b += v[-j]
    p.sort(reverse=True)
    n = a+b
    for i in range(min(k-h,len(p))):
      n -= p.pop()
    t = max(t,n)
print(t if t > 0 else 0)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

string toBinary(long long x, int n)
{
    string s;
    while (x != 0)
    {
        int r = abs(x % n);
        s += to_string(r);
        x -= r;
        x /= n;
    }
    reverse(s.begin(), s.end());

    return s;
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> F;
    vector<vector<int>> P;
    F.resize(N);
    P.resize(N);
    for (int i = 0; i < N; i++)
    {
        F[i].resize(10);
        P[i].resize(11);
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> F[i][j];
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 11; j++)
        {
            cin >> P[i][j];
        }
    }

    int ans = -1000000000;
    for (int i = 1; i < (1 << 10); i++)
    {
        string b = toBinary(i, 2);
        while (b.size() < 10)
        {
            b = "0" + b;
        }

        int tmp = 0;
        for (int j = 0; j < N; j++)
        {
            int num = 0;
            for (int k = 0; k < 10; k++)
            {
                if ((b[k] - '0') == 1 && F[j][k] == 1)
                {
                    num++;
                }
            }
            tmp += P[j][num];
        }
        if (tmp > ans)
        {
            ans = tmp;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, k, x, y;
  cin >> n >> k >> x >> y;
  ll ans = 0;
  if(n <= k) ans += n*x;
  else ans += k*x+(n-k)*y;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def f():
    n,s=int(input()),input()
    a,b=s[n-1::-1],s[n:]
    from collections import defaultdict
    ad=defaultdict(int)
    bd=defaultdict(int)
    for i in range(2**n):
        sa,ta,sb,tb="","","",""
        for j in range(n):
            if i%2:
                sa+=a[j]
                sb+=b[j]
            else:
                ta+=a[j]
                tb+=b[j]
            i//=2
        ad[(sa,ta)]+=1
        bd[(sb,tb)]+=1
    ans=0
    for k in ad:
        ans+=bd[k]*ad[k]
    print(ans)
if __name__ == "__main__":
    f()


Measured memory_bytes: 150056
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        boolean end_str = false;
        String s = sc.next();
        s = s.toLowerCase();
        char[] c = s.toCharArray();
        int l = s.length();
        int cnt = 0;
        while(true){
            String s1 = sc.next();
            if(s1.equals("END_OF_TEXT")){
                break;
            }
            s1 = s1.toUpperCase();
            s1 = s1.toLowerCase();
            //System.out.printf("%s%n",s1);
            char[] c1 = s1.toCharArray();
            
            int l1 = s1.length(),cnts=0;
            if(s1.equals(s)){
                cnt++;
            }
            /*
            for(int i=0;i<l1-l+1;i++){
                for(int j=0;j<l;j++){
                    if(c1[i+j] == c[j]){
                        cnts++;
                        //System.out.printf("%c:%d%n",c1[i+j],j);
                    }
                    else{
                        break;
                    }
                }
                if(cnts == l){
                    cnt++;
                }
                cnts = 0;
            }
            */
            
        }
        System.out.println(cnt);
        sc.close();
    }
}


Measured memory_bytes: 26336
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<pair<int,int>,int>> NPY(M);
  for(int i=0;i<M;i++){
    int p,y;
    cin >> p >> y;
    NPY.at(i)=make_pair(make_pair(p,y),i);
  }
  sort(NPY.begin(),NPY.end());
  
  vector<vector<int>> ans(M,vector<int>(2));
  int count=1;
  for(int i=0;i<M;i++){
    int x=NPY.at(i).second;
    ans.at(x).at(0)=NPY.at(i).first.first;
    ans.at(x).at(1)=count;
    if(i<M-1 && NPY.at(i).first.first==NPY.at(i+1).first.first)  count++;
    else  count=1;
  }

  for(int i=0;i<M;i++){
      printf("%06d%06d\n",ans.at(i).at(0),ans.at(i).at(1));
  }

  return 0;
}


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

int main() {
  int N, A, B; cin >> N >> A >> B;
  if ((ll)A * B < N or A + B - 1 > N) {
    cout << -1 << endl;
  } else {
    int cur {}, r { N - A };
    vector<int> ans;
    for (int i = 1; i <= A; i++) {
      int m = min(r, B - 1) + 1;
      r -= m - 1;
      for (int j = 0; j < m; j++) ans.push_back(cur + m - j);
      cur += m;
    }
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << ( (i == ans.size() - 1) ? '\n' : ' ' );
    }
  }
  return 0;
}


Measured memory_bytes: 3440
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2552
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

ans = ""

if A < B:
    a = A + V * T
    b = B + W * T
    if a >= b:
        ans = "YES"
    else:
        ans = "NO"
else:
    a = A - V * T
    b = B - W * T
    if a <= b:
        ans = "YES"
    else:
        ans = "NO"

print(ans)


Measured memory_bytes: 9188
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
ll h[maxn];

int main(){
    int n,k;
    cin >> n >> k;
    for(int i = 0;i < n;i++){
    	scanf("%lld",&h[i]);
	}
	sort(h,h+n);
	ll cnt = 0;
	if(k >= n){
		printf("0\n");
		return 0;
	}
	if(k != 0){
		for(int i = n - 1;i >= n - k;i--)
			h[i] = 0;
	}
	for(int i = 0;i < n;i++){
		cnt += h[i];
	}
	printf("%lld\n",cnt);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;
    
    int A[N];
    
    int B[N-1];
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }
    
    int point=0;
    
    for(int i=0;i<N;i++){
        if(i==0){
            A[i] = B[0];
            
        }else if(i>0 && i<N-1){
            A[i] = min(B[i-1],B[i]);   
        }else if(i == N-1){
            A[i] = B[N-2];
        }
        point += A[i];
    }
    cout << point <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  int A,B,T;
  cin >> A >> B >> T ;
  cout << T/A*B << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  LL N,K;
  cin>>N>>K;

  vector<LL> plus(0);
  vector<LL> minus(0);

  plus.push_back(0);
  minus.push_back(0);

  REP(i, N)
  {
    LL a;
    cin >> a;
    if(a>0){
      plus.push_back(a);
    }else
    if(a<0){
      minus.push_back(-a);
    }else{
      K--;
    }
  }

  SORT(plus);
  SORT(minus);

  LL min = 1145141919810931;

  REP(i,K+1){
    if(i<plus.size()&&(K-i)<minus.size()){
      LL hoge = plus[i]*2 + minus[K - i];
      if(hoge<min)
      {
        min = hoge;
      }hoge = plus[i] + minus[K - i]*2;
      if(hoge<min)
      {
        min = hoge;
      }
    }
  }

  cout << min << endl;
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000000

/*方針*/
/*辺をそれぞれ壊す。(全パターン)
　その辺の両端の頂点のうち、いずれかの点から全ての頂点へ行ければ、そこは橋ではない*/

//➀辺をpairに入れる。
//➁➀の辺それぞれを壊すことを考える。
//➂壊した辺の両端の頂点のうち、いずれかの点からdfsを行う。
//➃➂でdfsをして、全頂点に行ければ橋ではない。行っていない頂点が一つでもあれば橋なので、ans++
int main(){
	int n,m,ans=0;cin>>n>>m;
	
	vector<vector<int>> G(n);//隣接行列
	
	vector<pair<int,int>> P;
/*➀*/for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
		P.push_back(make_pair(a,b));//辺を記憶
	}

	for(int i=0;i<P.size();i++){//各辺について
		vector<int> visit(n,0);//各頂点を訪れたかどうかの判定(visit:1  !visit:0  切り離し:-1)
		
		stack<int> st;
		st.push(P[i].first);
/*➁*/		visit[P[i].first]=visit[P[i].second]=-1;//辺を一つ切り離す(-1が切り離されたところ)
		
/*➂*/		while(st.size()!=0){
	
			int now=st.top();
			st.pop();
			visit[now]=1;//visit

			visit[now]=1;//visitしたならば1
			for(auto next:G[now]){
				if(now==P[i].first && next==P[i].second) continue;//切り離し
				if(visit[next]==1) continue;//すでにvisit

				st.push(next);
			}
		}

		bool bridge=false;//橋か否か
/*➃*/		for(int j=0;j<n;j++){
			if(visit[j]==0 || visit[j]==-1){bridge=true;}//訪れていないところがあれば橋
		}
		if(bridge){ans++;}
	}

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

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string T, P;
	cin >> T >> P;
	int N = T.size(), M = P.size();

	vector<int> ans1, ans2;
	int n = 0;
	for(int i = 0; i < N; i++){
		if(T[i] == P[n]){
			ans1.push_back(i);
			n++;
			if(n == M) break;
		}
	}
	n = M - 1;
	for(int i = N - 1; i >= 0; i--){
		if(T[i] == P[n]){
			ans2.push_back(i);
			n--;
			if(n == -1) break;
		}
	}

	reverse(ans2.begin(), ans2.end());
	if(ans1.size() == P.size() && ans1 == ans2){
		cout << "yes" << endl;
	}
	else{
		cout << "no" << endl;
	}
}

Measured memory_bytes: 8944