akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

typedef long long ll;
typedef pair<ll,ll> P;

#define MOD 1000000007

long long totient(long long a) {
	ll ret = a;
	for(int i = 2;i * i <= a;i++){
		if(a % i == 0){
			ret = ret * (i - 1) / i;
			while(a % i == 0)a /= i;
		}
	}
	if(a > 1)ret = ret * (a - 1) / a;
	return ret;
}

// a / b (mod p) b と p は互いに素
// O(sqrt(p))かかるので注意
long long totient_div(long long a, long long b, long long p) {
	long long ret = a;
	long long tp = totient(p) - 1;
	long long c = b;
	for(int i = 0;i <= 60;i++){
		if(tp & (1LL << i))ret = (ret * c) % p;
		c = (c * c) % p;
	}
	return ret;
}

//a^b % MOD
long long mod_pow(ll a,ll b){
	long long ret = 1;
	long long c = a;
	for(int i = 0;i <= 60;i++){
		if(b & (1LL << i))ret = (ret * c) % MOD;
		c = (c * c) % MOD;
	}
	return ret;
}

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}


ll dp[1111111];
ll fact[1111111];
ll factAcc[1111111];

void calFact(){
	fact[0] = 1;
	REP(i, 1111110) {
		fact[i+1] = fact[i] * (i+1) % MOD;
		factAcc[i+1] = (factAcc[i] + fact[i+1]) % MOD;
	}
}

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

	calFact();
	ll n, d, h;cin >> n >> h >> d;
	dp[0] = mod_div(1, factAcc[n]);
	ll sum = 0;
	ll l = 0;

	REP(i, h){
		sum = (sum + dp[i] * factAcc[n] % MOD) % MOD;
		while(l < i && i - l >= d){
			sum = (sum + MOD - dp[l] * factAcc[n] % MOD) % MOD;
			l++;
		}
		dp[i+1] = sum;
	}

	cout << dp[h] * fact[n] % MOD << endl;
	return 0;
}


Measured memory_bytes: 28032
// SeeAlso: https://atcoder.jp/contests/abc119/tasks/abc119_c

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int N,A,B,C;
int l[MAX];

int dfs(int n, int a, int b, int c) {
    if(n==N) {
        if(min(a,min(b,c)) <=0) {
            return 100000;
        } else {
            return abs(A-a) + abs(B-b) + abs(C-c) - 30;
        }
    }
    int r1 = dfs(n+1,a,b,c);
    int r2 = dfs(n+1,a+l[n],b,c)+10;
    int r3 = dfs(n+1,a,b+l[n],c)+10;
    int r4 = dfs(n+1,a,b,c+l[n])+10;
    int m1 = min(r1,r2);
    int m2 = min(r3,r4);
    return min(m1,m2);
}

int main() {
    cin >> N >> A >> B >> C;
    REP(i, N) {
        cin >> l[i];
    }

    print(dfs(0,0,0,0));
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>


typedef std::pair<int, int> P;
int n;

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

    std::priority_queue<P> que;
    for(int i = 0; i < n; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        que.push(P(b, a));
    }

    P p = que.top(); que.pop();
    while(!que.empty()){
        P q = que.top(); que.pop();

        if(q.first < p.first) break;

        if(p.second > q.second){
            p = q;
        }
    }
    printf("%d %d\n", p.second, p.first);

    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int h[n+10];
    REP(i,n){
        cin>>h[i];
    }
    for(int i=n-1;i>0;i--){
        if(h[i-1]>h[i]){
            h[i-1]--;
        }
    }
    REP(i,n-1){
        if(h[i]>h[i+1]){
            print("No");
            return 0;
        }
    }
    print("Yes");
    return 0;
}


Measured memory_bytes: 640
lst=list(map(int,input().split()))
#x n-x x x n-2x n-2x n-2x
n=lst[0]
x=lst[1]
#if x==n-x :
#    s=
if n-x<=x:
    a,b=x,n-x
else:
    a,b= n-x,x
s=n
#i=0
while b!=0:
    s+=a//b*2*b
    c=a
    a=b
    b=c%b
print(s-a)    


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
# 整数の入力
import math
import numpy as np

N = int(input())
A = []
B = []
for i in range(N):
    t = list(map(int, input().split()))
    A.append(t[0])
    B.append(t[1])
A.sort()
B.sort()

if N % 2 == 0:
    i = N // 2
    j = N // 2 - 1
    a = A[j] + A[i]
    b = B[j] + B[i]
    print(b - a + 1)
else:
    i = N // 2
    a = B[i] - A[i] + 1

    print(a)



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

int two(ll ai) {
  int count = 0;
  while(true) {
    if(ai % 2 == 0) {
      count++; 
      ai /= 2;
    } else {
      return count;
    }
  }
}

int c(int n, vector<ll> a) {
  int count = 0;
  for(auto aa: a) {
    count += two(aa);
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  cout << c(n, a);
}

Measured memory_bytes: 3792
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        
        int n=sc.nextInt();
        String s=sc.next();
        int x=0;
        int max=0;
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='I') x++;
            else x--;
            max=Math.max(x,max);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;



int main() {
	long long x, y,ans=1;
	cin >> x >> y;
	while (1) {
		x = x * 2;
		if (x > y) {
			break;
		}
		ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$numbers = explode(" ", trim(fgets(STDIN)));
$ans = 0;
for($i=2; $i<$n; $i++){
	$sort_array = [$numbers[$i-2], $numbers[$i-1], $numbers[$i]];
	sort($sort_array);
	if($sort_array[1] === $numbers[$i-1]){
		$ans += 1;
	}
}
echo $ans . "\n";

?>

Measured memory_bytes: 4604
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define FOR(i, l, r) for(int i = (l); i <= (r); i++)
#define REP(i, l, r) for(int i = (l); i != (r); i++)
#define DFR(i, l, r) for(int i = (l); i >= (r); i--)
#define DRP(i, l, r) for(int i = (l); i != (r); i--)

using namespace std;

#define DEBUG(arg...) fprintf(stderr, arg)

namespace FI {
    const int SIZE = 1 << 18 | 1;
    char buf[SIZE], *front, *back;

    void Char(char &c) {
	if(front == back) back = (front = buf) + fread(buf, 1, SIZE, stdin);
	c = (front == back) ? (char)EOF : *front++;
    }

    template<typename T> void Num(T & x) {
	char c; int f = 1;
	for(Char(c); c > '9' || c < '0'; Char(c)) if(c == '-') f = -1;
	for(x = 0; c >= '0' && c <= '9'; Char(c)) x = (x << 3) + (x << 1) + c - '0';
	x *= f;
    }
}

typedef long long LL;
const int maxn = 200000 + 47;
const int mod = 1e9 + 7;

int n, c[maxn], head[maxn];
int f[maxn], pre[maxn];

int main() {
    memset(head, -1, sizeof head);
    
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", &c[i]);
    FOR(i, 1, n) pre[i] = head[c[i]], head[c[i]] = i;
    f[0] = 1; FOR(i, 1, n) f[i] = (f[i - 1] + (pre[i] == -1 || pre[i] == i - 1 ? 0 : f[pre[i]])) % mod;
    printf("%d\n", f[n]);
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <int> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    fast
    ll n,m;
    cin>>n>>m;
    map<ll,vi> ma;
    for(ll i=0;i<m;i++)
    {
        ll p;
        string s;
        cin>>p>>s;
        if(s=="AC")
            ma[p].pb(1);
        else
            ma[p].pb(-1);
    }
    ll ac = 0;
    ll penalty = 0;
    for(auto &i:ma)
    {
        ll flag=0;
        for(ll j=0;j<i.S.size();j++)
            if(i.S[j]==1)
                flag=1;
        if(flag)
        {
            ac++;
            for(ll j=0;j<i.S.size();j++)
            {
                if(i.S[j]==-1)
                    penalty++;
                else
                    break;
            }
        }
    }
    cout<<ac<<" "<<penalty<<endl;
}

Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
char mem[114514];
char t[114514];
char c[114514];
string s[114514];
int a[114514],b[114514];
signed main(){
	ic(n) ic(a)
	c((n-1)/a+1)
}

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



unordered_map<int,list<int> > adj;

int dp[100005];


int solve(int src)
{
	if(dp[src]!=-1)
		return dp[src];



	if(adj[src].size()==0)
		return 0;

	int bestchild=0;
	for(auto child:adj[src])
	{
		bestchild=max(bestchild,solve(child));
	}


	dp[src]=bestchild+1;


	return dp[src];
}

int main()
{


	int n,m;
	cin>>n>>m;


	memset(dp,-1,sizeof(dp));


	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
	}

	int finalans=0;


	for(int i=1;i<=n;i++)
	{
		finalans=max(finalans,solve(i));
	}

	cout<<finalans<<endl;

}

Measured memory_bytes: 11428
h, w = map(int, input().split())
s = []

for i in range(h):
    a = input()
    s.append([str(m) for m in list(str(a))])

coi = 0
p = len(s)
for i in range(h):
    i = i - coi
    """if i > len(s) - 1 - coi:
        break"""
    #for j in range(w):
    if "#" not in s[i]:
        s.pop(i)
        p = len(s)
        coi += 1

coj = 0
for j in range(w):
    j = j - coj
    for i in range(len(s)):
        """if j > len(s[0]) - 1 - coj:
            break"""
        if "#" == s[i][j]:
            break
        if "." == s[i][j] and i == len(s) - 1:
            for m in range(len(s)):
                s[m].pop(j)
            coj += 1

t = []

for i in range(len(s)):
    t.append( ''.join(s[i]))

for i in range(len(t)):
    print(t[i])

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

#define mp(x, y) make_pair(x, y)

const int maxn = 5e5 + 10;

int nex1[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}, nex2[20][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}, {-2, -2}, {-2, -1}, {-2, 0}, {-2, 1}, {-2, 2}, {-1, 2}, {-1, -2}, {0, 2}, {0, -2}, {1, 2}, {1, -2}, {2, 2}, {2, 1}, {2, 0}, {2, -1}, {2, -2}};
int d[1005][1005];
char Map[10005][1005];
int n, m;
int check(int x, int y)
{
  if (x <= 0 || x > n || y <= 0 || y > m || Map[x][y] == '#')
    return 0;
  return 1;
}
void bfs(int a, int b)
{
  d[a][b] = 0;
  deque<pair<int, int> > que;
  que.push_back(mp(a, b));
  while (!que.empty())
  {
    int x, y;
    x = que.front().first, y = que.front().second;
    que.pop_front();
    for (int i = 0; i < 4; i++)
    {
      int _x = x + nex1[i][0], _y = y + nex1[i][1];
      if (check(_x, _y) && d[_x][_y]>d[x][y])
      {
        que.push_front(mp(_x, _y));
        d[_x][_y] = d[x][y];
      }
    }
    for (int i = 0; i < 20; i++)
    {
      int _x = x + nex2[i][0], _y = y + nex2[i][1];
      if (check(_x, _y) && d[_x][_y] > d[x][y]+1)
      {
        d[_x][_y] = d[x][y] + 1;
        que.push_back(mp(_x, _y));
      }
    }
  }
}
void init()
{
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      d[i][j] = 1e9;
}
void solve()
{
  cin>>n>>m;
  int x, y, tox, toy;
  cin>>x>>y>>tox>>toy;
  init();
  getchar();
  for (int i = 1; i <= n; i++)
    scanf("%s", Map[i] + 1);
  bfs(x, y);
  if (d[tox][toy] == 1e9)
    cout << -1 << endl;
  else
    cout << d[tox][toy] << endl;
}
signed main()
{
  solve();
  return 0;
}

Measured memory_bytes: 8576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int price = sc.nextInt();
        for(int i = 0;i <= 50000;i++){
          if(price == (int)(i * 1.08)){
            System.out.println(i);
            return;
          }
        }
      System.out.println(":(");
    }
}

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

int ans=0, N, M, a, b;
vector<vector<int>> G;

void search(int s, vector<int> chk) {
  chk[s]=1;
  if(accumulate(chk.begin(), chk.end(), 0)==N) {ans++; return;}
  for (auto t : G[s]){
    if(chk[t]==1) continue;
    else {
      search(t, chk);
    }
  }
  return;
}

int main() {
  cin >> N >> M;
  G = vector<vector<int>>(N, vector<int>(0));
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> chk(N,0);
  search(0, chk);
  
  cout << ans << "\n";
  return 0;
}

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

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, M;
  cin >> N >> M;

  vec v, l;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 1) v.push_back(b);
    if (b == 1) v.push_back(a);
    if (a == N) l.push_back(b);
    if (b == N) l.push_back(a);
  }

  sort(ALL(l));

  for (auto x : v) {
    if (binary_search(ALL(l), x)) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 2004
n = int(input())
l = [26 ** j for j in range(1, 15)]
for i in range(15):
  if n <= sum(l[:i]):
    x = i #文字数
    if i == 1:
      y = n - 1 #何個目か
    else:
      y = n - sum(l[:i-1]) - 1 #何個目か
    break
  else:
    pass
'''
m = []
for i in range(x):
  z = n % 26
  m.insert(0, z+96)
  n = n // 26

for i in range(len(m)):
  m[i] = chr(m[i])

print(''.join(m))
'''
m = []
for i in range(x):
  z = y % 26
  m.insert(0, z+97)
  y = y // 26
for i in range(len(m)):
  m[i] = chr(m[i])

print(''.join(m))

Measured memory_bytes: 9196
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n,aux;
	map<int,int>ma;
	bool t=true;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> aux;
		if(ma[aux]!=0) t=false;
		ma[aux]++;
	}	

	cout << (t  ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>

//?????¢??¢?´¢
int search(int A[], int n, int key){
	int i = 0;
	A[n] =key;
	while( A[i] != key ) i++;
	return i != n;
}

int main(void){
	int i,n,A[10000+1],q,key,sum = 0;
	
	scanf("%d",&n);
	for( i = 0; i < n; i++)scanf("%d",&A[i]);
	
	scanf("%d",&q);
	for( i = 0; i < q; i++){
	    scanf("%d",&key);
		if(search(A,n,key))sum++;
	}
	printf("%d\n",sum);
	
    return 0;
}

Measured memory_bytes: 640
#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 <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int my_abs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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

int main() {
    int N;
    int ans = 0;
    cin >> N;
    for (int i = 0; i <= N; i++) {
        ans = ans + i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

fn main() {
  input!{
    n: i64
  }
  for i in 1..=n {
    let mut ans = 0;
      for x in 1..(n as f64).sqrt().ceil() as i64 {
          for y in x..(n as f64).sqrt().ceil() as i64 {
              for z in y..(n as f64).sqrt().ceil() as i64 {
                  if x*x + y*y + z*z + x*y + y*z + z*x == i {
                      if x == y && y == z && z == x {
                        ans += 1;
                      }else if x != y && y != z && z != x {
                        ans += 6;
                      }else{
                        ans += 3;
                      }
                  }
              }
          }
      }
    println!("{}",ans);
  }  
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    string s;
    cin >>s;
    int n=s.size();

    int ans=0;
    int g=0,p=0;
    rep(i,n)
    {
        if(s[i]=='g')
        {
            if(p<g)
            {
                ++p;
                ++ans;
            }
            else ++g;
        }
        else
        {
            if(p<g) ++p;
            else
            {
                ++g;
                --ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int s;
  cin>>s;
  int d,f,g,h;
  d=s/3600;
  f=s%3600;
  g=f/60;
  h=f%60;
  cout<<d<<":"<<g<<":"<<h<<endl;
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string.h>

using namespace std;
bool IsPrime[1000001];

void calc()
{
	memset(IsPrime, 1, sizeof(IsPrime));
	IsPrime[0] = false;
	IsPrime[1] = false;
	for(int i = 2; i < 1000001; ++i)
	{
		if(IsPrime[i])
		{
			for(int j = 2 * i; j < 1000001; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		int temp = n / 2;
		for(int i = 0; i <= temp; ++i)
		{
			if(IsPrime[i] == 1 && IsPrime[n - i] == 1)
			{
				count++;
			}
		}
		cout << count << endl;
	}
}

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin>>s;
  	if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
    }
  	else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
    }
  	else if(s=="Rainy"){
    cout<<"Sunny"<<endl;
    }
}

Measured memory_bytes: 256
N,K = map(int,input().split())
*A, = map(int,input().split())
S = [0]*(N+1)
Sp = [0]*(N+1)
for i,a in enumerate(A,1):
    S[i] = S[i-1]+a
    Sp[i] = Sp[i-1] + max(0,a)
ans = 0
for i in range(N-K+1):
    ans = max(ans,max(0,S[K+i]-S[i]) + Sp[-1] - (Sp[K+i]-Sp[i]))
print(ans)

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
   int n;
   cin >> n;
   int x,y,b,p;
   int sum1,sum2;
   REP(i,n){
       cin >> x >> y >> b >> p;

       sum1=((x*5+y*2)*8)/10;
       if(b>5)sum1+=(x*(b-5)*8)/10;
       if(p>2)sum1+=(y*(p-2)*8)/10;

       sum2=x*b+y*p;
       cout << min(sum1,sum2) << endl;
   }
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;



int main() {
  int a,b,c,saidai,ans;cin >> a >> b >> c;
  saidai = max(a,b);
  saidai = max(saidai,c);
  ans = a*b*c/(saidai*2);
  cout << ans << endl;
  }



Measured memory_bytes: 256
/*input
abracadabra
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long freq[200005][26],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=1,sum=0,p,x,y;
	string a;
	cin>>a;
	for(int i=0;i<200005;++i)
		for(int j=0;j<26;++j)
			freq[i][j]=0;
	for(int i=a.size();i--;){
		for(int j=0;j<26;++j)
			freq[i][j]=freq[i+1][j];
		++freq[i][a[i]-'a'];
	}
	for(int i=0;i<a.size()-1;++i){
		sum=0;
		for(int j=0;j<26;++j){
			if(j==a[i]-'a') continue;
			ans+=freq[i+1][j];
		}
	}
	cout<<ans;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

	int n;
	cin>>n;
	int ans = 0;
	for(int i=1;i<n;i++) {
		ans+=n/i;
		if(n%i==0)
			ans--;
	}	
	cout<<ans;

	return 0;
}

Measured memory_bytes: 3632
A, B, C, D = map(int,input().split())
P = 998244353

memo = [[0]*(D+1) for _ in range(C+1)]

memo[A][B] = 1

for i in range(A,C+1):
  for j in range(B,D+1):
    memo[i][j] += i*memo[i][j-1] + j*memo[i-1][j] - (i-1)*(j-1)*memo[i-1][j-1]
    memo[i][j] %= P
    
print(memo[C][D])

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

int main() {
  	int a, c;
  	char b;
  	cin >> a >> b >> c;
	int total = a;
  	if(b == '+'){
      total += c;
    }
  	else{
    total -= c;
    }
  	cout << total << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n; string s;
	cin >> n >> s;
	int ans = 0;
	for(int ss = 0; ss < n; ss++){
		string si = s.substr(ss, n-ss);
		vector<int> z(si.size());
		int i = 1, j = 0;
		while(i < si.size()) {
			while(i+j < (int)si.size() && si[j]==si[i+j]) j++;
			
			z[i] = j;

			if(j==0) {
				i++;
				continue;
			}

			int k = 1;
			while(k < j && k + z[k] < j) {
				z[i+k] = z[k];
				k++;
			}

			i += k;
			j -= k;
		}
		for(i = 1; i < (int)si.size(); i++) {
			if(i >= z[i]) {
				chmax(ans, z[i]);
			}
		}
	}
	cout << ans << endl;
}

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

ll n,k,p[200000],x[200000];
set<int> st;

int main(){
    cin>>n>>k;
    ll ans=n-k+1;
    rep(i,n)cin>>p[i];
    rep(i,k)st.insert(p[i]);
    rep(i,n-k){
        st.insert(p[i+k]);
        auto itr=st.end();
        itr--;
        if(*st.begin()==p[i]&&*itr==p[i+k])ans--;
        st.erase(p[i]);
    }
    int aaa=0;
    for(int i=1;i<n;i++){
        if(p[i-1]<p[i])x[i]=x[i-1]+1;
        if(x[i]==k-1)ans--,aaa=1;
    }
    cout<<ans+aaa<<endl;
}

Measured memory_bytes: 12800
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = ReadIntArray();
            int A = abc[0], B = abc[1], C = abc[2];
            if (A != B || B != C || C != A) Out("No");
            else Out("Yes");
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL<<60;
vector<int> mx;
vector<int> c;
vector<vector<int>> a;
int n,m,x;
bool check(vector<int> ch){
    bool flag = true;
    for(auto &i:ch){
        //cout << i << " ";
        if(i>0) flag = false;
    }
    //cout << endl;
    return flag;
}


int main(){
    cin >> n >> m >> x;
    mx.assign(m,x);
    c.resize(n);
    a.assign(n,vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    Int ans = INF;
    for(int bit = 0;bit < (1<<n);bit++){
        vector<int> mx(m,x);
        Int sum = 0;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                rep(gg,m){
                    mx[gg]-=a[i][gg];
                }
                sum+=c[i];
            }
        }
        if(check(mx)) chmin(ans,sum);
    }
    cout << (ans==INF?-1:ans) << endl;
}

Measured memory_bytes: 3632
/*input
999
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

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


ll power(ll a,ll m,ll mod){
    ll ans=1;
    while(m){
        if(m%2){
            ans*=a;
            ans%=(mod);
        }
        a=(a*a)%(mod);
        m>>=1;
    }
    return ans;
}


void init(ll* a,ll n,ll val){
    for(ll i=0;i<n;i++)
        a[i]=val;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll t=1,i,j;
    ld ans=0.0;
    ll l;
    cin>>l;
    ans=l/(ld)3;
    cout<<setprecision(30)<<pow(ans,3);
    return 0;
}




Measured memory_bytes: 512
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {

    auto tmp = readln.split.to!(int[]);
    auto M = tmp[0], N = tmp[1], X = tmp[2];
    auto a = readln.split.to!(int[]);

    auto left = a.filter!(x => x < X).walkLength;
    auto right = a.filter!(x => x > X).walkLength;

    writeln(min(left, right));
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int answer=0;
    for(int i=0;i<n/2;i++){
      if(s.substring(i,i+1).equals(s.substring(n-i-1,n-i))){
        answer=answer+0;
      }else{
        answer=answer+1;
      }
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <set>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
const int maxn = 1e5 + 100;
struct p{
    int x,y,t;
}a[maxn];
bool cmp(p a,p b){
     return a.t < b.t;
}
int main(){
    int N;
    scanf("%d",&N);
    for (int i = 0; i < N; i++){
        scanf("%d%d%d",&a[i].t,&a[i].x,&a[i].y);
    }
    a[N].t = 0;
    a[N].x = 0;
    a[N].y = 0;
    sort(a,a + N + 1, cmp);
    for (int i = 1; i <= N; i++){
        if (a[i].t == a[i - 1].t)
        {
             printf("No\n");
             return 0;
        }
        int dis = abs(a[i].x - a[i - 1].x)  + abs(a[i].y - a[i - 1].y);
        int t = abs(a[i].t - a[i - 1].t);
        if (dis > t)
        {
             printf("No\n");
             return 0;
        }else 
        {
            if (dis < t)
            {
                if ((t - dis) & 1)
                {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y<a.y;
        return y>a.y;
    }
};
vector<P> v1,v2;
vector<int> v;
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
int o[311];
long long l[311][100000];
long long j[311][100000];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
int px[10]={-1,1,1,-1,1,1,-1,-1},py[10]={1,1,-1,-1,1,-1,1,-1};
long long mod=998244353,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s,s1;

priority_queue<P> q;
//queue<int> q;
//string r;

char r[211111],r2[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());

bool as(P a,P b)
{

    return a.y<b.y;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

long long f(int n,int m)
{
    if(m<0) return 0;
    if(n>a)
    {
        if(m) return 0;
        return 1;
    }
    if(l[n][m]>=0) return l[n][m];
    return l[n][m]=(f(n+1,m)*2%mod+f(n+1,m-o[n])%mod)%mod;

}

long long g(int n,int m)
{
    if(m<0) return 0;
    if(n>a)
    {
        if(m) return 0;
        return 1;
    }
    if(j[n][m]>=0) return j[n][m];
    return j[n][m]=(g(n+1,m)%mod+g(n+1,m-o[n])%mod)%mod;

}

int main()
{
    memset(l,-1,sizeof(l));
    memset(j,-1,sizeof(j));
    scanf("%d",&a);
    for(int t=1;t<=a;d+=o[t],t++)
        scanf("%d",&o[t]);
    b=d/2;
    if(d%2) b++;
    //printf("%d\n",d);
    for(int t=0;t<b;t++)
        x+=f(1,t),x%=mod;
    for(int t=b;t<=d;t++)
        x+=(mod-f(1,t))*2,x%=mod;
    if(d%2==0) x+=g(1,d/2)*3%mod,x%=mod;
    printf("%lld",x);
}



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

int main(){
  string a; cin>>a;
  if(a.length()%2==1)cout<<"No";
  else{
    bool ok;
  rep(i,a.length()){
    ok=false;
    if(i%2==1){if(a[i-1]!='h')break;}
    else{if(a[i-1]!='i')break;}
    ok=true;
  }
  cout<<(ok?"Yes":"No");
  }

}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
  int D,N;
  cin>>D>>N;
  if(N==100){N+=1;}
  if(D==0){cout<<N<<endl;}
  else{
    cout<<(int)pow(100,D)*N<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;

int main() {
    long N,K;
    double ans=0;
    cin >> N >> K;

    vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    
    vector<int> s(N+1, 0);
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

    long long res = -INF,lres = -1, rres = N+1; // 最初は無限小の値に初期化しておく

    for (int i = 0; i <= N-K; ++i) {
            long long val = s[K+i] - s[i];
            long left = i;
            long right = K+i;
            if (res < val){
                res = val;
                lres = left;
                rres = right;
            } 
    }

    for (int i = lres; i <= rres-1; ++i) {
        long long s=0;
        double t = a.at(i);
        long j=1;
        while(j<=a.at(i)){
            s = s+j;
            j++;
        }
        //cout << a.at(i) << " " << s << endl;
        ans += s/t;
    }

    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

const ll M = 1000000007;

vector<ll> fac(2005); //n!(mod M)
vector<ll> ifac(2006); //k!^{M-2} (mod M)

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

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

int main()
{
	ll n, k; cin >> n >> k;
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 2001; i++)
	{
		fac[i + 1] = fac[i] * (i + 1) % M; 
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; 
	}
	
	rep(i, 1, k)
	{
		if (n - k + 1 < i)
		{
			cout << 0 << endl;
			continue;
		}
		ll c = i;
		ll fo = comb(n - k + 1, c);
		ll af = comb(k - 1, c - 1);
		cout << fo * af % M << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int f(int x) {
    int res = 0;
    while (x%2 == 0) {
        x /= 2;
        res++;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    int ans = 0;
    rep(i, n) {
        cin >> a[i];
        ans += f(a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict


n, m = map(int, input().split())
rel = defaultdict(set)

for _ in range(m):
    p, r = map(int, input().split())
    rel[p].add(r)
    rel[r].add(p)


color = defaultdict(int)

def search(f, c):
    stack = [f]
    color[f] = c
    while stack:
        u = stack.pop()
        for v in rel[u]:
            if not color[v]:
                color[v] = c
                stack.append(v)


# assign color
cl = 0
for i in range(n):
    if not color[i]:
        cl += 1
        search(i, cl)

qn = int(input())

for _ in range(qn):
    f, l = map(int, input().split())
    print(['no', 'yes'][color[f] == color[l]])






Measured memory_bytes: 50980
import sys
N=int(input())
a=list(map(int,input().split()))
for i in a:
  if i==0:
    print(0)
    sys.exit()
    
ans=1
for i in a:
  ans*=i
  if 1e18<ans:
    print("-1")
    sys.exit()
  
print(ans)

Measured memory_bytes: 21616
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       String s = sc.next();
        StringBuilder sb = new StringBuilder(s);
        System.out.println(s.equals(sb.reverse().toString())? "Yes":"No");
                
    }
 
            
    
}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using P = function<E(E,size_t)>;
  int n;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,H h,T ti,E ei,
	      P p=[](E a,size_t b){b++;return a;}):
    f(f),g(g),h(h),ti(ti),ei(ei),p(p){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,ti);
    laz.clear();
    laz.resize(2*n-1,ei);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int a,int b,E x,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
    dat[k]=f(g(dat[k*2+1],p(laz[k*2+1],(r-l)>>1)),
	     g(dat[k*2+2],p(laz[k*2+2],(r-l)>>1)));
  }
  void update(int a,int b,E x){
    update(a,b,x,0,0,n);
  }
  T query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return ti;
    if(a<=l&&r<=b) return g(dat[k],p(laz[k],r-l));
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return g(f(vl,vr),p(laz[k],min(r,b)-max(l,a)));
  }
  T query(int a,int b){
    return query(a,b,0,0,n);
  }
};
//END CUT HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  SegmentTree<Int, Int>::F f=[](Int a,Int b){return min(a,b);};
  SegmentTree<Int, Int>::G g=[](Int a,Int b){return a+b;};
  const Int INF = 1e15;
  SegmentTree<Int, Int> seg(n,f,g,g,INF,0);
  seg.build(n,vector<Int>(n,0));
  for(Int i=0;i<q;i++){
    Int a,s,t,x;
    cin>>a>>s>>t;
    t++;
    if(a) cout<<seg.query(s,t)<<endl;
    if(!a){
      cin>>x;
      seg.update(s,t,x);
    }
  }
  return 0;
}
/*
  verified on 2018/03/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_H&lang=jp
*/



Measured memory_bytes: 7624
S=input()

if S[0]==S[1]==S[2]:
  if S[0]=='R':
    print(3)
  else:
    print(0)
elif S[0]==S[1]:
  if S[0]=='R':
    print(2)
  else:
    print(1)
elif S[1]==S[2]:
  if S[1]=='R':
    print(2)
  else:
    print(1)
else:
  print(1)

Measured memory_bytes: 9124
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for i in range(m):
  s=heapq.heappop(a)*(-1)
  heapq.heappush(a, (s//2)*(-1))

print(sum(a)*(-1))

Measured memory_bytes: 92184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    int N=in();
    int a[N];
    rep(i, N){
        cin>>a[i];
    }
    sort(a, a+N);
    int count=1;
    int ans=0;
    rep(i, N-1){
        if(a[i]==a[i+1]){
            count++;
        }
        else{
            ans+=count%2;
            count=1;
        }
    }
    ans+=count%2;
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	int a[n + 1], b[n + 1];
	FOR (i, 1, n)
	{
	    cin >> a[i] >> b[i];
	    if (i >= 3 && (a[i] == b[i] && a[i - 1] == b[i-1] && a[i-2]==b[i-2])) 
	    {
	        cout << "Yes";
	        return 0;
	    }
	}
	cout << "No";
}



















Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string S;
    cin >> S;
    if (S.front() != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    ll C_count = 0;
    unsigned int C_pos;
    for (unsigned int i = 2; i < S.size() - 1 ; i++){
        if (S.at(i) == 'C'){
            C_count++;
            C_pos = i;
        }
    }
    if (C_count != 1){
        cout << "WA" << endl;
        return 0;
    }
    for (unsigned int i = 1; i < S.size(); i++){
        if (isupper(S.at(i)) && i != C_pos){
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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





using namespace std;
int main() {
	
	
	string p;
	cin >> p;
	for (int i = 1; i < 4; i++) {
		if (p[i] == p[i - 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256