akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k, c] <- getIntList
    s <- f . zip [1..] <$> getLine
    let ansf = take k $ solvef c s
    let ansb = reverse . take k $ solveb c (reverse s)
    mapM_ print (check ansf ansb)


f :: [(Int, Char)] -> [Int]
f [] = []
f ((i, b) : xs) | b == 'o' = i : f xs
                | otherwise = f xs

solvef :: Int -> [Int] -> [Int]
solvef _ [] = []
solvef c (x : xs) = x : solvef c (dropWhile (x + c >= ) xs)

solveb :: Int -> [Int] -> [Int]
solveb _ [] = []
solveb c (x : xs) = x : solveb c (dropWhile (x - c <= ) xs)

check :: [Int] -> [Int] -> [Int]
check [] _ = []
check _ [] = []
check (x : xs) (y : ys) | x == y = x : check xs ys
                        | otherwise = check xs ys

Measured memory_bytes: 38908
#include <iostream>
using namespace std;
typedef long long ll;
ll comb(int a, int b) {
	if (a<b) return 0;
	return a-b+1;
}
int main() {
	int n, m;
	string str;
	while (cin>>n&&n!=0) {
		cin>>m>>str;
		ll res=0;
		int cnt=0;
		for (int i=0; i<m-1; i++) {
			if (str[i]=='I') {
				if (str[i+1]=='O'&&str[i+2]=='I') cnt++;
				else {
					res += comb(cnt,n);
					cnt=0;
				}
			}
		}
		if (str[m-3]=='I'&&str[m-2]&&'O'&&str[m-1]=='I') {
			res += comb(cnt,n);
		} else if (str[m-3]=='O') {
			res += comb(cnt,n);
		}
		cout << res << endl;
	}
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A, D;
string S;

signed main(){
    cin >> N >> S;
    for(int i=0;i<N;i++) {
        if(S[i]=='o') A.push_back(0);
        else A.push_back(1);
    }
    D.resize(N, -1);
    D[N-1] = 0;
    D[0] = 0;
    D[1] = A[0]^D[0]^D[N-1];
    for(int i=1;i<N-2;i++) {        
        D[i+1] = A[i]^D[i]^D[i-1];
    }
    if(D[N-1]==A[N-2]^D[N-2]^D[N-3]&&D[0]==A[N-1]^D[N-1]^D[N-2]) ans++;
    if(ans>0) {
        for(int i=0;i<N;i++) {
            if(D[i]==0) cout << "S";
            else cout << "W";
        }
        return 0;
    }
    D.resize(N, -1);
    D[N-1] = 0;
    D[0] = 1;
    D[1] = A[0]^D[0]^D[N-1];
    for(int i=1;i<N-2;i++) {        
        D[i+1] = A[i]^D[i]^D[i-1];
    }
    if(D[N-1]==A[N-2]^D[N-2]^D[N-3]&&D[0]==A[N-1]^D[N-1]^D[N-2]) ans++;
    if(ans>0) {
        for(int i=0;i<N;i++) {
            if(D[i]==0) cout << "S";
            else cout << "W";
        }
        return 0;
    }
    D.resize(N, -1);
    D[N-1] = 1;
    D[0] = 0;
    D[1] = A[0]^D[0]^D[N-1];
    for(int i=1;i<N-2;i++) {        
        D[i+1] = A[i]^D[i]^D[i-1];
    }
    if(D[N-1]==A[N-2]^D[N-2]^D[N-3]&&D[0]==A[N-1]^D[N-1]^D[N-2]) ans++;
    if(ans>0) {
        for(int i=0;i<N;i++) {
            if(D[i]==0) cout << "S";
            else cout << "W";
        }
        return 0;
    }
    D.resize(N, -1);
    D[N-1] = 1;
    D[0] = 1;
    D[1] = A[0]^D[0]^D[N-1];
    for(int i=1;i<N-2;i++) {        
        D[i+1] = A[i]^D[i]^D[i-1];
    }
    if(D[N-1]==A[N-2]^D[N-2]^D[N-3]&&D[0]==A[N-1]^D[N-1]^D[N-2]) ans++;
    if(ans>0) {
        for(int i=0;i<N;i++) {
            if(D[i]==0) cout << "S";
            else cout << "W";
        }
        return 0;
    }
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 4920
N,W=map(int,input().split())

v=[0]*N
w=[0]*N

for i in range(N):
    v[i],w[i]=map(int,input().split())

dp=[[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j-w[i]>=0:
            dp[i+1][j]=dp[i+1][j-w[i]]+v[i]
        dp[i+1][j]=max(dp[i][j],dp[i+1][j])
print(dp[-1][-1])


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

typedef struct{
    long r;
    long c;
    long step;
} way_t;

char s[50][51];
long d[50][50];

way_t find_min(long h, long w){
    way_t min;
    min.step=LONG_MAX;
    for(long i=0; i<h; i++){
        for(long j=0; j<w; j++){
            if(s[i][j]=='.' && d[i][j]<min.step){
                min.r=i;
                min.c=j;
                min.step=d[i][j];
            }
        }
    }
    return min;
}

int main(void){
    char line[60];
    long h, w;
    scanf("%ld %ld\n", &h, &w);
    for(long i=0; i<h; i++){
        fgets(line, 60, stdin);
        memcpy(s[i], line, w);
    }
    long count = 0;
    for(long i=0; i<h; i++){
        for(long j=0; j<w; j++){
            if(s[i][j]=='.'){
                count++;
            }
            d[i][j]=LONG_MAX;
        }
    }
    d[0][0]=0;
    for(;;){
        /*
           for(long i=0; i<h; i++){
           for(long j=0; j<w; j++){
           if(d[i][j]==LONG_MAX){
           printf("Inf ");
           }else{
           printf("%3ld ", d[i][j]);
           }
           }
           printf("\n");
           }
           for(long i=0; i<h; i++){
           printf("%s\n", s[i]);
           }
           */
        way_t u = find_min(h,w);
        s[u.r][u.c]='#';
        //printf("(%ld, %ld) %ld\n", u.r, u.c, u.step);
        if(u.step==LONG_MAX){
            break;
        }
        //N
        if(u.r-1>=0){
            way_t t=u;
            t.r--;
            t.step++;
            if(s[t.r][t.c]=='.' && d[t.r][t.c]>t.step){
                d[t.r][t.c]=t.step;
            }
        }
        //S
        if(u.r+1<h){
            way_t t=u;
            t.r++;
            t.step++;
            if(s[t.r][t.c]=='.' && d[t.r][t.c]>t.step){
                d[t.r][t.c]=t.step;
            }
        }
        //W
        if(u.c-1>=0){
            way_t t=u;
            t.c--;
            t.step++;
            if(s[t.r][t.c]=='.' && d[t.r][t.c]>t.step){
                d[t.r][t.c]=t.step;
            }
        }
        //E
        if(u.c+1<w){
            way_t t=u;
            t.c++;
            t.step++;
            if(s[t.r][t.c]=='.' && d[t.r][t.c]>t.step){
                d[t.r][t.c]=t.step;
            }
        }
    }
    if(s[h-1][w-1]=='.'){
        printf("-1\n");
    }else{
        printf("%ld\n", count-1-d[h-1][w-1]);
    }
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

vector<int> coin = {500,5};
vector<int> coin_v = {1000,5};

int main() {
  int N,value = 0,i=0;
  
  cin >> N;
  
  rep(i,2){
    value += (N/coin.at(i)) * coin_v.at(i);
  	N -= (int)(N/coin.at(i))*coin.at(i);    
  }
  
  cout << value << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int n,k;
vector<int> g[100005];
ll ans = 1LL;

ll dfs(int now,int from){
  int c;
  if(from == -1) c = k-1;
  else c = k-2;
  
  if(k < g[now].size()){
    return 0;
  }else{
    ll case_num = 1;
    for(auto e: g[now]){
      if(e==from) continue;
      case_num *= c; case_num %= MOD;
      c--;
    }
    for(auto e: g[now]){
      if(e==from) continue;
      case_num *= dfs(e,now); case_num %= MOD;
    }
    return case_num;
  }
}

int main(){
  cin >> n >> k;
  rep(i,n-1){
    int a,b; cin >> a >> b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  ll ans = k*dfs(0,-1);
  ans %= MOD;
  cout << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 10368
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class AtCoder{
  public static void Main(){

    var input1 = Console.ReadLine().Split();
    int H = int.Parse(input1[0]);
    int W = int.Parse(input1[1]);

    int n = int.Parse(Console.ReadLine());
    var input2 = Console.ReadLine().Split();
    int[] a = new int[n];
    for (int i = 0; i < n; i++){
        a[i] = int.Parse(input2[i]);
    }

    int[,] c = new int[H,W];
    bool up = true;
    int h = 0, w =0;
    for(int i = 0; i < n; i++){
        for (int j = 0; j < a[i]; j++){
            c[h,w] = i + 1;
            if(up){
                if(w == W -1){
                    h++;
                    up = false;
                }
                else w++;
            }
            else{
                if(w == 0){
                    h++;
                    up = true;
                }
                else w--;
            }            
        }
    }

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            Console.Write(c[i,j]);
            if(j == W-1) Console.WriteLine("");
            else Console.Write(" ");
        }
    }
  }
}

Measured memory_bytes: 11232
#include<stdio.h>
 int main(void){
   int a,b,c,d,ans;
   scanf("%d",&a);
   b=a/100;
   c=a%10;
   d=a%100/10;
   if(b==7||c==7||d==7){
     printf("Yes\n");
   }else{
     printf("No\n");
   }return 0;
      }
 

Measured memory_bytes: 1612
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int[] ant = new int[5];
        //        String s = sc.next();
 
        boolean ans = false;
 
        for (int i = 0; i < 5; i++) {
            ant[i] = sc.nextInt();
        }
        int k = sc.nextInt();
 
        if ((Math.abs(ant[0] - ant[1]) > k) || (Math.abs(ant[0] - ant[2]) > k) ||
                (Math.abs(ant[0] - ant[3]) > k) || (Math.abs(ant[0] - ant[4]) > k) ||
                (Math.abs(ant[1] - ant[2]) > k) || (Math.abs(ant[1] - ant[3]) > k) ||
                (Math.abs(ant[1] - ant[4]) > k) || (Math.abs(ant[2] - ant[3]) > k) ||
                (Math.abs(ant[2] - ant[4]) > k) || (Math.abs(ant[3] - ant[4]) > k))
            ans = true;
 
        sc.close();
        System.out.println(ans ? ":(" : "Yay!");
 
    }
}

Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N,K;
	cin >> N>>K;
	vector<int>H(N);
	for (int n = 0;n<N;++n) {
		cin >> H[n];
	}
	sort(H.begin(),H.end());
	int ans = 1e9;
	for (int n = 0;n<N+1-K;++n) {
		ans = min(ans, H[n + K - 1] - H[n]);
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3776
/*
 * Author:heroming
 * File:heroming.cpp
 * Time:2012-7-17 13:29:51
 */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define SZ(v) ((int)(v).size())
const int MAXN = 30, MID = 15;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
const int OPPO[] = {0, 6, 5, 4, 3, 2, 1};
const int LEFT[7][7] = {{0, 0, 0, 0, 0, 0, 0}, {0, 0, 4, 2, 5, 3, 0}, {0, 3, 0, 6, 1, 0, 4}, {0, 5, 1, 0, 0, 6, 2}, {0, 2, 6, 0, 0, 1, 5}, {0, 4, 0, 1, 6, 0, 3}, {0, 0, 3, 5, 2, 4, 0}};

int n, t, f, A[7], B[7];
int P[MAXN][MAXN][MAXN][2];
int T[MAXN][MAXN];

void fall(int x, int y, int z, int top, int front)
{
        int ff = front;
        memset(B, -1, sizeof(B));
        for (int k = 0; k < 4; ++ k)
        {
                if (ff >= 4 && ff <= 6)
                        B[ff] = k;
                ff = LEFT[top][ff];
        }
        for (int i = 6; i >= 4; -- i)
        {
                if (B[i] == -1)
                        continue;
                int k = B[i];
                int a = x + dx[k];
                int b = y + dy[k];
                if (T[a][b] < z)
                {
                        int tt;
                        if (k == 0)
                                tt = top;
                        else if (k == 2)
                                tt = OPPO[top];
                        else
                                tt = front;
                        fall(a, b, T[a][b], OPPO[i], tt);
                        return;
                }
        }

        P[x][y][z + 1][0] = top;
        P[x][y][z + 1][1] = front;
        ++ T[x][y];
}

int main()
{
        while (scanf("%d", &n) != EOF && n)
        {
                memset(P, 0, sizeof(P));
                memset(T, 0, sizeof(T));
                for (int i = 0; i < n; ++ i)
                {
                        scanf("%d%d", &t, &f);
                        fall(MID, MID, T[MID][MID], t, f);
                }
                memset(A, 0, sizeof(A));
                for (int i = 0; i < MAXN; ++ i)
                        for (int j = 0; j < MAXN; ++ j)
                                ++ A[P[i][j][T[i][j]][0]];
                printf("%d", A[1]);
                for (int i = 2; i <= 6; ++ i)
                        printf(" %d", A[i]);
                printf("\n");
        }
        return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    getline(cin, s);
    char prev = 'a';
    for (int i = 0; i < 4; i++) {
        char c = s[i];
        if (prev == c) {
            cout << "Bad" << "\n";
            return 0;
        }
        prev = c;
    }
    cout << "Good" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
const ll MOD  = 1e9 + 7;
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  std::vector<ll> x(n),y(m);
  rep(i,n) cin>>x[i];
  rep(i,m) cin>>y[i];
  ll xs = 0,ys = 0;
  repl(i,1,n) xs += ((x[i] - x[i-1]) * (1ll * i * (n - i) % MOD)) % MOD;
  repl(i,1,m) ys += ((y[i] - y[i-1]) * (1ll * i * (m - i) % MOD)) % MOD;
  xs %= MOD;
  ys %= MOD;
  ll res = (xs * ys) % MOD;
  cout<<res<<endl;
  return ;
}

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


Measured memory_bytes: 1792
#include<cstring>
#include<string>
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	for(int i=1;i<n;i++)
	{
		if(s[i]==s[i-1])
		{
			cout<<i<<" "<<i+1<<endl;
			return 0;
		}
		else if(i>1 && s[i]==s[i-2])
		{
			cout<<i-1<<" "<<i+1<<endl;
			return 0;
		}
	}
	cout<<"-1 -1"<<endl;
}

Measured memory_bytes: 512
#include<cstdio>

char s1[30];
char s2[30];
char s3[30];

int main()
{
	scanf("%s",s1);
	scanf("%s",s2);
	scanf("%s",s3);
	printf("%c",s1[0] - 32);
	printf("%c",s2[0] - 32);
	printf("%c",s3[0] - 32);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000
using namespace std;
using ll = long long;
int dp[3][32];
int main()
{
    int n,c;
    cin >> n >> c;
    vector<vector<int>> d(c,vector<int>(c)), col(n,vector<int>(n));
    rep(i,c){
        rep(j,c){
            cin >> d[i][j];
        }
    }
    rep(i,n){
        rep(j,n){
            cin >> col[i][j];
            col[i][j]--;
        }
    }
    rep(i,n){
        rep(j,n){
            rep(k,c){
                dp[(i + j) % 3][k] += d[col[i][j]][k];
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < c; i++)
    {
        for (int j = 0; j < c; j++)
        {
            if (i == j)
                continue;
            for (int k = 0; k < c;k++){
                if(k == j || k == i)
                    continue;
                ans = min(ans,dp[0][i] + dp[1][j] + dp[2][k]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const double INF=1e9;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
	int N;cin>>N;
	int L[202];
	REP(i,N*2)cin>>L[i];
	sort(L,L+2*N);
	int sum=0;
	REP(i,N){
		sum+=L[2*i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools

n = int(input())
x = ["" for _ in range(n)]
y = ["" for _ in range(n)]

for i in range(n):
    x[i], y[i] = map(int, input().split())

def dist(x1, x2, y1, y2):
    return ((x1 - x2)**2 + (y1 - y2)**2 )**0.5

seq = list(range(n))
lis = list(itertools.permutations(seq))
#print(lis)

means = []
for s in lis:
    total_dist = []
    for i in range(len(s)-1):
        x1 = x[s[i]]
        x2 = x[s[i+1]]
        y1 = y[s[i]]
        y2 = y[s[i+1]]
        total_dist.append(dist(x1, x2, y1, y2))
    means.append(sum(total_dist))

print(sum(means)/len(means))


Measured memory_bytes: 47580
"use strict";
const Main = (input) =>{
	let xs = input.trim().split(' ').map(v=>parseInt(v,10));
    if(xs[0] <= xs[2] && xs[1] >= xs[2]){
    console.log('Yes');
    } else {
    console.log('No');
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
import queue
k = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)
cnt = 0
runrun = 0
while cnt < k:
    runrun = q.get()
    cnt += 1
    if runrun % 10 != 0:
        q.put(10 * runrun + (runrun % 10) - 1)
    q.put(10 * runrun + (runrun % 10))
    if runrun % 10 != 9:
        q.put(10 * runrun + (runrun % 10) + 1)
print(runrun)

Measured memory_bytes: 12452
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

ll dp[10][101][2][2];

void odd_init() {
  dp[0][1][0][0] = dp[1][1][1][1] = 1;
  REP(i,9) {
    for (int j=1; j<100; ++j) {
      REP(k,2) {
        dp[i][j+1][k][0] += dp[i][j][k][0] + dp[i][j][k][1];
        dp[i+1][j+1][k][1] += dp[i][j][k][0];
      }
    }
  }
}

ll dp2[10][101][3][3];

void even_init() {
  dp2[0][1][0][0] = dp2[1][1][1][1] = dp2[1][1][2][2] = 1;
  REP(i,9) {
    REP(j,100) {
      REP(k,3) {  
        dp2[i][j+1][k][0] += dp2[i][j][k][0] + dp2[i][j][k][1] + dp2[i][j][k][2];
        dp2[i+1][j+1][k][1] += dp2[i][j][k][0] + dp2[i][j][k][2];
        dp2[i+1][j+1][k][2] += dp2[i][j][k][0] + dp2[i][j][k][1];
      }
    }
  }
}

ll solve_odd(int n) {
  return (dp[8][n][0][0] + dp[8][n][0][1] + dp[8][n][1][0]) * 40320;
}

ll solve_even(int n) {
  ll ans = 0;
  REP(i,3) REP(j,3) {
    if (i==1&&j==2 || i==2&&j==1) continue;
    ans += dp2[8][n/2][i][j];
  }
  return ans * 40320;
}

int main() {
  odd_init();
  even_init();
  int n;
  while(cin>>n,n) {
    if (n&1) {
      cout << solve_odd(n) << endl;
    } else {
      cout << solve_even(n) << endl;
    }
  }
}

Measured memory_bytes: 1256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	class perser {

		String data;

		int ptr;



		perser(String data) {

			this.data = data;

			ptr = 0;

		}



		boolean hasNextCar() {

			if (ptr % 3 == 0) {

				return data.length() > ptr;

			}else{

				return false;

			}

		}



		boolean hasNextCommand() {

			if (ptr % 3 == 1) {

				return data.length() > ptr;

			}else{

				return false;

			}

		}



		int nextCommand(){

			int ret = 0;

			if(data.charAt(ptr) == '-'){

				ret = 1;

			}else{

				ret = -1;

			}

			ptr+=2;

			return ret;

		}

		Character nextCar(){

			return data.charAt(ptr++);

		}

	}



	void run() {

		int n = sc.nextInt();

		for (int z = 0; z < n; z++) {

			String data = sc.next();

			LinkedList<Character> fore = new LinkedList<Character>();

			LinkedList<Character> reer = new LinkedList<Character>();

			perser p = new perser(data);

			int now = 0;

			int min = 0;

			int max = 0;

			Character car = p.nextCar();

			fore.add(car);

			for(;p.hasNextCommand();){

				int cmd = p.nextCommand(); 

				now+=cmd;

				car = p.nextCar();

				if(min > now){

					min = now;

					reer.addFirst(car);

				}else if(max < now){

					max = now;

					fore.addLast(car);					

				}

			}

			String ret ="";

			for(Character c : reer){

				ret +=c;

			}

			for(Character c : fore){

				ret +=c;

			}

			System.out.println(ret);

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int flag=0;
    for (int i=0;i<s.size();i++) {
        if (flag==0) {
            if (s[i]=='C') {
                flag=1;
            }
        } else if (flag==1) {
            if (s[i]=='F') {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.bigin(),v.end()
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define R(a) a=sqrt(a)
#define POW(a,b) a=pow(a,b)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    FAST;
    ll x,t;
    ll k=0;
    ll d=360;
    cin>>x;
    while(true){
        if(d%x==0){
            k=d/x;
            break;
        }
        else{
            d+=360;
        }
    }
    cout<<k;
    
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
const int MAX=100001;
int a[MAX]={},e[MAX]={};
void era(){
   for(int i=4;i<MAX;i+=2)
     e[i]=1;
   for(int i=3;i<MAX;i+=2){
      a[i-1]=a[i-2];
      if(!e[i]){
         a[i]=a[i-1]+(!e[(i+1)/2]); 
         for(int j=i+i;j<MAX;j+=i)
           if(!e[j])
             e[j]=1;
      }else{
         a[i]=a[i-1]; 
      } 
   } 
}
int main(){
  int q,l,r;
  cin>>q;
  era();
  rep(i,q){
    scanf("%d%d",&l,&r);
    printf("%d\n",a[r]-a[l-1]);
  }
  return 0;
}

Measured memory_bytes: 1408
solveImpl :: [Int] -> [String]
solveImpl [h,w] = take h $ repeat $ take w $ repeat '.'

solve :: [Int] -> [String]
solve [h,w] = (l ++) $ (++ l) $ map ("#"++) $ map (++"#") $ solveImpl [h-2 , w-2]
    where
        l = [take w $ repeat '#']

main :: IO ()
main  = getContents
    >>= return . map (map read) . map words . lines
    >>= return . takeWhile (/= [0,0])
    >>= return . map solve
    >>= mapM_ (\ x -> mapM_ putStrLn x >> putStrLn "")

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

int main()
{
    string s,a;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='0'){
			a += "0";
		} else if(s[i]=='1'){
			a += "1";
		} else if(s[i]=='B'){
			if(a.size()>0){
				a.erase(a.end()-1);
			}
		}
	}
	cout << a << endl;
    return 0;
}


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

int main(void) {
	int N;

	scanf("%d",&N);
	char S[N+1];
	scanf("%s",S);

	if(N%2) {printf("No");return 0;}
	N/=2;
	if(!memcmp(&S[0],&S[N],N))
	     printf("Yes");
	else printf("No");

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main ()
{
	int l,x;
	scanf("%d %d ",&l,&x);
	int a=0;
	int i;
	char buff[6]={0};
	for(i = 0; i < l*x; ++i){
		buff[0]=getchar();
		buff[1]=getchar();
		buff[2]=getchar();
		buff[3]=getchar();
		buff[4]=getchar();
		if(strcmp(buff, "snuke")==0){
			a=1;
			break;
		}
		getchar();
	}
	if(a==1){
		printf("%c%d",i%x+'A',i/x+1);
	}
	return 0;
}


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

using namespace std;

int main()
{
  int N, X, min = 1000000, sum = 0;
  int types[101];
  cin >> N >> X;
  for (int i = 0; i < N; i++)
  {
    cin >> types[i];
    sum += types[i];
    if (types[i] < min)
      min = types[i];
  }
  X -= sum;
  int R = N;
  R += X / min;
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
using namespace std;
int main() {
  int check = 0;
  string s, l, r;
  size_t Slen, Llen, Rlen;
  cin >> s;
  Slen = s.length();
  // cout << Slen << endl;
  l = s.substr(0, (Slen-1)/2);
  // cout << l << endl;
  r = s.substr((Slen+3)/2-1, Slen-(Slen+3)/2+1);
  // cout << r << endl;
  Llen = l.length();
  Rlen = r.length();
  for(int i=0; i<Slen; i++) {
    if (s[i] != s[Slen-i-1]) check = 1;
  }
  for(int i=0; i<Llen; i++) {
    if (l[i] != l[Llen-i-1]) check = 1;
  }
  for(int i=0; i<Rlen; i++) {
    if (r[i] != r[Rlen-i-1]) check = 1;
  }
  if (check == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 888
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using Number = System.Int32;
using System.Numerics;

namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			var s = rs;
			var t = rs;
			Console.WriteLine(t + s);
		}

		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = true });
		var solver = new Program.Solver();
		//* 
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		t.Start();
		t.Join();
		//*/
		// solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion


Measured memory_bytes: 14428
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int dp[55][5][5];
char a[55],b[55];
const int modo=1000000007;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    scanf("%s%s",a,b);
    if (a[0]==a[1])
    {
        int i,j;
        for (i=0;i<3;i++)
        {
            for (j=0;j<3;j++)
            {
                if (i==j) continue;
                dp[1][i][j]=1;
            }
        }
    }
    else
    {
        int i;
        for (i=0;i<3;i++)
        {
            dp[0][i][i]=1;
        }
    }
    int sum=0;
    int i;
    for (i=0;i<n;i++)
    {
        int j;
        for (j=0;j<3;j++)
        {
            int k;
            for (k=0;k<3;k++)
            {
                if (dp[i][j][k]==0) continue;
                if (a[i+1]==b[i+1])
                {
                    int l;
                    for (l=0;l<3;l++)
                    {
                        if ((j!=l)&&(l!=k))
                        {
                            dp[i+1][l][l]+=dp[i][j][k];
                            dp[i+1][l][l]%=modo;
                        }
                    }
                }
                else
                {
                    int l;
                    for (l=0;l<3;l++)
                    {
                        if (l==j) continue;
                        int t;
                        for (t=0;t<3;t++)
                        {
                            if (l==t) continue;
                            if (t==k) continue;
                            dp[i+2][l][t]+=dp[i][j][k];
                            dp[i+2][l][t]%=modo;
                        }
                    }
                }
                if (i==n-1)
                {
                    sum+=dp[i][j][k];
                    sum%=modo;
                }
            }
        }
    }
    printf("%d\n",sum);
    return 0;
} 


Measured memory_bytes: 256
package main

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

var inf = math.MaxInt32
var dbg = false

func main() {
	sc := NewScanner()
	N, Q := sc.NextInt(), sc.NextInt()
	edges := make([][]int, N, N)
	for i := 0; i < N-1; i++ {
		a, b := sc.NextInt(), sc.NextInt()
		a--
		b--
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}
	queries := make([]int64, N, N)
	for i := 0; i < Q; i++ {
		p, x := sc.NextInt(), sc.NextInt64()
		p--
		queries[p] = queries[p] + x
	}
	counters := make([]int64, N, N)
	//seen := make([]bool, N)
	var dfs func(int, int, int64)
	dfs = func(node int, prev int, accum int64) {
		inc := queries[node]
		//seen[node] = true
		accum += inc
		counters[node] = accum
		for _, adj := range edges[node] {
			//if !seen[adj] {
			if adj != prev {
				dfs(adj, node, accum)
			}
		}
	}
	dfs(0, -1, 0)
	for i := 0; i < N-1; i++ {
		fmt.Printf("%d ", counters[i])
	}
	fmt.Printf("%d\n", counters[N-1])
	// suppress warnings
	/*
		if dbg {
			fmt.Println(, T)
			if false {
				_ = sc.NextToken()
			}
		}
	*/
}

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &Scanner{sc: sc}
}

func (r *Scanner) SetBufferSize(size int) {
	buf := make([]byte, size)
	r.sc.Buffer(buf, size)
}

func (r *Scanner) NextToken() string {
	r.sc.Scan()
	return r.sc.Text()
}

func (r *Scanner) NextInt64() int64 {
	n, e := strconv.ParseInt(r.NextToken(), 10, 64)
	if e != nil {
		panic(e)
	}
	return n
}

func (r *Scanner) NextInt() int {
	n, e := strconv.ParseInt(r.NextToken(), 10, 32)
	if e != nil {
		panic(e)
	}
	return int(n)
}

func (r *Scanner) NextInt64Array(size int) []int64 {
	a := make([]int64, size)
	for i := 0; i < size; i++ {
		a[i] = r.NextInt64()
	}
	return a
}

func (r *Scanner) NextIntArray(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = r.NextInt()
	}
	return a
}


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

int main()
{
    string X;
    cin >> X;
    stack<char> s;
    s.push(X.front());
    auto n = X.size();
    for(int i=1;i<n;i++){
        if(s.size()>0 && X[i]=='T' && s.top()=='S') s.pop();
        else s.push(X[i]);
    }
    cout<<s.size()<<endl;

    return 0;
}

Measured memory_bytes: 644
#include<iostream>
using namespace std;
int UCLN(int a, int b)
{
	while (a != b)
	{
		if (a > b)
			a = a - b;
		else
			b = b - a;
	}
	return a; // or return b; a = b
}
int main()
{
	int x, y;
	cin >> x >> y;
	cout << UCLN(x, y) << endl;
	return 0;
}

Measured memory_bytes: 3096
count = 0 

def merge(data, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid 
    L = []
    R = []
    for i in range(n1):
        L.append(data[left+i])
    for i in range(n2):
        R.append(data[mid+i])
    L.append(float('inf'))
    R.append(float('inf'))
    i = 0 
    j = 0 
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            data[k] = L[i]
            i += 1
        else:
            data[k] = R[j]
            j += 1

def merge_sort(data, left, right):
    if left + 1 < right:
        mid = (left + right) / 2 
        merge_sort(data, left, mid)
        merge_sort(data, mid, right)
        merge(data, left, mid, right)

def main():
    num = raw_input()
    num_list = raw_input().split()
    num_list = map(int, num_list)
    merge_sort(num_list, 0, len(num_list))
    num_list =  map(str, num_list)
    print " ".join(num_list)
    print count

if __name__ == '__main__':
    main()

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

#define ll long long int 

int main()
{int n,x;
int p=0;
cin>>n;
for(int i=0;i<3;i++)
{   x=n%10  ;
	if(x==7)
		{  p=1;}
	n=n/10;
   }

if(p==1)
	{ cout<<"Yes";}
else
	cout<<"No";


}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] cut = x.split(" ");
		String a = cut[0];
		String b = cut[1];
		String c = cut[2];

		char q = a.charAt(0);
		char w = b.charAt(0);
		char e = c.charAt(0);

		System.out.println(q + "" + w + "" + e);

	}
}

Measured memory_bytes: 21076
L,R = map(int,input().split())
mod = 2019
d = R - L + 1
c = d // mod 
a = L % mod
b = R % mod
if c >= 2 :
    print(0)
else :
    if a > b :
        print(0)
    else :
        amari = []
        for i in range(L,R+1):
            for j in range(i+1,R+1):
                amari.append(i*j%mod)
        print(min(amari))



Measured memory_bytes: 75428
N = int(input())
h = list(map(int,input().split()))

d = [0]*N

for i in range(1,N):
    if i==1:
        d[i]=abs(h[1]-h[0])
    elif i==2:
        d[i]=abs(h[2]-h[0])
    else:
        d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]))

print(d[N-1])


Measured memory_bytes: 52208
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using ll = long long;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) ll v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
const int MOD = 1000000007;
const int INF = 1000000000;

int main() {
  IN(N);

  vi A(N);
  REP(i, N) cin >> A[i];
  SORT(A);
  if (N % 2 == 0) {
    REP(i, N) {
      if (A[i] == A[i+1] && A[i] == i+1) {
        ++i;
        continue;
      }
      OUT(0); return 0;
    }
  } else {
    if (A[0] != 0) {
      OUT(0); return 0;
    }
    FOR(i, 1, N) {
      if (A[i] == A[i+1] && A[i] == i + 1) {
        ++i;
        continue;
      }
      OUT(0); return 0;
    }
  }
  ll ans = 1;
  REP(i, N / 2) {
    ans *= 2;
    ans %= MOD;
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main() {
  int N, M;
  cin >> N >> M;
  if(N == M){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())

A = []
B = []

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)


A = np.array(A)
B = np.array(B)

time = 0
ans = "Yes"
A = A[np.argsort(B)]
B = np.sort(B)
#print(A,B)
for i in range(N):
    time += A[i]
    #print(time, B[i])
    if time > B[i]:
        ans = "No"
        break
print(ans)






Measured memory_bytes: 28160
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    int counter=0;
    REP(i, 3){
        if(S[i]==S[i+1]){
            counter++;
        }
    }
    if(counter==0){
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }


    return 0;
}


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

const int N = 100100;

LL a[N], f[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i ++)
    scanf("%lld", a + i);
  sort(a, a + n);
  f[0] = 1;
  for (int i = 1; i < n; i ++) {
    f[i] = 1;
    if (a[i] <= a[i - 1] * 2)
      f[i] = f[i - 1] + 1;
    a[i] += a[i - 1];
  }
  cout << f[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int x,y,z,n;
struct node{
   int a,b,c;
}p[100005];
long long l[100005];
bool cmp(node x,node y){
    return x.a-x.b<y.a-y.b;
}
priority_queue<int , vector<int> , greater<int> >q;
long long ans;
int main () {
    x=read();
	y=read();
	z=read();
    n=x+y+z;
	long long tot=0,sum=0;
	F(i,1,n){
	   p[i].a=read();
	   p[i].b=read();
	   p[i].c=read();
	   tot+=p[i].c;
	}
	sort(p+1,p+n+1,cmp);
    F(i,1,y){
	    sum+=p[i].b-p[i].c;
		q.push(p[i].b-p[i].c);
	}
	F(i,y+1,n-x+1){
	      l[i]=sum;
		  sum+=p[i].b-p[i].c;
		  q.push(p[i].b-p[i].c);
		  sum-=q.top();
		  q.pop();
	}
	while(!q.empty())q.pop();
	sum=0;
	f(i,n,n-x+1){
	   sum+=p[i].a-p[i].c;
	   q.push(p[i].a-p[i].c);
	}
	f(i,n-x,y){
	    ans=max(ans,tot+l[i+1]+sum);
		sum+=p[i].a-p[i].c;
		q.push(p[i].a-p[i].c);
		sum-=q.top();
		q.pop();
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2176
s = int(input())
a = s // 100
b = s % 100
if 0 < a <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
elif 0 < a <= 12:
    print('MMYY')
elif 0 < b <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> W(N);
  rep(i,N) cin>>W[i];
  rep(i,N) if(i) W[i]+=W[i-1];
  rep(i,N-1) W[i]=abs(2*W[i]-W[N-1]);
  sort(all(W));
  cout<<W[0]<<endl;
}

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

n=int(input())
a=[int(input()) for _ in range(n)]
b=[0 for _ in range(n)]

cnt=0
idx=0
while True:
    if n==0 or b[idx]==1:
        print(-1)
        break
    elif a[idx]==2:
        print(cnt+1)
        break
    b[idx]=1
    idx=a[idx]-1
    cnt+=1
    n-=1


Measured memory_bytes: 7852
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,h,w;
  cin>>n;
  cin>>h;
  cin>>w;

  int ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(i+h-1<=n&&j+w-1<=n) ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#入力
N = int(input())
maxmembers={}
for i in range(5):
    maxmembers[i] = int(input())

#シミュレーション
'''
citypeople = [N,0,0,0,0,0]
flag = bool(False)
time = 0

for i in range(6):
    print(citypeople[i],end=' ')
print('')

while True:
    for i in reversed(range(1,6)):
        if citypeople[i-1] > maxmembers[i-1]:
            citypeople[i] += maxmembers[i-1]
            citypeople[i-1] -= maxmembers[i-1]
        else:
            citypeople[i] += citypeople[i-1]
            citypeople[i-1] = 0
    time += 1
    
    for i in range(6):
        print(citypeople[i],end=' ')
    print('')
    
    if citypeople[5] == N:
        break

print(time)
'''
#ボトルネックを全部に適用する
mintransportation = maxmembers[0]
for i in range(1,5):
    if maxmembers[i] < mintransportation:
        mintransportation = maxmembers[i]

if N % mintransportation == 0:
    time = int(N / mintransportation) + 4
else:
    time = int(N / mintransportation) + 5
print(time)





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

int32_t main() {
        int a, b, k; cin >> a >> b >> k;
        int ax = min(k, a);
        k -= ax;
        a -= ax;
        
        int bx = min(k, b);
        k -= bx;
        b -= bx;
        
        cout << a <<  " " << b << endl;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> h(n);
  int highest = 0;
  int count=0;
  for (size_t i = 0; i < n; i++) {
    cin>>h[i];
    if (h[i]>=highest) {
      highest=h[i];
      count++;
    }
  }
  cout<<count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;	
int n,ans;
pair<int,int> a[55];
map<pair<int,int>,int> m;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&a[i].first,&a[i].second);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j) continue;
			m[make_pair(a[j].first-a[i].first,a[j].second-a[i].second)]++;
			if(ans<m[make_pair(a[j].first-a[i].first,a[j].second-a[i].second)]) ans=m[make_pair(a[j].first-a[i].first,a[j].second-a[i].second)];
		}
	}
	printf("%d",n-ans);
}

Measured memory_bytes: 384
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1): 
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)


Measured memory_bytes: 31948