akhauriyash/Code-Regression huggingface dataset:
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

L = [0]*26

v = 0
ans = [0]*D
import copy
for i in range(1, D+1):
    max_score = -float('inf')
    max_idx = 0
    for j in range(26):
        temp = v
        temp += S[i-1][j]
        L_ = copy.copy(L)
        L_[j] = i
        for k in range(26):
            temp -= C[k]*(i-L_[k])
        if temp >= max_score:
            max_score = temp
            max_idx = j
    v = max_score
    L[max_idx] = i
    ans[i-1] = max_idx+1
print(*ans, sep='\n')


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

int main(){
    string s;
    cin >> s;
    int countn=0,countw=0,counts=0,counte=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='N')countn++;
        if(s.at(i)=='W')countw++;
        if(s.at(i)=='S')counts++;
        if(s.at(i)=='E')counte++;
    }
    if(countn==0&&counts!=0||countn!=0&&counts==0)puts("No");
    else if(countw==0&&counte!=0||countw!=0&&counte==0)puts("No");
    else puts("Yes");
}

Measured memory_bytes: 256
function Main(input){
  var arr = input.split(" ");
  var n = parseInt(arr[0],10);
  var i = parseInt(arr[1],10);
  var s = (n - i) + 1;
  console.log(s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import Control.Applicative
import Data.List

main = do
  word <- words <$> getLine
  putStrLn $ unwords . (modeWord word :) . (longestWode word :) $ []

modeWord :: [String] -> String
modeWord = fst . foldl1 (\x y -> if snd x > snd y then x else y) . fmap (\x -> (head x, length x)) . group . sort

longestWode :: [String] -> String
longestWode = fst . foldl1 (\x y -> if snd x > snd y then x else y) . fmap (\x -> (x, length x)) . nub . sort

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

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

    long long s;
    cin >> s;
    int turn;
    set<long long> st;

    for (turn = 1; turn <= 1e6; ++turn) {
        st.insert(s);
        if (st.size() != turn) break;
        if (s % 2 == 1) {
            s = s * 3 + 1;
        } else {
            s /= 2;
        }
    }
    
    cout << turn << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
int main() {
	map<string, int> word;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		string u;
		cin >> u;
		word[u] = 0;
	}
	int m;
	cin >> m;
	bool opened = false;
	for(int i = 0; i < m; i++) {
		string t;
		cin >> t;
		if(word.find(t) != word.end()) {
			if(!opened) {
				cout << "Opened by " << t << endl;
				opened = true;
			}
			else {
				cout << "Closed by " << t << endl;
				opened = false;
			}
		}
		else {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
# n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))

border = sum(a) / (4*m)

cnt = 0

for _a in a:
    if _a >= border:
        cnt += 1

if cnt >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int A,B,K;
	scan(A);scan(B);scan(K);
	vint yakusu;
	rep1(i,min(A,B)){
		if(A%i==0&&B%i==0) yakusu.push_back(i);
	}
	prin(yakusu[yakusu.size()-K]);
	return 0;
}


Measured memory_bytes: 256
def main():
    """
    1 以上 N 以下の整数のうち、
    10 進法での各桁の和が A 以上 B 以下であるものの総和を求めてください。
    """
    N, A, B = map(int, input().split())

    ans = 0
    for n in range(1, N + 1):
        s = sum(map(int, str(n)))
        if A <= s <= B:
            ans += n

    print(ans)

if __name__ == '__main__':
    main()


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

//数列v内に数nが存在するかどうか調べる
bool srt_knsk(vector<int> v,int n){
  for(int i=0; i<v.size(); i++){
    if(v.at(i) == n){
      return true;
    }
  }
  return false;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(446);
  for(int i=0; i<446; i++){
    a[i] = (i+1)*(i+2)/2;
  }
  if(srt_knsk(a,n)){
    cout << "Yes" << endl;
    int k = (1+sqrt(1+8*n))/2;
    cout << k << endl;
    int a[k][k-1];
    int cnt = 1;
    for(int i=0; i<k-1; i++){
      for(int j=i; j<k-1; j++){
        a[i][j] = cnt;
        a[j+1][i] = cnt;
        cnt++;
      }
    }
    for(int i=0; i<k; i++){
      cout << k-1 << " ";
      for(int j=0; j<k-1; j++){
        cout << a[i][j] << " ";
      }
      cout << endl;
    }
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int i,j,n,a,m,c,k,l;
int main(){
  cin>>n>>m;
  vector<vector<int>> s(m);
  for(;i<m;i++){
    cin>>k;
    s[i].resize(k);
    for(j=0;j<k;j++){
      cin>>s[i][j];--s[i][j];
    }
  }

  vector<int> p(m);
  for(i=0;i<m;i++)cin>>p[i];

  int ans=0;
  for(i=0;i<(1<<n);i++){
    bool res=true;
    for(j=0;j<m;j++,c=0){
      for(int idx:s[j]){
        if((i>>idx)&1)++c;
      }
      c%=2;
      if(c!=p[j])res=false;
    }
    if(res)++ans;
  }
  cout<<ans;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7
last = [0 for i in range(N+1)]
last[0] = 1
bro = [int(input()) for i in range(M)]

broken = [1 for i in range(N+1)]
for i in range(M):
  broken[bro[i]] = 0

for i in range(N):
  if i == 0:
    last[i+1] = last[i]*broken[i]
  else:
    last[i+1] = last[i]*broken[i]+last[i-1]*broken[i-1]
  last[i+1] %= mod
print(last[N])

Measured memory_bytes: 9608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	

	ll n;
	cin>>n;
	cout<< 3 *(n*n);

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest 116：B - Collatz Problem


def f(n):
    if n & 1 == 1:
        return n+n+n+1
    else:
        return n>>1


def main():
    s = int(raw_input().strip())

    hist = [s]
    i = 2
    while True:
        n = f(s)
        if n in hist:
            print i
            exit()
        hist.append(n)
        s = n
        i += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  ll ans = 0;
  int n;
  cin >> n;
  if(n == 1) cout << 0 << endl;
  else{
     for(int i = 1; i < n; i++){
        ans += i;
     }
     cout << ans << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
class Main{
	public static void main(String args[])throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		
StringBuilder str = new StringBuilder();
        int i = 1;
        while (true) {
            int data = Integer.parseInt(br.readLine());
            if (data == 0)
                break;
            str.append("Case ").append(Integer.toString(i)).append(": ")
                .append(Integer.toString(data)).append("\n");
            i++;
        }
        System.out.print(str);
    }
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1;
    cin >> s2;

    vector<int> vi;
    int i = 0;
    while (i < s1.size())
    {
        if (s1[i] == s2[i])
        {
            vi.push_back(0);
            i += 1;
        }
        else
        {
            vi.push_back(1);
            i += 2;
        }
    }

    long long ans;
    if (vi[0] == 0)
    {
        ans = 3;
    }
    else
    {
        ans = 6;
    }

    for (int i = 1; i < vi.size(); i++)
    {
        if (vi[i - 1] == 0)
        {
            if (vi[i] == 0)
            {
                ans *= 2;
            }
            else
            {
                ans *= 2;
            }
        }
        else
        {
            if (vi[i] == 0)
            {
                ans *= 1;
            }
            else
            {
                ans *= 3;
            }
        }
        ans %= 1000000007;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int good[N];
  int H[N]; for (int i=0; i<N; i++) {
    cin >> H[i];
    good[i] = 0;
  }

  int A[M], B[M];
  int ans = 0;
  for (int i=0;i<M; i++) {
    cin >> A[i] >> B[i];
    if (H[A[i]-1] < H[B[i]-1]) {
      if (good[B[i]-1] == 0) good[B[i]-1] = 2;
      if (good[A[i]-1] == 0) good[A[i]-1] = 1;
      if (good[A[i]-1] == 2) good[A[i]-1] = 1;

    } else if (H[A[i]-1] > H[B[i]-1]){
      if (good[A[i]-1] == 0) good[A[i]-1] = 2;
      if (good[B[i]-1] == 0) good[B[i]-1] = 1;
      if (good[B[i]-1] == 2) good[B[i]-1] = 1;

    } else {
      if (good[A[i]-1] == 0) good[A[i]-1] = 1;
      if (good[B[i]-1] == 0) good[B[i]-1] = 1;
      if (good[A[i]-1] == 2) good[A[i]-1] = 1;
      if (good[B[i]-1] == 2) good[B[i]-1] = 1;

    }
  }

  for (int i=0; i<N; i++) {
    if (good[i] == 0 || good[i] == 2) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5144
n,k = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i)

(k..(n-1)).each do |i|
  # i学期の評点: k[i] + k[i-1] + ... + k[i-(k-1)]
  # (i - 1)学期の評点: k[i-1] + k[i-2] + ... + k[i-(k-1)] + k[i-k]
  if a_arr[i-k] < a_arr[i]
    puts "Yes"
  else
    puts "No"
  end
end


Measured memory_bytes: 36056
#include "bits/stdc++.h"
// Custom Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (n); i >= (t); --i)
#define LF          '\n'

#ifdef DBG
#define err(...)    fprintf(stderr, __VA_ARGS__)
#define dump(x)     clog << std::setw(6) << (#x) << ": " << (x) << endl
#else
#define err(...)
#define dump(x)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << max({ a+b, a-b, a*b }) << endl;

    return 0;
}



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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "AC" : "WA") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(S);
  bool ok = true;
  ok &= (S[0] == 'A');
  // OK(ok);
  int cnt = 0;
  FOR(i, 2, S.size() - 1) {
    if (S[i] == 'C') cnt++;
    else ok &= ((S[i] >= 'a' && S[i] <= 'z'));
  }
  // OK(ok);
  ok &= ('a' <= S[1] && S[1] <= 'z');
  ok &= ('a' <= S.back() && S.back() <= 'z');
  ok &= (cnt == 1);

  OK(ok);

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ITP1_6_C
{
	class Program
	{
		const int HOUSE_CNT = 4;
		const int FLOOR_CNT = 3;
		const int ROOM_CNT = 10;

		static void Main(string[] args)
		{
			List<List<List<int>>> houses = new List<List<List<int>>>();

			// 初期化
			Init(houses);

			// 入退去
			InOut(houses);

			// 出力
			Output(houses);
		}

		private static void Init(List<List<List<int>>> houses)
		{
			for(int h = 0; h < HOUSE_CNT; h++) {
				List<List<int>> floors = new List<List<int>>();
				for(int f = 0; f < FLOOR_CNT; f++) {
					List<int> rooms = new List<int>();
					for(int r = 0; r < ROOM_CNT; r++) {
						rooms.Add(0);
					}
					floors.Add(rooms);
				}
				houses.Add(floors);
			}
		}

		private static void InOut(List<List<List<int>>> houses)
		{
			int n = int.Parse(Console.ReadLine());

			for(int i = 0; i < n; i++) {
				string[] vs = Console.ReadLine().Split(' ');

				int b = int.Parse(vs[0]) - 1;
				int f = int.Parse(vs[1]) - 1;
				int r = int.Parse(vs[2]) - 1;
				int v = int.Parse(vs[3]);

				houses[b][f][r] += v;
			}
		}

		private static void Output(List<List<List<int>>> houses)
		{
			bool line = false;
			foreach(List<List<int>> house in houses) {
				if(line) {
					Console.WriteLine("####################");
				}
				else {
					line = true;
				}

				foreach(List<int> floor in house) {
					foreach(int room in floor) {
						Console.Write($" {room}");
					}
					Console.WriteLine();
				}
			}
		}
	}
}



Measured memory_bytes: 18116
#include <iostream>
#include <bits/stdc++.h>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#define initrand mt19937 mt_rand(time(0));
#define rand mt_rand()
#define int long long
#define INF 10000000000000
#define mid(l, u) ((l+u)/2)
#define lchild(i) (i*2 + 1)
#define rchild(i) (i*2 + 2)
using namespace std;
signed main(){
    int cnt = 0, n, d, x, y;
    cin>>n>>d;
    while(n--){
        cin>>x>>y;
        if((x*x + y*y) <= (d*d)) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;
use std::cmp::min;

fn main() {
    let x: usize = read();
    let a: usize = read();

    println!("{}", if x < a {0} else {10});
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define MN 1000005
#define LL long long
#define mp make_pair
#define fir first
#define sec second
#define pii pair<int,int>
inline void chkmax(int &a,int b){if(a<b)a=b;}
inline void chkmin(int &a,int b){if(a>b)a=b;}
inline int read(){
	   int a=0,fh=1;char c=getchar();
	   while(c>'9'||c<'0'){if(c=='-')fh=-1;c=getchar();}
	   while('0'<=c&&c<='9'){
		   a=a*10+c-48;
		   c=getchar();
	   }
	   return a*fh;
}
int C(int n,int m){return (n&m)==m;}
char ch[MN];
int n,a[MN];
int main(){
	scanf("%d%s",&n,ch+1);
	n--;
	bool op=0;
	for(int i=1;i<=n;++i)a[i]=abs(ch[i+1]-ch[i]),op|=(a[i]==1);
	if(!op)for(int i=1;i<=n;++i)a[i]>>=1;
	int ans=0;
	for(int j=1;j<=n;++j)ans^=C(n-1,j-1)*(a[j]&1);
	if(op)printf("%d\n",ans);
	else printf("%d\n",ans*2);
	return 0;
}

















Measured memory_bytes: 5120
#include<iostream>
#include<time.h>
#define Max 100005
int Arr[Max] = {0};
int Arr2[Max] = {0};
using namespace std;
int main(){
    // int t1, t2;
    // t1 = clock();
    int q, i, j, n, m, ans=0;
    for(i=2; i<Max; i++){
        if(Arr[i] == 0)
        for(j =i+i; j<Max; j=j+i)
            Arr[j] = 1;
    }
    for(i=3; i<Max; i++)
        if(Arr[i] == 0 && Arr[(i+1)/2] == 0)
            Arr2[i] = ++ans;
        else
            Arr2[i] = ans;

    cin>>q;
    for(i=0; i<q; i++){
        cin>>n>>m;
        cout<<Arr2[m] - Arr2[n-1]<<endl;
    }
    // t2 = clock();
    // cout<<t2 - t1<<endl;
    // for(i=0; i<1000; i++){
    //     // if(Arr2[i] == )
    //     cout<<i<<"|"<<Arr2[i]<<"    ";
    // }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    int H[N];
    for(int i = 0; i < N; i++) cin >> H[i];
    vector<bool> g(N, true);
    for (int i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        if(H[a] > H[b]) g[b] = false;
        else if(H[a] == H[b]) { g[a] = false; g[b] = false;}
        else g[a] = false;
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(g[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <stdio.h>

int main () {
	int n, a, b, dig1, dig2, dig3, dig4, dig5;
	int sum = 0;
	scanf("%d %d %d", &n, &a, &b);
	for(int i = 1; i <= n; i++) {
		dig1 = i%10;
		dig2 = (i/10)%10;
		dig3 = (i/100)%10;
		dig4 = (i/1000)%10;
		dig5 = (i/10000)%10;
		if ((dig1+dig2+dig3+dig4+dig5) >= a && (dig1+dig2+dig3+dig4+dig5) <= b) {
			sum += i;
		}
	}
	printf("%d", sum);
	
	
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
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; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N];
    REP(i,N){
        cin >> A[i];
        if(A[i] > i){
            cout << -1 << endl;
            return 0;
        }
        if(i >= 1){
            if(A[i]-A[i-1] >= 2){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    ll cnt = 0;
    REPP(i,1,N){
        if(A[i]-A[i-1] <= 0){
            cnt += A[i];
        }
        else if(A[i]-A[i-1] == 1){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
n,p = map(int,input().split())
a = []
i = 2
k = p

if n == 1:
  c = p
else:
  while (p>1) and (i < int(k**0.5) + 4):
      c = 0
      while p%i == 0:
          p = p/i
          c += 1
      a.append([i,c])
      i += 1
  if p>1:
      a.append([p,1])
  c = 1

  for i in range(len(a)):
    if a[i][1] >= n:
      k = a[i][0] ** int(a[i][1]/n)
      c = c* k

print(c)


Measured memory_bytes: 116020
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

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

int G[15][15];

int main(){
    int n;
    cin >> n;
    rep(i,n)rep(j,n) G[i][j] = -1;
    rep(i,n){
        int m;
        cin >> m;
        rep(j,m){
            int a,x;
            cin >> a >> x;
            a--;
            G[i][a] = x;
        }
    }
    int ans=0;
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n){
            // iを二進数であらわして、j桁目が1であるかどうかを判定、１ならjは正直者としてbit全探索の準備
            if((i>>j) & 1){ 
                d[j] = 1;
            }
        }
        bool ok = true;
        rep(j,n){
            rep(k,n){
                //cout << G[j][k] << " " << d[k] << endl;
                if(d[j] == 1){
                    //cout << G[j][k] << " " << d[k] << endl;
                    if(G[j][k] == -1) continue;
                    if(G[j][k] != d[k]) ok = false;  
                }
            }
        }

        if(ok){
            //cout << "helloL " << endl;
            int anscandi=0;
            rep(j,n){
                if((i>>j) & 1) anscandi++; 
            }
            ans = max(ans, anscandi);
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main()
{
	string a;
	cin>>a;
	long long ans=0,cnt=0;
	for (int i=0; i<a.length(); i++)
	{
		if (a[i]=='A') 
		{
			if (i>0&&a[i-1]=='B') cnt=0;
			cnt++;
		}
		if (a[i]=='B') 
		{
			if (i==0) continue;
			else if (a[i-1]=='B') cnt=0;
		}
		if (a[i]=='C')
		{
			if (i==0||a[i-1]!='B') cnt=0;
			else ans+=cnt;
		}
	}
	
	cout << ans;
 } 

Measured memory_bytes: 640
X = int(input())

A = 0
B = 0

f = 0

for i in range(400):
    A = -200 + i
    
    if f == 1:
        break
    
    for j in range(400):
        B = -200 + j
        n = A**5 - B**5
        
        if n == X:
            print(A, end=' ')
            print(B)
            f = 1
            break

Measured memory_bytes: 64860
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
for i in range(X+1,Y+1,1):
    if i <= min(y) and i > max(x):
        print("No War")
        break
else:
    print("War")

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

#define endl '\n'
#define int long long

const int N = 405;

int n, a[N], pref[N], cache[N][N];

int dp(int i, int j) {
	if(i == j) 	
		return 0;
	int &ans = cache[i][j];
	if(ans != -1) 
		return ans;
	ans = 1e15;
	for(int k = i; k < j; k ++) {
		ans = min(ans, dp(i, k) + dp(k+1, j) + pref[j] - pref[i-1]);
	}
	return ans;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	memset(cache, -1, sizeof cache);

	cin >> n;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}

	cout << dp(1, n);

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (ll)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll a[n];
        fr(i,0,n) cin>>a[i];
        double prod=0;
        fr(i,0,k) prod+=log(a[i]);
        double prev=prod;
        fr(i,k,n)
        {
            prod-=log(a[i-k]);
            prod+=log(a[i]);
            if(prod>prev) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
            prev=prod;
        }
    }
    return 0;
}


Measured memory_bytes: 5412
/*      ex4_2
        Tarara  */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double pow2(double x);

int main(void)
{
    int hour_hand_len;   //時針の長さ(cm)
    int minute_hand_len; //分針の長さ(cm)
    int hour;            //時計が指す時間
    int minute;          //時計が指す分

    scanf("%d %d %d %d", &hour_hand_len, &minute_hand_len, &hour, &minute);

    double rad = M_PI / 6 * fabs(hour - 11.0 * minute / 60);

    double length = sqrt(pow2(hour_hand_len) + pow2(minute_hand_len) - 2 * hour_hand_len * minute_hand_len * cos(rad));
    printf("%.13f\n", length);
    return 0;
}

// ２乗を計算する
double pow2(double x)
{
    return x * x;
}

Measured memory_bytes: 2584
#include <stdio.h>
#include <string.h>

#define MAX(x, y) ((x) >= (y) ? (x) : (y))
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
int get_str(char *str) {
    int c;
    while((c = getchar_unlocked()) > 32) *str++ = (char)c;
    *str = 0;
    return c;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}

int lcs(char *s, char *t) {
    const size_t M = strlen(s);
    const size_t N = strlen(t);
    int dp[1001][1001] = {};
    for(int i = 0; i < M; ++i)
        for(int j = 0; j < N; ++j)
            if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
            else dp[i + 1][j + 1] = MAX(dp[i + 1][j], dp[i][j + 1]);
    return dp[M][N];
}
int main(int argc, char **argv) {
    int q = get_uint();
    char s[1001], t[1001];
    for(int i=0;i<q;++i){
        get_str(s);
        get_str(t);
        put_uint(lcs(s, t));
        putchar_unlocked('\n');
    }
    return 0;
}



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

using namespace std;

int main() {
    long long int N, X;
    cin >> N >> X;
    
    long long int max_length=1;
    int n=0;
    vector<long long int> max_p_num(N+1, 0);
    max_p_num[0] = 1;
    while(n<N) {
        max_length *= 2;
        max_length += 3;
        
        max_p_num[n+1] = max_p_num[n]*2+1;
        // cout << max_p_num[n+1] << endl;
        n++;
    }
    // cout << max_length << endl;
    
    long long int s=1, e=max_length;
    long long int cur=(s+e)/2;
    long long int ans=0;
    long long int curN=N-1;
    if(cur==X) {
        ans = max_p_num[curN]+1;
    }
    while(cur!=X) {
        // cout << cur << endl;
        if(cur<X) {
            if(curN>=0) {
                ans += max_p_num[curN]+1;
            } else {
                ans += 1;
                break;
            }
            
            s = cur+1;
            if(e!=X) {
                e--;
            } else {
                ans += max_p_num[curN];
                break;
            }
            cur = (s+e)/2;

            if(cur==X) {
                if(curN>0) {
                    ans += max_p_num[curN-1]+1;
                } else if(curN==0) {
                    ans += 1;
                }
            }
        } else if(cur>X) {
            e = cur-1;
            if(s!=X) {
                s++;
            } else {
                break;
            }
            cur = (s+e)/2;
            
            if(cur==X) {
                if(curN>0) {
                    ans += max_p_num[curN-1]+1;
                } else if(curN==0) {
                    ans += 1;
                }
            }
        }
        
        curN--;
    }
    
    cout << ans << endl;


    return 0;
    
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int H, W;
char S[20][20];
int rowperm[20];
bool row_used[20];

bool is_match(int j1, int j2){
    for(int i = 0; i < H; i++){
        if(S[rowperm[i]][j1] != S[rowperm[H - 1 - i]][j2]){
            return false;
        }
    }
    return true;
}

bool rec(int depth){
    if(depth == H / 2){
        for(int i = 0; i < W; i++){
            bool used[20] = {};
            if(W % 2){
                if(!is_match(i, i)){
                    continue;
                }
                used[i] = true;
            }
            
            for(int j = 0; j < W; j++){
                if(used[j]) continue;
                used[j] = true;
                bool ok = false;
                for(int k = 0; k < W; k++){
                    if(used[k]) continue;
                    if(j == k) continue;
                    if(is_match(j, k)){
                        used[k] = true;
                        ok = true;
                        break;
                    }
                }
                if(!ok) break;
            }

            int cnt = 0;
            for(int i = 0; i < W; i++)
                if(used[i]) cnt++;
            
            if(cnt == W) return true;

            if(W % 2 == 0) break;

            if(W % 2) used[i] = false;
        }
        return false;
    }
    else{
        int start = -1;
        for(int i = 0; i < H; i++){
            if(row_used[i]) continue;
            start = i;
            break;
        }

        row_used[start] = true;
        rowperm[depth] = start;

        for(int i = start + 1; i < H; i++){
            if(row_used[i]) continue;
            rowperm[H - 1 - depth] = i;
            row_used[i] = true;
            if(rec(depth + 1))
                return true;
            row_used[i] = false;
        }
        row_used[start] = false;
    }
    return false;
}

bool solve(){
    if(H % 2){
        for(int i = 0; i < H; i++){
            row_used[i] = true;
            rowperm[H / 2] = i;
            if(rec(0)){
                return true;
            }
            row_used[i] = false;
        }
        return false;
    }
    else{
        return rec(0);
    }
}

int main(){
    cin >> H >> W;
    for(int i = 0; i < H; i++) cin >> S[i];
    if(solve()){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    long long n;
    cin >> n;
    int flag = 0;
    for (n ; ; n++)
    {
        flag = 0;
        for (int j = 2; j*j<n; j++)
        {
            if (n % j == 0) {
                flag = 1;
                break;
            }
        }
        if (!flag) {
            cout << n << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func sub(x, y, z int) (count int) {
	count = 1
	if x != y {
		count += 1
	}
	if x != z && y != z {
		count += 1
	}

	return
}

func main() {
	var x, y, z int
	fmt.Scan(&x)
	fmt.Scan(&y)
	fmt.Scan(&z)
	fmt.Println(sub(x, y, z))
}


Measured memory_bytes: 512
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for i in range(N+1)]
B[0] = 0
C = {"0":1}
for i in range(N):
	B[i+1] = (B[i]+A[i])%M
	if str(B[i+1]) in C.keys():
		C[str(B[i+1])] = C[str(B[i+1])] + 1
	else:
		C[str(B[i+1])] = 1
	
out = 0
for j in C.values():
	out = out + int(j*(j-1)/2)

print(out)


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += 1ll * arr[i] * arr[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		String[] strs = null;
		
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			strs = br.readLine().split(" ");
		} catch (IOException e) {
			return;
		}
		
		int a = Integer.parseInt(strs[0]);
		int b = Integer.parseInt(strs[1]);
		
		System.out.println(Math.max(a + b, Math.max(a - b, a * b)));
	}
}


Measured memory_bytes: 22484
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#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 <map>
#include <tuple>
#include <iomanip>

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

typedef long long ll;

#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
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define sum(a) accumulate(begin(a), end(a), 0)


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;
    cin >> N;
    vector<ll> A;
    rep(i, 0, N){
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    ll all = A[0];
    rep(i, 1, N){
        all = all ^ A[i];
    }
    rep(i, 0, N){
        ll ans = all ^ A[i];
        cout << ans;
        if (i < (N - 1)){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5336
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        string S = Console.ReadLine();
        string T = Console.ReadLine();

        if (T.Take(S.Length).SequenceEqual(S))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 26532
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int C = Integer.parseInt(tokens[2]);
		int D = Integer.parseInt(tokens[3]);

		int turnTakahashi = C / B;
		if (C % B > 0) {
			turnTakahashi++;
		}
		int turnAoki = A / D;
		if (A % D > 0) {
			turnAoki++;
		}
		if (turnTakahashi <= turnAoki) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	void calc() {
	}

	void showResult() {
	}

}


Measured memory_bytes: 32444
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 100000000000000


int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  bool plus=false;
  bool minus=false;
  bool zero=false;
  ll sum=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=abs<ll>(A.at(i));
    if(A.at(i)>0){
      plus=true;
    }else if(A.at(i)<0){
      minus=true;
    }else{
      zero=true;
    }
  }
  sort(A.begin(),A.end());
  if((plus&&minus)||zero){
    int k=lower_bound(A.begin(),A.end(),0)-A.begin();
    cout<<sum<<endl;
    for(int i=k;i<N-1;i++){
      if(i==0){
        continue;
      }
      cout<<A.at(0)<<" "<<A.at(i)<<endl;
      A.at(0)-=A.at(i);
    }
    for(int i=0;i<k;i++){
      cout<<A.at(N-1)<<" "<<A.at(i)<<endl;
      A.at(N-1)-=A.at(i);
    }
    if(k==0){
      cout<<A.at(N-1)<<" "<<A.at(0)<<endl;
    }
  }else if(plus){
    cout<<sum-2*A.at(0)<<endl;
    for(int i=1;i<N-1;i++){
      cout<<A.at(0)<<" "<<A.at(i)<<endl;
      A.at(0)-=A.at(i);
    }
    cout<<A.at(N-1)<<" "<<A.at(0)<<endl;
  }else{
    cout<<sum+2*A.at(N-1)<<endl;
    for(int i=0;i<N-1;i++){
      cout<<A.at(N-1)<<" "<<A.at(i)<<endl;
      A.at(N-1)-=A.at(i);
    }
  }
}


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

int a,b,c,ans,n,k,r,g;


int  main()
{
    cin>>r>>g>>b>>n;
    for(int i=0;i<n+1;i+=r){
        if(i>n)break;
        for(int u=0;u<n+1;u+=g){
            if(u>n)break;
            int ll=n-i-u;
            if(ll<b&&ll!=0)continue;
            if(ll==0){
                ans++;
                continue;
            }
            if(ll%b==0&&ll/b!=0){
                //cout<<i<<" "<<u<<" "<<ll/b<<endl;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


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

int count(int n){
	int counter = 0;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < 10; k++){
				for(int l = 0; l < 10; l++){
					if((i + j + k + l) == n){
						counter++;
					}
				}
			}
		}
	}
	return counter;
}

int main(){
	vector<int> results;
	int n;
	while(cin >> n){
		results.push_back(count(n));
	}
	for(auto result : results){
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
n = int(input())
v = list(map(int, input().split()))

from collections import Counter
def solve():
    a1 = Counter(v[i] for i in range(0,n,2)).most_common(2)
    a2 = Counter(v[i] for i in range(1,n,2)).most_common(2)

    n1 = a1[0][1]
    n2 = a2[0][1]

    if a1[0][0] == a2[0][0]:
        if len(a1) <= 1:
            if len(a2) > 1: n2 = a2[1][1]
            else: n2 = 0
        elif len(a2) <= 1:
            if len(a1) > 1: n1 = a1[1][1]
            else: n1 = 0
        elif n1 - a1[1][1] < n2 - a2[1][1]:
            n1 = a1[1][1]
        else:
            n2 = a2[1][1]
    print(n-n1-n2)

solve()

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

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

    if (d == 0)
    {
        cout << (double)1 / n * (m - 1) << endl;
        return 0;
    }

    long long plus = max(0ll, n - d);
    long long minus = max(0ll, n - (1 + d) + 1);
    long long dbl = plus + minus - n;
    long long sgl = n - dbl;
    long long numerator = (m - 1) * (sgl + 2 * dbl);
    long long denominator = n * n;
    // cout << sgl << " " << dbl << endl;
    // cout << (double)numerator / denominator << endl;
    // cout << numerator << " " << denominator << endl;
    cout << fixed << setprecision(7) << ((double)sgl / n / n + (double)dbl * 2 / n / n) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int xx[n], yy[m];
  for(int i = 0; i < n; i++) cin >> xx[i];
  for(int i = 0; i < m; i++) cin >> yy[i];

  int mx = x;
  for(int i = 0; i < n; i++){
    mx = max(mx, xx[i]);
  }
  int mi = y;
  for(int i = 0; i < m; i++){
    mi = min(mi, yy[i]);
  }

  if(mi - mx >= 1) cout << "No War" << endl;
  else cout << "War" << endl;

  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int A[100000];
	int ichi0;
	rep(i, N) {
		cin >> A[i];
		if (A[i] == 1) ichi0 = i;
	}
	int kotae = (N - 1) / (K - 1) + 1;
	if ((N - 1) % (K - 1) == 0) kotae--;
	cout << kotae << "\n";
	Would you please return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int N, K; cin >> N >> K;
    string S;  cin >> S;

    S[K-1] = S[K-1] + 0x20;
    print(S);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, Q;
  cin >> N >> M >> Q;

  int L[200010], R[200010], X[510][510], C[510][510];
  for (int i = 1; i <= M; i++) {
    cin >> L[i] >> R[i];
    X[L[i]][R[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      C[i][j] = C[i][j - 1] + X[i][j];
    }
  }
  for (int i = 1; i <= Q; i++) {
    int p, q;
    cin >> p >> q;
    int sum = 0;
    for (int j = p; j <= q; j++)
      sum += C[j][q] - C[j][p - 1];
    cout << sum << endl;
  }
  return 0;
}

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

int main(){
    int n, k;

    while(cin >> n >> k, n != 0 && k != 0){
        bool flug = false;
        vector<int> blood_stock(k);
        for(int i=0; i<k; i++){
            cin >> blood_stock[i];
        }
        for(int i=0; i<n; i++){
            for(int j=0; j<k; j++){
                int tmp;
                cin >> tmp;
                blood_stock[j] -= tmp;
            }
        }

        for(int i=0; i<k; i++){
            if(blood_stock[i] < 0){
                cout << "No" << endl;
                flug = true;
                break;
            }
        }
        if(flug == false){
            cout << "Yes" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 892
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = 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 SORT(V) sort((V).begin(),(V).end())
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define int long long

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// 変数定義
int k,n;
//

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> k >> n;
  if(500*k >= n) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, k, a[200010], psa[200010], idx, mx;
double ans;
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        psa[i] = a[i] + psa[i - 1];
    }
    for (int i = k; i <= n; i++){
        if (psa[i] - psa[i - k] > mx){
            mx = psa[i] - psa[i - k];
            idx = i - k + 1;
        }
    }
    for (int i = idx; i < idx + k; i++){
        ans += (double)(a[i])*(a[i] + 1) / 2.0 / (double)a[i];
    }
    printf("%.7f", ans);
}

Measured memory_bytes: 3456
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(){
  int h,w;
  while(true){
    cin >> h >> w;
    if(h == 0 && w == 0)
      break;
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        if(i==0 || i==h-1 || j==0 || j==w-1)
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define N 200010
using namespace std;
 
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge{int v,next;}vs[N<<1];
int n,ee,st[N<<1],du[N],Rt,F[N];
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}

inline bool cmp(int a,int b){return F[a]<F[b];}

inline bool dfs(int rt,int pr,int x)
{
	vector <int> v; v.clear();
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		if(!dfs(vs[i].v,rt,x)) return false;
		v.push_back(vs[i].v);
	}
	if(v.size()==0){
		F[rt]=1;
		return true;
	}
	if(du[rt]&1) v.push_back(0);
	sort(v.begin(),v.end(),cmp);
	// printf("son of node %d len of %d\n",rt,x);
	// for(int i=0;i<v.size();i++) printf("%d ",v[i]); puts("");
	int l=0,r=v.size()-1;
	while(l<=r)
	{
		int mid=(l+r)>>1,fg=1;
		for(int i=0,j=v.size()-1;i<j;i++,j--)
		{
			if(i==mid) i++; if(j==mid) j--;
			int tmp1=F[v[i]],tmp2=F[v[j]];
			fg&=(tmp1+tmp2)<=x;
		}
		if(fg) r=mid-1;
		else l=mid+1;
	}
	if(l==v.size()) return false;
	F[rt]=F[v[l]]+1;
	return F[rt]<=x+1;
}
inline bool check(int x)
{
	return dfs(Rt,0,x);
}
int main()
{
	// freopen("read.in","r",stdin);
	n=read(); for(int i=1;i<n;i++)
	{
		int u=read(), v=read();
		addedge(u,v); du[u]++;
		addedge(v,u); du[v]++;
	}
	int cnt=0; for(int i=1;i<=n;i++) 
		cnt+=du[i]&1,Rt=du[i]==1? i:Rt;
	//Rt=1;
	int l=1,r=n;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1;
		else l=mid+1;
	}
	cout << cnt/2 << " " << l << endl;
	return 0;
}

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

from functools import reduce

def gcd(a, b):
    while b:
      a, b = b, a % b
    return a

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

N = input()
a_list = map(int, input().split())
a_list = list(a_list)

m = lcm(a_list) - 1
fm = 0

for i in a_list:
    fm = fm+(m % i)

print(fm)

Measured memory_bytes: 3812
el,dl = map(int,input().split())
es=list(map(int,input().split()))
es.sort()
#print(es)
ds=[]
for _ in range(dl):
  d = list(map(int,input().split()))
  ds.append(d)
ds.sort(key=lambda d: -d[1])
#print(ds)
fs=[]
for b,c in ds:
  for _ in range(b):
    fs.append(c)
  if len(fs)>el:
    break
re=0
for ei in range(el):
  if ei>=len(fs):
    re += es[ei]
  else:
    re += max(es[ei],fs[ei])
print(re)

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

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

    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;

    int sumAB = 0, sumB = 0;
    for (auto &c : S) {
        if (c == 'a') {
            if (sumAB < A + B) {
                cout << "Yes" << endl;
                sumAB++;
            } else {
                cout << "No" << endl;
            }
        } else if (c == 'b') {
            if (sumAB < A + B && sumB < B) {
                cout << "Yes" << endl;
                sumAB++;
                sumB++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 848
use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty), +) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn check_num(x: u64) -> bool {
    let ret = x%3 == 0;
    if ret {
        print!(" {}", x);
    }
    ret
}

fn include3(i: u64, x: u64) {
    if x%10 == 3 {
        print!(" {}", i);
        return;
    }
    if x/10 != 0 {
        include3(i, x/10);
    }
}

fn main() {
    from_line!(n: u64);

    for i in 1..n+1 {
        if !check_num(i) {
            include3(i, i);
        }
    }
    print!("\n");
}


Measured memory_bytes: 5028
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();
            int A = in.nextInt();
            int B = in.nextInt();
            System.out.println(B <= A ? "delicious" : (B - A) <= X ? "safe" : "dangerous");
        }
    }
}


Measured memory_bytes: 27088
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;


void solve(){
	int a ;
	string b ;
	cin >> a >> b ;
	int bef = b[0]-'0' ;
	int aft = (b[2]-'0')*10+(b[3]-'0') ;
	int ans = a * (bef*100+aft)/100 ;
	cout << ans << endl ; 
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
}


Measured memory_bytes: 3656