akhauriyash/Code-Regression huggingface dataset:
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 500005; 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 


void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 
 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit));
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n);  
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n);
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	}  
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
}  
int main() 
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n ;
	cin >> n;
	int q;
	cin >> q;
	int arr[n+2];
	Query queries[q+2];
	for(int i = 0 ;i < n ; i ++){
		cin >> arr[i];
	}
	for(int i = 0 ;i < q ;i ++){
		int l ,r;
		cin >>l >> r;
		l--;
		r--;
		queries[i].l = l;
		queries[i].r = r;
		queries[i].idx = i;
	}
	sort(queries, queries+q, cmp); 
	answeringQueries(arr, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 17380
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 1, 0, -1, -1, -1, 0, 1};
vector<int> dx = {0, 1, 1, 1, 0, -1, -1, -1};
void spell(map<string, int> &mp, vector<vector<char>> &c, int y, int x, int d){
  int h = c.size();
  int w = c[0].size();
  string S;
  int y2 = y;
  int x2 = x;
  while (1){
    S += c[y2][x2];
    mp[S]++;
    y2 = (y2 + h + dy[d]) % h;
    x2 = (x2 + w + dx[d]) % w;
    if (y2 == y && x2 == x){
      break;
    }
  }
}
int main(){
  while (1){
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0){
      break;
    }
    vector<vector<char>> c(h, vector<char>(w));
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        cin >> c[i][j];
      }
    }
    map<string, int> mp;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        for (int k = 0; k < 8; k++){
          spell(mp, c, i, j, k);
        }
      }
    }
    string ans = "A";
    for (auto P : mp){
      if (P.second >= 2){
        if (P.first.size() > ans.size() || P.first.size() == ans.size() && P.first < ans){
          ans = P.first;
        }
      }
    }
    if (ans == "A"){
      cout << 0 << endl;
    } else {
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 37876
# AOJ 0086 Patrol
# Python3 2018.6.17 bal4u

while True:
	try: a, b = list(map(int, input().split()))
	except: break
	
	c = [0]*105
	n = 0
	while True:
		if a != b:
			c[a] += 1
			c[b] += 1
		if a > n: n = a
		if b > n: n = b
		a, b = list(map(int, input().split()))
		if a == 0: break

	f = False
	if (c[1]&1) and (c[2]&1):
		i = 3
		while i <= n:
			if (c[i]&1): break;
			i += 1
		if i > n: f = True
	print("OK" if f else "NG")


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
bool visited[100007]={false};
unordered_map<int,int>degree;
int main(){
    int n;cin>>n;map<pair<int,int>,int>id;
    vector<vector<int>>g(n+6);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        if(a>b)
        swap(a,b);
        id[make_pair(a,b)]=i;
        g[a].push_back(b);
        g[b].push_back(a);
        if(degree.find(a)==degree.end())
            degree[a]=1;
        else
            degree[a]++;
        if(degree.find(b)==degree.end())
            degree[b]=1;
        else
            degree[b]++;
    }
    int max_degree=INT_MIN;
    for(int i=1;i<=n;i++){
        max_degree=max(max_degree,degree[i]);
    }
    cout<<max_degree<<"\n";
    int anss[n+3];
    queue<int>q;q.push(1);
    unordered_map<int,int>parent_clr;
    parent_clr[1]=-1;
    while(!q.empty()){
        int now=q.front();q.pop();
        visited[now]=true;
        int pr_clr=1;
        for(int i=0;i<g[now].size();i++){
            if(!visited[g[now][i]]){
                if(pr_clr==parent_clr[now])
                    pr_clr++;
                int x=now,y=g[now][i];
                if(x>y)
                    swap(x,y);
                anss[id[make_pair(x,y)]]=pr_clr;
                parent_clr[g[now][i]]=pr_clr;
                pr_clr++;
                q.push(g[now][i]);
            }
        }
    }
   // cout<<id[make_pair(1,2)];
    for(int i=0;i<n-1;i++){
        cout<<anss[i]<<"\n";
    }

    
}

Measured memory_bytes: 21028
import math
a,b,h,m = list(map(int, input().split()))

hh=360*(60*h+m)/(60*12)
mm=360*(m/60)
rad=hh-mm
if rad > 180:
    rad=360-rad
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad))))

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  ll n,c,k;
  cin >> n >> c >> k;
  priority_queue<ll,vector<ll>,greater<ll>> que;
  vector<ll> t(n);
  rep(i,n)cin >> t[i];
  sort(ALL(t));
  ll res = 0;
  ll hu = 0;
  rep(i,n){
    if(que.empty()){
      que.push(t[i]);
      hu++;
      continue;
    }
    ll cnt = 0;
    while(!que.empty()){
      ll tt = que.top();que.pop();
      if(tt+k < t[i])cnt++;
      else {
        que.push(tt);
        break;
      }
    }
    if(cnt == 0){
      que.push(t[i]);
      hu++;
      continue;
    }
    res += (cnt+c-1)/c;
    hu -= cnt;
    if((cnt%c) != 0)hu = max(hu-(c-cnt%c),0ll);
    while(que.size() != hu)que.pop();
    que.push(t[i]);
    hu++;
  }
  res += (hu+c-1)/c;
  cout << res << endl;



  return 0;
}

Measured memory_bytes: 1152
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int m;
int n;
int p[10];
int q[10];
int t[10];
int dfs(int a,int b){
	if(a==n){
		for(int i=0;i<m;i++){
			if(t[p[i]]!=q[i])return 0;
		}
		printf("%d\n",b);
		return 1;
	}
	for(int i=0;i<10;i++){
		if(i==0&&a==0&&n>1)continue;
		t[a]=i;
		if(dfs(a+1,b*10+i))return 1;
	}
	return 0;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);n=a;m=b;
	for(int i=0;i<b;i++){
		scanf("%d%d",p+i,q+i);
		p[i]--;
	}
	int ret=dfs(0,0);
	if(ret==0){
		printf("-1\n");
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ri register int
#define pb push_back
#define fi first
#define se second
using namespace std;
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
inline int Read(char*s){
	int top=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))s[++top]=ch,ch=gc();
	return top;
}
const int mod=998244353;
inline int add(int a,int b){return (a+=b)<mod?a:a-mod;}
inline void Add(int&a,int b){a=add(a,b);}
inline int dec(int a,int b){return (a-=b)<0?a+mod:a;}
inline void Dec(int&a,int b){a=dec(a,b);}
inline int mul(int a,int b){return (ll)a*b%mod;}
inline void Mul(int&a,int b){a=(ll)a*b%mod;}
inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))(p&1)&&(Mul(ret,a),1);return ret;}
const int N=3005;
int t[N],n,L;
const double pi=acos(-1.0);
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read(),L=read();
	for(ri i=1;i<=n;++i)t[i]=read();
	double resx=0,resy=0,Ang=pi/L;
	for(ri i=1;i<n;++i)for(ri j=i+1;j<=n;++j){
		resx+=cos(Ang*(t[i]+t[j]))*(n-(j-i+1));
		resy+=sin(Ang*(t[i]+t[j]))*(n-(j-i+1));
		resx+=cos(Ang*(t[i]+t[j])+pi)*(j-i-1);
		resy+=sin(Ang*(t[i]+t[j])+pi)*(j-i-1);
	}
	printf("%.10lf %.10lf",resx*6.0/n/(n-1)/(n-2),resy*6.0/n/(n-1)/(n-2));
	return 0;
}

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

void solve(int TestCase) {
    int n;
    cin >> n;

    vector<pair<long long, long long>> A(n);
    for(auto& a : A) {
        long long x, y;
        cin >> x >> y;

        a.first = x + y, a.second = x - y;
    }

    sort(A.begin(), A.end());
    int ret = 0;
    long long last = numeric_limits<long long>::min();
    for(auto a : A) {
        if(last <= a.second) {
            ret++;
            last = a.first;
        }
    }

    cout << ret << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i)
        solve(i);
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int i = 0, sum1 = 0, sum2 = 0;
	char c;
	for (int a, b; cin >> a >> c >> b; i++) {
		sum1 += a*b;
		sum2 += b;
	}
	cout << sum1 << endl << round((double)sum2 / i) << endl;
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a,b;
    cin >> a >> b;
    if(a==b.substr(0,a.length()))
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3620
import math
def is_prime(n):
  if n == 1:
    return False
  for p in range(2, int(math.sqrt(n))+1):
    if n%p == 0:
      return False
  return True
m = int(input())
while m > 0:
  if is_prime(m) == True:
    print(m)
    break
  m += 1

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define pb push_back
#define p2(x) (x)*(x)
#define len(x) (int)(x).size()
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = 1e9 + 7;
void md(int &a){
    while(a >= mod)a-=mod;
}

signed main(){
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n;
    cin >> n;
    vector < ll > a(n);
    for(auto &i : a)cin >> i;
    vector < int > cnt(61);
    for(int j = 0  ; j < n; ++j){
        for(int bit = 0 ; bit <= 60; ++bit){
            if((1ll<<bit)&a[j])cnt[bit]++;
        }
    }
    int answer = 0 ;
    for(int j = 0 ; j  <= 60; ++j){
        answer += (1ll<<j)%mod*(cnt[j])%mod*(n-cnt[j])%mod;
        md(answer);
    }
    cout << answer;
    return 0;
}


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

int main(){
  int n,q; cin>>n>>q;
  vector<long long>a(n),x(q);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<q;i++){
    cin>>x[i];
  }
  for(int i=0;i<q;i++){
    long long res=0;
    long long sum=0;
    int right=0;
  for(int left=0;left<n;left++){
    while(right<n&& sum+a[right] <=x[i]){
      sum+=a[right];
      right++;
    }
    res+=(right-left);
    if(right==left)++right;
    else sum-=a[left];
  }
  cout<<res<<endl;
  }
  
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
long gcd(long a, long b){
    long r = a % b;
    while(r > 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main(){
    long k;
    cin >> k;
    long ans = 0;
    for(long i = 1; i <= k; i++)
        for(long j = 1; j <= k; j++)
            for(long l = 1; l <= k; l++)
                ans += gcd(i, gcd(j, l));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>

int main(void)
{
	double h,min,max;
	
	scanf("%lf",&h);
	min=max=h;
	while(scanf("%lf",&h) != EOF)
	{
		if(max<h)
			max = h;
		else if(min>h)
			min = h;
	}
	printf("%0.1f\n",max-min);
	return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int H, W, K;
    int ans = 0;
    cin >> H >> W >> K;
    vector<string> c(H);
    rep(i, H) cin >> c[i];
    for(int bit1=0; bit1 < (1<<H); ++bit1){
        for(int bit2=0; bit2 < (1<<W); ++bit2){
            int kuro = 0;
            for(int i=0; i<H; ++i){
                for(int j=0; j<W; ++j){
                    if(!((bit1>>i) & 1) && !((bit2>>j) & 1)){
                        if(c[i][j]=='#') kuro++;
                    }

                }
            }
            if(kuro==K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>
#include <deque>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll ans, a1 = INF, a2 = INF;
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	vector<ll> x(a),y(b);
	REP(i, a) {
		cin >> x[i];
		a1 = min(a1, x[i]);
	}
	REP(i, b) {
		cin >> y[i];
		a2 = min(a2, y[i]);
	}
	ans = a1 + a2;
	REP(i, c) {
		ll c1, c2, c3;
		cin >> c1 >> c2 >> c3;
		c1--;
		c2--;
		ans = min(ans, x[c1] + y[c2] - c3);
	}
	cout << ans << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string A,B,C,ans;
    cin >> A >> B >> C;
    locale l = locale::classic();
    cout 
      << toupper(A.at(0),l) 
      << toupper(B.at(0),l) 
      << toupper(C.at(0),l) << endl;
}

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

int main(){
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if(abs(a-b) >= pow(10,18)) cout << "Unfair" << endl;
    else if(k %2 == 0) cout << a-b << endl;
    else cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 764
import static java.lang.Math.max;
import static java.lang.Math.min;
import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final String s = scanner.next();
    final String t = scanner.next();
    final int a = scanner.nextInt();
    final int b = scanner.nextInt();
    final String u = scanner.next();

    if(u.equals(s)) {
      System.out.println((a-1) + " " + b);
    } else {
      System.out.println(a + " " + (b-1));
    }

  }
}


Measured memory_bytes: 23252
N, D = map(int, input().split())
X = [[int(i) for i in input().split()] for _ in range(N)]

ret = 0
for i in range(N-1) :
    for j in range(i + 1, N) :
        d = 0
        for k in range(D) :
            d += (X[i][k] - X[j][k]) ** 2
        
        k = 1
        while k * k < d :
            k += 1
        if k * k == d :
            ret += 1
            
print(ret)

Measured memory_bytes: 38640
n=int(input())
s=list(input())
#n,k=map(int,input().split())
#pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

r=s.count("R")
g=s.count("G")
b=s.count("B")

count=0

for i in range(n):
    for j in range(i+1,n):
        k=2*j-i
        if k>=n:
            continue
        if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
            count+=1

print(r*g*b-count)


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

static const ll INF = 1e15;

static const ll mod = 1e9 + 7;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};


int main() {
	ll k;
	string s;
	cin >> k;
	cin >> s;
	ll n = s.size();
	Factorial f(n + k);
	ll all = 0;
	for (int i = 0; i <= k; i++) {
		ll right = mpow(26, i);
		ll rest = n + k - i - 1;
		ll c = f.cmb(rest, n - 1);
		ll left = mpow(25, k - i);
		ll sum = right * left;
		sum %= mod;
		sum *= c;
		sum %= mod;
		all += sum;
		all %= mod;
	}
	cout << all << endl;
	return 0;
}
	

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

int main(void)
{
	int i,str1,str2;
	char o[51],e[50];
	scanf("%s %s",o,e);
	
	str1=strlen(o);
	str2=strlen(e);
	
	if(str1-str2==0){
		for(i=0;i<=str1-1;i++){
			printf("%c%c",o[i],e[i]);
		}
		printf("\n");
	} else{
		for(i=0;i<=str1-2;i++){
			printf("%c%c",o[i],e[i]);
		}
		printf("%c\n",o[str1-1]);
	}
	return 0;
}

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

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

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

    int maxv = 	-2147483648;
    for(int i = 1; i < n; i++){
        int tmp;
        scanf("%d", &tmp);
        maxv = max(maxv, tmp - minv);
        minv = min(minv, tmp);
    }
    printf("%d\n", maxv);
}


Measured memory_bytes: 2756
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (auto &e: h) cin >> e;

    int p = 0;
    int ans = 0;
    for (auto &e: h) {
        if (e > p) {
            ans += e - p;
        }
        p = e;
    } 

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N = II()
    a = ILI()
    return (N, a)


def solve(N, a):
    num_min = min(a)
    num_max = max(a)
    ans = num_max - num_min
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


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

int main() {

    double ans = 0.0;
    int n;
    cin >> n;

    rep(i,n) {
        double x;
        string s;
        cin >> x >> s;
        if (s == "JPY") ans += x;
        else ans += x*380000.0;
    }

    printf("%.8f\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
S = list(input())
ans = 0
now = 0
count = 0
a = 0
for i in S:
  if i == "<":
    if count > 0:
      if count == 1:
        now = 0
        count = 0
      else:
        if count > now:
          ans = ans +  sum(range(1, count+1)) - now
          now = 0
          count = 0
        else:
          ans = ans + sum(range(1, count))
          now = 0
          count = 0
    now += 1
    a = 1
  else:
    if a == 1:
      ans += sum(range(1, now+1))
      a = 0
    count += 1
if a == 1:
  ans += sum(range(1, now+1))
elif count > 0:
  if count == 1:
    if now == 0:
      ans += 1
      now = 0
      count = 0
    else:
      now = 0
      count = 0
  else:
    if count > now:
      ans = ans +  sum(range(1, count+1)) - now
      now = 0
      count = 0
    else:
      ans = ans + sum(range(1, count))
      now = 0
      count = 0
  
print(ans)


Measured memory_bytes: 8092
#include <stdio.h>
int main(void){
    
    int i,n,a[100000],b;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    i=0; b=a[0];
    while(i<n){
        i++;
        if(b==2){
            printf("%d\n",i);
            return 0;
        }
        else{
            b=a[b-1];
        }
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 2068
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#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 {
#ifdef LOCAL
~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__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const int MAXN = 1e5 + 1 ; 
int main(){
    fastio
    int n ; 
    cin >> n ; 
    if ( n % 2 == 1 ) {
    	cout << 0 << endl;
    	return 0 ; 
    }
    vector<int> v(n) ; 
    for(int &x : v){
    	cin >> x; 
    }
    sort(v.begin(),v.end()) ; 
    cout << v[n/2] - v[(n-1)/2] << endl;
    return 0 ;
}


Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    let k = read::<usize>() - 1;
    let n = std::cmp::min(a, b);
    let mut anss = vec![];
    for i in 1..n + 1 {
        if a / i * i == a && b / i * i == b {
            anss.push(i);
        }
    }
    anss.reverse();
    println!("{}", anss[k]);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
	int val;
	Node *pre,*next;
};

Node *NIL;
void init(){
	NIL = (Node *)malloc(sizeof(Node));
	NIL->next = NIL;
	NIL->pre = NIL;
}

void insert(int k){
	Node *p = (Node *)malloc(sizeof(Node));
	p->val = k;
	p->next = NIL->next ;
	NIL->next->pre = p;
	NIL->next = p;
	p->pre = NIL;
}

Node* searchNode(int k){
	Node *p = NIL->next ;
	while(p != NIL&&p->val != k){
		p = p->next ;
	}
	return p;
}

void deleteNode(Node *t){
	if(t != NIL)	
	{
		t->next->pre = t->pre ;
		t->pre->next = t->next ;
		free(t);
	}
}
void deleteLast(){
	deleteNode(NIL->pre);
}
void deleteFirst(){
	deleteNode(NIL->next);
}
void deleteNode(int k){
	deleteNode(searchNode(k));
}
int main(){
	char op[20];int n,num;
	init();
	scanf("%d",&n);
	while(n--){
		scanf("%s",op);
		if(op[0] == 'i'){
			scanf("%d",&num);
			insert(num);
		}
		else if(op[6] == 'F'){
			deleteFirst();
		}
		else if(op[6] == 'L'){
			deleteLast();
		}
		else{
			scanf("%d",&num);
			deleteNode(num);
		}
	}
//	printf("%d  ",NIL->next->val);
	Node *p = NIL->next;
	int first = 1;
	while(p != NIL){
		if(first)
			first = 0;
		else 
			printf(" ");
		printf("%d",p->val);
		p = p->next;
	}
	printf("\n");
	return 0;
}







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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


// やめます

int main() {
  char b;
  cin >> b;
  if(b == 'A') cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  char a[4];
  cin>>a[0]>>a[1]>>a[2]>>a[3];
  if(a[0] == a[1] || a[1] == a[2] || a[2] == a[3]){
    cout << "Bad" << endl;
  }
  else{
    cout << "Good" << endl;
  }
  return 0;
}

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

int main() {
    string S; cin >> S;
    map<char, int> check;

    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        for (int j = 0; j < S.size(); j++) {
            if (S.at(i) == S.at(j)) check[S.at(i)]++;
        }
    }

    for (int i = 0; i < S.size(); i++) {
        if (check[S.at(i)] != 1) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int sub(vector<int> array){
  int ans=0;
  for(int i=0;i<array.size();i++)ans=max(ans,array.at(i));
  return ans;
}
int main() {
  int n;
  cin >> n;
  bool MMYY = 0<n/100 && n/100<=12;
  bool YYMM = 0<n%100 && n%100<=12;
  if(YYMM && MMYY)cout << "AMBIGUOUS" << endl;
  else if(YYMM)cout << "YYMM" << endl;
  else if(MMYY)cout << "MMYY" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
a = input().split()
a0 = int(a[0])
k = int(a[1])
b = []
for i in range(a0):
    c = int(input())
    b.append(c)
b.sort()
d = []
for i in range(len(b)-k+1):
    d.append(b[i+k-1]-b[i])

print(min(d))


Measured memory_bytes: 11292
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	c := 0
	ans := 0
	for i := 0; i < n; i++ {
		if a[n-1-i] > n-1-i || c > a[n-1-i] {
			fmt.Fprintln(wr,-1)
			return
		}

		if a[n-1-i] != 0 {
			ans++
		}

		if c != a[n-1-i] {
			ans+=c
			c = a[n-1-i]
		}

		c--
		c = max(0,c)
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 5120
#include <stdio.h>
 
int main(void)
{
 
    int n,m,a[1000],x=0,w=0,i;
    double y=0;
  
    scanf("%d%d",&n,&m);
 
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        x=x+a[i];
    }
 
     y=(double)x/(4*m);
 
     for(i=0;i<n;i++){
         if(a[i]>=y) w++;
     }
 
     if(m<=w)  printf("Yes\n");
     else if(m>w)  printf("No\n");
 
     
 
     return 0;
}

Measured memory_bytes: 1652
A = list(map(int, input().split()))
A += list(map(int, input().split()))
A += list(map(int, input().split()))
N = int(input())

bingo = [False]*9

for i in range(N):
    b = int(input())
    if b in A:
        bingo[A.index(b)] = True

for i in range(3):
    if bingo[i*3:(i+1)*3] == [True]*3:
        print("Yes")
        break
    elif bingo[i:7+i:3] == [True]*3:
        print("Yes")
        break
else:
    if ([bingo[0]] + [bingo[4]] + [bingo[8]]) == [True]*3:
        print("Yes")
    elif ([bingo[2]] + [bingo[4]] + [bingo[6]]) == [True]*3:
        print("Yes")
    else:
        print("No")


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

using namespace std;

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

  int  N; cin>>N;
  vector<int> B(N-1);
  for (auto&b : B) cin>>b;
  vector<int> A(N, numeric_limits<int>::max());
  for (int i = 0; i < N-1; i++) {
    if (A[i] > B[i])
      A[i] = B[i];
    A[i+1] = B[i];
  }
  int sum = 0;
  for (auto a : A) sum += a;
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    vector<long long> mul;
    long long a,b,x,y;
    cin >> a >> b >> x >> y;
    mul.push_back(a*x);
    mul.push_back(a*y);
    mul.push_back(x*b);
    mul.push_back(y*b);
    sort(mul.begin(),mul.end());
    cout << mul[3] << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;

int main() {
    int n;
    cin >> n;
    string ans;
    string s[51];
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    //a~zのcharループで文字列判定を行う
    for(char c = 'a'; c <= 'z'; c++){
        int small = 1000;
        for(int i = 0; i < n; i++){
            int cnt = 0;
            for(int j = 0; j < s[i].size(); j++){
                if(s[i][j] == c) cnt++;
            }
            small = min(small, cnt);
        }
        for(int i = 0; i < small; i++){
            ans += c;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, l; std::cin >> n >> l;
  vector<string> vec(n); rep(i, n) std::cin >> vec[i];
  sort(rng(vec));
  rep(i, n) std::cout << vec[i] << (i+1<n ? "" : "\n");
}


Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()
p = III()
counter = 0
for i in range(N):
  if p[i]!=i+1:
    counter += 1

if counter<=2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 38256
# https://atcoder.jp/contests/abc128/submissions/11722664

def main():
    from collections import deque, namedtuple
    from heapq import heappush, heappop
    from operator import attrgetter
    import sys

    input = sys.stdin.readline
    Event = namedtuple('Event', 'pos start end')
    UC = namedtuple('UC', 'pos end')  # UnderConstruction

    N, Q = map(int, input().split())

    events = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        e = Event(pos=x, start=s - x, end=t - x)  # 時間[s-x,t-x)にpos=0にいるとpos=xで工事中
        events.append(e)
    events.sort(key=attrgetter('start'))
    events = deque(events)

    D = (int(input()) for _ in range(Q))

    ans = []
    h = []
    for d in D:
        while events and events[0].start <= d:
            e = events.popleft()
            heappush(h, UC(pos=e.pos, end=e.end))

        while h and h[0].end <= d:
            heappop(h)

        ans.append(h[0].pos if h else -1)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 56036
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<math.h>

using namespace std;

typedef long long int64;

int main(void){
    int64 h;
    cin>>h;
    int64 ans=0;

    for(int64 i=0;h>0;i++){
        ans+=pow(2,i);
        h/=2;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+1;
vector<vector<int> >g;
int deg[N]={0};
int main()
{
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	int m=0;
	for(int i=0;i<5;i++)
	  {
	  	if(a[i]!=i+1)
	  	   m=i+1;
	  	  
	  }
	  cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 3608
from collections import*
n=int(input())
s=input()
c=0
r=s.count('R')
g=s.count('G')
b=s.count('B')
rgb=r*g*b

for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i 
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]:
            rgb-=1

print(rgb)

Measured memory_bytes: 74132
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<bitset>
#include<iomanip>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;



int main(){
  long long x, y;
  cin >> x >> y;
  long long ans = __gcd(x, y);
  cout << ans << endl;
  return 0;
  }


Measured memory_bytes: 3096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());

using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MOD = 1000000007; // 10^9 + 7

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

  int K, S; cin >> K >> S;
  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      if (x + y > S) break;
      if (x + y >= S - K) ans++;
    }
  }

  cout << ans << endl;
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, m;
  cin >> n >> m;
  if(n != m) cout << "No";
  else cout << "Yes";
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int t,n;
  int i,j,w;
  scanf("%d",&t);
  while(t--){
    scanf("%d",&n);
    int a[100];
    int b[100]={0};
    for(i=0;i<n;i++)
      scanf("%d",&a[i]);
    for(i=0;i<n-1;i++)
      b[i]=a[i+1]-a[i];
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(b[j-1]<b[j]){
	  w=b[j];
	  b[j]=b[j-1];
	  b[j-1]=w;
	}
      }
    }
    printf("%d %d\n",b[0],-b[n-1]);
  }

  return 0;
}

Measured memory_bytes: 596
'use strict'
function Main(input){
  input=input.trim().split('').map(x=>x-0);
  var S=input;
  var odd=0;
  var even=0;
  var L=S.length;
  for(let i=0;i<L;i++){
    if(i%2===0){
      even+=S[i];
    }else{
      odd+=S[i];
    }
  }
  var E=Math.floor(L/2)+L%2;
  var O=Math.floor(L/2);
  var A=E-even+odd;
  var B=even+O-odd;
  var result=Math.min(A,B);
  console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));


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

int sx, sy;
int tx, ty;

inline char get_ch(int dir_x, int dir_y)
{
    if(dir_x == 1 && dir_y == 0)
        return 'R';
    if(dir_x == -1 && dir_y == 0)
        return 'L';
    if(dir_x == 0 && dir_y == 1)
        return 'U';
    return 'D';
}
void move_and_print(int step, int dir_x, int dir_y)
{
    while(step--)
        cout << get_ch(dir_x, dir_y);
}
int main()
{
    cin >> sx >> sy;
    cin >> tx >> ty;
    move_and_print(tx - sx, 1, 0);
    move_and_print(ty - sy, 0, 1);
    move_and_print(tx - sx, -1, 0);
    move_and_print(ty - sy, 0, -1);
    cout << get_ch(0, -1);
    move_and_print(tx - sx + 1, 1, 0);
    move_and_print(ty - sy + 1, 0, 1);
    cout << get_ch(-1, 0);
    cout << get_ch(0, 1);
    move_and_print(tx - sx + 1, -1, 0);
    move_and_print(ty - sy + 1, 0, -1);
    cout << get_ch(1, 0);
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.LinkedHashMap

object Main extends App {
  Iterator.continually(readInt).takeWhile(_!=0).foreach { n =>
    val map = new LinkedHashMap[Long, Long]

    for(i<-1 to n) {
      val e = readLine.split(" ").map(_.toLong)
      if(!map.contains(e(0))) map += e(0) -> e(1)*e(2)
      else map(e(0)) += e(1)*e(2)
    }

    val filtered = map.filter( _._2 >= 1000000 )
    if(filtered.isEmpty) println("NA") else filtered.foreach( e => println(e._1))
  }
}

Measured memory_bytes: 45604
n = int(input())
a = list(map(int, input().split(" ")))

cache = 1000
kabu = 0
for i in range(n):
    if i == n - 1:
        cache += kabu * a[i]
        kabu = 0
        break

    if cache > a[i] and a[i] < a[i + 1]:
        kabu = cache // a[i]
        cache = cache % a[i]

    if kabu > 0 and a[i] > a[i + 1]:
        cache += kabu * a[i]
        kabu = 0

print(cache)


Measured memory_bytes: 8972
import java.util.*;

public class Main{
    public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
	int a[]= new int[3];
	int c5=0, c7=0;
	for(int i=0; i<3; i++){
	    a[i] = sc.nextInt();
	    if(a[i]==5){
		c5++;
	    }
	    if(a[i]==7){
		c7++;
	    }
	}
	if(c5==2 && c7==1){
	    System.out.println("YES");
	}else{
	    System.out.println("NO");
	}
    }
}

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

class Program
{

    static void Main(string[] args)
    {
        ProblemB(args);
    }
	static void ProblemB(string[] args)
    {
        int N = int.Parse(System.Console.ReadLine());
        int[] H = System.Console.ReadLine().Split(' ').Select((i) => int.Parse(i)).ToArray();
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            bool canSee = true;
            for(int j = 0; j < i; j++)
            {
                if (H[i] < H[j])
                {
                    canSee = false;
                }
            }

            if (canSee)
            {
                ans++;
            }
        }

        System.Console.WriteLine(ans.ToString());

    }
}

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

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

    vector<string> w(N);
    for(int i = 0; i < N; i++){
        cin >> w[i];

        if(i >= 1){
            int len = w[i-1].size();
            for(int j = 0; j < i; j++){
                if(w[j] == w[i] || w[i-1][len-1] != w[i][0]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
int main(){
  ll n;
  cin>>n;
  ll INF=10000000000;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll dp[100000];
  rep(i,n) dp[i]=INF;
  dp[0]=0;
  rep(i,n-1){
    dp[i+1]=min(dp[i+1],dp[i]+abs(v[i+1]-v[i]));
    if(i>0) dp[i+1]=min(dp[i+1],dp[i-1]+abs(v[i+1]-v[i-1]));
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include<iostream> 
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int main(){cout<<"1407 38"<<endl;int t=2;r(i,38){cout<<1<<" ";r(j,37){cout<<t<<" ";t++;}}r(i,37){r(j,37){cout<<i+2<<" ";r(l,37)cout<<37*l+39+(j+i*l)%37<<" ";}}}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    int l = s.size(), r = 0, b = 0;
    for(int i=0;i<l;i++){
        if(s[i] == 'R')
            r++;
        else
            b++;
    }

    if(r > b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

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

using namespace std;
const int INFTY = 1001001001;

int main()
{
    int N;
    cin >> N;
    vector<int> state(N);
    char c;
    int east=0, west=0;
    for(int i=0;i<N;++i){
        cin >> c;
        if(c == 'E'){
            // 東
            state[i] = 1;
            ++east;
        }
        else{
            // 西
            state[i] = 0;
            ++west;
        }
    }

    int e = 0, w = 0, ans=INFTY;
    for(int i=0;i<N;++i){
        if(state[i]){
            ans = min(ans, east - 1 + w - e);
            ++e;
        }
        else{
            ans = min(ans, east + w - e);
            ++w;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
x=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
y=int(input())
print(x[y-1])

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
ll dp[305][305][305];//見ている場所,スキップした回数,最後にスキップした場所
int main(){
for(int i=0;i<305;i++)for(int j=0;j<305;j++)for(int k=0;k<305;k++)dp[i][j][k]=inf;
ll n,d;
cin>>n>>d;
n++;
V<ll> a(n);
for(int i=1;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n;i++)dp[i+1][i][0]=0;
for(int i=0;i<=d;i++){
  for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
          if(j>=k)continue;
          if(a[k]-a[j]>0&&i>=k-j-1)chmin(dp[k+1][i][k],dp[j+1][i-(k-j-1)][j]+a[k]-a[j]);
          else if(i>=k-j-1)chmin(dp[k+1][i][k],dp[j+1][i-(k-j-1)][j]);
          chmin(dp[k+1][i+1][j],dp[k][i][j]);
      }
  }
}
ll ans=inf;
for(int i=0;i<=d;i++)for(int j=0;j<n;j++)chmin(ans,dp[n][i][j]);
cout<<ans<<endl;
}

Measured memory_bytes: 221952