akhauriyash/Code-Regression huggingface dataset:
k,n =map(int,input().split())
mod = 998244353
fact = [1]*(n+k+1)
rfact = [1]*(n+k+1)
for i in range(n+k):
    fact[i+1] = rr = ((i+1) * fact[i]) % mod
    rfact[i+1] = pow(rr, mod-2, mod)
def comb(N, K,mod):
    return fact[N] * rfact[K] * rfact[N-K] % mod
kota = []
for i in range(2,k+2):
  ans = 0
  if i %2 == 1:
    pp = (i+1)//2
    pm = i - pp
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q<0:
        break
      r = k-p*2
      if r <0:
        r = 0
      if n+r-1 < n-q:
        continue
      ans += sen* comb(n+r-1,n-q,mod)%mod
    kota.append(ans%mod)
  else:
    pp = i//2 +1
    pm = i//2 -1
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q<0:
        break
      r = k-p*2-1
      if r <0:
        r = 0
      if n+r-1 < n-q:
        continue
      ans += sen* comb(n+r-1,n-q,mod)%mod
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q-1<0:
        break
      r = k-p*2-1
      if r <0:
        r = 0
      if n+r-2 < n-q-1:
        continue
      ans += sen* comb(n+r-2,n-q-1,mod)%mod
    kota.append(ans%mod)
for i in kota:
  print(i)
for i in range(len(kota)-2,-1,-1):
  print(kota[i])

Measured memory_bytes: 53084
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, int> pi;
const int MAXN = 205;

int n, a[MAXN];

int main(){
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	vector<int> ans;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			ans.push_back(1);
			if(j + 1 < n && a[j] > a[j+1]){
				swap(a[j], a[j+1]);
				ans.push_back(n - 1);
			}
		}
	}
	printf("%d\n", ans.size());
	for(auto &i : ans) printf("%d\n", i);
}


Measured memory_bytes: 764
#include <stdio.h>
int main (void){
char a[100];
for(int i=0;i<3;i++){
    scanf("%c",&a[i]);
    }
for(int i=0;i<3;i++){
    if(a[i]=='1'){
        a[i]='9';
    }else if(a[i]=='9'){
        a[i]='1';
    }
}
printf("%c%c%c",a[0],a[1],a[2]);
}

Measured memory_bytes: 128
//usr/bin/env swift $0 $@;exit
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let n=arr[0]
let a=arr[1]
let b=arr[2]
var r=0
for i in 1...n {
	var j=i
	var s=0
	while j>0 {
		s+=j%10
		j/=10
	}
	if a<=s&&s<=b {r+=i}
}
print(r)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define MAX 999999999

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

typedef long long ll;

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

    int n, m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << "\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#ARC096C
import copy
import sys
import math

#n = int(input())
tmp = input().split()
a,b,c,x,y = list(map(lambda a: int(a), tmp))

t=min(x,y)
u=max(x,y)

print(min(a*x+b*y, min(2*t*c+(x-t)*a+(y-t)*b, 2*u*c)))

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

int main(){
  string S, T;
  int A, B;
  string U;
  cin >> S >> T >> A >> B >> U;
  if(S==U){
    cout << A-1 << " " << B << endl;
  }
  else{
    cout << A << " " << B-1 << endl;
  }
}

Measured memory_bytes: 256
import Control.Monad

main=do
  n<-readLn
  ss<-replicateM n getLine
  print $ solve n ss

solve :: Int->[String]->Int
solve n ss
  | lAfB /= 0 && lA == lAfB && fB == lAfB = nAB + bonus - 1
  | otherwise = nAB + bonus
  where
  bonus = min lA fB
  count [] = 0
  count ('A':'B':s)=1+count s
  count (c:s)=count s
  nAB = sum$map count ss
  lAs = filter((=='A').last)ss
  lA = length lAs
  fB = length$filter((=='B').head)ss
  lAfB = length$filter((=='B').head)lAs


Measured memory_bytes: 5500
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int n = scanner.nextInt();
    Map<Character, Integer>[] freqs = new Map[n];
    for (int i = 0; i < n; i++) {
      freqs[i] = new HashMap<>();
      for (char ch : scanner.next().toCharArray()) freqs[i].put(ch, freqs[i].getOrDefault(ch, 0) + 1);
    }

    List<Character> ans = new ArrayList<>();
    for (char ch = 'a'; ch <= 'z'; ch++) {
      int min = 51;
      for (int i = 0; i < n; i++) min = Math.min(min, freqs[i].getOrDefault(ch, 0));
      if (min < 51) for (int i = 0; i < min; i++) ans.add(ch);
    }

    char[] chars = new char[ans.size()];
    for (int i = 0; i < ans.size(); i++) chars[i] = ans.get(i);
    System.out.println(new String(chars));
  }
}


Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
llint k;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k;
	cout << a[k-1] << endl;
	
	return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
A = list(map(int, input().split()))

OK = 10**9
NG = 0

while OK - NG > 1:
    ans = 0
    mid = (OK+NG)//2
    for a in A:
        ans += (a-0.1)//mid
    if ans > K:
        NG = mid
    else:
        OK = mid
print(OK)

Measured memory_bytes: 94124
N = int(input())
a = list(map(int, input().split()))

suma = sum(a)
sums = [0]
for i in range(N):
    sums.append(sums[-1] + a[i])

ans = 10**14
for i in range(1, N):
    ans = min(ans, abs(suma - sums[i] * 2))

print(ans)


Measured memory_bytes: 24824
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m = MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
void solve(){
  	int n;
  	cin >> n;
  	vector<int> v(n);
  	for (auto &it : v) cin >> it;
  	
  	int ret = 0;
  	for (auto it : v){
		while ( it % 2 == 0){
		  	it >>= 1;
		  	ret++;
		}
	}
  	cout << ret << endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main(void){
	int N,H,i,ans=0,m=0;
	scanf("%d%d",&N,&H);
	int a,b[N];
	for(i=0;i<N;i++){
		scanf("%d%d",&a,&b[i]);
		if(a>m) m=a;
	}
	qsort(b, N, sizeof(int), compare);
	i=0;
	while(b[i]>m && i<N && H>0){
		H-=b[i++];
		ans++;
	}
	if(H>0)	ans += (H+m-1)/m;
	
	printf("%d",ans);
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

ll fn(ll x){
  ll last=(ll)sqrt(x);
  while(x%last != 0)last--;
  return last;
}

int main(){
  ll x; cin >> x;
  ll l = fn(x);
  cout << l+(x/l)-2 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out){
            int n = in.nextInt();
            int[] arr = new int[n];
            int[] mod1 = new int[100001];
            int[] mod2 = new int[100001];
            for (int i = 0; i <n ; i++) {
                arr[i]=in.nextInt();
            }
            for (int i = 0; i <n; i+=2){
                mod1[arr[i]]++;
            }
            for (int i = 1; i <n ; i+=2) {
                mod2[arr[i]]++;
            }
            int e1 = 0;
            int e2 = 0;
            int o1 = 0;
            int o2 = 0;
            for (int i = 1; i <mod1.length ; i++) {
                if (mod1[i] >= mod1[e1]) {
                    e2=e1;
                    e1=i;
                }
                else if (mod1[i] > mod1[e2]) e2=i;
            }
            for (int i = 1; i <mod1.length ; i++) {
                if (mod2[i] >= mod2[o1]) {
                    o2=o1;
                    o1=i;
                }
                else if (mod2[i] > mod2[o2]){
                    o2=i;
                }
            }
            if (e1!=o1) System.out.println((n/2-mod1[e1]) + (n/2-mod2[o1]));
            else {
                System.out.println(Math.min((n/2-mod1[e2])+(n/2-mod2[o1]) , (n/2-mod1[e1])+(n/2-mod2[o2])));
            }
        }




    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 37584
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = float('inf')
for i in range(N-K+1):
    r = X[K-1+i]-X[i] + min(abs(X[K-1+i]), abs(X[i]))
    ans = min(ans, r)

print(ans)

Measured memory_bytes: 15020
#include <cmath>
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int a, b, h, m;
const double PI = M_PI;

int main() {
    cin >> a >> b >> h >> m;
    double rad = (11 * m - 60 * h) * PI / 360;
    double ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad));
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}


Measured memory_bytes: 3552
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int a,b,c; cin >> a >> b >> c;
  if (a+b>=c){cout << "Yes" << endl;}
  else {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 REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
#define pint pair <int, int>
void dfs(string s, int sp, int n) {
  if (SZ(s) == n) {
	  cout << s << endl;
	  return;
	}
  REP(i, sp) {
	char c = 'a' + i;
	dfs(s + c, sp, n);
  }
  dfs(s + (char) ('a' + sp), sp + 1, n);
}

int main() {
  int n;
  cin >> n;
  dfs("", 0, n);
  return 0;
}


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

using namespace std;

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

Measured memory_bytes: 256
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()

def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(1, n):
        if A[i - 1] > A[i]:
            ans += A[i - 1] - A[i]
            A[i] = A[i - 1]
    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 94020
import java.io.*;

class Main {
	public static void main(String[] args)  throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean end = false;

		while (end == false) {
			// ??\?????????????????????
			String temp = br.readLine();
			String[] numbers = temp.split(" ");// ????????¨??????????????????
			int H = Integer.parseInt(numbers[0]);
			;// ??????
			int W = Integer.parseInt(numbers[1]);
			;// ???

			if (H >= 3 || W <= 100 && H > 0 && W > 0) {
				// ????§???¢??????????????????
				for (int i = 0; i < H; i++) {

					if (i == 0 || i == H - 1) {
						for (int j = 0; j < W; j++) {
							System.out.print("#");
						}
					} else {
						System.out.print("#");
						for (int j = 1; j < W - 1; j++) {
							System.out.print(".");
						}
						System.out.print("#");
					}

					System.out.println();// ?¬??????????
				}
				System.out.println();// ??????

			} else if (H == 0 && W == 0) {
				end = true;// HW?????????0??????????????????
			}
		}


	}
}

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

int main() {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
cm = []
h.times do |i|
  s = gets.chomp
  cm.push(s) if s.count('.') != w
end
1.upto(w) do |i|
  f = true
  cm.each do |x|
    f = false if x[w - i] != '.'
  end
  if f
    cm.each do |x|
      x[w - i] = ''
    end
  end
end
cm.each do |x|
  puts x
end

Measured memory_bytes: 1916
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7;
using namespace std;
ll t;
ll arr[200005];
int main()
{
    ll a,b,c,d,e,f,g,i,j,k,sum;
    vector<ll>v;
    cin>>a>>b;
    for(i=1;i<=a;i++)cin>>arr[i];
    f=0;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=a;j++)
        {
            d=b-i-j;
            sum=0;
            v.clear();
            if(d<0||i+j>b||i+j>a)continue;
            for(k=1;k<=i;k++)
            {
                v.push_back(arr[k]);
                sum+=arr[k];
            }
            for(k=a;k>a-j;k--)
            {
                v.push_back(arr[k]);
                sum+=arr[k];
            }
            sort(v.begin(),v.end());
            for(k=0;k<i+j&&d!=0;k++)
            {
                if(v[k]>=0)break;
                sum=sum-v[k];
                --d;
            }
            f=max(sum,f);
        }
    }
    cout<<f<<endl;
    return 0;
}



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

using namespace std;

int main()
{
    int a;
    cin >> a;
    int s=0;
    if(a/100==1){
        s=s+1;
    }
    if(a%10==1){
        s=s+1;
    }
    if(a/10%10){
        s=s+1;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
    int n,m;
    m=100000;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        m=m*21;
        if(m%20000==0)m=m/20;
        else
        {
            m=m/20000;
            m=m*1000+1000;
        }
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 2980
class Solution:

    def solve(self, N: int, P: int, S: str):

        if P == 2 or P == 5:
            answer = 0
            for idx, s in enumerate(S):
                if int(s) % P == 0:
                    answer += idx + 1

        else:
            answer = 0
            U = [0] * P  # int(S[i,N] mod P
            U[0] += 1

            num = 0
            base10_mod_p = 1
            for i in range(N):
                num = (num + int(S[N-i-1]) * base10_mod_p) % P
                base10_mod_p = (base10_mod_p * 10) % P

                U[num] += 1

            for u in U:
                answer += u * (u-1) // 2

        return answer


if __name__ == '__main__':

    # standard input
    N, P = map(int, input().split())
    S = input()

    # solve
    solution = Solution()
    answer = solution.solve(N, P, S)
    print(answer)


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

int main()
{
	string buf;
	getline(cin, buf);
	int N;
	N = stoi(buf);
	int runCount = 0;
	int Run = 0;
	int outCount = 0;

	while(1)
	{
		if(N == 0)
		{
			return 0;
		}
		string str;
		getline(cin, str);
		if(str == "HOMERUN")
		{
			Run += runCount + 1;
			runCount = 0;
		}
		else if(str == "HIT")
		{
			runCount++;
			if(runCount == 4)
			{
				Run++;
				runCount = 3;
			}

		}
		else if(str == "OUT")
		{
			outCount++;
			if(outCount == 3)
			{
				cout << Run << endl;
				outCount = 0;
				runCount = 0;
				Run = 0;
				N--;

			}

		}

	}



}

Measured memory_bytes: 3192
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<bits/stdc++.h>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3F3F3F3F
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,m; 
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
    cin>>n>>m;
    cout<<(n-1)*(m-1);
	//system("pause");
	return 0;	
}

Measured memory_bytes: 256
fun judge(ret: Boolean, ok: String, ng: String) = if (ret) println(ok) else println(ng)
fun isInRect(w:Int,h:Int,x:Int,y:Int,r:Int): Boolean =
  if (r <= x && x <= w - r && r <= y && y <= h - r) true else false

fun main(args: Array<String>) {
  val (w,h,x,y,r) = readLine()!!.split(' ').map(String::toInt)
  judge(isInRect(w,h,x,y,r), "Yes", "No")
}



Measured memory_bytes: 34024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

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

ll lcm(ll x, ll y) {
    return x*y / gcd(x,y);
}

int main(void)
{
    IOS
    ll a,b; cin >> a >> b;
    ll g = gcd(a,b);
    int ans = 1;
    ll g2 = g;
    for (ll i = 2; i*i <= g ; i++) {
        if (g2 % i == 0) {
            ans++;
            while(g2 % i == 0) g2 /= i;
        }
    }
    if (g2 != 1) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef long long ll;
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define rep(i, n) for(int i = 0; i < n; ++i) 
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) 

#define TRACE(x...) x
#define watch(x) TRACE(cout << #x" = " << x << endl)
#define watcharr(i, x) TRACE(cout << #x" = "); rep(i, sz(x)) cout << x[i] << " "; cout << endl

int main() {
	
	ifstream infile("input.in");
	if(infile.good()) cin.rdbuf(infile.rdbuf());
	
    long long A, B, N;
    cin >> A >> B >> N;


    long long v = min(B-1, N);
    long long res = ll(A * v / B) - A * ll(v / B);

    cout << res << endl;
	
	if(infile.good()) infile.close();
	return 0;
	
}



Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        
        while (true) {
            int N = in.nextInt();
            int L = in.nextInt();
            if (N == 0 && L == 0) break;
            
            int[] arr = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            
            int max = -999;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    if (arr[i] + arr[j] <= L)
                        max = Math.max(max, arr[i] + arr[j]);
                } 
            }
            
            if (max < 0) System.out.println("NONE");
            else System.out.println(max);
        }
    }
}



Measured memory_bytes: 51268
// HOPE IS A GOOD THING MAY BE THE BEST OF THINGS AND NO GOOD THINGS EVER DIES  <3 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0)
#define testcase ll T; cin >> T; for (int tc = 1; tc <= T; tc++)
const long long M = 2e5 + 10, M2 = 1e6 + 10, oo = 1e9 + 7;
ll lvl[M], vis[M];
vector < ll > adj[M];
pll bfs (ll s) {
    queue < ll > q;
    q.push(s);
    vis[s] = 1;
    lvl[s] = 0;
    while (!q.empty()) {
        ll u = q.front();
        q.pop();
        for (auto v : adj[u]) {
            if (vis[v]) {
                //cout << v << endl;
                return pll(lvl[v], lvl[u] + 1 - lvl[v]);
            }
            vis[v] = 1;
            lvl[v] = lvl[u] + 1;
            q.push(v);
        }
    }
}
int main () {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    for (ll i = 1, x; i <= n; i++) {
        cin >> x;
        adj[i].pb(x);
    }
    pll ln = bfs(1);
    //cout << ln << " " << k % ln << endl;
    //cout << ln.first << " " << ln.second << " " << lvl[2] << " " << k % ln.second << endl;
    ll ans = 0;
    if (k <= ln.first) {
        for (ll i = 1; i <= n; i++) {
            if (lvl[i] == k) {
                cout << i << endl;
                return 0;
            }
        }
    }
    for (ll i = 1; i <= n; i++) {
        if (lvl[i] == ((k - ln.first) % ln.second) + ln.first) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 17728
let n = stdin.ReadLine() |> int
let sArray = [|
    for _ in 1..n -> stdin.ReadLine()
|]

let counted =
    sArray 
    |> Seq.countBy (fun x -> x)
    |> Seq.cache

let max = counted |> Seq.maxBy (fun (str, i) -> i) |> snd

counted 
|> Seq.groupBy (fun (str, i) -> i) 
|> Seq.filter (fun (i, seq) -> i = max)
|> Seq.collect (fun (i, seq) -> seq)
|> Seq.map (fun (str, i) -> str)
|> Seq.sort
|> Seq.iter (fun str -> stdout.WriteLine str)


Measured memory_bytes: 61048
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	char alpha; cin >> alpha;
	if( 'a' <= alpha and alpha <= 'z' ) cout << 'a' << endl;
	else cout << 'A' << endl;
}

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

int main(void) {
  ll A, B, K;
  cin >> A >> B >> K;

  for (ll i = 100; i >= 1; i--) {
    if (A % i == 0 && B % i == 0) {
      K--;
      if (K == 0) {
        cout << i << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

using namespace std;

int n, x;
int l[1001];

int main() {
    cin >> n >> x;
    int sol = 1, pos = 0;
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
        pos += l[i];
        if (pos <= x)
            sol++;
        else
            break;
    }

    cout << sol;

    return 0;
}


Measured memory_bytes: 256
//@sakshjha
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979
const ll MOD =1000000007;
const ll N=1000005;
ll pow (ll x, ll y, ll m);
int main()
{
    IOS
    ll t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        string s1=t.substr(0,s.size());
        if(s1==s && t.size()==s.size()+1)
            cout<<"Yes"<<"\n";
        else
            cout<<"No"<<"\n";
    }
    return 0;
}


/*ll pow (ll x, ll y, ll m)
{
    ll res=1;
    x=x%m;
    if(x==0)
        return 0;
    while(y>0)
    {
        if(y&1)
        {
            res*=x;
            res%=m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return res;
}*/


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

bool can_complete();

int main()
{
    if (can_complete()) printf("Yes\n");
    else printf("No\n");
	return 0;
}

bool can_complete()
{
    int h, w;
    char s[52][52]{};
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
            scanf(" %c", s[i] + j);
    }
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (s[i][j] != '#') continue;
            if (s[i][j+1] != '#' && s[i+1][j] != '#' && s[i][j-1] != '#' && s[i-1][j] != '#')
                return false;
        }
    }
    return true;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

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

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N >> M;
    arr[0] = 1;
    arr[1] = 3;
    arr[2] = 5;
    arr[3] = 7;
    arr[4] = 8;
    arr[5] = 10;
    arr[6] = 12;
    arr1[0] = 4;
    arr1[1] = 6;
    arr1[2] = 9;
    arr1[3] = 11;
    ll cnt = 0;
    ll cnt1 = 0;
    fi(i, 0, 7, 1) {
    	if(arr[i] == N || arr[i] == M) {
    		cnt++;
    	}
    }
    if(cnt == 2) {
    	cout << "Yes\n";
    	quit;
    }
    cnt = 0;
    fi(i, 0, 4, 1) {
    	if(arr1[i] == N || arr1[i] == M) {
    		cnt++;
    	}
    }
    if(cnt == 2) {
    	cout << "Yes\n";
    	quit;
    }
    
    cout << "No\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;




int main() {
	int n, m, s;
	cin >> n >> m >> s;

	vector<vector<pll>> r(n, vector<pll>(n, make_pair(INF, INF)));

	int aMax = 0;
	for (int i = 0; i < m; i++) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		r[u][v] = make_pair(a, b);
		r[v][u] = make_pair(a, b);

		aMax = max(aMax, a);

	}

	

	vector<pii> e(n);
	for (int i = 0; i < n; i++) {

		int c, d;
		cin >> c >> d;

		e[i] = (make_pair(c, d));
	}

	int ma = aMax * (n - 1);

	vector<vector<ll>> d(n, vector<ll>(ma + 1, INF));

	priority_queue<tl3, vector<tl3>, greater<tl3>> pq;



	ll t0 = 0;
	while (s < ma) {
		d[0][s] = t0;
		pq.push(make_tuple(t0, s, 0));
		s += e[0].first;
		t0 += e[0].second;
	}
	s = ma;
	d[0][s] = t0;
	pq.push(make_tuple(t0, s, 0));

	while (!pq.empty()) {
		ll v = get<2>(pq.top());
		ll c = get<1>(pq.top());
		ll t = d[v][c];
		//cout << v << " " << c << " " << t << endl;

		pq.pop();
		for (int u = 0; u < n; u++) {
			ll cu = c - r[v][u].first;
			if (cu < 0) {
				continue;
			}

			if (d[u][cu] > t + r[v][u].second) {

				d[u][cu] = t + r[v][u].second;
				pq.push(make_tuple(d[u][cu], cu, u));
			}
		}

		t += e[v].second;
		
		c += e[v].first;
		while (c < ma) {
			if (d[v][c] > t) {
				d[v][c] = t;
				pq.push(make_tuple(t, c, v));
			}
			c += e[0].first;
			t += e[0].second;
		}
		c = ma;
		if (d[v][c] > t) {
			d[v][c] = t;
			pq.push(make_tuple(t, c, v));
		}
	}

	for (int i = 1; i < n; i++) {
		ll ans = INF;
		for (ll di : d[i]) {
			ans = min(ans, di);
		}
		cout << ans << endl;
	}

}


Measured memory_bytes: 102544
#!/usr/bin/env pypy3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = 0

for i in range(1, n+1):
    for ntoss in range(10000000):
        #print(i, ntoss)
        if i * (2 **  ntoss) >= k:
            ans += (1 / n) * ((1 / 2) ** ntoss)
            break
    # n_omote = int(math.ceil(math.log(k, 2)))
print(ans)


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

int main(){
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  vector<int> B;
  rep(i, N){
    cin >> A[i];
  }
  
  int max_diff = 0;
  rep(i, N-1){
    int diff = A[i+1] - A[i];
    max_diff = max(max_diff, diff);
    B.push_back(diff);
  }
  
  int last_diff = K - A[N-1] + A[0];
  max_diff = max(max_diff, last_diff);
  B.push_back(last_diff);
  int ans = accumulate(B.begin(), B.end(), 0) - max_diff;
  cout << ans << endl;
  
}

Measured memory_bytes: 2168
#include <algorithm>
#include <cstdio>
#include <vector>

int main(void) {
    int N, M;
    std::scanf("%d", &N);
    std::scanf("%d", &M);
    int upper = N, lower = 1;
    for (int i = 1; i <= M; i++) {
        int L, R;
        std::scanf("%d", &L);
        std::scanf("%d", &R);
        upper = std::min(R, upper);
        lower = std::max(L, lower);
    }
    std::printf("%d", std::max(0, upper - lower + 1));
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int k;
    cin>>k;
    k--;
    
    for(int i =0;i<n;i++){
        if (s[i]!=s[k]){
            cout<<"*";
        }
        else{
        cout<<s[i];
        }
    }
}


Measured memory_bytes: 3600
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const long double pi = acos(-1);

int main()
{
	string s ; 
	cin >> s; 
	int c = 0 , mx = -1 ;
	for (int i = 0; i < s.size(); ++i)
	{
		if(s[i] == 'A' or s[i] == 'G' or s[i] == 'C' or s[i] == 'T'){
			c ++ ;
		}
		else{
			mx = max(c , mx) ;
			c = 0 ;
		}
	}
	mx = max(c , mx) ;
	cout << mx << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int a, b;
  ci(a, b);
  int x = 0;
  rep(i, b - a){
    x += i;
  }
  co(x - a);
}


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(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;


int main(){
    int n;
    cin>>n;
    char c;
    int j=0;
    char pc;
    rep(i,n){
        if(i==0){
            cin>>pc;
            j++;
        }
        else{
            cin>>c;
            if(c!=pc){
                j++;
                pc=c;
                
            }
            
        }
    }
    cout<<j<<endl;
    return 0;
}

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

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

    vector<uint64_t> A(N);
    for (uint64_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    
    uint64_t ans;
    ans = 0;
    for (uint64_t i = 1; i <= N - 1; i++)
    {
        ans = ans + A[(N - 1) - (i / 2)];
    }

    cout << ans << endl;
}

Measured memory_bytes: 4772
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str;
	cin >> str;
	for(int i = 1;i <= 2;i++){
		if(str[0] != str[i]){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<ii> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].second, &a[i].first);
  }
  sort(a.begin(), a.end());
  int last = 0;
  bool found = false;
  for (int i = 0; i < n; ++i) {
    if (last + a[i].second > a[i].first) {
      found = true;
      break;
    }
    last += a[i].second;
  }
  puts(found ? "No" : "Yes");
  return 0;
}


Measured memory_bytes: 1792
a = [list(map(int, input().split())) for _ in range(3)]
mark = [[False] * 3 for _ in range(3)]
n = int(input())
for _ in range(n):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j] == b:
        mark[i][j] = True
bingo = False
for i in range(3):
  if mark[i][0] and mark[i][1] and mark[i][2]:
    bingo = True
  if mark[0][i] and mark[1][i] and mark[2][i]:
    bingo = True
if mark[0][0] and mark[1][1] and mark[2][2]:
  bingo = True
if mark[0][2] and mark[1][1] and mark[2][0]:
  bingo = True
if bingo:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(p.at(i)!=i+1){
      count++;
    }
  }
  if(count<=2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

template <class T> struct Dijkstra {

    struct Edge{
        int to;
        T cost;
        Edge(int _to, T _cost) : to(_to), cost(_cost) {}
    };
    
    const T INF = numeric_limits<T>::max() / 2;
    vector< vector< Edge > > G;
    vector< T > d;
    Dijkstra (int n) : G(n), d(n) {}

    void add_directed_edge(int a, int b, T c) {
        G[a].push_back(Edge(b,c));
    }
    
    void add_undirected_edge(int a, int b, T c) {
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }

    void init(int s) {
        priority_queue< pair<T,int>,vector< pair<T,int> >, greater< pair<T,int> > > que;
        fill(d.begin(), d.end(), INF);
        d[s] = 0;
        que.push(make_pair(0,s));
        while (!que.empty()){
            pair<T,int> p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            for (int i = 0; i < G[v].size(); i++) {
                Edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
    
    T dist(int a) {
        return d[a];
    }
    
}; 

int n,m;
int s,t;

const ll kenkoooo = 1e15;

int main () {

    cin >> n >> m >> s >> t;

    Dijkstra < ll > g1(100010);
    Dijkstra < ll > g2(100010);

    REP(i,m) {
        int u,v;
        ll a,b;
        cin >> u >> v;
        cin >> a >> b;
        g1.add_undirected_edge(u, v, a);
        g2.add_undirected_edge(u, v, b);
    }

    g1.init(s);
    g2.init(t);

    ll cost[100010];
    for (int i = 1; i <= n; i++) {
        cost[i] = g1.dist(i) + g2.dist(i);
    }

    ll min_cost = 1e18;
    vector < ll > ans;
    for (int i = n; i >= 1; i--) {
        if (min_cost > cost[i]) {
            min_cost = cost[i];
        }
        ans.push_back(min_cost);
    }

    reverse(ans.begin(), ans.end());
    REP(i,ans.size()) cout << kenkoooo - ans[i] << endl;

    return 0;
}



Measured memory_bytes: 20860
<?php
 list($n,$k) = explode(' ',fgets(STDIN));
  $ans = 0;
  for ($i=1; $i<=$n; $i++) {
    $x = intdiv($k+$i-1, $i);
    $p = ceil(log($x, 2));
    $ans = $ans + (1 / $n) * pow(1/2, $p);
  }
  echo $ans;
  

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
template <typename T>
void dump_stack(std::stack<T>& stack) {
  std::stack<T> temp;
  while (!stack.empty()) {
    T top = stack.top(); stack.pop();
    std::cout << top << " ";
    temp.push(top);
  }
  std::cout << endl;
  while (!temp.empty()) {
    T top = temp.top(); temp.pop();
    stack.push(top);
  }
}

typedef long long ll;

int main(){
  string s;
  int x,y;
  stack<int> sk;
  while (cin >> s){
    if(s == "+") {
      y = sk.top(); sk.pop();
      x = sk.top();sk.pop();
      sk.push(x + y);
      //dump_stack(sk);
      //exit(0);
    } else if (s == "-") {
      //dump_stack(sk);
      //exit(0);
      y = sk.top(); sk.pop();
      x = sk.top();sk.pop();
      sk.push(x - y);
    } else if (s == "*") {
      y = sk.top(); sk.pop();
      x = sk.top();sk.pop();
      sk.push(x * y);
    } else {
      sk.push(atoi(s.c_str()));
    }
    
  }
  int r = sk.top();
  cout << r << endl;  
}



Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}

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

    int v = a%b;
    map<int,int> mp;
    mp[v] =1;
    int x=a;
    bool st = true;
    while(st || mp.count(x%b)==0){
        st = false;
        if ( x%b == c) {cout<<"YES"<<endl;return 0;}
        mp[x%b]=1;
        x+=a;
    }
    cout<<"NO"<<endl;
    
    return 0;
}







Measured memory_bytes: 256