akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

vector<int> divisor(int n){
    vector<int> res;
    for(int i=1;i*i<=n;i++){
    if(n%i==0){
            res.push_back(i);
            if(i!=n/i) res.push_back(n/i);
        }
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = 1;
    vector<int> d = divisor(m);
    rep(i, 0, d.size()){
        if(n * d[i] <= m){
            chmax(ans, d[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int S;
  cin >> S;
  
  int left = S/100;
  int right = S%100;
  
  string ret = "";
  
  // leftがYY確定
  if(left == 0 || left > 12){
    if(right == 0 || right > 12) ret = "NA";
    else ret = "YYMM";    

  // leftがMM確定
  }else{
    if(right == 0 || right > 12) ret = "MMYY";
    else ret = "AMBIGUOUS";
  }
  cout << ret << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int N=0,K=0,ans=1;
	scanf("%d\n%d",&N,&K);
	for(int i=0;i<N;i++)
	{
		if(ans*2>ans+K)
		{
			ans+=K;
		}else{
			ans*=2;
		}
	}
	printf("%d",ans);
	
	return 0;
}
	

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    if(n < 105){
        ans = 0;
    }else if(n < 135){
        ans = 1;
    }else if(n < 165){
        ans = 2;
    }else if(n < 189){
        ans = 3;
    }else if(n < 195){
        ans = 4;
    }else{
        ans = 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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(){
	char x;cin>>x;
	if (x >= 'a' && x<= 'z'){
		cout << 'a' << endl;
	}
	else{
		cout << 'A' << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    auto S = new string[](H);
    foreach (i; 0 .. H)
        S[i] = sread();
    foreach (h; 0 .. H)
        foreach (w; 0 .. W)
            if (S[h][w] == '#')
            {
                if (0 < h && S[h - 1][w] == '#')
                    continue;
                if (h + 1 < H && S[h + 1][w] == '#')
                    continue;
                if (0 < w && S[h][w - 1] == '#')
                    continue;
                if (w + 1 < W && S[h][w + 1] == '#')
                    continue;
                writeln("No");
                return;
            }
    writeln("Yes");
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
long long k;
  cin>>k;
  int t=7;
  int cnt=1;
  if(k %2 ==0 || k % 5==0)cout <<"-1"<<endl;
  else {
  while(t % k !=0){
    t=(t*10+7) % k;
    cnt++;

  }
  
  cout << cnt <<endl;
  }
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int n=0;
  
  for (int i; i<3; i++) {
    if (S.at(i)==T.at(i)) {
      n++;
    }
  }
  
  cout << n << endl;
}


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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((v).begin(), (v).end())
#define rvsort(v)          sort((v).rbegin(), (v).rend())
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

int main(int argc, char *argv[])
{
    int X, N;
    cin >> X >> N;
    vi p(N);
    rep(i, N) {
        cin >> p[i];
    }

    if (N == 0) {
        cout << X << endl;
        return 0;
    }
    if (X == 1) {
        cout << 0 << endl;
        return 0;
    }

    // vsort(p);

    vector<bool> v(102, true);
    rep(i, N) {
        v[p[i]] = false;
    }

    if (v[X]) {
        cout << X << endl;
        return 0;
    }

    int a;
    for (int i = X; i>=0; i--) {
        if (v[i]) {
            a = i;
            break;
        }
    }

    int b;
    for (int i = X; i<102; i++) {
        if (v[i]) {
            b = i;
            break;
        }
    }

    if (abs(X - a) == abs(X - b) || abs(X - a) < abs(X - b)) {
        cout << a << endl;
    } else {
        cout << b << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

LL N,W;
LL w[100],v[100];

LL ans = 0;
 
void solve(){
	//dp[i][j]=i個目までを見たときに
	//重みの総和がjになるような選び方があるなら
	//その価値の総和の最小値
	vector<vector<LL>> dp(N+1,vector<LL>(W+1,-1));
	dp[0][0] = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<W;j++){
			dp[i+1][j] = max(dp[i][j],dp[i+1][j]);//i個目を取らないとき
			//i個目をとるとき
			if(j+w[i]<=W){
				dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
				ans = max(ans,dp[i+1][j+w[i]]);
			}
		}
	}
}
 
int main(){
	cin >> N >> W;
	for(int i=0;i<N;i++) cin >> w[i] >> v[i];
 
	solve();
 
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		solve(a, b);

	}

	static void solve(int a, int b) {

		switch (a) {
		case 0:
			if (b == 100) {
				System.out.println(b + 1);
			} else {
				System.out.println(b);
			}
			break;
		case 1:
			int c = 100 * b;
			if (c == 10000) {
				System.out.println(c + 100);
			} else {
				System.out.println(c);
			}
			break;
		case 2:
			int d = 10000 * b;
			if (d == 1000000) {
				System.out.println(d + 10000);
			} else {
				System.out.println(d);
			}
			break;
		default:
			break;
		}
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n,0);
	int sm = 0;
	for(int i = 0;i < n;i++)
	{
		cin >> a.at(i);
		sm += a.at(i);
	}
	int av = sm / n;
	int kai1=0,kai2=0;
	for(int i = 0;i < n;i++)
	{
		kai1 += pow(a.at(i) - av,2);
		kai2 += pow(a.at(i) - av - 1,2);
	}
    cout << min(kai1,kai2) << endl;
}


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

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

  int tmp = 0, max = 0;

  for(int i = 0; i <= n; i++) {
    if (a[i] == 1 && tmp == 0) {
      tmp++;
      if (max < tmp) max = tmp;
    } else if (a[i] == 0) {
      if (max < tmp) max = tmp;
      tmp = 0;
    } else if (a[i] == 1 && tmp >= 1) {
      tmp += 1;
      if (max < tmp) max = tmp;
    }
  }
  cout << (max + 1) << endl;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <cstring>

int main()
{
    char match_word[20];
    char word[500];
    int match_count;

    match_count = 0;
    
    scanf(" %s", match_word);
    for (int i = 0; match_word[i] != '\0'; i++){
        if (match_word[i] >= 'A' && match_word[i] <= 'Z'){
            match_word[i] += 'a' - 'A';
        }
    }
    while (true){
        for (int i = 0; i < 500; i++){
            word[i] = '\0';
        }
        scanf(" %s", word);
        if (!strcmp(word, "END_OF_TEXT")){
            break;
        }
        for (int i = 0; word[i] != '\0'; i++){
            if (word[i] >= 'A' && word[i] <= 'Z'){
                word[i] += 'a' - 'A';
            }
        }
        if (!strcmp(word, match_word)){
            match_count++;
        }
    }

    printf("%d\n", match_count);

    return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int n[2],m[2],k;
	cin>>n[0]>>n[1]>>m[0]>>m[1]>>k;
	puts(m[0]*60+m[1]-(n[0]*60+n[1])-k);
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
/*
*/
//using Graph = vector<bitset<10>>;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<ll>>;


int main(){
  ll N,Q;
  cin >> N >> Q;
  Graph G(N+1);
  rep(i,N-1){
    ll a,b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<ll> p(Q),x(Q);
  rep(i,Q){
    cin >> p[i] >> x[i];
  }

  //頂点pjにカウンターをxjだけたす
  vector<ll> count(N+1);//各頂点のカウンター
  rep(i,Q){
    count[p[i]] += x[i];
  }

/*根に近い頂点から見ていき、ある頂点のカウンターは、親の
頂点のカウンタだけ足す
この操作をキューで実現する。
*/
vector<bool> seen(N+1);
queue<ll> q;
q.push(1);
seen[1] = true;

while(!q.empty()){
  ll vertex = q.front();
  seen[vertex] = true;
  q.pop();

  //vertexから行ける各子頂点について
  for(auto next_vertex : G[vertex]){
    if(seen[next_vertex] == true) continue;
    
     count[next_vertex] += count[vertex];//親のカウンターを足す
     seen[next_vertex] = true;
     q.push(next_vertex);
  }
}

 for(ll i = 1;i<=N;i++){
   cout << count[i] << " ";
 }
  cout << endl;
}

Measured memory_bytes: 21104
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t0 = 0;
		int x0 = 0;
		int y0 = 0;
		boolean flag = true;
		for (int i = 0; i < n; i++) {
			int t = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int d = Math.abs(x - x0) + Math.abs(y - y0);
			int dt = t - t0;
			if (d > dt || (dt - d) % 2 != 0) {
				flag = false;
				break;
			}
			t0 = t;
			x0 = x;
			y0 = y;
		}
		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 87452
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

# 3人、5回修行できる
N, K = getNM()
# 消化コスト
A = getList()
# 食べにくさ
F = getList()

A.sort()
F.sort(reverse = True)

ng = -1
ok = 10 ** 12 + 1

def judge(limit):
    cnt = 0
    for i in range(N):
        # limit // F[i] 消費コストとして許される値
        # A[i] - (limit // F[i]) 消費コストとして許される値との差
        cnt += max(0, A[i] - (limit // F[i]))
    return cnt

while ok - ng > 1:
    mid = (ok + ng) // 2
    margin = judge(mid)

    # 差がK以下であれば修正可能
    # もうちょい下のmidも試してみる
    if K >= margin:
        ok = mid
    else:
        ng = mid
print(ok)

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<bool> zero(N, true);
    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int A;
            cin >> A;
            zero[A - 1] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (zero[i]) {
            ++ans;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	rep(i, n) {
		if (ans + k < ans * 2)ans = ans + k;
		else ans = ans * 2;
	}
	cout << ans << endl;
}

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

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

  vector<bool> p(N + 1, true);
  p[0] = p[1] = false;
  REP(i, 2, N + 1) {
    if (p[i]) {
      for (ll j = i * 2; j <= N; j += i) {
        p[j] = false;
      }
    }
  }

  vector<ll> cnt(N + 1);
  REP(i, 1, N + 1) {
    ll x = i;
    REP(j, 0, N + 1) {
      if (p[j]) {
        while (x % j == 0) {
          x /= j;
          cnt[j]++;
        }
      }
    }
  }

  ll ans = 0;
  REP(i, 0, N + 1) if (p[i] && cnt[i] >= 2) {
    REP(j, 0, N + 1) if (i != j) if (p[j] && cnt[j] >= 4) {
      REP(k, j + 1, N + 1) if (i != k) if (p[k] && cnt[k] >= 4) {
        ans++;
      }
    }
  }
  REP(i, 0, N + 1) if (p[i] && cnt[i] >= 2) {
    REP(j, 0, N + 1) if (i != j) if (p[j] && cnt[j] >= 24) {
      ans++;
    }
  }
  REP(i, 0, N + 1) if (p[i] && cnt[i] >= 4) {
    REP(j, 0, N + 1) if (i != j) if (p[j] && cnt[j] >= 14) {
      ans++;
    }
  }
  REP(i, 0, N + 1) if (p[i] && cnt[i] >= 74) {
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
else:
    p = set(map(int, input().split()))
q = set(range(min(p)-1,max(p)+2,1))
r = q - p
diff = 100
ans = 0
for i in r:
    if diff > abs(X-i):
        diff = abs(X-i)
        ans = i
print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
 
int n;
string s;
map<int, char> mp;
 
string::const_iterator iter, end_;
string ans;
 
void consume(char ex) {
  assert(ex == *iter);
  iter++;
}
 
bool consume_if(char ex) {
  if(ex == *iter) { consume(ex); return true; }
  return false;
}
 
 
void rec(deque<char>& res, int qcnt = 0) {
 
  int prog = 0;
  while(iter != end_) {
    if(isalpha(*iter)) {
      res.push_back(char((*iter - 'A' + prog) % 26 + 'A'));
      consume(*iter);
      prog = 0;
    }
    else if(consume_if('+')) {
      prog ++;
    }
    else if(consume_if('-')) {
      prog --;
      if(prog < 0) prog = 25;
    }
    else if(consume_if('[')) {
      int pos = res.size();
      rec(res);
      assert(pos < (int)res.size());
      reverse(res.begin() + pos, res.end());
    }
    else if(consume_if(']')) {
      return;
    }
    else if(consume_if('?')) {
      prog = 0;
      res.push_back(mp[qcnt]);
      qcnt ++;
    }
  }
 
  if(iter == end_) {
    string x;
    rep(i, res.size()) {
      x.push_back(res[i]);
    }
    ans = min(ans, x);
  }
   
}
 
int main() {
 
  while(1) {
    cin >> s;
    if(s == ".") break;
    ans = string(88, 'Z');
     
    n = s.size();
    vector<int> qs;
    rep(i, n) {
      if(s[i] == '?') {
    qs.push_back(i);
      }
    }
     
    rep(i, pow(26, qs.size())) {
      mp.clear();
      int k = i;
      rep(j, qs.size()) {
    mp[j] = char('A' + (k % 26));
    k /= 26;
      }
      iter = s.begin(), end_ = s.end();
      deque<char> d;
      rec(d);
    }
    cout << ans << endl;
  }
   
  return 0;
}

Measured memory_bytes: 3328
import collections
n = int(input())
v = list(map(int, input().split()))
a = []
b = []
for i in range(n // 2):
    a.append(v[(i+1)*2-1])
    b.append(v[(i+1)*2-2])
a = collections.Counter(a)
b = collections.Counter(b)
 
 
if a.most_common()[0][0] != b.most_common()[0][0]:
    print(n - a.most_common()[0][1] - b.most_common()[0][1])
elif len(a.most_common()) == 1 and len(b.most_common()) == 1:
    print(n//2)
elif a.most_common()[1][1] + b.most_common()[0][1] > a.most_common()[0][1] + b.most_common()[1][1]:
    print(n - a.most_common()[1][1] - b.most_common()[0][1])
else:
    print(n - a.most_common()[0][1] - b.most_common()[1][1])

Measured memory_bytes: 18656
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		
		int sum = 0, m = n;
		
		while (m > 0) {
			
			sum += m % 10;
			m /= 10;
			
		}
		
		System.out.println((n % sum == 0) ? "Yes" : "No");
		
	}

}


Measured memory_bytes: 21716
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
ll K, A[int(2e5+5)], B[int(2e5+5)];

int main(){
  scanf("%d%d%lld", &N, &M, &K);
  for (int i = 1; i <= N; i++){
    scanf("%lld", A + i);
    A[i] += A[i-1];
  }
  for (int i = 1; i <= M; i++){
    scanf("%lld", B + i);
    B[i] += B[i-1];
  }

  int ans = 0;
  for (int i = 0; i <= N; i++){
    if (A[i] > K) break;
    ll Rest = K - A[i];
    if (B[M] <= Rest){
      ans = max(ans, i + M);
      continue;
    }
    int L = 0, R = M;
    while (R - L > 1){
      int mid = (L + R) / 2;
      if (Rest < B[mid]) R = mid;
      else L = mid;
    }
    ans = max(ans, i + L);
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 6952
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 2005;
const int mod = 1000000007;

int c[maxn][maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  for(int i=0;i<maxn;i++)c[i][0]=c[i][i]=1;
  for(int i=1;i<maxn;i++)
    for(int j=1;j<i;j++){
      c[i][j]=c[i-1][j]+c[i-1][j-1];
      if(c[i][j]>=mod)c[i][j]-=mod;
    }
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    if(n-m+1<i){
      cout<<0<<endl;
      continue;
    }
    cout<<c[m-1][i-1]*(ll)c[n-m+1][i]%mod<<endl;
  }
  return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<ll> A(200001, 0);

int main(void){
	
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%lld", &A[i]);
	
	int cnt = 0;
	for(int i = N - 1; i >= 0; i -= 2){
	    printf("%lld", A[i]);
	    ++cnt;
	    printf(" ");
	}
	for(int i = (N % 2 == 0) ? 0 : 1; i < N; i += 2){
	    printf("%lld", A[i]);
	    ++cnt;
	    if(cnt != N) printf(" ");
	}
	printf("\n");
	
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 50;

bool is_problem(string s[MAX_N], ll i, ll j, ll H, ll W){
    if (s[i][j] == '.') return false;

    if (i == 0 && j == 0){ if (s[i + 1][j] == '#' || s[i][j + 1] == '#') return false;}
    else if (i == 0 && j == W - 1){ if (s[i + 1][j] == '#' || s[i][j - 1] == '#') return false;}
    else if (i == H - 1 && j == 0){ if (s[i - 1][j] == '#' || s[i][j + 1] == '#') return false;}
    else if (i == H - 1 && j == W - 1){ if (s[i - 1][j] == '#' || s[i][j - 1] == '#') return false;}
    else if (i == 0){ if (s[i + 1][j] == '#' || s[i][j - 1] == '#' || s[i][j + 1] == '#') return false;}
    else if (i == H - 1){ if (s[i - 1][j] == '#' || s[i][j - 1] == '#' || s[i][j + 1] == '#') return false;}
    else if (j == 0){ if (s[i - 1][j] == '#' || s[i + 1][j] == '#' || s[i][j + 1] == '#') return false;}
    else if (j == W - 1){ if (s[i - 1][j] == '#' || s[i + 1][j] == '#' || s[i][j - 1] == '#') return false;}
    else if (s[i - 1][j] == '#' || s[i + 1][j] == '#' || s[i][j - 1] == '#' || s[i][j + 1] == '#') return false; 

    return true;
}

int main(void){
    ll H, W;
    string s[MAX_N];
    ll answer;

    cin >> H >> W;
    rep(i, H) cin >> s[i];
    rep(h, H) rep(w, W) if (is_problem(s, h, w, H, W)) {cout << " No " << endl; return 0;}

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var x, y, z, k int
	fmt.Scan(&x, &y, &z, &k)

	as := make([]int, x)
	bs := make([]int, y)
	cs := make([]int, z)
	for i := 0; i < x; i++ {
		fmt.Scan(&as[i])
	}
	for i := 0; i < y; i++ {
		fmt.Scan(&bs[i])
	}
	for i := 0; i < z; i++ {
		fmt.Scan(&cs[i])
	}

	ab := make([]int, 0)
	for _, a := range as {
		for _, b := range bs {
			ab = append(ab, a+b)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ab)))
	ab = ab[0:min(len(ab), k)]

	abc := make([]int, 0)
	for _, v := range ab {
		for _, c := range cs {
			abc = append(abc, v+c)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(abc)))

	for i := 0; i < k; i++ {
		fmt.Println(abc[i])
	}
}

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


Measured memory_bytes: 94232
N = int(input())
S = list(input())
if(N % 2 == 1):
    print("No")
else:
    flag = True
    for i in range(N // 2):
        if(S[i] != S[i+N//2]):
            flag = False

    if (flag):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
	string S, ACGT = "ACGT";
	cin >> S;
	int ans = 0;
	int now = 0;
	for(char c : S) {
		if (ACGT.find(c) != string::npos) {
			now++;
			ans = max(ans, now);
		}
		else {
			now = 0;
		}
	}
	cout << ans << endl;
}

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



int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll h,a;
    cin>>h>>a;
    if(h%a==0)
    {
    	cout<<h/a<<endl;
	}
	else cout<<h/a+1<<endl;
    
    
    
	return 0;
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin >> k;
	if(k%2 == 0 || k%5 == 0){
		cout << -1 << '\n';
		return 0;
	}

	long long n = 7, i;
	for (i = 1; i <= k; ++i) {
		if(n%k == 0)
			break;
		n = (n * 10 + 7) % k;
	}

	cout << i << '\n';
	return 0;
}


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

using namespace std;

int N, M, L, R;

int main(){
    cin >> N >> M;
    L = 1, R = N;
    for(int i = 1; i<=M; i++){
        int l, r;
        cin >> l >> r;
        L = max(l, L), R = min(r, R);
    }
    cout << max(R-L+1, 0) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
int g[101][101];
int H,W,N,x,k,i,j;
int main()
{
    while(scanf("%d%d%d",&H,&W,&N)!=EOF)
    {
        k=-1;
        for(i=1;i<=N;i++)
        {
            scanf("%d",&x);
            while(x--) k++,g[(k/H)&1?(H-1-(k%H)):k%H][k/H]=i;
        }
        for(i=0;i<H;i++)
        {
            for(j=0;j<W;j++)
            {
                if(j) printf(" ");
                printf("%d",g[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  ll n;
  ll k;
  cin >> n >> k;
  ll m;
  m=pow(k-1,n-1);
  cout << k*m <<endl;
}

Measured memory_bytes: 384
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  list($tc, $ac) = explode(" ", trim(fgets(STDIN)));
  for($i=1; $i<$n; $i++){
    list($t, $a) = explode(" ", trim(fgets(STDIN)));
    $b1 = intdiv($tc+$t-1 , $t);
    $b2 = intdiv($ac+$a-1 , $a);
    $tc = $t * max($b1, $b2);
    $ac = $a * max($b1, $b2);
//    echo $tc." ".$ac.PHP_EOL;
  }
  echo $tc+$ac;

Measured memory_bytes: 16220
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int N, M;
    cin >> N>> M;
    if (N==M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

using namespace std;

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

using int64 = long long;
const int mod = 1e9 + 7;

int64 calc(vector< int64 > &vs)
{
  int64 ret = 0;
  int64 less = 0;
  sort(begin(vs), end(vs));
  for(int i = 1; i < vs.size(); i++) {
    (less += vs[i - 1]) %= mod;
    (ret += vs[i] * i) %= mod;
    (ret += mod - less % mod) %= mod;
  }
  return (ret);
}

int main()
{
  int N, M;

  cin >> N >> M;
  vector< int64 > X(N), Y(M);
  rep(i, N) cin >> X[i];
  rep(i, M) cin >> Y[i];

  // ∑{i,j}∑{k,l} (x_i-x_j)*(y_k-y_l)
  // ∑{i,j} (x_i-x_j) * ∑{k,l} (y_k - y_l)
  // x_i - ∑(j<i) x_j

  cout << calc(X) * calc(Y) % mod << endl;
}



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

    }
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
signed main()
{
    fast;
    ll n,m;
    cin>>n>>m;
    ll arr[n];
    ll i;
    set < ll > lol;
    for(i=0;i<n;i++)
        cin>>arr[i],arr[i]/=2;
    for(i=0;i<n;i++)
        lol.insert(arr[i]);
    vi temp;
    for(auto v:lol)
        temp.pb(v);
    ll f = temp[0];
    for(i=1;i<temp.size();i++)
    {
        f = (temp[i]*f)/gcd(temp[i],f);
        if(f>m)
        {
            cout<<0;
            return 0;
        }
    }
    for(auto v:lol)
    {
        if((f/v)%2==0)
        {
            cout<<0;
            return 0;
        }
    }
    cout<<(m/f)/2+(m/f)%2<<"\n";
    
}


Measured memory_bytes: 6908
S = str(input())

ans = 0
cnt = 0
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    cnt += 1
  else:
    ans += (cnt+1) // 2
    if cnt % 2 == 0:
      cnt = 0
    else:
      cnt = 1
ans += (cnt+1) // 2
print(ans)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, t;
  cin >> a >> b >> t;
  cout << t/a*b << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from string import ascii_lowercase as alp
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	S = input().rstrip()
	# zyxwvutsrqponmlkjihgfedcba の例
	if S == alp[::-1]:
		print(-1)
		sys.exit()
	# 使われていない文字が残っている場合
	for i, letter in enumerate(alp):
		if not S.count(letter):
			print(S+letter)
			sys.exit()
	# 26文字全て使われている場合
	# => ABCDE(01234) -> ABCE(0124) にする
	tmp = []
	for i in range(len(S)-1, 0, -1):
		if S[i] < S[i-1]:
			tmp.append(S[i])
		elif S[i] > S[i-1]:
			tmp.append(S[i])
			tmp.sort()
			# print(tmp, S[i-1])
			for t in tmp:
				if S[i-1]<t:
					print(S[:i-1]+t)
					sys.exit()

if __name__ == '__main__':
	main()

Measured memory_bytes: 3768
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=1e9+7;
const int maxn=3e5+100;
const int N=1e6+1000;
const int M=500+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll sum[N],a[N];
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    int n;cin>>n;
    rep1(i,n) cin>>a[i];
    sum[n+1]=0;
    for(int i=n;i>=1;--i) sum[i]=(sum[i+1]+a[i])%mod;
    ll ans=0;
    rep1(i,n-1)
    {
        ans=(ans+a[i]*sum[i+1]%mod)%mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6688
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import System.IO.Unsafe
import Debug.Trace

solve :: Int -> Int -> B.ByteString -> Int
solve n k ss = max
  ( maxi
    [ accums
      VU.! ((i + k') `min` (gn - 1))
      -    (if i - k' - 1 >= 0 then accums VU.! (i - k' - 1) else 0)
    | i <- [0, 2 .. gn - 1]
    , let
      k' =
        if B.head ss == '0' then ((k - 1) `div` 2) * 2 + 1 else (k `div` 2) * 2
    ]
  )
  ( maxi
    [ accums
      VU.! ((i + k') `min` (gn - 1))
      -    (if i - k' - 1 >= 0 then accums VU.! (i - k' - 1) else 0)
    | i <- [1, 3 .. gn - 1]
    , let
      k' =
        if B.head ss == '0' then (k `div` 2) * 2 else ((k - 1) `div` 2) * 2 + 1
    ]
  )
 where
  maxi xs = if null xs then 0 else maximum xs

  (_, istream, gn) = fix
    ( \f (bs, acc, g) -> if B.length bs == 0
      then (bs, acc, g)
      else if B.last bs == '0'
        then
          let (other, zeros) = B.spanEnd (== '0') bs
          in  f (other, B.length zeros : acc, g + 1)
        else
          let (other, ones) = B.spanEnd (== '1') bs
          in  f (other, B.length ones : acc, g + 1)
    )
    (ss, [], 0)

  accums :: VU.Vector Int
  accums = unsafePerformIO $ VU.unsafeFreeze $ (\(x, _, _) -> x) $ foldl'
    ( \(acc, i, prev) k ->
      let cur = prev + k
      in  cur
            `seq` ( unsafePerformIO $ (VM.write acc i cur >> return acc)
                  , i + 1
                  , cur
                  )
    )
    (unsafePerformIO $ VM.new gn, 0, 0)
    istream

main = do
  let readInt = fmap (second B.tail) . B.readInt

  nk <- V.unfoldrN 2 readInt <$> B.getLine
  ss <- B.getLine
  print $ solve (nk V.! 0) (nk V.! 1) ss


Measured memory_bytes: 11516
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<map>
#include<vector>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=110;
int N,a[maxn];
double ans;
int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++)
		a[i]=read();
	for(int i=1;i<=N;i++)
		ans+=1.0/a[i];
	ans=1/ans;
	printf("%.8lf\n",ans);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdlib.h>
#include <string.h>

using namespace std;

bool so[300000 + 1];
	int sosu[40000];

int main()
{
	so[6] = true;
	for(int i = 1; i < 300000 / 7; i++){
		so[i * 7 + 1] = true;
		so[i * 7 + 6] = true;
	}
	for(int i = 12; i < 300000; i += 6){
		so[i] = false;
	}

	int a[] = {1,6};
	for(int i = 1; i < 300000 / 7; i++){
		for(int j = 0; j < 2; j++)
		{
			int x = i * 7 + a[j];
			if(so[x]){
				for(int k = 2 * x; k < 300000; k += x){
					so[k] = false;
				}
			}
		}
	}

	int count = 0;
	for(int i = 0; i < 300000 / 7; i++){
		for(int j = 0; j <2; j++){
			int x = i * 7 + a[j];
			if(so[x])
				sosu[count++] = x;
		}
	}

	int n;
	while(cin >> n, n != 1){
		cout << n << ":";
		for(int i = 0; i  <count; i++){
			if(n % sosu[i] == 0) cout << ' ' << sosu[i];
		}

		cout <<endl;
	}

	return 0;
}

Measured memory_bytes: 1300
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n=arr.shift()-0;
var a=[];
for(var i=0;i<n;i++)a.push(arr[i].split(" ").map(Number));
a.sort(function(a,b){
   if(a[0]!=b[0]) return a[0]-b[0];
   else return a[1]-b[1];
});
console.log(a.join("\n").replace(/,/g," "));


Measured memory_bytes: 69936
#include<bits/stdc++.h>
using namespace std;
int n,m;char c[101][101];int f[101][101];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
	{
		c[i][j]=getchar();
		while(c[i][j]!='.'&&c[i][j]!='#') c[i][j]=getchar();
	}
	f[1][1]=c[1][1]=='#';
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
	{
		if(i==1&&j==1) continue;
		f[i][j]=10000000;
		if(i>1) f[i][j]=min(f[i][j],f[i-1][j]+(c[i][j]=='#'&&c[i-1][j]!='#'));
		if(j>1) f[i][j]=min(f[i][j],f[i][j-1]+(c[i][j]=='#'&&c[i][j-1]!='#'));
	}
	cout<<f[n][m]<<endl;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n, k; cin >> n >> k;
	vector<ll> v(n);
	rep(i, n) cin >> v[i];

	rep(i, n - k){
		if(v[i] < v[i + k]){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4788
# -*- coding: utf-8 -*-
from sys import stdin

in_strings = lambda: stdin.readline()[:-1] # s = in_strings()
in_int = lambda: int(stdin.readline()) # N = in_int()
in_intlist = lambda: list(map(int, stdin.readline().split())) # List = in_intlist()

s = in_strings()
print(s[:4] + ' ' + s[4:])


Measured memory_bytes: 2940
// ITP1_7_B:   How many ways?
// 2017.7.28

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n, x, max;
	int a, b, c;
	int ans;

	while (1) {
		scanf("%d%d", &n, &x);
		if (n == 0 && x == 0) break;

		ans = 0;
		max = x; if (max > n) max = n;
		for (a = 1; a <= max; a++) {
			for (b = a + 1; b <= max; b++) {
				c = x - a - b;
				if (c > b && c <= n) ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int a,b;
	cin >> a >> b;
	cout << (a+b)%24 << "\n";	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define N
#define int long long
using namespace std;

#define v1 first
#define v2 second
#define pb push_back
#define mid ((l+r)>>1)
#define vec vector<int>
#define pr pair<int,int>
#define tp tuple<int,int,int>
#define sz(x) ((int) x.size())
#define all(x) x.begin(),x.end()
#define mem(a,x) memset(a,x,sizeof a)
#define For(x) for(int y,i=head[x];(y=e[i].to);i=e[i].nxt)

inline bool rd(int &X)
{
    X=0;int w=0;char ch=0;
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    X=w?-X:X; return 1;
}
int n,a,b;
signed main()
{
    cin>>n>>a>>b;
    if(a>b) return cout<<0,0;
    if(n==1) return cout<<(a==b),0;
    cout<<(n-1)*b+a-(n-1)*a-b+1;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;   
const int inf = (int) 1e9+7;
int n,m;
string nn[52],mm[52];
bool f(int x,int y){
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			if(nn[x+i][y+j] != mm[i][j])return false;	
		}
	}
	return true;
}
int main(){
	fastIO; 
	cin>>n>>m;	
	for(int i=0;i<n;i++){
		cin>>nn[i];
	}
	for(int i=0;i<m;i++){
		cin>>mm[i];
	}
	for(int i=0;i<n-m+1;i++){
		for(int j=0;j<n-m+1;j++){
			if(f(i,j)){
				cout<<"Yes\n";
				return 0;
			}
		} 	
	}	            
	cout<<"No\n";	
	return 0;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 042 - A
# -*- encoding: UTF-8 -*-
f_list = map(int, input().split())
l5 = 0
l7 = 0
result = "NO"

for f in f_list:
  if f == 5:
    l5 = l5 + 1
  elif f == 7:
    l7 = l7 + 1

if l5 == 2 and l7 == 1 :
  result = "YES"
  
print(result)



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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
int main()
{     int x,a,b;
      cin>>x>>a>>b;
      if(b<=a)cout<<"delicious"<<endl;
        else if(b-a<=x)cout<<"safe"<<endl;
        else cout<<"dangerous"<<endl;
	  return 0;
}


Measured memory_bytes: 256