akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;

    if(abs(e-a) <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10**9
 
def dfs(cur, a, b, c):
  if cur == N:
    return abs(A-a) + abs(B-b) + abs(C-c) -30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a,          b,          c       )
  ret1 = dfs(cur + 1, a + l[cur], b,          c       ) + 10
  ret2 = dfs(cur + 1, a,          b + l[cur], c       ) + 10
  ret3 = dfs(cur + 1, a,          b,          c+l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
 
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<ll> cnt(26,1);
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        cnt[s[i]-'a']++;
    }
    ll ans=1;
    for(auto &I:cnt){ans*=I; ans%=MOD;}
    ans--;
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>


int max1 = 1e9;

using namespace std;

int main(int argc, const char * argv[]) {

    std::ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(NULL);
	int tmp;
    for(int i =1;i<=5;i++){
		cin >> tmp;
		if ( tmp == 0){
			cout << i << endl;
		}
	}


	return 0;
}



Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18



int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> ba(M);
    rep(i,M){
        cin >> ba[i].second >> ba[i].first;
        ba[i].second--; ba[i].first--;
    }
    sort(ba.begin(),ba.end());

    int ans = 1;
    int bridge = ba[0].first - 1;

    repr(i,1,M){
        if(ba[i].second > bridge){
            bridge = ba[i].first - 1;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

void put(int,int,int,int);
void tansaku(int,int);

const int nashi=-1;
const int tootta=10;

int field[102][102];
int main(int argc,char* argv[]){
	while(1){
		int x_size,y_size;
		int sx,sy;
		int gx,gy;
		int n;
		scanf("%d %d",&x_size,&y_size);
		if(x_size==0)
			return 0;

		scanf("%d %d",&sx,&sy);
		scanf("%d %d",&gx,&gy);
		scanf("%d",&n);

		for(int i=0;i<y_size+2;i++)
			for(int j=0;j<x_size+2;j++)
				field[i][j]=nashi;

		for(int i=0;i<n;i++){
			int c,d,x,y;
			scanf("%d %d %d %d",&c,&d,&x,&y);
			put(c,d,x,y);
		}

		tansaku(sx,sy);
		if(field[gy][gx]==tootta)
			printf("OK\n");
		else
			printf("NG\n");
	}
}

void put(int c,int d,int x,int y){
	const int size[2][2]={{4,2},{2,4}};
	for(int i=0;i<size[d][1];i++){
		for(int j=0;j<size[d][0];j++){
			field[y+i][x+j]=c;
		}
	}
}

void tansaku(int sx,int sy){
	int c=field[sy][sx];
	field[sy][sx]=tootta;
	if(field[sy][sx-1]==c)
		tansaku(sx-1,sy);
	if(field[sy][sx+1]==c)
		tansaku(sx+1,sy);
	if(field[sy-1][sx]==c)
		tansaku(sx,sy-1);
	if(field[sy+1][sx]==c)
		tansaku(sx,sy+1);
}

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

using namespace std;

int main()
{
    int N, K;
    cin>>N>>K;
    vector<int> a(N);
    for (int &t: a)
        cin>>t;
    vector<long long> T(K+1);
    T[0] = 1;
    for (int i=0; i<N; i++)
    {
        vector<long long> P = T;
        T = vector<long long>(K+1);
        long long t = 0;
        for (int j=0; j<=K; j++)
        {
            t += P[j];
            if (j-a[i]-1 >= 0)
                t -= P[j-a[i]-1];
            t = (t+1000000007)%1000000007;
            T[j] = t;
        }
    }
    cout<<T[K]<<endl;
}


Measured memory_bytes: 2676
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define mod 1000000007
#define fst first
#define pb push_back
int main()
{
   long long X;
   cin >> X;
   long long target = 100;
   long long count = 0;
   while(target < X){
       target += target / 100;
       count++;
   }
   cout << count << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define FIND(c, e) ((c).find(e) != (c).end())
#define NFIND(c, e) ((c).find(e) == (c).end())
#define ALL(t) (t).begin(),  (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
template<class T> T max(T a,T b,T c){return max(max(a,b),c);}
template<class T> T min(T a,T b,T c){return min(min(a,b),c);}
const int N = 1e6 + 42;

void __answer()
{
   int n, x;
   cin >> n;
   set<int> a;
   for(int i = 0; i < n; i++) {
        cin >> x;
        a.insert(x);
   }
   cout << a.size() << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cout << setprecision(11) << fixed;
    #ifdef LOCAL
        freopen("TEST.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, Q, B, C, f,s;
    int64_t sum = 0;
    map<int,int> count;
    cin >> N;
    vector<int> Ai(N);

    for (int i=0; i<N; i++){
        cin >> s;
        Ai.at(i) = s;
        sum += s;
        if (count.count(s)){
            count.at(s) += 1;
        }else{
            count[s] = 1;
        }
    }
    cin >> Q;
    for (int j=0; j<Q; j++){
        cin >> B >> C;
        f = count[B];
        if (f == 0){
            cout << sum << endl;
            continue;
        }else{
            sum = sum + (C-B)*f;
            count.erase(B);
            if (count.count(C)){
                count.at(C) += f;
            }else{
                count[C] = f;
            }
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 6964
N=int(input())
A=list(map(int,input().split()))
kari=[0]*((10**6)+1)
A.sort()
hako=[]
for i in range(N):
    kari[A[i]]+=1

for i in range(N):
    if kari[A[i]]==1:
        hako.append(A[i])
kari=[0]*((10**6)+1)
aru=A.copy()
count=0
aru=list(set(aru))
#print(hako)
for i in aru:
    for j in range(i*2,10**6+1,i):
        kari[j]+=1
for i in hako:
    if kari[i]==0:
        count+=1
print(count)

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

//vector<int>のサイズnと要素の入力
vector<int> input_vector()
{
    int n;
    scanf("%d", &n);
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &vec[i]);
    }
    return vec;
}

//第１引数がvectorで第２引数がサイズ
void print_vector(vector<int> &vec, int N)
{
    for (int i = 0; i < N; i++)
    {
        if (i != N - 1)
        {
            printf("%d ", vec[i]);
        }
        else
        {
            printf("%d\n", vec[i]);
        }
    }
}

//bubble_sort カウント数あり
int bubble_sort(vector<int> &A, int n)
{
    bool flag = 1;
    int m;         //変数交換用
    int i = 1;     //未ソート部分先頭アドレス
    int count = 0; //反転数
    for (i; flag; i++)
    {
        flag = 0;
        for (int j = n - 1; j >= i; j--)
        {
            if (A[j - 1] > A[j])
            {
                m = A[j];
                A[j] = A[j - 1];
                A[j - 1] = m;
                flag = 1;
                count++;
            }
        }
    }
    return count;
}

int main(){
    vector<int> A=input_vector();
    int n=A.size();
    int count=bubble_sort(A,n);
    print_vector(A,n);
    printf("%d\n", count);
}






Measured memory_bytes: 3220
#include<stdio.h>
#define N 1000

int main(void){
  int i,n,j;
  int hi[N];
  int num[N];
  double w[N],h[N];
  char hoge;

  for(i=0;scanf("%d%c%lf%c%lf",&num[i],&hoge,&w[i],&hoge,&h[i])==5;i++){}
  n=i;
  for(i=0,j=0;i<n;i++)
    if(w[i]/h[i]/h[i]>=25.0){
      hi[j]=num[i];
      j++;
    }
  for(i=0;i<j;i++)
    printf("%d\n",hi[i]);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int K,X,i;
  cin>>K>>X;
  for(i=0;i<2*K-1;i++){
  cout<<X-K+i+1<<" ";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int t[100001]={};
int main(){

	int n;
	cin>>n;
	rep(i,n){
		int a;
		cin>>a;
		t[a]++;
	}
	int f=0;
	ll total=1;
	rep(i,n){
		if(n%2==0){
			if(i%2>0){
				total*=2;
				total%=1000000007;
				if(t[i]!=2)f=1;
			}
		}
		if(n%2>0){
			if(i%2==0){
				if(i>0){
					total*=2;
					total%=1000000007;
					if(t[i]!=2)f=1;
				}
			}
		}
	}
	if(f==1)cout<<"0"<<endl;
	else cout<<total<<endl;
	return 0;

}



Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
    char c[10];
    scanf("%s",c);

    if(strcmp(c,"Sunny")==0)
        printf("Cloudy");
    else if(strcmp(c,"Cloudy")==0)
        printf("Rainy");
    else
        printf("Sunny");
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N;
	int SM, LM;
	vector<int> A,B;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
		B.push_back(tmp);
	}

	sort(A.begin(), A.end());
	SM = A.at(N / 2 );
	LM = A.at(N / 2 - 1);

	/*cout << "sm" << SM <<  "  "<< N / 2  << endl;
	cout << "lm" << LM << "  " << N / 2 - 1 << endl;*/

	for (int i = 0; i < N; i++)
	{
		if (i == N - 1) {
			if (SM > B.at(i)) {
				cout << SM << endl;
			}
			else {
				cout << LM << endl;
			}
		}
		else {
			if (SM > B.at(i)) {
				cout << SM << " ";
			}
			else {
				cout << LM << " ";
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3948
# 初期入力
N =int(input())
A = list(map(int, input().split()))

#
from collections import Counter
A_counter = Counter(A)
A_max = max(A_counter.values())
if 1 < A_max: # ２以上なら同じものが複数あるとういうこと
    print("NO")
else:
    print("YES")

Measured memory_bytes: 33008
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  double T, A; cin >> T >> A;
  double vmin = 1e9;
  int index = -1;
  for (int i = 0; i < N; ++i) {
    double H; cin >> H;
    double t = T - H * 0.006;
    double d = abs(A - t);
    if (vmin > d) {
      index = i + 1;
      vmin = d;
    }
  }
  cout << index << endl;
}


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

namespace AtCoder_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            float t = int.Parse(strs[0]);
            float x = int.Parse(strs[1]);

            Console.WriteLine((t / x).ToString());
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=998244353;
const double pi=3.1415926535897932,eps=1e-6;
int n,ans;
vector<pii > fact;string t,x,ss,rev;
int main()
{
    fastio;cin>>n>>x;
    rep(i,1,2*n){
        if(2*n%i!=0||n%i==0) continue;
        int cur=0,len=i/2;
        rap(j,0,fact.size()){
            if(i%fact[j].fi==0) cur=(cur-fact[j].se+mod)%mod;
        }
        int w=1;
        per(j,len,1){
            if(x[j-1]=='1') cur=(cur+w)%mod;
            //cout<<i<<" "<<cur<<'\n';
            w=(w*2)%mod;
        }
        ss=x.substr(0,len);rev=ss;
        rap(i,0,rev.size()) rev[i]=(rev[i]=='0'?'1':'0');
        t="";rep(j,1,2*n/i) {
            if(j&1) t+=ss;
            else t+=rev;
        }
        if(t<=x) cur=(cur+1)%mod;
        fact.pb(mpr(i,cur));
    }
    rap(i,0,fact.size()) ans=(ans+(ll)fact[i].se*fact[i].fi%mod)%mod;
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define maxn 200005
#define mo 1000000007
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,x,y,ans=1;
int jc[maxn],inv[maxn],mi[maxn];
vector<int>G[maxn];
inline void Min(int &x,int y){x=x>y?y:x;}
int main()
{
    n=read(),x=read(),y=read();if(n==1){puts("1");return 0;}
    reg int i,c,w,j,sz,cnt;jc[0]=inv[0]=inv[1]=1;
    for(i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%mo;
    for(i=2;i<=n;++i)inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
    for(i=2;i<=n;++i)inv[i]=1ll*inv[i]*inv[i-1]%mo;
    memset(mi,63,sizeof mi);
    for(i=1;i<=n;++i)
    {
        c=read(),w=read();
        Min(mi[c],w);
        G[c].push_back(w);
    }reg int m=0,mm=2e9;
    for(i=1;i<=n;++i)if(mi[i]<mi[m])m=i;
    for(i=1;i<=n;++i)if(i!=m&&mi[i]<mm)mm=mi[i];
    reg int sum=0,sum1=1;
    for(i=1;i<=n;++i)
    {
        if(mi[i]+mi[m]>y)continue;
        cnt=0;sz=G[i].size();
        if(i!=m)
        {
            for(j=0;j<sz;++j)
                if(G[i][j]+mi[m]<=y||G[i][j]+mi[i]<=x)
                    ++cnt;
        }
        else
        {
            for(j=0;j<sz;++j)
                if(G[i][j]+mm<=y||G[i][j]+mi[i]<=x)
                    ++cnt;
        }
        sum+=cnt,sum1=1ll*sum1*inv[cnt]%mo;
    }sum=1ll*jc[sum]*sum1%mo;
    printf("%d\n",sum);
	return 0;
}


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define piii pair<int,pii>
#define pb push_back
#define mxn 200005

int ans(int n){
int to=0;
while(n){
    if(n%10==2)++to;
    n/=10;
}
return to;
}

int main(){
sp;
int n;
cin>>n;
cout<<ans(n);

return 0;}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  for (int i = 0; i < A; i++) {
    if (S[i] == '-') {
      cout << "No" << endl;
      return 0;
    }
  }
  if (S[A] != '-') {
    cout << "No" << endl;
    return 0;
  }
  for (int i = A + 1; i < A + B + 1; i++) {
    if (S[i] == '-') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, k;
    cin >> n >> k;
    set<int>st;
    while(k--){
        int d;
        cin >> d;
        while(d--){
            int x;
            cin >> x;
            st.insert(x);
        }
    }
    cout << n - st.size() << endl;
}


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

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;


inline void boost () {
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
}


bool comp(ll a, ll b){
	return a >= b;
}

void solve() {                   

	ll n, res, a[300500];

	cin >> n;
	n *= 3;
	for (int i = 1;i <= n;i ++) cin >> a[i];
	sort (a + 1, a + n + 1);
	reverse (a + 1, a + n + 1);
	n/=3;
	for (int i = 2;i <= 2 * n;i += 2) res += a[i];
	cout << res; 
 

}

int main() {    
 		boost();
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
const ll MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    ll cnt[30] = {};
    for (int i = 0; i < n; i++) {
        cnt[s[i] - 'a']++;
    }
    ll ans = 1;
    for (int i = 0; i < 30; i++) {
        ans = ans * (cnt[i] + 1) % MOD;
    }
    cout << (ans - 1 + MOD) % MOD << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
char a[100100];
int main()
{
    
    scanf("%s",a);
    ll num1=0,num2=0;
    for(int i=0;a[i]!='\0';i++)
    {
        if(a[i]=='1')
            num1++;
        if(a[i]=='0')
            num2++;
    }
    ll mi=min(num1,num2);
    printf("%lld\n",mi*2);
    return 0;
}


Measured memory_bytes: 384
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

maxNum = 0

for i in range(n):
    currNum = sum(l1[:i]) + sum(l2[i:]) + l1[i]
    if maxNum < currNum:
        maxNum = currNum

print(maxNum)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

    int a[n];
    int ans = 0;
    
    cin >> a[0];
    for (int i = 1; i < n; i++) {
        cin >> a[i];
        if (a[i] == a[i-1]) {
            ans++;
            a[i] = 0;
        }
    }

    cout << ans << endl;
}


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

struct team
{
  int ac, wa[10], pe, num;
  bool operator <(const team& t) const
  {
    if(ac != t.ac)
      return ac < t.ac;
    if(pe != t.pe)
      return pe > t.pe;
    return num > t.num;
  }
};

team teams[50];
int main()
{
loop:
  int T, P, R;
  for(int i = 0; i < 50; i++)
    teams[i] = team();
  for(int i = 0; i < 50; i++)
    teams[i].num = i + 1;
  cin >> T >> P >> R;
  if(!T)
    return 0;
  for(int i = 0; i < R; i++)
  {
    int t, p, time;
    string st;
    cin >> t >> p >> time >> st;
    t--; p--;
    if(teams[t].wa[p] == -1)
      continue;
    if(st == "WRONG")
      teams[t].wa[p]++;
    else
    {
      teams[t].ac++;
      teams[t].pe += teams[t].wa[p] * 1200 + time;
      teams[t].wa[p] = -1;
    }
  }
  sort(teams, teams + T);
  reverse(teams, teams + T);
  for(int i = 0; i < T; i++)
    cout << teams[i].num << " " << teams[i].ac << " " << teams[i].pe << endl;
  goto loop;
}

Measured memory_bytes: 1240
#include<stdio.h>

typedef struct {
  double x;
  double y;
} p;

double convex(p a, p b, p c, p d){ 
  return ((a.x-b.x)*(c.y-a.y)+(a.y-b.y)*(a.x-c.x))*((a.x-b.x)*(d.y-a.y)+(a.y-b.y)*(a.x-d.x));
}

int main(void){
  p a,b,c,d;
  
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
	      &a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y)!=EOF){
    
    if(convex(a,c,b,d)>0||convex(b,d,a,c)>0)
      puts("NO");
    else
      puts("YES");
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int L[]=new int[N];
		int z=0,max=0,plu=0;
		while(z<N){
			L[z]=stdIn.nextInt();
			plu+=L[z];
			if(L[z]>max)
				max=L[z];
			z++;
		}z=0;
		if(max<plu-max)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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

int main() {
  int n;
  cin >> n;
  string str;
  switch(n%10){
    case 3:
      str = "bon";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      str = "pon";
      break;
    default:
      str = "hon";
  }
  cout << str << endl;
  return 0;
}


Measured memory_bytes: 3600
a1 = gets.split.map(&:to_i)
a2 = gets.split.map(&:to_i)
a3 = gets.split.map(&:to_i)

a = [*a1, *a2, *a3]

n = gets.to_i
n.times do
  b = gets.to_i
  (0...a.size).to_a.each do |i|
    a[i] = 0 if a[i] == b
  end
end

bingo = false
bingo = true if a[0].zero? && a[1].zero? && a[2].zero?
bingo = true if a[3].zero? && a[4].zero? && a[5].zero?
bingo = true if a[6].zero? && a[7].zero? && a[8].zero?

bingo = true if a[0].zero? && a[3].zero? && a[6].zero?
bingo = true if a[1].zero? && a[4].zero? && a[7].zero?
bingo = true if a[2].zero? && a[5].zero? && a[8].zero?

bingo = true if a[0].zero? && a[4].zero? && a[8].zero?
bingo = true if a[2].zero? && a[4].zero? && a[6].zero?

puts bingo ? 'Yes' : 'No'


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;

    int m;
    int sum = 0;
    int mmax = 0;
    for (int i = 0; i < N; i++) {
        std::cin >> m;
        sum += m;
        mmax = std::max(mmax, m);
    }

    std::cout << ((mmax < (sum-mmax)) ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 384
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const ab = arg.slice(1, M + 1);
    
    let map = [...Array(N)].fill(0);
    let answer = "IMPOSSIBLE";
    
    for(let i=0; i<M; i++) {
        let temp = ab[i].split(" ").map(n=>parseInt(n));
        let from = temp[0];
        let to   = temp[1];
        
        if(from === 1) {
            if(map[to] === 1) {
                answer = "POSSIBLE";
                break;
            } else {
                map[to]++;
            }
        }
        
        if(to === N) {
            if(map[from] === 1) {
                answer = "POSSIBLE";
                break;
            } else {
                map[from]++;
            }
        }
    }
        
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 59908
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
void merge(vector<int>&A,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  vector<int>L(n1+1),R(n2+1);
  for(int i=0;i<n1;i++)L[i]=A[left+i];
  for(int i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1<<30;
  R[n2]=1<<30;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j])A[k]=L[i++];
    else A[k]=R[j++];
    cnt++;
  }
}
void mergeSort(vector<int>&A,int left,int right){
  if(1<right-left){
    int mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
int main(void){
  cin>>n;
  vector<int>A(n);
  for(int i=0;i<n;i++)cin>>A[i];
  mergeSort(A,0,n);
  for(int i=0;i<n;i++)cout<<A[i]<<" \n"[i==n-1];
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 6724
H,W,M=map(int,input().split())
nh=[0]*H
nw=[0]*W
boms=set()
for _ in range(M):
    h,w=map(int,input().split())
    nh[h-1] += 1
    nw[w-1] += 1
    boms.add((h-1, w-1))

maxh = max(nh)
maxw = max(nw)

i_indexes=[]
for i in range(H):
    if nh[i] == maxh:
        i_indexes.append(i)
j_indexes=[]
for j in range(W):
    if nw[j] == maxw:
        j_indexes.append(j)

for i in i_indexes:
    for j in j_indexes:
        if (i,j) in boms:
            continue
        print(maxh + maxw)
        exit()
print(maxh + maxw - 1)

Measured memory_bytes: 176612
fun main(args: Array<String>) {
  val s = readLine()!!
  val keyence = "keyence"
  for (i in 0..keyence.length) {
    val head = keyence.substring(0, i)
    val tail = keyence.substring(i)
    if (s.startsWith(head) && s.endsWith(tail)) {
      println("YES")
      return
    }
  }
  println("NO")
}

Measured memory_bytes: 33868
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

int n, m;
vector<int> graph[100010];
int main() {
    cin >> n >> m;
    vector<int> h(n);
    rep(i, 0, n) cin >> h[i];
    rep(i, 0, m){
        int a, b; cin >> a >> b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int ans = 0;
    rep(i, 0, n){
        int nh = h[i];
        int maxh = 0;
        for(auto x : graph[i]){
            maxh = max(maxh, h[x]);
        }
        if(nh > maxh) ans++;
    }

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


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

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

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

  while (!isPrime(x)) x++;

  cout << x << endl;

  return 0;
}


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

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


void solve(long long K, std::string S){
    int len = S.size();
    string ans = "";
    if(len <= K) ans = S;
    else {
        rep(i,K) ans += S[i];
        ans += "...";
    }

    cout << ans << endl;
}

int main(){
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int k;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}


int main(){
    ll n,k;
    cin >> n;
    cin >> k;
    k += 1;

    vector<double>L(n);
    rep(i,n) cin >> L[i];
    //cin >> k;
    double l=0;
    double r=inf;
    ll count;
    
    auto judge=[&](double x){
        count=0;
        rep(i,n) count+=floor(L[i]/x);
        if(count>=k) return true;
        else return false;
    };

    for(int j=0;j<100;j++){
        double mid=(l+r)/2.0;
        bool flag;
        flag=judge(mid);
        if(flag) l=mid;
        else r=mid;
    }
    cout << ll(ceil(l)) << endl;


    return 0;
}

Measured memory_bytes: 4764
#include "omp.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <random>
#include <bitset>
#include <unordered_set>
#include <cassert>
#include <list>
#include <functional>


using namespace std;

typedef long long ll;
typedef long double ld;


const int sze = 1 << 15, INF = 1e9 + 10;

signed main()
{
	int n;
	cin >> n;

	vector<int> values(n), challengers(n);

	for (int i = 0; i < n; ++i)
	{
		cin >> values[i];
		challengers[i] = values[i];
	}

	sort(values.begin(), values.end());
	
	map<int, int> ans;

	for (int i = 0; i < n; ++i)
	{
		if (i >= n / 2)
			ans[values[i]] = values[n / 2 - 1];
		else if (i < n / 2)
		{
			ans[values[i]] = values[n / 2];
		}
	}

	for (int v : challengers)
		cout << ans[v] << '\n';

	return 0;
}

Measured memory_bytes: 12928
#include <stdio.h>

struct year {
	int start;
	int end;
};

void outputLeapyear(int, int);

int main(void) 
{
	int isInit = 0;
	struct year year;

	while (scanf("%d %d", &year.start, &year.end), !(year.start == 0 && year.end == 0)) {
		if (isInit == 0) {
			isInit++;
		} else {
			printf("\n");
		}
		outputLeapyear(year.start, year.end);
	}
	
		return 0;
}

void outputLeapyear(int start, int end) 
{
	int i;
	int count = 0;

	for (i = start; i <= end; i++) {
		if (i % 400 == 0) {
			printf("%d\n", i);
			count++;
		} else if (i % 100 == 0) 
			continue;
		else if (i % 4 == 0) {
			printf("%d\n", i);
			count++;
		}
	}

	if (!count) 
		printf("NA\n");
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) n % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std; 

int main() { 
    IOS;
    ll n;
    cin >> n;
    vll a(n);
    vll b(n);
    vll c(n);
    vector<vll> dp(n, vll (3, 0));
    for (int i = 0; i < n; i++) {
    	cin >> a[i] >> b[i] >> c[i];
    	if (!i) {
    		dp[0][0] = a[i];
    		dp[0][1] = b[i];
    		dp[0][2] = c[i];
    		continue;
    	}
    	dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
    	dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
    	dp[i][2] = max(dp[i - 1][1] + c[i], dp[i - 1][0] + c[i]);
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}   

Measured memory_bytes: 8064
#!/usr/bin/env python
N = input()
tmp = N[0]
counter = 1
flag = False
for i in range(1,len(N)):
    if N[i]==tmp:
        counter += 1
    else:
        tmp = N[i]
        counter = 1
    if counter==3:
        flag = True
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n * n);
        }

    }
}



Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>

int main(void) {
	int datamax,datanum;
	int equalnum;
	int i;
	char hebi[201];
	scanf("%d",&datamax);
	for(datanum=0;datanum<datamax;datanum++) {
		scanf("%s",hebi);
		if(strlen(hebi)<2 || hebi[0]!='>') {
			puts("NA");
			continue;
		}
		if(hebi[1]=='\'') {
			equalnum=0;
			i=2;
			while(hebi[i]=='=') {
				i++;
				equalnum++;
			}
			if(hebi[i]!='#' || equalnum<=0)puts("NA");
			else {
				i++;
				while(hebi[i]=='=') {
					i++;
					equalnum--;
				}
				if(equalnum!=0)puts("NA");
				else if(hebi[i]!='~' || hebi[i+1]!=0)puts("NA");
				else puts("A");
			}
		} else if(hebi[1]=='^') {
			i=2;
			while(hebi[i]=='Q' && hebi[i+1]=='=')i+=2;
			if(i==2)puts("NA");
			else if(hebi[i]!='~' || hebi[i+1]!='~' || hebi[i+2]!=0)
				puts("NA");
			else puts("B");
		} else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const LL MAXN = 100010;
const LL INF = 2147483600;

LL N;
LL opr[MAXN+1];
LL a[MAXN+1],f[MAXN+1][5];

inline LL fan(LL x,LL c){
	if(c&1) return -x; return x;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); 
	for(LL i=1;i<=N;i++){
		a[i]=read(); char c;
		if(i<N){
			c=getchar();
			getchar();
			opr[i+1]=(c=='+'?1:-1);
		}
	} memset(f,-127,sizeof(f));
	opr[1]=1; f[0][0]=0;
	for(LL i=1;i<=N;i++){
		for(LL j=0;j<=min(N,4LL);j++){
			if(j>0&&opr[i]==-1) f[i][j]=f[i-1][j-1]+fan(opr[i],j-1)*a[i];
			if(j<4&&j<N) f[i][j]=max(f[i][j],f[i-1][j+1]+fan(opr[i],j+1)*a[i]);
			f[i][j]=max(f[i][j],f[i-1][j]+fan(opr[i],j)*a[i]);
		}
	}
	for(LL i=0;i<=4LL;i++) f[N][0]=max(f[N][0],f[N][i]);
	printf("%lld\n",f[N][0]);
	return 0;
}


Measured memory_bytes: 5760
n = int(input())
A = list(map(int, input().split()))

wari = [0]*3

for a in A:
    if a % 4 == 0:
        wari[2] += 1
    elif a % 2 == 0:
        wari[1] += 1
    elif a % 2 == 1:
        wari[0] += 1

if wari[1] == 0:
    if wari[2] + 1 >= wari[0]:
        print("Yes")
    else:
        print("No")

else:
    if wari[2] >= wari[0]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 85436
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(abs(a-c)<=d)
	{
		printf("Yes");
	}
	else
	{
		if(abs(a-b)<=d&&abs(b-c)<=d)
		{
			printf("Yes");
		}
		else
		{
			printf("No");
		}
	}
	return 0;
}

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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    ll n, k;
    cin >> n >> k;
    int balls[n];
    for(ll i = 0; i < n; i++) cin >> balls[i];
    sort(balls, balls+n);

    ll ver[n], cnt = 0;
    ll index = 0;
    for(ll i = 0; i < n; i++){
        if(balls[i] == balls[i+1]) cnt++;
        else{
            ver[index] = cnt + 1;
            index++;
            cnt = 0;
        }
    }

    sort(ver, ver+index);
    ll ans = 0;
    for(int i = 0; i < index - k; i++){
        ans += ver[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll a = 0, b = 0, c = 0;
    REP(i, S.length()) {
        if (S[i] == 'a')
            a++;
        else if (S[i] == 'b')
            b++;
        else
            c++;
    }
    if (max({a, b, c}) - min({a, b, c}) <= 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define N 200010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}


signed main(){
  int n;
  cin>>n;
  int cnt[N]={};  
  for(int i=0,a;i<n;i++)cin>>a,cnt[a]++;
  
  int ans = 0;
  for(int i=0;i+2<N;i++){
    int score = cnt[i+0] + cnt[i+1] + cnt[i+2];
    Max(ans,score);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b==c||a+c==b||b+c==a)cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

struct data{
	int l,r;
	data(){}
	data(int x,int y):l(x),r(y){}
	friend bool operator<(const data &dt1,const data &dt2){return dt1.r-dt1.l+1<dt2.r-dt2.l+1;}
};

int N,M,sum[300001];
data dt[300001];

inline int lowbit(int x){return x&-x;}

int update(int k,int x){for(int i=k;i<=M+1;i+=lowbit(i))sum[i]+=x;}

int query(int x){int res=0;for(int i=x;i>0;i-=lowbit(i))res+=sum[i];return res;}

int main(){
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;++i)scanf("%d%d",&dt[i].l,&dt[i].r);
	sort(dt+1,dt+N+1);
	for(int i=1,p=1;i<=M;++i){
		int ans=N-p+1;
		for(int j=1;i*j<=M;++j)ans+=query(i*j);
		printf("%d\n",ans);
		while(p<=N&&dt[p].r-dt[p].l+1<=i)update(dt[p].l,1),update(dt[p].r+1,-1),++p;
	}
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  if((N==3) || (N==5) || (N==7)) {
cout <<"YES" << endl;
  }
else {
cout << "NO" << endl;
}
}


Measured memory_bytes: 256
S = input()

N = len(S)
ret = [0]*N
for i in range(N-1):
    if S[i:i+2] == 'RL':
        for j in range(i, -1, -1):
            if S[j] == 'R':
                ret[i + (i-j)%2] += 1
            else:
                break
        for j in range(i+1, N):
            if S[j] == 'L':
                ret[i + (j-i)%2] += 1
            else:
                break

print(' '.join(map(str, ret)))

Measured memory_bytes: 51184
from math import gcd
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

K = int(readline())

ans = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += gcd(gcd(i, j), k)

print(ans)

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

void print(int i,int n){
    cout << i << ":";
    for(int j = 0;j < n;++j){
        if(i & (1 << j)){
            cout << " " << j;
        }
    }
    cout << endl;
}

int main() {
    int n,k,vIndex = 0;
    cin >> n >> k;
    vector<int> vec(k);
    for(int i = 0;i < k;++i){
        cin >> vec[i];
    }
    
    for(int i = 0;i < (1 << n);++i){
        if(vec.size() != 0){
            vIndex = 0;
            for(int j = 0;j < n;++j){
                int bit = 1 << j;
                int targetBit = 1 << vec[vIndex];
                if(i & bit && bit == targetBit){
                    if(++vIndex == vec.size()){
                        j = n;
                    }
                }
            }
            
            // 部分集合だった場合
            if(vIndex == vec.size()){
                print(i,n);
            }
        }
        else{
            print(i,n);
        }
    }
}



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

#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(nullptr); //cout.tie(nullptr);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define test            int TESTS; cin>>TESTS; for(int CASE=1; CASE<=TESTS; ++CASE)
#define in(arr,n)       for(int i=0; i<(n); ++i) cin>>arr[i]
#define lcm(a,b)        ((a)/__gcd((a),(b)))*(b)
#define midl(l,r)       ((l)+((r)-(l))/2)
#define prec(n)         fixed<<setprecision(n)
#define r0              return 0
#define E               "\n"
#define S               " "
#define elif            else if
#define INF             9e18
#define M               1000000007
#define PI              3.141592653589793238L
#define sortd(s,n)      sort((s), (s)+(n), greater<int>())
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define sz(s)           (int)(s).size()
#define em(s)           (s).empty()
#define fr              first
#define sc              second
#define pb              push_back
#define eb              emplace_back
#define ins             insert
#define emp             emplace
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ " : " << (__VA_ARGS__) << "] "

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int,int>;
using mii = map<int,int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int,int>>;
using seti = set<int>;
using setd = set<int,greater<int>>;
using pqmx = priority_queue<int>;
using pqmn = priority_queue<int,vector<int>,greater<int>>;

/*__*/

signed main()
{
    thegamebegins

    float a,b;	cin>>a>>b;
    cout<<(int)(a*b);
    r0;
}


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

int n;
int h[100005];
int dp[100005];

int solve(int x){
    if (x >= n-1) return 0;
    else if (dp[x] != -1) return dp[x];
    else if (x == n-2){
        return dp[x] = abs(h[x+1]-h[x]);
    }
    else {
        return dp[x] = min(abs(h[x+1]-h[x])+solve(x+1),abs(h[x+2]-h[x])+solve(x+2));
    }
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    memset(&dp,-1,sizeof(dp));
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }
    cout << solve(0) << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

int main(int argc, char *argv[])
{
    int n;
    scanf("%d", &n);
    int t = 0, x = 0, y = 0;
    for (int i = 0; i < n; ++i)
    {
        int tt, xx, yy;
        scanf("%d %d %d", &tt, &xx, &yy);
        int dt = tt - t;
        int dx = xx - x;
        int dy = yy - y;
        t = tt;
        x = xx;
        y = yy;
        if (abs(dx) + abs(dy) > dt)
        {
            puts("No");
            return 0;
        }
        else if ((dt - abs(dx) - abs(dy)) % 2 == 1)
        {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


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

int main(){
  int N;
  cin >> N;
  string S[N];
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  int countAC=0, countWA=0, countTLE=0, countRE=0;
  for(int i=0; i<N; i++){
    if(S[i]=="AC"){
      countAC = countAC+1;
    }
    else if(S[i]=="WA"){
      countWA = countWA+1;
    }
    else if(S[i]=="TLE"){
      countTLE = countTLE+1;
    }
    else{
      countRE = countRE+1;
    }
  }  

  cout << "AC x " << countAC << endl;
  cout << "WA x " << countWA << endl;
  cout << "TLE x " << countTLE << endl;
  cout << "RE x " << countRE << endl;

  return 0;
}  
  

Measured memory_bytes: 6700
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
using ll = long long int;
template<typename T>
ostream& operator+(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out<<x<<" ";
    }
    out<<"\n";
    return out;
}
template<typename T>
ostream& operator*(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out+x;
    }
    return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}
void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c, b*d, a*d, b*c})<<"\n";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10000)
s=input()
ans=0
num=len(s)-1
def solve(moji,num):
    global ans
    if num==0:
        ans+=eval(moji)
    else:
        solve(moji,num-1)
        solve(moji[:-num]+"+"+moji[-num:],num-1)
solve(s,num)
print(ans)

Measured memory_bytes: 3060