akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env pypy3

import itertools


class CumulativeSum(object):
    """Constructs the cumulative sum of the elements in the given sequence.

    :param sequence: The sequence to be processed.
    :type sequence: sequence
    """

    def __init__(self, sequence):
        self.cumulative_sum = [0]
        self.cumulative_sum.extend(itertools.accumulate(sequence))

    def partial_sum(self, first, last):
        """Computes the partial sum of the sequence.

        :param first: The index representing the first element of the
                      subsequence.
        :type first: int
        :param last: The index representing the last element of the
                     subsequence.
        :return: The partial sum.
        """
        return self.cumulative_sum[last + 1] - self.cumulative_sum[first]


def prepare(h, w, d, board):
    val2pos = [None for _ in range(h * w + 1)]
    for r, c in itertools.product(range(h), range(w)):
        val2pos[board[r][c]] = (r, c)
    max_e = h * w // d
    cumsums = []
    for m in range(d):
        max_e = (h * w - m) // d
        costs = []
        for e in range(max_e + 1):
            if e == 0:
                costs.append(0)
            else:
                x0 = (e - 1) * d + m
                if x0 != 0:
                    r0, c0 = val2pos[x0]
                    x1 = e * d + m
                    r1, c1 = val2pos[x1]
                    cost = abs(r1 - r0) + abs(c1 - c0)
                else:
                    cost = 0
                costs.append(cost)
        cumsums.append(CumulativeSum(costs))
    return cumsums


def main():
    h, w, d = (int(x) for x in input().split())
    board = [[int(b) for b in input().split()] for _ in range(h)]
    cumsums = prepare(h, w, d, board)
    q = int(input())
    for _ in range(q):
        l, r = (int(x) for x in input().split())
        dl, ml = divmod(l, d)
        dr, mr = divmod(r, d)
        res = cumsums[ml].partial_sum(dl + 1, dr)
        # print(cumsums[ml].cumulative_sum)
        # print(dl + 1, dr)
        print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72412
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 105;
const int mod = (int) 1e9 + 7;

int n, k;
int arr[N];
int dp[2][100005];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  for (int j = 0; j <= arr[0]; j++) dp[0][j] = 1;
  for (int i = 1; i < n; i++) {
    int sum = 0;
    for (int j = 0; j <= k; j++) {
      if (j == 0) {
        sum++;
      } else {
        sum = (sum + dp[(i - 1) & 1][j]) % mod;
      }
      if (j > arr[i]) {
        sum = ((sum - dp[(i - 1) & 1][j - arr[i] - 1]) + mod) % mod;
      }
      dp[i & 1][j] = sum;
    }
  }
  cout << dp[(n - 1) & 1][k] << endl;
  return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    int ans=h[0];
    for (int i=1; i<n; i++) {
        if (h[i-1]<h[i]) ans+=h[i]-h[i-1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MN 1000
long long x[MN+5],y[MN+5];
int main()
{
	int n,i,j,u=0;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%lld%lld",&x[i],&y[i]);x[i]+=1e9;y[i]+=1e9;
		if((x[i]+y[i]+x[1]+y[1])&1)return 0*puts("-1");
	}
	if(~(x[1]+y[1])&1)u=1;
	printf("34\n%d %d ",(int)1e9+u,(int)1e9);
	for(i=0;i<=31;++i)printf("%u ",1<<i);puts("");
	for(i=1;i<=n;++i)
	{
		printf("LD");x[i]+=u;
		for(j=0;j<=30;++j)
			if((x[i]+y[i])&2)putchar(x[i]&1?'R':'U'),x[i]>>=1,y[i]>>=1;
			else putchar(x[i]&1?'L':'D'),x[i]=x[i]+1>>1,y[i]=y[i]+1>>1;
		puts(x[i]?"R":"U");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int c[3][3];
    int a[3];
    int b[3];
    
    
    rep(i, 3){
        rep(j, 3){
            cin >> c[i][j];
        }
    }
    
    rep_eq(i, 100){
        a[0] = i;
        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];
        
        a[1] = c[1][0] - b[0];
        /*cout << "a[0] " << a[0] << endl;
        cout << "a[1] " << a[1] << endl;
        cout << "b[0] " << b[0] << endl;
        cout << "b[1] " << b[1] << endl;
        cout << "b[2] " << b[2] << endl;*/
        if(a[1] == c[1][1] - b[1] && a[1] == c[1][2] - b[2]){
            a[2] = c[2][0] - b[0];
            //cout << "a[2] " << a[2] << endl;
            if(a[2] == c[2][1] - b[1] && a[2] == c[2][2] - b[2]){
                
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000037

    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
//                         #define ll long long
//                         #define int long long
  #define ll int
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
ll dp[maxn];
vi v[maxn];
void dfs(ll root)
{
    if(dp[root])return;
    for(int i : v[root])
    {
        dfs(i);
        dp[root]=max(dp[root],dp[i]+1);
    }
    
}
void solve()
{
    ll n,m;cin>>n>>m;ll a,b;
    for(ll i=0;i<m;i++)
    {
        cin>>a>>b;v[a].pb(b);
    }
    ll ans =0;
    for(ll i=1;i<=n;i++)
    {
            dfs(i);
        ans =max(ans,dp[i]);
    }
    cout<<ans<<endl;
}

signed main()
{
   Need_for_speed(activated);
//
//satisfy
//    {
//  solve();
//   }

    solve();
    
    return 0;
}



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

int main() {

    int N,H,sum=0;
    cin >> H >> N;
   vector<int>A(N);
    for (int i = 0; i < N; i++) { cin >> A[i];sum+=A[i]; }
    if(sum>=H)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main(void)
{
	ios_base::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	k--;
	s[k] = tolower(s[k]);
	cout << s;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<int>> dp(n+1, vector<int>(2, INF));
  dp[0][0] = 0;
  reverse(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    int d = s[i] - '0';
    dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + d);
    dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + d + 1);
    dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 10 - d);
    dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 9 - d);
  }
  int res = min(dp[n][0], dp[n][1] + 1);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 55940
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N int
	con.Scan(&N)
	P := 1
	for i := 1; i <= N; i++ {
		P *= i
		P %= 1e9 + 7
	}
	con.Println(P)
	return nil
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int ans = 0;
    long long a;
    long long b;
    
    scanf("%lld %lld", &a, &b);
    ans = b - a;
    ans = ans * (ans + 1) / 2 - b;
    
    printf("%d\n", ans);
}


Measured memory_bytes: 1664
H, W = map(int, input().split())

s = ['.'*(W+2)] + ['.'+input()+'.' for _ in range(H)] + ['.'*(W+2)]
for hi in range(1, H+1):
  for wi in range(1, W+1):
    if s[hi][wi] == '.':
      continue
    if s[hi-1][wi]=='.' and s[hi+1][wi]=='.':
      if s[hi][wi-1]=='.' and s[hi][wi+1]=='.':
        print('No')
        exit()
        
print('Yes')

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

int main(){
    int n, p;
    cin>>n>>p;
    string s;
    cin>>s;

    if(10%p == 0){
        long long ans = 0;
        for(int i = 0; i < (int)s.length(); i++ ){
              if((s[i]-'0')%p == 0) ans+=(i+1);
        }
        cout<<ans;
        return 0;
    }

    map<int,int> mp;
    mp[0] = 1;
    int pp = 1;
    int t = 0;
    long long ans = 0;
    for(int i = n-1; i>=0 ; i--){
        t = (t+(s[i] - '0')*pp)%p;
        ans += mp[t];
        mp[t]++;
        pp = pp*10%p;
    }
    cout<<ans;
}


Measured memory_bytes: 900
#include<stdio.h>
int main(){
  int a,b;
scanf("%d%d",&a,&b);
  if(a>=13){
    printf("%d",b);
  }
  else if(6<=a && a<=12){
    printf("%d",b/2);
  }
  else{
    printf("0");
  }
  return 0;
}

Measured memory_bytes: 128
n=int(input())
a,b,c=map(int,input().split())
dp=[[a,b,c] for i in range(n)]
for i in range(1,n):
  a,b,c=map(int,input().split())
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))

Measured memory_bytes: 61420
#include<bits/stdc++.h>
using namespace std;
int p[100003];
int main(){
	int n,m,i,j,c,t,s=0;
	scanf("%d%d%d",&n,&m,&t);
	for(i=1;i<=n;++i){
		scanf("%d %d",&p[i],&c);
		if(c==1)p[i]+=t;else p[i]-=t;
		s+=p[i]/m,(s-=((p[i]%=m)<0))%=n,(p[i]+=m)%=m;
	}
	sort(p+1,p+n+1),(s+=n)%=n;
	for(i=s+1;i<=n;++i)printf("%d ",p[i]);
	for(i=1;i<=s;++i)printf("%d ",p[i]);
	return 0;
}

Measured memory_bytes: 1536
import java.io.*;
import java.util.*;
class Main{
    public static void main(String args[]) throws IOException{

	int x=0;
	int y=0;
	int i=0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str = br.readLine();
	String delimiter = " ";
        StringTokenizer stringTokenizer = new StringTokenizer( str, delimiter );
	while(stringTokenizer.hasMoreTokens())
	{
            String current = stringTokenizer.nextToken();
	    if(i==0)x=Integer.parseInt(current);
	    if(i==1)y=Integer.parseInt(current);
	    i++;
	}

	
	System.out.println(x*y+" "+(x+y)*2);
    }
}

Measured memory_bytes: 17056
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N; cin >> N;
	string S; cin >> S;
	int ans = 0;
	rep(i, N - 2) {
		if (S.substr(i, 3) == "ABC") {
			ans++;
		}
	}
	cout << ans << endl;

	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from itertools import accumulate

import math

def is_prime(n):
    if n <= 0: return None
    if n == 1: return False
    sup = math.floor(pow(n,1/2))
    for i in range(2,sup+1):
        if n % i == 0:
            return False
    return True

Q = int(input())
query = [list(map(int,input().split())) for _ in range(Q)]

bit = [0]*(10**5+1)

for i in range(10**5+1):
    if i % 2 == 1 and is_prime(i) and is_prime((i+1)//2):
        bit[i] = 1

bit = list(accumulate(bit))

for l, r in query:
    res = bit[r] - bit[l-1]
    print(res)

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3100
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        s: Chars,
        t: Chars
    };

    let mut res = 1 << 30;
    for i in 0..=s.len() - t.len() {
        let mut c = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                c += 1;
            }
        }
        if c < res {
            res = c;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

using namespace std;

#define ll long long

int pal(string a) 
{ 
  int b=a.length(),f=0;
  for(int i=0; i<b; i++){
      if(a[i]!=a[b-i-1]){
          return false;
      }
  }

  return true;
} 
  

int main(){
    string s,h="",c="";
    cin>>s;
    int n=s.length();
    for(int i=0; i<(n-1)/2; i++){
            h+=s[i];
        }

    for(int i=(n+1)/2; i<n; i++){
            c+=s[i];
    }
    if(pal(s) && pal(h) && pal(c)){
       if(pal(h)){
           if(pal(c)){
               cout<<"Yes"<<endl;
           }
       }
    }
    else cout<<"No"<<endl;
}




Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class BTaxRate {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        for(int i=1;i<=n;i++){
            if((int)(i*1.08)==n) {
                assert((int)(i*1.08)==n);
                out << i << endl;
                return;
            }
        }
        out << ":(" << endl;
	}
};


int main() {
	BTaxRate solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, m, k;
	cin >> n >> m >> k;
	vector<long long> a(n+1,0), b(m+1,0), sa(n+1,0), sb(m+1,0);
	for(int i=1; i<=n; ++i){
		cin >> a[i];
		sa[i] =sa[i-1]+a[i];
	}
	for(int i=1; i<=m; ++i){
		cin >> b[i];
		sb[i] =sb[i-1]+b[i];
	}
	
	int ans=0, j=m;
	for(int i=0; sa[i]<=k && i<=n; ++i){
		while(sa[i]+sb[j]>k) --j;
		ans = max(ans, i+j);
	}

	cout << ans << endl;
}

Measured memory_bytes: 9480
w = input()

if len(w)%2 == 1:
    print('No')
else:
    count = 0
    for i in range(len(w)):
        if w.count(w[i])%2 == 1:
            print('No')
            count = count + 1
            break
        else:
            continue
        #break
    if count == 0:
        print('Yes')   

Measured memory_bytes: 2940
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (lli)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>k;
    while(n)
    {
        cnt++;
        n/=k;
    }
    cout<<cnt<<endl;
}   aryanc403();
    return 0;
}


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

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

  int64_t N, K;
  cin >> N >> K;
  int64_t A[N], F[N];
  rep(i, N){
    cin >> A[i];
  }
  sort(A, A+N);
  reverse(A, A+N);

  rep(i, N){
    cin >> F[i];
  }
  sort(F, F+N);

  pair<int64_t, int64_t> P[N];
  rep(i, N){
    P[i].first = A[i]*F[i];
    P[i].second = F[i];
  }
  sort(P, P+N);
  int64_t num = 0;
  int64_t left = -1, right = P[N-1].first, middle;
  while(right - left > 1){
    middle = (left+right)/2;
    num = 0;
    for(int64_t i=0;i<N;i++){
      num += max((int64_t)0, ((P[i].first + P[i].second - 1)-middle)/P[i].second);
    }
    if(num > K) left = middle;
    else right = middle;
  }


  cout << right << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int n, k;

int dp[100010];
int main() {
    cin >> n >> k;
    vector<int> h(n, 0);
    for(int i = 0; i < n; ++i) cin >> h.at(i);

    dp[0] = 0;
    for(int i = 1; i < n; ++i) {
        dp[i] = 1e9+7;
        for(int j = 1; j <= min(i, k); ++j) {
            dp[i] = min(dp[i], dp[i-j] + abs(h.at(i)-h.at(i-j)));
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  string S;
  cin >> S;
  map<char, ll> counts = {
      {'a', 0},
      {'b', 0},
      {'c', 0},
  };
  rep (i, S.size()) {
    counts[S[i]] += 1;
  }
  ll ma = max(counts['a'], max(counts['b'], counts['c']));
  ll mi = min(counts['a'], min(counts['b'], counts['c']));

  if (abs(ma - mi) <= 1) {
    cout << "YES" << "\n";
  } else {
    cout << "NO" << "\n";
  }

}

Measured memory_bytes: 512
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
a.sort(reverse = True)
cnt = n
ind = 0
res = 0
while cnt:
    if ind % 2:
        res += a[ind]
        cnt -= 1
    ind += 1
print(res)

Measured memory_bytes: 40168
#include<iostream>
#include<vector>
#include <numeric>
#include<algorithm>
using namespace std;
typedef pair<int, int> pii;

int up(int y, int x, int w){
  y %= 2*w;
  while(y){
    int diff;
    if((x + y)&1) diff = min(y, w - x - 1); //odd
    else diff = -min(y, x); //even
    x += diff;
    y -= abs(diff);
    if(y)y--;
  }
  return x;
}

int main(){
  int h, w, n;
  std::cin >> h >> w >> n;
  vector<pii> del(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    std::cin >> a >> b;
    del[i] = pii(--a, --b);
  }
  sort(del.begin(), del.end());
  vector<int> seq(w), ans(w);
  iota(seq.begin(), seq.end(), 0);
  for (int i = 0; i < n; i++) {
    int a = del[i].first, b = del[i].second;
    int x = up(a, b, w), y = up(a, b + 1, w);
    swap(seq[x], seq[y]);
  }
  for (int i = 0; i < w; i++) {
    ans[seq[up(h, i, w)]] = i + 1;
  }
  for (int i = 0; i < w; i++) {
    std::cout << ans[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 5968
import java.util.Arrays;
import java.util.Scanner;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        int[] d = new int[n];
        for(int i = 0; i < n; i++) v[i] = sc.nextInt();
        for(int i = 0; i < n; i++) c[i] = sc.nextInt();
        for(int i = 0; i < n; i++) d[i] = v[i] - c[i];
        Arrays.sort(d);
        int ans = 0;
        for(int i = n - 1; i >= 0; i--){
            if(d[i] >= 0) ans += d[i];
        }
        System.out.print(ans);
    }
}


Measured memory_bytes: 21332
#include <stdio.h>

int main()
{
	int A, B, C, D, E, F;
	scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
	
	int i, j, dp[31][1501] = {{1}};
	for (i = 0; i <= F / 100; i++) {
		for (j = 0; j <= i * E && i * 100 + j <= F; j++) {
			if ((i + A) * 100 + j <= F) dp[i+A][j] |= dp[i][j];
			if ((i + B) * 100 + j <= F) dp[i+B][j] |= dp[i][j];
			if (j + C <= i * E && i * 100 + j + C <= F) dp[i][j+C] |= dp[i][j];
			if (j + D <= i * E && i * 100 + j + D <= F) dp[i][j+D] |= dp[i][j];
		}
	}
	
	int argmax[2] = {A * 100, 0};
	long double max = 0.0, tmp;
	for (i = 1; i <= F / 100; i++) {
		for (j = 1; j <= i * E && i * 100 + j <= F; j++) {
			if (dp[i][j] == 0) continue;
			tmp = (long double)j / (i * 100 + j);
			if (tmp > max) {
				max = tmp;
				argmax[0] = i * 100 + j;
				argmax[1] = j;
			}
		}
	}
	printf("%d %d\n", argmax[0], argmax[1]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);
		int total = 0;
		int a =0;
		int b =0;
		int c =0;
		int d =0;

		a = sc1.nextInt();
		b = sc1.nextInt();
		c = sc1.nextInt();
		d = sc1.nextInt();

		if(a<b) {
			total += a;
		}
		else {
			total += b;
		}

		if(c<d) {
			total += c;
		}
		else {
			total += d;
		}

		System.out.println(total);

		sc1.close();

	}

}


Measured memory_bytes: 21972
from fractions import gcd
def agc018_a():
  n, k = map(int, input().split())
  A = list(map(int, input().split()))
  A = sorted(A)
  # 元の数列の最大を超える数は作れない
  if A[-1] < k:
    print('IMPOSSIBLE')
    return
  # 数列要素のgcdを求める
  g = A[0]
  for a in A:
    g = gcd(g, a)
    # 元の数列内に存在していれば即OK
    if a == k:
      print('POSSIBLE')
      return
  # gcdで割れる値なら作り出せる？？
  if k % g == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

agc018_a()

Measured memory_bytes: 16240
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a + b;
        if (c % 2 != 0) {
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println(c / 2);
        }
    }
}


Measured memory_bytes: 24276
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;



void solve() {
	string S; cin >> S;
	int c = 0;
	int Q; cin >> Q;
	string v1, v2;
	while (Q--) {
		int t; cin >> t;
		if (t == 1)c++;
		else {
			int f; cin >> f;
			char C; cin >> C;
			if ((c + f) & 1) {
				v1 += C;
			}
			else {
				v2 += C;
			}
		}
	}
	if (c % 2 == 0) {
		VREVERSE(v1);
		cout << v1 << S << v2 << endl;
	}
	else {
		VREVERSE(v2);
		VREVERSE(S);
		cout << v2 << S << v1 << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 1040
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    h, w = input_to_int_map()
    mz = [input() for i in range(h)]

    from collections import deque

    ret = 0
    for x in range(h):
        for y in range(w):
            # 壁からはスタートできない
            if mz[x][y] == "#":
                continue

            # 初期化
            distance = [[0] * w for _ in range(h)]
            # start位置
            dq = deque([[x, y]])

            while dq:
                now_h, now_w = dq.popleft()
                for i, j in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
                    new_h, new_w = now_h + i, now_w + j
                    if new_h < 0 or new_w < 0 or new_h >= h or new_w >= w:
                        continue

                    if mz[new_h][new_w] != "#" and distance[new_h][new_w] == 0:
                        distance[new_h][new_w] = distance[now_h][now_w] + 1
                        dq.append([new_h, new_w])

            distance[x][y] = 0
            ret = max(max(list(map(max, distance))), ret)

    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3316
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <vector>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;


int main(){
    ll n;
    cin>>n;
    string s[n];
    bool fl=true;
    for(ll i=0;i<n;i++){
        if(!(fl))break;
        cin>>s[i];
        if(i!=0){
            if(s[i-1][s[i-1].length()-1]!=s[i][0]){
                fl=false;
            }
            for(ll j=0;j<i;j++){
                if(s[i]==s[j]){
                    fl=false;
                    break;
                }
            }
        }
    }
    if(fl) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  // dp1[i]: 上からi桁目まで最大 N以下確定
  // dp2[i]: N以下未確定
  string S; cin >> S;
  int N = S.size();

  vector<int> dp1(N, 0);
  vector<int> dp2(N, 0);

  int d0 = S[0] - '0';
  for(int i = 0; i <= d0; i++){
    if(i == d0){
      dp2[0] = i;
    } else { 
      dp1[0] = max(dp1[0], i);
    }
  }

  for(int i = 0; i < N-1; i++){
    int d = S[i+1] - '0';
    for(int j = 0; j <= d; j++){
      if(j == d){
        dp2[i+1] = dp2[i] + d; 
      } else { 
        dp1[i+1] = max(dp1[i+1], dp1[i] + j);
      }
    }
  }

  for(int i = 0; i < N-1; i++){
    int d = S[i+1] - '0';
    for(int j = 0; j <= 9; j++){
      dp1[i+1] = max(dp1[i+1], dp1[i] + j);
    }
  }

  cout << max(dp1[N-1], dp2[N-1]) << endl;
}



Measured memory_bytes: 3604
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int n;
char S[300][300] = {};
char copy_big[600][600] = {};

bool func(int A,int B) {
	
	for (int i = 0; i < 2*n; i++) {
		for (int j = 0; j < 2*n; j++) {
			copy_big[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			copy_big[i + A][j + B] = S[i][j];
		}
	}/*
	for (int i = 0; i < 2*n; i++) {
		for (int j = 0; j < 2*n; j++) {
			cerr << copy_big[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;*/
	for (int i = 0; i < 2*n; i++) {
		for (int j = 0; j < 2*n; j++) {
			if (copy_big[i][j] != 0) {
				copy_big[i%n][j%n] = copy_big[i][j];
			}
		}
	}
/*
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cerr << copy_big[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;*/

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (copy_big[i][j] != copy_big[j][i]) {
				return false;
			}
		}
	}
	return true;
}

int main(void)
{
	cin >> n;

	//n = 3;
	//srand(7);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			//S[i][j] = rand() % 2 + 'a';
			cin >> S[i][j];
		}
	}

	int answer = 0;

	for (int i = 0; i < n; i++) {
		if (func(i, 0)) {
			answer += n;
		}
	}
/*
	system("cls");

	int test = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (func(i, j)) {
				test += 1;
			}
		}
	}

	cerr << test << " " << answer << endl;
	assert(test == answer);*/

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 640
def solve(N, W, data):
    """
    >>> solve(4, 8, [(4, 2), (5, 2), (2, 1), (8, 3)])
    21
    >>> solve(2, 20, [(5, 9), (4, 10)])
    10
    >>> solve(3, 9, [(2, 1), (3, 1), (5, 2)])
    27
    """
    dp = [0] * (W + 1)

    for v, w in data:
        for i in range(w, W + 1):
            dp[i] = max(dp[i - w] + v, dp[i])

    return dp[-1]


if __name__ == '__main__':
    N, W = map(int, input().split())
    data = [tuple(map(int, input().split())) for _ in range(N)]
    print(solve(N, W, data))
    # import doctest
    # doctest.testmod(verbose=True)



Measured memory_bytes: 5732
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

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


int main()
{
  int N;
  cin>>N;
  long long ans=1LL;
  for(int i=0;i<N;i++){
    long long t;
    cin>>t;
    ans=ans/gcd(ans,t)*t;
  }
  cout<< ans <<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1;
  cin>>s1;
  if(s1[2]==s1[3]&&s1[4]==s1[5]){
    cout<<"\nYes";
  }else{
    cout<<"\nNo";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    double r;
    cin >> r;
    cout << fixed << setprecision(10) << 2 * r * acos(-1) << endl;
    return 0;
}

Measured memory_bytes: 3788
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] A = new int[N + 2];
    int sum = 0;
    for (int i = 1; i <= N; i++) {
      A[i] = scanner.nextInt();
      sum += Math.abs(A[i] - A[i - 1]);
    }
    sum += Math.abs(A[N]);
    StringBuilder sb = new StringBuilder();
    for (int i = 1; i <= N; i++) {
      sb.append(sum - Math.abs(A[i] - A[i - 1]) - Math.abs(A[i] - A[i + 1]) + Math.abs(A[i + 1] - A[i - 1])).append('\n');
    }
    System.out.print(sb.toString());
  }
}


Measured memory_bytes: 51500
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;
#define eps 1e-8
#define mod 1000000007

ll n, m;

ll mul(ll a, ll b) {
    return a * b % mod;
}

int main() {
    cin >> n >> m;
    if (n < m) swap(n, m);
    if (n - m > 1) {
        cout << 0 << endl;
        return 0;
    }
    ll res;
    if (n - m == 1) {
        res = 1;
        for (int i = 1; i < n; ++i) {
            res = mul(res, mul(i, i));
        }
        res = mul(res, n);
    } else {
        res = 1;
        for (int i = 1; i <= n; ++i) {
            res = mul(res, mul(i, i));
        }
        res = mul(res, 2);
    }
    cout << res;

    return 0;
}

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

#define ll long long
using namespace std;

#define MAXN 

void solve()
{
	int a,b;
	cin>>a>>b;
	int ans = 0;
	ans = max(4-a,0) + max(4-b,0);
	if(ans==6)
		ans+=4;
	cout<<ans*100000<<endl;
	

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//int T;
	//cin>>T;
	//while(T--)
		solve();
		
	return 0;
}


Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var n int
  fmt.Scan(&n)
  if n == 3 {
    fmt.Println(2,5,63)
    return
  }
  var d []int = []int{6,2,10,3,9,4,8,12}
  if n%2 == 0 { d = []int{2,10,3,9,4,8,6,12} }
  for len(d) < n { d = append(d,d[len(d)-8]+12) }
  fmt.Print(d[0])
  fmt.Print(" ")
  for i:=1;i<n-1;i++ {
    fmt.Print(d[i])
    fmt.Print(" ")
  }
  fmt.Println(d[n-1])
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll a,b,c;

int main(){
	cin>>a>>b>>c;
	for(int i=0;i<10;i++){
		c=a*c-b;
		cout<<c<<endl;
	}
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    C = [list(map(int, readline().split())) for _ in range(3)]

    A = [0] * 3
    B = [0] * 3

    for i in range(3):
        B[i] = C[0][i]

    for i in range(1, 3):
        A[i] = C[i][0] - B[0]

    for i in range(3):
        for j in range(3):
            if C[i][j] != A[i] + B[j]:
                print('No')
                return

    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
N,M = map(int,input().split())
XYZ = [[int(x) for x in input().split()] for _ in range(M)]

par = [i for i in range(N)]
rank = [0]*N


def root(x):
    tmp = x
    while par[tmp]!=tmp:
        tmp = par[tmp]
    return tmp

def unite(x,y):
    rx = root(x)
    ry = root(y)
    if rx==ry:
        return
    if rank[rx] < rank[ry]:
        rx,ry = ry,rx
    if rank[rx] == rank[ry]:
        rank[rx] += 1
    par[ry] = rx

for x,y,z in XYZ:
    unite(x-1,y-1)

ans = 0
for i in range(N):
    if par[i] == i:
        ans += 1
print(ans)


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

int main () {
	int n, w; cin >> n >> w;
	int x[n + 1], y[n + 1];
	for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];

	vector <vector <long long>> f(n + 1,  vector <long long> (w + 1, 0)); 
	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= w; j++) 
			if (x[i] > j) f[i][j] = f[i - 1][j];
			else f[i][j] = max (f[i - 1][j], y[i] + f[i - 1][j - x[i]]);

	cout << f[n][w];
	return 0;
}

Measured memory_bytes: 83232
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;



int main() {
ll N,K;
  in(N>>K);
  ll ans =0;
  for(ll i=K;i<=N+1;i++){
   ans +=  ((i*N)-i*(i-1)+1);
    ans %= mod;
  }
  out(ans);
}


Measured memory_bytes: 3624
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		// scanner.nextLine();
		String line = scanner.nextLine();

		int N = Integer.parseInt(line.split("\\s+")[0]);

		int res = (int)Math.ceil(1.0 * N / 2);
		System.out.println(res);
		// int R = Integer.parseInt(line.split("\\s+")[1]);



		return;
	}

	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl G = VV(200001, 0, 0, ll);
vll red, blue;

void f(ll now, ll from, ll d){
  (d%2?red:blue).push_back(now);
  for(auto to:G[now]){
    if(to==from) continue;
    f(to, now, d+1);
  }
}
int main(int argc, char const *argv[]) {
  ll a, b, n;std::cin >> n;
  re(i, n-1){
    scanf("%lld %lld", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  f(1, -1, 0);
  ll o = n/3 + (n%3>=1);
  ll t = n/3 + (n%3>=2);
  ll th = n/3;

  vll ans(200001, 0);


  if(n - max(red.size(), blue.size())<=th){
    set<ll> s;
    for(int i=1;i<=n;i++) s.insert(i);
    if(red.size()>blue.size()){
      ll cnt = 1;
      for(int i=0;i<blue.size();i++, cnt++){
        ans[blue[i]] = cnt*3;
        s.erase(cnt*3);
      }
      for(auto to:red){
        ans[to] = (*s.begin());
        s.erase(s.begin());
      }
    }else{
      ll cnt = 1;
      for(int i=0;i<red.size();i++, cnt++){
        ans[red[i]] = cnt*3;
        s.erase(cnt*3);
      }
      for(auto to:blue){
        ans[to] = (*s.begin());
        s.erase(s.begin());
      }
    }
  }else{
    ll t = 1, x = 1, y = 2;
    for(int i=0;i<red.size();i++, x+=3){
      if(x<=n) ans[red[i]] = x;
      else ans[red[i]] = t*3, t++;
    }
    for(int i=0;i<blue.size();i++, y+=3){
      if(y<=n) ans[blue[i]] = y;
      else ans[blue[i]] = t*3, t++;
    }
  }
  for(int i=1;i<=n;i++) std::cout << ans[i] << (i==n?"\n":" ");
  return 0;
}


Measured memory_bytes: 23148
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int N,i;
	bool flag=0;
	cin>>N;
	vector<int> K{1,2,3,5,6,9,10,13,17};
	for(i=0;i<9;i++){
		if(K.at(i)==N){
			flag=1;
		}
	}
	if(flag){
		cout<<"No";
	}else{
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int n, m;
vector<pair<int, int>> vec;
bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.second < b.second;
}

int main() {
  cin >> n >> m;
  vec.resize(m);
  
  for (int i = 0; i < m; i++) {
    cin >> vec[i].first >> vec[i].second;
  }
  sort(vec.begin(), vec.end(), cmp);
  
  int cut = 0;
  int endtime = 0;
  for (int i = 0; i < m; i++) {
    if (vec[i].first >= endtime) {
      endtime = vec[i].second;
      cut++;
    }
  }
  cout << cut << endl;
  return 0;
}


Measured memory_bytes: 1024
#from sys import stdin

#input = stdin.readline
#inputRstrip = stdin.readline().rstrip

#x = input().rstrip()
#n = int(input())

#a,b,c = input().split()
#a,b,c = map(int, input().split())

ST = [input() for i in range(2)]
S = ST[0]
T = ST[1]
ans = len(T)

for i in range(len(S) - len(T) + 1):
	count = len(T)
	for j in range(len(T)):
		if(T[j] == S[i + j]):
			count -= 1
	if(ans > count):
		ans = count
print(ans)

Measured memory_bytes: 73128