akhauriyash/Code-Regression huggingface dataset:
n = int(input())
lis = list(map(int, input().split()))

key = lis[0]
num = [0]
li = [key]
for i in range(1,n):
	if lis[i] > key:
		key = lis[i]
		num.append(i)
		li.append(key)

m = len(li)
nu = [li[0]]+[li[i+1]-li[i] for i in range(m-1)]

he = [0]*m
cou = [0]*m

from bisect import bisect_left

for k in lis:
	sen = bisect_left(li,k)
	cou[sen] += k -li[sen]
	he[sen] += 1

key = 0
for i in reversed(range(m)):
	key += he[i]
	he[i] = key

for i in range(m):
	cou[i] += he[i]*nu[i]

ans = [0]*n
for i,c in zip(num,cou):
	ans[i] = c

for r in ans:
	print(r)

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S)
{
    if (S[2] == S[3] && S[4] == S[5])
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff(i, c, n) for (ll i = c; i < n; i++)
#define fr(i, c, n) for (ll i = c; i >= n; --i)
#define INF 1e9 + 7

int main(){
    ll n;
    cin>>n;
    double dp[n+1][n+1]={0};
    dp[0][0]=1;
    ff(i,1,n+1){
        double p;
        cin>>p;
        ff(j,0,i+1){
            if(j==0) dp[i][j]=dp[i-1][j]*(1-p);
            else dp[i][j]=dp[i-1][j-1]*p+dp[i-1][j]*(1-p);
            
        }
        cout<<"\n";
    }
    double pt=0;
    ff(i,n/2+1,n+1){
        pt+=dp[n][i];
        
    }
    cout<<setprecision(10)<<pt;
    
}

Measured memory_bytes: 70528
# xdatas, ydatas = [], []

# while True:
#     x, y = map(int, input().split())

#     if x == 0 and y == 0:
#         break
#     else:
#         xdatas.append(x)
#         ydatas.append(y)

# for l in range(len(xdatas)):
#     if xdatas[l] > ydatas[l]:
#         tmp = xdatas[l]
#         ydatas[l] = xdatas[l]
#         xdatas[l] = tmp

# for l in range(len(xdatas)):
#     print("{0} {1}".format(xdatas[l], ydatas[l]))

while True:
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        break
    else:
        if x > y:
            x, y = y, x
    print("{0} {1}".format(x, y))



Measured memory_bytes: 5616
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n, m;
std::vector<int> edge[10];
bool used[10];
int cnt;

void check(int a, int depth){
	if(depth == n){
		cnt++;
		return;
	}
	used[a] = true;
	for(int i = 0; i < edge[a].size(); i++){
		int b = edge[a][i];
		if(!used[b]){
			check(b, depth+1);
		}
	}
	used[a] = false;
	return;
}

signed main(){
	scanf("%ld %ld", &n, &m);
	for(int i = 0; i < m; i++){
		int a, b;
		scanf("%ld %ld", &a, &b);
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	check(1, 1);
	printf("%ld\n", cnt);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{ 
 
 
    static long mod=1000000007;
    static int dx[]={1,-1,0,0};
    static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
    // ArrayList<Integer> lis = new ArrayList<Integer>();
    // ArrayList<Integer> map[]=new ArrayList[26];
    // static HashMap<Integer,Long> map = new HashMap<Integer,Long>();

    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // long n=sc.nextLong();
        // char c[][] = new char[h][w];
        // long a[] = new long [n];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {a[i]=sc.nextInt();}
        
        String s = sc.nextString() , sb;
        int n = sc.nextInt(), l=s.length();
        String z[] = {"{","{","{","{","{","{"};
        for(int i=0; i<l; i++) {
         lp:for(int t=i; t<min(l,i+6); t++) {
            sb =s.substring(i,t+1);
              for(int w=0; w<5; w++)if(z[w].equals(sb)){
                continue lp;}
                z[5] = sb;
                sort(z);
            }
        }
        sort(z);

        out.println(z[n-1]);
        out.flush();
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}
 
class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return -x + p.x;//des
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 23764
N = gets.to_i
s = N.times.map{gets.chomp}
M = gets.to_i
t = M.times.map{gets.chomp}

plus_point = s.inject(Hash.new(0)){|hash, key| hash[key] += 1; hash}
all_point = t.inject(plus_point){|hash, key| hash[key] -= 1; hash}

puts all_point.inject(0){|x, (_, val)| x = [x, val].max if val > 0; x}

Measured memory_bytes: 3836
n=int(input())
a=list(map(int,input().split()))
if a[-1]!=2:exit(print(-1))
l=r=2
for i in a[::-1]:
  if (l-1)//i==r//i:exit(print(-1))
  l=(0--l//i)*i
  r=(r//i)*i+i-1
print(l,r)

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

int main() {
    long long x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    if (x/d >= k) cout << x-k*d << endl;
    else { 
        if ((k-x/d)%2 == 0) cout << x%d << endl;
        else cout << d-x%d << endl;
    }
}


Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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




int main(){
    int N; std::cin >> N;
    long long prv(0);
    std::map<long long, long long> mp;
    mp[0] = 1;
    {
        int A;
        for(int i(0); i < N; ++i){
            std::cin >> A;
            prv += A;
            ++mp[prv];
        }
    }
    long long ans(0);
    {
        long long num;
        for(auto itr(mp.begin()); itr != mp.end(); ++itr){
            num = itr->second;
            ans += num*(num-1) / 2;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 12800
#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); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	string S;
	cin >> S;
	int N = S.length();
	const string K = "keyence";
	bool JD = false;
	
	if(S.find(K) != string::npos){
		JD = true;
	} else {
		JD = false;
		for(int i = 1; i < 7; i++){
			string L = S.substr(0, 7 - i);
			string R = S.substr(N - i, i);
			if(L + R == K){
				JD = true;
				break;
			}
		}
	}
	cout << ((JD) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
from bisect import bisect_right

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
asum = [0]*n
asum[0] = a[0]
b = list(map(int, input().split()))
bsum = [0]*m
bsum[0]=b[0]
for i in range(1, n):
  asum[i]=asum[i-1]+a[i]
for i in range(1, m):
  bsum[i]=bsum[i-1]+b[i]

ans = 0
for i in range(n):
  if asum[i] <= k:
    temp = i+1
    nokori = k-asum[i]
    #print("i " + str(i) + " nokori " + str(nokori))
    temp += bisect_right(bsum, nokori)
    ans = max(ans, temp)

ans = max(ans, bisect_right(bsum, k))
print(ans)

Measured memory_bytes: 47336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

int main() {
    ll n;
    cin >> n;
    string ans = "";
    ll base = 1;
    while(n != 0){
        if(n%(base*2) != 0){
            n -= base;
            ans += "1";
        } 
        else ans += "0";
        base *= -2;
    }
    if(ans == "") ans = "0";
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

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

int main(){
    ll h,w;
    cin>>h>>w;
    ll ans;
    if(h==1 or w==1){
        ans = 1;
    }else{
        ans=h*w;
        ans = (ans+1) / 2;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define read_in_arr(a, n) for(int i=0;i<n;i++){ cin>>a[i];}
#define print_arr(a, n) for(int i=0;i<n;i++){ cout<<a[i];}
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
		if(a[i]==0){
			cout<<i+1<<endl;
			break;
		}
	}
	return 0;
}

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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	if (n % 2) {
		cout << "No\n";
		return 0;
	}
	else {
		int h = n / 2;
		for (int i = 0; i < h; i++) {
			if (s[i] != s[h + i]) {
				cout << "No\n";
				return 0;
			}
		}
		cout << "Yes\n";
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  vector<int> Box(N);
  for (int i=0; i<N; i++){
    Box[i] = 0;
  }
  int cnt = 0;
  for (int i=N-1; i>=0; i--){
    int j=i;
    int sum = 0;
    while(j < N){
      sum += Box[j];
      j += i+1;
    }
    if ((A[i] % 2) != (sum % 2)){
      Box[i] = 1;
      cnt++;
    }
  }
  printf("%d\n",cnt);
  for (int i=0; i<N; i++){
    if (Box[i] == 1){
      printf("%d ", i+1);
    }
  }
  return 0;
}


Measured memory_bytes: 2432
N = int(input())

A = list(map(int, input().split()))

A.sort()
A.reverse()

ans = 0

if len(A) == 2:
  print(A[0])
  exit()
count = 0
for i in range(len(A)):
  if i == 0:
    ans += A[i]
    count += 1
  else:
    ans += A[i]
    count += 1
    if count == len(A)-1:
      break
    count += 1
    ans += A[i]
    if count == len(A)-1:
      break

print(ans)

Measured memory_bytes: 31680
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	int sum,ave,num;
	int c,t;
	double h;

	sum=0;
	h=0;
	num=0;
	while(scanf("%d,%d",&c,&t)!=EOF){
		sum+=c*t;
		h+=t;
		num++;
	}
	h=(double)h/(double)num+0.5;
	ave=h;
	printf("%d\n%d\n",sum,ave);
	return 0;
}

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


int main() {
  int N;
  cin >> N;
  vector<int> dp(1);
  dp.at(0) = 2;
  int cnt = 1, i = 3;
  while (cnt < N) {
    bool flg = true;
    for (int j = 3; j <= sqrt(i); ++j) {
      if (i % j == 0) {
        flg = false;
        break;
      }
    }
    if (flg && i % 5 == 1) {
      dp.push_back(i);
      ++cnt;
    }
    i += 2;
  }
  for (int i = 0; i < N; ++i) {
    cout << dp.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <climits>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define M 1000000007
int main() {
    string s;
    cin>>s;
    int k=s.size()-1;
    if(s[k]=='s')
    {
        s.append("es");
    }
    else {
        s.append("s");
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

long long n;

int main() {
	cin >> n;
	double N;
	while (true)
	{
		N = -1 + sqrt(1 + 8 * n);
		cout << ceil(N / 2) << endl;
		n -= ceil(N / 2);
		if (n== 0)
			break;
	}

	//cin >> n;
	return 0;
}

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

int main(){
  string s; cin >> s;
  long long sum = 0;
  int n = s.size();
  for(int i = 0; i < (1<<n-1); i++){
  	vector<int> a = {0};
  	for(int j = 0; j < n-1; j++){
    	if(i & (1<<j)) a.push_back(j+1);
    }
  	a.push_back(n);
    for(int j = 0; j < a.size()-1; j++){
    	sum += stoll(s.substr(a[j], a[j+1]-a[j]));
    }
  }
  cout << sum << endl;
}

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

using namespace std;

int main(){
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	int water=0, sugar=0;
	int ans_w=min(A,B), ans_s=0;
	for(int a=0; 100*a*A<=F; a++){
		for(int b=0; 100*b*B<=F; b++){
			for(int c=0; c*C<=F; c++){
				for(int d=0; d*D<=F; d++){
					water=a*A+b*B;
					sugar=c*C+d*D;
					if(water>0 && sugar<=E*water && 100*water+sugar<=F){
						if(sugar*(100*ans_w+ans_s)>ans_s*(100*water+sugar)){
							ans_w=water;
							ans_s=sugar;
						}
					}
				}
			}
		}
	}
	cout << 100*ans_w+ans_s << " " << ans_s << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	a, b := readInt(), readInt()

	fmt.Println(max(0, a-2*b))
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
using namespace std;

int N,K,bil;
int main (){
	cin >> N >> K;
	bil=1;
	for (int i=1; i<=N; i++){
		if((bil*2)<=(bil+K)){
			bil= bil*2;
		}else{
			bil= bil+K;
		}
	}
	cout <<bil;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 805;
const int MAXM = 640005;
const int INF = 0x3f3f3f3f;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

int n, m, k, ql, qr, ans = INF, qx[MAXM], qy[MAXM], dis[MAXN][MAXN];
char s[MAXN][MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	mset(dis, INF), n = Read(), m = Read(), k = Read();
	for (int i = 1; i <= n; i ++)
		scanf("%s", s[i] + 1);
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++)
			if (s[i][j] == 'S')
				qx[++ qr] = i, qy[qr] = j, dis[i][j] = 0;
	while (ql ^ qr)
	{
		int x = qx[++ ql], y = qy[ql];
		if (dis[x][y] >= k)
			break;
		for (int i = 0; i < 4; i ++)
		{
			int nx = x + dx[i], ny = y + dy[i];
			if (s[nx][ny] == '.' && dis[nx][ny] == INF)
				dis[nx][ny] = dis[x][y] + 1, qx[++ qr] = nx, qy[qr] = ny;
		}
	}
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++)
			if (dis[i][j] <= k)
				ans = min(ans, (min(i - 1, min(j - 1, min(n - i, m - j))) + k - 1) / k + 1);
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 8320
<?php
	list($r, $D, $x_lastyear) =  explode(" ",trim(fgets(STDIN)));
    define("r", $r);
    define("D", $D);
	$x_thisyear = 0;	

	for($i=1; $i<=10; $i++) {
		$x_thisyear = r * $x_lastyear - D;
		echo $x_thisyear;
		echo "\n";
		
		$x_lastyear = $x_thisyear;
	}
?>



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

int main() {
    int n, k;
    cin >> n >> k;
    int x[n], y[n];
    int sx[n], sy[n];
    rep(i, n) {
        cin >> x[i] >> y[i];
        sx[i] = x[i], sy[i] = y[i];
    }
    sort(sx, sx + n);
    sort(sy, sy + n);
    
    ll ans = 1LL * (sx[n-1] - sx[0]) * (sy[n-1] - sy[0]);
    rep(x1, n) {
        REP(x2, x1+1, n) {
            rep(y1, n) {
                REP(y2, y1+1, n) {
                    int num = 0;
                    int lx = sx[x1], rx = sx[x2];
                    int dy = sy[y1], uy = sy[y2];

                    rep(i, n) {
                        if (lx <= x[i] && x[i] <= rx && dy <= y[i] && y[i] <= uy) {
                            num++;
                        }
                    }
                    if (num >= k) {
                        ans = min(ans, 1LL * (rx - lx) * (uy - dy));
                    }
                }
            }
        }

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

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

long long int dp[1001][1001];

int main() {

    string t,b;

    cin >> t >> b;

    int ts = t.size(), bs = b.size();

    dp[0][0] = 1;

    for(int i=0;i<ts;i++){
        for(int j=0;j<bs;j++){
            if(t[i] == b[j]){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= 1000000007;
            }
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= 1000000007;
        }
    }

    long long int ans = 0;

    for(int i=1;i<=ts;i++){
        ans += dp[i][bs];
        ans%=1000000007;
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 10988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int h,w;
    string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j] == "snuke"){
                cout << al[j] << i + 1 << endl;
            }
        }
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back
#define mp make_pair

int n, k;
vec<vec<int>> kids;
vec<int> v;
vec<pair<int, int>> range;
vec<int> check;
vec<bool> dp;
int flag = 1;
pair<int, int> INF = {- 1e+9, 1e+9};
vec<int> ans;

void dfs(int p)
{
	if (v[p] != - 1) range[p] = mp(v[p], v[p]);
	rep(i, kids[p].size()) {
		if (dp[kids[p][i]]) continue;
		dp[kids[p][i]] = 1;
		if (check[kids[p][i]] == check[p]) {
			flag = 0;
			break;
		} else check[kids[p][i]] = 1 - check[p];
		dfs(kids[p][i]);
		if (range[kids[p][i]] != INF) {
			range[p].first = max(range[kids[p][i]].first - 1, range[p].first);
			range[p].second = min(range[kids[p][i]].second + 1, range[p].second);
			if (range[p].first > range[p].second) {
				flag = 0;
				break;
			}
		}
	}
}

void dfs2(int p)
{
	rep(i, kids[p].size()) {
		if (dp[kids[p][i]]) continue;
		dp[kids[p][i]] = 1;
		if (ans[p] - 1 < range[kids[p][i]].first) ans[kids[p][i]] = ans[p] + 1;
		else ans[kids[p][i]] = ans[p] - 1;
		dfs2(kids[p][i]);
	}
}

int main(void)
{
	int n, k;
	cin >> n;
	kids.resize(n);
	check.resize(n);
	rep(i, n) check[i] = - 1;
	v.resize(n);
	rep(i, n) v[i] = - 1;
	dp.resize(n);
	rep(i, n) dp[i] = 0;

	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		kids[a].pb(b);
		kids[b].pb(a);
	}
	cin >> k;
	int start = 0;
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		a--;
		v[a] = b;
		check[a] = b % 2;
		start = a;
	}
	range.resize(n);
	rep(i, n) range[i] = INF;
	dp[start] = 1;
	dfs(start);
	if (!flag) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		ans.resize(n);
		ans[start] = v[start];
		rep(i, n) dp[i] = 0;
		dp[start] = 1;
		dfs2(start);
		rep(i, n) cout << ans[i] << endl;
	}
	return 0;
}

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

int main() {
  int N,M;
  string blue[110], red[110];
  cin >> N;
  for(int i=0; i<N; i++) cin >> blue[i];
  cin >> M;
  for(int i=0; i<M; i++) cin >> red[i];  
  
  int max=0;
  
  for(int i=0; i<N; i++){
    int count=0;
    for(int j=0; j<N; j++){
      if(blue[i]==blue[j]) count++;
    }
    for(int k=0; k<M; k++){
      if(blue[i]==red[k]) count--;
    }
    
    if(count > max) max = count;
  }
  
  cout << max << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
char s[222222];
int sum[222222];
int d[222222],pd;
int la[222222];
int f[222222];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(register int i=1;i<=n;++i)d[i]=sum[i]=sum[i-1]^1<<s[i]-'a';
	std::sort(d+1,d+n+2);
	pd=std::unique(d+1,d+n+2)-d-1;
	sum[0]=1;
	for(register int i=1;i<=n;++i)sum[i]=std::lower_bound(d+1,d+pd+1,sum[i])-d;
	memset(f,63,sizeof(f));
	memset(la,63,sizeof(la));
	f[0]=0;
	la[1]=0;
	for(register int i=1;i<=n;++i)
	{
		int v=sum[i];
		cmin(f[i],la[v]+1);
		for(register int j=0;j<26;++j)
		{
			int p=d[v]^1<<j;
			int pp=std::lower_bound(d+1,d+pd+1,p)-d;
			if(d[pp]==p&&pp<=pd)cmin(f[i],la[pp]+1);
		}
		cmin(la[v],f[i]);
	}
	printf("%d\n",f[n]);
	return 0;
}




Measured memory_bytes: 3712
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG D, G; cin >> D >> G;
    vector<LLONG> ps(D), cs(D), maxs(D);
    for (int i = 0; i < D; ++i)
    {
        cin >> ps[i] >> cs[i];
        maxs[i] = 100LL * (i + 1LL) * ps[i] + cs[i];
    }
    // 各同点問題を解くか解かないかでbit全探索:O(2^D <~ 10^3)
    LLONG minNum = 10e5;
    for (int bit = 0; bit < (1 << D); ++bit)
    {
        LLONG sum = 0LL;
        LLONG num = 0LL;
        for (int i = 0; i < D; ++i)
        {
            if (bit & (1 << i))
            {
                sum += maxs[i];
                num += ps[i];
            }
        }
        LLONG rem = G - sum;
        // 合計点がGを超えている場合，これ以上解く必要はない
        if (rem <= 0LL)
        {
            minNum = min(minNum, num);
        }
        // 合計点がGを超えていない場合は，まだ解いていない問題のうち，
        // 配点が最も高い問題を必要数だけ解く
        else
        {
            for (LLONG i = D - 1LL; i >= 0LL; --i)
            {
                if (!(bit & (1 << i)))
                {
                    // 必要数はps[i]未満である必要がある
                    LLONG needNum = (rem + 100LL * (i + 1LL) - 1) / (100LL * (i + 1LL));
                    if (needNum < ps[i])
                    {
                        num += needNum;
                        minNum = min(minNum, num);
                    }
                    break;
                }
            }
        }
    }
    cout << minNum << endl;
}


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

int N, M;
int c = 0;
int total = 0;
int A[105];

void solve() {
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    total += A[i];
  }
  for (int i = 0; i < N; i++) {
    if ((A[i])*(4*M) >= total) {
      c++;
    }
  }
  if (c >= M) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

int main() {
  cin >> N >> M;
  solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} comb(10000007);
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)

int main() {
  // aとbはbit毎で重ならない、桁dpでpendingとok
  string S;
  cin >> S;
  mint cur = 1;
  mint ans = 0;
  int length = sz(S);
  for (int i = 0; i < length; i++) {
    if (S[i] == '1') {
      ans += cur * mint(3).pow(length - i - 1);
      cur *= 2;
    } 
  }
  ans += cur;
  cout << ans << '\n';
  return 0;
}

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

using namespace std;
using i64 = int64_t;

int main(){
    i64 x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    k = abs(k);
    d = abs(d);
    cerr << abs((double)x) - abs((double)k * d) << endl;
    if(abs((double)x) < abs((double)k * d)){
        if(x % d < abs(x % d - d)){
            k -= x / d;
            if(k & 1){
                cout << abs(x % d - d) << endl;
            }else{
                cout << x % d << endl;
            }
        }else{
            k -= x / d + 1;
            if(k & 1){
                cout << x % d << endl;
            }else{
                cout << abs(x % d - d) << endl;
            }
        }
    }else{
        cout << abs(abs(x)-abs(k*d)) << endl;
    }
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;

int tab[100010];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1 ; i <= n ; i++)
		cin >> tab[i];
	int ans = 0;
	int cnt = 0;
	for (int i = n ; i >= 1 ; i--)
	{
		if (tab[i - 1] < tab[i])
		{
			ans = max(ans,cnt);
			cnt = 0;
		}
		else
			++cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
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; }

int main(){

    ll n,k; cin >> n >> k;
    ll sum = 0;
    ll now;
    while(k <= n+1){
        now = k*(2*n-k+1)/2 - k*(k-1)/2 +1;
        sum += now;
        sum = sum % mod;
        k++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<char, int> l;
    map<char, int> r;
    int m = n;
    for (int i = 1; i < n; i++) r[s[i]]++;
    for (int x = 0; x < n; x++) {
        if (x > 0) {
            l[s[x - 1]]++;
            r[s[x]]--;
        }
        int cur = 0;
        cur += l['W'];
        cur += r['E'];
        m = min(m, cur);
    }
    cout << m << endl;
    return 0;
}



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

using namespace std;

using ll = long long;

//部分点解法
//f(A, B)を全て求める
//max_lenは部分文字列であって同じ文字からなるもののうち最長のものの長さ（3番目の条件のやつ）
//求め方は公式解説のKの決定方法と同じ
string solve(int a, int b, int max_len) {
    //自明なやつ
    if (b == 0) return string(a, 'A');
    if (a == 0) return string(b, 'B');
    if (max(a, b) <= max_len) return string(a, 'A') + string(b, 'B');

    //a >= bなら'A' * max_len + 'B'を前に
    //a < bなら'A' + 'B' * max_lenを後ろに足していく
    //という操作を再帰的にやると上手くいく
    //（これで破綻しないことはmax_lenの計算方法から証明可能）
    if (a >= b) {
        if (max_len == -1) max_len = (a + b) / (b + 1);
        return string(max_len, 'A') + "B" + solve(a - max_len, b - 1, max_len);
    } else {
        if (max_len == -1) max_len = (a + b) / (a + 1);
        return solve(a - 1, b - max_len, max_len) + "A" + string(max_len, 'B');
    }
}

//満点解法
//前に足す操作をA，後ろに足す操作をBとすると
//操作列はAAA...ABAB...(or BBB...BABA...)みたいになる
//これらの操作列はAAA...のひたすら同じ操作をする部分と
//ABAB...の違う操作を交互にする部分に分けられる
string solve(int a, int b, int c, int d) {
    int max_len;
    int cnt_a = 0; //前に足す操作をした回数
    int cnt_b = 0; //後ろに足す操作をした回数

    //ひたすら前か後ろに足し続けるパート
    if (a >= b) {
        max_len = (a + b) / (b + 1);
        cnt_a = min({(a + b) / (max_len + 1), a / max_len, b});
        if (max_len > 1) cnt_a = min((a - b) / (max_len - 1), cnt_a);
        a -= cnt_a * max_len;
        b -= cnt_a;
    } else {
        max_len = (a + b) / (a + 1);
        cnt_b = min({(a + b) / (max_len + 1), b / max_len, a});
        if (max_len > 1) cnt_b = min((b - a) / (max_len - 1), cnt_b);
        b -= cnt_b * max_len;
        a -= cnt_b;
    }

    //前と後ろに交互に足すパート
    //このパート以降，(a <= max_len || b <= max_len)となる
    int tmp = min(b / (max_len + 1), a / (max_len + 1));
    cnt_a += tmp;
    cnt_b += tmp;
    a -= tmp * (max_len + 1);
    b -= tmp * (max_len + 1);

    //帳尻合わせ
    //これにより，(a <= max_len && b <= max_len)となる
    if (a >= b) {
        int tmp2 = min(a / max_len, b);
        cnt_a += tmp2;
        a -= tmp2 * max_len;
        b -= tmp2;
    } else {
        int tmp2 = min(b / max_len, a);
        cnt_b += tmp2;
        b -= tmp2 * max_len;
        a -= tmp2;
    }

    string res = "";
    //各インデックスの文字を調べる
    for (int i = c; i < d; i++) {
        if (i < cnt_a * (max_len + 1)) {
            int idx = i % (max_len + 1);
            res += (idx == max_len ? 'B' : 'A');
        } else if (i < cnt_a * (max_len + 1) + a) {
            res += 'A';
        } else if (i < cnt_a * (max_len + 1) + a + b) {
            res += 'B';
        } else {
            int idx = (i - cnt_a * (max_len + 1) - a - b) % (max_len + 1);
            res += (idx == 0 ? 'A' : 'B');
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        c--;
        cout << solve(a, b, c, d) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
	vector<int> num;
	rep(i, 0, 3){
		int temp;
		cin >> temp;
		num.push_back(temp);
	}
	sort(begin(num), end(num));
	int sum = accumulate(begin(num), end(num), 0);
	sum -= num[2];
	sum += (num[2] * 10);

	cout << sum << endl;

    return 0;
}

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

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

	vector<int> SX(n), SY(n), CX(m), CY(m);

	for(int s=0; s<n; s++) cin>>SX[s]>>SY[s];
	for(int c=0; c<m; c++) cin>>CX[c]>>CY[c];

	for(int s=0; s<n; s++){
		int ans = 1;
		int mini = abs(SX[s]-CX[0]) + abs(SY[s]-CY[0]);
		for(int c=1; c<m; c++){
			int m  = abs(SX[s]-CX[c]) + abs(SY[s]-CY[c]);
			if(mini>m){
				mini = m;
				ans = c+1;
			}
		}
		cout<< ans <<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;

  map<char, int> m;
  m['s'] = R;
  m['r'] = P;
  m['p'] = S;

  int ans = 0;
  for (int k = 0; k < K; k++) {
    char last = ' ';
    for (int i = k; i < N; i += K) {
      if (T[i] != last) {
        ans += m[T[i]];
        last = T[i];
      }
      else {
        last = ' ';
      }
    }
  }
  cout << ans << endl;
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    set<int> s;
    int a;
    rep(i,3){
        cin>>a;
        s.insert(a);
    }
    if(s.size()==2) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
int n,m;
int w[1200][1200];
int c[1200][1200];
struct node
{
    int x,y;
};
node q[12000000];
int l=0,r=0;

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

int solve()
{
    int nowx,nowy;
    int nextx,nexty;
    while (l<r)
    {
        node now=q[l];
        l++;
        nowx = now.x;
        nowy = now.y;
        for (int k=0; k<4; ++k)
        {
            nextx = nowx+dx[k];
            nexty = nowy+dy[k];
            if (nextx>=1 && nextx<=n && nexty>=1 && nexty<=m)
            if (c[nextx][nexty]==0)
            {
                c[nextx][nexty]=c[nowx][nowy]+1;
                q[r].x=nextx;
                q[r].y=nexty;
                r++;
            }
        }
    }
    int t =0;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=m; ++j)
            t = max(t,c[i][j]);
    return t-1;

}

int main()
{
    cin >>n >>m;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=m; ++j)
        {
            scanf("%c",&ce);
            while (ce!='.' && ce!='#')
                scanf("%c",&ce);
            w[i][j]=(ce=='#');
            if (w[i][j]==1)
            {
                q[r].x=i;
                q[r].y=j;
                r++;
                c[i][j]=1;
            }
        }
    cout<<solve()<<endl;
    return 0;
}



Measured memory_bytes: 20736
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int ans[m];
    for(int i = 0; i < m; i++)
        {
        cin >> ans[i];
        }
    int k = 0, t = 0;
    for(int i = 0; i < m; i++)
    {
        if(ans[i] < x)
                k++;
        else
                t++;
    }
    cout << min(t, k);
    return 0;
}

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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define REP(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)((x).size()))

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

bool ab[50000], bc[50000], ca[50000];

int match(char x, char y){
    if (x == y || x == '?' || y == '?')return 1;
    return 0;
}
int main() {
    string A, B, C;
    cin >> A >> B >> C;
    int ans = 10000;
    
    rep(i, SZ(A))rep(j, SZ(B))if (!match(A[i], B[j]))ab[10000 + i - j] = true;
    rep(i, SZ(B))rep(j, SZ(C))if (!match(B[i], C[j]))bc[10000 + i - j] = true;
    rep(i, SZ(C))rep(j, SZ(A))if (!match(C[i], A[j]))ca[10000 + i - j] = true;
    
    for (int i = -4000; i <= 4000; i++)for (int j = -4000; j <= 4000; j++){
        if (!ab[10000 + -(0 - i)] && !bc[10000 + -(i - j)] && !ca[10000 + -(j - 0)]){
            int lb = min(0, min(i, j));
            int ub = max(SZ(A), max(i + SZ(B), j + SZ(C)));
            chmin(ans, ub - lb);
        }
    }
    
    cout << ans;
    return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int ans = K;
	for (int i = 0;i < N - 1;i ++) ans *= K - 1;
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

最初の1個目のボールはK通りの塗り方があるね
で、次のボールは1個前のボールとは別の色なのでK-1通り
同様に次のボールも1個前のボールとは別の色なのでK-1通り
……よって、N個のボールの塗り方はK*(K-1)^(N-1)通り
*/

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		double map[][];
		double memo[][];

		while (true) {
			n = sc.nextInt();
			m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}
			map = new double[n][n];
			memo = new double[m][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map[i][j] = sc.nextDouble();
				}
			}
			for (int i = 0; i < m; i++) {
				Arrays.fill(memo[i], -1.0);
			}

			for (int j = 0; j < n; j++) {
				memo[0][j] = 1.0;
			}

			for (int i = 1; i < m; i++) {
				for (int j = 0; j < n; j++) {
					double max = 0;
					for (int k = 0; k < n; k++) {
						max = Math.max(max, memo[i - 1][k] * map[k][j]);
					}
					memo[i][j] = max;
				}
			}

			Arrays.sort(memo[m - 1]);
			System.out.printf("%.2f\n", memo[m - 1][n - 1]);
		}
	}
}

Measured memory_bytes: 66212
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)

using namespace std;

int32_t main() {
    int n, c;
    cin >> n >> c;
    int w[n + 1], u[n + 1];
    int s = 0;
    FOR(i, 1, n + 1) {
        cin >> w[i] >> u[i];
        s += u[i];
    }
    int d[n + 1][s + 1];
    FOR(i, 0, n + 1) {
        d[i][0] = 0;
    }
    FOR(i, 1, s + 1) {
        d[0][i] = c + 1;
    }
    FOR(i, 1, n + 1) {
        FOR(j, 1, s + 1) {
            d[i][j] = min(d[i - 1][j], d[i - 1][j - u[i]] + w[i]);
            if (j - u[i] < 0) {
                d[i][j] = d[i - 1][j];
            }
        }
    }
    for(int i = s; i >= 0; --i) {
        if (d[n][i] <= c) {
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 82524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int K=scan.nextInt();
		int A=scan.nextInt();
		int B=scan.nextInt();
		int s=0;
		s=(B/K)*K;
		if(A<=s)
		{
			System.out.println("OK");
		}
		else
		{
			System.out.println("NG");
		}
	}

}


Measured memory_bytes: 35688
import sys


# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

# ===CODE===
def main():
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

    ans = 0
    d = []
    for i in range(m):
        a,b = map(int,input().split())
        a-=1
        b-=1
        d.append((a,b))

    ans = 0
    for i in range(m):
        que = UnionFind(n)
        for j in range(m):
            if i!=j:
                que.union(d[j][0], d[j][1])

        if que.group_count() != 1:
            ans+=1

    print(ans)





if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

using namespace std;

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

int main(void) {
    li N;
    cin >> N;

    li ans = 0;

    FOR(i, 1, N+1) {
        li count = 0;
        if ( i % 2 == 0) {
            continue;
        }

        FOR(j, 1 , i+1) {
            if (i % j == 0) { 
                count++; 
            };
        }
        if (count == 8) {
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256