akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>



using namespace std;




int main() {
	
	unsigned long long int a,b,ans;;
	cin>>a>>b;
	ans=b;
	for(int i=0;i<a-1;i++)
		ans*=b-1;
	cout<<ans<<endl;

    return 0;
}

	
	


	

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
bool checked[17000000];
int FREE[17000000];
int x[25], y[25], r[25], c[25];
vector<int> colorinv[5];

int powd(int i, int j) {
    int dx = x[i] - x[j];
    int dy = y[i] - y[j];
    return dx * dx + dy * dy;
}

int bitcount(int bit) {
    if(bit == 0) return 0;
    return (1 & bit) + bitcount(bit >> 1);
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n; 
        if(n == 0) break;
        for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i] >> c[i];
        for(int i = 0; i <= 4; i++) colorinv[i].clear();
        for(int i = 0; i < n; i++) {
            colorinv[c[i]].push_back(i);
        }
        for(int i = 0; i < (1 << n); i++) {
            checked[i] = false;
            FREE[i] = 0;
        }
        for(int i = 1; i < (1 << n); i++) {
            int maxi = 0;
            while(!(1 & (i >> maxi))) maxi++;
            FREE[i] = FREE[i ^ (1 << maxi)];
            for(int j = maxi + 1; j < n; j++) {
                if(powd(j, maxi) < (r[j] + r[maxi]) * (r[j] + r[maxi])) FREE[i] &= ~(1 << j);
            }
            FREE[i] |= (1 << maxi);
            //cerr << i << " " << FREE[i] << endl;
        }
        checked[(1<<n) - 1] = true;
        int ans = 0;
        for(int bit = (1<<n) - 1; bit >= 0; bit--) {
            //cerr << bit << endl;
            if(!checked[bit]) continue;
            //cerr << bit << endl;
            ans = max(ans, n - bitcount(bit));
            for(int color = 0; color <= 4; color++) {
                for(int i = 0; i < colorinv[color].size(); i++) {
                    for(int j = i + 1; j < colorinv[color].size(); j++) {
                        if((FREE[bit] >> colorinv[color][i]) & (FREE[bit] >> colorinv[color][j]) & 1) {
                            int newbit = bit;
                            newbit &= ~(1 << colorinv[color][i]);
                            newbit &= ~(1 << colorinv[color][j]);
                            checked[newbit] = true;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 85092
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;

int n;
int parent[MAX_N];
pair<int, int> child[MAX_N];

void Preorder(int c) {
	if (c == -1) return;
	cout << ' ' << c;
	Preorder(child[c].first);
	Preorder(child[c].second);
}

void Inorder(int c) {
	if (c == -1) return;
	Inorder(child[c].first);
	cout << ' ' << c;
	Inorder(child[c].second);
}

void Postorder(int c) {
	if (c == -1) return;
	Postorder(child[c].first);
	Postorder(child[c].second);
	cout << ' ' << c;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		parent[i] = -1;

	for (int i = 0, id; i < n; i++) {
		cin >> id;
		cin >> child[id].first >> child[id].second;
		if (child[id].first != -1) parent[child[id].first] = id;
		if (child[id].second != -1) parent[child[id].second] = id;
	}

	int rt;
	for (int i = 0; i < n; i++) {
		if (parent[i] == -1) {
			rt = i;
			break;
		}
	}
	cout << "Preorder" << endl;
	Preorder(rt);
	cout << endl;

	cout << "Inorder" << endl;
	Inorder(rt);
	cout << endl;

	cout << "Postorder" << endl;
	Postorder(rt);
	cout << endl;
	return 0;
}

Measured memory_bytes: 3100
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/rope>
// #include <type_traits>
using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)

#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sum(xs) accumulate(all(xs), 0)
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
#define reverse(xs) reverse(all(xs))
#define contain(xs,n) (find(all(xs),n)!=xs.end())
#define unique(xs) xs.erase(unique(all(xs)),xs.end())
#define search(xs,n) distance(xs.begin(),find(all(xs),n))
#define count(xs,n) count(all(xs),n)
#define vecmin(xs) *min_element(all(xs))
#define vecmax(xs) *max_element(all(xs))

template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}

// 複数，シフト，演算
// #define newvec(T,n,xs) vector<T> xs(n)

#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define invec(T,n,...) vector<T> __VA_ARGS__;T t;_cinvec(t,n,__VA_ARGS__)
#define invec2(T,n,xs,ys) vector<T> xs(n),ys(n);fou(i,0,n)cin>>xs.at(i)>>ys.at(i)
#define invec3(T,n,xs,ys,zs) vector<T> xs(n),ys(n),zs(n);fou(i,0,n)cin>>xs.at(i)>>ys.at(i)>>zs[i]
// #define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
// #define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define out(...) _cout(__VA_ARGS__)
#define outvec(xs) tra(x,xs) cout << x << " ";cout << endl
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}


// #define int int64_t
// #define double long double

// map,文字列処理


signed main(){
  in(int,a,b,c,d,e);
  int x=10;
  int ax=a%10;if(ax!=0){a+=(-ax+10);mini(x,ax);}
  int bx=b%10;if(bx!=0){b+=(-bx+10);mini(x,bx);}
  int cx=c%10;if(cx!=0){c+=(-cx+10);mini(x,cx);}
  int dx=d%10;if(dx!=0){d+=(-dx+10);mini(x,dx);}
  int ex=e%10;if(ex!=0){e+=(-ex+10);mini(x,ex);}
  out(a+b+c+d+e+x-10);
}

Measured memory_bytes: 256
#define MOD 1000000007
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int k;
	cin>>k;
	while(k--){
		cout<<"ACL";
	}
	cout<<endl;
}


Measured memory_bytes: 3616
from collections import Counter
N = int(input())
A = list(input())
B = list(input())
C = list(input())

ans = 0
for i in range(N):
    tmp = list(A[i] + B[i] + C[i])
    cnt = Counter(tmp)
    max_cnt = max(cnt.values())

    if max_cnt == 3:
        # 出現する同じ英字の個数が3であれば、置換不要のためカウントしない。
        pass
    else:
        # 出現する同じ英字の個数が3以外の場合、3 - (出現する同じ英字の個数の最大値) 回置換する。
        # 例：w, e, w の場合、同じ個数の最大値は、wの2個。置換は、3-2=1回。
        ans = ans + (3 - max_cnt)

print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int ans=0;
	string s;
	cin>>s;
	int l=s.length();
	REP(i,l/2){
		if(s[i]!=s[l-i-1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
#define DEBUG

const int maxn=100005;
int x,k,q,rt;
pii qt[maxn];
int qa[maxn],r[maxn],ans[maxn];

namespace Segtree{
	int tot=0;
	class node{
	public:
		int ls,rs,mn,mx,tag,add;
		node(int _mn=0,int _mx=0){ls=rs=add=0;tag=-1;mn=_mn;mx=_mx;}
	}t[maxn*50];
	void push_down(int v,int l,int r){
		int mid=(l+r)>>1;
		int &ls=t[v].ls,&rs=t[v].rs;
		if(!ls)ls=++tot,t[ls]=node(l,mid);
		if(!rs)rs=++tot,t[rs]=node(mid+1,r);
		if(t[v].tag>=0){
			t[ls].mn=t[ls].mx=t[ls].tag=t[v].tag;t[ls].add=0;
			t[rs].mn=t[rs].mx=t[rs].tag=t[v].tag;t[rs].add=0;
			t[v].tag=-1;
		}
		if(t[v].add!=0){
			t[ls].mn+=t[v].add;t[ls].mx+=t[v].add;t[ls].add+=t[v].add;
			t[rs].mn+=t[v].add;t[rs].mx+=t[v].add;t[rs].add+=t[v].add;
			t[v].add=0; 
		}
	} 
	void push_up(int v){
		int ls=t[v].ls,rs=t[v].rs;
		t[v].mx=max(t[ls].mx,t[rs].mx);
		t[v].mn=min(t[ls].mn,t[rs].mn);
	}
	void increase(int &v,int l,int r,int val){
		if(!v)v=++tot,t[v]=node(l,r);
		if(t[v].mn>x-val){t[v].mn=t[v].mx=t[v].tag=x;t[v].add=0;return;}
		if(t[v].mx<=x-val){t[v].mn+=val;t[v].mx+=val;t[v].add+=val;return;}
		push_down(v,l,r);
		int mid=(l+r)>>1;
		increase(t[v].ls,l,mid,val);increase(t[v].rs,mid+1,r,val);
		push_up(v);
	}
	void decrease(int &v,int l,int r,int val){
		if(!v)v=++tot,t[v]=node(l,r);
		if(t[v].mx<val){t[v].mn=t[v].mx=t[v].tag=0;t[v].add=0;return;}
		if(t[v].mn>=val){t[v].mn-=val;t[v].mx-=val;t[v].add-=val;return;}
		push_down(v,l,r);
		int mid=(l+r)>>1;
		decrease(t[v].ls,l,mid,val);decrease(t[v].rs,mid+1,r,val);
		push_up(v);
	}
	int query(int &v,int l,int r,int k){
		if(!v)v=++tot,t[v]=node(l,r);
		if(l==r)return t[v].mn;
		push_down(v,l,r);
		int mid=(l+r)>>1;
		if(k<=mid)return query(t[v].ls,l,mid,k);
		else return query(t[v].rs,mid+1,r,k);
	}
}

int main(){
#ifndef DEBUG
	freopen("my.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%d%d",&x,&k);
	REP(i,k)scanf("%d",&r[i]);
	scanf("%d",&q);
	REP(i,q){
		scanf("%d%d",&qt[i].fst,&qa[i]);
		qt[i].snd=i;
	}
	sort(qt+1,qt+1+q);
	int ptr=1;
	REP(i,q){
		while(ptr<=k&&r[ptr]<=qt[i].fst){
			if(ptr&1)Segtree::decrease(rt,0,x,r[ptr]-r[ptr-1]);
			else Segtree::increase(rt,0,x,r[ptr]-r[ptr-1]);
			ptr++; 
		}
		int id=qt[i].snd;
		ans[id]=Segtree::query(rt,0,x,qa[id]);
		if(ptr&1)ans[id]=max(ans[id]-qt[i].fst+r[ptr-1],0);
		else ans[id]=min(ans[id]+qt[i].fst-r[ptr-1],x);
	}
	REP(i,q)printf("%d\n",ans[i]);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 120320
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (c<'0' || c>'9')
	{
		if (c=='-')	f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9')
	{
		sum=sum*10+c-'0';
		c=getchar();
	}
	return sum*f;
}
const int MAXN=200010;
int a[MAXN];
ll s[MAXN]; 
map <ll,int> num;
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	for (int i=1;i<=n;i++)
		num[s[i]]++;
	ll ans=num[0];
	ll tmp=0;
	for (int i=1;i<=n;i++)
	{
		tmp+=a[i];
		num[s[i]]--;
		ans+=num[tmp];
	}
	cout<<ans;
	return 0;
}


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

int main() {
   ll x;
   cin >> x;
   ll y = 100;
   int i = 0;
   while(1) {
      y *= 1.01;
      i++;
      if(y >= x) {
         cout << i << endl;
         return 0;
      }
   }
   return 0;
}

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

typedef long long int   ll;
#define f(i,st,en)    for(int i=st;i<en;i++)
#define s(n)            scanf("%d",&n)
#define sc(n)           scanf("%c",&n)
#define sl(n)           scanf("%lld",&n)
#define sf(n)           scanf("%lf",&n)

using namespace std;

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

    if(a%b==0){
        cout<<0<<endl;
        return 0;
    }

    if(a>b)
        a=a%b;

    ll x,y;
    x=b-a;
    y=a;

    cout<<min(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 256
#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)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX_N = 100100;

// n要素で初期化
void init(int par[], int rank[], int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        rank[i] = 0;
    }
}

// 木の根を求める
int find(int par[], int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par,par[x]);
    }
}

// xとyの属する集合を併合
void unite(int par[], int rank[], int x, int y){
    x = find(par,x);
    y = find(par,y);
    if(x == y) return;

    if(rank[x] < rank[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int par[], int x, int y){
    return find(par,x) == find(par,y);
}

int main() {
    int n;
    cin >> n;
    vector<P> v; 
    vector<int> x[MAX_N];
    vector<int> y[MAX_N];

    int parx[MAX_N]; int rankx[MAX_N];
    int pary[MAX_N]; int ranky[MAX_N];
    init(parx,rankx,MAX_N);
    init(pary,ranky,MAX_N);

    rep(i,n){
        int x_, y_;
        cin >> x_ >> y_;
        x[x_].push_back(y_);
        y[y_].push_back(x_);
        v.push_back(P(x_, y_));
    }

    sort(v.begin(),v.end());
    ll ans = 0;

    rep(i,n){
        if(x[v[i].first].size()>=2&&y[v[i].second].size()>=2){
            //ans += (x[v[i].first].size()-1)*(y[v[i].second].size()-1);
            rep(j,x[v[i].first].size()-1){
                unite(pary,ranky,x[v[i].first][j],x[v[i].first][j+1]);
            }
            rep(j,y[v[i].second].size()-1){
                unite(parx,rankx,y[v[i].second][j],y[v[i].second][j+1]);
            }
        }
    }

    ll countx[MAX_N] = {}; ll county[MAX_N] = {};

    rep(i,MAX_N){
        countx[find(parx,i)]++;
        county[find(pary,i)]++;
    }
    /*
    rep(i,15){
        cout << find(parx,i) << ' ';
    }
    cout << endl;
    rep(i,15){
        cout << find(pary,i) << ' ';
    }
    cout << endl;
    */

    int flag[MAX_N] = {};

    rep(i,n){
        if(countx[find(parx,v[i].first)]>=2&&county[find(pary,v[i].second)]>=2){
            ans--;
            if(flag[find(parx,v[i].first)]==0){
                flag[find(parx,v[i].first)] = 1;
                ans += countx[find(parx,v[i].first)] * county[find(pary,v[i].second)];
                //cout << countx[find(parx,v[i].first)]*county[find(pary,v[i].second)] << endl;
            }
        }
    }

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


Measured memory_bytes: 12404
from collections import Counter

N = int(input())
A = list(map(int,input().split()))

l = []
r = []
for i,j in enumerate(A):
    l.append(i+j)
    r.append(i-j)

num_l = Counter(l)
num_r = Counter(r)

ans = 0
for k, v in num_l.items():
    ans += num_r[k]*v
print(ans)

Measured memory_bytes: 63268
import java.util.Scanner;

public class Main {
    static final int MAX = 2000000;
    static int       p   = 0;
    static int[]     h   = new int[MAX + 1];;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            String order = sc.next();
            if (order.startsWith("i")) {
                insert(sc.nextInt());

            } else if (order.startsWith("ex")) {
                System.out.println(heapExtractMax());

            } else {
                break;
            }
        }
    }
    // static void print() {
    // for (int i = 1; i <= p; i++) {
    // U.print(" " + h[i]);
    // }
    // U.println();
    // }

    static void insert(int key) {
        p++;
        h[p] = Integer.MIN_VALUE;
        heapIncreaseKey(p, key);
    }

    static void heapIncreaseKey(int i, int key) {
        if (key < h[i]) {
            // error
        }
        h[i] = key;
        while (i > 1 && h[i / 2] < h[i]) {
            int temp = h[i];
            h[i] = h[i / 2];
            h[i / 2] = temp;
            i = i / 2;
        }
    }

    static int heapExtractMax() {
        if (p < 1) {
            // error
        }
        int max = h[1];
        h[1] = h[p];
        p--;
        maxHeapify(h, 1); // root以外の節点はヒープ化済み
        return max;
    }

    static int l(int i) {
        return 2 * i;
    }

    static int r(int i) {
        return 2 * i + 1;
    }

    static void maxHeapify(int[] h, int idx) {
        int n = p;
        int l = l(idx);
        int r = r(idx);
        // 左の子、自分、右の子で値が最大のノードを選ぶ
        int maxNodeIdx = 0;
        if (l <= n && h[l] > h[idx]) {
            maxNodeIdx = l;
        } else {
            maxNodeIdx = idx;
        }
        if (r <= n && h[r] > h[maxNodeIdx]) {
            maxNodeIdx = r;
        }
        // 子の方が値が大きい場合
        if (maxNodeIdx != idx) {
            int temp = h[idx];
            h[idx] = h[maxNodeIdx];
            h[maxNodeIdx] = temp;
            maxHeapify(h, maxNodeIdx);
        }
    }
}



Measured memory_bytes: 555308
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)

string s, t;
int ss[26], tt[26];
int main()
{
	cin >> s >> t;
	REP(i, 0, s.size()) {
		ss[s[i] - 'a']++;
	}
	REP(i, 0, t.size()) {
		tt[t[i] - 'a']++;
	}

	string ns = "", nt = "";
	REP(i, 0, 26) {
		while (ss[i] > 0) {
			ns += ('a' + i);
			ss[i]--;
		}
	}
	RREP(i, 0, 26) {
		while (tt[i] > 0) {
			nt += ('a' + i);
			tt[i]--;
		}
	}
  
	if (ns < nt) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n,x = inm()
l = inl()
d = 0
cnt = 1
for i in range(n):
    d += l[i]
    if d <= x:
        cnt += 1
print(cnt)


Measured memory_bytes: 3572
class abc_159:
    
    def __init__(self):
        pass
    
    def A(self):
        NM=list(map(int,input().split()))
        print(int((NM[0]*(NM[0]-1))/2 + (NM[1]*(NM[1]-1))/2))
    
    def B(self):
        S=input()
        if S==S[::-1] and S[:int((len(S)-1)/2)]==S[:int((len(S)-1)/2):-1] and S[int((len(S)+3)/2)-1:len(S)]==S[int((len(S)+3)/2)-1:len(S)+1][::-1]:print("Yes")
        else:print("No")
        
            
    
    def C(self):
        pass
        
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_159()
    obj.B()
    

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	int N;
	String S;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		S=sc.next();
		StringBuilder sx=new StringBuilder(S);
		
		int t=0;
		while(t<sx.length()){
			if(sx.charAt(t)=='('){
				for(int j=t;j<sx.length();j++){
					if(sx.charAt(j)==')'){
						sx.delete(j,j+1);
						sx.delete(t, t+1);
						t--;
						break;
						
					}
				}
			}
			t++;
		}
		
		int s=sx.length()-1;
		while(s>0){
			if(sx.charAt(s)==')'){
				for(int j=s-1;j>=0;j--){
					if(sx.charAt(s)=='('){
						sx.delete(s,s+1);
						sx.delete(j, j+1);
						s--;
						break;
					}
				}
			}
			s--;
		}
		
		int cnt_a=0;
		int cnt_b=0;
		
		for(int i=0;i<sx.length();i++){
			if(sx.charAt(i)=='(')cnt_a++;
			else cnt_b++;
		}
		
		String ans="";
		for(int i=0;i<cnt_b;i++){
			ans+='(';
		}
		ans+=S;
		
		for(int i=0;i<cnt_a;i++){
			ans+=')';
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include<stdio.h>
int main(void){

 int floor[4][3][10],N,b,f,r,v,i,j,k;

 for(i=0;i<4;i++){
 for(j=0;j<3;j++){
 for(k=0;k<10;k++){
floor[i][j][k]=0;
	}
	}
	}
	
scanf("%d",&N);

	for(i=0;i<N;i++){
scanf("%d%d%d%d",&b,&f,&r,&v);
floor[b-1][f-1][r-1]=floor[b-1][f-1][r-1]+v;
		}

 for(i=0;i<4;i++){
 for(j=0;j<3;j++){
 for(k=0;k<10;k++){
printf(" %d",floor[i][j][k]);
	}
	printf("\n");
	}
	if(i!=3){
	printf("####################\n");
	}
	}


return 0;
	}

Measured memory_bytes: 612
import std.stdio;
import std.c.stdio;
import std.typecons;
import std.algorithm;
import std.container;

int x,y;
int[] cost;
int[][Tuple!(int,int)] dists;

int dijkstra(Tuple!(int,int) s, Tuple!(int,int) g){
	int[]* p = s in dists;
	if(p){
		return (*p)[g[0]+x*g[1]];
	}
	BinaryHeap!(Array!(Tuple!(int,Tuple!(int,int))), "a[0] > b[0]") que;
	que.insert(tuple(0, s));
	int[] dist = new int[](cost.length);
	dist[] = int.max;
	while(!que.empty()){
		Tuple!(int,Tuple!(int,int)) top = que.front();
		que.removeFront();
		if(cost[top[1][0]+x*top[1][1]] < int.max && dist[top[1][0]+x*top[1][1]] > top[0]){
			dist[top[1][0]+x*top[1][1]] = top[0];
			foreach(i; -1..2){
				foreach(j; -1..2){
					if((!i||!j) && i+top[1][0]>=0 && i+top[1][0]<x && j+top[1][1]>=0 && j+top[1][1]<y){
						que.insert(tuple(cost[top[1][0]+x*top[1][1]] + top[0], tuple(i+top[1][0], j+top[1][1])));
					}
				}
			}
		}
		
	}
	dists[s] = dist;
	return dist[g[0]+x*g[1]];
}
int main(){
	scanf("%d %d\n", &y, &x);
	cost = new int[](x*y);
	cost[] = 1;
	Tuple!(int, int)[] m;
	Tuple!(int, int) s, g;
	foreach(i; 0..x){
		string a = readln;
		foreach(j; 0..y){
			if(a[j]=='S') s = tuple(i, j);
			else if(a[j]=='G') g = tuple(i, j);
			else if(a[j]=='M') m ~= tuple(i, j);
			else if(a[j]=='#'){
				foreach(k; -2..3){
					foreach(l; -2..3){
						if(i+k>=0 && i+k<x && j+l>=0 && j+l<y){
							cost[i+k+x*(j+l)] = max(cost[i+k+x*(j+l)], (k==2||k==-2||l==2||l==-2 ? 2 : 3));
						}
					}
				}
				cost[i+x*j] = int.max;
			}
		}
	}
	int ans = int.max;
	int[] pe;
	foreach(i; 0..m.length) pe ~= cast(int)(i);
	do{
		int route = dijkstra(s, m[pe[0]]) + dijkstra(m[pe[pe.length-1]], g);
		for(int i=1; ans>route && i<pe.length; i++){
			route += dijkstra(m[pe[i-1]], m[pe[i]]);
		}
		ans = min(ans, route);
	}while(nextPermutation(pe));
	ans.writeln;
	return 0;
}

Measured memory_bytes: 2800
#include <stdio.h>
int main(void){
    char s[10],t[10],u[10];
    scanf("%s %s %s",s,t,u);
    int a,b;
    for(int i=0;s[i]!='\0';i++){
        a=i;
    }
    for(int i=0;t[i]!='\0';i++){
        b=i;
    }
    if(s[a]==t[0]&&t[b]==u[0]) printf("YES");
    else printf("NO");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(x) for x in input().split()]
B = [0]*N
numofminus = 0
minabs = 10**9  # 最も絶対値が小さいもの
for i in range(N):
    B[i] = abs(A[i])
    if A[i] < 0:
        numofminus += 1
    if abs(A[i]) < minabs:
        minabs = abs(A[i])

if numofminus % 2 == 1:
    ans = sum(B) - 2 * minabs
else:
    ans = sum(B)
print(ans)


Measured memory_bytes: 14260
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;

main(){
	int n,m,i,j;
	cin >> n;
	vector<int> dp(400, -1);
	dp[0] = 0;
	while(n--){
		int s,d,p;
		cin >>s>>d>>p;
		for(i=0;i<394;i++){
			if(dp[i]==-1) continue;
			for(j=s;j<=d&&i+j<=393;j++) dp[i+j] = max(dp[i+j], dp[i] + p);
		}
	}
	cin >> n;
	vector<int> ans;
	while(n--){
		cin >> m;
		if(dp[m] == -1){
			cout << "-1" << endl;
			return 0;
		}
		ans.push_back(dp[m]);
	}
	for(i=0;i<ans.size();i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 1224
nums=[int(input()) for i in range(5)]

key=[]
sums=0

for num in nums:
  if num%10==0:
    key.append(10)
  else:
    key.append(num%10)

flag=True

for i in range(len(nums)):
  if nums[i]==nums[key.index(min(key))] and flag:
    flag=False
    continue
  sums+=((10-key[i])+nums[i])
  
print(sums+nums[key.index(min(key))])

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		//Scanner sc = new Scanner(new File("Diagonal.txt"));

		char[][] a = new char[3][3];
		for (int i = 0; i < 3; i++) {
			String s = sc.nextLine();
			int j = 0;
			for (char c : s.toCharArray()) {
				a[i][j] = c;
				j++;
			}
		}

		System.out.println(""+a[0][0] + a[1][1]+a[2][2]);
	}
}

Measured memory_bytes: 20820
n,q=map(int,input().split())
Q=[]
sum=0
for i in range(n):
    tmp=input().split()
    tmp[1]=int(tmp[1])
    Q.append(tmp[0])
    Q.append(tmp[1])

loop=0
while loop==0:
    for i in range(len(Q)//2):
        tmp=[Q[0],Q[1]]
        if tmp[1]>q:
            sum+=q
            Q.append(tmp[0])
            Q.append(tmp[1]-q)
        else:
            sum+=tmp[1]
            print(tmp[0],sum)
        Q.pop(0)
        Q.pop(0)
    if len(Q)==0:
        break



Measured memory_bytes: 9480
S = input()
Q = int(input())
reverse = False
front = ""
end = S

for _ in range(Q):
    I = input().split()
    if I[0] == "1":
        reverse = not reverse
    else:
        if (I[1] == "1") ^ reverse:
            front =front + I[2]
        else:
            end = end + I[2]


if reverse:
    print(end[::-1]+front)
    #print("".join(list(reversed(end)))+front)
else:
    print(front[::-1]+end)
    #print("".join(list(reversed(front)))+end)


Measured memory_bytes: 4340
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 7
typedef pair<int,int> P;
 
int m, cnt;
vector<P> v;
 
void check(int num, int pos)
{
    if (num == 0) {
	cnt++;
	return;
    } else if(num < 0 || m <= pos) {
	return;
    }
 
    for (int i = 0; i < v[pos].second; i++) {
	check(num-v[pos].first*(i+1), pos+1);
    }
    check(num, pos+1);
}
 
int main()
{
    int g, num;
    while (cin >> m, m) {
	v.clear(); v.resize(m);
	for (int i = 0; i < m; i++) {
	    cin >> v[i].first >> v[i].second;
	}
 
	cin >> g;
	for (int i = 0; i < g; i++) {
	    cin >> num;
	    cnt = 0; check(num, 0);
	    cout << cnt << endl;
	}
    }
    return 0;
}

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

int main(){
  int N, D;
  cin >> N >> D;

  vector<vector<int>> X(N, vector<int>(D));

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

  int sum = 0;
  double dist = 0.0;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    dist = 0;
    for(int j = i + 1; j < N; j++){
      sum = 0;
      for(int k = 0; k < D; k++){
        sum += pow((X[i][k]-X[j][k]), 2);
      }
      dist = (double)sqrt(sum);
      if((double)(dist - (int)dist) == 0){
        cnt++;
      }
    }
  }

  cout << cnt << endl;
 
  return 0;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

s = input()

sset = set(s)

for c in sset:
  if s.count(c) != 2:
    print('No')
    exit()

print('Yes')



Measured memory_bytes: 38640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int n;
    cin >> n;
    int a = 15 * 800;
    cout << n * 800 - 200 * (n / 15) << "\n";
}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

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

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    for(int i = 0; i < n; ++i) cin >> m[i];
    sort(m.begin(), m.end());
    for(auto hoge : m) x -= hoge;
    int count = n;
    while(x >= m[0]) {
        for(auto hoge : m) {
            if(x >= hoge) {
                x -= hoge;
                count++;
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

#define F first
#define S second

typedef pair<li, li> PI;
map<PI, li> cnt;

int main(void)
{
	li n;
	cin >> n;
	repp(i, 1, n + 1) {
		auto s = to_string(i);
		PI p = {s.front() - '0', s.back() - '0'};
		cnt[p]++;
	}
	li res = 0;
	li res1 = 0;

	for (auto& kv : cnt) {
		if (kv.F.F == kv.F.S) {
			res1 += kv.S * kv.S;
		} else {
			res += kv.S * cnt[ {kv.F.S, kv.F.F}];
		}
	}
	cout << res + res1 << endl;


	return 0;
}

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

namespace ConsoleApp1 {
    class Program {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int ans = 1;
            for(int i = 0; i < n - 1; ++i)
            {
                if (s[i] != s[i + 1]) ++ans;
            }
            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


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

    int ans = 1;
    if (s=="RRR") ans = 3;
    else if (s=="RRS" || s=="SRR"){
        ans = 2;
    }
    else if (s=="SSS") ans = 0;
    
    pr(ans);
    return 0;
}


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

int n;
char s[300000][10];
long long int res = 0;

int main(){
  cin >> n;
  vector<string> v(n);
  rep(i, n){
    cin >> s[i];
    sort(s[i], s[i] + 10);
    v[i] = s[i];
  }
  sort(v.begin(), v.end());
  v.push_back("atcoder");
  rep(i, n + 1) cerr << v.at(i) << endl;
  
  long long int cnt = 1;
  rep(i, n){
    if(v.at(i) == v.at(i + 1)){
      cnt++;
    }else if(cnt > 1){
      res += (cnt * (cnt - 1)) / 2;
      cnt = 1;
    }
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 8688
import java.util.*;

public class Main {
	 
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int n=cin.nextInt();
		int taro=0,hanako=0;
		
		for(int i=0;i<n;i++) {
			String Ts=cin.next(),Hs=cin.next();
			int j=Ts.compareTo(Hs);
			if(j>0)taro+=3;
			else if(j<0)hanako+=3;
			else {
				taro++;hanako++;
			}
		}
		System.out.println(taro+" "+hanako);
	}
	
	
}


Measured memory_bytes: 29676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string c;
    cin >> c;
    if(c != "a" && c != "e" && c != "i" && c != "o" && c != "u" ){
        cout << "consonant" << endl;
    }
    else{
        cout << "vowel" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;
int a[maxn];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    cout << (a[n / 2] - a[n / 2 - 1]) << endl;
    return 0;
}


Measured memory_bytes: 640
o=input()
e=input()
n=len(e)
a=""
if len(o)-len(e)==0:
    for i in range(n):
        a=a+o[i]+e[i]
    print(a)
else:
    for i in range(n):
        a=a+o[i]+e[i]
    a=a+o[n]
    print(a)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N);
    rep (i,N){
        cin >> A[i];
    }
    rep (i,N){
        cin >> B[i];
    }
    ll ans=0;
    bool c=true;
    while(c){
        c=false;
        rep (i,N){
            int a=B[(i-1+N)%N]+B[(i+1)%N];
            if (B[i]-A[i]>=a){
                int b=(B[i]-A[i])/a;
                B[i]-=a*b;
                ans+=b;
                c=true;
            }
        }
    }
    if (A==B){
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3328
N=int(input())


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
ans=num2alpha(N)

print(ans.lower())

Measured memory_bytes: 9176
from fractions import gcd
from functools import reduce

MOD = 1000000007

def lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = [int(_) for _ in input().split()]
LCM = reduce(lcm, a)

arr = [LCM // _ for _ in a]
print(sum(arr) % MOD)

Measured memory_bytes: 264700
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/

int main() {
    int n;
    sci(n);
    vi height(n);
    rep(i, 0, n - 1) {
        sci(height[i]);
    }
    vll dp(n);
    dp[0] = 0;
    dp[1] = abs(height[1] - height[0]);
    rep(i,2,n-1){
        dp[i] = (dp[i-2] + abs(height[i]-height[i-2]) < (dp[i-1] + abs(height[i]-height[i-1]))) ? (dp[i-2] + abs(height[i]-height[i-2])) : (dp[i-1] + abs(height[i]-height[i-1]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4584
H, W, K = map(int, input().split())
C = []

for i in range(H):
    c = input()
    C.append(c)

ans = 0

for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for k in range(H):
            for l in range(W):
                if ((i >> k) & 1) and ((j >> l) & 1) and C[k][l] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)
        




Measured memory_bytes: 68720
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> X(m);
  for (int i = 0; i < m; i++) cin >> X[i];
  sort(X.begin(), X.end());

  vector<int> Y(m - 1);
  for (int i = 0; i < m - 1; i++) Y[i] = X[i + 1] - X[i];

  sort(Y.begin(), Y.end());

  if (n >= m) {
    cout << 0 << endl;
  } else {
    int ans = 0;
    for (int i = 0; i < m - 1 - (n - 1); i++) {
      ans += Y[i];
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b>>c;
  if(a==5&&b==5&&c==7){
  cout<<"YES"<<endl;}
  else if(a==5&&b==7&&c==5){
  cout<<"YES"<<endl;}
  else if(a==7&&b==5&&c==5){
  cout<<"YES"<<endl;}
  else{
  cout<<"NO"<<endl;}
}

Measured memory_bytes: 3636
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)

ans = 0
k = 1
N.times do |i|
  if A[i] != k
    ans += 1
  else
    k += 1
  end
end
if ans == N
  puts -1
else
  puts ans
end


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

int main(){
  int64_t n,a,b;
  cin >> n >> a >> b;
  if((a-b)%2==0){
    cout << abs(a-b)/2 << endl;
  }else{
      cout << min((a+b-1)/2,(n-a+n-b+1)/2) << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#B
S = input()
str_1 = int(S[:2])
str_2 = int(S[2:])

def judge_month(i):
    if i >= 1 and i <= 12:
        judge = True
    else:
        judge = False
    return judge
judge_1 = judge_month(str_1)
judge_2 = judge_month(str_2)
if judge_1 and judge_2:
    print("AMBIGUOUS")
elif judge_1:
    print("MMYY")
elif judge_2:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n, W;
	cin >> n >> W;
	
	vector<ll> w(n), v(n);
	for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
	
	vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j <= W; j++) {
			if(j - w[i] >= 0) dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			else dp[i + 1][j] = dp[i][j];
		}
	}
	
	cout << dp[n][W] << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 83072
#include <cstdio>
#include <cmath>

const int price[7][7] = {
  {-1,300,500,600,700,1350,1650},
  {-1,-1,350,450,600,1150,1500},
  {-1,-1,-1,250,400,1000,1350},
  {-1,-1,-1,-1,250,850,1300},
  {-1,-1,-1,-1,-1,600,1150},
  {-1,-1,-1,-1,-1,-1,500}
};

const int dist[7][7] = {
  {-1,6,13,18,23,43,58},
  {-1,-1,7,12,17,37,52},
  {-1,-1,-1,5,10,30,45},
  {-1,-1,-1,-1,5,25,40},
  {-1,-1,-1,-1,-1,20,35},
  {-1,-1,-1,-1,-1,-1,15}
};

const int start = 17*60 + 30 , end = 19*60 + 30;

int main(){
  int sIC,sh,sm,tIC,th,tm;

  while(scanf("%d" ,&sIC) ,sIC){
    scanf("%d%d" ,&sh ,&sm);
    scanf("%d%d%d" ,&tIC ,&th ,&tm);

    sIC--; tIC--;
    bool ok1 = false,ok2 = false;
    int ssum = sh*60 + sm , tsum = th*60 + tm;

    if((start <= ssum && ssum <= end) ||
	(start <= tsum && tsum <= end)) ok1 = true;

    if(dist[sIC][tIC] <= 40) ok2 = true;
 
    int ans = price[sIC][tIC];
    if(ok1 && ok2){
      ans = (ans / 50 + 1) / 2;
      ans *= 50;
    }
    
    printf("%d\n" ,ans);
  }

  return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int N;
  cin >> N;
  int l[N],r[N];
  rep(i,N) cin >> l[i] >> r[i];
  int ans = 0;
  rep(i,N){
    ans += r[i]-l[i]+1;
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

ll c[100005] = {};
ll d[100005] = {};
ll s[100005] = {};

void solve()
{
    reps(i, 2, 100002)
    {
        c[i] = 1;
    }
    reps(i, 2, 100002)
    {
        if (c[i] == 1)
        {
            ll j = 2 * i;
            while (j < 100002)
            {
                c[j] = 0;
                j += i;
            }
        }
    }
    rep(i, 100002)
    {
        d[i] = c[i] && c[(i+1)/2];
    }
    reps(i, 1, 100002)
    {
        s[i] = s[i-1] + d[i];
    }
    IN(q);
    rep(i, q)
    {
        IN(l, r);
        cout << s[r] - s[l-1] << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 2944
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ar = new ArrayList<Integer>();
    int N = sc.nextInt();
    int T = sc.nextInt();
    int A = sc.nextInt();
    int H[] = new int[N];
    for(int i=0;i<N;i++){
      H[i] = sc.nextInt();
    }
    if(N == 1){
      System.out.println(1);
    }else{
      double min = Math.abs((T - H[0]*0.006) - A);
      for(int i=1;i<N;i++){
        if(Math.abs((T - H[i]*0.006) - A)<min){
          min = Math.abs((T - H[i]*0.006) - A);
          ar.add(i);
        }
      }
    }
    if(ar.size() == 0){
      System.out.println(1);
    }else{
      System.out.println(ar.get(ar.size()-1)+1);
    }

  }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int n,s,e,m,l,dp[102][1<<16];
main(){
  while(cin>>n,n){
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    r(i,n){
      cin>>m>>l;
      int range=0;
      r(j,m){
        cin>>s>>e;
        s-=6;
        e-=6;
        for(int k=s;k<e;k++)range|=(1<<k);
      }
      r(j,1<<16){
        if(dp[i][j]==-1)continue;
        if(j&range)continue;
        else dp[i+1][range|j]=max(dp[i+1][range|j],dp[i][j]+l);
      }
      r(j,1<<16)dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
    }
    int ans=0;
    r(i,1<<16)ans=max(ans,dp[n][i]);
    cout<<ans<<endl;
  }
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  ll N;
  vector<ll> A, B;

  void init() {
    cin >> N;
    A.resize(N+1);
    B.resize(N+1);
    repc(i, N) {
      cin >> A[i];
    }
  }

  void solve() {
    if(N == 0) {
      cout << (A[0] == 1 ? 1 : -1) << "\n";
      return;
    }
    ll sum_a = 0;
    REPC(i, 1, N) {
      sum_a += A[i];
    }
    B[0] = 1 - A[0];
    REPC(i, 1, N) {
      sum_a -= A[i];
      B[i] = min(B[i-1]*2-A[i], sum_a);
      if(B[i] < 0) {
        cout << -1 << "\n";
        return;
      }
    }
    ll ans = 0;
    repc(i, N) {
      ans += A[i] + B[i];
    }
    cout << ans << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 4784