akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int cnt = 0;
	for (int a = 0; a < n; a++) {
		for (int b = a + 1; b < n; b++) {
			for (int c = b + 1; c < n; c++) {
				if (l[a] + l[b] > l[c]) {
					cnt++;
				}
				else
				{
					break;
				}
			}
			
		}
	}
	cout << cnt << endl;

	return 0;
}

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

int
main(void)
{
	std::string input;
	std::cin >> input;
	
	int max_len  = 0;
	int current_len = 0;
	
	for (size_t i = 0; i < input.length(); ++i) {
		if (input[i] != 'A' && input[i] != 'T' && input[i] != 'C' && input[i] != 'G') {
			max_len = std::max(max_len, current_len);
			current_len = 0;

			continue;
		}
		current_len ++;
	}

	std::cout << std::max(max_len, current_len) << std::endl;
	
	return 0;
}


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

using namespace std;
int n,a[100005];
int re;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[a[i]]==i)
         re++;
    }
    cout<<re/2;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <climits>
#include <utility>
#include <map>
#include <set>
#include <complex>
#include <numeric>

#include <time.h>
#include <float.h>

#define loop(i, start, end) for(i = (start); i <= (end); i++)
#define loopIterators(it, vec) for(it = (vec).begin(); it != (vec).end(); it++)
#define loopIteratorsRev(it, vec) for(it = (vec).rbegin(); it != (vec).rend(); it++)
#define loopRev(i, start, end) for(i = (start); i >= (end); i--)
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCases(t) cin >> t; while(t--)
#define PN(n) cout << (n)
#define PN1(n) cout << (n) << " "
#define PN2(a, b) cout << (a) << " " << (b) << " "
#define PNN1(n) cout << (n) << endl
#define PNN2(a, b) cout << (a) << " " << (b) << endl
#define PNN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define PrintArray(ar, n) for(i = 0; i < n; i++) cout << ar[i] << " "; cout << endl
#define PrintObject(ar, it) loopIterators(it, ar) cout << *it << " "; cout << endl
#define PrintMap(map, it) loopIterators(it, map) PNN2(it->first, it->second)
#define sz(a) sizeof(a)
#define IN1(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define ALL(s) s.begin(), s.end()
#define SWAP(a, b, c) c = a; a = b; b = c
#define STRSP(s) scanf("%[^\n]%*c", s)
#define ENTER PNN1("")
#define MOD7 1000000007
#define MOD9 10000009
#define llPair std::pair<lli, lli>
#define iiPair std::pair<int, int>
#define ONLINE_JUDGE

typedef long long int lli;
typedef long int li;
typedef unsigned long long int ulli;
typedef long double ld;

using namespace std;

int main(void){
	FLASH

	#ifndef ONLINE_JUDGE
		freopen("input-stream.txt", "r", stdin);
		freopen("output-stream.txt", "w", stdout);
	#endif

	// std::string s;
	// IN1(s);
	//
	// PNN1(s.at(2) == s.at(3) && s.at(4) == s.at(4)? "Yes": "No");

	int n;
	IN1(n);

	lli ans = 1LL * n / 500 * 1000;
	n %= 500;
	ans += 1LL * n / 5 * 5;
	PNN1(ans);


	#ifndef ONLINE_JUDGE
		fclose(stdin);
		fclose(stdout);
	#endif

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int a, b;
int solve(int a, int b) {
	if (a > b)return 1000000001;
	else return b - a;
}
int main() {
	cin >> a >> b;
	ll ans = 1000000001;
	ans = min(min(solve(a, b), solve(-a, b) + 1), min(solve(a, -b)+1, solve(-a, -b)+2));
	cout << ans << endl;
}

Measured memory_bytes: 256
o=input()
e=input()

pw=""
if len(o)==len(e):
    for i in range(len(o)):
        pw+=o[i]
        pw+=e[i]
else:
    for i in range(len(e)):
        pw+=o[i]
        pw+=e[i]
    pw+=o[-1]
print(pw)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int n,t;
  cin >> n >> t;
  int ans = 0;
  int cur = -1;
  rep(i,0,n){
    int a;
    cin >> a;
    if(cur == -1){
      cur = a;
      ans += t;
    }
    else if(cur + t <= a){
      cur = a;
      ans += t;
    }
    else{
      ans += t - ((cur + t) - a);
      cur = a;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
/*
	for j = 2 to length[A]
    do key = A[j]
    // insert A[j] into the sorted sequence A[1,...,j-1] 
    i = j - 1
    while i > 0 and A[i] > key
       do A[i+1] = A[i]
          i = i - 1
    A[i+1] = key
*/
void disp_array (vector<int> a )
{
	int n = a.size();
	rep (i, n ){
		cout << a[i] << (i != n - 1 ? ' ' : '\n' );
	} // end rep
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.Insertion_Sort", "r", stdin );
	int n;
	scanf ("%d", &n );
	vector<int> A (n, 0 );

	rep (i, n ){
		scanf (" %d", &A[i] );
	} // end rep
	disp_array (A );
	for (int j = 1; j < n; j++ ){
		int key = A[j];
		int i = j - 1;
		while (i >= 0 && A[i] > key ){
			swap (A[i+1], A[i] );
			i--;
		} // end while
		disp_array (A );
	} // end for

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int a[2][n];
        for(int i = 0; i < n; i++)  cin >> a[0][i];
        for(int i = 0; i < n; i++)  cin >> a[1][i];
        bool va[2][n];
        memset(va, 0, sizeof(va));

        // {{building, floor}, step}
        queue<pair<pair<int,int>,int>> s;
        s.push({{0,0},0});
        s.push({{1,0},0});

        int ans = -1;
        while(!s.empty()){
            auto p = s.front(); s.pop();
            int b = p.first.first, f = p.first.second, h = p.second;
            while(a[b][f] == 2) f--;
            while(f+1 < n && a[b][f] == 1 && a[b][f+1] == 1)  f++;
            
            if(f == n-1){
                ans = h;
                break;
            }

            if(va[b][f])    continue;
            
            va[b][f] = true;

            b ^= 1;
            for(int i = 0; i < 3; i++){
                if(f+i >= n)    break;
                if(!va[b][f+i]) s.push({{b, f+i}, h+1});
            }

        }

        if(ans == -1)   cout << "NA" << endl;
        else            cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	int n = s.size();
	int one = 0;
	int zero = 0;
	for(int i=0;i<n;i++){
		if(s[i]=='1')one++;
		else{
			zero++;
		}
	}
	int ans = min(one,zero);
	cout << ans*2 << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define in inline
#define int long long
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
map<int,int>v;
int n,m,ans,a[200002];
signed main(){
	n=read();
	for(re int i=1;i<=n;++i){
		a[i]=read();
	}
	for(re int i=n;i;--i){
		ans+=v[-(i+a[i])];
		++v[a[i]-i];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 27904
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[100032],b[100032],c[100032];
long long ans=0;
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++) cin>>c[i];
	sort(a,a+n);sort(b,b+n);sort(c,c+n);
	for(int i=0;i<n;i++){
		int j=lower_bound(a,a+n,b[i])-a;
		int k=upper_bound(c,c+n,b[i])-c;
		k=n-k;
		ans+=(long long)j*k;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
  long long N, Sum=0;
  cin >> N;
  vector<long long> T(N+1);
  vector<long long> Y(N);
  rep(i,N+1) cin >> T.at(i);
  rep(i,N) cin >> Y.at(i);
  rep(i,N){
    if(Y.at(i)<=T.at(i)){
      Sum=Sum+Y.at(i);
    }
    else if(Y.at(i)<=T.at(i)+T.at(i+1)){
      Sum=Sum+Y.at(i);
      T.at(i+1)=T.at(i+1)-(Y.at(i)-T.at(i));
    }
    else if(Y.at(i)> T.at(i)+T.at(i+1)){
      Sum=Sum+T.at(i)+T.at(i+1);
      T.at(i+1)=0;
    }
  }
  cout << Sum << endl;
} 

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u32 n, k;
  cin >> n >> k;

  u32 ans = 1;
  u32 b = k;
  while (b <= n) {
    ans++;
    b = k * b;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
using namespace std;
int n, x, y, las;
int main() {
	scanf("%d%d", &n, &x); ll ans = 0;
	rep(i, 1, n) {
		scanf("%d", &y);
		if (y > x) ans += y - x, y = x;
		if (i == 1) las = y;
			else ans += max(las + y - x, 0), las = y - max(las + y - x, 0);
	}
	printf("%lld", ans);
	return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    int k;cin>>k;

    VVI c(k+10);
    
    REP(i,k+10){
        REP(j,k+10){
            c[i].resize(k+10);
            c[i][j] = gcd(i,j);
        }
    }

    LL result = 0;

    REP(x,k){
        REP(y,k){
            REP(z,k){
                result += c[x+1][c[y+1][z+1]];

            }
        }

    }

    cout <<result <<endl;



	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3712
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int main() {
	//freopen("greedy.in", "r", stdin);
	//freopen("greedy.out", "w", stdout);	
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << "Alice" << endl;
	} else cout << "Borys" << endl;
	return 0;
}

Measured memory_bytes: 764
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**9 +5
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()))
MOD = 10**9 + 7

h, w = MAP()
maze = [[]for i in range(h)]
for i in range(h):
    si = list(input())
    maze[i] = si

ans = []
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
def dfs(sx, sy):
    q = []
    d = [[INF]*w for i in range(h)]
    heapq.heappush(q, [0, sx, sy])
    d[sx][sy] = 0
    res = 0
    while len(q) >0:
        p = heapq.heappop(q)
        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[2] + dy[i]
            if 0<=nx<h and 0<=ny<w and maze[nx][ny] == '.' and d[nx][ny] == INF:
                heapq.heappush(q, [d[p[1]][p[2]] + 1, nx, ny])
                d[nx][ny] = d[p[1]][p[2]] + 1
                if d[nx][ny] > res:
                    res = d[nx][ny]
    return res

for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            ans.append(dfs(i, j))

print(max(ans))


Measured memory_bytes: 79060
import heapq


def dijkstra(n):
    inf=float("inf")
    color=["white" for _ in range(n)]
    D=[inf for _ in range(n)]
    P=[0 for _ in range(n)]
    M=[[] for _ in range(n)]

    for i in range(n):
        A=list(map(int, input().split()))
        for j in range(A[1]):
            M[i].append([A[2*(j+1)],A[2*(j+1)+1]])

    D[0]=0
    P[0]=-1

    H=[(0,0)]
    heapq.heapify(H)

    while len(H)>=1:
        u=heapq.heappop(H)[1]
        if color[u]=="black":continue
        color[u]="black"

        V=[(i,j) for i,j in M[u] if color[i]!="black"]
        while len(V)!=0:
            for i,j in V:
                if D[u]+j<D[i]:
                    D[i]=D[u]+j
                    P[i]=u
                    color[i]="gray"
                    heapq.heappush(H,(D[i],i))
            break

    return D


for i,j in enumerate(dijkstra(int(input()))):
    print(i,j)


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

using namespace std;

int main()
{
    int n, k;
    cin>>n>>k;
    vector<int> v(n);

    for(int& x : v){
        cin>>x;
    }

    vector<bool> dp(k + 1);
    for(int stones = 0 ; stones <= k ; stones ++){
        for(auto x : v){
            if(stones >= x && !dp[stones - x]){
                dp[stones] = true;
            }
        }
    }

    puts(dp[k] ? "First" : "Second");

    return 0;
}


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

int main(){
	int n, i, ans[4] = {0, 0, 0, 0};
  	char s[101];
  	cin >> n;
  	for(i=0; i<n; i++){
    	cin >> s[i];
    }
  	
  	for(i=0; i<n; i++){
    	if(s[i] == 'P')ans[0] = 1;
      	if(s[i] == 'W')ans[1] = 1;
      	if(s[i] == 'G')ans[2] = 1;
      	if(s[i] == 'Y')ans[3] = 1;
    }
  	if(ans[0] + ans[1] + ans[2] + ans[3] == 3) cout << "Three" << endl;
  	else if(ans[0] + ans[1] + ans[2] + ans[3] == 4) cout << "Four" << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=[]
for i in range(M):
    P,Y=map(int,input().split())
    A.append([P,Y,i])
A.sort()
a=str(A[0][0])
n="0"*(6-len(a))+a+"0"*5+"1"
A[0].append(n)
no=1
for i in range(1,M):
    if A[i][0]==A[i-1][0]:
        no=no+1
    else:
        no=1
    a=str(A[i][0])
    b=str(no)
    n="0"*(6-len(a))+a+"0"*(6-len(b))+b
    A[i].append(n)
A.sort(key=lambda x:x[2])
for i in range(M):
    print(A[i][3])

Measured memory_bytes: 34708
import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
    	long a = sc.nextLong();
    	long b = sc.nextLong();
    	long x = sc.nextLong();

        long b2 = b / x;
        long a2 = a / x;
        
        if (a % x == 0){
        	a2 = a2 - 1;
        }
        
        long ans=0;
        ans = b2 - a2;
        
        System.out.println(ans);
    }	
}
    
   

Measured memory_bytes: 10188
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll a,b;
	cin>>a>>b;
	cout<<max(0ll,a-b-b)<<endl;
	return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
m=len(s)
n=len(t)
check=False
for i in range(m-n,-1,-1):
  check2=True
  for j in range(i,i+n):
    if s[j]=='?' or s[j]==t[j-i]:
      continue
    else:
      check2=False
  if check2:
    check=True
    s=s[:i]+t+s[i+n:]
    s=s.replace('?','a')
    break
print(s if check else 'UNRESTORABLE')
    
      

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

int n , m ;

vector < pair < int , int > > g[100010] ;

int id[100010] ;

bool ok ;

void dfs( int u ){
    for( int i = 0 ; i < (int)g[u].size() ; ++ i ){
        int v = g[u][i].first , value = g[u][i].second ;
        if( id[v] > int(1e9) ) id[v] = id[u] + value , dfs(v) ;
        else{
            if( id[v] != id[u] + value ) { ok = false ; return ; }
        }
        if(!ok) return ;
    }
}

int main(){

    ios_base :: sync_with_stdio(false) ;

    cin >> n >> m ;

    for( int i = 1 ; i <= m ; ++ i ){
        int u , v , d ; cin >> u >> v >> d ;
        g[u].push_back( make_pair(v , d) ) ;
        g[v].push_back( make_pair(u , -d) ) ;
    }

    memset(id , 0x3f , sizeof(id)) ;

    ok = true ;

    for( int i = 1 ; i <= n ; ++ i ){
        if( id[i] > (int)(1e9) ) { id[i] = 0 ; dfs(i) ; if(!ok) return printf( "No" ) , 0 ; } ;
    }

    cout << "Yes" << endl ;

    return 0 ;
}


Measured memory_bytes: 12032
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let t: String = input();
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();
    let mut sum = 0;
    for i in 0..3 {
        if (s[i] == t[i]) {
            sum += 1;
        }
    }
    println!("{}", sum);
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        cin>>n;
        vector<string> v;
        for(i=0;i<n;i++)
        {
            string s;
            cin>>s;
            v.pb(s);
        }
        vector<pair<ll,pair<ll,ll>>> ag,ng,nn;
        ll tot=0;
        for(i=0;i<n;i++)
        {
            ll x=0,y=0,z=0;
            for(auto j:v[i])
            {
                if(j=='(')z++;
                else z--;
                x=min(x,z);
            }
            if(x>=0)
            {
                ag.pb({z,{x,z}});
                tot+=z;
            }
            else
            {
                if(z>=0)
                {
                    ng.pb({-x,{z,x}});
                }
                else
                {
                    nn.pb({-z+x,{-x,-z}});
                }
            }
        }
        sort(all(ng));sort(all(nn));
        for(i=0;i<ng.size();i++)
        {
            if(tot<ng[i].F)
            {
                cout<<"No";
                return 0;
            }
            tot+=ng[i].S.F;
        }
        for(i=0;i<nn.size();i++)
        {
            if(tot<nn[i].S.F)
            {
                // cout<<tot<<" "<<nn[i].S.F<<endl;
                cout<<"No";
                return 0;
            }
            tot-=nn[i].S.S;
        }
        if(tot!=0)
        {
            cout<<"No";return 0;
        }
        cout<<"Yes";
    }
    return 0;
}

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

int main() {
 string s,t;
 cin >> s >> t;
 int x = stoi(s+t);
 for(int i = 1; i < 320; i++){
   if(i*i == x){
     cout << "Yes" << endl;
     return 0;
   }
 }
 cout << "No" << endl;
 } 

Measured memory_bytes: 3568
#include<stdio.h>
# define LEN 100010

typedef struct {
    char name[20];
    int time;
} Process;

typedef struct {
    Process q_array[LEN];
    int head;
    int tail;
} Queue;

void init_queue(Queue *queue){
    queue->head = 0;
    queue->tail = 0;
}

void enque(Queue *queue, Process p){
    queue->q_array[queue->tail] = p;
    queue->tail = (queue->tail == LEN - 1) ? 0 : queue->tail + 1;
}

Process deque(Queue *queue){
    int head_tmp;
    head_tmp = queue->head;
    queue->head = (queue->head == LEN -1) ? 0 : queue->head+1;
    return queue->q_array[head_tmp];
}

int main(void){
    int i, n, q;
    int time = 0;
    Queue queue;
    Process p_tmp;

    // set the value of queue
    init_queue(&queue);
    scanf("%d", &n);
    scanf("%d", &q);
    for(i = 0; i < n; i++){
        scanf("%s", p_tmp.name);
        scanf("%d", &p_tmp.time);
        enque(&queue, p_tmp);
    }

    while(queue.head != queue.tail){
        p_tmp = deque(&queue);
        if(p_tmp.time > q){
            time += q;
            p_tmp.time -= q;
            enque(&queue, p_tmp);
        }
        else{
            time += p_tmp.time;
            printf("%s %d\n", p_tmp.name, time);
        }
    }

    return 0;
}



Measured memory_bytes: 4080
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int n, k;
    while (cin >> n >> k) {
        vector<int> a(n);
        int mn = 1 << 30;
        int mi;
        for (int i = 0; i < n; ++i) {
            auto& p = a[i];
            cin >> p;
            if (mn > p) {
                mn = p;
                mi = i;
            }
        }
        int be = 1 << 30;
        for (int si = mi - k - 1; si <= mi + k + 1; ++si) { 
            int ct = 0;
            for (int i = si; i + 1 < n; i += k - 1)
                ++ct;
            for (int i = si; i - 1 >= 0; i -= k - 1)
                ++ct;
            be = min(be, ct);
        }
        cout << be << endl;
    }
    return 0;
}


Measured memory_bytes: 1016
#import numpy as np
#from math import gcd

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

    
##################################################################

if __name__ == "__main__":
    Input1 = [input() for i in range(1)]
    #N = int(Input1[0])
    A,B = list(map(int,Input1[0].split()))
    if B > A:
        temp = A
        A = B
        B = temp

    ans = 1
    if B == 1:
        print(ans)
    else:
        fact = factorization(B)
        for i in range(len(fact)):
            f = fact[i][0]
            if A % f == 0:
                ans += 1
        print(ans)
    
    #print(' '.join(map(str,B)))
    


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;
 
int main()
{
	int n,s;
	while(cin>>n>>s,n){
		int res=0;
		for(int i=0;i<(1<<10);i++){

			int sum=0,bit=0;
			for(int j=0;j<10;j++){
				if( i & (1<<j) ){
					bit++;
					sum+=j;
				}
			}

			if(sum==s && bit==n) res++;

		}

		cout<<res<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
public class Main {


  private static void solve() {
    int n = ni();
    if (n == 1) {
      System.out.println("Hello World");
    } else {
      int a = ni();
      int b = ni();
      System.out.println(a + b);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22996
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	char b; cin >> b;

	if(b == 'A') cout << 'T' << endl;
	else if(b == 'C') cout << 'G' << endl;
	else if(b == 'T') cout << 'A' << endl;
	else if(b == 'G') cout << 'C' << endl;


	return 0;

}


Measured memory_bytes: 256
import heapq

# https://nashidos.hatenablog.com/entry/2020/04/07/100508
def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * ((maxsilver+1)*n) # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, w in e[v]:
            tmp = d + cost[v]
            if tmp < cost[w]:
                cost[w] = tmp
                heapq.heappush(hq, (tmp, w))
    return cost

n,m,s = map(int,input().split())

u,v,a,b = [0]*m,[0]*m,[0]*m,[0]*m 
c,d = [0]*n,[0]*n 
for i in range(m):
    u[i],v[i],a[i],b[i] = list(map(int,input().split()))
for i in range(n):
    c[i],d[i] = list(map(int,input().split()))

maA = max(a)
maxsilver = maA*(n-1)
p = (maxsilver+1) * n
# 都市i(0~)で銀貨j枚持っている時,i*(maxsilver+1)+j番目
e = [[] for i in range(p)]
# 金貨交換
for i in range(n):
    for j in range(maxsilver+1):
        e[i*(maxsilver+1) + j].append((d[i], i*(maxsilver+1) + min(j+c[i], maxsilver)))
# 移動
for i in range(m):
    for j in range(a[i],maxsilver+1):
        e[(u[i]-1)*(maxsilver+1) + j].append((b[i], (v[i]-1)*(maxsilver+1) + j-a[i]))
        e[(v[i]-1)*(maxsilver+1) + j].append((b[i], (u[i]-1)*(maxsilver+1) + j-a[i]))

# print(e)
# 初期地点は0+min(s,maxsilver)
d = dijkstra(min(s,maxsilver))
for i in range(1,n):
    ans = float("inf")
    x = [0]*(maxsilver+1)
    for j in range(maxsilver+1):
        x[j] =  d[i*(maxsilver+1)+j]
    heapq.heapify(x)
    ans = heapq.heappop(x)
    print(ans)

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

int main(){
  int n, m;
  cin >> n >> m;
  rep(i, m){
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while(!q.empty()){
    int v = q.front(); q.pop();
    for(int u: to[v]){
      if(dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }
  cout << "Yes" << endl;
  rep(i, n){
    if(i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 10548
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

void add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

int n, C;
int a[N], b[N];

int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = res * 1ll * x % mod;
		x = x * 1ll * x % mod, y >>= 1;
	}
	return res;
}

int dp[401][401];
int pref[401][401];
int calc(int v = 1, int ost = C) {
	if (v > n) {
		return !ost;
	}
	if (~dp[v][ost]) return dp[v][ost];
	int res = 0;
	rep(i, 0, ost) {
		int right = calc(v + 1, ost - i);
		int left = pref[i][b[v]];
		add(left, -pref[i][a[v] - 1]);
		add(res, left * 1ll * right % mod);
		continue;
		rep(x, a[v], b[v]) {
			int val = bp(x, i);
			add(res, val * 1ll * calc(v + 1, ost - i) % mod);
		}
	}
	return dp[v][ost] = res;
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n >> C;
	rep(i, 1, n) cin >> a[i];
	rep(i, 1, n) cin >> b[i];

	rep(dg, 0, 400) {
		rep(i, 1, 400) {
			pref[dg][i] = bp(i, dg);
			add(pref[dg][i], pref[dg][i - 1]);
		}
	}
	memset(dp, -1, sizeof(dp));
	cout << calc();
	ioi
}


Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var A int64
var B int64

func main() {
	A = nextInt64()
	B = nextInt64()
	diff := B - A + 1
	targets := []int64{}
	if A%2 > 0 {
		targets = append(targets, A)
		diff -= 1
	}
	if B%2 < 1 {
		targets = append(targets, B)
		diff -= 1
	}
	if (diff/2)%2 > 0 {
		targets = append(targets, 1)
	}
	ans := ""
	for i := 42; i >= 0; i-- {
		c := 0
		for _, t := range targets {
			if GetNthBit(t, i) == 1 {
				c += 1
			}
		}
		if c%2 > 0 {
			ans = ans + "1"
		} else {
			ans = ans + "0"
		}
	}
	val, _ := strconv.ParseInt(ans, 2, 64)
	fmt.Printf("%v", val)
}

func GetNthBit(num int64, nth int) int64 {
	return num >> uint(nth) & 1
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextInts64(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.Scanner;

class Main {
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        while (true) {
            int x = Integer.parseInt(sc.next());
            int y = Integer.parseInt(sc.next());
            if(x==0&&y==0) break;
            if(x<=y) System.out.println(x+" "+y);
            else System.out.println(y+" "+x);
        }
    }
}

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

int main(){
    int x,y;
    cin >> x >> y;
    if(y%2==1){
        cout << "No" << endl;
    }else{
        if(x*2<=y && y <= x*4){
            cout << "Yes" << endl;
        }else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
using System;
class Problem01{
	static void Main(string []args){
		string [] t=(Console.ReadLine()).Split(' ');
		int a=int.Parse(t[0]);
		int b=int.Parse(t[1]);
		int c=int.Parse(t[2]);
		int d=int.Parse(t[3]);
		if(Math.Abs(a-c)<=d){
			Console.WriteLine("Yes");
		}else if(Math.Abs(a-b)<=d && Math.Abs(b-c)<=d){
			Console.WriteLine("Yes");
		}else {
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 11092
N, M = map(int, input().split())

# 偶数回裏返す->表
# 奇数回裏返す->裏

# 四隅->4回->表
# 四隅以外の外枠->6回->表
# 内側->9回->裏

# 1マスの場合
if N == 1 and M == 1:
    print(1)
    exit(0)

# 1行又は1列の場合->両端以外
if N == 1 or M == 1:
    print(max(N, M)-2)
    exit(0)

# 内側のカードの枚数を求める
print((N-2)*(M-2))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){

//	vector<int> a(n);

  int n,cnt=0;
 
  cin >> n;

  vector<vector<int> > data(n, vector<int>(2));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }

  for(int i=0;i<n;i++){
    if(data.at(i).at(0) == data.at(i).at(1)){
      cnt = cnt + 1;
      if(cnt >= 3){
        cout << "Yes" << endl;
        exit(0);
      }
    }else{
      cnt = 0;
    }
  }

  cout << "No" << endl;

/*
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cout << data.at(i).at(j);
    }
  }
*/

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string alpha = "abcdefghijklmnopqrstuvwxyz";
  ll n;
  cin >> n;

  string ans = "";

  while(n) {
    n--;
    ans += alpha[n % 26];
    n /= 26;
  }
  // n--;
  // ans += alpha[n % 26];

  reverse(ans.begin(), ans.end());

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

void Output(int a, int b);

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

	Output(a, b);
	return 0;
}

void Output(int a, int b)
{
	if (a > b)
	{
		printf("a > b\n");
	}
	else if (a < b)
	{
		printf("a < b\n");
	}
	else
	{
		printf("a == b\n");
	}
}


Measured memory_bytes: 2692
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
      
        String S = stdIn.next();
        if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
            System.out.println("Yes");
        } 
        else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
//---------------------------------------------------------------------------//
ll n,a[100001];
ll b[100001];
ll sum=0;
int main(){
        cin>>n;
        rep(i,0,n) cin>>a[i]>>b[i];
        for(int i=n-1; i>=0; i--) {
                a[i]+=sum;
                if(a[i]%b[i]!=0) {
                        sum+=b[i]-(a[i]%b[i]);
                }
        }
        cout<<sum<<endl;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int vec[100000];

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

	for (int i = 0; i < n; i++)
		scanf("%d", &vec[i]);

	for (int i = 1; i < n; i++) {
		if (n <= (k - 1) * i + 1) return !printf("%d", i);
	}

	// x번 연산한다고 치면 (x-1) + (k*x)만큼 칠할 수 있음.
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int N, K;

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

	int A;
	A = N + 1;

	if (N % 2 == 0) {
		if (N / 2 >= K) {
			printf("YES");
		}
		else
			printf("NO");
	}
	else {
		if (A / 2 >= K) {
			printf("YES");
		}
		else
			printf("NO");
	}







	return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Char (digitToInt)
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  xs <- getc solve
  mapM_ putStrLn xs

solve :: String -> String
solve xs = maybe "NA" id $ decode "" xs

decode :: String -> String -> Maybe String
decode acc [] = Just $ reverse acc
decode acc (s1:s2:ss)
  | s1 >= '1' && s1 <= '6' && s2 >= '1' && s2 <= '5' = decode ((tr s1 s2) : acc) ss
  | otherwise = Nothing
decode _ _ = Nothing

tr :: Char -> Char -> Char
tr i j = tbl !! (((digitToInt i) - 1) * 5 + ((digitToInt j) - 1))
  where
    tbl = "abcdefghijklmnopqrstuvwxyz.?! "

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

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

using namespace std;

set<long long> allDivs(long long n) {
    set<long long> ans;
    for (long long d = 1; d*d <= n; d++) {
        if (n%d == 0) {
            ans.insert(d);
            ans.insert(n/d);
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long n;
    cin >> n;
    auto ans = allDivs(n-1).size() - 1;
    auto ds = allDivs(n);
    for (auto d: ds) {
        if (d > 1 && (n-1)%d != 0) {
            auto r = n;
            while (r%d == 0) {
                r /= d;
            }
            if (r%d == 1) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
#define F(i,x,n) for(int i=x;i<=n;++i)
#define F_(i,x,n) for(int i=x;i>=n;--i)
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
const int N=1e5+5;
int n;
struct node
{
    int w,id;
}a[N];
/**/
inline bool cmp(node x,node y)
{
    return x.w<y.w;
}
int main()
{
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    read(n);
    for(int i=1;i<=n;i++) {read(a[i].w);a[i].id=i;}
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=n;i++) cout<<a[i].id<<' ';
}

Measured memory_bytes: 1536
"""
これは、3の倍数かつ最小ステップでTにたどりつけ、という問題。
拡張ダイクストラを使えばよい。
"""
from collections import deque
N,M = map(int,input().split())
edges = [[] for _ in range(N+1)]
for _ in range(M):
    u,v = map(int,input().split())
    edges[u].append(v)
visited = set()
S,T = map(int,input().split())
que = deque([(S,0)])
while que:
    cur,step = que.popleft()
    rest = step%3
    if cur == T and rest == 0:
        print(step//3)
        exit()
    if (cur,rest) in visited:
        continue
    else:
        visited.add((cur,rest))
        for nx in edges[cur]:
            que.append((nx,step+1))
print(-1)

Measured memory_bytes: 119500
MOD = 998244353

def butterfly(arr):
    n = len(arr)
    h = (n - 1).bit_length()
    sum_e = (911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601,
                842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 0, 0, 0, 0, 0, 0, 0, 0, 0)
    for ph in range(1, h + 1):
        w = 1 << (ph - 1)
        p = 1 << (h - ph)
        now = 1
        for s in range(w):
            offset = s << (h - ph + 1)
            for i in range(p):
                l = arr[i + offset]
                r = arr[i + offset + p] * now
                arr[i + offset] = (l + r) % MOD
                arr[i + offset + p] = (l - r) % MOD
            now *= sum_e[(~s & -~s).bit_length() - 1]
            now %= MOD

def butterfly_inv(arr):
    n = len(arr)
    h = (n - 1).bit_length()
    sum_ie = (86583718, 372528824, 373294451, 645684063, 112220581, 692852209, 155456985, 797128860, 90816748, 860285882, 927414960, 354738543,
                109331171, 293255632, 535113200, 308540755, 121186627, 608385704, 438932459, 359477183, 824071951, 0, 0, 0, 0, 0, 0, 0, 0, 0)
    for ph in range(1, h + 1)[::-1]:
        w = 1 << (ph - 1)
        p = 1 << (h - ph)
        inow = 1
        for s in range(w):
            offset = s << (h - ph + 1)
            for i in range(p):
                l = arr[i + offset]
                r = arr[i + offset + p]
                arr[i + offset] = (l + r) % MOD
                arr[i + offset + p] = (MOD + l - r) * inow % MOD
            inow *= sum_ie[(~s & -~s).bit_length() - 1]
            inow %= MOD



def convolution(a, b):
    n = len(a)
    m = len(b)
    if not n or not m: return []
    if min(n, m) <= 50:
        if n < m:
            n, m = m, n
            a, b = b, a
        res = [0] * (n + m - 1)
        for i in range(n):
            for j in range(m):
                res[i + j] += a[i] * b[j]
                res[i + j] %= MOD
        return res
    z = 1 << (n + m - 2).bit_length()
    a += [0] * (z - n)
    b += [0] * (z - m)
    butterfly(a)
    butterfly(b)
    for i in range(z):
        a[i] *= b[i]
        a[i] %= MOD
    butterfly_inv(a)
    a = a[:n + m - 1]
    iz = pow(z, MOD - 2, MOD)
    for i in range(n + m - 1):
        a[i] *= iz
        a[i] %= MOD
    return a


def atcoder_practice2_f():
    import sys
    input = sys.stdin.buffer.readline

    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]

    print(*convolution(A, B))


if __name__ == "__main__":
    atcoder_practice2_f()


Measured memory_bytes: 196420