akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////



void solve()
{

    ll n;
    cin>>n;

    if(n>=30)
        cout<<"Yes";
    else
        cout<<"No";

    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        //cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

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

const int MAXN = 1e5 + 10;
int n, ans;
struct Node {
	int cnt, val;
} a[MAXN], b[MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 1, x; i <= n; ++i) {
		scanf("%d", &x);
		if (i & 1) {
			++a[x].cnt, a[x].val = x;
		} else {
			++b[x].cnt, b[x].val = x;
		}
	}
	std::sort(a + 1, a + MAXN, [](Node a, Node b) {
		return a.cnt > b.cnt;
	});
	std::sort(b + 1, b + MAXN, [](Node a, Node b) {
		return a.cnt > b.cnt;
	});
	if (a[1].val == b[1].val) ans = n - std::max(a[1].cnt + b[2].cnt, a[2].cnt + b[1].cnt);
	else ans = n - a[1].cnt - b[1].cnt;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1792
/* vo05_592.cpp */
#include <iostream>
using namespace std;

int main()
{
	int sum, score;

	sum = 0;
	for (int i = 0; i < 5; ++i) { 
		cin >> score;
		
		if (score < 40) score = 40;

		sum += score;
	}
	
	cout << sum / 5 << '\n';

	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

std::int64_t val_div(std::int64_t a, std::int64_t b)
{
	while (a % b == 0)
	{
		a /= b;
	}
	return a;
}

void Main()
{
	std::int64_t N;
	std::cin >> N;
	std::set<std::int64_t> result = { 0, N - 1,N };
	for (std::int64_t v = 2; v * v <= N; ++v)
	{
		if (N % v == 0)
		{
			auto u = N / v;
			auto V = val_div(N, v);
			auto U = val_div(N, u);
			if (V % v == 1)
			{
				result.emplace(v);
			}
			if (U % u == 1)
			{
				result.emplace(u);
			}
		}
		else if (N % v == 1)
		{
			result.emplace(v);
			result.emplace((N - 1) / v);
		}
	}
	result.erase(0);
	result.erase(1);
	std::cout << result.size() << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

using namespace std;

int main()
{
    int N;
    long long ans = 0;
    cin >> N;
    vector<int> i(N);
    for (int j = 0; j < N; j++)
        cin >> i.at(j);

    for (int j = 0; j < N - 1; j++)
        for (int k = j + 1; k < N; k++)
        {
            ans += i.at(j)*i.at(k);
        }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    n = 55555
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

    primes = []
    for i in range(2, n):
        if is_prime[i]:
            primes.append(i)

    ans = [2]
    cnt = 1
    for p in primes[1:]:
        a = p // 2
        if a % 5 == 1:
            ans.append(p)
            cnt += 1

            if cnt == N:
                break

    print(*ans, sep=" ")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3700
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  const c = parseInt(input.split(" ")[2], 10);
  const x = parseInt(input.split("\n")[1], 10);
  console.log(Math.max.apply(null,[a,b,c])*Math.pow(2,x)+a+b+c-Math.max.apply(null, [a,b,c]));

  

}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22080
// CppPractice.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <vector>

using namespace std;

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

	string s;
	cin >> s;
	
	int sum = 1;
	for (int i = 1; i < n; i++) {
		if (s.at(i) != s.at(i - 1)) sum += 1;
	}
	cout << sum << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 512
//Print a Chessboard

#include<stdio.h>

int main()
{
    int i, j,kmax;
    int H[100], W[100];
    int k=0;
    
//    if(H<1 || H<300 || W<1 || 300<W) return 0;
    
    while(1){
        scanf("%d %d",&H[k], &W[k]);
        if(H[k]==0 && W[k]==0) break;
        k++;
        kmax=k;
    }
    
    for(k=0; k<kmax; k++){
        for(j=1; j<=H[k]; j++){
            for(i=1; i<=W[k]; i++){
                if((j%2) != 0){
                    if(i%2 != 0) printf("#");
                    else if(i%2 == 0) printf(".");
                }
                else if((j%2) == 0) {
                    if(i%2 != 0) printf(".");
                    else if(i%2 == 0) printf("#");
                }
            }
        printf("\n");
        }
        printf("\n");
    }
    return 0;
}





Measured memory_bytes: 2556
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
const int MAXN = 2e5+5;
int a[MAXN],v[MAXN];
int dp[MAXN];
int main()
{
    int h,n;
    cin>>h>>n;
    int max_a = 0;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i]>>v[i];
        max_a = max(max_a,a[i]);
    }
    memset(dp,MAXN,sizeof(dp));
    dp[0] = 0;
    for(int i = 0;i<n;i++)
        for(int j = a[i];j <= h+max_a;j++)
            dp[j] = min(dp[j],dp[j-a[i]]+v[i]);
    int ans = 1e9+7;
    for(int i = h;i<=h+max_a;i++) ans = min(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
typedef long long ll;
using namespace std;
string s; 
ll sum=0;
bool is_plus[11]={};
void calc(int n,int i){
  if(i==n-1){
    ll keta=10;
    sum+=s[i]-'0';
    for(int i=n-2;i>=0;i--){
      if(is_plus[i]){
        keta=1;
      }
      sum+=(s[i]-'0')*keta;
      keta*=10;
    }
    return;
  }
  is_plus[i]=true;
  calc(n,i+1);
  is_plus[i]=false;
  calc(n,i+1);
}
int main(){
  cin >> s;
  if(s.size()==1){
    cout << s<<endl;
    return 0;
  }
  calc(s.size(),0);
  cout << sum << endl;
}


Measured memory_bytes: 256
def linear_search(number, list):
    i = 0
    n = len(list)
    list.append(number)
    while list[i] != number:
        i += 1
    if i == n:
        return 0
    return 1

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = map(int, input().split())
cnt = 0
for i in T:
    cnt += linear_search(i, S)
print(cnt)



Measured memory_bytes: 6552
<?php

while($s = fgets(STDIN)){
	$len = strlen($s);
	for($n = 1; $n <= 255; $n++){
		for($i = 0; $i < $len; $i++){
			$c = $s[$i];
			if('a' <= $c && $c <= 'z'){
				$c = chr(ord($c) + 1);
				if($c > 'z'){
					$c = 'a';
				}
				$s[$i] = $c;
			}
		}
		if(preg_match('/( |^)(the|this|that)( |\.|\n)/', $s)){
			echo $s;
			$n = 256;
			break;
		}
	}
}

Measured memory_bytes: 15444
#include <stdio.h>

char x[1010][1010];
int check[1010][1010];
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%s",x[i]+1);
	
	check[1][1] = (x[1][1]=='#'?1:0);
	for(int i=1;i<=a;i++) check[i][0] = 12345;
	for(int j=1;j<=b;j++) check[0][j] = 12345;
	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=b;j++)
		{
			if(i==1&&j==1) continue;
			int s1 = check[i-1][j];
			if(x[i][j]=='#'&&x[i-1][j]=='.') s1++;
			int s2 = check[i][j-1];
			if(x[i][j]=='#'&&x[i][j-1]=='.') s2++;
			check[i][j] = (s1<s2?s1:s2);
		}
	}
	printf("%d",check[a][b]);
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

const int MOD = 1e9+7;
string digit(ll N){
    string ans;
    while(N>0){
        ans += (N%2==0?'0':'1');
        N/=2;
    }
    reverse(ALL(ans));
    return ans;
}

int main() {
    ll N; cin >> N;
    string s = digit(N);
    vector<vector<ll>> dp(s.size()+1,vector<ll>(3,0));
    dp[0][0] = 1;

    //dp[digit][state];
    REP(i,s.size()){
        REP(x,3){
            REP(k,3){
                int next = min(2,2*x+(s[i]-'0')-k);
                if(0<=next){
                    dp[i+1][next] += dp[i][x];
                    dp[i+1][next] %= MOD;
                }
            }
        }
    }
    ll ans = 0;
    REP(i,3){
        ans += dp[s.size()][i];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

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

public class Main {


    public static void main(String[] args) throws Exception {

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int x = fs.nextInt();
        
        if(x>=30){
            out.println("Yes");
        }else{
            out.println("No");
        }









        out.close();

    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


Measured memory_bytes: 32932
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

#include<unistd.h>
char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 0,0,0,0,0,0,0,0,0,0,};
template <int size>
struct Buffer{
    int idx = 0;
    char buf[size];
    Buffer(){ read(0, buf, size); }
    int next(){
        int ret = 0;
        while(notDigits[buf[idx]]){ idx++; }
        while(!notDigits[buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return ret;
    }
};
struct FastInput {
    Buffer<1 << 22> buf;
    template <class T>
    FastInput& operator >> (T& num) { num = buf.next(); return *this; }
    void tie(int){ }
    template <class S, class T>
    friend FastInput& operator >> (FastInput& in, pair<S, T>& p){ return in >> p.first >> p.second; }
    template <class T>
    friend FastInput& operator >> (FastInput& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
};
FastInput fin;
#define cin fin

enum { SIZE = 1 << 20 };
char buf[SIZE];
int accs[512][512];
pair<int, int> pqs[100000];
int main(){
    int n, m, q;
    cin >> n >> m >> q;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        accs[0][r]++;
        accs[l + 1][r]--;
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            accs[i + 1][j] += accs[i][j];
            accs[i][j] += accs[i][j - 1];
        }
    }
    int idx = SIZE;
    for(int i = 0; i < q; i++){
        cin >> pqs[i].first >> pqs[i].second;
    }
    for(int i = q - 1; i >= 0; i--){
        int p = pqs[i].first, q = pqs[i].second;
        buf[--idx] = '\n';
        div_t num2;
        num2.quot = accs[p][q];
        do{
            num2 = div(num2.quot, 10);
            buf[--idx] = num2.rem + '0';
        }while(num2.quot);
    }
    write(1, buf + idx, SIZE - idx);
}


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

typedef long long ll;

const ll inf = (1LL << 60);

int n;

ll a[100002], dp[100002][2];

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

    cin >> n;

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

    dp[0][0] = a[0];
    dp[0][1] = -inf; //no puedo aplicar la operacion a un solo elemento
    dp[1][0] = a[0] + a[1];
    dp[1][1] = -(a[0] + a[1]);

    for(int i = 2; i < n; i++) {
        dp[i][0] = a[i] + a[i - 1] + max(dp[i - 2][0], dp[i - 2][1]);
        dp[i][0] = max(dp[i][0], a[i] + dp[i - 1][1]);

        dp[i][1] = -(a[i] + a[i - 1]) + max(dp[i - 2][0], dp[i - 2][1]);
        dp[i][1] = max(dp[i][1], dp[i - 1][1] - a[i] + a[i - 1] * 2);
    }
    cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
}

/**

dp(i, +) = a[i] + a[i - 1] + max(dp(i - 2, +), dp(i - 2, -))
dp(i, +) = a[i] + dp(i - 2, -)

dp(i, -) = -(a[i] + a[i - 1]) + max(dp(i - 2, +), dp(i - 2, -))
dp(i, -) = dp(i - 1, -) - a[i] + 2 * a[i - 1]

*/


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(),(x).end()

using ll = long long;

int main () {
  int a, b;
  cin >> a >> b;
  
  if (a+b < 10) {
    cout << a+b << endl;
  } else {
    cout << "error" << endl;
  }
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  vector<vector<int>> s(D,vector<int>(26));
  rep(i,26) cin >> c.at(i);
  rep(i,D){
    rep(j,26) cin >> s.at(i).at(j);
  }
  rep(i,D){
  	cout << ((i % 25)+1) << endl;
  }
  /* rep(i,D) cout << ((i % 26)+1) << endl; */
}


Measured memory_bytes: 3660
i = list(map(int, input().split()))
N = i[0]
M = i[1]
s = []
c = []
for i in range(M):
    l = list(map(int, input().split()))
    s.append(l[0])
    c.append(l[1])

ans = [0] * N
checked = [0] * N

bool = True

i = 0
for s_i in s:
    if checked[s_i - 1] == 0:
        ans[s_i - 1] = c[i]
    else:
        if ans[s_i - 1] != c[i]:
            print('-1')
            bool = False
            break
    checked[s_i - 1] = 1
    i += 1

if N > 1 and ans[0] == 0:
    if checked[0] == 0:
        ans[0] = 1
    else:
        print('-1')
        bool = False

if bool == True:
    if N == 1:
        print(ans[0])
    elif N == 2:
        print(ans[0]*10+ans[1]*1)
    elif N == 3:
        print(ans[0]*100+ans[1]*10+ans[2]*1)

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll n, k; cin >> n >> k;

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

    vector<ll> f(n);
    for (ll i = 0; i < n; ++i) {
        cin >> f[i];
    }

    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    ll l = -1, r = 1e12; //左側は必ずfalse、右側は必ずtrueになるものを設定する

    while (l+1 < r) {
        ll mid = (l + r) / 2;

        bool ok = [&] { //参照でキャプチャ
            ll s = 0;
            for (ll i = 0; i < n; ++i) {
                s += max(0LL, a[i] - mid / f[i]); //定数をlong longで扱う
            }

            return s <= k;
        }(); //即時実行

        if (ok) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << r << endl;
}

Measured memory_bytes: 3328
# ABC100C - *3 or /2
n = int(input())
lst = [i for i in list(map(int, input().rstrip().split())) if i % 2 == 0]
if lst == []:
    print(0)
else:
    ans = 0
    for i in lst:
        cnt = 0
        while i % 2 == 0:
            i //= 2
            cnt += 1
        ans += cnt
    print(ans)

Measured memory_bytes: 4148
#include<stdio.h>
int main(void){
	int n, m;
  int min, max;
  
  scanf("%d %d", &n, &m);
  
  int r[m][2];
  
  for(int i = 0; i < m; i++){
  	for(int j = 0; j < 2; j++){
    	scanf("%d", &r[i][j]);
    }
  }
  
    for(int i = 0; i < m; i++){
  		if(i == 0){
        	min = r[i][1];
          	max = r[i][0];
        }
      	else{
        	if(min > r[i][1]){
            	min = r[i][1];
            }
          	if(max < r[i][0]){
            	max = r[i][0];
            }
        }
    }
  if((min - max) + 1 >= 0){
  	printf("%d\n", (min - max) + 1);  
  }
  else{
  	printf("0\n");
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int h,w;
    cin >> h >> w;
    vector<vector<string>> a(h, vector<string>(w));
    rep(i,h)
    {
      string s;
      cin >> s;
      rep(j,w) a[i][j] = s.substr(j,1);
    }

    bool all_w_zero[h] = {false};
    bool all_h_zero[w] = {false};

    rep(i,h)
        rep(j,w)
        {
      		if(a[i][j] == "#") break;
            if(j == w-1) all_w_zero[i] = true;
        }

    rep(j,w)
        rep(i,h)
        {
            if(a[i][j] == "#") break;
            if(i == h-1) all_h_zero[j] = true;
        }

    rep(i,h)
    {
        if(all_w_zero[i]) continue;
        rep(j,w)
        {
            if(!all_h_zero[j])
                cout << a[i][j];
        }
      	cout << endl;
    }

    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    int n,m;
    cin>>n>>m;
    int ans=(n*(n-1))/2+(m*(m-1))/2;
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
////////////////////////////////////////
///  tu3 pro-con template            ///
////////////////////////////////////////
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <regex>
using namespace std;

//// MACRO ////
#define countof(a) (sizeof(a)/sizeof(a[0]))

#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define RFOR(i,s,n) for (int i = (n)-1; i >= (s); i--)
#define pos(c,i) c.being() + (i)
#define allof(c) c.begin(), c.end()
#define aallof(a) a, countof(a)
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define apartof(a,i,n) a + (i), a + (i) + (n)

#define EPS 1e-9
#define INF (1L << 30)
#define LINF (1LL << 60)

inline int sign(double x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }

//// i/o helper ////

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
struct _Writer { bool f; _Writer() : f(false) { } template <class T> _Writer operator ,(const T &rhs) { cout << (f ? " " : "") << rhs; f = true; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
#define WRITE(...) _Writer(), __VA_ARGS__; cout << endl

//// start up ////
void solve();
int main()
{
	solve();
	return 0;
}

////////////////////
/// template end ///
////////////////////

void solve()
{
	READ(long long, N);

	long long n = 1;
	for (int i = 0; i < 99; i++)
	{
		if (N <= n)
		{
			n = i;
			break;
		}
		n *= 3;
	}
	WRITE(n);
}

Measured memory_bytes: 1156
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a*n, b);	
	return 0;
}

Measured memory_bytes: 256
public class Main {


  private static void solve() {
    int n = ni();
    int[][] p = ntable(n, 2);
    
    if (n == 1) {
      System.out.println(1);
      return;
    }

    int ret = Integer.MAX_VALUE;
    for (int i = 0; i < n; i ++) {
      for (int j = 0; j < n; j ++) {
        if (i == j) continue;
        int dx = p[i][0] - p[j][0];
        int dy = p[i][1] - p[j][1];
        ret = Math.min(ret, f(p, dx, dy));
      }
    }
    System.out.println(ret);
  }
  
  private static int f(int[][] p, int dx, int dy) {
    int n = p.length;
    int cnt = 0;
    for (int i = 0; i < n; i ++) {
      for (int j = 0; j < n; j ++) {
        if (p[i][0] - p[j][0] == dx && p[i][1] - p[j][1] == dy) {
          cnt ++;
        }
      }
    }
    return n - cnt;
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23764
fn main() {
    let sc = std::io::stdin();
    let mut sc = Scanner { reader: sc.lock() };
    let n = sc.read();
    let m = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let u = sc.read::<usize>() - 1;
        let v = sc.read::<usize>() - 1;
        graph[u].push(v);
        graph[v].push(u);
    }

    let mut pairs = vec![];
    let mut color = vec![0; n];
    for i in 0..n {
        if color[i] == 0 {
            let mut count = 0;
            color[i] = 1;
            let is_bipartite = coloring(&graph, &mut color, i, &mut count);
            pairs.push((count, is_bipartite));
        }
    }

    let mut num_single = 0;
    let mut num_bipartite = 0;
    for &(count, is_bipartite) in pairs.iter() {
        if count == 1 {
            num_single += 1;
        } else if is_bipartite {
            num_bipartite += 1;
        }
    }
    let num_non_bipartite = pairs.len() - num_single - num_bipartite;
    let singles = num_single * n * 2 - num_single * num_single;
    let non_bipartites = num_non_bipartite * (num_bipartite + num_non_bipartite) * 2
        - num_non_bipartite * num_non_bipartite;
    let bipartites = num_bipartite * num_bipartite * 2;
    println!("{}", singles + non_bipartites + bipartites);
}

fn coloring(graph: &Vec<Vec<usize>>, color: &mut Vec<usize>, v: usize, count: &mut usize) -> bool {
    *count += 1;
    let mut result = true;
    for &next in graph[v].iter() {
        let next_color = if color[v] == 1 { 2 } else { 1 };
        if color[next] == 0 {
            color[next] = next_color;
            result &= coloring(graph, color, next, count);
        } else if color[next] != next_color {
            result = false;
        }
    }

    result
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 18300
def a(t,x,y):
    n=abs(x)+abs(y)
    if (t-n)%2==0 and t-n>=0 :
        return 1
    else :
        return 0
N=int(input())
result=1
tn,xn,yn=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    tn=t-tn
    xn=x-xn
    yn=y-yn
    result*=a(tn,xn,yn)
    if result==0:
        print('No')
        break
if result:
  print('Yes')

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

int main(){
    long N, W; cin >> N >> W;
    vector<vector<long>> dp(N+1, vector<long>(W+1, 0));
    for(int i=0; i<N; i++){
        int w, v; cin >> w >> v;
        for(int j=0; j<W+1; j++){
            if( j-w >=0 ) dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v);
            else dp[i+1][j] = max(dp[i][j], dp[i][0]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
unittest
{
	assert( [ "5 3" ].parse.expand.solve == "3\n6\n1" );
	assert( [ "2000 3" ].parse.expand.solve == "1998\n3990006\n327341989" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	auto r = n - k;
	auto anss = new long[ k ];
	foreach( i, ref ans; anss )
	{
		if( r < i ) break;
		
		auto cb = ( k - 1 ).combinationMod( i );
		auto cr = ( r + 1 ).combinationMod( i + 1 );
		ans = cb.mulMod( cr );
	}
	return anss.to!( string[] ).join( "\n" );
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}

// 割り算
auto divMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y.powMod!MOD( MOD - 2 ) % MOD;
}

// べき乗
auto powMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}

// 階乗
auto factorialMod( long MOD = 10L ^^ 9 + 7 )( long x )
{
	static memo = [ 1L ];
	if( memo.length <= x )
	{
		auto i = memo.length;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i % MOD;
	}
	return memo[ x ];
}

// 組み合わせ数
auto combinationMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x < y ) ? 0L : x.factorialMod!MOD.divMod!MOD( y.factorialMod!MOD * ( x - y ).factorialMod!MOD % MOD );
}


Measured memory_bytes: 380
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  while(true){
    int h, w;
    cin >> h >> w;

    if(h==0&&w==0)
      break;

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	if(i==0 || i==h-1 || j==0 || j==w-1)
	  cout << "#";
	else
	  cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
n,m = map(int,input().split())
s = []
c = []
while True:
  try:
    tmp = list(map(int,input().split()))
    s.append(tmp[0])
    c.append(tmp[1])
  except EOFError:
    break
if n == 1 and all(i == 0 for i in c):
  print(0)
  exit()
for i in range(10**(n-1),10**n):
  cnt =0
  tmp = str(i)
  for _ in range(len(c)):
    if tmp[s[_]-1]==str(c[_]):
      cnt +=1
  if cnt == len(c):
    print(i)
    exit()
print("-1")

Measured memory_bytes: 3064
DX = [0,0,-1,1]
DY = [-1,1,0,0]

H,W = map(int,input().split())

# 番兵法 (#を外周に設置する)
visited = [[True] * (W + 2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True] * (W + 2))

# #の位置をqに格納
q = []
for i in range(1,H+1):
    for j in range(1,W+1):
        if visited[i][j]:
            q.append((i,j))

# dx,dyを使用せずにBFS 
# 定数倍改善
ans = 0
while q:
    qq = []

    # 新たに#となった地点をqqに格納
    for y,x in q:
        for dy,dx in zip(DY,DX):
            if not visited[y+dy][x+dx]:
                visited[y+dy][x+dx] = True
                qq.append((y+dy,x+dx))

    if not qq:
        break
    
    ans += 1
    q = qq

print(ans)

Measured memory_bytes: 109092
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

vector<vector<pair<int, int>>> v;
int main()
{
  vector<vector<int>> v;
  int n, m; cin >> n >> m;
  v.resize(m);
  vector<int> p(m);
  rep(i, m){
    int a; cin >> a;
    v[i].resize(a);
    rep(j, a) cin >> v[i][j];
  }
  int ans = 0;
  rep(i, m) cin >> p[i];
  for(int bit = 0; bit < (1 << n); bit++){
    bool f = true;
    for(int i = 0; i < m; i++){
      int cnt = 0;
      for(int j = 0; j < v[i].size(); j++){
        if(bit & (1 << v[i][j]-1))cnt++;
      }
      if(cnt % 2 != p[i])f = false;
    }
    if(f)ans++;
  }
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 504
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
     try{
         while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W== 0)break;
            for(int i = 0; i<H;i++){
                for(int j=0; j<W;j++){
                    if(i==0 || i==H-1 || j==0 || j==W-1){
                        System.out.print("#");
                    }
                    else System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
     }
        catch(Exception e){
            return;
        }
    }
        
}


Measured memory_bytes: 32220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<double, P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)10000000000000000

int main() {
  ll A,B,C;
  ll K;
  cin>>A>>B>>C>>K;
  int flag=0;
  rep(i,K){
    if(A>=B){B*=2ll;continue;}
    if(B>=C){C*=2ll;continue;}
  }
  if(A<B&&B<C){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}


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

  $d = explode(" ", trim(fgets(STDIN)));

  sort($d);

  $half = $n / 2;

  $a = $d[$half];
  $b = $d[$half-1];

  if($a == $b){
    echo "0";
    exit;
  }

  echo $a - $b;

Measured memory_bytes: 12792
use std;

pub fn main() {
  fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse::<T>().ok().unwrap()
  }
  let k = read::<i128>();
  let mut current = 100 as i128;
  let mut ans = 0;
  while current < k {
    current *= 101;
    current /= 100;
    ans += 1;
  }
  println!("{:?}", ans);
}

Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }

    REP(times, k){
        bool flag = true;
        vector<ll> b(n+1, 0);
        REP(i, n){
            ll start = max(0ll, i - a[i]);
            ll finish = min(n-1, i + a[i]);
            b[start] ++;
            b[finish + 1] --;
        }
        REP(i, n){
            b[i+1] += b[i];
            if(b[i] != n) flag = false;
        }
        a = b;
        if(flag == true){
            break;
        }
    }
    REP(i, n){
        cout << a[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 8012
#include<bits/stdc++.h>
using namespace  std;
int main(){
  int R,G,B,n;
  cin >> R >> G >> B >> n;
  int rm,gm,bm;
  rm = n/R;
  gm = n/G;
  bm = n/B;
  int count=0;
  for (int i=0;i<=rm;i++){
    for (int j=0;j<=gm;j++){
      if (i*R+j*G > n) break;
      if ((n - (i*R + j*G)) % B == 0) count++;
    }
  }
  cout << count << endl;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main()
{
  ll A, B, C, D, ans=0, start;
  cin >> A >> B >> C >> D;
  ll X1 = B/C;
  ll X2 = (A-1)/C;
  ll Y1 = B/D;
  ll Y2 = (A-1)/D;
  ll X = X1-X2;
  ll Y = Y1-Y2;
  ll Z1 = B/lcm(C,D);
  ll Z2 = (A-1)/lcm(C,D);
  ll Z = Z1-Z2;
  cout << (B-A+1) - (X + Y - Z) << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

ll C[60][60]; //C[n][k] -> nCk
void comb(int n){
    for(int i=0; i<=n; i++){
        for(int j=0; j<=i; j++){
            if(j == 0 || j == i){
                C[i][j]=1LL;
            }
            else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}

int main(){
    int n, p; cin>>n>>p;
    ll ocnt=0, ecnt=0;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        if(a%2 == 0) ecnt++;
        else ocnt++;
    }

    comb(55);

    ll osum=0, esum=1;
    if(p%2 == 0){
        int eocnt=ocnt;
        if(eocnt%2 == 1) eocnt--;
        for(int i=eocnt; i>=0; i-=2){
            osum+=C[ocnt][i];
        }
    }
    else{
        int oocnt=ocnt;
        if(oocnt%2 == 0) oocnt--;
        for(int i=oocnt; i>0; i-=2){
            osum+=C[ocnt][i];
        }
    }

    for(int i=0; i<ecnt; i++) esum*=2;
    cout << esum*osum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(ll arg_minus_value,ll arg_loc){
		minus_value = arg_minus_value;
		loc = arg_loc;
	}
	ll minus_value,loc;
};


int main(){

	ll S,T,D;
	scanf("%lld %lld %lld",&S,&T,&D);

	ll* table = new ll[D];
	for(int i = 0; i < D; i++)scanf("%lld",&table[i]);

	ll min_maximum = 0;

	vector<Info> V;
	if(table[0] < 0){
		V.push_back(Info(abs(table[0]),0));
		min_maximum = max(min_maximum,abs(table[0]));
	}

	for(int i = 1; i <= D-1; i++){
		table[i] += table[i-1];
		if(table[i] < 0){
			V.push_back(Info(abs(table[i]),i));
			min_maximum = max(min_maximum,abs(table[i]));
		}
	}

	ll tmp = S;

	for(int day = 1; day <= D; day++){
		tmp = S+table[day-1];
		if(tmp <= T){
			printf("%d\n",day);
			return 0;
		}
	}

	if(tmp >= S){
		printf("-1\n");
		return 0;
	}

	ll ans = D;

	while(tmp-min_maximum > T){
		ans += D;
		tmp -= V[V.size()-1].minus_value;
	}

	ll pre_loc = -1;

	for(int i = 0; i < V.size(); i++){

		if(V[i].loc <= pre_loc){
			ans += (V[i].loc+D)-pre_loc;
		}else{
			ans += V[i].loc-pre_loc;
		}
		if(tmp -V[i].minus_value<= T){
			printf("%lld\n",ans);
			return 0;
		}
		pre_loc = V[i].loc;
	}
	return 0;
}

Measured memory_bytes: 5708
n = int(input())
c = input().split()
d = c[:]

# bubblesort
for i in range(n):
    for j in range(n - 1, i, -1):
        if d[j][1] < d[j - 1][1]:
            d[j], d[j - 1] = d[j - 1], d[j]
print(*d)
print("Stable")

# selectionsort
for i in range(n):
    minj = i
    for j in range(i, n):
        if c[j][1] < c[minj][1]:
            minj = j
    c[i], c[minj] = c[minj], c[i]

print(*c)
print("Stable" if c == d else "Not stable")

Measured memory_bytes: 7704
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    int n,m; cin >> n >> m;
    vector<string> pa(n), pb(m);
    rep(i,n) cin >> pa.at(i);
    rep(i,m) cin >> pb.at(i);

    rep(i,n-m+1) rep(j,n-m+1){
        rep(k,m) rep(l,m){
            if(pa.at(i+k).at(j+l) != pb.at(k).at(l)) goto jump;
            if(k==m-1 && l==m-1){
                cout << "Yes" << endl;
            	return 0;
            }
        }
        jump:;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <string.h>
#include <stack>
using namespace std;

int main(void) {
	stack<int> S;
	int a, b, sw = true;
	string op;
	while ( cin >> op ) {
		if (op == "+") {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}
		else if (op == "-") {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(b - a);
		}
		else if (op == "*") {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		}
		else {
			S.push(atoi(op.c_str()));
		}
	}
	cout << S.top() << endl;
	return 0;
}


Measured memory_bytes: 3172
#include <stdio.h>

int main(){
    int a,b,money;
    scanf("%d %d",&a,&b);
    if(a>12){
        money = b;
    }else if (a>5) {
        money = b/2;
    }else
    {
        money = 0;
    }

    printf("%d",money);
    
    return 0;
}

Measured memory_bytes: 128
// +build ignore
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	A := sc.nextInt()
	B := sc.nextInt()
	C := sc.nextInt()

	if A <= C && C <= B {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


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

int main(){
    string s;
    cin >> s;
    string ans;
    for (int i = 0; i < s.size(); i = i+2)
    {
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

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


int main(){
    ll n, a, b;  cin >> n >> a >> b;
    string s;   cin >> s;
    ll cnt=0, bc=0;

    for(int i=0; i<n; i++){
        if(s[i]=='a' && cnt<a+b){
            cout << "Yes" << endl;
            cnt += 1;
        }else if(s[i]=='b' && cnt<a+b && bc<b){
            cout << "Yes" << endl;
            bc += 1;    cnt += 1;
        }else{
            cout << "No" << endl;
        }
    }
    
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define m 1000000007
int main()
{
	ll n,i,k,j;
	cin>>n>>k;
	ll a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	ll dp[n];
	dp[0]=0;
	//dp[1]=abs(a[1]-a[0]);
	for(i=1;i<n;i++)
	{
		dp[i]=10000000000;
		for(j=i-1;j>=0&&j>=i-k;j--)
		{
			dp[i]=min(abs(a[i]-a[j])+dp[j],dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
}


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

int main() {
  int N,K,count = 0;
  cin >> N >> K;
  vector<int> height(N);
  for(int i = 0;i < N;i++) {
    cin >> height.at(i); 
  }
  sort(height.begin(), height.end());
  reverse(height.begin(), height.end());
  for(int i = 0;i < N;i++) {
    if(height.at(i) >= K) {
      count = count + 1;
    }
    else {
      break;
    }
  }
  cout << count << endl;
}


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

#define rep(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9;

int64_t gcd(int64_t a, int64_t b){
  if(a%b==0) return b;
  return gcd(b, a%b);
}

int main() {
  int64_t A, B;
  cin >> A >> B;
  int M=max(A,B), m=min(A,B);
  cout << A*B/gcd(M,m) << endl;
}

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




int main() {
    ll N;
    cin >> N;
    ll num[5];
    for (int i=0; i < 5; i++) {
        cin >> num[i];
    }
    ll min = *min_element(num, num + 5);

    ll res;
    res = ceil((double)N / min) + 4;

    cout << res << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n)
    {
        cin >> a[i];
    }
    int min = 10000;
    rep(i, n)
    {
        int j = 0;
        while (a[i] % 2 == 0)
        {
            a[i] /= 2;
            j++;
        }
        if(min>j){
            min = j;
        }
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256