akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n,d,a; cin >> n >> d >> a;
	vpl v(n);
	rep(i,n) cin >> v[i].first >> v[i].second;
	rep(i,n) v[i].second = (v[i].second + a - 1) / a;
	sort(all(v));
	vl x(n);
	rep(i,n) x[i] = v[i].first;
	ll ans = 0;
	ll now = 0;
	vl minus(n,0);
	ll index = 0;
	ll bomb;
	while(index < n){
		bomb = v[index].first + d;
		auto itr = upper_bound(all(x),bomb + d);
		itr--;
		ll right = itr - x.begin();
		now += v[index].second;
		minus[right] += v[index].second;
		ans += v[index].second;
		while(index < n){
			v[index].second -= now;
			now -= minus[index];
			minus[index] = 0;
			if(v[index].second > 0) break;
			index++;
		}
	}
	cout << ans << endl;
	//rep(i,n) cout << minus[i] << " ";
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(ll sz) {
    data.assign(++sz, 0);
  }

  T sum(ll k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(ll k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


ll N,K;
vector<ll> A;
void input(){
    fast_io();
    cin >> N >> K;
    A = fetch_vec<ll>(N);
}

int solve(){
    vector<ll> S(N+1),T(N+1);
    for (int i = 0; i < N; i++)
    {
        S[i+1] = S[i]+A[i];
    }
    for (int i = 0; i <= N; i++)
    {
        T[i] = S[i]-K*i;
    }
    map<ll, ll > st;
    for(auto t:T) st[t] = 0;
    int cnt = 0;
    for(auto &p:st) {p.second = cnt; cnt++;}
    for(auto &t:T) t = st[t];
    BinaryIndexedTree< ll > bit(N+10);
    ll ans = 0;
    for (int i = 0; i <= N; i++)
    {
        ans += bit.sum(T[i]);
        bit.add(T[i],1LL);
    }
    cout << ans << endl;   
    return 0;
}   

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

Measured memory_bytes: 21916
#include <stdio.h>
int main(){
	int yamataka[10], max;
	for(int i = 0; i < 10; i++){
		scanf("%d", &yamataka[i]);
	}
	for(int i = 0; i < 3; i++){
		max = 0;
		for(int j = 0; j < 10; j++){
			if(yamataka[j] > yamataka[max]) max = j;
		}
		printf("%d\n", yamataka[max]);
		yamataka[max] = 0;
	}
	return 0;
}

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

using namespace std;


int main()
{
    int N;
    while(cin >> N, N){
        int n;
        vector<int> ns{};
        for(int i=0;i<N;++i) { cin >> n; ns.push_back(n); }
        
        int rem = 32, idx = 0;
        while(rem){
            rem -= (rem - 1) % 5;
            cout << rem << endl;
            rem -= min(ns[idx % N], rem);
            cout << rem << endl;
            ++idx;
        }
    }
}

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

#define fastIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL);
#define asc(s) sort(s.begin(), s.end())
#define des(s) sort(s.rbegin(), s.rend())
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define rev(v) reverse(v.begin(), v.end())
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define precision(x, p) fixed << setprecision(p) << x
#define set_bits(n) __builtin_popcount(n);
#define mod 1000000007
#define PI 3.14159265358979
typedef long long ll;

#ifndef ONLINE_JUDGE
#define debug(x) cout << x << endl;
#else
#define debug(x)
#endif

template <class T>
T gcd(T a, T b)
{
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) { return a * b / gcd(a, b); };

vector<string> split(string s)
{
    istringstream buf(s);
    istream_iterator<string> beg(buf), end;
    vector<string> list(beg, end);
    return list;
}

bool isvowel(char c)
{
    string s = "aeiou";
    if (find(s.begin(), s.end(), c) != s.end())
        return true;
    return false;
}

bool cmp(pair<int, int> &a, pair<int, int> &b)
{
    return a.second > b.second || (a.second == b.second && a.first > b.first);
}

bool isprime(ll n)
{
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0)
            return false;

    return true && (n != 1);
}

void solve()
{
    ll n;
    cin >> n;

    map<string, ll> count;
    string s;

    for (int i = 0; i < n; i++)
    {
        cin >> s;
        asc(s);
        count[s]++;
    }

    ll ans = 0;

    for (auto x : count)
    {
        ans += (x.second * (x.second - 1)) / 2;
    }

    cout << ans;
}

int main()
{
    fastIO

        int t = 1;
    // cin>>t;

    for (int test_case = 1; test_case <= t; test_case++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11264
a, b, c = map(int, input().split())
k = int(input())
ans = "No"
for i in range(k):
  if (a<b)and(b<c):
    ans = "Yes"
    break
  elif b<=a:
    b=b*2
  elif c<=b:
    c=c*2
if (a<b)and(b<c):
    ans = "Yes"
print(ans)

Measured memory_bytes: 9136
#include<iostream>
#include<string>

using namespace std;

int main(int argc, char* argv[])
{
  string input, ring, target;
  string::size_type flag;
  cin >> input >> target;
  ring = input + input;
  flag = ring.find(target);
  if(flag==string::npos) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3188
n=gets.to_i
v=gets.chomp.split(" ").map(&:to_i)
c=gets.chomp.split(" ").map(&:to_i)

x=0
y=0

for i in 0..n-1 do
    if v[i]>c[i] then
        x+=v[i]
        y+=c[i]
    end
end

puts x-y

Measured memory_bytes: 1788
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

data = {"r": P, "s": R, "p": S}
ans = 0

for i in range(K):
    hand = T[i]
    ans += data[hand]

    for j in range(i + K, N, K):
        if T[j] == hand:
            hand = "other"
        else:
            hand = T[j]
            ans += data[hand]

print(ans)


Measured memory_bytes: 3316
def find(x, root)
  return unless @group[x]
  return true if @group[x].include?(root)
  @group[x].each do |m|
    return true if find(m, root)
  end
  false
end

while n = gets.to_i
  break if n == 0
  root = ''
  @group = {}
  n.times do |i|
    g, m = gets.split(':')
    root = g if i == 0
    ms = m[0..-3].split(',')
    ms.each{ |m| @group[m] ||= []; @group[m] << g }
  end
  cnt = 0
  @group.keys.each do |name|
    if find(name, root) && !@group.values.flatten.include?(name)
      cnt += 1
    end
  end
  p cnt
end

Measured memory_bytes: 28120
KEYENCE = 'keyence'


def keyence_string(s: str) -> bool:
    i = 0
    for i, c in enumerate(KEYENCE):
        if s[i] != c:
            break

    return s.endswith(KEYENCE[i:])


if __name__ == "__main__":
    s = input()

    if keyence_string(s):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 2940
from math import gcd
from time import time


def main():
    K = int(input())
    answer = 0

    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                answer += gcd(gcd(a, b), c)
    print(answer)

if __name__ == '__main__':
    start = time()
    main()
    # print(time() - start)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007

map<string, int> m;



int main()
{
	FAST;
	m["SUN"] = 7;
	m["MON"] = 6;
	m["TUE"] = 5;
	m["WED"] = 4;
	m["THU"] = 3;
	m["FRI"] = 2;
	m["SAT"] = 1;
	string s;
	cin >> s;
	cout << m[s];
	return 0;
}

Measured memory_bytes: 3656
from sys import stdin, exit
A = list(stdin.readline().rstrip())
B = list(stdin.readline().rstrip())
C = list(stdin.readline().rstrip())
cards = {"a": A, "b": B, "c": C}
turn = "a"
flag = True
while flag:
  if len(cards[turn]) == 0:
    print(turn.upper())
    exit()
  turn = cards[turn].pop(0)

Measured memory_bytes: 3060
n = int(input())
a, b = list(map(int, input().split()))
ps = list(map(int, input().split()))

num1 = 0
num2 = 0

for p in ps:
    if p <= a:
        num1 += 1
    elif p <= b:
        num2 += 1
num3 = n - num1 - num2
print(min([num1, num2, num3]))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main()
{
	char s[30];
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++)
		for(int j=i+1;j<len;j++)
			if(s[i]==s[j])
				goto wa;
	printf("yes\n");
	return 0;
wa:;
	printf("no\n");
	return 0;
}


Measured memory_bytes: 256
def main():

    n = int(input())
    alph = 'abcdefghijklmnopqrstuvwxyz'
    ans = ''
    while n > 0:
        n -= 1
        rem = n % 26
        ans += alph[rem]
        n //= 26

    ans = ans[::-1] # 文字列の反転
    print(f'{ans}')


if __name__ == '__main__':
    main()

Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}

const int MOD = 1e9+7; //998244353;
V<ll>Fac,Rac;void setF(int n,int mod=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%mod;Rac[n-1]=modInv(Fac[n-1],mod);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%mod;}
ll comb(int a,int b,int m=MOD){return (a<0||b<0)?0:Fac[a+b]*Rac[b]%m*Rac[a]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 1e5;
int h, w, n;
V<P<int, int>> v;
ll DP[3000];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  setF(N*2);
  cin >> h >> w >> n;
  FOR(i, 0, n){
    int r, c;
    cin >> r >> c;
    r--; c--;
    v.eb(r, c);
  }
  sort(all(v));
  h--, w--;
  ll ans = comb(h, w);
  FOR(i, 0, n){
    DP[i] = comb(v[i].fi, v[i].se);
    FOR(j, 0, i) DP[i] -= DP[j]*comb(v[i].fi-v[j].fi, v[i].se-v[j].se)%MOD;
    DP[i] %= MOD;
    ans -= DP[i]*comb(h-v[i].fi, w-v[i].se)%MOD;
  }
  cout << (ans%MOD+MOD)%MOD << endl;
}

Measured memory_bytes: 3456
D,G = map(int,input().split())
L = [list(map(int,input().split())) for i in range(D)]

ans = float("inf")
for bit in range(2 ** D) :
    score = 0
    AC = 0
    for k in range(D) :
        if bit & (1 << k) :
            p,c = L[k]
            score += c
            AC += p
            score += p*(k+1)*100
    if score >= G :
        ans = min(ans,AC)
        continue
    for k in range(D-1,-1,-1) :
        if bit & (1 << k) :
            continue
        p,c = L[k]
        if (score + p*(k+1)*100) < G :
            score += p*(k+1)*100
            AC += p
        else :
            rem = G - score
            AC += rem // ((k+1)*100)
            if rem % ((k+1)*100) != 0 :
                AC += 1
            ans = min(ans,AC)
            break
print(ans)



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

int main(){
    int n;cin>>n;
    ll ans=-100000000000;
    ll ans_m=-100000000000;
    vector<vector<int>> f(n,vector<int>(10));
    vector<vector<int>> p(n,vector<int>(11));
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>f[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++) cin>>p[i][j];
    }
    for(int bit=1;bit < (1 << 10);bit++){
        ans=0;
        for(int i=0;i<n;i++){
            int count=0;
            for(int j=0;j<10;j++){
                if((bit>>j&1)&&f[i][j]){
                    count++;
                }
            }
            ans+=p[i][count];
        }
        ans_m=max(ans_m,ans);
    }
    cout<<ans_m<<endl;
}

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

int main()
{
    int N; cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; ++i) { cin >> S[i]; }
    int M; cin >> M;
    vector<string> T(M);
    for (int i = 0; i < M; ++i) { cin >> T[i]; }

    map<string, int> mp;
    for (const auto& s : S) { mp[s]++; }
    for (const auto& t : T) { mp[t]--; }

    int ans = 0;
    for (const auto& p : mp)
    {
        if (ans < p.second) { ans = p.second; }
    }

    cout << ans << "\n";

    return 0;
}



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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

ll xorotn(ll n){
    switch(n&3){
        case 0: return n;
        case 1: return 1;
        case 2: return n+1;
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    ll A,B;
    cin >>A>>B;
    cout << (xorotn(A-1)^xorotn(B)) <<endl;
    return (0);
}

Measured memory_bytes: 256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


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

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 105;

int N;
int A[MAXN];

void input()
{
    read(N);
    for (int i = 1; i <= N; ++i) {
        read(A[i]);
    }
}

void solve()
{
    static int cnt[MAXN];
    int d = *std::max_element(A + 1, A + N + 1);

    for (int i = 1; i <= N; ++i) {
        cnt[A[i]] += 1;
    }
    for (int i = d; i * 2 > d; --i) {
        if (cnt[i] < 2) {
            puts("Impossible");
            return;
        }
    }
    if (d % 2 == 0 && cnt[d / 2] != 1) {
        puts("Impossible");
        return;
    }
    if (d % 2 == 1 && cnt[d / 2 + 1] != 2) {
        puts("Impossible");
        return;
    }
    for (int i = (d - 1) / 2; i >= 1; --i) {
        if (cnt[i] > 0) {
            puts("Impossible");
            return;
        }
    }

    puts("Possible");
}

int main()
{
#ifdef __DEBUG
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 心似双丝网，中有千千结。
//     -- 张先《千秋岁·数声鶗鴂》


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

int     main() {
        long N, S=0, SS=0, p;
        cin >>N;
        for (long i=0; i<N; i++) {
                cin >> p;
                S=max(S, p);
                SS += p;
        }
        S /=2;
        SS -= S;
        cout << SS << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdint>

constexpr std::int64_t kModulus = 1000000007;

std::int64_t ExtendedGCD(std::int64_t a, std::int64_t b,
                         std::int64_t& x, std::int64_t& y) {
  auto c = a;
  if (b == 0) {
    x = 1;
    y = 0;
  } else {
    c = ExtendedGCD(b, a % b, y, x);
    y -= a / b * x;
  }
  return c;
}

std::int64_t Inverse(std::int64_t n) {
  std::int64_t x, y;
  ExtendedGCD(n, kModulus, x, y);
  return (x % kModulus + kModulus) % kModulus;
}

int main() {
  int K;
  std::string S;
  std::cin >> K >> S;
  const int N = S.size();
  std::int64_t count = 1;
  for (int i = 0; i < K; ++i) {
    count = count * 26 % kModulus;
  }
  const auto ratio_count = Inverse(26) * 25 % kModulus;
  std::int64_t combination = 1;
  std::int64_t sum = 0;
  for (int i = 0; i <= K; ++i) {
    sum = (sum + combination * count) % kModulus;
    count = count * ratio_count % kModulus;
    auto delta_combination = combination * (N - 1) % kModulus * Inverse(i + 1) % kModulus;
    combination = (combination + delta_combination) % kModulus;
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 5280
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 998244353
#define mp make_pair
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%lld",&a)
#define pf printf
#define sz(a) (ll)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,wt;
	cin>>n>>wt;
	int w[n],v[n];
	f(i,0,n)
		cin>>w[i]>>v[i];
	ll dp[n+1][wt+1];
	f(i,0,n+1)
		dp[i][0]=0;
	f(i,0,wt+1)
		dp[0][i]=0;
	f(i,1,n+1)
	{
		f(j,1,wt+1)
		{
			if(w[i-1]>j)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
		}
	}
	cout<<dp[n][wt];
}

Measured memory_bytes: 79104
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
const int maxn=200005;
int ans;
string str;
int main()
{
	cin>>str;
	ans=str.length();
	for(int i=0;i<(int)str.length()-1;i++)
		if(str[i]==str[i+1])
		{
			ans--;
			i+=2;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
a = input()
b = a.split()
c = list(map(int,b))
if c[4] <= c[2] and c[2] <= c[0]-c[4]:
    if c[4] <= c[3] and c[3] <= c[1]-c[4]:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 5596
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	for(int i=0;i<3;i++)
		scanf("%d",&a[i]);
	sort(a,a+3);
	int ans=a[2]*10+a[1]+a[0];
	printf("%d\n",ans);
}

Measured memory_bytes: 128
<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

if(strlen($a) > strlen($b)){
    echo "GREATER";
}elseif(strlen($a) > strlen($b)){
    echo "LESS";
}else{
    if($a > $b){
        echo "GREATER";
    }elseif($a < $b){
        echo "LESS";
    }else{
        echo "EQUAL";
    }
}

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

int main(void)
{
    ll n;
    string s;
    map<char, ll> mp;
    mp['R'] = 0;
    mp['G'] = 0;
    mp['B'] = 0;
    cin >> n >> s;
    rep(i, 0, n) mp[s[i]]++;
    if (mp.size() != 3)
        cout << 0 << endl;
    else
    {

        ll ans = 1;
        for (auto i : mp)
            ans *= i.second;
        ll cta = 0;

        rep(i, 0, n)
        {
            rep(j, i + 1, n)
            {
                if (j + (j - i) >= n)
                    continue;
                if (s[i] != s[j] && s[j] != s[j + (j - i)] && s[j + (j - i)] != s[i])
                    cta++;
            }
        }
        cout << ans - cta << endl;
    }
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
#define F first
#define S second
#define RE register
#define random(x) (rand()%x)
#define LOG(a,b) (log(a)/log(b))
#define N 200005
#define mod 1000000007
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3fll
int n,lgn,q,k,x[N],lp[22][N],rp[22][N];
ll lsz[22][N],rsz[22][N];
int main(){
	scanf("%d%d",&n,&k);
	lgn=log2(n);
	for(int i=1;i<=n;++i){
		scanf("%d",x+i);
	}
	for(int i=0;i<=lgn;++i) rp[i][n+1]=n+1;
	for(int i=1;i<=n;++i){
		lp[0][i]=lower_bound(x+1,x+n+1,x[i]-k+1)-x-1;
		lsz[0][i]=lp[0][i];
		//printf("(%d:%d,%lld) ",0,lp[0][i],lsz[0][i]);
		for(int j=1;j<=lgn;++j){
			lp[j][i]=lp[j-1][lp[j-1][i]];
			lsz[j][i]=lsz[j-1][i]+lsz[j-1][lp[j-1][i]];
			//printf("(%d:%d,%lld) ",j,lp[j][i],lsz[j][i]);
		}
		//puts("");
	}
	for(int i=n;i;--i){
		rp[0][i]=lower_bound(x+1,x+n+1,x[i]+k)-x;
		rsz[0][i]=rp[0][i];
		for(int j=1;j<=lgn;++j){
			rp[j][i]=rp[j-1][rp[j-1][i]];
			rsz[j][i]=rsz[j-1][i]+rsz[j-1][rp[j-1][i]];
			//printf("(%d:%d,%lld) ",j,rp[j][i],rsz[j][i]);
		}
		//puts("");
	}
	scanf("%d",&q);
	int ql,qr,p,cntl=1,cntr=1;
	ll ansl=0,ansr=0;
	for(int i=1;i<=q;++i){
		scanf("%d%d",&ql,&qr);
		p=ql;ansl=ql;cntl=1;
		for(int j=lgn;j>=0;--j){
			if(rp[j][p]<=qr){
				cntl+=(1<<j);
				ansl+=rsz[j][p];
				p=rp[j][p];
			}
			//printf("%d:%d %d\n",j,p,ansl);
		}
		p=qr;ansr=qr;cntr=1;
		for(int j=lgn;j>=0;--j){
			if(lp[j][p]>=ql){
				cntr+=(1<<j);
				ansr+=lsz[j][p];
				p=lp[j][p];
			}
			//printf("%d:%d %d\n",j,p,ansr);
		}
		//printf("%d %d\n",cntl,cntr);
		assert(cntl==cntr);
		printf("%lld\n",ansr-ansl+cntl);
	}
	return 0;
}

Measured memory_bytes: 88940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,ll> P;

ll cost[10][10];
ll dist[10][10];


int main(){
    ll h,w;
    cin>>h>>w;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>cost[i][j];
            dist[i][j]=(ll)INF;
        }
    }
    for(int i=0;i<10;i++){
        priority_queue<P,vector<P>,greater<P> >pq;
        dist[i][i]=0;
        pq.push(P(i,0));
        while(!pq.empty()){
            P p = pq.top();
            pq.pop();
            ll now = p.first;
            ll d = p.second;
            for(int next=0;next<=9;next++){
                if(next==now)continue;
                if(dist[i][next]>d+cost[now][next]){
                    dist[i][next]=d+cost[now][next];
                    pq.push(P(next,d+cost[now][next]));
                }
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;
            cin>>a;
            if(a!=-1){
                //cout<<dist[a][1]<<endl;
                ans+=dist[a][1];
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
void trace(int a[],int n){
int i;
for(int i=0;i<n;i++){
if(i>0) printf(" ");
printf("%d",a[i]);
}
printf("\n");
}
void insertionsort(int a[],int n){
int j,i,v;
for(int i=1;i<=n-1;i++){
v=a[i];
j=i-1;
while(j>=0&&a[j]>v){
a[j+1]=a[j];
j--;
}
a[j+1]=v;
trace(a,n);
}
}
int main(){
int n,i,j;
int a[105];
scanf("%d",&n);
for (int i=0;i<=n;i++)
scanf("%d",&a[i]);
trace(a,n);
insertionsort(a,n);
return 0;
}

Measured memory_bytes: 2668
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ROBOT_MAX		100000									// 最大ロボット数

// 内部構造体 - ロボット情報
typedef struct Robot {
	int miPos;													// 位置
	int miLen;													// 長さ
} Robot;

// 内部変数
static FILE *szpFpI;											// 入力
static Robot sz1Robot[D_ROBOT_MAX];								// ロボット
static int siRCnt;												// ロボット数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// ソート関数 - 位置昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Robot *lzpVal1 = (Robot *)pzpVal1;
	Robot *lzpVal2 = (Robot *)pzpVal2;

	// 位置昇順
	if (lzpVal1->miPos > lzpVal2->miPos) {
		return 1;
	}
	else if (lzpVal1->miPos < lzpVal2->miPos) {
		return -1;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// ロボット数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siRCnt);

	// ロボット - 取得
	for (i = 0; i < siRCnt; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &sz1Robot[i].miPos, &sz1Robot[i].miLen);
	}
	qsort(sz1Robot, siRCnt, sizeof(Robot), fSortFnc);

	// 最大個数 - 取得
	int liCnt = 0;
	int liNow = INT_MIN;
	for (i = 0; i < siRCnt; i++) {
		int liL = sz1Robot[i].miPos - sz1Robot[i].miLen;
		int liR = sz1Robot[i].miPos + sz1Robot[i].miLen;

		// 重複チェック
		if (liNow <= liL) {				// なし
			liCnt++;
			liNow = liR;
		}
		else {							// あり
			if (liNow > liR) {
				liNow = liR;
			}
		}
	}

	return liCnt;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

int N, M;
vector<int> hh, ww;

#define MAX 1500001

int main(void)
{
	while (cin >> N >> M, N|M) {
		hh = vector<int>(N+1, 0);
		ww = vector<int>(M+1, 0);

		REPI(i, 1, N) {
			cin >> hh[i];
			hh[i] += hh[i-1];
		}
		REPI(i, 1, M) {
			cin >> ww[i];
			ww[i] += ww[i-1];
		}

		int cnt = 0;
		int wd[MAX];

		memset(wd, 0, sizeof(wd));
		rep(i, ww.size())
			REP(j, i+1, ww.size())
				wd[ww[j]-ww[i]]++;

		rep(i, hh.size())
			REP(j, i+1, hh.size())
				cnt += wd[hh[j]-hh[i]];

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

Measured memory_bytes: 7104
N = list(map(int, list(input())))
N.reverse()
N.append(0)
res = 0
f = False
for i in range(len(N)-1):
    n = N[i]
    if n < 5:
        res += n
    else:
        if n == 5:
            if N[i+1] >= 5:
                N[i+1] += 1
        else:
            N[i+1] += 1
        res += 10-n

if N[-1] > 0:
    res += 1

print(res)

Measured memory_bytes: 21220
#include <cstdio>
int H,W;
char ch[100][100];
void dfs(int y,int x,char c)
{
	ch[y][x]='0';
	int dx,dy;
	int sy,sx;
	for(dx=-1;dx<=1;dx++)
	for(dy=-1;dy<=1;dy++)
	{
		if(dx*dy!=0)continue;
		sx=dx+x;
		sy=dy+y;
		if(sy>=0&&sy<H&&sx>=0&&sx<W&&ch[sy][sx]==c)
		{
			dfs(sy,sx,c);
		}
	}
	
}
int main()
{
	scanf("%d %d",&H,&W);
	int i,j;
	do{
		getchar();
		int count=0;
	for( i=0;i<H;i++)
	for(j=0;j<W;j++)
	{
		if(i!=0&&j==0) getchar();
		scanf("%c",&ch[i][j]);
	
	}
	char und;
	for(i=0;i<H;i++)
	for(j=0;j<W;j++)
	{
		if(ch[i][j]=='0')continue;
		und=ch[i][j];
			dfs(i,j,und);
			count++;
	
		
	}
	printf("%d\n",count);
	scanf("%d %d",&H,&W);
}while(H*H+W*W!=0);

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N;
ll s[100010];
vector<int> G[100010];
int sz[100010];
using P = pair<int,int>;
map<P,int> e2i;
ll ans[100010];

int v2 = -1, p2 = -1;
ll dfs(int v,int p=-1){
	ll res = 0;
	for(int u:G[v]) if(u!=p) res += dfs(u,v);

	sz[v] = 1;
	for(int u:G[v]) if(u!=p){
		sz[v] += sz[u];
	}
	if(p!=-1){
		int i = e2i[P(v,p)];
		if(sz[v]!=N-sz[v]){
			ans[i] = (s[p]-s[v])/(sz[v]-(N-sz[v]));
		}else{
			v2 = v;
			p2 = p;
		}
		res += ans[i]*sz[v];
	}
	return res;
}
int main(){
	cin>>N;
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		G[a].pb(b);
		G[b].pb(a);
		e2i[P(a,b)] = i;
		e2i[P(b,a)] = i;
	}
	rep(i,N) cin>>s[i];
	ll now = dfs(0);
	if(v2!=-1){
		int i = e2i[P(v2,p2)];
		ans[i] = (s[0]-now)/sz[v2];
	}
	rep(i,N-1) cout<<ans[i]<<endl;
}

Measured memory_bytes: 33280
package main
 
import "fmt"
 
func main() {
	var n int
	ans := 1
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] == 0 {
			fmt.Println(0)
			return
		}
	}
	for _, v := range a {
		ans *= v
		if ans > 1000000000000000000 || ans < v {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 6308
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n,m,c;
	cin>>n>>m>>c;
	int A[n][m],B[m];
	rep(i,m)cin>>B[i];
	rep(i,n)rep(j,m)cin>>A[i][j];

	int ans=0;
	rep(i,n){
		int tmp=0;
		rep(j,m){
			tmp+=A[i][j]*B[j];
		}
		if(tmp+c>0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    ll res = 0;
    vector<vector<ll>> num(10, vector<ll>(10, 0));
    for (int i = 1; i <= N; i++) {
        string n = to_string(i);
        int a = n[0] - '0';
        int b = n.back() - '0';
        if (!a || !b)
            continue;
        num[a][b]++;
    }

    for (int a = 1; a < 10; a++) {
        for (int b = 1; b < 10; b++) {
            res += num[a][b] * num[b][a];
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int c;
    int cnt = 0;

    scanf("%d %d %d", &a, &b, &c);

    for ( int i = a; i <= b; i++ ) {
        if ( c % i == 0 ) {
            cnt++;
        }
    }

    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 2120
n = int(input())
p = list(map(int, input().split()))

lst = []
for i in range(n):
    lst.append(i+1)

tmp = 0
for i in range(n):
    if p[i] == lst[i]:
        tmp += 1

print('YES' if tmp==n or tmp==n-2 else 'NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll A,B; cin >> A >> B;
  println(A*B-A-B+1);
}


Measured memory_bytes: 256
def solve(n, m, a, b):
  for i in range(n - m + 1):
    for j in range(n - m + 1):
      if [row[j:j+m] for row in a[i:i+m]] == b:
        return True
  return False

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
print('Yes' if solve(n, m, a, b) else 'No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int a,b,c,n;
	int data[1000][4];
	int ans[301];
	while(cin >> a >> b >> c,a+b+c){
		for(int i=0;i<301;i++)ans[i]=2;
		cin >> n;
		for(int i=0;i<n;i++){
			for(int j=0;j<4;j++){
				cin >> data[i][j];
			}
			if(data[i][3]){
				for(int j=0;j<3;j++){
					ans[data[i][j]]=1;
				}
			}
		}
		for(int i=0;i<n;i++){
			if(data[i][3])continue;
			for(int j=0;j<3;j++){
				if(ans[data[i][j]]==1&&ans[data[i][(j+1)%3]]==1){
					ans[data[i][(j+2)%3]]=0;
				}
			}
		}
		for(int i=0;i<a+b+c;i++){
			cout << ans[i+1] << endl;
		}
	}
}


Measured memory_bytes: 2996
@L=1..<>+2;
@B=1e9;
map{
	$z-=!--$B[$-=/ /&&$L[$A[$`-1]]++];
	$z+=!$B[$-=--$L[/ /?$A[$`-1]=$':$_]]++;
	/ /&&print@A-$z,$/
}(@A=glob<>),<>


Measured memory_bytes: 113612
def pm_table(n):
    """
    素数テーブル
    n以下の素数のリストを返却する
    :param n:
    """
    res = [1] * (n + 1)
    res[0] = 0
    res[1] = 0

    for i in range(2, n):
        if i ** 2 > n:
            break

        if res[i] == 1:
            for j in range(i * 2, n + 1, i):
                res[j] = 0
    return res


N = 10 ** 5
pm = pm_table(N)

def is_prime(x):
    return pm[x]


s = [0] * (N + 2)
a = [0] * (N + 1)

for i in range(1, N):
    if i % 2 == 0: continue
    if is_prime(i) and is_prime((i + 1) // 2):
        a[i] = 1

for i in range(len(s) - 1):
    s[i + 1] = s[i] + a[i]

for i in range(int(input())):
    l, r = [int(_) for _ in input().split()]
    print(s[r + 1] - s[l])


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
signed main()
{
    string S;
    cin >> S;
    int a[S.length() + 1];
    fill(a, a + S.length(), 0);
    rep(i, S.length())
    {
        if (S[i] == '<')
        {
            a[i + 1] = max(a[i + 1], a[i] + 1);
        }
    }
    for (int i = S.length() - 1; i >= 0; i--)
    {
        if (S[i] == '>')
        {
            a[i] = max(a[i], a[i + 1] + 1);
        }
    }
    int ans = 0;
    rep(i, S.length() + 1)
    {
        ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4740
#!/usr/bin/env python3
import sys


def solve(N: int, D: int):
    a = (N // (2 * D + 1))
    b = (N % (2 * D + 1))
    if b is not 0:
        a = a+1
    print(a)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(N, D)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define FF first
#define SS second

const int N = 100 + 5;

int grid[N][N], arr[N*N];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int h, w; cin>>h>>w;
	int n; cin>>n;
	for(int i=0;i<n;i++) cin>>arr[i];
	int k=1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			grid[i][j]=k;
			arr[k-1]--;
			if(arr[k-1]<=0) k++;
		}
	}
	for(int i=0;i<h;i++){
		if(i&1){
			for(int j=w-1;j>=0;j--)
				cout<<grid[i][j]<<(" \n"[j==0]);
		}else{
			for(int j=0;j<w;j++)
				cout<<grid[i][j]<<(" \n"[j==w-1]);
		}
	}
	return 0;
}

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

typedef long long int ll;
const ll maxs = 1e5+5;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int main() 
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,a,b;
        cin>>n>>a>>b;
        ll diff = b-a;
        if( diff%2==0 )
        {
            cout << diff/2;
        }
        else
        {
            ll tmp = b;
            ll cnt = a - 1;
            b -= cnt;
            cnt += b/2;
            ll ans = cnt;
            
            b = tmp;
            cnt = n - b;
            a += cnt;
            cnt += (n-a+1)/2;
            ans = min(ans,cnt);
            cout << ans;
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll par[1000000];
ll Rank[1000000];

void init(ll n){
    rep(i,1,n){
        par[i]=i;
        Rank[i]=0;
    }
}

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

void unite(ll x,ll y){
    x=par[x];
    y=par[y];
    if(x==y)return ;
    if(Rank[x]<Rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(Rank[x]==Rank[y]){
            Rank[x]++;
        }
    }
    
}

bool same(ll x,ll y){
    return find(x)==find(y);
}


struct edge{ ll u,v,cost; };
bool comp(edge e1,edge e2){
    return e1.cost<e2.cost;
}
edge es[1000000];   //0~(E-1)
ll V,E;
ll kruskal(){
    sort(es,es+E,comp);
    init(V);
    ll res=0;
    rep(i,0,E-1){
        edge e=es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}

struct hogehoge{
    ll x;
    ll y;
    ll flag;
};
bool compp0(hogehoge a,hogehoge b){
    return a.x<b.x;
}
bool compp1(hogehoge a,hogehoge b){
    return a.y<b.y;
}
int main(){fastio
    ll n;cin>>n;
    ll x[n],y[n];
    vector<hogehoge> v[2];
    rep(i,0,n-1){
        cin>>x[i]>>y[i];
        hogehoge ho;
        ho.x=x[i];
        ho.y=y[i];
        ho.flag=i;
        v[0].pb(ho);
        v[1].pb(ho);
    }
    sort(v[0].begin(),v[0].end(),compp0);
    sort(v[1].begin(),v[1].end(),compp1);
    ll co=0;
    rep(i,0,1){
        rep(j,0,n-2){
            edge ed;
            ed.u=v[i][j].flag;
            ed.v=v[i][j+1].flag;
            if(i==0){
                ed.cost=v[i][j+1].x-v[i][j].x;
            }else{
                ed.cost=v[i][j+1].y-v[i][j].y;
            }
            es[co]=ed;
            co++;
        }
    }
    V=n;
    E=co;
    cout<<kruskal()<<endl;
    
    
    return 0;
}





Measured memory_bytes: 15780
from collections import deque


if __name__ == "__main__":
    N, L = map(int, input().split())
    a = list(map(lambda x: int(x), input().split()))

    que: deque = deque()
    ans = []
    for i, elem in enumerate(a):
        while (que and elem <= que[-1][1]):
            que.pop()
        que.append((i, elem))

        ans.append(que[0][1])

        if (que and que[0][0] <= i + 1 - L):
            que.popleft()

    print(" ".join([str(elem) for elem in ans[L - 1:]]))



Measured memory_bytes: 138852
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

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

	bool FLG = false;

	for(int i = 0; 4*i <= N; i++){

		int tmp = 4*i;
		int rest = N-tmp;

		if(rest%7 == 0){

			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");

	return 0;
}


Measured memory_bytes: 3636
alp = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s = input()
s = set(s)
if len(s)==len(alp):
    print("None")
else:
    s = sorted(s)
    s = list(s)
    for i in alp:
        if i not in s:
          print(i)
          break

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  map<long long, int> mp;
  REP(i, n) {
    int a; cin >> a;
    ++mp[a];
  }
  if (mp.size() == 1 && mp.count(0)) {
    cout << "Yes\n";
    return 0;
  }
  if (n % 3 == 0) {
    if (mp.size() == 2) {
      cout << (mp.count(0) && mp[0] == n / 3 && (*mp.rbegin()).second == 2 * n / 3 ? "Yes\n" : "No\n");
      return 0;
    }
    if (mp.size() == 3) {
      int test = 0;
      bool ok = true;
      for (auto p : mp) {
        test ^= p.first;
        if (p.second != n / 3) ok = false;
      }
      cout << (test == 0 && ok ? "Yes\n" : "No\n");
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 5120