akhauriyash/Code-Regression huggingface dataset:
// 2014/07/28 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int t1, n1;
	cin >> t1 >> n1;
	if(t1==1){
		cout << 6000*n1 << '\n';
	}
	else if(t1==2){
		cout << 4000*n1 << '\n';
	}
	else if(t1==3){
		cout << 3000*n1 << '\n';
	}
	else{
		cout << 2000*n1 << '\n';
	}

	int t2, n2;
	cin >> t2 >> n2;
	if(t2==1){
		cout << 6000*n2 << '\n';
	}
	else if(t2==2){
		cout << 4000*n2 << '\n';
	}
	else if(t2==3){
		cout << 3000*n2 << '\n';
	}
	else{
		cout << 2000*n2 << '\n';
	}

	int t3, n3;
	cin >> t3 >> n3;
	if(t3==1){
		cout << 6000*n3 << '\n';
	}
	else if(t3==2){
		cout << 4000*n3 << '\n';
	}
	else if(t3==3){
		cout << 3000*n3 << '\n';
	}
	else{
		cout << 2000*n3 << '\n';
	}

	int t4, n4;
	cin >> t4 >> n4;
	if(t4==1){
		cout << 6000*n4 << '\n';
	}
	else if(t4==2){
		cout << 4000*n4 << '\n';
	}
	else if(t4==3){
		cout << 3000*n4 << '\n';
	}
	else{
		cout << 2000*n4 << '\n';
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {
	ll a,b;
	string s;
	cin >> a >> s;
	b = 0;
	b += (s[0] - '0') * 100;
	b += (s[2] - '0') * 10;
	b += (s[3] - '0');
	cout << a * b / 100 << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<functional>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<unordered_set>
#define int long long
#define mod 1000000007
using namespace std;

vector<int>V;
vector<int>k[26];
signed main() {
	string a; cin >> a;
	for (int i = 0; i < a.length(); i++) {
		for (int j = 0; j < 26; j++) {
			if (a[i] == j + 'a') {
				k[j].push_back(i);
			}
		}
	}
	int b = 0;
	unordered_set<char>S;
	string e = a;
	reverse(e.begin(), e.end());
	V.push_back(0);
	for (char c : e) {
		S.insert(c);
		if (S.size() == 26) {
			b++;
			S.clear();
		}
		V.push_back(b);
	}
	reverse(V.begin(), V.end());
	string ans;
	int t = 0;
	for (int i = 0; i < b + 1; i++) {//i文字目を決める
		for (int j = 0; j < 26; j++) {
			int sum = i;
			auto p = lower_bound(k[j].begin(), k[j].end(), t);
			int q = a.length()-1;
			if (p != k[j].end()) { q = *p; sum++; }
			if (sum + V[q+1] == b) {
				ans += j + 'a';
				t = q + 1;
				break;
			}
		}
	}
	cout << ans << endl;
}

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

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];
  while( scanf("%s",s) != EOF ){
    if( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);
    }else if( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a-b);
    }else if( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

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

  return 0;
}
			     
			 



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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int n, d, t, ans;
string s, rs;
vector<int> l, rl;

void inline kmp_init(string s, vector<int> &l) {
	l.resize(s.size()), fill(all(l), 0);
	for (int i = 1, k = 0; i < s.size(); ++i) {
		for (; k && s[i] != s[k]; k = l[k - 1]);
		l[i] = k += s[i] == s[k];
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin >> s;
	rs = s, reverse(all(rs));
	n = (int) s.size();
	kmp_init(s, l);
	kmp_init(rs, rl);
	reverse(all(rl));
	d = n - l[n - 1];
	if (d == n || n % d) {
		cout << 1 << ln << 1 << ln;
	} else if (d > 1) {
		loop (i, n - 1) {
			int l1 = i + 1, l2 = n - l1, dd1 = l1 - l[i], dd2 = l2 - rl[i + 1];
			ans += (l1 == dd1 || l1 % dd1) && (l2 == dd2 || l2 % dd2);
		}
		cout << 2 << ln << ans << ln;
	} else {
		cout << n << ln << 1 << ln;
	}
}

Measured memory_bytes: 5684
H,W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
import copy
h,w = 0,0
flg = True
ansl = []
l = []
for i in range(N):
    for j in range(a[i]):
        if W > w:
            l.append(i+1)
            w += 1
        else:
            if flg == True:
                flg = False
                ansl.append(copy.deepcopy(l))
            else:
                flg =True
                ansl.append(copy.deepcopy(l[::-1]))
            w = 1
            l = []
            l.append(i+1)

if flg == True:
    ansl.append(copy.deepcopy(l))
else:
    ansl.append(copy.deepcopy(l[::-1]))

for l in ansl:
    print(' '.join(map(str,l)))


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi a, ans=0;
	string b;

	cin>> a >> b;

	LLi tmp=(LLi)(b[0]-'0');
	ans+=(LLi)(a*tmp)*100;

	if(1){
		tmp=(LLi)(b[2]-'0');
		ans+=(LLi)(a*tmp)*10;
	}

	if(1){
		tmp=(LLi)(b[3]-'0');
		ans+=(LLi)(a*tmp);
	}

	cout<< ans/100 <<endl;
 
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
    mp::cpp_int a,b,n;
    cin >> a >> b >> n;

    if(n < b){
        mp::cpp_int d = (a * n )/b;
        cout << d << endl;
    } else {
        mp::cpp_int d = (a * (b-1))/b;
        cout << d << endl;
    }

    return 0;


}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
#define MAXN 12


int Solve[MAXN];
int N,M,X;

int C[MAXN], A[MAXN][MAXN];

bool check() {
    for(int i=0;i<M;i++) {
        if(Solve[i] < X)return false;
    }
    return true;
}


int main(){

    cin >> N >> M >> X;

    rep(i,N){
        cin >> C[i];
        rep(j,M)cin >> A[i][j];
    }

    rep(i,N) Solve[i] = 0;
    ll ans = 10000000;
    ll tmp = 0;

    for(int i=0;i<(1<<N);i++) {
        for(int j=0;j<N;j++) {
            if(i&(1<<j)) {
                for(int k=0;k<M;k++) {
                    Solve[k] += A[j][k];
                }
                tmp += C[j];
            }
        }
        if(check()){
            ans = min(tmp,ans);
        }
        tmp = 0;
        for(int k=0;k<M;k++)Solve[k] = 0;
    }
    if(ans == 10000000)cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
std::vector<long long> divisor(long long n) {
  vector< long long > ret;
  for(long long i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
int main()
{   
	long long n;
	std::cin >> n;
	std::vector<long long> ret;
	std::vector<long long> r = divisor(n);
	for(auto i : r) {
		ret.push_back(i);
	}
	
	long long counter=0;
    for(auto i : ret) {
		if(i==1)continue;
		if(n/(i-1)==n%(i-1))counter+=(i-1);
	}
	std::cout << counter << std::endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string N;

int main() {
  INCANT;
  cin >> N;
  int cnt=0;
  rep(i, 4) if (N[i]=='2') cnt++;
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 3544
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  if(N%2==0) printf("%d\n",N);
  else printf("%d\n",N*2 );
  return 0;

}


Measured memory_bytes: 384
// AtCoder154 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

int main() {

    int n, i, m;
    int* a; // 動的メモリの先頭アドレス用のポインタ
    int* buka;
    int sum = 0;
    assert(scanf("%d", &n) ==1);

    // malloc:確保したメモリの先頭アドレスを返す
    a = (int*)malloc(sizeof(int) * (n-1));
    buka = (int*)calloc(n,sizeof(int));
    for (i = 0; i < (n-1); i++) {
        assert(scanf("%d", &a[i]) == 1);
        buka[a[i] - 1]++;
    }
    
    for (i = 0; i < n; i++) {
        printf("%d\n", buka[i]);
    }
    free(a);
    free(buka);

    return 0;
}

Measured memory_bytes: 3036
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  const int x = (a + d - 1) / d;
  const int y = (c + b - 1) / b;
  cout << (x >= y ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, n)
    {
        int cnt = 0;
        string l = s.substr(0, i);
        string r = s.substr(i);

        set<char> lset;
        rep(j, l.length())
        {
            lset.insert(l[j]);
        }

        rep(j, r.length())
        {
            if (lset.count(r[j]) == 1)
            {
                ++cnt;
                lset.erase(r[j]);
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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


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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

struct Node {
    int val;
};

Node mn(int val) {
    Node d;
    d.val = val;
    Node* nxt;
    
    return d;
}

int main() {
	
	fastio;
    rd2(ll, n, k);
    vl A(n + 1);
    A[0] = -1;
    FOR(i, 0, n) {
        cin >> A[i + 1];
    }
    
    // find cycle length
    // we surely have a cycle;
    ll sls = 1, fs = A[1];
    
    while(A[sls] != A[fs]) {
        sls = A[sls];
        fs = A[A[fs]];
    }
    // not both meet
    ll st = 1;
    sls = A[sls];
    while(A[sls] != A[fs]) {
        sls = A[sls];
        st++;
    }
    // loop length
    // cout << st;
    set<ll> le;
    ll tpsl = A[sls];
    le.insert(sls);
    while(tpsl != sls) {
        le.insert(tpsl);
        tpsl = A[tpsl];
    }
    
    ll stp = 1;
    ll ctt = 1;
    while(k-- and le.find(ctt) == le.end()) {
        ctt = A[ctt];
    }
    k++;
    if(k > 0)
        k = k % st;
    
    while(k--) {
        ctt = A[ctt];
    }
    
    cout << ctt;
    



	return 0;
}

Measured memory_bytes: 13052
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int n, m;
	std::cin >> n >> m;

	std::vector<int> vec(m);
	for (int i = 0; i < n; ++i) {
		int k;
		std::cin >> k;

		for (int j = 0; j < k; ++j) {
			int a;
			std::cin >> a;

			++vec[a - 1];
		}
	}

	std::cout << std::count(vec.begin(), vec.end(), n) << std::endl;
}

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

int main() {
int N;
  cin >> N;
  string S;
  cin >> S;
  int count = 1;
  for(int i = 1; i < N; i++){
  	if(S[i] != S[i-1]){
    	count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 998244353
#define int long long
using namespace std;
const int N=4*1e5+100;
int n,a[N],b[N],cnt[N];
char s[N];
signed main()
{
	scanf("%lld",&n);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) a[i]=s[i]-'0';
	for (int i=1;i<=2*n;i++)
	{
		if ((2*n)%i!=0 || n%i==0) continue;
		int num=0;
		for (int j=1;j<=i/2;j++) b[j]=a[j],num=(num*2+a[j])%mod;
		cnt[i]=(cnt[i]+num)%mod;
		for (int j=i/2+1;j<=n;j+=i/2)
		{
			for (int k=j;k<j+i/2;k++)
			  b[k]=b[k-i/2]^1;
		}
		bool bl=1;
		for (int j=1;j<=n;j++)
		{
			if (b[j]>a[j])
			{
				bl=0;
				break;
			}
			if (a[j]>b[j]) break;
		}
		if (bl) cnt[i]=(cnt[i]+1)%mod;
		for (int j=i+i;j<=2*n;j+=i)
		{
			if ((2*n)%j!=0 || n%j==0) continue;
			cnt[j]=(cnt[j]-cnt[i]+mod)%mod;
		}
	}
	int ans=0;
	for (int i=1;i<=2*n;i++) ans=(ans+i*cnt[i]%mod)%mod;
	printf("%lld\n",ans);
}

Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "1" : "0");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{'; for(auto it=lb; it!=ub; it++) cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

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

  vi v;  
  int b[1+n]; fill(b, b+1+n, 0);
  for(int p=n; p>=1; p--) {
    int tot = 0;
    for(int j=p+p; j<=n; j+=p) tot += b[j];
    if( tot % 2 == a[p] ) continue;
    b[p] = 1;
    v.emplace_back(p);
  }

  cout << v.size() << endl;
  for(auto&x:v) cout << x << " ";
  cout << endl;

}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 3192
N = int(input())
S_list = list(input())
ans = 'No'
if N%2 == 1:
    print(ans)
else:
    for i in range(N//2):
        if S_list[i] != S_list[N//2 + i]:
            break
    else:
        ans = 'Yes'
    print(ans)

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
	int n, i;
	char man[4][3][10] = {};

	scanf("%d", &n);
	for(i = 0; i < n; i++){
		int b,f,r,v;

		scanf("%d %d %d %d", &b, &f, &r, &v);
		man[b-1][f-1][r-1] += v;
	}

	for(i = 0; i < 4*3*10; i++){
		if(i){
			if(!(i%10))
				printf("\n");
			if(!(i%30))
				printf("####################\n");
		}

		printf(" %d", *((char*)man+i));
	}
	printf("\n");
}



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

int main(){
  int N,M,P,X[100],sum=0;
  
  while(1){
    sum=0;
    cin >> N >> M >> P;
    
    if(N==0 && M==0 && P==0){
      break;
    }
    
    for(int i=0;i<N;i++){
      cin >> X[i];
      sum+=X[i];
    }

    if(X[M-1]==0){
      cout << 0 << endl;
      continue;
    }

    cout << (int)((double)sum*((double)(100.0-(double)P))/(double)X[M-1]) << endl;
  }
  return 0;
}

    
    
    
  
  



Measured memory_bytes: 3084
import java.util.*;
//import java.util.Math.*;

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

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A[] = new int[n];
    int i,j;
    
    for(i = 0; i < n; i++){
        A[i] = sc.nextInt();
       // System.out.println(A[i]);
    }
    
    int min = A[0];
    int maxv = A[1] - A[0];
    
    for(i = 1; i < n; i++){
        if((A[i] - min) > maxv){
            maxv = (A[i] - min);
        }
        if(A[i] < min){
            min = A[i];
        }
    }
    
    System.out.println(maxv);

    }
}



Measured memory_bytes: 101144
#include <iostream>
using namespace std;
long long n, x, s, mn=1e18, a[2005], m[2005];
int main() {
	int i, j;
	cin>>n>>x;
	for(j=0; j<n; j++) cin>>a[j], m[j]=1e9;
	for(i=0; i<n; i++) {
		s = 0;
		for(j=0; j<n; j++) {
			m[j] = min(m[j], a[(j-i+n)%n]);
			s += m[j];
		}
		mn = min(mn, s + i*x);
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
/*
 * @Description:
 * @Autor: G_Rampart
 * @Date: 2020-08-18 14:33:25
 * @LastEditTime: 2020-08-18 15:16:16
 */
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long cnt = 0;
    long k;
    int x = 7;
    cin >> k;
    while (1)
    {
        cnt ++;
        if (k%2 == 0 || k%5 == 0)
        {
            cout << -1 <<endl;
            return 0;
        }
        if(x % k == 0)
        {
            cout << cnt << endl;
            return 0;
        }
        x = 10 * (x % k) + 7;
    }
}


Measured memory_bytes: 3612
//
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};
int N,M,Q;
int m[112345];
int l[112345];

int need[112345];
int pos[112345];

int main(){
    int N,M;
    cin>>N>>M;
    for(int i:range(M)){
        cin>>m[i];
        m[i]--;
    }
    cin>>Q;
    for(int i:range(Q)){
        cin>>l[i];
    }
    for(int i:range(N)){
        pos[i]=-1e7;
    }

    for(int i:range(M)){
        pos[m[i]]=m[i];
    }
    need[0]=0-pos[0]+1;
    for(int i:range(1,N)){
        pos[i]=max(pos[i],pos[i-1]);
        need[i]=i-pos[i]+1;
    }

    sort(need,need+N);
/*
    for(int i:range(N))cerr<<pos[i]<<",";
    cerr << endl;

    for(int i:range(N))cerr<<need[i]<<",";
    cerr << endl;
*/

    for(int i:range(Q)){
        const int query = l[i];
        int ok=1e6;
        int ng=0;
        if(query<m[0]){
            ok=-1;
        }
        else{
            while(abs(ok-ng)>1){
                const int mid = (ok+ng)/2;
                int sonsitu = need+N-upper_bound(need,need+N,mid);
                if(sonsitu<=query){
                    ok=mid;
                }
                else{
                    ng=mid;
                }
            }
        }
        assert(ok<=112345);
        cout<<ok<<endl;
    }



    return 0;
}


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

using namespace std;

int main()
{
    long long int a,b,v,w,t;
    scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);

    long long int disTA = v*t;
    long long int disTB = w*t;

    if(b>a)
    {
        disTA += a;
        disTB += b;
    }
    else
    {
        disTA -= a;
        disTB -= b;
        disTA = abs(disTA);
        disTB = abs(disTB);
    }

    if(disTB<=disTA)
        cout<<"YES";
    else
        cout<<"NO";

    return 0;
}


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

typedef long long ll;

const int MOD = 1e9+7;

int main(){
  int n, m; cin >> n >> m;
  int x[n+1], y[m+1];
  for(int i=1; i<=n; i++) cin >> x[i];
  for(int i=1; i<=m; i++) cin >> y[i];

  ll xsum=0, ysum=0;
  for(int k=1; k<=n; k++){
    xsum += 1LL*(k-1)*x[k]-1LL*(n-k)*x[k];
    xsum %= MOD;
  }
  for(int k=1; k<=m; k++){
    ysum += 1LL*(k-1)*y[k]-1LL*(m-k)*y[k];
    ysum %= MOD;
  }

  cout << xsum*ysum%MOD << endl;

  return 0;
}


Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    R,G,B,N=map(int, input().split())
    cnt=0
    rnum=N//R
    gnum=N//G
    for r in range(rnum+1):
        for g in range(gnum+1):
            x=R*r+G*g
            if x>N:
                break
            else:
                if (N-x)%B==0:
                    cnt+=1
    print(cnt)
resolve()

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c =='o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

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

  sort(vd.begin(), vd.end());
  vd.erase(unique(vd.begin(), vd.end()), vd.end());
  cout << vd.size() << '\n';
  return 0;
}

Measured memory_bytes: 3636
using System;

public class hello
{
    public static void Main()
    {
        long t = 0;
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
            t  +=  int.Parse(Console.ReadLine().Trim());
        long av = t / n;
        Console.WriteLine(av);
    }
}

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3],i,n=3;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    if((a[0]!=a[2]&&a[1]!=a[2]&&a[0]==a[1])||(a[0]!=a[1]&&a[0]!=a[2]&&a[2]==a[1]))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

int main(){
	/*double*/unsigned long long int N;
	cin >> N;
	unsigned long long int i;
	char s[N];
	for(i=0; i<N; i++){
		cin >> s[i];
	}
	
	unsigned long long int count[26]={0}, Num=1;
	count[0]=1;
	char chars[26];
	chars[0]=s[0];
	
	unsigned long long int j=0;
	for(i=1; i<N; i++){
		int flg=0;
		j=0;
		do{
			if(s[i]==chars[j]){
				count[j]++;
				flg++;
			}
			else{
				j++;
			}
		}while(j<Num && flg==0);
		if(j==Num){
			count[j]=1;
			chars[j]=s[i];
			Num++;
		}
	}
	
	unsigned long long int ans = 1;
	for(i=0; i<Num; i++){
		ans *= (count[i]+1);
		if(ans>1000000007)	ans %= 1000000007;
	}
	ans %= 1000000007;
	
	cout << ans-1 << endl;
	
	return 0;
}




Measured memory_bytes: 384
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	string s;
	cin>>s;
	for(int i=1;i<s.length();i++){
		if(s[i]==s[i-1]){
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}


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

int main() {
    int n,k;
	scanf("%d%d",&n,&k);
	int h[n];
	for(int i=0;i<n;i++)scanf("%d",&h[i]);
	int dp[n];
	for(int i=0;i<n;i++)dp[i]=2000000010;
	dp[0]=0;
	for(int i=0;i<n-1;i++){
		for(int j=1;j<=k;j++){
			if(i+j>=n)break;
			dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
		}
	}
	printf("%d",dp[n-1]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  int mx = sqrt(m + 1) + 1;
  rep2(i, 2, mx) {
    if(m < i) break;
    while(m % i == 0) {
      m /= i;
      mp[i]++;
    }
  }
  if(m > 1) mp[m]++;
  combination c(1e6);
  mint ans = 1;
  for(auto v : mp) ans *= c(v.second + n - 1, n - 1);
  cout << ans.x << endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  int idx=-1;
  for(int i=0;i<n;i++){
    if(s[i]=='C'){
      idx=i;
      break;
    }
  }
  if(idx!=-1)for(int i=idx+1;i<n;i++){
    if(s[i]=='F'){
      puts("Yes");
      return 0;
    }

  }
  puts("No");
  return 0;
}


Measured memory_bytes: 764
n = gets.to_i
nums = gets.split.map(&:to_i)
rest = 1000
stock = 0
waiting_to_buy = true
previous = nums.first
last_price = previous
nums[1..-1].each do |num|
  if waiting_to_buy && num <= previous
    previous = num
    next
  elsif waiting_to_buy
    stock, rest = rest.divmod(previous)
    previous = num
    waiting_to_buy = !waiting_to_buy
    last_price = num
  elsif !waiting_to_buy && num >= previous
    previous = num
    next
  elsif !waiting_to_buy
    rest += previous * stock
    stock = 0
    previous = num
    waiting_to_buy = !waiting_to_buy
  end
end
puts rest + [last_price, nums.last].max * stock


Measured memory_bytes: 14412
import java.util.Scanner;

class Main{




	public static void main(String[] args) {





		Scanner sc = new Scanner(System.in);			//文字の入力
		int	x = sc.nextInt();
		if(x < 1200){
			System.out.println("ABC");
		}else{
			System.out.println("ARC");
		}


	}
}


class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int *c = new int[n-1];
  int *s = new int[n-1];
  int *f = new int[n-1];
  // Note: Station No. varies from 0 to n-2,
  // not 1 to n-1. 
  
  int *x = new int[n];
  int next;
  
  for (int i = 0; i <= n-2; i++)
  {
    cin >> c[i] >> s[i] >> f[i];
  }
  
  for (int i = 0; i <= n-1; i++)
  {
    x[i] = 0;

    for(int j = i; j <= n-1; j++)
    {
      // 最終駅ならおわり
      if (j < n-1)
      {
        next = f[j] * (x[i] / f[j]);
        if (x[i] % f[j] != 0) next += f[j];
        
        // 次乗れる便まで待つ
        x[i] = max(s[j], next);
        
        /*
        if (x[i] < s[j])	// 始発より前なら
        {
          x[i] = s[j];
          //wait for the FIRST train
        }
        else
        {
          x[i] = f[j] * (x[i] / f[j] + 1);
          //wait for the NEXT train
        }
        */
        
        x[i] += c[j];	// そこから駅j+1まで
        //cout << "x[" << i <<"]="<<x[i] <<endl;
      }
    }
    
    cout << x[i] << endl;
  }
  
  delete[] c, s, f, x;
  return 0;
}


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

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

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

	int k, a, b;	cin  >> k >> a >> b;

	int l  = (b/k)*k;

	if(a <= l)
		cout << "OK";
	else
		cout << "NG";

}


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

#define ipr 			pair<int, int>
#define pb 				push_back
#define ff 				first
#define ss 				second
#define mp 				make_pair
#define fr(i, j, k) 	for (int i = j; i < k; i++)
#define rf(i, j, k) 	for (int i = j; i >= k; i--)
#define int 			long long
#define ll 				unsigned long long
#define ld 				long double
#define all(x) 			x.begin(), x.end()
#define rall(x) 		x.rbegin(), x.rend()
#define cnt_ones(x) 	__builtin_popcountll(x)
#define dbg() 			cerr << "okay" << endl;			

#define IOS                           \
	std::ios::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);

const int inf = 1000000000000000000;
const int Maxn = 100001;
const ld pi = acos(-1);
const int mod = 998244353;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A)
{
	for (auto x : A)
		out << x << " ";
	return out;
}

int n, e;
vector<vector<int > > g;
vector<vector<int>> dis;

void graph_print(){
    fr(i,0,n)
        cout << g[i] << endl;
}

void graph_inp(){
    g.resize(n);
    e = n-1;    //for a tree
    fr(i,0,e){
        int u,v;    cin>>u>>v;
        --u;   --v;
        g[u].pb(v);
        g[v].pb(u);
    }  
    
}

void bfs(int root, int col){
    queue<int> q;   q.push(root);
    dis[root][col] = 0;
    while(!q.empty()){
        int node = q.front();   q.pop();
        for(auto child : g[node])
            if(dis[child][col] == -1){
                dis[child][col] = dis[node][col] + 1;
                q.push(child);
            }
          
    }
}

int32_t main(){IOS
    int x,y, ans=0;
    cin>>n>>x>>y;  x--; y--;
    graph_inp();
    dis.resize(n, vector<int>(2, -1));
    bfs(y,0);   bfs(x,1);
    fr(i,0,n)
       if(dis[i][1] < dis[i][0])
            ans = max(ans, dis[i][0]);
    cout << ans-1 << endl;
	return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>

int quick(int *arr, int L, int R);
void exch(int *arr, int i, int j);
void merge(int *arr, int L, int R);

int main()
{
	int N, K, i, T, j = 0, M, sum = 0;
	int arr[200001] = {0};

	scanf("%d %d", &N, &K);

	for (i = 0; i < N; i++)
	{
		scanf("%d", &T);
		arr[T]++;
	}

	merge(arr, 0, N);

	for (i = N-K; i >= 0; i--)
	{
		sum += arr[i];
	}

	printf("%d\n", sum);
}

int quick(int *arr, int L, int R)
{
	int left = L-1;
	int right = R;
	int index = L;
	int less = R;
	static int b[2] = {0};

	while (index < right)
	{
		if (arr[index] < arr[less])
			exch(arr, ++left, index++);
		else if(arr[index] > arr[less])
			exch(arr, --right, index);
		else
			index++;
	}
	exch(arr, right, less);

	b[0] = left+1;
	b[1] = right-1;
	
	return b;
}

void merge(int *arr, int L, int R)
{
	int *b;
	if (L < R)
	{
		b = quick(arr, L, R);
		merge(arr, L, b[0]-1);
		merge(arr, b[1]+1, R);
	}
}

void exch(int *arr, int i, int j)
{
	int temp;
	temp = arr[i];
	arr[i] = arr[j];
	arr[j] = temp;
}

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

int main() {
  
  int A=0, B=0;
  
  cin >> A >> B;
  
  int add = A+B;
  int sub = A-B;
  int mul = A*B;
  
  int ans = max(max(add, sub), mul);
  
  cout << ans << endl;
  
}

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

int N, K, H[100];
vector<int> L;
long long P[30];
long long D[101][101];
#define MOD 1000000007LL
long long R;

long long pow(int x) {
  long long r = 1;
  for(int b = 0; b < 30; ++b) {
    if((1 << b) & x) (r *= P[b]) %= MOD;
  }
  return r;
}
int main() {
  P[0] = 2LL;
  for(int i = 1; i < 30; ++i) {
    P[i] = P[i - 1] * P[i - 1] % MOD;
  }
  cin >> N;
  L.push_back(0);
  for(int i = 0; i < N; ++i) {
    cin >> H[i]; L.push_back(H[i]);
  }
  sort(L.begin(), L.end());
  L.erase(unique(L.begin(), L.end()), L.end());
  K = L.size();
  long long prev_l = 0; D[0][0] = 1;
  for(int i = 0; i < N; ++i) {
    long long l = lower_bound(L.begin(), L.end(), H[i]) - L.begin();
    if(prev_l >= l) {
      (D[i + 1][0] += 2 * D[i][0] % MOD) %= MOD;
      for(int k = 1; k <= l; ++k) {
        (D[i + 1][k] += D[i][k]) %= MOD;
      }
      for(int k = l + 1; k <= prev_l; ++k) {
        (D[i + 1][0] += 2 * D[i][k] % MOD) %= MOD;
      }
    } else {
      (D[i + 1][0] += 2 * D[i][0] % MOD) %= MOD;
      for(int k = prev_l + 1; k <= l; ++k) {
        (D[i + 1][k] +=
          2
          * (pow(L[k] - L[k - 1] - (k - 1 == 0 ? 1 : 0)) + MOD - 1) % MOD
          * pow(L[l] - L[k]) % MOD
          * D[i][0]) %= MOD;
      }
      long long C = pow(L[l] - L[prev_l]);
      for(int k = 1; k <= prev_l; ++k) {
        (D[i + 1][k] += C * D[i][k] % MOD) %= MOD;
      }
    }
    prev_l = l;
  }
  for(int k = 0; k < K; ++k) {
    (R += D[N][k]) %= MOD;
  }
  cout << R << endl;
  return 0;
}


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


int main() {
  long int N,A=1,C;
  cin>>N;
  vector<long int> B(N);
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  for(int i=0;i<N;i++){
    C=1000000000000000000/A;
    if(C<B[i])A=-1;
    if(A!=-1)A*=B[i];
    if(B[i]==0){A*=B[i];break;}
  }
  cout<<A<<endl;
}


Measured memory_bytes: 4044
from collections import defaultdict
import heapq
N=int(input())
alist=list(map(int,input().split()))

adic=defaultdict(int)
for a in alist:
  adic[a]+=1
  
hq=[]
for k,b in adic.items():
  heapq.heappush(hq,(-b,k))
#print(hq)  

cnt=0
while True:
  mf,n=heapq.heappop(hq)
  if mf==-1:
    break
  elif mf<=-3:
    heapq.heappush(hq,(mf+2,n))
    cnt+=1
  else:
    mf2,n2=heapq.heappop(hq)
    if mf2==-1:
      cnt+=1
      break
    else:
      heapq.heappush(hq,(mf+1,n))
      cnt+=1
    
print(N-2*cnt)

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

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

Measured memory_bytes: 1152
import numpy as np
from scipy.sparse.csgraph import floyd_warshall as fw
import sys
sdin = sys.stdin.readline


n,m = map(int, sdin().split())

INF = float("inf")
adj_mat = INF * np.ones((n, n))


for _ in range(m):
    a,b,c = map(int, sdin().split())
    a -= 1
    b -= 1
    adj_mat[a,b] = c
    adj_mat[b,a] = c

    
for i in range(n):
    adj_mat[i,i] = 0

    
shortest = fw(adj_mat)


ans = 0
for i in range(n):
    for j in range(i+1,n):
        if adj_mat[i][j] != INF and adj_mat[i][j] > shortest[i][j]:
            ans += 1

print(ans)

Measured memory_bytes: 14184
#include<iostream>
#include<algorithm>
#include<vector>
#include<bitset>

using namespace std;

int N;
vector<vector<int>> E;

int grundy[100000 + 100];

int dfs(int pos, int bef) {
	if (grundy[pos] != -1)return grundy[pos];

	int g = 0;
	for (int i = 0; i < E[pos].size(); i++) {
		int nxt = E[pos][i];
		if (nxt == bef)continue;
		g ^= (dfs(nxt, pos) + 1);
	}
	return grundy[pos] = g;
}

int main() {

	cin >> N;
	E.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		E[u].push_back(v), E[v].push_back(u);
	}

	for (int i = 0; i < N; i++)grundy[i] = -1;
	dfs(0, -1);

	if (grundy[0])cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 12416
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main(string[] args) {
        int N = cin.Int();
        var A = new long[N];
        var B = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.Long();
            B[i] = cin.Long();
        }

        long add = 0;
        for (int i = N - 1; i >= 0; i--) {
            if ((A[i] + add) % B[i] == 0) continue;
            else {
                add += B[i] - (A[i] + add) % B[i];
            }
        }

        Console.WriteLine(add);
        Console.ReadLine();
    }
}

Measured memory_bytes: 18648
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk,q;
  map<string,int> m;
  int c,x;
  string key;
  //cout << "hoge" << endl;
  map<string,int>::iterator it;
  
  cin >> q;


  for(ii=0;ii<q;ii++){
    cin >> c ;
    //cout << c << endl;
    if(c == 0){
      cin >> key >> x;
      //m.insert_or_assign(make_pair(key,x));
      m.erase(key);
      m.insert(make_pair(key,x));
    }
    else if(c==1){
      cin >> key;

      it = m.find(key);
      //cout << key << endl;
      if(it != m.end()){
          cout << m[key] << endl;
      }
      else{
        cout << 0 << endl;
      }


    }
    else if(c==2){
      cin >> key;
      m.erase(key);
    }
    //cout << key << endl;
  }

  
  return 0;
  
}



Measured memory_bytes: 27832
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  int N;
  int A[200];
  int count=0;
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> A[i];
  }
  bool flg=true;
  while(flg){
     for (int i=0;i<N;i++){
      if(A[i]%2!=0){flg=false;}
      else{A[i]/=2;}
    }
    count++;
  }
  cout << count-1 << endl;
  return 0;
}

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

int main(){
	while(1){
		int n;		
		scanf(" %d", &n);
		if(n==0) break;
		
		int a=0, b=0, c=0;
		int aok=0, bok=0, cok=0;
		
		for(int i=0; i<n; ++i){
			int h, m, M;
			
			scanf(" %d:%d %d", &h, &m, &M);
			if(m>M) M+=60;
			
			if(11<=h && h<=14){
				a++;
				if(M-m<=8) aok++;	
			}
			else if(18<=h && h<=20){
				b++;
				if(M-m<=8) bok++;	
			}
			else if(h==0 || h==1 || (21<=h && h<=23)){
				c++;	
				if(M-m<=8) cok++;	
			}		
				
		}
		
		printf("lunch ");
		if(a==0) printf("no guest\n");
		else printf("%d\n", aok*100/a);

		printf("dinner ");
		if(b==0) printf("no guest\n");
		else printf("%d\n", bok*100/b);

		printf("midnight ");
		if(c==0) printf("no guest\n");
		else printf("%d\n", cok*100/c);
	}
}

Measured memory_bytes: 1196
from math import floor
from fractions import Fraction
from decimal import Decimal


def com_interest(n: int) -> int:
    saving = Decimal(100)
    interest_per = 0.01
    years = 0

    while True:
        years += 1
        b = Decimal('1.01')
        saving = int(saving) * b
        if saving >= n:
            break
    return years


print(com_interest(int(input())))

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

const ll INF = 1001001001001;

ll ti[111][111];
ll co[111][111];

int main() {
    ll n, m;
    while (cin >> n >> m && !(n == 0 && m == 0)) {
        for (int i = 0; i < 111; i++) {
            for (int j = 0; j < 111; j++) {
                ti[i][j] = co[i][j] = INF;
            }
        }
        ll a, b, c, t;
        for (int i = 0; i < n; i++) {
            cin >> a >> b >> c >> t;
            a--; b--;
            co[a][b] = co[b][a] = c;
            ti[a][b] = ti[b][a] = t;
        }
        for (int k = 0; k < m; k++) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < m; j++) {
                    ti[i][j] = min(ti[i][j], ti[i][k] + ti[k][j]);
                    co[i][j] = min(co[i][j], co[i][k] + co[k][j]);
                }
            }
        }
        int k;
        cin >> k;
        for (int i = 0, p, q, r; i < k; i++) {
            cin >> p >> q >> r;
            p--; q--;
            if (r == 0) cout << co[p][q] << endl;
            else cout << ti[p][q] << endl;
        }
    }
}


Measured memory_bytes: 3208