akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c&&b >= c) {
		cout << "Yes" << endl;
	}
	else if (b <= c&&a >= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



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

typedef long long i64;
const int MAX_N = 100005;

class Edge {
public:
  int nxt, to, w;
} e[MAX_N << 1];

int head[MAX_N], cnt;
void addedge(int u, int v, int w) {
  e[++cnt] = (Edge){head[u], v, w}, head[u] = cnt;
  e[++cnt] = (Edge){head[v], u, w}, head[v] = cnt;
}

int N, sz[MAX_N], vis = 1, f[MAX_N], rt;
i64 result;

void dfs(int u, int v) {
  sz[u] = 1, f[u] = 0;
  for (int i = head[u]; i; i = e[i].nxt)
    if (e[i].to != v) {
      dfs(e[i].to, u), sz[u] += sz[e[i].to];
      result += 2LL * min(N - sz[e[i].to], sz[e[i].to]) * e[i].w;
      if (sz[e[i].to] == N - sz[e[i].to]) vis = 0, result -= e[i].w;
      f[u] = max(f[u], sz[e[i].to]);
    }
  f[u] = max(f[u], N - sz[u]);
  if (!rt || f[u] < f[rt]) rt = u;
}

int main() {
  scanf("%d", &N);
  int mn = 100000000;
  for (int i = 1; i < N; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    addedge(u, v, w);
  }

  dfs(1, 0);
  if (vis) {
    for (int i = head[rt]; i; i = e[i].nxt)
      mn = min(mn, e[i].w);
    result -= mn;
  }

  printf("%lld\n", result);
  return 0;
}


Measured memory_bytes: 7680
#include<stdio.h>

int main(void) {
	int a, b, c, d,t,s;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (c % b == 0) t = c / b;
	else t = c / b + 1;
	if (a % d == 0) s = a / d;
	else s = a / d + 1;
	if (t<=s) printf("Yes");
	else printf("No");

	return 0;
}

Measured memory_bytes: 2140
def f_single_dot():
    # https://atcoder.jp/contests/abc168/submissions/13368489
    import sys
    from collections import deque
    input = sys.stdin.readline
    N, M = [int(i) for i in input().split()]

    x_set, y_set = set([0]), set([0])  # 重複を除いた xy 座標の一覧 (座標圧縮に必要)

    vertical_lines = []
    for _ in range(N):
        a, b, c = map(int, input().split())
        vertical_lines.append((a, b, c))
        x_set |= {a, b}
        y_set |= {c}

    horizontal_lines = []
    for _ in range(M):
        d, e, f = map(int, input().split())
        horizontal_lines.append((d, e, f))
        x_set |= {d}
        y_set |= {e, f}

    x_set = sorted(x_set)
    y_set = sorted(y_set)

    # 座標圧縮 (壁も配列に格納するので、2 倍している)
    x_encoded = {n: i * 2 for i, n in enumerate(x_set)}
    y_encoded = {n: i * 2 for i, n in enumerate(y_set)}
    # 座標圧縮されたグリッドで縦横に 1 マス分進むことは実際にはどれくらい進んだことなのか
    x_length = [x_set[i // 2 + 1] - x_set[i // 2] if i %
                2 else 0 for i in range(len(x_set) * 2 - 1)]
    y_length = [y_set[i // 2 + 1] - y_set[i // 2] if i %
                2 else 0 for i in range(len(y_set) * 2 - 1)]

    # 壁を埋めていく (累積和を用いていない)
    x_size, y_size = 2 * len(x_set) - 1, 2 * len(y_set) - 1
    grid = [[0] * y_size for _ in range(x_size)]
    for a, b, c in vertical_lines:
        a, b, c = x_encoded[a], x_encoded[b], y_encoded[c]
        for x in range(a, b + 1):
            grid[x][c] = 1
    for d, e, f in horizontal_lines:
        d, e, f = x_encoded[d], y_encoded[e], y_encoded[f]
        for y in range(e, f + 1):
            grid[d][y] = 1

    queue = deque()
    is_visited = [[0] * (y_size + 1) for _ in range(x_size + 1)]
    dy = [1, 1, -1, -1]
    dx = [1, -1, 1, -1]
    for k in range(4):
        nnx, nny = x_encoded[0] + dx[k], y_encoded[0] + dy[k]
        if 1 <= nnx < len(x_set) * 2 - 1 and 1 <= nny < len(y_set) * 2 - 1:
            queue.append((nnx, nny))
            is_visited[nnx][nny] = 1
    ans = 0
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    while queue:
        x, y = queue.pop()
        if (x % 2) & (y % 2):
            ans += x_length[x] * y_length[y]
        for k in range(4):
            nx, ny = x + dx[k], y + dy[k]
            nnx, nny = nx + dx[k], ny + dy[k]
            if grid[nx][ny] == 0:
                if nnx < 0 or nnx >= len(x_set) * 2 - 1 or nny < 0 or nny >= len(y_set) * 2 - 1:
                    return 'INF'
                if not is_visited[nnx][nny]:
                    queue.appendleft((nnx, nny))
                    is_visited[nnx][nny] = 1
    return ans

print(f_single_dot())

Measured memory_bytes: 713692
s=input()
k=int(input())
uselist=[]
count=0
checker=0
alphabet="abcdefghijklmnopqrstuvwxyz"
while count<=5 and checker<=26:
    for i in alphabet:
        for j in range(len(s)):
            if s[j]==i:
                uselist.append((j,i))
                count+=1
        checker+=1
anslist=[]
for some in uselist:
    count=0
    for j in range(some[0],len(s)):
        anslist.append(s[some[0]:j+1:])
        count+=1
        if count>5:
            break
            
anslist=sorted(set(anslist))

print(anslist[k-1])

Measured memory_bytes: 5964
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	minn = l[0]
	ans = 1
	for i in range(1,n):
		if(l[i] <= minn):
			ans += 1
		minn = min(minn,l[i])
	return ans
	

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
# L = []
# for i in range(N):
# 	L.append([l[i],i])
ans = solve(l)
print(ans)


Measured memory_bytes: 25892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
}


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

using namespace std;

int main() {
    //forItachi
    int n;
    string s;
    cin>>n;
    cin>>s;
    int i,count = 0;
    for( i = 0 ; i < n-2 ; i++){
        if( s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

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

long long x, k, d;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> k >> d;
	x = abs(x);
	long long req = (x % d) ? x / d + 1 : x / d;
	if(req > k) cout << x - k * d << '\n';
	else{
		k -= req;
		long long cur = x - req * d;
		if(k % 2) cout << cur + d << '\n';
		else cout << abs(cur) << '\n';
	}
	return 0;
}

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

class Card{public:char suit,value;};

void bubble(Card A[],int N){
    for(int i=0;i<N;i++){
        for(int j=N-1;j>i;j--){
            if(A[j-1].value>A[j].value){
                swap(A[j],A[j-1]);
            }
        }
    }
}

void selection(Card A[],int N){
    for(int i=0;i<N;i++){
        int minj = i;
        for(int j=i;j<N;j++){
            if(A[minj].value>A[j].value)minj = j;
        }
        swap(A[minj],A[i]);
    }
}

void print(Card A[],int N){
    for(int i=0;i<N;i++){
        if(i)cout<<' ';
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}

bool isStable(Card C1[],Card C2[],int N){
    for(int i=0;i<N;i++){
        if(C1[i].suit!=C2[i].suit) return false;
    }
    return true;
}

int main(int argc, const char * argv[]) {
    Card C1[100],C2[100];
    int N;cin>>N;
    for(int i=0;i<N;i++){
        cin>>C1[i].suit>>C1[i].value;
    }
    
    for(int i=0;i<N;i++)C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout<<"Stable"<<endl;
    print(C2,N);
    if(isStable(C1,C2,N)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<cstdio>
#include<vector>
const int N=2e5+5;
int val[N<<2],add[N<<2],n,m;
void push(int k) {
    if(!add[k]) return;
    add[k<<1]+=add[k];add[k<<1|1]+=add[k];
    val[k<<1]+=add[k];val[k<<1|1]+=add[k];
    add[k]=0;
}
void pull(int k) {
    val[k]=std::max(val[k<<1],val[k<<1|1]);
}
void build(int k,int lef,int rig) {
    add[k]=0;
    if(lef==rig) {
        val[k]=lef-m-1;
        return;
    }
    int mid=(lef+rig)>>1;
    build(k<<1,lef,mid),build(k<<1|1,mid+1,rig);
    pull(k);
}
void update(int k,int lef,int rig,int l,int r) {
    if(l<=lef&&rig<=r) {
        add[k]++;val[k]++;
        return;
    }
    int mid=(lef+rig)>>1;push(k);
    if(l<=mid) update(k<<1,lef,mid,l,r);
    if(r>mid) update(k<<1|1,mid+1,rig,l,r);
    pull(k);
}
int query(int k,int lef,int rig,int l,int r) {
    if(l<=lef&&rig<=r) return val[k];
    int mid=(lef+rig)>>1,ans=0;push(k);
    if(l<=mid) ans=std::max(ans,query(k<<1,lef,mid,l,r));
    if(r>mid) ans=std::max(ans,query(k<<1|1,mid+1,rig,l,r));
    return ans;
}
std::vector<int> g[N];
int main() {
    scanf("%d%d",&n,&m);
    build(1,1,m+1);int ans=std::max(0,n-m);
    int l,r;
    while(n--) {
        scanf("%d%d",&l,&r);
        g[l].push_back(r);
    }
    for(int i=0;i<=m;i++) {
        for(int v:g[i]) update(1,1,m+1,1,v);
        ans=std::max(ans,query(1,1,m+1,i+1,m+1)-i);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 14080
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		String str=s.next();
		String str2=s.next();
		
		int n=str.length();
		int len=str2.length();
		
		int min=Integer.MAX_VALUE;
		
		for(int i=0;i<=n-len;i++)
		{
			String temp=str.substring(i,i+len);
			
			int count=0;
			
			for(int j=0;j<temp.length();j++)
			{
				if(temp.charAt(j)!=str2.charAt(j))
				{
					count++;
				}
			}
			
			if(count<min)
				min=count;
		}
		
		System.out.println(min);
		
	}
	
}

Measured memory_bytes: 36564
class UnionFind():
    def __init__(self, n):
        self.__parent = [i for i in range(n)]
        self.__rank = [0 for i in range(n)]
        self.size = [1 for _ in range(n)]

    def union(self, x, y):
        pX, pY = self.find(x), self.find(y)
        if pX != pY:
            if self.__rank[pX] > self.__rank[pY]:
                self.__parent[pY] = pX
                self.size[pX] += self.size[pY]
                self.__rank[pX] += 1
            else:
                self.__parent[pX] = pY
                self.size[pY] += self.size[pX]
                self.__rank[pY] += 1

    def find(self, x):
        if self.__parent[x] != x:
            self.__parent[x] = self.find(self.__parent[x])
        return self.__parent[x]


n, m = map(int, input().split())
A_li = []
B_li = []
for i in range(m):
  AB_li = input().split()
  A_li.append(int(AB_li[0]))
  B_li.append(int(AB_li[1]))
A_li.reverse()
B_li.reverse()
dis = int(n * (n - 1) / 2)
uf = UnionFind(n)
ans = []
for i in range(m):
  pA = uf.find(A_li[i] - 1)
  pB = uf.find(B_li[i] - 1)
  ans.append(dis)
  if pA != pB:
    dis -= uf.size[pA] * uf.size[pB]
    uf.union(A_li[i] - 1, B_li[i] - 1)
ans.reverse()
for i in ans:
  print(i)


Measured memory_bytes: 19372
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<u32 M = 1000000007>
struct modint{
    u32 val;
    modint(): val(0){}
    template<typename T>
    modint(T t){t %= (T)M; if(t < 0) t += (T)M; val = t;}

    modint pow(ll k) const {
        modint res(1), x(val);
        while(k){
            if(k&1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }
    template<typename T>
    modint& operator=(T t){t %= (T)M; if(t < 0) t += (T)M; val = t; return *this;}
    modint inv() const {return pow(M-2);}
    modint& operator+=(modint a){val += a.val; if(val >= M) val -= M; return *this;}
    modint& operator-=(modint a){if(val < a.val) val += M-a.val; else val -= a.val; return *this;}
    modint& operator*=(modint a){val = (u64)val*a.val%M; return *this;}
    modint& operator/=(modint a){return (*this) *= a.inv();}
    modint operator+(modint a) const {return modint(val) +=a;}
    modint operator-(modint a) const {return modint(val) -=a;}
    modint operator*(modint a) const {return modint(val) *=a;}
    modint operator/(modint a) const {return modint(val) /=a;}
    modint operator-(){return modint(M-val);}
    bool operator==(const modint a) const {return val == a.val;}
    bool operator!=(const modint a) const {return val != a.val;}
    bool operator<(const modint a) const {return val < a.val;}
};
using mint = modint<MOD>;

int main() {
    int n, k;
    cin >> n >> k;
    cout << mint(k).pow(n).val << "\n";
    return 0;
}


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

int main() {
  ll n;
  cin >> n;
  ll ans=0;
  if(n%2==0) {
    ll m=10;
    while(n/m>0) {
      ans+=n/m;
      m*=5;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
N, A, B = map(int, input().split())

if A > B :
    print(0)
elif N == 1:
    if A != B:
        print(0)
    else:
        print(1)
else:
    ma = B * (N-1) + A
    mi = A * (N-1) + B
    print(ma - mi + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a[200000],ans=0,last=-1;
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>a[i];
	for (int i=0;i<n;i++)
	{
		if (last!=-1)
		{
			if (a[i]<last)
			{
				int t=last-a[i];
				ans+=t;
				a[i]+=t;
			}
			last=a[i];
		} else {
			last=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5192
#include <stdio.h>

using namespace std;

int main(){
	int a,b,c,count = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(int i = a; i <= b; i++){
		if(c%i == 0) count++;
	}
	printf("%d\n",count);
}


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

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

using namespace std;
using lint=long long;

int main(){
	int n;
	lint k;
	scanf("%d%lld",&n,&k);
	vector<lint> w(n),d(n);
	rep(i,n) scanf("%lld%lld",&w[i],&d[i]);

	lint lo=0,hi=2e18;
	while(hi-lo>1){
		lint mi=(lo+hi)/2;
		lint cnt=0;
		rep(i,n) if(w[i]<=mi) cnt+=1+(mi-w[i])/d[i];
		if(cnt<k) lo=mi;
		else      hi=mi;
	}
	printf("%lld\n",hi);

	return 0;
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 A,B,C;
    cin >> A >> B >> C;

    if(A+B>=C-1){
        cout << B+C << endl;
        return;
    }

    cout << A+B*2+1 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Divide a Cuboid
https://atcoder.jp/contests/agc004/tasks/agc004_a

"""
import sys


def solve(A, B, C):
    ans = []
    ans.append(B*C * (A%2))
    ans.append(A*C * (B%2))
    ans.append(A*B * (C%2))
    return min(ans)


def main(args):
    A, B, C = map(int, input().split())
    ans = solve(A, B, C)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 3064
# abc159 D
n = gets.to_i
a = gets.split.map(&:to_i)

agroup = {}

a.group_by(&:itself).each{|k,v| agroup[k] = v.size  }

# p agroup

agroup2 = {}
agroup.each { |key, val|
  agroup2[key] = val * (val-1) / 2
}
sum = agroup2.map{|k,v|v}.inject(:+)

# puts "sum: #{sum}"

a.each do |aa|
  val = agroup[aa]
  p sum - ( val * (val-1) / 2 )  + ( (val-1) * (val-2) / 2 )
end









Measured memory_bytes: 75880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    ll n; cin>>n;
    ll ans=0LL;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ll x=i,y=n/i;
            if(x!=1&&n/(x-1)==y)ans+=x-1;
            if(y!=1&&n/(y-1)==x)ans+=y-1;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define ll long long

vector<ll> subsetSums(vector<ll> v, int n)
{
	ll sum, total = 1 << n;
	vector<ll> v2;
	
	for(ll i = 0; i < total; i++)
	{
		sum = 0;
		
		for(int j = 0; j < n; j++)
			if(i & (1 << j))
				sum += v[j];
		v2.push_back(sum);
	} 
	return v2;
}

int main()
{
	int n, m;
	
	scanf("%d", &n);
	
	vector<ll> v;
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		v.push_back(m);
	}
	
	vector<ll> s = subsetSums(v, n);
	
	sort(s.begin(), s.end());
	
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		
		printf("%s\n", binary_search(s.begin(), s.end(), m) ? "yes" : "no");
	}
	return 0;
}


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

int main()
{
     int g[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
     int a, b;
     cin >> a >> b;
     if(g[a]==g[b]) puts("Yes");
     else puts("No");
}

Measured memory_bytes: 256
n = int(input())
lst = []
for i in range(n):
  lst.append(input())
abc = [chr(ord('a') + i) for i in range(26)]
#print(abc)###
cnt = []
for s in abc:
  temp = 100
  for i in range(n):
    temp = min(temp, lst[i].count(s))
  cnt.append(temp)
#print(cnt)###
res = []
for i in range(26):
  for j in range(cnt[i]):
    res.append(abc[i])
print(''.join(res))

Measured memory_bytes: 9208
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int L; cin >> L;

    int n = 20;
    int l = 0;
    int sv = 1;
    using Edge = tuple<int, int, int>;
    vector<Edge> res;

    rep(i, n-1){
        int v = i + 1;
        int k = (n-1) - v;
        int cl = bit(k);

        int nv = v + 1;

        if((L >> k) & 1){
            res.emplace_back(Edge(sv, nv, l));
            l += cl;
        }

        if(v == sv){
            if((L >> (k + 1)) & 1){
                l += bit(k + 1);

                res.emplace_back(Edge(sv, nv, bit(k)));

                if((L >> k) & 1){
                    res.emplace_back(Edge(sv, nv, bit(k + 1)));
                }
                else {
                    res.emplace_back(Edge(sv, nv, 0));
                }
            }
            continue;
        }

        res.emplace_back(Edge(v, nv, cl));
        res.emplace_back(Edge(v, nv, 0));
    }

    int m = res.size();
    cout << n << " " << m << endl;
    for(auto& e : res){
        int a, b, w; tie(a, b, w) = e;
        cout << a << " " << b << " " << w << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 44

int F[N];

int fibonacci(int n){
  if(n==0 || n==1) return F[n]=1;
  if(F[n]!=0) return F[n];
  return F[n]=fibonacci(n-2)+fibonacci(n-1);
}

int main(){
  int n,a;
  scanf("%d",&n);
  a=fibonacci(n);
  printf("%d\n",a);
  return 0;
}



Measured memory_bytes: 2112
def r;gets.split.map &:to_i;end
M,K = r
A = Array.new(2**M,&:itself)
if (M == 1 && K == 1) || K >= 2**M
  puts -1
  exit
end
if M == 1 && K == 0
  puts "1 1 0 0"
  exit
end
A.delete(K)
puts [A + [K] + A.reverse + [K]].join(" ")

Measured memory_bytes: 11928
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
//int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			//depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

#define int long long //change int main to int32_t main
const int INF = 1e9 + 5;

const int N = 1e5 + 5;

int dp[105][N];
int w[105], v[105];
int n, fw;


void solve()
{

	cin >> n >> fw;
	fr0(i, n) cin >> w[i + 1] >> v[i + 1];
	//mem(dp);
	fr(i, 1, N) fr0(j, 105) dp[j][i] = INF;
	int ans = 0;
	fr(j, 1, n + 1) fr0(i, N)
	{
		if (i - v[j] >= 0)
			dp[j][i] = min(dp[j - 1][i], w[j] + dp[j - 1][i - v[j]]);
		else dp[j][i] = dp[j - 1][i];
		if (dp[j][i] <= fw) ans = max(ans, i);
	}



	cout << ans << nl;
}





int32_t main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




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

int main()
{
    ll n,temp;
    cin >> n;
    set<ll> a;
    rep(i, n){
        cin >> temp;
        a.insert(temp);
    }

{
    ll i;
    set<ll>::iterator itr;
    for(itr = a.begin(), i=0; itr != a.end(); ++itr, ++i)
    {
        cout << (i ? " " : "") << flush;
        cout << *itr << flush;
    }
}

    cout << endl;

    return 0;
}


Measured memory_bytes: 7768
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;cin>>n;
    cout<<ceil((double)n/2);
    return 0;
}

    


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

#define ll long long

int main()
{
    ll n;
    cin>>n;
    string ss=to_string (n);
    ll cnt=0;
     for(ll i=0;i<ss.size();i++){
     	if(ss[i]=='7'){
     		cnt=1;
     		break;
     	}
     }
     (cnt==1)?cout<<"Yes":cout<<"No";
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vi b(m);
    rep(i,m){
        cin >> b[i];
    }
    int ans = 0;
    rep(i,n){
        int cc = c;
        rep(j, m)
        {
            int a;
            cin >> a;
            cc += a * b[j];
        }
        if(cc>0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m, x = list(map(int, input().split(' ')))

anm = [None] * n
cn = [None] * n
for i in range(n):
    row = list(map(int, input().split(' ')))
    cn[i] = row[0]
    anm[i] = row[1:]

ans = float('inf')
for i in range(2 ** n):
    cost = 0
    ex = [0] * m
    for j in range(n):
        if i >> j & 1:
            cost += cn[j]
            for k in range(m):
                ex[k] += anm[j][k]
    if sum(1 for e in ex if e >= x) == m and ans > cost:
        ans = cost

if ans == float('inf'):
    print('-1')
else:
    print(ans)



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

int  main(){
  int n,c,ans=0,l,r;cin>>n;
  vector<int> v(n);
  rep(i,n){cin>>v.at(i);}
  while(true){
    if(count(v.begin(),v.end(),0)==n){break;}
   
    c=0;
    if(v.at(0)!=0)c++;
    for(int i=0; i<n-1; i++){
      if(v.at(i)==0&&v.at(i+1)!=0){c++;}
    }
    ans+=c;
    rep(i,n){
      if(v.at(i)!=0){v.at(i)--;}
    }
  }
  cout<<ans;
}

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


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

int main(){
    int N,K;
    string S;
    cin>>N>>K;
    cin>>S;
    S[K-1] +=0x20;
    cout<<S;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,i;    
    i=0;
    while(1){   
    cin >> x;
    i++;
    if( x == 0) break;
    cout << "Case";
    cout << " ";
    cout << i;
    cout << ":";
    cout << " ";
    cout << x;
    cout << endl;}
    
}



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

#define    ll     long long int

int main( )
{
    int n, m, k, l, i;
    cin >> n >> m >> k;
    for (i = 0; i < k && i + n <= m; i++) {
        cout << i + n << '\n';
        l = (i + n);
    }
    for (i = k; i > 0; i--) {
        if (m - i + 1 > l) {
            cout << m - i + 1 << '\n';
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <list>
using namespace std;

int main() {
	int n, m, count = 0, s[10000];
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> m;
	for(int i = 0; i < m; i++) {
		int t;
		cin >> t;
		for(int j = 0; j < n; j++) {
			if(s[j] == t) {
				count ++;
				break;
			}
		}
	}
	cout << count <<endl;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a-c)/(b+c)<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (empty($l)) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a[0];
    $key->B = $a[1];
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->D=$a;
  }
}
if (($key->A <= 0) && (0 <= $key->B)) {
  printf("Zero\n");
  exit;
}
if (($key->A <= $key->B) && ($key->B < 0)) {
 if (($key->B - $key->A  + 1)%2==0) {
   printf("Positive\n");
 }
 else {
   printf("Negative\n");
 }
 exit;
}
else {
  printf("Positive\n");
}


Measured memory_bytes: 3832
#include <stdio.h>
int main(){
	char s[101];
	int i = 0;
	scanf("%s", s);
	while(s[i] != 'C'){
		if(i == 100) goto NO;
		i++;
	}
	while(s[i] != 'F'){
		if(i == 100) goto NO;
		i++;
	}
	printf("Yes\n");
	return 0;
	NO:
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll num[MAX], cnt[MAX];
vll edge[MAX];
void dfs(ll cur, ll pre, ll sum) {
  sum += num[cur];
  cnt[cur] = sum;
  rep(i, edge[cur].size()) {
    ll to = edge[cur][i];
    if (to == pre) continue;
    dfs(to, cur, sum);
  }
}



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


  cin >> n >> m;
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    edge[a].pb(b);
    edge[b].pb(a);
  }
  rep(i, m) {
    ll p, x;
    cin >> p >> x;
    num[p] += x;
  }
  dfs(1, -1, 0);
  FOR(i, 1, n + 1) cout << cnt[i] << " ";
  cout << endl;


  return 0;
}


Measured memory_bytes: 29440
#include <iostream>
using namespace std;
int main(){
  int n; cin>>n;
  int uzaklik = 0;
  for(int i = 0; i < n; i++){
    int sayi2; cin>>sayi2;
    if(sayi2 != i+1){
      if(uzaklik == 0){
        uzaklik = abs(i+1 - sayi2);
      }else if(abs(i+1 - sayi2) != uzaklik){
        cout<<"NO";
        return 0;
      }
    }
  }
  cout<<"YES";
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static boolean isPalindrome(String str){
    for(int i = 0; i < (int)Math.ceil(0.5*str.length()); i++) {
      if (str.charAt(i) != str.charAt(str.length()-1-i)) {
        return false;
      }
    }
    return true;
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int counter = 0;
    while(sc.hasNext()) {
      String str = sc.next();
      if (isPalindrome(str)) {
        counter++;
      }
    }
    System.out.println(counter);
  }
}

Measured memory_bytes: 11000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz;
    UnionFind(int N) : par(N),siz(N,1) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if(siz[rx] < siz[ry])swap(rx,ry);
        siz[rx] += siz[ry];
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){
      return siz[root(x)];
    }
};

// TODO: write
int main() {
  int n,m;cin>>n>>m;
  auto tree = UnionFind(n);
  set<int> s;
  rep(i,m){
    int a,b;cin>>a>>b;
    a--;b--;
    tree.unite(a,b);
    s.emplace(a);
    s.emplace(b);
  }
  int ans = 1;
  rep(i,n){
    if(s.count(i))chmax(ans,tree.size(i));
  }
  print(ans);
  return 0;
}

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

using namespace std;

int main()
{
	int r, c;	//???????¨?
	cin >> r >> c;
	
	vector< vector<int> > data(r, vector<int>( c ));

	vector<int> r_sum( c + 1, 0 );	//??????????????????
	int c_sum;	//?¨????????????????
	
	
	for(auto ity = data.begin(); ity != data.end(); ity++)
	{
		auto r_sum_it = r_sum.begin();
		c_sum = 0;
		
		for(auto itx = ity->begin(); itx != ity->end(); itx++)
		{
			cin >> *itx;
			
			c_sum += *itx;
			
			*r_sum_it += *itx;
			r_sum_it++;
		}
		ity->push_back( c_sum );
		
		r_sum[c] += c_sum;	//???????????????
		
	}
	
	data.push_back( r_sum );
	
	
	for(auto ity = data.begin(); ity != data.end(); ity++)
	{
		for(auto itx = ity->begin(); itx != ity->end(); itx++)
		{
			cout << *itx;
			if( (itx + 1) != ity->end() )cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
a, b, c = gets.chomp.split.map(&:to_i)
k = gets.chomp.to_i

# c > b > a

(k+1).times do
	if c > b && b > a
		puts "Yes"
		exit
	end

	if a >= b
		b *= 2
	elsif b >= c
		c *= 2
	end
end

puts "No"

Measured memory_bytes: 14300
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    int N,M;cin>>N>>M;
    string S;cin>>S;
    int r=N;
    vector<int> ans;
    while(r>0){
        int tmpr=r;
        tmpr-=M;
        if(tmpr<=0){
            ans.push_back(r);
            break;
        }
        while(S[tmpr]=='1'){
            tmpr++;
        }
        if(tmpr==r){
            cout<<-1<<endl;
            return 0;
        }
        ans.push_back(r-tmpr);
        r=tmpr;
    }
    reverse(All(ans));
    REP(i,ans.size()) cout<<ans[i]<<" \n"[i+1==ans.size()];
}

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    //int ans = 0;
    int p;
    int a[3000], fac[3001], inv[3001];
    int ans[3000] = {};
    cin >> p;
    REP(i, p) cin >> a[i];
    
    REP(i, p+1){
        if(i==0) fac[i] = 1;
        else fac[i] = (fac[i-1] * i) % p; 
        REP(j, p+1){
            if(i==0) {
                inv[i] = 1;
                break;
            }
            else {
                if((fac[i]*j)%p ==1){
                    inv[i] = j;
                    break;
                }
            }
        }
    }
    //REP(i, p+1) cout << fac[i] << " " << inv[i] << endl;
    REP(i, p){
        if(a[i]==0) continue;
        else{
            ans[0] = (ans[0]+1) % p;
            REP(j, p){
                ans[j] = (ans[j] - modpow(-i,p-1-j,p) * fac[p-1] * inv[j] * inv[p-1-j]) % p;
                if (ans[j] < 0) ans[j] += p;
            }
        }
    }

    REP(i, p){
        cout << ans[i] << " ";
    }
    cout << endl;
}

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

int main() {

    char s[200010], t[200010];
    int cout = 0;

    scanf("%s", s);
    scanf("%s", t);

    int i = 0;
    while (s[i]) {
        if (s[i] != t[i]) {
            cout++;
        }
        i++;
    }

    printf("%d", cout);

    return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a <= c && c <= b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    
    /*
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    */
    int ans = 0;
    if(a1+a2+a3 >= 22)
    cout << "bust" << endl; 
    else
    cout << "win" << endl; 

    return 0;
}

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

using namespace std;

int main(void) {
  char x[52][52] = { {0} };
  int h, w;
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> x[i][j];
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (x[i][j] == '#') {
        cout << '#';
        continue;
      }
      int count = 0;
      if (x[i][j - 1] == '#') {
        count++;
      }
      if (x[i + 1][j - 1] == '#') {
        count++;
      }
      if (x[i + 1][j] == '#') {
        count++;
      }
      if (x[i + 1][j + 1] == '#') {
        count++;
      }
      if (x[i][j + 1] == '#') {
        count++;
      }
      if (x[i - 1][j + 1] == '#') {
        count++;
      }
      if (x[i - 1][j] == '#') {
        count++;
      }
      if (x[i - 1][j - 1] == '#') {
        count++;
      }
      cout << count;
    }
    cout << endl;
  }
  return EXIT_SUCCESS;
}


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

int main() {
	char a[100];
	int f = 0;
	gets(a);
	int n = strlen(a);
	for (int i = 0; i < n; i++) {
		if (a[i] == 'C') {
			f = 1;
		}
		if (a[i] == 'F' && f == 1) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x " "
#define debugln(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define vvdebug(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int D, N; cin >> D >> N;
	if (N == 100) N++;
	rep(i, D) N *= 100;
	cout << N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w,k;
char s[20][2000];
int tot[20][2000];
vector<int> pr;
int ot[20];
void add(int j) {
    int c=0;
    for(int i=0;i<h;i++) {
        if(c+1<pr.size() && pr[c+1]==i) c++;
        if(s[i][j]=='1') ot[c]++;
    }
}
bool check() {
    for(int l=0;l<pr.size();l++) {
        if(ot[l]>k) return false;
    }
    return true;
}
void clear() {
    for(int l=0;l<pr.size();l++) ot[l]=0;
}
int main() {
    scanf("%d %d %d",&h,&w,&k);
    for(int i=0;i<h;i++) {
        scanf("%s",s[i]);
    }
    int ba=h-1+w-1;
    for(int i=0;i<(1<<(h-1));i++) {
        int ca=__builtin_popcount(i);
        pr.clear();
        pr.push_back(0);
        int f=1;
        for(int j=1;j<=i;j*=2,f++) {
            if(i&j) pr.push_back(f);
        }
        for(int j=0;j<=h;j++) ot[j]=0;
        for(int kl=0;kl<w;kl++) {
            add(kl);
            if(!check()) {
                clear();
                add(kl);
                if(!check()) {
                    ca=1e9;
                    break;
                }
                else ca++;
            }
        }
        ba=min(ba,ca);
    }
    printf("%d",ba);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define fi first 
#define se second 
#define mod 1000000007
int power(ll x, ll  y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main() 
{ 
  ll n ;
  cin >> n ;
  vector<ll> v ;
  while(n!=0)
  {
    if(n%26!=0)v.pb(n%26) ;
    else
    {
      v.pb(26) ;
      n--;
    }
    n = n/26 ;
  }
  string s ="" ;
  ll i = v.size()-1 ;
  while(i>=0)
  {
    s += 'a' + (v[i]-1) ;
    i-- ;
  }
  cout << s << endl;

} 

Measured memory_bytes: 3604
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    a.append(list(str(input())))
for i in range(m):
    b.append(list(str(input())))
f2=True
for y in range(n-m+1):
    for x in range(n-m+1):
        f=True
        for dy in range(m):
            for dx in range(m):
                if b[dy][dx]!=a[y+dy][x+dx]:
                    f=False
        if f:
             f2=False
print("YNeos"[f2::2])

Measured memory_bytes: 3064
# tolist つけ忘れ
# https://atcoder.jp/contests/abc163/submissions/16271142

def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import numpy as np

def eular_tour(G, root):
    # G は破壊的に有向木にされる
    # グラフは 1-indexed が良い
    n = len(G)
    stack = [root]
    tour = [0] * 0
    firsts = np.full(n, -100, dtype=np.int64)
    lasts = np.full(n, -100, dtype=np.int64)
    parents = np.full(n, -100, dtype=np.int64)
    while stack:
        v = stack.pop()
        if firsts[v] >= 0:
            lasts[v] = len(tour)
            tour.append(-v)  # 帰りがけの辺の表現をマイナス以外にしたい場合ここを変える
            continue
        firsts[v] = len(tour)
        tour.append(v)
        stack.append(v)
        for u in G[v]:
            G[u].remove(v)
            parents[u] = v
            stack.append(u)
    tour = np.array(tour, dtype=np.int64)
    return tour, firsts, lasts, parents

def solve(N, C, AB):
    G = [[0]*0 for _ in range(N+1)]
    for i in range(N-1):
        a, b = AB[i]
        G[a].append(b)
        G[b].append(a)
    tour, firsts, lasts, parents = eular_tour(G, 1)
    Siz = lasts - firsts + 1 >> 1

    Cnt = np.zeros(N+1, dtype=np.int64)
    Ans = np.zeros(N+1, dtype=np.int64)
    Cnt_old = np.empty_like(Cnt)
    Siz_tmp = np.full_like(Cnt, 1)
    for v in tour:
        if v >= 0:
            p = parents[v]
            if p != -100:
                Cnt[C[p]] = N - Siz[v]  # 上を塞ぐ

            color = C[v]
            Cnt_old[v] = Cnt[color]
        else:
            v = -v
            Ans[C[v]] += N - Siz_tmp[v] + 1 - Cnt_old[v]
            Cnt[C[v]] = Cnt_old[v] + Siz_tmp[v]

            p = parents[v]
            if p != -100:
                Siz_tmp[p] += Siz[v]
                Ans[C[p]] += Siz[v] * (N - Siz_tmp[p] + 1 - Cnt_old[p])

    return Ans[1:]


numba_compile([
    [eular_tour, "Tuple((i8[:],i8[:],i8[:],i8[:]))(List(List(i8)),i8)"],
    [solve, "i8[:](i8,i8[:],i8[:,:])"],
])


import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(505050)
N = int(input())
C = np.array(["0"] + input().split(), dtype=np.int64)
AB = np.array([list(map(int, input().split())) for _ in range(N-1)], dtype=np.int64)
Ans = solve(N, C, AB)
print("\n".join(map(str, Ans.tolist())))


Measured memory_bytes: 98808