akhauriyash/Code-Regression huggingface dataset:
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>

using namespace std;

typedef struct datum_name {
	int x;
	int y;
	int whosay;
	bool operator==(const datum_name& data) const
	{
		return (x == data.x && y == data.y);
	}
} datum;


bool cmp_who(const datum& left, const datum& right) {
	return left.whosay < right.whosay;
}


int main()
{
	int N;
	cin >> N;
	vector<int> array;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		array.push_back(tmp);
	}
	int target_n = 1;
	bool found = false;
	for (int i = 0; i < N; i++) {
		if (array[i] == target_n) {
			found = true;
			target_n++;
		}
	}

	if (!found) cout << "-1" << endl;
	else cout << N-(target_n-1) << endl;

	return 0;

}

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

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


Measured memory_bytes: 1400
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int A, B; cin >> A >> B;
	// A-1で割った時の余りの最大値を足せば切り上げと同じになる
	int ans = (B - 1 + A -2) / (A - 1);
	cout << ans;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b;
    cin >> a >> b;
    int ans = a/b;
    if(a%b) ans++;
    cout << ans << "\n";
    return 0;
}



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 main()
{
    int X, A;
    cin >> X >> A;

    cout << ((X < A) ? 0 : 10) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int x[200000];
int l[200000][20];
int r[200000][20];
int dp1[1 << 20];
int dp2[1 << 20];

int main() {
    int n, v, p = 0, c = 0, f = 0, i, j;
    
    scanf("%d %d", &n, &v);
    
    for (i = 0; i < n; i++) scanf("%d", &x[i]);
    
    for (i = 0; ; i++) {
        if ((1 << i) > v) {
            p = i + 1;
            
            break;
        }
    }
    
    for (i = 0; i < n; i++) {
        int nv = v;
        
        for (j = 0; j < p; j++) {
            if (i == 0 || x[i] - x[i - 1] > nv) {
                l[i][j] = i;
            } else {
                l[i][j] = l[i - 1][j];
            }
            
            nv /= 2;
        }
    }
    
    for (i = n - 1; i >= 0; i--) {
        int nv = v;
        
        for (j = 0; j < p; j++) {
            if (i == n - 1 || x[i + 1] - x[i] > nv) {
                r[i][j] = i;
            } else {
                r[i][j] = r[i + 1][j];
            }
            
            nv /= 2;
        }
    }
    
    for (i = 0; i < (1 << p); i++) {
        if (i & 1) continue;
        
        for (j = 1; j < p; j++) {
            if ((i >> j) & 1) continue;
            
            if (dp1[i] == n) {
                dp1[i | (1 << j)] = n;
            } else {
                dp1[i | (1 << j)] = max(dp1[i | (1 << j)], r[dp1[i]][j] + 1);
            }
        }
    }
    
    for (i = 0; i < (1 << p); i++) dp2[i] = n - 1;
    
    for (i = 0; i < (1 << p); i++) {
        if (i & 1) continue;
        
        for (j = 1; j < p; j++) {
            if ((i >> j) & 1) continue;
            
            if (dp2[i] == -1) {
                dp2[i | (1 << j)] = -1;
            } else {
                dp2[i | (1 << j)] = min(dp2[i | (1 << j)], l[dp2[i]][j] - 1);
            }
        }
    }
    
    for (i = 0; i < n; i++) {
        if (l[i][0] == i) c++;
    }
    
    if (c > p) {
        for (i = 0; i < n; i++) puts("Impossible");
        
        return 0;
    }
    
    for (i = 0; i < n; i++) {
        if (l[i][0] == i) {
            for (j = 0; j < (1 << p); j++) {
                if (j & 1) continue;
                
                if (i > 0 && dp1[j] < i) continue;
                if (r[i][0] < n - 1 && dp2[(1 << p) - 2 - j] > r[i][0]) continue;
                
                break;
            }
            
            if (j < (1 << p)) {
                f = 1;
            } else {
                f = 0;
            }
        }
        
        if (f == 1) {
            puts("Possible");
        } else {
            puts("Impossible");
        }
    }
    
    return 0;
}


Measured memory_bytes: 42496
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>

using namespace std;

#define ll long long
#define reps(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) reps(i, 0, n)
#define P pair<int, int>

const ll mod = 1000000007;

const int MAX_N = 1<<19;
const int INF = 1000000000;
// セグメント木を持つグローバル変数
int nn, dat[2 * MAX_N - 1];

void init(int n_){
    nn = 1;
    while(nn < n_) nn *= 2;
    for(int i = 0; i < 2 * nn - 1; i++) dat[i] = 0;
}

// k番目の値(0-indexed)をaに変更
void update(int k, int a){
    // 葉の節点
    k += nn - 1;
    dat[k] = a;
    // 登りながら更新
    while(k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

// [a, b)の最小値を求める
// 後ろのほうの引数は、計算の簡単のための引数
// kは節点の番号、lとrはその節点が[l, r)に対応付いていることを表す
// したがって、外からはquery(a, b, 0, 0, nn)として呼ぶ
int query(int a, int b, int k, int l, int r){
    // [a, b)と[l, r)が交差しなければ、INT_MAX;
    if(r <= a || b <= l) return 0;

    // [a, b)が[l, r)を完全に含んでいれば、この節点の値
    if (a <= l && r <= b) return dat[k];
    else{
        // そうでなければ2つの子の最小値
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}




int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    init(1<<19);
    for (int i = n-1; i >= 0; i--){
        int num = a[i];
        int now = query(num-k, num+k+1, 0, 0, 1<<19);
        now--;
        update(a[i], now);
        // cout << "c" << query(3, 10, 0, 0, 1<<19) << endl;
        // cout << now << endl;
    }
    
    int ans = query(0, 300002, 0, 0, 300002);
    ans = -ans;
    cout << ans << endl;
}

Measured memory_bytes: 8536
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    rep(i,m/2)cout<<i+1<<sp<<m-i<<endl;
    rep(i,(m+1)/2)cout<<m+i+1<<sp<<2*m+1-i<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());

    ll ans = 1, cnt = 0;
    rep(i, N - 1) {
        if (A[i] == A[i + 1]) {
            ans *= A[i];
            cnt++;
            i++;
        }
        if (cnt == 2)
            break;
    }

    if (cnt == 2)
        cout << ans << endl;
    else
        cout << 0 << endl;

    return 0;
}


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

int main(void)
{
    int A, B;
    scanf("%d %d", &A, &B);

    if(A<=5) printf("0\n");
    else if(A>=6 && A<=12){
        printf("%d\n", B/2);
        }
    else printf("%d\n", B);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> a(n, 123456);
    for (int i = 1; i < n; i++) {
        int x; cin >> x;
        a[i - 1] = min(a[i - 1], x);
        a[i] = min(a[i], x);
    }
    int res = 0;
    for (int x : a) {
        res += x;
    }
    cout << res << "\n";
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 +7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >>n >>m;
	vector<string> a(n);
	vector<string> b(m);
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];
	
	if(m>n){ puts("No"); return 0;}
	rep(y,n+1-m) rep(x,n+1-m){
		bool ng=0;
		rep(i,m) rep(j,m){
			if(b[i][j] != a[y+i][x+j]) ng=1;
		}
		if(ng==0){ puts("Yes");return 0;}
	
	}
	puts("No");
	
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#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,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
n = gets.to_i
a = gets.split(" ").map(&:to_i).sort{|c, b| b <=> c }

ans = 0
if n%2 == 0
    
for i in 0 .. (n-1)/2 do
    ans = ans + a[2*i] - a[2*i +1]
end
else
    for i in 0 .. (n-1)/2-1 do
    ans = ans + a[2*i] - a[2*i +1]
    end
    ans = ans + a[n-1]
end
puts ans



Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<double> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(ALL(a));
    for (ll i = 0; i < n - 1; i++)
    {
        a[i + 1] += a[i];
        a[i + 1] /= 2;
    }

    cout << SP(10) << a[n - 1] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int K,N,i;
    scanf("%d %d",&K,&N);
    int A[N];
    for (i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    int max=0;
    for(i=0;i<N-1;i++){
        if(max<A[i+1]-A[i]){
            max=A[i+1]-A[i];
        }
    }
    if(max<K-A[N-1]+A[0]) max=K-A[N-1]+A[0];
    printf("%d",K-max);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M ;
  
  vector<int> Ans(N);
  for(int i=0 ; i<Ans.size() ; i++){
    Ans.at(i)=0;
  } 
  
  for(int i=0 ; i<M ; i++){
    int a,b;
    cin >> a >> b ;
    Ans.at(a-1) += 1;
    Ans.at(b-1) += 1;
  }
  
  for(int i=0 ; i<N ; i++){
    cout << Ans.at(i) << endl ;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
bool map[810][810];
int dis[810][810];
#define x first
#define y second
int main()
{
	int n=gi(),i,j,t,m=gi(),k=gi(),x,y,d,ans=1<<30;char c;
	queue< pair<int,int> >q;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) {
			while ((c=getchar())!='S'&&c!='#'&&c!='.');
			if (c=='S') x=i,y=j;
			map[i][j]=c!='#';
		}
	q.push(make_pair(x,y));dis[x][y]=1;
	const int dx[4]={1,-1,0,0};
	const int dy[4]={0,0,1,-1};
	while (!q.empty()) {
		x=q.front().x,y=q.front().y;q.pop();
		if (x==1||x==n||y==1||y==n) return puts("1"),0;
		d=min(min(x-1,n-x),min(y-1,m-y));
		ans=min(ans,(d+k-1)/k+1);
		if (dis[x][y]<=k)
			for (t=0;t<4;t++)
				if (map[x+dx[t]][y+dy[t]]&&!dis[x+dx[t]][y+dy[t]]) {
					dis[x+dx[t]][y+dy[t]]=dis[x][y]+1;
					q.push(make_pair(x+dx[t],y+dy[t]));
				}
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat& A, mat& B) {
	mat C(A.size(), vec(B[0].size(), 0));
	for (int i = 0; i < A.size(); i++) {
		for (int k = 0; k < B.size(); k++) {
			for (int j = 0; j < B[0].size(); j++) {
				(C[i][j] += A[i][k] * B[k][j] % MOD) %= MOD;
			}
		}
	}
	return C;
}

mat pow(mat A, ll n) {
	mat B(A.size(), vec(A.size(), 0));
	for (int i = 0; i < A.size(); i++) {
		B[i][i] = 1;
	}
	while (n > 0) {
		if (n & 1) B = mul(B, A);
		A = mul(A, A);
		n >>= 1;
	}
	return B;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll K;
	cin >> n >> K;
	mat A(n, vector<ll>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> A[i][j];
		}
	}

	A = pow(A, K);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			(ans += A[i][j]) %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int n, a[101];
int ans=1;
int main()
{
    ios::sync_with_stdio(false);
    
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    sort(a, a+n);
    int val = a[0];
    for (int i = 1; i < n; i++)
        if (a[i] != val) {
            ans++;
            val = a[i];
        }
    
    cout << ans << '\n';
    
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, q;
    cin >> k >> q;
    int d[5010];
    rep(i, k) cin >> d[i];
    while(q--) {
        int n, x, m;
        cin >> n >> x >> m;
        int d2[5010];
        int N = n;
        rep(i, k) d2[i] = (d[i] + m - 1) % m + 1;
        // rep(i, k) cout << d2[i] << " ";
        // cout << endl;
        rep(i, k - 1) d2[i + 1] += d2[i];
        x = x % m;
        x += (n - 1)/k * d2[k - 1];
        n -= (n - 1)/k * k;
        // cout << x << " ";
        rep(i, n - 1) x += (d[i] + m - 1) % m + 1;
        // cout << x << " ";
        cout << N - x/m - 1 << endl;
    }

    return 0;
}


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

int main(){
  int n;
  cin>>n;
  if(n%1000==0){
    cout<<0<<endl;
  }else{
    cout<<1000-n%1000<<endl;
  }
}



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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

dp0 = list2d(N+1, 4, -INF)
dp1 = list2d(N+1, 4, -INF)
dp0[0][2] = 0
for i, a in enumerate(A):
    for j in range(4):
        if j != 0:
            dp0[i+1][j-1] = max(dp0[i+1][j-1], dp0[i][j])
            dp0[i+1][j-1] = max(dp0[i+1][j-1], dp1[i][j])
        if j != 3:
            dp1[i+1][j+1] = max(dp1[i+1][j+1], dp0[i][j] + a)
if N % 2 == 0:
    ans = max(dp0[N][2], dp1[N][2])
else:
    ans = max(dp0[N][1], dp1[N][1])
print(ans)


Measured memory_bytes: 138192
#include <stdio.h>
 
int main()
{
  int h,w;
  int i,j;
  scanf("%d",&h);
  scanf("%d",&w);
  while(!((h==0) && (w==0))){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d",&h);
    scanf("%d",&w);
  }
 
 
  return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0);

void solve(){
  	FAST_IO;
    int n; cin >> n;
    queue<string> q;
    for(int i=1; i<=9; i++)
        q.push(to_string(i));
    //cout << q.front() << endl;
    if(n <= 9) cout << n << endl;
    int start = 9;
    string ans;
    while(start < n){
        string k = q.front(); q.pop();
        //cout << start << " " << k << endl;
        if(k[0] == '9'){
            q.push('8'+k);
            start++;
            if(start == n){
                ans = '8'+k;
                break;
            }
            q.push('9'+k);
            start++;
            if(start == n){
                ans = '9'+k;
                break;
            }
        }
        else if(k[0] == '0'){
            q.push('0' + k);
            start++;
            if(start == n){
                ans = '0' + k;
                break;
            }
            q.push('1' + k);
            start++;
            if(start == n){
                ans = '1' + k;
                break;
            }
        }
        else{
            q.push(to_string(k[0] -'0' - 1) + k);
            start++;
            if(start == n){
                ans = to_string(k[0] -'0' - 1) + k;
                break;
            }
            q.push(k[0] + k);
            start++;
            if(start == n){
                ans = k[0] + k;
                break;
            }
            q.push(to_string(k[0] - '0' + 1) + k);
            start++;
            if(start == n){
                ans = to_string(k[0] - '0' + 1) + k;
                break;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    
}

int main(){
    int t = 1; //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3840
import fractions as math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B, C, D = (int(x) for x in input().split())

Cu = B//C       #Cの上限
Cd = -(-A//C)   #Cの下限
Du = B//D       #Dの上限
Dd = -(-A//D)   #Dの下限

#Least common multiple
LCMu = B//(lcm(C,D))
LCMd = -(-A//lcm(C,D))


C_num = Cu - Cd + 1
D_num = Du - Dd + 1
LCM_num = LCMu - LCMd + 1

C_D_num = C_num + D_num - LCM_num
A_B_num = B - A  + 1

ans = A_B_num - C_D_num
print(ans)


Measured memory_bytes: 64748
n = gets.to_i
a = n.times.map{gets.split.map(&:to_i)}.sort_by{|i,j|i}.reverse
c = n.times.map{gets.split.map(&:to_i)}.sort_by{|i,j|j}

ans = 0

n.times do |i|
    min = 1000
    n.times do |j|
        if a[i][0] < c[j][0] && a[i][1] < c[j][1]
            ans += 1
            c[j] = [-1,-1]
            break
        end
    end
end
puts ans

Measured memory_bytes: 1788
(function() {
	'use strict';
	var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;

	var push = ArrayProto.push,
	slice = ArrayProto.slice,
	concat = ArrayProto.concat,
	toString = ObjProto.toString,
	hasOwnProperty = ObjProto.hasOwnProperty;

	var
	nativeForEach = ArrayProto.forEach,
	nativeMap = ArrayProto.map,
	nativeReduce = ArrayProto.reduce,
	nativeReduceRight = ArrayProto.reduceRight,
	nativeFilter = ArrayProto.filter,
	nativeEvery = ArrayProto.every,
	nativeSome = ArrayProto.some,
	nativeIndexOf = ArrayProto.indexOf,
	nativeLastIndexOf = ArrayProto.lastIndexOf,
	nativeIsArray = Array.isArray,
	nativeKeys = Object.keys,
	nativeBind = FuncProto.bind;

	this._ = {};
	var each = _.each = _.forEach = function(obj, iterator, context) {
		if (obj == null) return;
		if (nativeForEach && obj.forEach === nativeForEach) {
			obj.forEach(iterator, context);
		} else if (obj.length === +obj.length) {
			for (var i = 0, l = obj.length; i < l; i++) {
				if (iterator.call(context, obj[i], i, obj) === breaker) return;
			}
		} else {
			for (var key in obj) {
				if (_.has(obj, key)) {
					if (iterator.call(context, obj[key], key, obj) === breaker) return;
				}
			}
		}
	};

	_.extend = function(obj) {
		each(slice.call(arguments, 1), function(source) {
			if (source) {
				for (var prop in source) {
					obj[prop] = source[prop];
				}
			}
		});
		return obj;
	};
}).call(global);

(function(undefined){
	'use strict';

	var INPUT_TYPE = 'string';

	var INPUT_REGEXP_LIST = {};
	INPUT_REGEXP_LIST['string'] = /\w*/g;
	INPUT_REGEXP_LIST['number'] = /[-]?\d+/g;
	var INPUT_REGEXP = INPUT_REGEXP_LIST[INPUT_TYPE];

	(function init() {
		this.output = function() {
			console.log.apply( console, arguments );
		};
		this.stdin = process.openStdin();
		stdin.setEncoding('utf8');
		this.input_list = [];
		stdin.on('data', function(chunk){
			var result = chunk.match(INPUT_REGEXP);
			input_list = input_list.concat(result.filter(function(line){
				return line.length;
			}));
		});
		stdin.on('end', function(){
			fire();
		});
		_.extend( this, {
			input_number: function() {
				return parseInt( input_list.splice(0,1)[0] );
			},
			input_text: function() {
				return input_list.splice(0,1)[0];
			},
			has_next: function() {
				return ! input_list.length;
			}
		} );
	}).call( this );

	(function solver(){
		this.fire = function() {
			setTimeout( solve, 0, this );
		};
		function solve() {
			output( input_text().split('').reverse().join('') );
			if ( ! has_next() )
				setTimeout( solve, 0, this );
		}
	}).call(this);

}).call(global);

Measured memory_bytes: 7868
#include<stdio.h>
int main(void){
  int n,a,b,i,j,num,all=0,sum,amari;
  scanf("%d %d %d",&n,&a,&b);
  for(i=1;i<=n;i++){
    num=i;
    sum=0;
    while(num!=0){
      amari=num%10;
      sum+=amari;
      num=num/10;
    }
    if(sum>=a&&sum<=b){
      all+=i;
    }
  }
  printf("%d",all);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(c - a) <= d)
    {
        cout << "Yes" << endl;
    }
    else if (abs(a - b) <= d && abs(b - c) <= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdio.h>
	int main(void) {


		int a, b, c,x1,x2,x3;
		scanf("%d %d %d", &a, &b, &c);
		x1 = a;
		if (x1 > b) {
			x1 = b;
			x2 = a;
		}
		else x2 = b;

		if (x1 > c) {
			x3 = x2;
			x2 = x1;
			x1 = c;
		}
		else if (x2 > c) {
			x3 = x2;
			x2 = c;
		}
		else {
			x3 = c;
		}

		printf("%d %d %d\n", x1, x2, x3);

		

    return 0;
}

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

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

  vector<int> A(N);
  int flag = 0;   // 奇数管理

  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if( A[i] % 2 != 0) {  // 入力の時点で奇数
      flag = 1;
      break;
    }
  }

  int count = 0;
  if (flag == 0) {  // 入力の時点では全部偶数
    for (int j = 0;;j++) {
      for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) A[i] /= 2;
        else {
          flag = 1;
          break;
        }
      }
      if (flag == 1) break;
      count++;    // 全部2で割ることが出来たら+1
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		long MOD=1000000007L;

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int m=sc.nextInt();
		int a[]=new int[m+1];
		a[m]=100001;

		int pt=0;

		long s[]=new long[n+1];
		s[0]=1L;

		for(int i=0;i<m;++i){
			a[i]=sc.nextInt();
		}

		if(a[0]==1){s[1]=0L; ++pt;}
		else s[1]=1L;


		for(int i=2;i<n+1;++i){
			if(a[pt]==i){s[i]=0L; ++pt;}
			else s[i]=(s[i-2]+s[i-1])%MOD;
		}


		System.out.println(s[n]);
	}
}

Measured memory_bytes: 50548
#include <iostream>
#include <vector>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <algorithm>

using namespace std;
using ll = long long;

#define X 1000000007


int main(){
    int n;
    cin>>n;
    vector<int> b(n);
    int a;
    ll tmp = 0;
    ll sum = 0;
    for(int i = 0;i<n;i++){
        cin>>a;
        tmp = (a + tmp) % X;
        b[i] = tmp;
    }
    
    sum = ll(b[0]*ll(X +b[n-1]-b[0]))%X;
    for(int i = 1; i < n - 1;i++){
        sum = ll(sum + ll(ll(X + b[i]-b[i-1]) % X * ll(X+b[n - 1] - b[i])% X)) % X;
    }
    cout<<sum<<endl;
    return 0;
}  


Measured memory_bytes: 3968
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, m) = (v[0], v[1]);
    if n == 1 && m == 1 {
        println!("1");
        return;
    }
    if n == 1 || m == 1 {
        println!("{}", max(n, m) - 2);
        return;
    }
    println!("{}", n * m - 2 * (n + m) + 4);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

score = 0
for i in range(len(A)):
#    print (f"i={i},A[i]-1={A[i]-1},B={B[A[i]-1]}")
    score += B[A[i]-1]

    if i != len(A)-1:
        if A[i+1] == A[i] + 1:
#            print (f"c,C[A[i]-1]={C[A[i]-1]}")
            score += C[A[i]-1]
#    print (f"score={score}")
print (score)


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

int main() {
  int N;
  cin >> N;
  
  for (int i =0; i < N; i++){
    string s;
    cin >> s;
    if (s == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (i == N-1){
      cout << "Three" << endl;
    }
  }
  
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
using ll = long long;
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()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    sort(P.begin(), P.end());
    int count = 0;
    rep(i, K) { count += P[i]; }
    cout << count << endl;
}

Measured memory_bytes: 3600
n=int(input())
a=[int(x) for x in input().rstrip().split()]

now=1
mod=10**9+7
def lcm(a,b):#最小公倍数
    ori_a=a
    ori_b=b
    while b!=0:
        a,b=b,a%b
    return (ori_a*ori_b)//a
  
for i in a:
  now=lcm(i,now)
# print(now)
print(sum([now//i for i in a])%mod)
  


Measured memory_bytes: 268488
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int X,A,B,C;
	int sum=0;
	cin>>A>>B>>C>>X;
	for(int i=0;i<=A;i++)
	{
		for(int j=0;j<=B;j++)
		{
			for(int k=0;k<=C;k++)
			{
				if(500*i+100*j+50*k==X)
					sum++;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
n = input()
#print(n[-1])

if n[-1] == "3":
    print("bon")
elif n[-1] == "0":
    print("pon")
elif n[-1] == "1":
    print("pon")
elif n[-1] == "6":
    print("pon")
elif n[-1] == "8":
    print("pon")
else: print("hon")

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

int main(void) {
    int i = 1;
    int x;
    while (1) {
        scanf("%d", &x);
        if (x == 0) break;
        printf("Case %d: %d\n", i, x);
        i++;
    }
    return 0;
}

Measured memory_bytes: 1028
<?php

$n = trim(fgets(STDIN));
$line = explode(" ", trim(fgets(STDIN)));

$cnt = 0;
for($i=1; $i<=$n; $i++){
    if($i % 2 !== 0 && $line[$i-1] % 2 !== 0){
        $cnt++;
    }
}
echo $cnt;

Measured memory_bytes: 15984
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;

//Binary exponent
ll Bin_pow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
        {
            res=res*a;
        }
        a=a*a;
        b>>=1;
    }
    return res;
}

//GCD
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}

//LCM
ll lcm(ll a,ll b)
{
	return (a*b)/gcd(a,b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll x;
	cin>>x;
	
	ll tmp=100;
	ll count=0;
	
	while(tmp<x)
	{
	    tmp += tmp*1/100;
	    
	    count++;
	}
	cout<<count<<endl;
}

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

using namespace std;

const int N = 18, K = 51, inf = 1e7 + 7;

int dp[1 << N][K];

int a[N], b[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", a+i);
  for (int i = 0; i < n; ++i)
    scanf("%d", b+i);
  int nmask = 1 << n;
  for (int i = 0; i < nmask; ++i) {
    for (int j = 0; j < K; ++j)
      dp[i][j] = inf;
  }
  dp[0][0] = 0;
  for (int mask = 0; mask < nmask; ++mask) {
    int cost = 0, odd = __builtin_popcount(mask) & 1;
    for (int i = 0; i < n; ++i) {
      if (mask & (1 << i)) continue;
      int val = ((odd^i) & 1) ? b[i] : a[i];
      int new_mask = mask | (1 << i);
      for (int j = 0; j <= val; ++j) {
        dp[new_mask][val] = min(dp[new_mask][val], cost + dp[mask][j]);
      }
      ++cost;
    }
  }
  int ans = inf;
  for (int i = 0; i < K; ++i)
    ans = min(ans, dp[nmask-1][i]);
  if (ans >= inf)
    ans = -1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 52480
"""
hour hand = A cm
min hand = B cm

"""

from decimal import Decimal
from math import radians, cos, sqrt

a, b, h, m = map(Decimal, input().split())

ha = (((h + m / 60 ) % 12) / 12) * 360
ma = (m / 60) * 360
angle = abs(ha - ma)
#print(ha, ma, angle)

# x^2 = a^2 + b^2 - 2ab cos X
# x^2 =  a^2 + b^2 - 2ab cos angle


res = sqrt(a**2 + b**2 - 2 * a * b * Decimal(cos(radians(angle))))

print(res)

Measured memory_bytes: 71804
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

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

using namespace std;

int G[101][101];
int d[101];
bool checked[101];

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

	for (int i = 0; i < n; i++)
	{
		int id, k;
		cin >> id >> k;

		for (int i = 0; i < k; i++)
		{
			int v;
			cin >> v;
			G[id][v] = 1;
		}
	}

	for (int i = 1; i <= 100; i++)
	{
		d[i] = -1;
	}

	queue<int> q;
	q.push(1);

	int td = 0;
	while (q.size() != 0)
	{
		int size = q.size();
		for (int i = 0; i < size; i++)
		{
			int id = q.front();
			q.pop();
			if (checked[id])
			{
				continue;
			}
			d[id] = td;
			checked[id] = true;
			for (int j = 1; j <= n; j++)
			{
				if (G[id][j] == 1 && !checked[j])
				{
					q.push(j);
				}
			}
		}
		td++;
	}

	for (int i = 1; i <= n; i++)
	{
		printf("%d %d\n", i, d[i]);
	}

	return 0;
}


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

const int mod = 1e9+7;


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

  int H, W;
  cin >> H >> W;

  vector<vector<bool>> grid(H, vector<bool>(W));
  vector<vector<int>> dir = {{0, 1}, {1, 0}};

  char c;
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      cin >> c;
      grid[i][j] = (c=='.');
    }
  }

  vector<vector<int>> dp(H, vector<int>(W));
  dp[0][0] = 1;

  for(int r=0; r<H; r++) {
    for(int c=0; c<W; c++) {
      for(auto move : dir) {
        int x = r + move[0];
        int y = c + move[1];
        if(x<H && y<W && grid[r][c]) {
          dp[x][y] = (0LL + dp[x][y] + dp[r][c]) % mod;
        }
      }
    }
  }
  cout << dp[H-1][W-1] << '\n';

  return 0;
}

Measured memory_bytes: 7356
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define ll_1e9 (ll)1e9
using namespace std;

int main(){
  ll n,cnt = 0;
  cin >> n;
  ll memo = 0,a = 0;
  rep(i,0,n){
    cin >> a;
    cnt += (a+memo)/2;
    memo = (a+memo) % 2;
    if(!a) memo = 0;
  }


  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    string str;
    cin>>str;
    for(int i=0;i<str.size();i++){
        if(str[i]=='A'||str[i]=='B'||str[i]=='C')str[i]=str[i]+23;
        else str[i]=str[i]-3;
        cout<<str[i];
      
    }
    cout<<endl;
 return 0;
}

Measured memory_bytes: 3164
using System;
class oneclue{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int k=int.Parse(str[0]);
    int x=int.Parse(str[1]);
    for(int i=x-k+1; i<x+k-1; i++){
      Console.Write("{0} ",i);
    }
    Console.WriteLine(x+k-1);
  }
}


Measured memory_bytes: 13268
from heapq import heappop, heappush

N, M, S, T = map(int, input().split())
K = 10**15
S -= 1
T -= 1

edgesYen = [[] for _ in range(N)]
edgesSun = [[] for _ in range(N)]

for _ in range(M):
    fr, to, yen, sun = map(int, input().split())
    fr -= 1
    to -= 1
    edgesYen[fr].append((to, yen))
    edgesYen[to].append((fr, yen))
    edgesSun[fr].append((to, sun))
    edgesSun[to].append((fr, sun))

def calcMinDist(edges, start):
    minDist = [10**18] * N
    minDist[start] = 0
    que = [(0, start)]
    while que:
        dist, now = heappop(que)

        if minDist[now] < dist:
            continue

        for to, d in edges[now]:
            if minDist[to] > dist + d:
                heappush(que, (dist + d, to))
                minDist[to] = dist + d

    return minDist

minDistYenS = calcMinDist(edgesYen, S)
minDistSunT = calcMinDist(edgesSun, T)

ans = [0] * N
for mid in range(N):
    ans[mid] = K - minDistYenS[mid] - minDistSunT[mid]

for mid in range(N - 1)[::-1]:
    ans[mid] = max(ans[mid], ans[mid + 1])

print(*ans, sep='\n')


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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	string ch;
	
	cin >> ch;
	
	if(ch[0] == ch[1] || ch[1] == ch[2] || ch[2] == ch[3]) cout << "Bad\n";
	else cout << "Good\n";
	
	return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	while (1) {
		ll x, y, s; scanf("%lld %lld %lld", &x, &y, &s);
		if (x == 0 && y == 0 && s == 0) break;
		ll res = 0;
		for (ll i = 1; i <= s - 1; i++) {
			for (ll j = 1; j <= s - 1; j++) {
				ll pre = i * (100 + x) / 100 + j * (100 + x) / 100;
				if (pre == s) {
					chmax(res, i * (100 + y) / 100 + j * (100 + y) / 100);
				}
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
int main(void){
    int a, b, c=0, i=1, sum=0;
    float t;
    scanf("%d%d%f", &a, &b, &t);
    t+=0.5;
    
    if(a<t){
        do{
            sum+=b;
            i++;
            c=a*i;
        }while(c<t);
    }else{
        sum=0;
    }
    printf("%d", sum);
}

Measured memory_bytes: 128
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		execute5_3();
	}
	
	private static void execute5_3() {
		try (Scanner sc = new Scanner(System.in)) {
			long H = sc.nextLong();
			int N = sc.nextInt();
			
			
			for(int i=0; i<N;i++) {
				long a = sc.nextLong();
				H = H-a;
			}
			if(0<H) {
				
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
	}
}

Measured memory_bytes: 47940
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int k; cin >> k;
  vector<string> ans;

  for(int i=1;i<=9;i++){
    string x = to_string(i);
    ans.pb(x);
  }

  int ptr = 0;

  for(int i=10;i<=k;i++){
    string x = ans[ptr];
    if(x[x.size()-1]=='0'){
      ans.pb(x+'0');
      ans.pb(x+'1');
    }else if(x[x.size()-1]=='9'){
      ans.pb(x+'8');
      ans.pb(x+'9');
    }else{
      char ch = x[x.size()-1] - 1;
      for(int j=1;j<=3;j++){
        ans.pb(x+ch);
        ch++;
      }
    }
    ptr++;
  }

  cout << ans[k-1];

  return 0;
}

Measured memory_bytes: 22256
N = int(input())
csf = [0] * (N - 1)

for i in range(N - 1):
  c, s, f = map(int, input().split())
  csf[i] = [c, s, f]
  
def depart(n):
  now_time = 0
  if n == N - 1:
    return 0
  while n != N - 1:
    next_st = csf[n]
    if now_time <= next_st[1]:
      now_time = next_st[1] + next_st[0]
    else:
      while now_time % next_st[2] != 0:
        now_time += 1
      now_time += next_st[0]
    n += 1
    #print(n, now_time)
  return now_time

for i in range(N):
  print(depart(i))
  
  
      
      
      
  
  
  
  
  
  



Measured memory_bytes: 9208
N, M = gets.split().map(&:to_i)
if N == 1 && M == 0
  puts 0
  exit
end
array = []
ans = Array.new(N)

M.times do 
  array.push(gets)
end

array = array.uniq.map do |i|
  i.split().map(&:to_i)
end

array.each do |i, j|
  if i == 1 && j == 0 && N != 1
    puts -1
    exit
  end
  if ans[i-1]
    puts -1
    exit
  end
  ans[i-1] = j
end

ans[0] = 1 unless ans[0] 

ans = ans.map do |i|
  i ? i : 0
end

puts ans.join().to_i

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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  map<int ,int> mp;
  bool prime[101] = {};
  REP(i,101){
    prime[i] = true;
  }
  for(int i = 2; i * i <= 100; ++i){
    if(prime[i]){
      for(int j = 0; i* (j + 2) <= 100; ++j){
        prime[i * (j+2)] = false;
      }
    }
  }
  for(int i = 2; i <= n; ++i){
    int val = i;
    for(int j = 2; j <= n; ++j){
      if(prime[j]){
        if(val % j == 0){
          while(val % j == 0){
            mp[j]++;
            val /= j;
          }
        }
      }
    }
  }

  int ans = 0;

  //75
  if(mp[2] >= 74) ans++;

  //25 3
  REPI(itr,mp){
    if(itr->second >= 24){
      REPI(itr2,mp){
        if(itr->first != itr2->first && itr2->second >= 2){
          ans++;
        }
      }
    }
  }
  //15 5
  REPI(itr,mp){
    if(itr->second >= 14){
      REPI(itr2,mp){
        if(itr->first != itr2->first && itr2->second >= 4){
          ans++;
        }
      }
    }
  }
  //5 5 3
  REPI(itr,mp){
    if(itr->second >= 2){
      int four = 0;
      REPI(itr2,mp){
        if(itr->first != itr2->first && itr2->second >= 4){
          four++;
        }
      }
      ans += four * (four-1) / 2;
    }

  }
  cout << ans << endl;

  return 0;
}



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

int main()
{
  /*処理系*/
  long long A, B, N;
  cin >> N >> A >> B;
  long long ans;
  long long c = N / (A + B);
  ans = c * A;
  long long d = N - (A + B) * c;
  if (d > A)
  {
    ans += A;
  }
  else
  {
    ans += d;
  }
  cout << ans;
}

Measured memory_bytes: 256
import math
k = int(input())
a = []
for i in range(1, k+1):
    for j in range(1, k+1):
        x = math.gcd(i, j)
        for l in range(1, k+1):
            y = math.gcd(l, x)
            a.append(y)
print(sum(a))

Measured memory_bytes: 71592
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		String[] s1=(scanner.next()+"1").split("");
		String[] s2=scanner.next().split("");
		List<Boolean>list=new ArrayList<>();
		int cnt=0;
		String pre=s1[0];
		for(int i=1;i<n+1;i++){
			String now=s1[i];
			if(now.equals(pre)){
				cnt++;
			}else{
				if(cnt==0){
					list.add(true);
				}else{
					list.add(false);
				}
				cnt=0;
			}
			pre=now;
		}
		int mod=1000000007;
		long p=list.get(0)?3:6;
		boolean x=list.get(0);
		for(int i=1;i<list.size();i++){
			boolean y=list.get(i);
			if(x&&y||x&&!y){
				p=p*2%mod;
			}else if(!x&&y){
				p=p;
			}else{
				p=p*3%mod;
			}
			x=y;
		}
		System.out.println(p);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21332