akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	while(1){
		int a=-1,b;
		int dt[101]={0};
		while(cin>>a>>b && a||b){
			dt[a]++;
			dt[b]++;
		}
		if(a==-1)return 0;
		bool flg=true;
		int sum=0;
		if(dt[1]%2==0 || dt[2]%2==0)flg=false;
		loop(i,3,101)if(dt[i] && dt[i]%2==1){flg=false;break;}
		cout<<((flg)?"OK":"NG")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000
typedef long long i64;

int n, m;
int s, t;

int input() {
	if (scanf("%d %d", &n, &m) < 0) return 0;
	s = 0, t = n;
	for (int i=0; i<m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (a>s) s = a;
		if (b<t) t = b;
	}
	return 1;
}

void init() {
}

int solve() {
	return max(0, t-s+1);
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7; // 998244353
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	int H, W; cin >> H >> W;
	VVS S(H, VS(W));
	REP(i, H)REP(j, W) cin >> S[i][j];
	REP(i, H)REP(j, W) if (S[i][j] == "snuke") cout << char('A' + j) << i + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll=long long;
signed main()
{
	ll X; cin >> X;
	X = abs(X);
	ll ok = numeric_limits<ll>::max();

	auto is_larger = [](auto a, ll X) {
		return double(1.) * 0.5 * a * (a+1) >= X;
	};
	
	ll ng = 0;
	ll mid = (ok+ng)/2;
	while (abs(ok-ng) > 1) {
		if ( is_larger( mid, X) )  {
			ok = mid;
		} else ng = mid;
		mid = (ok+ng)/2;
	}
	cout << ok << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

type p struct {
	x, y int
}

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, n)
	ys := make([]int, n)
	for i := range xs {
		fmt.Scan(&xs[i], &ys[i])
	}

	cnt := make(map[p]int)
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			cnt[p{x: xs[i] - xs[j], y: ys[i] - ys[j]}]++
			cnt[p{x: xs[j] - xs[i], y: ys[j] - ys[i]}]++
		}
	}

	max := 0
	for _, v := range cnt {
		if v > max {
			max = v
		}
	}
	fmt.Println(n - max)
}


Measured memory_bytes: 896
n,k = list(map(int,input().split()))
r,s,p = list(map(int,input().split()))
t = input()

ans = 0
counter = [{v:0 for v in "rsp"} for i in range(k)]

for i in range(n):
    if t[i] == 'r':
        counter[i%k]['r'] += 1
        counter[i%k]['s'] = 0
        counter[i%k]['p'] = 0
        if counter[i%k]['r'] %2 == 1:
            ans += p
    if t[i] == 's':
        counter[i%k]['s'] += 1
        counter[i%k]['r'] = 0
        counter[i%k]['p'] = 0
        if counter[i%k]['s'] %2 == 1:
            ans += r
    if t[i] == 'p':
        counter[i%k]['p'] += 1
        counter[i%k]['s'] = 0
        counter[i%k]['r'] = 0
        if counter[i%k]['p'] %2 == 1:
            ans += s
print(ans)


Measured memory_bytes: 76380
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define deb(a) cout<<#a<<" "<<a<<endl
#define WW 100000
#define INF 1000000000000000000 //1e18
#define EPS 0.000000001 //1e-9
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({_,......,_}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
//reverse(all(v)) would reverse a vector  
//pow(10.0, 2.0) can give exactly 100.0, slightly greater, or slightly less. 
//Therefore use(int)(pow(10.0,zz)+EPS)
int32_t main()
{
    IOS;
    int n; cin>>n;
    int f[n+1]={};
    for(int i=2;i<=n;i++)
    {
        int x; cin>>x; f[x]++;
    }
    for(int i=1;i<=n;i++)
        cout<<f[i]<<endl;
    return 0;
}

Measured memory_bytes: 5180
def read_input():
    n = int(input())
    return n

def div_2(x, memo):
    # memoに答えがあれば返す
    if x in memo.keys():
        return memo[x], memo

    if x % 2 == 0:
        c, memo = div_2(x/2, memo)
        count = 1 + c
        memo[x] = count
        return count, memo

    return 0, memo

def submit():
    n = read_input()

    div_memo = {}
    for i in range(1, n + 1):
        _, div_memo = div_2(i, div_memo)

    counts = list(div_memo.items())
    counts.sort(key=lambda x:x[1], reverse=True)

    if not counts:
        print(1)
    else:
        print(counts[0][0])

if __name__ == '__main__':
    submit()

Measured memory_bytes: 38640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

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

    int dp[2][5][1000]={};
    dp[1][0][0]=0;
    dp[1][1][0]=1;
    dp[1][2][0]=0;
    dp[1][3][0]=0;
    dp[0][0][0]=1;
    dp[0][1][0]=int(N[0]-'1');
    dp[0][2][0]=0;
    dp[0][3][0]=0;

    rep(i,1,N.size()){
        if(N[i] == '0'){
            rep(j,0,4){
                dp[1][j][i]=dp[1][j][i-1];
            }
        }
        else{
            rep(j,1,4){
                dp[1][j][i]=dp[1][j-1][i-1];
            }
        }
    }

    rep(i,0,N.size()-1){
        rep(j,0,4){
            dp[0][j][i+1] += dp[0][j][i]; 
            dp[0][j+1][i+1] += dp[0][j][i]*9;
            if(N[i+1] != '0'){
                dp[0][j][i+1] += dp[1][j][i];
                dp[0][j+1][i+1] += dp[1][j][i]*int(N[i+1]-'1');
            }
        }
    }

    cout<<dp[0][K][N.size()-1] + dp[1][K][N.size()-1]<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
numl = [0] * 4
for i in range(n):
    s = input()
    if(s == "AC"):
        numl[0]+=1
    elif(s ==  "WA"):
        numl[1]+=1
    elif(s == "TLE"):
        numl[2]+=1
    else:
        numl[3]+=1
print("AC x "+str(numl[0]))
print("WA x "+str(numl[1]))
print("TLE x "+str(numl[2]))
print("RE x "+str(numl[3]))

Measured memory_bytes: 69820
// D - Candidates of No Shortest Paths

// 各頂点からDijkstra法でその他の全ての頂点への最短経路を求め、
// その時に使われる辺をチェックする解法
// 計算量: O(N*M*logN))

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 922337203685477580;
// const ll MOD = 1e9 + 7;

const int N_MAX = 100;
const int M_MAX = 1000;
const ll INF = 1000000;
const int NIL = -1;
const int UNCONF = 0;
const int CONF = 1;

// 辺
struct Edge {
	int next;
	int cost;
};

// 頂点
struct Node {
	vector<Edge> edges;
	int status;
	int min_cost;
};

// 候補となる経路（最短経路を記録するために移動元を保持）
struct Candidate {
	int next_cost;
	int next_idx;
	int from_idx;
};

// ダイクストラ法（優先度付きキューを使用）
// n: ノード数, start_idx: 開始ノードのインデックス
void Dijkstra(Node nodes[], int n, int start_idx, map<pair<int, int>, bool>& used) {
	for (int i=0; i<n; i++) {
		nodes[i].status = UNCONF;
		nodes[i].min_cost = INF;
	}

	nodes[start_idx].min_cost = 0;

	// PQ: Candidateを格納する優先度付きキュー（next_costが小さいもの優先）
	auto cmp = [](Candidate &a, Candidate &b) {
		return a.next_cost > b.next_cost; // 昇順
	};
	priority_queue<Candidate, vector<Candidate>, decltype(cmp)> PQ(cmp);

	Candidate candidate = {
		.next_cost = 0,
		.next_idx = start_idx,
		.from_idx = start_idx
	};
	PQ.push(candidate);

	while (!PQ.empty()) {
		Candidate candidate = PQ.top();
		PQ.pop();

		// 他にコストの低いルートがあれば使わない
		if (candidate.next_cost > nodes[candidate.next_idx].min_cost) continue;

		// このルートを採用
		int idx = candidate.next_idx;
		int from_idx = candidate.from_idx;
		nodes[idx].status = CONF;

		// ルートを記録
		if (from_idx < idx) {
			used[make_pair(from_idx, idx)] = true;
		} else {
			used[make_pair(idx, from_idx)] = true;
		}

		// 隣接する頂点のmin_costを更新し、キューに入れる
		for (Edge edge : nodes[idx].edges) {
			int next_idx = edge.next;
			int next_cost = nodes[idx].min_cost + edge.cost;
			if (nodes[next_idx].status != CONF) {
				if (next_cost < nodes[next_idx].min_cost) {
					nodes[next_idx].min_cost = next_cost;
				}

				Candidate candidate = {
					.next_cost = next_cost,
					.next_idx = next_idx,
					.from_idx = idx
				};
				PQ.push(candidate); // 候補としてキューに入れる
			}
		}
	}
}

Node nodes[N_MAX];
map<pair<int, int>, bool> used;

int main() {
	int N, M;
	cin >> N >> M;

	int a, b, c;
	for (int i=0; i<M; i++) {
		cin >> a >> b >> c;
		a--;
		b--;
		nodes[a].edges.push_back(Edge{b, c});
		nodes[b].edges.push_back(Edge{a, c});

		if (a < b) {
			used[make_pair(a, b)] = false;
		} else {
			used[make_pair(b, a)] = false;
		}
	}

	for (int i=0; i<N; i++) {
		Dijkstra(nodes, N, i, used);
	}

	int ans = 0;
	for (auto itr=used.begin(); itr!=used.end(); itr++) {
		if (itr->second == false) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
 int a,b,c,d;
  cin >> a >> b >> c >> d;
   int res = 0;
  for (int A = 0; A <= a; ++A) {
    for (int B = 0; B <= b; ++B) {
      for (int C = 0; C <= c; ++C) {
        int total = 500*A + 100*B + 50*C;
        if(total==d){
          res++;
        }
      }
    }
  }
  cout << res << endl;
  
}


Measured memory_bytes: 256
h, n = map(int, input().split())
dp = [1000000000] * (h+1)
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    for j in range(h):
        # nj = min(j + a, h)
        if j + a < h: nj = j + a
        else: nj = h
        # dp[nj] = min(dp[nj], dp[j] + b)
        if dp[nj] > dp[j] + b: 
            dp[nj] = dp[j] + b
print(dp[h])

Measured memory_bytes: 43108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int a, b, c, d, flag=0;
    cin >> a >> b >> c >> d;
    while (1){
        if(flag == 0){
            c -= b;
            flag = 1;
        }else if(flag == 1){
            a -= d;
            flag = 0;
        }if(c <= 0 || a <= 0) break;
    }
    if(a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nab = ReadIntArray();
            var n = nab[0];
            var a = nab[1];
            var b = nab[2];
            var v = ReadLongArray().OrderByDescending(x => x).ToArray();
            var average = v.Take(a).Average();
            Console.WriteLine($"{average.ToString("0.000000")}");

            var last = v.Take(a).Last();
            var count = v.Count(x => x == last);
            var need = v.Take(a).Count(x => x == last);
            long pattern = 0;
            if (v.Take(a).All(x => x == last))
            {
                for (int i = a; i <= b; i++)
                {
                    pattern += Combination(count, i);
                }
            }
            else
            {
                pattern = Combination(count, need);
            }
            Console.WriteLine($"{pattern}");
        }

        static long Combination(long n, long r)
        {
            long value = 1;
            for (long i = 1; i <= r; i++)
            {
                value *= n;
                n--;
                value /= i;
            }
            return value;
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13524
// https://atcoder.jp/contests/abc154/tasks/abc154_f
// AtCoder Beginner Contest 154
// F - Many Many Paths

/*
Problem.
f(r,c):点(0,0)から点(r,c)までx,yどちらかの正方向に1ずつ移動する時、移動経路の個数。
r1,r2,c1,c2が与えられ、r1<=r<=r2, c1<=c<=c2の整数の組(r,c)について、
f(r,c)の総和を答えよ。(MOD:1e9+7)

Point.
経路の総数の計算問題。
f(r2, c+1) = sum(f(0~r2, c))であることに注目。
また、f(r, c) = r+cCr 
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>

using namespace std;

const int maxn = 3000000;
int fac[maxn], invfac[maxn];

#define MOD 1000000007
long long qpow(long long a, long long b){
    long long s = 1;
    while (b > 0) {
        if (b & 1)s = s * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return s;
}
void init() {
    int n = maxn - 1;
    fac[0] = 1;
    for (int i = 1; i <= n; ++i)
        fac[i] = 1ll * fac[i - 1] * i % MOD;
    invfac[n] = qpow(fac[n], MOD - 2);
    for (int i = n - 1; i >= 0; --i) {
        invfac[i] = 1ll * invfac[i + 1] * (i + 1) % MOD;
    }
}
long long comb(int n, int m) {
    if (n < m) return 0;
    return 1ll * fac[n] * invfac[m] % MOD * invfac[n - m] % MOD;
}

int main(){
  int ti = clock();
  init();
  long long r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  long long g11 = 0;
  long long g12 = 0;
  long long g21 = 0;
  long long g22 = 0;
  for(int i = 0; i < r2+1; i++){
    g22 += comb(i+1+c2, c2);
    g22 %= MOD;
  }
  for(int i = 0; i < r2+1; i++){
    g21 += comb(i+1+c1-1, c1-1);
    g21 %= MOD;
  }
  for(int i = 0; i < r1; i++){
    g12 += comb(i+1+c2, c2);
    g12 %= MOD;
  }
  for(int i = 0; i < r1; i++){
    g11 += comb(i+1+c1-1, c1-1);
    g11 %= MOD;
  }

  cout << (g22 - g12 - g21 + g11 + MOD * 2) % MOD << endl;
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 23680
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, K;
int day[128];
int dp[128][4][4];

int dfs(int n, int pprev, int prev){
  if(n==N) return 1;
  int &res = dp[n][pprev][prev];
  if(res >= 0) return res;
  res = 0;
  if(day[n]){
    if(day[n]!=pprev || day[n]!=prev) res = (res+dfs(n+1, prev, day[n]))%10000;
  }else{
    for(int i=1;i<=3;i++){
      if(i==pprev && i==prev) continue;
      res = (res+dfs(n+1, prev, i))%10000;
    }
  }
  return res;
}

int main(){
  scanf("%d%d", &N, &K);
  memset(day, 0, sizeof(day));
  memset(dp, -1, sizeof(dp));
  int A, B;
  rep(i, K){
    scanf("%d%d", &A,&B); A--;
    day[A] = B;
  }
  printf("%d\n", dfs(0, 0, 0));
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <fstream>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int bt[2000000];

int update(int c, int i, int node, int rangeL, int rangeR) {
    if (i < rangeL || i >= rangeR) return bt[node];
    if (rangeL + 1 == rangeR && rangeL == i) {
        bt[node] = (1 << c);
        return bt[node];
    }
    int rangeM = (rangeL + rangeR) / 2;
    int r1 = update(c, i, node * 2, rangeL, rangeM);
    int r2 = update(c, i, node * 2 + 1, rangeM, rangeR);
    bt[node] = r1 | r2;
    return bt[node];
}

int query(int qL, int qR, int node, int rangeL, int rangeR) {
    if (qL >= rangeR || qR <= rangeL) return 0;
    if (qL <= rangeL && rangeR <= qR) return bt[node];
    int rangeM = (rangeL + rangeR) / 2;
    return query(qL, qR, node * 2, rangeL, rangeM) | query(qL, qR, node * 2 + 1, rangeM, rangeR);
}

int main() {
    int n, q, d;
    string s;
    cin >> n >> s >> q;
    for (int i = 0; i < n; i++) {
        update(s[i] - 'a', i, 1, 0, 500000);
    }
    for (int i = 0; i < q; i++) {
        cin >> d;
        if (d == 1) {
            int i2;
            char c;
            cin >> i2 >> c;
            update(c - 'a', i2 - 1, 1, 0, 500000);
        } else {
            int l, r, c = 0;
            cin >> l >> r;
            int v = query(l - 1, r, 1, 0, 500000);
            for (int j = 0; j < 26; j++) {
                if (v & (1 << j)) c++;
            }
            cout << c << endl;
        }
    }
}

Measured memory_bytes: 7044
#include <cstdio>
#include <string>
using namespace std;

string s;
char t[100001];

int main(){
	scanf("%s", t);
	s = t;

	while(s.size() > 7){
		string p = s.substr(s.size() - 7, 7);
		string q = s.substr(s.size() - 6, 6);
		string r = s.substr(s.size() - 5, 5);
		if(p == "dreamer"){
			s = s.substr(0, s.size() - 7);
		}else if(q == "eraser"){
			s = s.substr(0, s.size() - 6);
		}else if(r == "dream" || r == "erase"){
			s = s.substr(0, s.size() - 5);
		}else{
			break;
		}
	}
//	printf("%s\n", s.c_str());
	if(s == "dream" || s == "dreamer" || s == "erase" || s == "eraser"){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int X; cin >> X;
    if(X>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    //[0] import
    int D,N; // 100で D回 割り切れる. 1<=N<=100番目
    cin >> D >> N;

    //[1] main logic
    if(N<100) {
        int res = N * pow(100,D);
        cout << res << '\n';
    }
    else if(N==100) {
        int res = (N+1) * pow(100,D);
        cout << res << endl;
    }
}

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

bool rec(int node,int c){
    bool res = true;
    rep(i,n){
        if(v[node][i]==1){
            if(color[i]==0){
                color[i] = -c;
                res = res&&rec(i,-c);
            }
            else if(color[i]!=-c){
                res=false;
            }
        }
    }
    return res;
}
int main(){
    cin >> n;
    rep(i,n){
        rep(j,n){
            d[i][j] = 1e9;
        }
    }
    rep(i,n){
        string s;
        cin >> s;
        rep(j,n){
            v[i][j]=s[j]-'0';
            if(v[i][j]==1){
                d[i][j]=1;
            }
        }
    }
    color[0] = 1;
    bool flag = rec(0,1);
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans = 1;
    rep(i,n){
        rep(j,n){
            if(d[i][j]<n){
                ans = max(ans,d[i][j]);
            }
        }
    }
    if(flag){
        cout << ans+1 << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main()
{
	int n, k, x, y;
	int res = 0;
	cin >> n >> k >> x >> y;
	for (int i = 1; i <= n; i++)
	{
		if (i <= k)
		{
			res += x;
		}
		else
		{
			res += y;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
S = input("")

S1 = str(S[-1])
S2 = str(S[-2])
S3 = str(S[-3])
S4 = str(S[-4])

n = 0

if S1 == S2:
    n += 1
if S3 == S4:
    n += 1

if n == 2:
    print("Yes")
else:
    print("No")


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

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

  int date;
  int sum = 0;
  for(int i = 0; i < m; i++) sum += a[i];
  date = n - sum;
  if (date < 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << date << endl;
}


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

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    
    vector<int> a(n, 0);
    rep(i, n-1) {
        if (s[i] == 'A' && s[i+1] == 'C') {
            a[i] = 1;
        } 
    }


    vector<int> v(n+1);
    rep(i, n) v[i+1] = v[i] + a[i];
    
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        cout << v[r] - v[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            consoleReader.ReadLine();
            var As = consoleReader.ReadLineSplitInt32();

            bool evenMinus;
            int min = (evenMinus = (As[0] >= 0)) ? As[0] : -As[0];

            long res = 0;

            for (int i = 1; i < As.Length; i++)
            {
                int a = As[i];
                if(a < 0)
                {
                    evenMinus = !evenMinus;
                    a = -a;
                }


                if (a < min)
                {
                    res += min;
                    min = a;
                }
                else
                {
                    res += a;
                }
            }

            if (evenMinus)
            {
                res += min;
            } else
            {
                res -= min;
            }

            return res;
        }

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader)
        {
            this.consoleReader = consoleReader;
        }
        static void Main() => Console.WriteLine(new Program().Calc());
    }

    public class ConsoleReader
    {
        public virtual string ReadLine() => Console.ReadLine();
        public int ReadLineInt32() => int.Parse(ReadLine());
        public long ReadLineInt64() => long.Parse(ReadLine());
        public ulong ReadLineUInt64() => ulong.Parse(ReadLine());
        public double ReadLineDouble() => double.Parse(ReadLine());
        public string[] ReadLineSplit() => ReadLine().Split().ToArray();
        public int[] ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public long[] ReadLineSplitInt64() => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public ulong[] ReadLineSplitUInt64() => ReadLine().Split().Select(s => ulong.Parse(s)).ToArray();
        public double[] ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToArray();

        public IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        public IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        public IEnumerable<string[]> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
    static class DicExt
    {
        public static double GetOrDefault(this Dictionary<int, double> dic, int key)
        {
            double val;
            return dic.TryGetValue(key, out val) ? val : 1;
        }
    }
}


Measured memory_bytes: 32220
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll mod_pow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1)res=res*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return res;
}

ll inverse_element(ll t){
	return mod_pow(t,MOD-2);
}

ll x,y;
int main(){
	cin>>x>>y;
	if(!((-1*x+2*y)%3==0&&((2*x-y)%3==0))){
		cout<<0<<endl;
		return 0;
	}
	ll a=-x/3+2*y/3;
	ll b=2*x/3-y/3;
	if(a<0||b<0){
		cout<<0<<endl;
		return 0;
	}
	ll ans=1;
	for(ll i=b+1;i<=a+b;i++){
		ans=ans*i;
		ans%=MOD;
	}
	for(ll i=1;i<=a;i++){
		ans=ans*inverse_element(i);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
 	ll n;
 	ll ans=0,i=1;
 	cin>>n;
 	while(i<=n)
 	{
 		if(i%3&&i%5)
 			ans+=i;
 		i++;
 	} 
 	deb(ans);
}

Measured memory_bytes: 3652
def main():
    H, N = map(int, input().split())
    ab = []
    for _ in range(N):
        ab.append(list(map(int, input().split())))
    dp = [0] * (H + max([a for a, _ in ab]))
    for i in range(1, H+1):
        dp[i] = min([dp[i-a] + b for a, b in ab])
    print(dp[H])


if __name__ == "__main__":
    main()


Measured memory_bytes: 9476
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int tanku[] = {5, 7, 5, 7, 7};

void solve()
{
	int n;
	while (cin >> n, n)
	{
		vector<int> w(n);
		for (int i = 0; i < n; ++i)
		{
			string s;
			cin >> s;
			w[i] = s.size();
		}
		for (int i = 0; i < n; ++i)
		{
			int pos = 0;
			int cnt = 0;
			for (int j = i; j < n; ++j)
			{
				cnt += w[j];
				if (cnt == tanku[pos])
				{
					++pos;
					cnt = 0;
				}
				if (pos >= 5 || cnt > tanku[pos])
				{
					break;
				}
			}
			if (pos == 5)
			{
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1208
N = gets.to_i
dp = Array.new(N+1){N}
dp[0] = 0
1.upto(10) do |i|
  [6**i, 9**i].each do |d|
    0.upto(N-d) do |j|
      dp[j+d] = [dp[j+d], dp[j]+1].min
    end
  end
end
N.times do |j|
  dp[j+1] = [dp[j+1], dp[j]+1].min
end
p dp[N]


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}
#define run_time cout << "\nTIME = " << clock() - tt << endl; tt = clock();

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,vi> g;
unordered_map<ll,ll> vis;
ll tt;
const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 2e5+10;
ll dx[4]={-1, +1, 0, 0};
ll dy[4]={0, 0, +1, -1};
bool imp = false;



void solve() {

    ll n;cin>>n;
    ll ans = n + (n*n ) + (n*n*n);
    cout<<ans<<endl;


}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    fio
    int t=1;
    if(imp) cin>>t;
    tt = clock();
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }
//    run_time;

}


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


bool used[500][500];

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

    
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll l=0,r=0;
    if(s[0]=='W' || s[2*n-1]=='W'){
        cout<<0<<endl;
        return 0;
    }
    bool left[n*2]={};

    for(ll i=0;i<n*2;i++){
        if(s[i]=='B'){
            if((l-r)%2==0){
                l++;
                left[i]=1;
            }
            else r++;
        }
        else{
            if((l-r)%2==0){
                r++;
            }
            else {
                l++;
                left[i]=1;
            }
        }
    }
    l=0,r=0;
    ll ans = 1;
    ll mod = 1e9+7;
    for(ll i=0;i<2*n;i++){
        //cerr<<left[i]<<" ";
        if(left[i]) l++;
        else{
            ans *= l;
            l--;
            ans %= mod;
        }
        if(l<0){
            cout<<0<<endl;
            return 0;
        }
    }
    if(l){
        cout<<0<<endl;
        return 0;
    }
    //cerr<<endl;
    for(ll i=1;i<=n;i++){
        ans *= i;
        ans %= mod;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<ll>> dp(n,vector<ll>(3,0));
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    for(int i = 1; i < n; i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]) << endl;

}


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

int main()
{
	int n;
	set<string> a;
	string cmd, str;
	
	cin>>n;
	for(int i = 0; i < n; i++)
	{
		cin>>cmd>>str;
		if(cmd.compare("insert") == 0)
			a.insert(str);
		else
		{
			if(a.find(str) != a.end())
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
	}
}


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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for(int i = 1 ; i <= n ; i++){
    int res = i, k = 0;
    while(res > 0){
      k += res % 10;
      res /= 10;
    }
    if(a <= k && k <= b){
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    cout << n*(n-1)/2<< endl;
    return 0;
}

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

int main(){
    long long n;
    cin >> n;
    
    if (n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }
    
    n /= 2;
    
    long long ans = 0;
    
    while(n){
        ans += n / 5;
        n /= 5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def func(s, i):
    return s[:i] + '*' + s[i+1:]


N = int(input())
A = input()
B = input()
C = input()

for i in range(N):
    if A[i] == B[i] == C[i]:
        A = func(A, i)
        B = func(B, i)
        C = func(C, i)
    elif A[i] == B[i]:
        A = func(A, i)
        B = func(B, i)
    elif A[i] == C[i]:
        A = func(A, i)
        C = func(C, i)
    elif B[i] == C[i]:
        B = func(B, i)
        C = func(C, i)

ans = 0
for j in range(N):
    if A[j] == B[j] == C[j]:
        continue
    elif A[j] != B[j] and A[j] != C[j] and B[j] != C[j]:
        ans += 2
    elif A[j] == B[j] or A[j] == C[j] or B[j] == C[j]:
        ans += 1

print(ans)


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop(i,b,n) for(int i=b;i<(n);++i)
#define each(e,v) for(auto &&e : v)

#define all(v) (v).begin(),(v).end()
#define sz(v) (int)v.size()

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const double EPS = 1e-9;
const ll MOD = 1000000007;

template<typename A,typename B> inline void chmin(A &a,B b){ if(a>b) a=b; }
template<typename A,typename B> inline void chmax(A &a,B b){ if(a<b) a=b; }
template <typename T> inline void print(const T& x) { cout << x << endl; }

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

    int ac_count = 0;
    int wa_count = 0;
    int tle_count = 0;
    int re_count = 0;
    for(int i=0; i<n; ++i){
        string s;
        cin >> s;
        if(s=="AC") ++ac_count;
        else if(s=="WA") ++wa_count;
        else if(s=="TLE") ++tle_count;
        else if(s=="RE") ++re_count;
    }

    cout << "AC x " << ac_count << endl;
    cout << "WA x " << wa_count << endl;
    cout << "TLE x " << tle_count << endl;
    cout << "RE x " << re_count << endl;

    return 0;
}

Measured memory_bytes: 3628
n=int(input())
a=sorted(list(map(int,input().split())))
d={}
for i in a:
  if i in d:
    d[i]+=1
  else:
    d[i]=1
q=int(input())
ans=sum(a)
for i in range(q):
  b,c = map(int,input().split())
  if b in d:
    ans+=d[b]*c
    ans-=d[b]*b
    print(ans)
    if c in d:
      d[c]+=d[b]
    else:
      d[c]=d[b]
    d[b]=0
  else:
    print(ans)

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int x, y;
  cin >> x >> y;
  vector<int> a = {1, 3, 5, 7, 8, 10, 12};
  vector<int> b = {4, 6, 9, 11};

  if (find(a.begin(), a.end(), x) != a.end()) {
    if (find(a.begin(), a.end(), y) != a.end()) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  if (find(b.begin(), b.end(), x) != b.end()) {
    if (find(b.begin(), b.end(), y) != b.end()) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int k = scanner.nextInt();
        final String s = scanner.next();

        if (s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
#define pi acos(-1)
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,h,k;cin>>a>>b>>h>>k;
	double jiao1=(double)h/12+double(k)/60/12,jiao2=double(k)/60;
	double dis=jiao1-jiao2;
	if(dis>0.5) dis=1-dis;
	dis*=2*pi;
	double ans=sqrt(a*a+b*b-2*a*b*cos(dis));
	cout<<fixed<<setprecision(15)<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define repi(i,n) for(int i=0; i<(n); i++)
int main() {
  vector<int> num(5);
  repi(i,5) cin >> num.at(i);

  repi(i,5) {
    if (num.at(i)==0) {
      cout << i+1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin>>S;

    if(S.size()>=4&&S.substr(0,4)=="YAKI"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    



}


Measured memory_bytes: 3624
import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    int K=s.nextInt();
    String S=s.next();

    if(S.length()<=K) System.out.println(S);
    else{
      for(int i=0;i<K;i++) System.out.print(S.charAt(i));
      System.out.println("...");
    }
  }  
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int maxn = 1e4 + 10;
int a[maxn], b[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i ++)
        scanf("%d", &a[i]);
    for(int i = 0; i < n; i ++)
        scanf("%d", &b[i]);

    LL need = 0, all = 0;
    for(int i = 0; i < n; i ++) {
        if(a[i] > b[i])
            need += (LL)a[i] - b[i];
        else
            all += ((LL)b[i] - a[i]) / 2LL;
    }
    return !printf(all >= need ? "Yes" : "No");
}


Measured memory_bytes: 384
using System;

namespace CSsample
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string input = Console.ReadLine();
            var H = input.Split();
            int num = 1;
            bool flag = false;
            for(int i = 1; i < N; i++)
            {
                for(int j = 0; j < i; j++)
                {
                    if (int.Parse(H[i]) < int.Parse(H[j]))
                    {
                        flag = true;
                    }
                }
                if(flag == false)
                {
                    num++;
                }
                flag = false;
            }
            Console.WriteLine(num);
        }
    }
}



Measured memory_bytes: 11092
#include <iostream>

 int main()
 {
 int in;
 std::cin >> in;

 int sec = in % 60;
 int min = ((in - sec) % 3600) / 60;
 int hour = (in - sec - min * 60) / 3600;
 std::cout << hour << ":" << min << ":" << sec << std::endl;

 return 0;
 }


Measured memory_bytes: 3116
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {
    val n = StdIn.readInt()
    val as = (1 to n).map(_ => StdIn.readInt()).toVector
    val maxis = (0 until n).foldLeft((0, 0)){(acc, i) =>
      if (as(i) > as(acc._1)) (i, acc._1)
      else if (as(i) > as(acc._2) || acc._1 == acc._2) (acc._1, i)
      else acc
    }
    (0 until n).foreach{ i =>
       val ans = if (i == maxis._1) as(maxis._2) else as(maxis._1)
       println(ans)       
    }
  }

}

Measured memory_bytes: 57944
N = int(input())
def zero(N):
    if N % 2 == 1:
        return 0
    else:
        return zero2(N)
def zero2(N):
    m = N//2
    n = 0
    i = 1
    while (5 ** i) <= m:
        n = n + (m //(5 ** i))
        i = i + 1
    return n
print(zero(N))

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

using namespace std;

#define S second
#define F first

typedef long long ll;

const int maxn = 22;
const int MASK = (1<<21)+2;
const int mod = 1e9+7;

int n;
int dp[MASK];
int a[maxn][maxn];

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            scanf("%d", &a[i][j]);

    dp[0] = 1;
    for(int mask = 1; mask < (1<<n); mask++)
    {
        int i = __builtin_popcount(mask)-1;
        for(int j = 0; j < n; j++)
            if(((1<<j) & mask) && a[i][j] == 1)
                (dp[mask] += dp[mask^(1<<j)]) %= mod;
    }

    int mask = (1<<n)-1;
    printf("%d", dp[mask]);
}





Measured memory_bytes: 8448
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

locale l = locale::classic();

int main(){
    int n,k;
    cin >> n >> k;
    cout << n-k+1 << endl;
}

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

#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    long X;
    cin >> X;

    cout << X / 500 * 1000 + (X % 500) / 5 * 5 << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    string  str;
    cin >> str;

    if(str[0] == str[1] || str[1] == str[2] || str[2] == str[3])
    {
        cout << "Bad" << endl;
    }
    else cout << "Good" << endl;


    return 0;
}



Measured memory_bytes: 256
essage = "Yes"# -*- coding: utf-8 -*-
"""
Created on Mon Aug 12 19:09:11 2019

@author: doppe
"""

N = int(input())
H = list(map(int, input().split()))
message = "Yes"
for i in range(0, N):
    if (i == 0 or H[i] > H[i - 1]):
        H[i] -= 1 
    elif (H[i] == H[i - 1]):
        continue
    else:
       message = "No"
       break

print(message)
        
        

Measured memory_bytes: 14704