akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=998244353;
int n,k,m,a[N],sum[N];
int dp[N][N][N];
//dp[i][j][h] 第i个坑，用了j个1，移动了k次的方案数
char s[N];
int main()
{
    scanf("%s%d",s+1,&k);
    for(int i=1;s[i];i++) m+=s[i]=='1';
    int t=0;
    for(int i=1;s[i];i++)
        if(s[i]=='0') a[++n]=t,t=0;
    else t++;
    a[++n]=t;
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    k=min(k,m);
    dp[0][0][0]=1;
    for(int i=0;i<n;i++)
        for(int j=sum[i];j<=sum[n];j++)
            for(int h=0;h<=k;h++)
        {
            for(int f=max(j,sum[i+1]);f<=sum[n];f++)
                if(f>=sum[i+1]&&h+f-j-a[i+1]<=k)
            {
                if(i+1==n&&f-j>a[i+1]) break;
                int cost=f-j<=a[i+1]?0:f-j-a[i+1];
                dp[i+1][f][h+cost]=(dp[i+1][f][h+cost]+dp[i][j][h])%mod;
            }
        }
    ll ans=0;
    for(int i=0;i<=k;i++) ans=(ans+dp[n][m][i])%mod;
    printf("%lld\n",ans);
}


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

int main() {
  int N;
  cin >> N;
  bool x = false;
  
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 15; j++){
      if( 4 * i + 7 * j == N ){
        x = true;
        break;
      }
    }
  }
 if (x == true){
   cout << "Yes" << endl;}
  else {
    cout << "No" << endl;}
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a, b);}
ll n, m, x;
vector<ll> c;
vector<vector<ll>> a;
ll ans = LONG_LONG_MAX;

void dfs(vector<bool> v) {
  if (v.size() == n) {
    //rep(i,n) {
    //  printf("%d%c", int(v[i]), (i == n-1)?'\n':' ');
    //}
    bool clear = true;
    vector<ll> tmp(m, 0);
    ll totalC = 0;
    rep(i, n) {
      if(!v[i]) continue;
      totalC += c[i];
      rep(j, m) {
        tmp[j] += a[i][j];
      }
    }
    rep(i, m) {
      if (tmp[i] < x) {
        clear = false;
        break;
      }
    }
    if (clear) ans = min(ans, totalC);
    return;
  }
  v.push_back(true);
  //  rep(i,v.size()) {
  //    printf("%d%c", int(v[i]), (i == n-1)?'\n':' ');
  //  }
  dfs(v);

  v.pop_back();

  v.push_back(false);
  //  rep(i,v.size()) {
  //    printf("%d%c", int(v[i]), (i == n-1)?'\n':' ');
  //  }
  dfs(v);
}

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

  cin >> n >> m >> x;
  c.resize(n);
  a.resize(n);
  rep(i, n) {
    cin >> c[i];
    a[i].resize(m);
    rep(j, m) cin >> a[i][j];
  }
  dfs(vector<bool>(1, true));
  dfs(vector<bool>(1, false));
  if (ans == LONG_LONG_MAX) ans = -1;
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int a, b, c;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a = atoi(ch);
	ch = strtok(NULL, " ");
	b = atoi(ch);
	ch = strtok(NULL, " ");
	c = atoi(ch);

	if(c >= a && c <= b) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2020
import math
from bisect import bisect_left


def eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


def solve():
    X = int(input())
    primes = eratosthenes(100010)
    index = bisect_left(primes, X)
    print(primes[index])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    int n;
    cin >> n;
    if (100 <= n && n<= 111){
        cout << 111 << endl;
    }
    for (int i = 1; i < 10; i++){
        if (100 * i + 10 * i + i < n  && n <= 100 * (i + 1) + 10 * (i + 1) + i + 1){
            cout << 100 * (i + 1) + 10 * (i + 1) + i + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
#壁あり迷路
H,W = map(int,readline().split())
H += 2; W += 2
maze = [["#"]*W]
for _ in range(H-2):
    maze += [list('#' +readline().rstrip().decode() + '#')]
maze += [["#"]*W]
#バグる場合はdecode("utf-8")にすること

for i in maze:
    print("".join(i))

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scanner=new Scanner(System.in);
        int N=scanner.nextInt();
        int M=scanner.nextInt();
        int X=scanner.nextInt();
        boolean booleans[]=new boolean[N+1];
        for(int i=0;i<=N;i++){
            booleans[i]=false;
        }
        for(int i=0;i<M;i++){
            booleans[scanner.nextInt()]=true;
        }
        int a=0;
        int b=0;
        for(int i=1;i<X;i++){
            if(booleans[i]) a++;
        }
        for(int i=X+1;i<N;i++){
            if(booleans[i]) b++;
        }
        System.out.println(Math.min(a,b));
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int N;
ll K, res;

int main()
{
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int d = 60; d >= -1; d--)
    {
        if (d != -1 && !(K & (1LL << d)))
            continue;
        ll tmp = 0;
        for (int e = 60; e >= 0; e--)
        {
            ll mask = 1LL << e;
            int num = 0;
            for (int i = 0; i < N; i++)
            {
                if (A[i] & mask)
                    num++;
            }
            if (e > d)
            {
                if (K & mask)
                    tmp += mask * (N - num);
                else
                    tmp += mask * num;
            }
            else if (e == d)
            {
                tmp += mask * num;
            }
            else
            {
                tmp += mask * max(num, N - num);
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long n,ans;
string tmp;
map<string,long long> m;
int main()
{
	cin>>n;
	while(n--)
	{
		cin>>tmp;
		sort(tmp.begin(),tmp.end());
		m[tmp]++;
	}
	for(map<string,long long>::iterator i=m.begin();i!=m.end();i++)
	{
		long long q=i->second;
		ans+=q*(q-1)/2;
	}
	cout<<ans;
}

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

int main() { 
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if(s < t) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if (a >= k) {
    cout << a - k << " " << b << endl;
    return;
  }
  cout << 0 << " " << max(b - (k - a), 0LL) << endl;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t,o;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> par;
typedef double dob;
int work(){
	int n,k;
	scanf("%d%d",&n,&k);
	while (n%k!=0){
		int nk=n/k,np=nk*k;
		int tp=(n-np)/(n/k+1);
		n-=tp*(n/k+1);
		if (n%k==0) break;
		while (n/k==nk) n-=n/k+1;
	}
	return n/k;
}
int main(){
	int tc,ans=0;
	scanf("%d",&tc);
	while (tc--) ans^=work();
	puts(ans?"Takahashi":"Aoki");
	return 0;
}


Measured memory_bytes: 128
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

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

        final List<String> list = new LinkedList<>();
        final char[] array = new char[n];
        recursive(0, array, list, 0);
        for (final String s : list) {
            System.out.println(s);
        }
    }

    private static void recursive(final int index, final char[] array, final List<String> list, final int max) {
        if (index == array.length) {
            list.add(new String(array));
            return;
        }

        for (int i = 0; i < index + 1 && i <= max + 1; i++) {
            array[index] = (char) ('a' + i);
            recursive(index + 1, array, list, Math.max(i, max));
        }
    }
}


Measured memory_bytes: 49144
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		ArrayList<String> list = new ArrayList<String>();

		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String in = scan.nextLine();
			list.add(in);
		}
		scan.close();

		for (String str : list) {
			String[] split = str.split(" ");
			long a = Long.valueOf(split[0]);
			long b = Long.valueOf(split[1]);

			String s = String.valueOf(a + b);

			System.out.println(s.length());
		}

	}
}



Measured memory_bytes: 26408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n+1,0);
  vector<vector<ll>> mul(n+1,vector<ll>(n+1,100000));
  for(int i = 1;i <= n;i++){
    mul[i][i] = 0;
  }
  rep(i,n){
    cin >> t1 >> t2;
    vec[i] = t1;
    vec[i+1] = t2;
  }
  for(int l = 2;l <= n;l++){
    for(int i = 1;i <= n-l+1;i++){
      int j = i + l - 1;
      mul[i][j] = (1 << 21);
      for(int k = i;k <= j-1;k++){
        chmin(mul[i][j],mul[i][k] + mul[k+1][j] + vec[i-1] * vec[k] * vec[j]);
      }
    }
  }
  cout << mul[1][n] << endl;
}


Measured memory_bytes: 3208
K = int(input())

S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(S[K-1])

Measured memory_bytes: 3060
N,T = map(int,input().split())
P = list(map(int,input().split()))

total = T
now = T

for i in range(1,N):
  if now > P[i]:
    total += T - (now - P[i])
  else:
    total += T
  now = P[i] + T
    
print(total)

Measured memory_bytes: 26836
#include<iostream>
#include<vector>
const int INF=1001001001;
using namespace std;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int c[n],a[n][m];
  for(int i=0;i<n;i++){
     cin>>c[i];
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int ans=INF;
  for(int bit;bit<(1<<n);bit++){
    int cost=0;
    vector<int> d(m);
    for(int j=0;j<n;j++){
      if(bit>>j&1){
        cost+=c[j];
        for(int k=0;k<m;k++) d[k]+=a[j][k];
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++) if(d[j]<x) ok=false;
    if(ok) ans=min(ans,cost);
  }
  if(ans==INF) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3644
N = int(input())
li = list(map(int,input().split()))
li.sort(reverse = True)
li2 = []
for i in range(N):
    soeji = i+1
    if i == N-1:
        soeji = i
    li2.append(li[i]/(2**soeji))
print(sum(li2))

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

int main() {
	// your code goes here
	int a,b,c,sum=0;
	cin>>a>>b>>c;
	sum=a*100;
	sum+=b*10;
	sum+=c;
	if(sum%4==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php

define('MOD', 1000000007);

function input() {
    return trim(fgets(STDIN));
}
function input_array() {
    return explode(' ', input());
}

$conbi = [
    1 => 2,
    2 => 3,
    3 => 5,
    4 => 8,
    5 => 13,
    6 => 21,
];

list($h, $w, $k) = array_map(function($numeric_string) {
    return (int)$numeric_string;
}, input_array());

$table = array_fill(0, $h + 1, array_fill(1, $w, null));

$table[0][1] = 1;
for ($i = 2; $i <= $w; $i++) {
    $table[0][$i] = 0;
}

for ($i = 1; $i <= $h; $i++) {
    for ($j = 1; $j <= $w; $j++) {
        if ($j === 1) {
            $table[$i][$j]  = ($w - $j - 2 > 0 ? $conbi[$w - $j - 2] : 1) * $table[$i - 1][$j + 1]
                            + ($w - $j - 1 > 0 ? $conbi[$w - $j - 1] : 1) * $table[$i - 1][$j];
        } else if ($j === $w) {
            $table[$i][$j]  = ($w - 2 > 0 ? $conbi[$w - 2] : 1) * $table[$i - 1][$j]
                            + ($w - 3 > 0 ? $conbi[$w - 3] : 1) * $table[$i - 1][$j - 1];
        } else {
            $table[$i][$j]  = ($j - 2 > 0 ? $conbi[$j - 2] : 1) * ($w - $j - 2 > 0 ? $conbi[$w - $j - 2] : 1) * $table[$i - 1][$j + 1]
                            + ($j - 2 > 0 ? $conbi[$j - 2] : 1) * ($w - $j - 1 > 0 ? $conbi[$w - $j - 1] : 1) * $table[$i - 1][$j]
                            + ($j - 3 > 0 ? $conbi[$j - 3] : 1) * ($w - $j - 1 > 0 ? $conbi[$w - $j - 1] : 1) * $table[$i - 1][$j - 1];
        }
        $table[$i][$j] %= MOD;
    }
}

echo $table[$h][$k] . "\n";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int x;
  cin>>x;
  FOR(a,1,1000){
    FOR(b,-1000,1000){
      if(pow(a,5)-pow(b,5)==x){
        cout<<a<<' '<<b<<endl;
        return 0;
      }
    }
  }

  // cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4100
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
s = input()
revs = s[::-1]
n = len(s)
s2 = s[:(n-1)//2]
revs2 = s2[::-1]
s3 = s[(n+3)//2-1:]
revs3 = s3[::-1]

# print(s == revs)
# print(s2 == revs2)
# print(s3 == revs3)
if s == revs and s2 == revs2 and s3 == revs3:
    ans = "Yes"
else:
    ans = "No"

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 3060
N,Y = map(int,input().split())
answer = 0 
s,t,u = -1,-1,-1

for i in range(N+1):
    for j in range(N+1-i):
        if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y:
            s = i
            t = j
            u = N-i-j

print(s,t,u)

Measured memory_bytes: 3060
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String ans = (a/k * k + k <= b || a%k == 0) ? "OK" : "NG";
    System.out.println(ans);
  }
}

Measured memory_bytes: 35740
import * as fs from 'fs';

// main
function main(input: string[]) {
    // param
    var n: number = 0;
    var m: number = 0;
    var ans: number = 0;
    // init
    [n, m] = input.shift().split(" ").map(x => Number(x));
    // solve
    ans = n * (n - 1) / 2 + m * (m - 1) / 2
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        var input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29444
#include <iostream>
using namespace std;
const int MAX=100;
int main(){
    int w,h,n;
    
    int x[MAX],y[MAX],a[MAX];
    cin>>w>>h>>n;
    int max_x=w,max_y=h;
    int min_x=0,min_y=0;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]==2){
            if(max_x>x[i]){
                max_x=x[i];
            }
        }else if(a[i]==1){
            if(min_x<x[i]){
                min_x=x[i];
            }
        }else if(a[i]==4){
            if(max_y>y[i]){
                max_y=y[i];
            }
        }else{
            if(min_y<y[i]){
                min_y=y[i];
            }
        }
    }
    
    int len_x=max_x-min_x;
    int len_y=max_y-min_y;
    if(len_x>0&len_y>0){
        cout<<len_x*len_y;
    }else{
        cout<<0;
    }
    return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();
   unordered_set<int> a[3];

    a[0]= {1, 3, 5, 7, 8, 10, 12};
    a[1]= {4, 6, 9, 11};
    a[2]= {2};

    int x, y, i;
    cin>> x>> y;

    for( i=0; i<3; i++)
    {
        if(a[i].find(x)!=a[i].end() && a[i].find(y)!=a[i].end())
        {
            cout<<"Yes\n";
            break;
        }
    }

    if(i==3)
        cout<<"No\n";



    return 0;
}




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

int main() {
	ios::sync_with_stdio(false);

	int n, x, y;
	cin >> n >> x >> y;
	int head = x - 1;
	int tail = n - y;
	int slen = head + 1 + tail;
	int llen = y - x + 1;

	cout << n << "\n";
	for (int k = 2; k < n; k++) {
	        int res = max(0, slen + 1 - k);
		if (llen > 2 * k)
			res += llen;
		else if (llen == 2 * k)
			res += k;
		int lp = min(llen - 1, (k - 1) * 2);
		res += max(0, lp - max(1, 2 * (k - tail - 1)));
		res += max(0, lp - max(1, 2 * (k - head - 1)));
		cout << res << "\n";
	}
	cout.flush();
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
    }
    if(N & 1)A.push_back(0);
    sort(all(A));
    int x = (N & 1) ? 0 : 1;
    for(int i = 0; i < N + (N&1); i+=2) {
        if(A[i] != x || A[i + 1] != x) {
            cout << 0 << endl;
            return 0;
        }
        x += 2;
    }
    ll ans = 1;
    rep(i, N / 2)ans = ans * 2 % 1000000007;
    cout << ans << endl;
}

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

using namespace std;

int main() {

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; ++i) cin >> a[i] >> b[i];

    // 定期便を２つ使っていきたい
    vector<vector<int>> g(n, vector<int>());
    for (int i = 0; i < m; ++i) {
        g[a[i] - 1].push_back(b[i] - 1);
        g[b[i] - 1].push_back(a[i] - 1);
    }

    bool can = false;
    vector<bool> one_step(n, false);
    for (int i = 0; i < g[0].size(); ++i) {
        one_step[g[0][i]] = true;
    }

    for (int i = 0; i < g[n - 1].size(); ++i) {
        if (one_step[g[n - 1][i]]) {
            can = true;
            break;
        }
    }

    if (can) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 13552
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
const int maxn=100005;
ll a,b,c,k,ans;
int main()
{
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>a>>b>>c>>k;
    while(1)
    {
        if(b>a)
            break;
        b*=2;
        ans++;
    }
    while(1)
    {
        if(c>b)
            break;
        c*=2;
        ans++;
    }
    if(ans>k)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}
/*

*/


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == 5 && b == 5 && c == 7){
    cout << "YES" << endl;
  }
  
  else if(a == 5 && b == 7 && c == 5){
    cout << "YES" << endl;
  }
  
  else if(a == 7 && b == 5 && c == 5){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
}


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

struct leef {
  int parent=0;
  ll num=0;
  ll cnt=0;
};

vector<vector<ll>> tree(200010, vector<ll>());
vector<leef> leefs(200010);

void dfs(int parent, int n)
{
  leefs[n].parent = parent;
  leefs[n].cnt = leefs[parent].cnt + leefs[n].num;
  for (auto v:tree[n]) {
    dfs(n, v);
  }
}

int main()
{
  ll N;
  scanf("%lld",&N);
  ll Q;
  scanf("%lld",&Q);
  for(int i=0; i<N-1; i++){
    ll a,b;
    scanf("%lld",&a);
    scanf("%lld",&b);
    tree[a].push_back(b);
  }
  for (int i=0; i<Q; i++){
    ll p,x;
    scanf("%lld",&p);
    scanf("%lld",&x);
    leefs[p].num += x;
  }
  dfs(0, 1);
  for (int i=1; i<=N; i++) {
    if (i==1) cout << leefs[i].cnt;
    else cout << " " << leefs[i].cnt;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 24320
S = input()
if S == "MON":
  print(6)
elif S == "TUE":
  print(5)
elif S == "WED":
  print(4)
elif S == "THU":
  print(3)
elif S == "FRI":
  print(2)
elif S == "SAT":
  print(1)
else:
  print(7)


Measured memory_bytes: 8972
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;
typedef long long ll;
inline ll min(ll x,ll y) {return x<y?x:y;}
inline ll max(ll x,ll y) {return x>y?x:y;}
const int Maxn=1e5+5;
int n,a[Maxn];
ll ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=n/2+1;i<=n;i++)
		ans+=2*a[i];
	for(int i=1;i<=n/2;i++)
		ans-=2*a[i];
	if(n&1)
	{
		ans-=2*a[n/2+1];
		ans+=max(a[n/2]-a[n/2+1],a[n/2+1]-a[n/2+2]);
	}	
	else	
		ans+=a[n/2]-a[n/2+1];
	cout<<ans<<endl;
 	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int n, m;
int a[100], b[100];
int s, t, u;
int x, y;
int main()
{
	while(cin >> n >> m && n!=0)
	{
		s=0;
		t=0;
		for(int i=0; i<n; i++)
		{
			cin >> a[i];
			s+=a[i];
		}
		for(int j=0; j<m; j++)
		{
			cin >> b[j];
			t+=b[j];
		}
		u=0;
		for(int i=0; i<n; i++)
		{
			for(int j=0; j<m; j++)
			{
				if((a[i]-b[j])*2==s-t)
				{
					u+=1;
					if(u==1)
					{
						x=a[i];
						y=b[j];
					}
					else if(a[i]+b[j]<x+y)
					{
						x=a[i];
						y=b[j];
					}
				}
			}
			
		}
		if(u==0)
			{
				cout << -1 << endl;
			}
			else
			{
				cout << x << " " << y << endl;
			}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());

  // for_each(a.begin(), a.end(), [](int x) { cout << x << " "; });
  for (int i = 0; i < a.size(); i++) {
    if (i != 0) {
      cout << " ";
    }
    cout << a[i];
  };
  cout << endl;
  return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=210;
char s[N][N];
int w[N],v[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-o:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
	scanf("%s",s[i]+1);
	for(int j=1;j<=n;j++) s[i][j]-='0';
    }
    for(int i=1;i<=n;i++) {
	int t=0,sum=1;
	memset(w,0,sizeof(w)),w[v[1]=i]=1;
	while(t<sum) {
	    int x=v[++t];
	    for(int y=1;y<=n;y++)
		if(s[x][y]) {
		    if(w[y]) {
			if(~(w[x]^w[y])&1) return cout<<-1,0;
		    }
		    else w[y]=w[x]+1,v[++sum]=y;
		}
	}
	ans=max(ans,w[v[sum]]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
int i,j,m,n,ans=0,l;
static int r[2001][2001][2]={0};
char s[4001],t[4001];
scanf("%d%d",&m,&n);
scanf("%s",s);
scanf("%s",t);
for(i=0;i<=m;i++){
for(j=0;j<=n;j++){
for(l=0;l<2;l++){
if(l==0){
if(s[i]=='I')
r[i+1][j][1]=max(r[i+1][j][1],r[i][j][0]+1);
if(t[j]=='I')
r[i][j+1][1]=max(r[i][j+1][1],r[i][j][0]+1);
}
else{
if(s[i]=='O'&&r[i][j][1]!=0)
r[i+1][j][0]=max(r[i+1][j][0],r[i][j][1]+1);
if(t[j]=='O'&&r[i][j][1]!=0)
r[i][j+1][0]=max(r[i][j+1][0],r[i][j][1]+1);
}
}
}
}
for(i=0;i<=m;i++){
for(j=0;j<=n;j++){
ans=max(ans,r[i][j][1]);
}
}
printf("%d\n",ans);
return 0;
}



Measured memory_bytes: 34492
#include <iostream>

using namespace std;
int main() {
	int n;
	cin >> n;
	int ans = 0;

	for(int i = 1; i <= n; i += 2) {
		int s = 0;
		for(int j = 1; j <= i; j += 2) {
			if(i % j == 0) {
				s++;
			}
		}
		if(s == 8) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;
 
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
 
int main(){
    ll k,x,y; cin>>k>>x>>y;
    ll xm=1,ym=1,xym=0;
    if(x<0){
        xm=-1; x=-x;
    }
    if(y<0){
        ym=-1; y=-y;
    }
    if(y<x){
        swap(x,y); xym=1;
    }
    ll dis=x+y,ans,xcur=0,ycur=0;
    vector<pair<ll,ll>> path;
    if(k%2){
        if(dis<k && dis%2){
            ans=3;
            path.assign(ans,mk(0,k));
            path[0]=mk(k-(dis+k)/2,(dis+k)/2);
            path[1]=mk(-k+(dis+k)/2,(dis+k)/2);
            path[2]=mk(0,-k);
        }
        else if(dis<k){
            ans=2;
            path.assign(ans,mk(0,k));
            path[0]=mk((ans*k-dis)/2,k-(ans*k-dis)/2);
            path[1]=mk(-(ans*k-dis)/2,k-(ans*k-dis)/2);
        }
        else{
            ans=(dis+k-1)/k;
            if(dis%2!=ans%2) ans++;
            path.assign(ans,mk(0,k));
            if(ans>1){
                path[0]=mk((ans*k-dis)/2,k-(ans*k-dis)/2);
                path[1]=mk(-(ans*k-dis)/2,k-(ans*k-dis)/2);
            }
        }
    }
    else{
        if(dis%2){
            cout<<-1<<endl;
            return 0;
        }
        if(dis<k){
            ans=2;
            path.assign(ans,mk(0,k));
            path[0]=mk((ans*k-dis)/2,k-(ans*k-dis)/2);
            path[1]=mk(-(ans*k-dis)/2,k-(ans*k-dis)/2);
        }
        else{
            ans=(dis+k-1)/k;
            path.assign(ans,mk(0,k));
            if(ans>1){
                path[0]=mk((ans*k-dis)/2,k-(ans*k-dis)/2);
                path[1]=mk(-(ans*k-dis)/2,k-(ans*k-dis)/2);
            }
        }
    }
    cout<<ans<<endl;
    ll cnt=x;
    //rep(i,ans) cout<<path[i].first<<" "<<path[i].second<<endl;
    rep(i,ans){
        if(path[i].first>=0 && path[i].second>=0){
            ll d=min(cnt,path[i].second);
            path[i].first+=d;
            path[i].second-=d;
            cnt-=d;
        }
        xcur+=path[i].first;
        ycur+=path[i].second;
        if(xym) cout<<xm*ycur<<" "<<ym*xcur<<endl;
        else cout<<xm*xcur<<" "<<ym*ycur<<endl;
    }
}

Measured memory_bytes: 6428
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int startSpot = sc.nextInt();
		int spot[] = new int[num];
		for(int i = 0; i < num; i ++) {
			spot[i] = sc.nextInt();
		}
		int diff[] = new int[num];
		for(int i = 0; i < num; i ++) {
			diff[i] = Math.abs(spot[i] - startSpot);
		}
		Arrays.sort(diff);

		int moveDist = diff[0];
		for(int i = 1; i < num; i ++) {
			moveDist = gcd(moveDist, diff[i]);
		}
		System.out.println(moveDist);
	}

	public static int gcd(int a, int b) {
		if(b == 0) {
			return a;
		}else {
			return gcd(b, a % b);
		}
	}
}

Measured memory_bytes: 50228
#include<stdio.h>

#define N 2000

int main(){

  int i,j;
  int n,a;
  int q,m;
  int ans[N+1]={0};

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    for(j = N-a; j>0; j--){
      if(ans[j]){
	ans[j+a] = 1;
      }
    }
    ans[a] = 1;
  }  
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(ans[m]) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

Measured memory_bytes: 588
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b){if (b == 0) return a;return gcd(b, a % b);}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

int vector_finder(vector<string> vec, string number) {
    auto itr = find(vec.begin(), vec.end(), number);
    size_t index = distance( vec.begin(), itr );
    if (index != vec.size()) {
        return 1;
    }
    else {
        return 0;
    }
}

int main(){
    int N;
    cin >> N;
    vector<string> words;
    string ans = "Yes";
    for (int i = 0; i < N; ++i) {
        string s, last_word;

        if(i != 0) last_word = words.back();
        cin >> s;

        if (vector_finder(words, s)) {
            ans = "No";
        }
        words.push_back(s);
        if (i == 0) continue;
        char first = s[0];
        char last = last_word[last_word.size() - 1];
        if(first != last) {
            ans =  "No";
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3624
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int solve(int A) {
    int ret = 0;
    for(; A>0; A/=10) {
        ret += (A % 10);
    }
    return ret;
}

signed main() {
    int N; cin >> N;
    
    int ans = INF;
    for(int i=1; i<N; i++) {
        int sum = 0, A = i, B = N - i;
        sum += solve(A);
        sum += solve(B);
        chmin(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<cmath>
#define LL long long
using namespace std;
inline void read(int &x){
	x=0;int f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();	}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	x*=f;
}
char s[200100]; 
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	int ans=0,las=0;
	for(int i=1;i<=len;i++)
	{
		if(las==0||las==2)
		{
			ans++;
			las=1;
		}
		else
		{
			if(s[i]==s[i-1]&&i!=len)
			{
				i++;
				ans++;
				las=2;
			}
			else if(s[i]!=s[i-1]) ans++; 
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

int n;
map<int, int> mp;

void prime_decomposition(int N) {
  int i = 2;

  while (i * i <= N) {
    if (N % i == 0) {
      N /= i;
      mp[i]++;
    } else {
      i++;
    }
  }
  mp[N]++;

  return;
}

void solve() {
  int i;
  ll ans = 1;

  for (i = 2; i <= n; i++) {
    prime_decomposition(i);
  }

  for (auto p : mp) {
    ans = ans * (p.second + 1) % MOD;
  }

  cout << ans << "\n";

  return;
}

int main() {
  int i;

  cin >> n;

  solve();

  return 0;
}


Measured memory_bytes: 256
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

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

typedef long long lint;


int main() {

    lint N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<lint> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A), greater<lint>());
    int ok = -1, ng = N;
    while(ng - ok > 1) {
        // now が上位 P 位に入ることはできるか？
        int now = (ok + ng) / 2;
        ([&]{
            if(now < P) return true;
            if(A[now] + M < A[P - 1]) return false;
            lint sum = 0;
            for(int i = 0; i < P - 1; ++i) sum += M;
            for(int i = P - 1; i < now; ++i) sum += A[now] + M - A[i];
            for(int i = now; i < N; ++i) sum += M;
            return sum >= M * V;
        }() ? ok : ng) = now;
    }

    cout << ok + 1 << '\n';
    return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define d double
const int sz=301;
d dp[301][301][301];
d solve(int one,int two,int three, int n){
    if(one==0 and two==0 and three==0)
        return 0;
    if(one<0 or two<0 or three<0)
        return 0.0;
    if(dp[one][two][three]>-0.9)
        return dp[one][two][three];
    d ans=n+one*solve(one-1,two,three,n)+two*solve(one+1,two-1,three,n)+three*solve(one,two+1,three-1,n);
    return dp[one][two][three]=(ans/(one+two+three));
}   

int main() {
	for(int i=0;i<301;i++){
        for(int j=0;j<301;++j){
            for(int k=0;k<301;++k){
                dp[i][j][k]=-1;
            }
        }
    }
    int n=0;cin>>n;
    int one=0,two=0,three=0;
    int temp=0;
    for(int i=1;i<=n;++i){
        cin>>temp;
        if(temp==1)
            one++;
        if(temp==2)
            two++;
        if(temp==3)
            three++;
    }
    cout<<fixed<<setprecision(10)<<solve(one,two,three,n)<<endl;
    return 0;
}


Measured memory_bytes: 213376
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a[10009],n;
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    int ans=0;
    for(int i=0;i<n;i++)
    while(a[i]%2==0&&a[i]) ans++,a[i]>>=1;
    cout <<ans << endl;
}


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


using ll = long long int;

using namespace std;


const int MAX_V = 100000;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int i, j, n, k;
    
    vector<int> p(MAX_V + 1);
    
    for(i = 0; i < 2; ++i)
    {
        cin >> n;
        for(j = 2; j * j <= n; ++j)
        {
            k = 0;
            while(n % j == 0)
            {
                ++k;
                n /= j;
            }
            if (k)
            {
                p[j] = max(p[j], k);
            }
        }
        if (n > 1)
        {
             p[n] = max(p[n], 1);
        }
    }
    
    ll ans = 1;
    
    for(i = 1; i <= MAX_V; ++i)
    {
        while(p[i]--)
        {
            ans *= i;
        }
    }
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair

using namespace std;

int main(){

    int n,k;

    cin >> n >> k;

    vector<int> v(200000,0);
    int kind = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        if(v[tmp - 1] == 0) kind++;
        v[tmp - 1]++;
    }

    sorta(v);
    int ans = 0;

    cerr << "kind :" << kind << endl;

    if(k < kind){

        int erasekind = kind - k;

        int index = 0;

        while(v[index] == 0){
            index++;
        }

        cerr << "index:" << index << endl;

        for(int i = index; i < index + erasekind; i++){
            ans = ans + v[i];
        }

    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
mx = [i for i in [input().split() for _ in range(n)]]
for i in range(n):
    mx[i] = [int(h) for h in mx[i]]
current_point = [0, 0, 0]
distance = [0, 0, 0]
canArriveAt = True
for p in mx:
    next_point = p
    for i in range(3):
        distance[i] = next_point[i] - current_point[i]
    if distance[0]%2 == (abs(distance[1])+abs(distance[2]))%2 and distance[0] >= abs(distance[1])+abs(distance[2]):
        current_point = next_point
    else:
        canArriveAt = False
print("Yes" if canArriveAt == True else "No")

Measured memory_bytes: 33128
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int black[200005];
int white[200005];

int main(){
    int N; cin >> N;
    string S; cin >> S;
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') black[i] = 1;
        if (i) black[i] += black[i-1];
    }
    for (int i = N-1; i >= 0; i--) {
        if (S[i] == '.') white[i] = 1;
        if (i != N-1) white[i] += white[i+1];
    }
    int ans = 200005;
    for (int i = 0; i <= N; i++) {
        int cnt;
        if (i == 0) cnt = white[i];
        else if (i == N) cnt = black[i-1];
        else cnt = white[i] + black[i-1];
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}




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

typedef long long ll;

const ll mod = 1000000007;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main() {
    int n,k;
    cin >> n >> k;
    vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
    dp[0][0] = 1;
    for (int i = 0;i < n;++i) {
        int a;
        cin >> a;
        vector<ll> sum(k+2,0);
        for (int j = 0;j <= k;++j) sum[j+1] = (sum[j]+dp[i][j])%mod;
        for (int j = 0;j <= k;++j) {
            dp[i+1][j] = sum[j+1]-sum[max(0,j-a)];
            dp[i+1][j] %= mod;
        }
    }
    cout << (dp[n][k]+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
  int a = 0;
  cin >> a;
  vector<int> b(a);
  for(int i = 0;i <= a - 1;i++){
    cin >> b[i];
  }
  sort(b.begin(),b.end());
  int c = 0;
  for(int i = 0;i <= a - 2;i++){
    if(b[i] == b[i + 1]){
      c = 1;
      break;
    }
  }
  if(c == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n, ball;
	int a, b, c;
	int i, j;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		
		c = 0;
		a = b = -1;
		
		for (j = 0; j < 10; j++){
			scanf("%d", &ball);
			
			if (a >= ball && ball <= b){
				for (; j < 9; j++){
					scanf("%d", &ball);
				}
				c = 1;
				break;
			}
			
			if (a < ball && b >= ball){
				a = ball;
			}
			else if (b < ball && a >= ball){
				b = ball;
			}
			else {
				if (a < b){
					b = ball;
				}
				else {
					b = ball;
				}
			}
			
		}
		if (c == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 580
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin >> N;
  string S; cin>>S;

  string ans = "";
  REP(i,S.size()) {
    if (S[i] + N > 'Z') ans += 'A' + (S[i] + N - 'Z' - 1);
    else ans += S[i] + N;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>a(N);
	rep(i, 0, N)cin >> a[i];
	int ans = INF;
	rep(i, -100, 101) {
		int cnt = 0;
		rep(j, 0, N) {
			int x = a[j] - i;
			cnt += x * x;
		}
		chmin(ans, cnt);
	}
	cout << ans << "\n";



	return 0;
}


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

using ll = long long;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int h, w, m;
    cin >> h >> w >> m;
    map<int, int> row, col;
    set<pair<int, int>> cell;
    while(m--) {
        int i, j;
        cin >> i >> j;
        row[i]++;
        col[j]++;
        cell.insert({i, j});
    }
    int r_val = 0, c_val = 0;
    for(auto &[key, val] : row) {
        r_val = max(r_val, val);
    }
    for(auto &[key, val] : col) {
        c_val = max(c_val, val);
    }
    
    vector<int> r, c;
    for(auto &[key, val] : row) {
        if(val == r_val) r.push_back(key);
    }
    for(auto &[key, val] : col) {
        if(val == c_val) c.push_back(key);
    }
    int res = r_val + c_val - 1, flag = 0;
    for(int i=0; i<r.size() && flag == 0; i++) {
        for(int j=0; j<c.size() && flag == 0; j++) {
            if(cell.count({r[i], c[j]}) == 0) {
                flag = 1;
            }
        }
    }
    
    if(flag == 1) res++;
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 49520