akhauriyash/Code-Regression huggingface dataset:
S = input()
K = int(input())
l = len(S)

if l == 1:
    print(K // 2)
    exit()

if l == 2:
    if S[0] == S[1]:
        print(K)
    else:
        print(0)
    exit()



else:
    ans = 0
    prev = None
    edge = False
    for i, v in enumerate(S):
        if prev == v:
            ans += 1
            if i == 0 or i == l - 1:
                edge = True
            prev = None
        else:
            prev = v

    if S[0] != S[-1] or edge:
        print(ans * K)
    else:
        ans2 = 1
        prev = None
        edge2 = False
        for i, v in enumerate(S):
            if i == 0:
                continue
            elif prev == v:
                ans2 += 1
                if i == l - 1:
                    edge2 = True
                prev = None
            else:
                prev = v

        ans3 = 1
        prev = None
        edge3 = False
        for i, v in enumerate(S[::-1]):
            if i == 0:
                continue
            elif prev == v:
                ans3 += 1
                if i == l - 1:
                    edge3 = True
                prev = None
            else:
                prev = v

        if ans2 == ans3 and edge2:
            #print('type2, ans={}, ans2={}, edge2={}'.format(ans, ans2, edge2))
            print((ans + ans2) * (K // 2) + min(ans, ans2) * (K % 2))
        elif ans2 == ans3:
            #print('type3, ans={}, ans2={}, edge2={}'.format(ans, ans2, edge2))
            print(ans + ans2 * (K - 1))
        else:
            print(min(ans2 * K, ans3 * K))


Measured memory_bytes: 38384
p, g, ig = 998244353, 3, 332748118
W = [pow(g, (p - 1) >> i, p) for i in range(24)]
iW = [pow(ig, (p - 1) >> i, p) for i in range(24)]

def fft(k, f):
    for l in range(k, 0, -1):
        d = 1 << l - 1
        U = [1]
        for i in range(d):
            U.append(U[-1] * W[l] % p)
        
        for i in range(1 << k - l):
            for j in range(d):
                s = i * 2 * d + j
                t = s + d
                f[s], f[t] = (f[s] + f[t]) % p, U[j] * (f[s] - f[t]) % p

def ifft(k, f):
    for l in range(1, k + 1):
        d = 1 << l - 1
        U = [1]
        for i in range(d):
            U.append(U[-1] * iW[l] % p)
        
        for i in range(1 << k - l):
            for j in range(d):
                s = i * 2 * d + j
                t = s + d
                f[s], f[t] = (f[s] + f[t] * U[j]) % p, (f[s] - f[t] * U[j]) % p

def convolve(a, b):
    n0 = len(a) + len(b) - 1
    k = (n0).bit_length()
    n = 1 << k
    a = a + [0] * (n - len(a))
    b = b + [0] * (n - len(b))
    fft(k, a), fft(k, b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(k, a)
    invn = pow(n, p - 2, p)
    for i in range(n0):
        a[i] = a[i] * invn % p
    del a[n0:]
    return a

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


Measured memory_bytes: 204380
#include <stdio.h>

int main(void) {

	int A;
	int B;

	scanf("%d", &A);
	scanf("%d", &B);     
  
    int K = A - 1;
    int J = B - 1;

    if(A + K >= A + B && A + K >= B + J){
      printf("%d",A + K);
    }
    else if(A + B >= A + K && A + B >= B + J){
      printf("%d",A + B);
    }
    else if(B + J >= A + K && B + J >= B + A){
      printf("%d",B + J);
    }
	return 0;
}



Measured memory_bytes: 128
mod=10**9+7
n=gets.to_i
dp=(0..n).map{Hash.new(0)}
dp[0]['TTT']=1
n.times{|i|
    dp[i].each{|k, v|
        a, b, c=k.chars
        'ACGT'.chars{|d|
            next if (a+b+c+d)['AGC']
            next if (b+a+c+d)['AGC']
            next if (a+c+b+d)['AGC']
            next if (a+b+d+c)['AGC']
            s=b+c+d
            dp[i+1][s]=dp[i+1][s]+v
            dp[i+1][s]%=mod
        }
    }
}
puts dp[n].values.inject(:+)%mod


Measured memory_bytes: 2428
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int x = tx-sx;
	int y = ty-sy;
	cout << string(y,'U') << string(x,'R');
	cout << string(y,'D') << string(x,'L');
	cout << 'L' << string(y+1,'U')<<string(x+1,'R') << 'D';
	cout <<'R' << string(y+1,'D')<<string(x+1,'L') << 'U';
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double ans = 0;
		for(int i = 0; i < n; i++){
			double x = sc.nextDouble();
			String u = sc.next();
			if(u.equals("JPY")){
				ans += x;
			}else{
				ans += x*380000;
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pii(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main(){
//	freopen("in.txt","r",stdin);
 //   freopen("out.txt","w",stdout);
  int n;
  cin>>n;
    vector<pair<int,int>>v(n);
    f(i,0,n)
	 cin>>v[i].first;

	 f(i,0,n)cin>>v[i].second;
	 
	 int ans=0;
	 f(i,0,n)
	 { 
	   ans=max(ans+v[i].first-v[i].second,ans);	
	 }
	 cout<<ans;
	    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll h;
    cin >> h;
    int cnt = 0;
    while (h > 0) {
        h /= 2;
        cnt++;
    }
    cout << (1LL << cnt) - 1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define ll long long
ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}
ll lcm(ll p,ll q){return p/gcd(p,q)*q;}

int main(void) {
    long a, b, c, d, count=0;
    scanf("%ld %ld %ld %ld", &a, &b, &c, &d);

    long x = b-b/c-b/d+b/lcm(c,d);
    long y = (a-1)-(a-1)/c-(a-1)/d+(a-1)/lcm(c,d);
    printf("%ld\n", x-y);
    return 0;
}


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

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

N, C = MAP()
x = [0] * N
v = [0] * N
for i in range(N):
	x[i], v[i] = MAP()

A = [0] * N
v_tmp = 0
for i in range(N):
	v_tmp += v[i]
	A[i] = v_tmp - x[i]

B = [0] * N
v_tmp = 0
for i in range(N-1, -1, -1):
	v_tmp += v[i]
	B[i] = v_tmp - (C-x[i])

gA = [0] * N
gA[0] = A[0]
for i in range(1, N):
	gA[i] = max(gA[i-1], A[i])

gB = [0] * N
gB[N-1] = B[N-1]
for i in range(N-2, -1, -1):
	gB[i] = max(gB[i+1], B[i])

a = max(A)
b = max(B)
c, d = 0, 0
if N > 1:
	c = max([A[i]-x[i]+gB[i+1] for i in range(N-1)])
	d = max([B[i]-(C-x[i])+gA[i-1] for i in range(N-1, 0, -1)])

print(max(a, b, c, d, 0))


Measured memory_bytes: 27288
#include<bits/stdc++.h>
#define PI 3.141592653589
using namespace std;
using ll = long long;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int f(int n){
  int tmp = 0;
  while(n>0){
    tmp += n%10;
    n = n/10;
  }
  return tmp;
}
int main(){
  int n, a, b;
  int cnt = 0;
  cin >> n >> a >> b;
  for(int i=1; i<=n; ++i){
    if(f(i)>=a && f(i)<=b) cnt +=i;
  }

  cout << cnt;
  return 0;
}

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

// #define deb(x) cout << #x << " " << x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define ll  long long
#define all(c) (c).begin(),(c).end()
#define nl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll; typedef map< int, int> mll;
int t[100][100];

void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}





int main() {
 
    int i;

    c_p_c();
    // cout<<"Da"<<endl;
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
  return 0;

}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#define rep(num,num2) for(int num=0;num<num2;num++)
using namespace std;
int main()
{
    int t=0,r=0,n=0,p=0;
    while(true)
    {
        int a[3];
        rep(i,3)cin>>a[i];
        sort(a,a+3);
        if(a[1]+a[0]<=a[2])break;
        if(a[2]*a[2]==a[1]*a[1]+a[0]*a[0]){
            t++;r++;
        }
        if(a[2]*a[2]>a[1]*a[1]+a[0]*a[0]){
            t++;p++;
        }
        if(a[2]*a[2]<a[1]*a[1]+a[0]*a[0]){
            t++;n++;
        }
    }
    cout<<t<<" "<<r<<" "<<n<<" "<<p<<endl;
}

Measured memory_bytes: 1180
package main

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

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	n, a, b := scanInt(sc), scanInt(sc), scanInt(sc)
	s := scanString(sc)
	rank, rankB := 0, 0
	for i := 0; i < n; i++ {
		switch s[i] {
		case 'c':
			fmt.Println("No")
			continue
		case 'a':
			if rank < a+b {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
				continue
			}
		case 'b':
			if rank < a+b && rankB < b {
				fmt.Println("Yes")
				rankB++
			} else {
				fmt.Println("No")
				continue
			}
		}
		rank++
	}
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
  bool flag=false;
  long long X;
  cin >> X;

  if(X==2){
    cout << '2' << endl;
  }
  else{
    for(long long i=0;;i++){
      for(long long j=2;j<X+i;j++){
        if((X+i)%j==0){
          break;
        }
        if(j==X+i-1){
          cout << X+i << endl;
          flag=true;
          break;
        }
      }
      if(flag){
        break;
      }
    }
  }
}


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

typedef long long ll;

int main() {
  ll K;
  std::cin >> K;

  const int N = 50;
  ll a[N];

  ll cnt = K / N;
  a[0] = cnt;
  for(int i = 1; i < N; ++i) {
    a[i] = a[i - 1] + 1;
  }

  cnt = K - N * cnt;
  for(int i = 0; i < cnt; ++i) {
    a[i] += N;
    for(int j = 0; j < N; ++j) {
      if(i != j) --a[j];
    }
  }

  std::cout << N << "\n";
  for(int i = 0; i < N; ++i) {
    std::cout << a[i] << " ";
  } std::cout << std::endl;

}


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

const int INF = 500000;

int n, m;
vector<int> G[200000];

int bfs() {
  vector<int> dist(200000, INF);
  queue<int> Q;
  Q.push(0);
  dist[0] = 0;
  
  while (Q.size()) {
    int v = Q.front(); Q.pop();
    for (auto u: G[v]) {
      if (dist[u] < INF) continue;
      Q.push(u);
      dist[u] = dist[v] + 1;
    }
  }
  
  return dist[n-1];
}

int main() {
  cin >> n >> m;
  loop(i,0,m) {
    int a, b;
    cin >> a >> b; a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if (bfs() <= 2) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 15972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

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

}


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

int main(){
	int N;
  cin >> N;
 	int j,odd=0,even=0;
  for(int k = 0; k < N; k++){
    cin >> j;
if(j % 2 == 0){
even++;
}
else{
odd++;
}
}
if(odd % 2 == 0){
    cout << "YES" << endl;
}
else {
cout << "NO"<< endl;
}
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 101000
using namespace std;
int n, v[N_], R1[N_], R2[N_];
vector<int>E[N_], G[N_], U;
int main() {
	int i, a, b, st, j;
	scanf("%d", &n);
	for (i = 1; i < n; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	if (n == 2) {
		printf("%d %d\n", 1, 2);
		return 0;
	}
	for (i = 1; i <= n; i++) {
		if (E[i].size() >= 2) {
			for (auto &t : E[i]) {
				if (E[t].size() >= 2)G[i].push_back(t);
			}
			if (G[i].size() > 2) {
				puts("-1\n");
				return 0;
			}
			if (G[i].size() <= 1) {
				st = i;
			}
		}
	}
	int x = 0;
	for (auto &t : E[st]) {
		if (E[t].size() == 1) {
			x = t;
			break;
		}
	}
	while (1) {
		int nxt = -1;
		int Mx = 0, c = 0;
		v[x] = 1;
		for (auto &t : E[x]) {
			if (!v[t] && E[t].size() > Mx)nxt = t, Mx = E[t].size();
		}
		for (auto &t : E[x]) {
			if (!v[t] && t != nxt)c++;
		}
		U.push_back(c);
		if (nxt == -1)break;
		x = nxt;
	}
	int p1 = 0;
	for (i = 0; i < U.size(); i++) {
		int t = U[i]+1;
		for (j = p1 + 1; j < p1 + t; j++)R1[j] = j+1;
		R1[p1 + t] = p1+1;
		p1 += t;
	}
	p1 = 0;
	for (i = U.size() - 1; i >= 0; i--) {
		int t = U[i]+1;
		for (j = p1 + 1; j < p1 + t; j++)R2[j] = j + 1;
		R2[p1 + t] = p1+1;
		p1 += t;
	}
	int ck = 0;
	for (i = 1; i <= n; i++)if (R1[i] != R2[i]) {
		if (R1[i] > R2[i])for (j = 1; j <= n; j++)R1[j] = R2[j];
		break;
	}
	for (i = 1; i <= n; i++)printf("%d ", R1[i]);
}

Measured memory_bytes: 13436
#include <stdio.h>
 
int main(){
    int H,W;
    int x,y;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){break;}
        for(x=0;x<H;x++){
            for(y=0;y<W;y++){
                if((x+y)%2==0){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}
 

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
deque<int> d;
int a[200005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
//	cout<<1;
	for(int i=0;i<n;i++)
	{
		if((i+n)%2==0) d.push_back(a[i]); else d.push_front(a[i]);
//		cout<<a[i];
	}
	for(int i=0;i<n;i++)
	{
		cout<<d.front()<<" ";
		d.pop_front();
	}
	return 0;
}

Measured memory_bytes: 3840
def nCr(n, r, mod):
    if r < 0 or n < r:
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod


mod = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


h, w, a, b = map(int, input().split())

ans = 0

for i in range(w - b):
    ans += nCr(h - a - 1 + b, b, mod) * nCr(w - b - 1 + a - 1, a - 1, mod)
    b += 1

print(ans % mod)

Measured memory_bytes: 122068
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<ll> H(N);
    REP(i,N) cin>>H[i];
    if(N==1){
        cout<<"Yes"<<endl;
        return 0;
    }
    for(int i=1;i<N;i++){
        if(H[i-1]-1>H[i]){
            cout<<"No"<<endl;
            return 0;
        }
        else if(H[i-1]==H[i]) continue;
        else if(H[i-1]<H[i]) H[i]--;
    }
    for(int i=1;i<N;i++){
        if(H[i-1]>H[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 1024
n, m, c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    t = c
    a = list(map(int,input().split()))
    for j in range(m):
      t += a[j]*b[j]
    if t > 0: ans += 1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const int maxn=1e6+5;
ll n,m,p;
ll gcd(ll a,ll b)
{
    if(!b) return a;
    return gcd(b,a%b);
}
int main()
{
    scanf("%lld%lld",&n,&m);
    printf("%lld\n",n*m/gcd(n,m));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  int n,k;
  cin>>n>>k;
  vin a(n);
  rep(i,n) cin>>a[i];
  ////
  int ans=0;
  ans++;
  n-=k;
  
  while(n>0){
    ans++;
    n-=(k-1);
    
  }
  cout<<ans<<endl;
}

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

using namespace std;

struct Point {
    double x, y;
    Point(double x, double y) : x(x), y(y) {}
    Point() {}
};
bool operator<(const Point &p1, const Point &p2) {
    return (p1.x < p2.x) || (p1.x == p2.x && p1.y < p2.y);
}
bool compare_y(const Point &p1, const Point &p2) {
    return p1.y < p2.y;
}

double ClosestPair(vector<Point>::iterator begin, vector<Point>::iterator end) {
    const int n = end - begin;
    if (n <= 1)
        return numeric_limits<double>::max();
    int m = n / 2;
    double x = (begin + m)->x;
    double d = min(ClosestPair(begin, begin + m), ClosestPair(begin + m, end));
    inplace_merge(begin, begin + m, end, compare_y);

    vector<Point> b;
    for (auto it = begin; it != end; ++it) {
        if (d <= abs(it->x - x))
            continue;

        for (size_t i = 0; i < b.size(); ++i) {
            double dx = it->x - b[b.size() - i - 1].x;
            double dy = it->y - b[b.size() - i - 1].y;
            if (d <= dy)
                break;
            d = min(d, sqrt(dx * dx + dy * dy));
        }
        b.emplace_back(*it);
    }

    return d;
}

double Solve(vector<Point> &p) {
    sort(p.begin(), p.end());
    return ClosestPair(p.begin(), p.end());
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(15) << setiosflags(ios::fixed); // printf("%.4f", x);

    int n;

    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; ++i)
        cin >> p[i].x >> p[i].y;

    cout << Solve(p) << endl;

    return 0;
}

Measured memory_bytes: 7604
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);

  rep(i, m){
    cin >> l[i] >> r[i];
  }

  int conl, conr;
  conl = l[0]; conr = r[0];
  for(int i = 1; i < m; ++i){
    conl = max(l[i], conl);
    conr = min(r[i], conr);
  }
  int ans = 0;
  for(int i = conl; i <= conr; ++i){
    if(n >= i) ans++;
  }

  cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << max({a + b, a - b, a * b}) << endl;


  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		String ans = "NO";
		if(s.matches("(dream|dreamer|erase|eraser)*")) ans = "YES";
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 35204
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
const ll MAX_N = 2e5;
vector<ll> G[MAX_N],GR[MAX_N];
vector<ll> vlist;
vector<bool> used(MAX_N,false);
ll n,m;
void dfs(ll v){
  if(used[v]) return;
  used[v] = true;
  for(auto nv:G[v]){
    dfs(nv);
  }
  vlist.push_back(v);
}
void tsort(){
  for(int i=0;i<n;i++){
    dfs(i);
  }
  reverse(vlist.begin(),vlist.end());
}
signed main(){
  init_io();
  cin >> n >> m;
  vector<ll> a(n-1+m),b(n-1+m),tp_idx(n,0);
  for(int i=0;i<n-1+m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    GR[b[i]].push_back(a[i]);
  }
  tsort();
  ll p=vlist[0];
  for(int i=0;i<n;i++){
    tp_idx[vlist[i]] = i;
  }
  for(int i=0;i<n;i++){
    if(p==i){
      cout <<0<<endl;
    }else{
      ll mv=GR[i].front();
      for(auto v:GR[i]){
        if(tp_idx[mv]<tp_idx[v]){
          mv = v;
        }
      }
      cout << mv+1 << endl;
    }
  }
}


Measured memory_bytes: 22904
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, a, b);
    Cout(b, a);
}

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


int main()
{
	int N,L;
	cin>>N>>L;
	vector<string> s(N);
	rep(i,N) cin>>s[i];
	sort(s.begin(),s.end());
	rep(i,N) cout<<s[i];
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cstring>
#include <map>
#include <unordered_set>
#include <cmath>
#include <iomanip>

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define linebreak "\n"
#define space " "
#define PI atan(1)*4
#define E 10
#define ACCURATE cout << fixed << setprecision(20)
#define MAX 1e9
#define MOD (int)(998244353 )
#define vi vector<int>
#define N (int)(1e7)
#define _DEBUG
using namespace std;


int main() {
#ifdef _DEBUG // place in cmake-build-debug folder
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    IO;
    int n  ;
    cin >> n ;
    map<string , int> mp ;
    int most = 0 ;
    for(int i = 0  ; i <n ; i++) {
        string t ;
        cin >> t ;
        if(mp.count(t)) mp[t]++ ;
        else mp[t] = 1 ;
        most = max(most , mp[t]) ;
    }
    for(map<string , int >:: iterator it = mp.begin() ; it != mp.end() ; it++) {
        if(it->second == most) cout << it->first << endl ;
    }
    return 0;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
#define sz(x) (int)x.size()
#define MAX 100000

using namespace std;
typedef long long ll;

string s;
int A[MAX];

int main(){
  cin >> s;
  int n=sz(s);
  int rnum=0, lnum=0;
  bool rstate=false, lstate=false;
  int rtol;//lindex
  for(int i=0; i<n; i++){
    if(s[i]=='R' && !lstate){
      rnum++;
      rstate=true;
    } else if(s[i]=='R' && lstate){
      lstate=false;
      rstate=true;
      A[rtol-1]=(rnum-rnum/2)+lnum/2;
      A[rtol]=rnum/2+(lnum-lnum/2);
      rnum=1;
    } else if(s[i]=='L' && !rstate){
      lnum++;
    } else if(s[i]=='L' && rstate){
      lnum=1;
      rstate=false;
      lstate=true;
      rtol=i;
    }
  }
  A[rtol-1]=(rnum-rnum/2)+lnum/2;
  A[rtol]=rnum/2+(lnum-lnum/2);
  for(int i=0; i<n; i++){
    cout << A[i] << " ";
  }
}


Measured memory_bytes: 1024
#include <iostream>

#include <string>

#include <cstring>

using std::cin;
using std::cout;
using std::endl;

using std::string;

using std::strcpy;

char mat[52][52] = {'.'};

static void
solve(int H, int W)
{
  for (int y = 1; y <= H; y++)
  {
    for (int x = 1; x <= W; x++)
    {
      if (mat[y][x] == '.')
      {
        mat[y][x] = ('0'
                     + (mat[y - 1][x - 1] == '#') + (mat[y - 1][x] == '#') + (mat[y - 1][x + 1] == '#')
                     + (mat[y + 0][x - 1] == '#') + (mat[y + 0][x] == '#') + (mat[y + 0][x + 1] == '#')
                     + (mat[y + 1][x - 1] == '#') + (mat[y + 1][x] == '#') + (mat[y + 1][x + 1] == '#'));
      }
    }
  }
}

int
main()
{
  int H, W;
  cin >> H >> W;
  string s;
  for (int h = 0; h < H; h++)
  {
    cin >> s;
    strcpy(&mat[h + 1][1], s.c_str());
  }
  solve(H, W);
  for (int h = 0; h < H; h++)
  {
    cout << &mat[h + 1][1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    const int inf = 100000000;

    int n, m;
    cin >> n >> m;

    int a[1000], b[1000], c[1000], dist[100][100];

    for (int i = 0; i < m; ++i)
    {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i == j)
            {
                dist[i][j] = 0;
            }
            else
            {
                dist[i][j] = inf;
            }
        }
    }

    for (int i = 0; i < m; ++i)
    {
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    for (int k = 0; k < n; ++k)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = m;
    for (int i = 0; i < m; ++i)
    {
        bool shortest = false;
        for (int j = 0; j < n; ++j)
        {
            if (dist[j][a[i]] + c[i] == dist[j][b[i]])
            {

                shortest = true;
            }
        }
        if (shortest == true)
        {
            ans = ans - 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
fn solve(n: &str) -> i32 {
    let n = n.parse().unwrap();
    let mut vs = std::collections::BTreeSet::new();
    vs.insert(0);
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().parse::<i32>().unwrap();
        for v in vs.clone().iter() {
            vs.insert(v+s);
        }
    }
    vs.iter().fold(0, |m,&v|
        if v%10 == 0 {m}
        else {std::cmp::max(m,v)}
    )
}
fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right();
        if s=="" { break; }
        println!("{}",solve(&s));
    }
}

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

namespace IO
{
char gc()
{
#ifdef FREAD
	static char buf[1<<21], *P1 = buf, *P2 = buf;
	if(P1 == P2)
	{
		P1 = buf;
		P2 = buf + fread(buf, 1, 1<<21, stdin);
		if(P1 == P2) return EOF;
	}
	return *(P1++);
#else
	return getchar();
#endif
}
template<typename Tp> bool get1(Tp &x)
{
	bool neg = 0;
	char c = gc();
	while( c != EOF && (c < '0' || c > '9') && c != '-' ) c = gc();
	if(c == '-') c = gc(), neg = 1;
	if(c == EOF) return false;
	x = 0;
	for(; c>='0' && c<='9'; c = gc()) x = x*10 + c - '0';
	if(neg) x = -x;
	return true;
}
template<typename Tp> void printendl(Tp x)
{
	if(x<0)putchar('-'),x=-x;
	static short a[40], sz;
	sz = 0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
	puts("");
}
} // namespace IO
using IO::get1;
using IO::printendl;
#define get2(x,y) get1(x) && get1(y)
#define get3(x,y,z) get2(x,y) && get1(z)
#define get4(x,y,z,w) get3(x,y,z) && get1(w)
#define pb push_back
#define mp std::make_pair
#define ff first
#define ss second
typedef long long LL;
typedef unsigned long long uLL;
typedef std::pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const LL Linf = 1ll<<61;

const int maxn = 2000111;
const int N = 13;

int go[maxn][3], tot, power[N], val[maxn];
bool inv[maxn];
void inverse(int t)
{
	inv[t] ^= 1;
	std::swap(go[t][1], go[t][2]);
}
void push(int t)
{
	if(inv[t])
	{
		for(int i=0; i<3; i++) if(go[t][i]) inverse(go[t][i]);
		inv[t] = 0;
	}
}

int n, ans[maxn];
void dfs(int o, int d, int num)
{
	if(d == n)
	{
		val[o] = num;
		return;
	}
	for(int i=0; i<3; i++)
	{
		go[o][i] = ++tot;
		dfs(go[o][i], d+1, num + power[d] * i);
	}
}
void dfs2(int o, int d, int num)
{
	if(d == n)
	{
		ans[val[o]] = num;
		return;
	}
	push(o);
	for(int i=0; i<3; i++) dfs2(go[o][i], d+1, num + power[d] * i);
}

char s[maxn];
int main()
{
	power[0] = 1;
	for(int i=1; i<N; i++) power[i] = power[i-1] * 3;
	
	get1(n);
	int rt = ++tot;
	dfs(rt, 0, 0);
	
	scanf("%s", s);
	for(int i=0; s[i]; i++)
	{
		if(s[i] == 'S') inverse(rt);
		else
		{
			int cur = rt;
			while(cur)
			{
				push(cur);
				int tmp = go[cur][2];
				go[cur][2] = go[cur][1];
				go[cur][1] = go[cur][0];
				go[cur][0] = tmp;
				cur = tmp;
			}
		}
	}
	
	dfs2(rt, 0, 0);
	for(int i=0; i<power[n]; i++) printf("%d ", ans[i]);
	return 0;
}

Measured memory_bytes: 19516
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Console;

namespace CPLib
{
    class Atria
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            long[] As = ReadLine().Split(' ').Select(long.Parse).OrderByDescending(x => x).ToArray();
            long ans = As[0];
            int addindex = 1;
            int cnt = 0;
            for (int i = 1; i < n-1; i++)
            {
                cnt++;
                ans += As[addindex];
                if (cnt % 2 == 0) addindex++;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 51400
import heapq

n = int(input())

adj = [[] for _ in range(n)]

for _ in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] != 0:
        node = tmp[0]
        for i in range(2, 2 + tmp[1] * 2, 2):
            adj[node].append((tmp[i], tmp[i + 1]))

def dijkstra(s):
    visited = [0]*n
    d = [float("inf")]*n
    
    visited[s] = 1
    d[s] = 0
    queue = [(0, s)]
    heapq.heapify(queue)
    
    while queue:
        mincost, u = heapq.heappop(queue)
        visited[u] = 2

        if d[u] >= mincost:
            for idx, i in adj[u]:
                if visited[idx] != 2 and d[idx] > d[u] + i:
                    d[idx] = d[u] + i
                    heapq.heappush(queue, (d[idx], idx))
                    visited[idx] = 1
                    
    for i in range(n):
        print(i, -1 if d[i] == float("inf") else d[i])


dijkstra(0)





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

using namespace std;

int check(int num, int k, vector<int> &v){
    int i = 0;
    for (int j = 0; j < k; ++j) {
        int sum = 0;
        while (sum + v[i] <= num){
            sum += v[i];
            i++;
            if (i == v.size())return true;
        }
    }
    return false;
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> w;
    int sum = 0;
    for (int i = 0; i < n; ++i){
        int weight;
        cin >> weight;
        sum += weight;
        w.push_back(weight);
    }

    int left = 0,right = sum;
    while (left < right){
        int mid = (left + right) / 2;
        if (check(mid,k,w)){
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    cout << right << endl;

    return 0;
}

Measured memory_bytes: 3496
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] p = new int[n];
      int max = 0;
      int sum = 0;
      for(int i = 0;i < n;i++){
      	p[i] = sc.nextInt();
        sum += p[i];
        max = Math.max(max,p[i]);
      }
      System.out.println(sum-max/2);
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<stdio.h>
#include<cmath> 
#include<stack> 
#include<algorithm> 
#include <string.h>
using namespace std;
int main() {
	int l,r,d,s=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++){
		if(i%d==0) s++;
	} 
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3564
object Main {

  import scala.math._

  def main(args: Array[String]) {

    val sc = new java.util.Scanner(System.in)

    val n = sc.nextInt()
    val arr = List.fill(n)(sc.nextInt())

    var odd = arr.filter(_%2 == 1)
    var even = arr.filter(_%2 == 0)

    if (check(odd.length, even.length)) println("YES")
    else println("NO")

  }
  def check(odd_len: Int, even_len: Int): Boolean = {
    if (odd_len%2 == 0) true
    else if (even_len == 0) true
    else false
  }
}

Measured memory_bytes: 49408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int a,b,c;
    string s,t,u;
    cin>>s>>t;
    for (int i = 0; i < s.length(); ++i) {
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3628
#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>;

int main() {
  int n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  deque<ll> mt;//バスを待ってる人が乗れる最遅の便
  int cnt = 0;
  rep(i,n) cin >> t[i];
  sort(t.begin(),t.end());
  rep(i,n-1) {
    int people=0;//乗客
    mt.push_back(t[i]+k);
    while(mt.size()>0&&mt.front()<t[i+1]) {
      people++;
      mt.pop_front();
    }
    while(mt.size()>0&&people%c!=0) {
      people++;
      mt.pop_front();
    }
    cnt+=(people+c-1)/c;
  }
  cnt+=(mt.size()+c)/c;

  cout << cnt << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int x, y;
	cin >> x >> y;

	for (int i = 0; i <= 200; i++) {
		if (i > x) break;
		if (i * 2 + (x-i) * 4 == y) {
			cout << "Yes" << endl;
			return 0;
		} 
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
using namespace std;
typedef long long ll;
typedef vector<ll> VLL;
const int MOD=1000000007;

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

    string s(100000, '\0');
    cin >> s;
    FOR(i, 0, (int)s.size()){
        if (i % 2 == 0){
            cout << s[i];
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
using llong = long long;

llong n, k;
llong a[200005];
llong imos[200005];

bool check() {
    for (int i = 0; i < n; i++) {
        if (a[i] < n) return false;
    }
    return true;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int j = 0; j < k; j++) {
        if (check()) {
            break;
        }

        for (int i = 0; i < n; i++) imos[i] = 0;
        for (int i = 0; i < n; i++) {
            imos[max(0ll, i - a[i])]++;
            imos[min(n, i + a[i] + 1)]--;
        }

        a[0] = imos[0];
        for (int i = 1; i < n; i++) {
            imos[i] += imos[i - 1];
            a[i] = imos[i];
        }
    }

    for (int i = 0; i < n; i++) {
        cout << a[i] << ' ';
    }
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, W;
int v[111], w[111];
int dp[111][11111];

int main() {
   cin >> N >> W;
   rep (i, N) {
      cin >> v[i+1] >> w[i+1];
   }

   repp (i, 1, N+1) {
      for (int j = 0; j <= W; j++) {
         dp[i][j] = dp[i-1][j];
         if (j >= w[i]) {
            dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]]+v[i]);
         }
      }
   }

   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 7412
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ABC = []
for a in range(X):
    for b in range(Y):
        if (a+1) * (b+1) > K:
            break
        for c in range(Z):
            if (a+1) * (b+1) * (c+1) > K:
                break
            ABC.append(A[a] + B[b] + C[c])
ABC.sort(reverse=True)
print("\n".join(map(str, ABC[:K])))

Measured memory_bytes: 46192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1ll<<60;

int main(){
    int h, w;
    cin >> h >> w;
    vec<string> mp(h);
    rep(i, h) cin >> mp[i];

    ll mod = 1e9 + 7;

    vvec<ll> dp(h, vec<ll>(w, 0));
    dp[0][0] = 1;
    rep(i, h) rep(j, w) {
        if (i==0 && j==0) continue;
        if (mp[i][j]=='#') continue;
        int pi, pj;
        // right
        if (i>0) if(mp[i-1][j]=='.') dp[i][j] += dp[i-1][j];
        if (j>0) if(mp[i][j-1]=='.') dp[i][j] += dp[i][j-1];
        dp[i][j] %= mod;
    }
    cout << dp[h-1][w-1]%mod << endl;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    for(int i=0; i<Q; i++){
        scanf(" %d", &A[i]); A[i]--;
    }

    vector<int> count(N, 0);
    for(int i=0; i<Q; i++) count[A[i]]++;

    for(int i=0; i<N; i++){
        if(Q-count[i] >= K) cout << "No\n";
        else cout << "Yes\n";
    }
}

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

int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="0"){
      break;
    }
    int sum=0;
    for(int i=0;i<(int)str.size();i++){
      sum+=str[i]-'0';
    }
    cout<<sum<<endl;
  }
  return 0;
}



Measured memory_bytes: 3208
def main():
    import sys
    n, k, *a = map(int, sys.stdin.read().split())
    a = [0] + a
    check = [0] * (n + 1)
    check[1] = 1

    nw = 1
    path = [1]
    for i in range(1, n + 1):
        nx = a[nw]
        if i == k:
            print(nx)
            break
        if check[nx]:
            j = path.index(nx)
            d = j + (k - i) % (i - j)
            print(path[d])
            break
        path.append(nx)
        check[nx] = 1
        nw = nx


if __name__ == '__main__':
    main()


Measured memory_bytes: 32440
def sigma(x):
    a = 0
    for i in range(x):
        a += i + 1
    return a

s = input()
ans = 0
prev = ''
cnt = 0
p_cnt = 0
for i in s:
    if i == prev:
        cnt += 1
    else:
        if i =='<':
            ans += sigma(cnt - 1) + max(cnt, p_cnt)
        else:
            ans += sigma(cnt - 1)
        prev = i
        p_cnt = cnt
        cnt = 1
else:
    if prev == '<':
        ans += sigma(cnt)
    else:
        ans += sigma(cnt - 1) + max(cnt, p_cnt)
print(ans)

Measured memory_bytes: 4212
#include<stdio.h>
#include<string.h>
int main(){
	char a[15],b[15],c[15];
	int m,n;
	scanf("%s%s",a,b);
	scanf("%d%d",&n,&m);
	scanf("%s",c);
	if(strcmp(c,b)==0)
	m=m-1;
	if(strcmp(c,a)==0)
	n=n-1;
	printf("%d %d\n",n,m);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b,c;
    cin >> a >> b >> c;
    //処理
    //出力
    cout << a+b+c-max(max(a,b),c)<< ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define m 1000000007
long long int dp[110000];
int main()
{
	long long int n,k;
	cin>>n>>k;
	long long int a[n],i;
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<=n;i++)
	dp[i]=m;
	dp[0]=0;
	for(i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		if(i+j<n)dp[i+j]=min(dp[i+j],abs(a[i]-a[i+j])+dp[i]);
		
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

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

using namespace std;

char s[200007];

int main()
{
    int n, i, w=0;
    char t;
    cin >> s;
    n=strlen(s);
    for(i=0; i<n; i++){
        cin >> t;
        if(t!=s[i]){
            w++;
        }
    }
    cout << w << '\n';
    return 0;
}


Measured memory_bytes: 3820