akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

long a, b;
int k;

void input() {
	cin >> a >> b >> k;
}

void sendAtoB() {
	if (a % 2 == 1) a--;
	a /= 2;
	b += a;
}

void sendBtoA() {
	if (b % 2 == 1) b--;
	b /= 2;
	a += b;
}

void solve() {
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) sendAtoB();
		else sendBtoA();
	}
	cout << a << " " << b << "\n";
}

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

	input();
	solve();

	return 0;
}

Measured memory_bytes: 256
price_of_bell_a, price_of_bell_b, price_of_bell_c = map(int, input().split())

sum_a_b = price_of_bell_a + price_of_bell_b
sum_a_c = price_of_bell_a + price_of_bell_c
sum_b_c = price_of_bell_b + price_of_bell_c

print(min(sum_a_b, sum_a_c, sum_b_c))

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 200010;
int N,M;
int A[MC];
int X[MC];
int B[MC];

int f(int z){
	return A[z]-X[A[z]] > 0 ? A[z]-X[A[z]] : 0;
}

int main(){
	scanf("%d%d" , &N , &M);
	repp(i,0,N){
		scanf("%d" , A + i);
		++B[f(i)];
		++X[A[i]];
	}
	int ans = 0;
	repp(i,1,N+1){
		if(B[i] == 0) ++ans;
	}
	B[0] = M*3;
	repp(i,0,M){
		int x,y;
		scanf("%d%d" , &x , &y);
		--x;
		//printf("   %d %d %d %d " , A[x] , f(x) , X[A[x]] , B[f(x)]);
		--X[A[x]];
		if(--B[f(x)] == 0) ++ans;
		A[x] = y;
		if(B[f(x)]++ == 0) --ans;
		++X[A[x]];
		printf("%d\n" , ans);
	}
	return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
const int M=200001;
int n,A[M],ma,t,cnt;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<=n;i++)ma=max(ma,A[i]);
	for(int i=1;i<=n;i++){
		if(A[i]==ma)cnt++;
		else t=max(t,A[i]);
	}
	if(cnt>1)t=ma;
	for(int i=1;i<=n;i++){
		if(A[i]==ma)printf("%d\n",t);
		else printf("%d\n",ma);
	}
}

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

/*
R8BH3W
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//*/

#define y1 wwgp
#define endl '\n'
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound

#define mp  make_pair
#define pb  push_back
#define read(x) freopen(x".in","r",stdin);
#define write(x) freopen(x".out","w",stdout);
#define   sz(x)  (int)x.size()
#define  all(x)  x.begin(), x.end()
#define  bit(x)  __builtin_popcountll(x)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = int(2e5)+666, maxn2 = int(1e6)+666;
int inf = LONG_MAX; ll linf = LLONG_MAX;
int mod = 69;
int kob (int x, int y) { return ((ll)x * 1ll * y) % mod; } 
int aza (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int kos (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
/// --------------------------@MAIN THEME-----------------------------------

#define int ll

int d[101][100001];
int c[maxn], w[maxn], res;

main () { ios_base::sync_with_stdio(0); cin.tie(0);
	#ifdef ez
		read ("")
	#endif
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++ i) {
		cin >> w[i] >> c[i];
	}

	for (int i = 1; i <= n; ++ i) {
		for (int s = 0; s <= k; ++ s) {
			d[i][s] = d[i-1][s];
			if (s-w[i] >= 0) {
				d[i][s] = max (d[i][s], d[i-1][s-w[i]]+c[i]);
			}
		}                      
	}

	for (int s = 0; s <= k; ++ s)
		res = max (res, d[n][s]);

	cout << res;
	return 0;	
}

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

int main()
{
    long long int t=0,n,i;
    cin>>n;
    for(i=1;i*(i+1)<n;i++)
        if(n%i==0)
            t+=n/i-1;
    cout<<t;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[9][9];
int main()
{
    int h,w,k;
    scanf("%d%d%d",&h,&w,&k);
    for(int i=0;i<h;i++)
        scanf("%s",str[i]);
    int res=0;
    for(int i=0;i<(1<<h);i++)
        for(int j=0;j<(1<<w);j++)
        {
            int cnt=0;
            for(int x=0;x<h;x++)
                for(int y=0;y<w;y++)
                    if((~i>>x&1) && (~j>>y&1))
                        cnt+=(str[x][y]=='#');
            res+=(cnt==k);
        }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 3756
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		double H = sc.nextInt();
		double A = sc.nextInt();
		double ans = Math.ceil(H / A);
		System.out.println((int) ans);
		sc.close();
	}
	
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;

}


Measured memory_bytes: 256
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define watch(x)     cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define forn(i,a,n)  for(int i=a;a==0?i<n:i<=n;i++)



/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
using namespace __gnu_pbds;

const int maxn=1e5+5;


void solve()
{
	int x,n;
	cin>>x>>n;
	
	int ans=INT_MAX;
	int ans2=0;
	//vector<int>v;
	map<int,int> vis;
	forn(i,0,n){
		int a;
		cin>>a;
		//v.pb(a);
		vis[a]=1;
	}
	
	for(int i=-100;i<=110;i++)
	{
		if(vis[i]) continue;
		int val=abs(x-i);
		
		if(ans>val)
		{
			ans=val;
			ans2=i;
		}
	}
	
	cout<<ans2<<endl;
   

}


int main()
{
    fast_cin;
    //case
    {
        //cout<<""<<cas++<<""<<endl;
        solve();
    }

    return 0;
}


Measured memory_bytes: 3664
import Control.Monad( replicateM)
import Data.Array.IArray( listArray, (!))
import Data.Array.Unboxed( UArray)
main = do
    [n_, m_] <- return . map read . words =<< getLine
    alines_ <- replicateM n_ getLine
    blines_ <- replicateM m_ getLine
    let
	a2D, b2D::UArray (Int,Int) Char
	a2D = listArray ((1,1), (n_,n_)) $ concat alines_
	b2D = listArray ((1,1), (m_,m_)) $ concat blines_

	offset = [(k,l) | k<-[1..m_], l<-[1..m_]]
	verify (i,j) = all (checkFrom (i,j)) offset
	checkFrom (i,j) (k,l) = a2D!(i+k-1,j+l-1) == b2D!(k,l)

	bruteforceTopLeft = [(i,j) |	i<-[1..n_-m_+1],
					j<-[1..n_-m_+1]]
    putStr $ if	any verify bruteforceTopLeft
	then "Yes"
	else "No"

Measured memory_bytes: 1020
from collections import deque

h,w = list(map(int,input().split()))
m = [[x for x in input()] for _ in range(h)]
next_que = deque([])
for i in range(h):
  for j in range(w):
    if m[i][j] == '#':
      next_que.append([i,j])


dh = [1,0,-1,0]
dw = [0,1,0,-1]

def bfs(next_que):
  cnt = -1
  while next_que:
    cnt += 1
    que = list(next_que)
    next_que = deque([])
    for cur in que:
      #cur = que.popleft()
      for i in range(4):
        nh = cur[0] + dh[i]
        nw = cur[1] + dw[i]
        
        if nh >= 0 and nh < h and nw >= 0 and nw < w and m[nh][nw] == '.':
          m[nh][nw] = '#'
          next_que.append([nh,nw])
  
  return cnt



cnt = bfs(next_que) 

print(cnt)

Measured memory_bytes: 177244
#include <iostream>

int main()
{
    using namespace std;

    int W, H;
    int x, y, r;

    cin >> W >> H >> x >> y >> r;

    if (x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3112
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	K, X = inputMap()

	tmp = K * 500
	if tmp >= X:
		print("Yes")
	else:
		print("No")


if __name__ == "__main__":
	main()


Measured memory_bytes: 38512
k = int(input())
A = list(map(int, input().split()))
A.reverse()

L = [-1]*(k+1)
R = [-1]*(k+1)

L[0] = 2
R[0] = 2
for i in range(1, k+1):
    if L[i-1]%A[i-1] == 0 or R[i-1]%A[i-1] == 0:
        pass
    else:
        if R[i-1] - L[i-1] >= A[i-1] or L[i-1]%A[i-1]>R[i-1]%A[i-1]:
            pass
        else:
            #print(i, A[i-1], L[i-1], R[i-1])
            print(-1)
            exit()
    if L[i-1]%A[i-1] == 0:
        L[i] = (L[i-1]//A[i-1])*A[i-1]
    else:
        L[i] = (L[i-1]//A[i-1]+1)*A[i-1]
    R[i] = (R[i-1]//A[i-1])*A[i-1]+A[i-1]-1
    #print(i, L[i], R[i])

#print(L)
#print(R)
print(L[k], R[k])

Measured memory_bytes: 15312
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int n,k;
int now=1;
scanf("%d",&n);
scanf("%d",&k);
for(int count=0;count<n;count++){
if(now*2>now+k){now=now+k;}
else{now=now*2;}
}
printf("%d",now);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll inf = 1e18;
int former(const vector<ll> &v, ll x) {
    return upper_bound(ALL(v), x) - v.begin() - 1;
}
int latter(const vector<ll> &v, ll x) {
    return lower_bound(ALL(v), x) - v.begin();
}

int main(){
    int a,b,q; cin >> a >> b >> q;
    vector<ll> s(a);
    rep(i,a) cin >> s[i];
    vector<ll> t(b);
    rep(i,b) cin >> t[i];
    s.push_back(-inf); s.push_back(inf);
    t.push_back(-inf); t.push_back(inf);
    sort(ALL(s)); sort(ALL(t));

    rep(kai,q){
        ll x; cin >> x;
        ll ans = inf;
        rep(i,2){
            ll first = (i ? s[former(s, x)] : s[latter(s, x)]);
            rep(j,2){
                ll second = (j ? t[former(t, first)] : t[latter(t, first)]);
                ans = min(ans, abs(x - first) + abs(first - second));
            }
        }

        rep(i,2){
            ll first = (i ? t[former(t, x)] : t[latter(t, x)]);
            rep(j,2){
                ll second = (j ? s[former(s, first)] : s[latter(s, first)]);
                ans = min(ans, abs(x - first) + abs(first - second));
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 2912
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

int n, k, a[500500];

bool check(int x) {
    int cnt = 0;
    rep(i, 0, n) {
        cnt += (a[i] - 1) / x;
    }
    return cnt <= k;
}

main() {
    cin >> n >> k;
    rep(i, 0, n) {
        cin >> a[i];
    }
    int l = 0, r = 1e9 + 10;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (check(mid)) r = mid;
        else l = mid;
    }
    cout << r << '\n';
}

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

long long pow(long long a, long long n) {
    if (n == 0) return 1;
    
    if (n == 1) return a;
    
    if (n % 2 == 0) {
        long long half = pow(a, n / 2);
        return half * half;
    }
    else return pow(a, 1) * pow(a, n - 1);
}

int main() {
    int n, m;
    cin >> n >> m;
    int ans = (1900 * m + 100 * (n - m)) * pow(2, m);
    cout << ans << endl;
}

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

struct s
{
	int a, b;
};

int main()
{
	int n;
	cin >> n;
	long long sum = 0;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			for (int k = 1; k <= n; ++k)
			{
				int q = __gcd(i,__gcd(j, k));
				sum += q;
			}
		}
	}
	cout << sum << "\n";
	
}


Measured memory_bytes: 3628
import sys
import math
input = sys.stdin.readline

MOD = 10 ** 9 + 7


def main():
    N = int(input())
    p = list(map(int, input().split()))
    ans = 0

    for i in range(N-2):
        if (p[i+1] > p[i+2] and p[i+1] < p[i]) or (p[i+1] < p[i+2] and p[i+1] > p[i]):
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38676
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

using namespace std;

int dp_x[8100][16010] = {}, dp_y[8100][16010] = {};

typedef pair<int,int> pii;

int main(){

  string s;
  int x, y;

  cin >> s >> x >> y;

  vector<int> dx, dy;

  int dir = 1, sum = 0;
  REP(i,(int)s.length()){
    if(s[i] == 'F'){
      sum++;
    }else{
      if(dir == 1){
        dx.pb(sum);
      }else{
        dy.pb(sum);
      }
      sum = 0;
      dir *= -1;
    }

    if(i == (int)s.length() - 1 && sum != 0){
      if(dir == 1){
        dx.pb(sum);
      }else{
        dy.pb(sum);
      }
    }
  }

  dp_x[0][8000] = 1; dp_y[0][8000] = 1;
  REP(i,(int)dx.size()){
    if(i == 0){
      dp_x[1][8000 + dx[i]] = 1;
      continue;
    }
    REP(j,16002){
      if(j - dx[i] >= 0){
        dp_x[i + 1][j] = max(dp_x[i][j - dx[i]], dp_x[i + 1][j]);
      }
      if(j + dx[i] <= 16000){  
        dp_x[i + 1][j] = max(dp_x[i + 1][j], dp_x[i][j + dx[i]]);
      }
    }
  }

  REP(i,(int)dy.size()){
    REP(j,16002){
      if(j - dy[i] >= 0){
        dp_y[i + 1][j] = max(dp_y[i][j - dy[i]], dp_y[i + 1][j]);
      }
      if(j + dx[i] <= 16000){  
        dp_y[i + 1][j] = max(dp_y[i + 1][j], dp_y[i][j + dy[i]]);
      }
    }
  }

  if(dp_x[dx.size()][x + 8000] == 1 && dp_y[dy.size()][y + 8000] == 1){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
 
  return 0;
}



Measured memory_bytes: 499968
n = int(input())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))
length = 0
for i in range(n):
    for j in range(i + 1, n):
        length += ((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) ** 0.5
print(length / n * 2)


Measured memory_bytes: 2940
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import numpy as np

N = int(input())
A = list(map(int, input().split()))
count = 0

while(True):
    for i in range(len(A)):
        if A[i] % 2 == 1:
            print(count)
            sys.exit()
        A[i] /= 2
    count += 1


Measured memory_bytes: 12392
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    if(A < 9 && B < 9) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

bool check(vector<P> s) {
  int h = 0;
  for (P p : s) {
    int b = h + p.first;
    if (b < 0) return false;
    h += p.second;
  }
  return true;
}

int main() {
  int N;
  cin >> N;
  vector<P> ls, rs;
  int total = 0;
  rep(i, N) {
    string S;
    cin >> S;
    int h = 0, b = 0;
    for (char c : S) {
      if (c == '(') {
        h++;
      } else {
        h--;
      }
      b = min(b, h);
    }
    if (h > 0) {
      ls.emplace_back(b, h);
    } else {
      rs.emplace_back(b - h, -h);
    }
    total += h;
  }
  sort(ls.rbegin(), ls.rend());
  sort(rs.rbegin(), rs.rend());
  if (check(ls) && check(rs) && total == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 18976
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i64> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn read_ints() -> std::vec::Vec<i64> {
    str_to_ints(read_line())
}

fn prime_numbers(n: i64) -> std::vec::Vec<i64> {
    let mut ret = std::vec::Vec::new();
    for i in 2..(n+1) {
        let mut is_prime = true;
        for j in 0..ret.len() {
            if i % ret[j] == 0 {
                is_prime = false;
            }
        }
        if is_prime {
            ret.push(i);
        }
    }
    return ret;
}

fn main() {
    let n: i64 = read_ints()[0];
    if n <= 9 {
        println!("0");
        return;
    }

    let primes = prime_numbers(n);

    let mut factor_table: std::vec::Vec<i64> = std::vec::Vec::new();
    for i in 0..primes.len() {
        factor_table.push(0);
    }

    for i in 2..(n+1) {
        let mut tmp: i64 = i;
        for j in 0..primes.len() {
            while tmp % primes[j] == 0 {
                factor_table[j] += 1;
                tmp /= primes[j];
            }
        }
    }

    let mut ret: i64 = 0;

    // 2 * 4 * 4
    for i in 0..(factor_table.len()-2) {
        for j in (i+1)..(factor_table.len()-1) {
            for k in (j+1)..factor_table.len() {
                if factor_table[i] >= 2 && factor_table[j] >=4 && factor_table[k] >= 4 {
                    ret += 1;
                }
                if factor_table[i] >= 4 && factor_table[j] >=2 && factor_table[k] >= 4 {
                    ret += 1;
                }
                if factor_table[i] >= 4 && factor_table[j] >=4 && factor_table[k] >= 2 {
                    ret += 1;
                }
            }
        }
    }
    // 2 * 24
    // 4 * 14
    for i in 0..(factor_table.len()-1) {
        for j in (i+1)..(factor_table.len()) {
            if factor_table[i] >= 2 && factor_table[j] >= 24 {
                ret += 1;
            }
            if factor_table[i] >= 24 && factor_table[j] >= 2 {
                ret += 1;
            }
            if factor_table[i] >= 4 && factor_table[j] >= 14 {
                ret += 1;
            }
            if factor_table[i] >= 14 && factor_table[j] >= 4 {
                ret += 1;
            }
        }
    }

    // 74
    for i in 0..factor_table.len() {
        if factor_table[i] >= 74 {
            ret += 1;
        }
    }

    println!("{}", ret);
}

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

using namespace std;

typedef long long int ll;
typedef long long unsigned int llu;
#define tc long long int t; cin>>t; while(t--)
#define  sync ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define mpi unordered_map<ll, ll>
#define mpc unordered_map<char, ll>
#define map_loop(it,m) for(auto it = m.begin(); it!=m.end(); it++)
#define rep(i,n) for(ll i=0;i<n;i++)


int main(){
  
  ll n;
  cin>>n;
  string s;
  cin>>s;
  mpc m;
  vector<int> r,g,b;
  for(int i=0;i<s.size();i++){
	  m[s[i]]++;
	  if(s[i]=='R')
	  r.pb(i);
	  else if(s[i]=='G')
	  g.pb(i);
	  else if(s[i]=='B')
	  b.pb(i);
	  
  }
  ll exc=0;
  for(int i=0;i<r.size();i++){
	  for(int j=0;j<g.size();j++){
		  if(((r[i]+g[j])%2==0)&&s[(r[i]+g[j])/2]=='B')
		  exc++;
	  }
  }
  
  for(int i=0;i<g.size();i++){
	  for(int j=0;j<b.size();j++){
		  if(((g[i]+b[j])%2==0)&&s[(g[i]+b[j])/2]=='R')
		  exc++;
	  }
  }
  for(int i=0;i<r.size();i++){
	  for(int j=0;j<b.size();j++){
		  if(((r[i]+b[j])%2==0)&&s[(r[i]+b[j])/2]=='G')
		  exc++;
	  }
  }
  
  ll ans=m['R']*m['B']*m['G']-exc;
  
  cout<<ans<<endl;
  
  
  
}






















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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int look = 1;
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int cur;
        cin >> cur;
        if (cur != look) {
            ans++;
        } else {
            look++;
        }
    }
    if (ans == n) ans = -1;
    cout << ans << '\n';
}

Measured memory_bytes: 256
n = int(input())
vote = dict()
for i in range(n):
  s = input()
  if s not in vote.keys():
    vote[s] = 0
  else:
    vote[s] += 1

res = []
mx = max(vote.values())
for key, value in vote.items():
    if value== mx:
        res.append(key)

res = sorted(res)
for i in res:
  print(i)

Measured memory_bytes: 33116
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FS first
#define SC second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for (auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for (auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

// int gcd(int x, int y) {
//    if(x < y) swap(x, y);
//    if(x % y == 0) return y;
//    else return gcd(y, x % y);
// }

signed main()
{
   int N; cin >> N;
   V<int> a(N);
   REP(i, N) {
      cin >> a[i];
   }

   int m = a[0];
   REP(i, N-1) {
      m = __gcd(m, a[i+1]);
   }
   cout << m << endl;

   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <cstdio>
#include <cstring>
#include<cctype>
#define INF 0x3f3f3f3f
#define lb long double
#define LINF 0x3f3f3f3f3f3f3f3f
#define ull unsigned long long
#define random(x) (rand()%x)
#define rep(i, a, b) for(int i=a;i<b;i++)
#define req(j, a, b) for(int j=a;j<b;j++)
#define mem(a, b) memset(a, b, sizeof(a))
#define PI 3.14
#define K 20

using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
const double eps = 1e-14;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const int hash_mod = 19260817;

inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline double dbread()
{
    double X=0,Y=1.0; int w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=X*10+(ch^48),ch=getchar();
    ch=getchar();//读入小数点
    while(isdigit(ch)) X+=(Y/=10)*(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

int v[10005];
double w[1005];
int dp[1005][1005];

int sum = 0;

ll gcd(ll a,ll b)//辗转相除法（欧几里德算法）求最大公约数
{
    return b ? gcd(b,a%b) : a;
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);//最小公倍数
}


int main()
{
    char c;
    cin >> c;
    int t = c - 'a';
    t = (t + 1) % 26;
    char ans = t + 'a';
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int mod=998244353;
struct P{
	int x,y;
}a[205];
int n,bin[205],ans=0;
int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
	bin[0]=1;
	for(int i=1;i<=n;i++) bin[i]=add(bin[i-1],bin[i-1]);
	ans=add(bin[n],mod-1-n-n*(n-1)/2);
	for(int i=1;i<=n;i++){
		for(int p=i+1;p<=n;p++){
			int sum=0;
			for(int j=p+1;j<=n;j++){
				if((a[p].x-a[i].x)*(a[j].y-a[p].y)==(a[j].x-a[p].x)*(a[p].y-a[i].y)) sum++;
			}
			ans=add(ans,mod-bin[sum]+1);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  rep(i, N) cin >> W[i];
  map<string, int> m;
  char hip = W[0][0];
  rep(i, N) {
    if (m.find(W[i]) != m.end()) {
      cout << "No" << endl;
      return 0;
    }
    if (W[i][0] != hip) {
      cout << "No" << endl;
      return 0;
    }
    m[W[i]] = 1;
    hip = W[i][W[i].size() - 1];
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(N+1);
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    A[x]=i;}
  for(int i=0;i<N;i++){
    cout<<A[i+1]+1<<" ";
  }
  return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

class UnionFind {
    public : 
        vector<int> size, p;

        UnionFind(int sz): p(sz), size(sz, 1) {
            rep (i, sz) p[i] = i;
        }

        void init(int sz) {
            p.resize(sz);
            size.assign(sz, Inf);
            rep (i, sz) p[i] = i;
        }

        int root(int x) {
            if (x != p[x]) p[x] = root(p[x]);
            return p[x];
        }

        bool merge(int x, int y) {
            x = root(x);
            y = root(y);
            if (x == y) return false;
            if (size[x] < size[y]) swap(x, y);
            size[x] += size[y];
            p[y] = x;
            return true;
        }

        bool same(int x, int y) {
            return root(x) == root(y);
        }

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false); 
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind uf1 = UnionFind(n), uf2 = UnionFind(n);
    
    rep (i, k) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        uf1.merge(p, q);
    }
    rep (i, l) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        uf2.merge(r, s);
    }
    map<pair<int, int>, int > mp;
    rep (i, n) {
        mp[make_pair(uf1.root(i), uf2.root(i))]++;
    }
    rep (i, n) {
        if (i != n - 1) {
            cout << mp[make_pair(uf1.root(i), uf2.root(i))] << " ";
        } else {
            cout << mp[make_pair(uf1.root(i), uf2.root(i))] << endl;
        }
    }
    
    return 0;
}



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

using ll = long long;

ll H;

ll rec(ll h){
    if(h == 1) return 1;
    return 2 * rec(h / 2) + 1;
}

void solve(){
    cout << rec(H);
}
int main(){
    cin >> H;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;
#define LL long long

int N,K,S;
string ans="";

int main(){
	cin>>N>>K>>S;
	for(int i=0;i<K;i++){
		if(i)ans+=" ";
		ans+=to_string(S);
	}
	for(int i=K;i<N;i++){
		if(i)ans+=" ";
		ans+=to_string(S==1000000000?S-1:S+1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#105_D
N,M=map(int,input().split())
A=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+A[i]
S_Mod=[S[i]%M for i in range(N+1)]
T=sorted(S_Mod)

cnt=0
tmp=1
for i in range(N):
    if T[i]==T[i+1]:
        tmp+=1
    else:
        cnt+=tmp*(tmp-1)//2
        tmp=1
cnt+=tmp*(tmp-1)//2

print(cnt)

Measured memory_bytes: 16844
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int n;
     cin >> n;
     long long int m;
     m = n;
     int a = 0;
     long long int d = 0;
     long long int b = 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10;
     int c = 0;
     for(int i = 0; i < 10; i ++){
         a += n % b;
         
         c += n/b;
         d = n/b;
         n -= d * b;
         b /= 10;
     }
     
     if(m % c == 0){
         cout << "Yes"<< endl;
     }else{
         cout << "No" << endl;
     }
     
}

Measured memory_bytes: 256
#line 1 "main.cpp"

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { ++i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr range(itr l_, itr r_) noexcept : l(l_), r(std::max(l_, r_)) { }
  constexpr iterator begin() const noexcept { return l; }
  constexpr iterator end() const noexcept { return r; }
};

struct revrange {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { --i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr revrange(itr l_, itr r_) noexcept : l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr iterator begin() const noexcept { return r; }
  constexpr iterator end() const noexcept { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  size_t N;
  std::cin >> N;
  std::vector<i32> A(N);
  for (auto &x: A) {
    std::cin >> x;
  }
  i32 ans = 0;
  for (auto i: range(0, N)) {
    if ((i + 1) % 2 == 1 && A[i] % 2 == 1) {
      ++ans;
    }
  }
  std::cout << ans << '\n';
  return 0;
}

/**
 * @title Template
 */


Measured memory_bytes: 3620
using System;

public class Hello
{
    const int MOD = 1000000007;
    const int FMAX = 510000;
    public static void Main()
    {
        var fac = new long[FMAX];
        var finv = new long[FMAX];
        var inv = new long[FMAX];
        COMinit(fac, finv, inv);
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var a = int.Parse(line[2]);
        var b = int.Parse(line[3]);
        var ha1 = h - a - 1;
        var imax = w - b;
        var ret = 0L;
        for (int i = 0; i < imax; i++)
        {
            var ww1 = ha1 + b + i;
            var ww2 = a - 2 + imax - i;
            ret += (COM(fac, finv, inv, ww1, ha1) * COM(fac, finv, inv, ww2, a - 1)) % MOD;
            ret %= MOD;
        }
        Console.WriteLine(ret);
    }
    public static long COM(long[] fac, long[] finv, long[] inv, int n, int k)
    {
        if (n < k) return 0;
        if (n < 0 | k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    public static void COMinit(long[] fac, long[] finv, long[] inv)
    {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < FMAX; i++)
        {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
}

Measured memory_bytes: 22880
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a,b,c,d = map(int,input().split())
ab = abs(b - a)
bc = abs(c - b)
ac = abs(c - a)
if ac <= d:
    print("Yes")
    sys.exit()
if ab <= d and bc <= d:
    print("Yes")
    sys.exit()
print("No")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    while(a>0 && c>0) {
        c -= b;
        if(c<=0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll x,a,b;cin>>x>>a>>b;
    cout<<(abs(x-a) < abs(b-x) ? 'A' : 'B') << ednl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int r,c,d;
    cin>>r>>c>>d;
    int count=0;
    while(count<10){
        int f=r*d-c;
        cout<<f<<endl;
        d=f;
        count++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;

#define all(i) i.begin(), i.end()
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	int num = 0; cin >> num;
	string dat[12] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	rep(i, num)
	{
		string str; cin >> str;
		vector<int> hit(10, 0);
		rep(j, (int)str.size())
		{
			hit[str[j] - '0'] += 1;
			if (j == 0 || str[j - 1] == '0') {}
			else if (str[j] == '0')
			{
				int tmp = str[j - 1] - '0', n = hit[tmp];
				while (1)
				{
					if (n <= (int)dat[tmp].size()) { break; }
					n -= (int)dat[tmp].size();
				}
				printf("%c", dat[tmp][n - 1]);
				rep(i, 10) { hit[i] = 0; }
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3220
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

N, A, B, K = map(int, input().split())

p = 998244353
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

for a in range(N+1):
    if (K - A*a) % B == 0 and A*a <= K:
        b = (K- A*a) // B
        ans += cmb(N, a, p)*cmb(N, b, p)%p

print(ans%p)



Measured memory_bytes: 38956
n = gets.to_i

foo = 1
(1..n).each{ |i| foo*=i }

def factoring(foo)
    hoge = 2
    array = []

    while foo >= hoge
        if (foo % hoge) == 0 
            foo /= hoge
            array.push(hoge)
            hoge -= 1
        end
        hoge += 1
    end

    array2 = array.uniq
    array3 = []
    array2.each{ |var| array3.push(array.count{ |i| i==var }) }

    result = 1
    array3.each{ |var| result *= (var + 1)}
    return result
end

puts factoring(foo) % (10**9 + 7)

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> p){
    LL max_a = 1e9;
    LL step = max_a / N;
    VLL b_list(N, 0);
    REP(i, N) {
        cout << (step * (i+1)) << (i+1 == N ? "\n" : " ");
        b_list[i] += step * (N-i-1);
        b_list[p[i]-1] += i+1;
    }

    REP(i, N) {
        cout << b_list[i] << (i+1 == N ? "\n" : " ");
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 896
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a,b,c; cin>>a>>b>>c;
    ll k = a-b;
    cout<<max(0LL, c-k);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

vl a;
void dfs(ll n,ll x){
    if(n>=x){
        a.pb(x);
        x*=10;
        dfs(n,x+3);
        dfs(n,x+5);
        dfs(n,x+7);
    }
    return;
}


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

    ll n;
    cin >> n;
    dfs(n,ll(0));
    ll cnt = 0;
    
    rep(i,a.size()){
        vi mp(10,0);
        string tmp = to_string(a[i]);
        rep(j,tmp.size()){
            mp[tmp[j]-'0']++;
        }
        if(mp[3]!=0 &&mp[5]!=0 &&mp[7]!=0){cnt++;}

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

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    s = list(input())
    t = list(input())
    n = len(s)
    s_dict = defaultdict(int)
    t_dict = defaultdict(int)
    for i in range(n):
        s_dict[s[i]] += 1
        t_dict[t[i]] += 1

    #print(s_dict)
    #print(t_dict)

    if sorted(list(s_dict.values()))== sorted(list(t_dict.values())):
        print('Yes')
    else:
        print('No')
        

if  __name__=='__main__':
    main()


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


def solve(N: int, d: "List[int]"):
    d = set(sorted(d)) # uniq 処理
    return(len(d))
    

# Generated by 1.1.7.1 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)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, d))

if __name__ == '__main__':
    main()


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

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

using namespace std;

int main(){
  int n;
  cin>>n;
  
  map<pair<int,int>, int> m;

  for(int i=1;i<n;i++){
    int tmp1=i;
    int tmp2=n-i;
    if(tmp1==tmp2)continue;
    if(tmp1>tmp2){
      int t=tmp1;
      tmp1=tmp2;
      tmp2=t;
    }

    m[make_pair(tmp1,tmp2)]=1;
  }
  
  cout<<m.size();
  return 0;
}


Measured memory_bytes: 31488