akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;


int main()
{
  lint n, m;
  cin >> n >> m;
  vector<vector<lint>> cnct(n);
  REP(i,m){
    lint a, b;
    cin >> a >> b;
    a--;
    b--;
    cnct[a].push_back(b);
    cnct[b].push_back(a);
  }

  // 各部屋の部屋1からの距離と道しるべ
  vector<lint> dist(n, n);
  vector<lint> sign(n, -1);
  dist[0] = 0;
  sign[0] = 0;
  queue<lint> que;
  que.push(0);
  // 幅優先探索で部屋1からの距離を求めてゆく
  while(que.size()){
    lint node = que.front();
    que.pop();
    for(lint x : cnct[node]){
      // 未探索ならキューに追加
      if(dist[x] == n) que.push(x);
      // 距離と道しるべの更新
      if(dist[node]+1 < dist[x]){
        dist[x] = dist[node]+1;
        sign[x] = node;
      }
    }
  }

  // 連結成分がひとつならYes，そうでないならNo
  auto itr = find(ALL(sign), -1);
  if(itr != sign.end()){
    cout << "No\n";
  }else{
    cout << "Yes\n";
    FOR(i,1,sign.size()){
      cout << sign[i]+1 << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 13752
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    string a;
    int ans = 700;
    cin >> a;
    
    for(int i = 0; i < 3; i++)
    {
        
        if (a[i] == 'o') {
            ans+= 100 ;
        }
        
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
n,m = map(int,input().split())
A = list(map(int,input().split()))
CntA = [1 for i in range(n)]
for i in range(m):
  b,c = map(int,input().split())
  A.append(c)
  CntA.append(b)
Z = list(zip(A,CntA))
Z.sort(reverse=True)
ans = 0
for z in Z:
  if n>z[1]:
    ans+=z[1]*z[0]
    n-=z[1]
  else:
    ans+=n*z[0]
    break
print(ans)

Measured memory_bytes: 31460
#include <stdio.h>

int main(void)
{
  int h, w;
  char s[102][102];
  scanf("%d %d", &h, &w);
  for (int i = 0; i <= h+1; i++) {
    for (int j = 0; j <= w+1; j++) {
      s[i][j] = '#';
    }
  }
  for (int i = 1; i <= h; i++) {
    scanf("%s", s[i]);
    for (int j = w; j > 0; j--) {
      s[i][j] = s[i][j-1];
    }
    s[i][0] = '#';
  }
  for (int i = 0; i <= h+1; i++) {
    for (int j = 0; j <= w+1; j++) {
      printf("%c", s[i][j]);
    }
    putchar('\n');
  }
}


Measured memory_bytes: 128
import fractions
a,b,c,d = map(int,input().split())
a=a-1
x=(c*d)//fractions.gcd(c,d)
n=b//c-a//c
m=b//d-a//d
o=b//x-a//x
ans=b-a-n-m+o
print(ans)

Measured memory_bytes: 6712
#include<cstdio>
const long long mod=998244353ll;
long long n,k,pu[500600];
long long matmod(long long v,long long k){
	long long ans=1ll;
	for(;k;k>>=1){
		if(k&1) ans=(ans*v)%mod;
		v=(v*v)%mod;
	}
	return ans;
}
long long C(long long o,long long p){
	if(p==0) return 1ll;
    if(o<p) return 0ll;
    if(o==p) return 1ll;
	long long ls=pu[p]*pu[o-p]%mod;
	ls=matmod(ls,mod-2ll);
	return pu[o]*ls%mod;
}
int main(){
	long long a,b,ans=0ll;
	pu[0]=1ll;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	for(long long i=1ll;i<=n+5;i++)
		pu[i]=(pu[i-1ll]*i)%mod;
	if(!k){puts("1");return 0;}
	//if(n*(a+b)<k){puts("0");return 0;}
	//if(k%gcd(a,b)!=0){puts("0");return 0;}
	for(long long i=0ll;i<=n;i++){
		if(k-a*i<0) continue;
		if(!((k-a*i)%b)){
			long long j=(k-a*i)/b;
			if(j>n) continue;
			ans=(ans+C(n,j)*C(n,i)+mod)%mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin>>n;
	int k;
	cin>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	    cin>>arr[i];
	int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++)
    {
        int j=max(0,i-k);
        dp[i]=dp[j]+abs(arr[i]-arr[j]);
        for(;j<i;j++)
            if(dp[j]+abs(arr[i]-arr[j])<dp[i])
                dp[i]=dp[j]+abs(arr[i]-arr[j]);
    }
    cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll inf=100000000000000000,mod=1000000007;
string fn(ll num)
{
     string s;
     while(num)
     {
         s+=(num%10+'0');
         num/=10;
     }
     return s;
}
int main(){
  
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll n,num1,num2;
    cin>>n;
    map<pair<ll,ll> ,ll> mp;string s;
    for(ll i=1;i<=n;i++)
    {
        s=fn(i);
       num1=s[0]-'0';
       num2=s[s.length()-1]-'0';
       mp[{num1,num2}]++;
    }
    ll ans=0;
    for(ll i=1;i<10;i++)
    {
        for(ll j=i;j<10;j++)
        {
            ans+=(mp[{i,j}]*mp[{j,i}]);
            if(i!=j)
            ans+=(mp[{j,i}]*mp[{i,j}]);
            // cout<<ans<<" ";
        }
    }
    // ans*=2;
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
using namespace std;
typedef long long int lli;
typedef long long ll;
#define mod 10000000007
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   lli n;
   cin>>n;
   vector<int>v(n);
   lli i,ans=0;
   for(i=0;i<n;i++)
     cin>>v[i];
   int x=0;
   sort(v.begin(),v.end(),greater<>());
   for(i=0;i<n-1;i++)
   {
       ans+= (ll)v[x];
       if(i%2==0)
         x++;
   }
   cout<<ans<<"\n";
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  int n, m;
  cin >> n >> m;
  tuple<int, int, int> data[m];
  rep(i, m){
    int p, y;
    cin >> p >> y;
    data[i] = make_tuple(y, p, i);
  }
  sort(data, data+m);
  int cnt[n+1];
  fill(cnt, cnt+n+1, 0);
  P id[m];
  
  rep(i, m){
    int y, p, idx;
    tie(y, p, idx) = data[i];
    cnt[p]++;
    id[idx] = make_pair(p, cnt[p]);
  }

  rep(i, m){
    cout << setw(6) << setfill('0') << id[i].first;
    cout << setw(6) << setfill('0') << id[i].second << endl;
  }
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int N;
        int num[];
        String line;

        Scanner scan=new Scanner(System.in);

        line=scan.next();
        N=Integer.parseInt(line);

        if(N<1||100<N){
            return;
        }
        
        num=new int[N];

        for(int i=0;i<N;i++){
            num[i]=Integer.parseInt(scan.next());
            if(num[i]<0||num[i]>100){
                return;
            }
        }

        //バブルソート
        int swap_num=0;
        for(int i=0;i<N-1;i++){
            for(int j=N-1;j>i;j--){
                if(num[j]<num[j-1]){
                    int temp=num[j];
                    num[j]=num[j-1];
                    num[j-1]=temp;

                    swap_num++;
                }
            }
        }

        for(int i=0;i<N;i++){
             if(i==N-1)System.out.print(num[i]);
             else System.out.print(num[i]+" ");

        }
        System.out.println();
        System.out.println(swap_num);
    }
}


Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2e5+10;
ll N,M,K,CstA[MAXN],CstB[MAXN];

inline void pre(){
    cin>>N>>M>>K;
    for(int i=1;i<=N;i++) cin>>CstA[i];
    for(int i=1;i<=N;i++) CstA[i]+=CstA[i-1];
    for(int i=1;i<=M;i++) cin>>CstB[i];
    for(int i=1;i<=M;i++) CstB[i]+=CstB[i-1];
}

int main(){
    pre();
    int CurA=N,CurB=0,Ans=0;
    while(CurB<=M){
        while(CurA>=0&&CstA[CurA]+CstB[CurB]>K)
            CurA--;
        if(CurA<0) break;
        Ans=max(Ans,CurA+CurB);
        CurB++;
    }
    cout<<Ans;
    return 0;
}

Measured memory_bytes: 6740
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {

    SS(double,n,m,d);
    double ans=2*(n-d)*(m-1)/n/n;
    if(d==0)ans/=2;
    p(ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a.at(i);
  queue<tuple<int, int, int>> q;
  rep(i, h)rep(j, w){
    if(a.at(i).at(j) == '#') q.push({i, j, 0});
  }
  int ans = 0;
  int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};
  while(!q.empty()){
    auto [i, j, k] = q.front(); q.pop();
    ans = max(ans, k);
    rep(l, 4){
      int ni = i + di[l], nj = j + dj[l];
      if(nj < 0 || w <= nj || ni < 0 || h <= ni) continue;
      if(a.at(ni).at(nj) == '#') continue;
      a.at(ni).at(nj) = '#';
      q.push({ni, nj, k+1});
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int  s;
  cin >> s;
  int s1 = s/100 % 100;
  int s2 = s % 100;
  if((s1 > 12 || s1 == 0) && (s2 > 12 || s2 == 0)) cout << "NA" << endl;
  else if(s1 > 12 || s1 == 0) cout << "YYMM" << endl;
  else if(s2 > 12 || s2 == 0) cout << "MMYY" << endl;
  else cout << "AMBIGUOUS" << endl;

}

Measured memory_bytes: 256
n=int(input())
S=[input() for i in range(n)]
a=[0]*4
a[0]="AC"
a[1]="WA"
a[2]="TLE"
a[3]="RE"
c=[0]*4
for i in range(4):
  c[i]=S.count(a[i])
for i in range(4):
  print(a[i],"","x","",c[i])


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

int main() {
  string S;
  cin >> S;
  int s = S.size();
  if (s != 26) {
    vector<bool> alphabet(26, false);
    for (int i = 0; i < s; i++) {
      alphabet[(int)(S[i]-97)] = true;
    }
    int unuse;
    for (int i = 0; i < 26; i++) {
      if (!alphabet[i]) {
        unuse = i;
        break;
      }
    }
    char plus = (char)(97+unuse);
    S.push_back(plus);
    cout << S << endl;
  }
  else {
    if (S == "zyxwvutsrqponmlkjihgfedcba") {
      cout << -1 << endl;
      return 0;
    }
    string T = S;
    next_permutation(S.begin(), S.end());
    for (int i = 0; i < s; i++) {
      cout << S[i];
      if (S[i] != T[i]) break;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
import bisect
INF = 1000000000000000000

A,B,Q = map(int,input().split())
lA = []
lB = []
lQ = []
lA.append(-INF)
lB.append(-INF)

for i in range(A):
    a = int(input())
    lA.append(a)

for i in range(B):
    b = int(input())
    lB.append(b)

for i in range(Q):
    q = int(input())
    lQ.append(q)

lA.append(INF)
lB.append(INF)
    

for i in lQ:
    ar = bisect.bisect_right(lA,i)
    al = ar - 1

    br = bisect.bisect_right(lB,i)
    bl = br - 1

    ans = INF

    for S in [lA[al],lA[ar]]:
        for T in [lB[bl],lB[br]]:
            d1 = abs(S-i) + abs(T-S)
            d2 = abs(T-i) + abs(S-T)

            ans = min(ans,d1,d2)

    print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

//vector<ll> G[100100];

class UnionFind{
    int n;
    vector<int> par;
    vector<int> depth;
    vector<int> size;

    public:
    UnionFind(int N){
        n = N;
        par.resize(n);
        REP(i,n) par[i] = i;
        depth.resize(n, 1);
        size.resize(n, 1);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(depth[x] > depth[y]){
            par[y] = x;
            size[x] += size[y];
        }
        else{
            par[x] = y;
            size[y] += size[x];
            if(depth[x] == depth[y])
                depth[y] += 1;
        }
    }

    int find(int x){
        if(par[x] == x)
            return x;
        else
            return find(par[x]);
    }

    int get_size(int n){
        return size[find(n)];
    }
};

int main(){
    ll N, M, K;
    cin >> N >> M >> K;

    vector<ll> X(N);
    vector<ll> Y(N);
    UnionFind uni(N);

    REP(i,M){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        uni.unite(a, b);
        X[a]++;
        X[b]++;
    }

    map<int, set<int>> ma;
    REP(i,N){
        int x = uni.find(i);
        ma[x].insert(i);
    }

    REP(i,K){
        ll c, d;
        cin >> c >> d;
        c--, d--;
        int cp = uni.find(c);
        int dp = uni.find(d);
        if(ma[cp].find(d) != ma[cp].end())
            Y[c]++;
        if(ma[dp].find(c) != ma[dp].end())
            Y[d]++;
    }

    REP(i,N){
        ll ans = 0;
        ans += uni.get_size(i);
        ans -= X[i];
        ans -= Y[i];
        ans --;
        printf("%lld ", ans);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 17152
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
	vector<P> v[100001];
	int n, m;
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int p, y;
		cin>>p>>y;
		v[p].push_back(P(y, i));
	}
	ll ans[100001];
	for(ll i=1; i<=n; i++){
		sort(v[i].begin(), v[i].end());
		for(ll j=0; j<v[i].size(); j++){
			int t=v[i][j].second;
			ans[t]=i*1000000+j+1;
		}
	}
	for(int i=0; i<m; i++) printf("%012lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 7808
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, ans = 0;
	int a[114514], b[114514];
	cin >> n;
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		a[i] += ans;
		if (a[i] % b[i] == 0) continue;
		ans += b[i] * (a[i] / b[i] + 1) - a[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100000+5;
int dp[MAXN],n,w,m,v;

int main(){
	cin>>n>>m;
	for(int i=1;i<=100000;++i) dp[i]=1000000001;
	for(int i=1;i<=n;++i){
		cin>>w>>v;
		for(int j=100000;j>=v;--j) dp[j]=min(dp[j],dp[j-v]+w);
	}
	for(int i=100000;i;--i) if(dp[i]<=m) { cout<<i<<endl; break; }
	return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve() {
	int n, m;
	cin >> n >> m;

	vi ship(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		if (a == 0) {
			ship[b]++;
		}

		if (b == n - 1) {
			ship[a]++;
		}
	}

	for (int i = 0; i < n; i++) {
		if (ship[i] == 2) {
			return true;
		}
	}

	return false;
}

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

	cout << (solve() ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
using namespace std;
int main(void)
{
    int n,yy,mm;
    cin>>n;
    yy=n/100;
    mm=n%100;
    if(mm>=1&&mm<=12){
        if(yy>=1&&yy<=12){
            cout<<"AMBIGUOUS"<<endl;
        }
        else{
            cout<<"YYMM"<<endl;
        }
    }else if(yy>=1&&yy<=12){
        cout<<"MMYY"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    string s;
    cin >> s;
    if (s.size() == 1) {
        cout << s << endl;
        ret();
    }
    int ans = 0;

    if (*min_element(s.begin() + 1, s.end()) == '9') {

    } else {
        s.front()--;
        rep(i, s.size()) {
            if (i == 0) continue;
            s[i] = '9';
        }
    }
    for (char c : s) {
        int k = c - '0';
        ans += k;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
def main():
    n, k = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]

    R = [1]
    RS = set(R)
    cnt = 0
    while True:
        nx = A[R[-1] - 1]
        if nx in RS:
            st = R.index(nx)
            R = R[st:]
            break

        R.append(nx)
        RS.add(nx)

        cnt += 1
        if cnt == k:
            print(nx)
            exit()

    m = (k - cnt) % len(R)
    print(R[m - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 114956
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

long long solve(long long X, long long K, long long D) {
  // TODO: edit here
  ll cnt = abs(X) / D;
  if (cnt >= K) {
    return abs(X) - K * D;
  } else {
    if ((K - cnt) % 2 == 0) {
      return abs(X) % D;
    } else {
      return D - abs(X) % D;
    }
  }
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  long long X, K, D;
  std::cin >> X >> K >> D;
  auto ans = solve(X, K, D);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3624
import sys,queue,math,copy,itertools,bisect,collections,heapq
LI = lambda : [int(x) for x in sys.stdin.readline().split()]

N,M = LI()
A = list(itertools.accumulate(LI()))

d = {0:1}
for x in A:
    m = x % M
    if m in d: d[m] += 1
    else: d[m] = 1

ans = 0
for x in d.values():
    ans += x * (x-1) // 2
print (ans)

Measured memory_bytes: 64796
#include <cstdio>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
int n,m,i,j,odd,l,c[N],a[N],b[N];
int main()
{
//	freopen("sequence.in","r",stdin);
//	freopen("sequence.out","w",stdout);
	scanf("%d%d",&n,&m);
	rep(i,1,m) {
		scanf("%d",&a[i]);
		if (a[i]%2==1) odd++,c[odd]=a[i];
	}
	if (odd>=3) printf("Impossible\n");
	else if (odd==0 && m==1) {
		b[++l]=1; b[++l]=n/2-1; b[++l]=n/2;
		if (a[1]==2) b[--l]=1;
		printf("%d\n",a[1]);
		printf("%d\n",l);
		rep(i,1,l) printf("%d ",b[i]); printf("\n");
	}
	else {
		if (odd>=1) rep(i,1,c[1]/2+1) b[++l]=2;
		rep(i,1,m)
		if (a[i]%2==0)	b[++l]=a[i];
		rep(i,1,c[2]/2) b[++l]=2;
		if (odd==1) b[l]--;
		if (odd==0) b[1]++,b[l]--;
		if (odd>=1) printf("%d ",c[1]); rep(i,1,m) if (a[i]%2==0) printf("%d ",a[i]);
		if (odd>=2) printf("%d ",c[2]); printf("\n");
		printf("%d\n",l);
		rep(i,1,l) printf("%d ",b[i]); printf("\n");
	}
	return 0;
}

Measured memory_bytes: 512
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    ind(n); 
    
    out(n*6.283185307179586232);
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,y,a,b,c,p,q,r;cin>>x>>y>>a>>b>>c;
  lvector A(a,0),B(b,0),C(c,0);
  priority_queue<ll,lvector,greater<ll>> Aq,Bq,Cq;
  rep(i,a) cin>>A[i];sort(ALL(A));rep(i,x) Aq.push(A[a-1-i]);
  rep(i,b) cin>>B[i];sort(ALL(B));rep(i,y) Bq.push(B[b-1-i]);
  rep(i,c) cin>>C[i];sort(ALL(C));
  ll cpos=c-1;
  while(cpos>=0) {
    ll atop=Aq.top(),btop=Bq.top(),cval=C[cpos];
    if(atop>=cval&&btop>=cval) break;
    if(atop<cval&&btop<cval) {
      if(atop>btop) {Bq.pop();Bq.push(cval);}
      else {Aq.pop();Aq.push(cval);}
    }
    if(atop>=cval&&btop<cval) {Bq.pop();Bq.push(cval);}
    if(atop<cval&&btop>=cval) {Aq.pop();Aq.push(cval);}
    cpos--;
  }
  ll ans=0;
  while(!Aq.empty()) {
    ans+=Aq.top();Aq.pop();
  }
  while(!Bq.empty()) {
    ans+=Bq.top();Bq.pop();
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 4852
#include "bits/stdc++.h"
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == s[i] - '0')
      ++cnt1;
    else
      ++cnt2;
  }
  cout << min(cnt1, cnt2) << endl;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int count(vector<int> ls, int x) {
  const int n = ls.size();
  int left;
  int right;

  {{{ // search left
    if (ls[0] == x) {
      left = 0;
    } else {
      int l = 0;
      int r = n;
      // ls[l] < x <= ls[r]
      while (l < r) {
        if (l + 1 == r) {
          if (ls[l] == x) left = l;
          else if (ls[r] == x) left = r;
          else return 0;
          break;
        }
        int m = (l + r) / 2;
        if (ls[m] < x) {
          l = m;
        } else {
          r = m;
        }
      }
    }
  }}}

  {{{ // search right
    if (ls[n-1] == x) {
      right = n;
    } else {
      int l = 0;
      int r = n;
      // ls[l] <= x < ls[r]
      while (l < r) {
        if (l + 1 == r) {
          if (ls[l] == x) right = r;
          else if (ls[r] == x) right = r + 1;
          else return 0;
          break;
        }
        int m = (l + r) / 2;
        if (ls[m] <= x) {
          l = m;
        } else {
          r = m;
        }
      }
    }
  }}}

  return right - left;
}

int main() {

more:;
   int n, m; cin >> n >> m;
   if (!n && !m) return 0;

   vector<int> xs(n+2, -1);
   rep (i, n) xs[i] = n - i;

   rep (i, m) {
     int c, p; cin >> p >> c;
     rotate(xs.begin(), xs.begin() + p - 1, xs.begin() + c + p - 1);
   }
   cout << xs[0] << endl;
   goto more;

  return 0;
}

Measured memory_bytes: 1216
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(a <= 8 && b <= 8 ? "Yay!" : ":(");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufLength == -1)
                throw new InputMismatchException();
            if (bufPointer >= bufLength) {
                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (bufLength == -1)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            long n = 0;

            boolean minus = false;
            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9')
                throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (isSpaceChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, k, i;
	cin >> n >> k;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	
	for(i = 0; i < k; i++) {
		int diff[n + 1];
		memset(diff, 0, sizeof diff);
		
		for(int j = 0; j < n; j++) {
			int l = max(0, j - arr[j]);
			int r = min(n - 1, j + arr[j]);
			diff[l]++;
			diff[r + 1]--;
		}
		
		for(int j = 0; j < n; j++) {
			if(j == 0)
			arr[j] = diff[j];
			else
			arr[j] = diff[j] + arr[j - 1];
		}
		bool ok = 1;
		for(int x : arr) {
			if(x != n) {
				ok = 0;
				break;
			}
		}
		if(ok) break;
	}
	for(int x : arr)
	cout << x << ' ';
}


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

int main() {
  string S;
  cin>>S;
  bool test1=true;
  bool test2=true;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='N'){
      test1=false;
      for(int j=0;j<S.size();j++){
        if(S.at(j)=='S'){
          test1=true;
        }
      }
    }
    if(S.at(i)=='S'){
      test1=false;
      for(int j=0;j<S.size();j++){
        if(S.at(j)=='N'){
          test1=true;
        }
      }
    }
    if(S.at(i)=='W'){
      test2=false;
      for(int j=0;j<S.size();j++){
        if(S.at(j)=='E'){
          test2=true;
        }
      }
    }
    if(S.at(i)=='E'){
      test2=false;
      for(int j=0;j<S.size();j++){
        if(S.at(j)=='W'){
          test2=true;
        }
      }
    }
  }
  if(test1&&test2){
    cout<<"Yes"<< endl;
  }
  else{
    cout<<"No"<< endl;
  }
}
          


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>a>>b;
      if(a%b==0)Cout(0);
      else Cout(1);
     

       
return 0;
}


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

int main(){
	int v[2]={};
	for(int i=0; i<2; i++){
		for(int j=0; j<4; j++){
			int n;
			cin >> n;
			v[i] += n;
		}
	}
	cout << max(v[0], v[1]) << endl;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0;
  int xmax = 0;
  REP(i,n){
    if(s[i] == 'I') x++;
    else x--;

    xmax = max(x, xmax);

  }

  cout << xmax << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <map>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<intmax_t> A(N);
  std::map<intmax_t, int> S;
  for (size_t i=0; i<N; ++i) {
    scanf("%jd", &A[i]);
    ++S[A[i]];
  }

  int res = 0;
  for (intmax_t pt=1<<30; pt; pt>>=1) {
    for (auto it=S.begin(); it!=S.end();) {
      intmax_t key = it->first;
      int n = it->second;

      auto pair = S.find(pt-key);
      if (pair == S.end()) {
        ++it;
        continue;
      }

      if (pair == it) {
        res += n/2;
        it->second %= 2;
        if (it->second == 0) {
          it = S.erase(it);
        } else {
          ++it;
        }
        continue;
      }

      int m = pair->second;
      int d = std::min(n, m);
      it->second -= d;
      pair->second -= d;
      res += d;

      if (pair->second == 0) {
        S.erase(pair);
      }
      if (it->second == 0) {
        it = S.erase(it);
      } else {
        ++it;
      }
    }
  }
  printf("%d\n", res);
}


Measured memory_bytes: 14336
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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 Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, long long K, std::vector<long long> p);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
}

void solve(long long N, long long K, std::vector<long long> p){
    sort(ALL(p));
    ll sum = 0;
    REP(i, K){
        sum += p[i];
    }
    cout << sum << el;
}



Measured memory_bytes: 3688
#include <iostream>
#include <cstdlib>
#include <algorithm>


int main() {
	long long int a, b, c, d;
	long long int m1, m2, m3, m4;

	std::cin >> a >> b >> c >> d;
	m1 = a*c;
	m2 = a*d;
	m3 = b*c;
	m4 = b*d;

	std::cout << std::max({m1, m2, m3, m4}) << "\n";

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

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


int n;
int freq[N+5];
int main()
{
  finp;
  cin>>n;
  afor(i,1,n)
  {
  	int val;
  	cin>>val;
  	freq[val]++;
  }

  int od = 0;
  int ev = 0;
  afor(i,1,N)
  {
  	if(freq[i] & 1)od++;
  	else if(freq[i])ev++;
  }

  cout<<(od + 2*(ev/2));
  
return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;


int main(){
  cin >> s;
  stack<char> st;
  rep(i,s.size()){
    if(s[i] == 'B'){
      if(st.size() > 0) st.pop();
    }else{
      st.push(s[i]);
    }
  }
  s = "";
  int n = st.size();
  rep(i, n ){
    s += st.top();
    st.pop();
  }
  reverse(s.begin(),s.end());
  cout << s;
  cout << "\n";
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n,k; cin >> n >> k;
    vector<double> p(n+1);
    
    for(int i=0;i<n;i++){
      double P; cin >> P;
      p[i+1] = p[i] + (P+1)/2; 
    }
    double ans = 0;
    for(int i=k;i<n+1;i++){
      ans = max(ans,p[i]-p[i-k]);
    } 
    cout << fixed << setprecision(10) << ans << endl;
}
  

Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
	int x, y, j, c;
	scanf("%d %d %d", &x, &y, &j);
	c=x+y+j;
	
	if (c <22){
		printf("win\n");
	}
	else if (c >= 22){
		printf("bust\n");
	}
	return 0;
}

Measured memory_bytes: 3164
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      mut sps: [(String,i64); n],
    }
    let mut list = vec![];
    for i in 0..n {
        list.push((
            sps[i].0.clone(),
            sps[i].1,
            i
        ))
    }
    list.sort_by_key(|v| (v.0.clone(), v.1 * -1));
    for i in 0..n {
        println!("{}", list[i].2 + 1);
    }
}


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

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


Measured memory_bytes: 3100
def binSearch(l, x):
	u = 0
	d = len(l) - 1
	while True:
		if u > d:
			break
		m = int((u + d) / 2)
		if l[m] == x:
			return True
		elif l[m] < x:
			u = m + 1
		else:
			d = m - 1
	return False

n = int(input())
ni = [int(x) for x in input().split()]
q = int(input())
qi = [int(x) for x in input().split()]

print(sum([1 for x in qi if binSearch(ni, x) is True]))


Measured memory_bytes: 16900
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, T = readnums()
    t = list(readnums())

    ans = 0
    for i in range(N - 1):
        if t[i + 1] - t[i] >= T:
            ans += T
        else:
            ans += t[i + 1] - t[i]

    print(ans + T)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25744