akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#define MAX 200
#define ROUND 3

int sum[MAX];
int game[MAX][ROUND];

void run(int N) {
    int chk;
    bool isdec;
    for (int i = 0; i < ROUND; i++) {
        for (int j = 0; j < N; j++) {
            if (game[j][i] == 0) { continue; }
            else {
                chk = game[j][i];
                isdec = false;
                for (int k = 1; k + j < N; k++) {
                    if (game[j+k][i] == chk) {
                        game[j+k][i] = 0;
                        sum[j+k] -= chk;
                        if (!isdec) {
                            game[j][i] = 0;
                            sum[j] -= chk;
                            isdec = true;
                        }
                    }
                }
            }
        }
    }
}

int main()
{
    int N;
    int tmp;
    std::scanf("%d", &N);
    for (int i = 0; i < N; i++) sum[i] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < ROUND; j++) {
            std::scanf("%d", &tmp);
            game[i][j] = tmp;
            sum[i] += tmp;
        }
    }
    run(N);
    for (int i = 0; i < N; i++) std::cout << sum[i] << std::endl;

return 0;
}



Measured memory_bytes: 3244
#include<stdio.h>
int main(){
	int a[3][3],m[3][3]={0};
	int n;
	int b[10];
	int i,j,k;
	for(i=0;i<3;i++)
		for(j=0;j<3;j++)
			scanf("%d",&a[i][j]);
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&b[i]);
	for(k=0;k<n;k++)
		for(i=0;i<3;i++)
			for(j=0;j<3;j++){
				if(b[k]==a[i][j]){
					m[i][j]=1;
					break;
				}
			}
	if(m[0][0]==1&&m[0][1]==1&&m[0][2]==1)
        printf("Yes");
	else if(m[1][0]==1&&m[1][1]==1&&m[1][2]==1)
        printf("Yes");
    else if(m[2][0]==1&&m[2][1]==1&&m[2][2]==1)
        printf("Yes");
    else if(m[0][0]==1&&m[1][0]==1&&m[2][0]==1)
        printf("Yes");
    else if(m[0][1]==1&&m[1][1]==1&&m[2][1]==1)
        printf("Yes");
    else if(m[0][2]==1&&m[1][2]==1&&m[2][2]==1)
        printf("Yes");
    else if(m[0][0]==1&&m[1][1]==1&&m[2][2]==1)
        printf("Yes");
    else if(m[0][2]==1&&m[1][1]==1&&m[0][2]==1)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 128
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] x = new double[n];
		String[] u = new String[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextDouble();
			u[i] = sc.next();
		}
		double sum = 0;
		for (int i = 0; i < n; i++) {
			if (u[i].equals("JPY")) {
				sum += x[i];
			} else {
				sum += x[i] * 380000;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23508
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]

cnt=0
for i in range(n):
  cntt=0
  for j in range(m):
    cntt+=a[i][j]*b[j]
  if cntt+c>0:
    cnt+=1

print(cnt)  

Measured memory_bytes: 9140
import static java.util.stream.Collectors.toSet;

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.LongStream;

public class Main {
    static final long MOD = 998244353;
    private final long a;
    private final long b;

    public Main(final long a, final long b) {
        this.a = a;
        this.b = b;
    }

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long a = scanner.nextLong();
        final long b = scanner.nextLong();

        final long result = new Main(a, b).calculate();

        System.out.println(result);
    }

    long calculate() {
        final long rightLastLength = b - a;

        final long rightTotalLength = (rightLastLength * (rightLastLength + 1)) / 2;

        return rightTotalLength - b;
    }

    long c(final long p, final long q) {
        if (q == 1) {
            return p;
        }

        if (q * 2 < p) {
            return c(p, p - q);
        }

        long result = 1;
        final Set<Long> hashSet = new TreeSet<>(LongStream.rangeClosed(2, q).boxed().collect(toSet()));
        for (long i = p; i > p - q; --i) {
            final long i_ = i;
            final Long div = hashSet.stream().filter(k -> i_ % k == 0).findFirst().orElse(1L);
            hashSet.remove(div);
            result *= (i / div);
            if (result > MOD) {
                result = result % MOD;
            }
        }
        return result;
    }
}


Measured memory_bytes: 21972
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)5e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll x,n=100,c=0;cin>>x;
	while(n<x) n+=n/100,c++;
	cout<<c<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

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


int main() {
	ll i, j;

	ll N, A, B;
	cin >> N >> A >> B;
	cout << min(N * A, B) << endl;

	return 0;
}


Measured memory_bytes: 764
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
hq = []

for i in range(N):
    heapq.heappush(hq, A[i]*(-1))

for i in range(M):
    tmp = heapq.heappop(hq) * (-1) // 2
    heapq.heappush(hq, tmp*(-1))
    
print(sum(hq)*(-1))

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[]) {
	int ans = 0, diff = 0;
	rep(i, 5) {
		int t;
		cin >> t;
		int digit = t % 10, pre = t;
		if (digit) {
			t += 10 - digit;
			diff = max(diff, t - pre);
		}
		ans += t;
	};
	cout << ans - diff << endl;
	return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def all_pattern(l):
    global n
    ans=0
    for ds in make_divisors(l)[1:]:
        k=n
        while k%ds==0:
            k//=ds
        ans+=(k%ds==1 or k-k%ds==1)
    return ans

n=int(input())
print(all_pattern(n)+all_pattern(n-1))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> P;

const Int Q = 26;

Int D;
vector<Int> C(Q);
vector<vector<Int>> S(400, vector<Int>(Q));

Int range(Int l, Int r){
    Int len = r-l-1;
    return -len * (len+1) / 2;
}

struct ContestInformation{
    vector<set<Int>> held; // held[q] : コンテストqを行った日程の集合
    vector<Int> schedule; // schedule[d]: d日目に実施するコンテストの番号
    Int score = 0; // 最終日の満足度

    ContestInformation(Int D){
        schedule.resize(D);

        held.resize(Q);
        rep(q, Q){
            held[q].insert(-1);
            held[q].insert(D);
        }
    }

    void ReadSchedule(){
        rep(d,D) {
            Int q; cin >> q; q--;
            schedule[d] = q;
            held[q].insert(d);
        }
    }

    // 最終日の満足度を計算する
    void CalcScore(){
        Int ans = 0;

        rep(d,D){
            Int q_now = schedule[d]; // その日に行われるコンテスト

            rep(q, Q){
                if(q == q_now){
                    ans += S[d][q];
                } else {
                    auto itr_last_day = lower_bound(held[q].begin(),held[q].end(),d);
                    ans -= C[q] * (d - *prev(itr_last_day));
                }
            }
            //cout << ans << endl;
        }

        score = ans;
    }

    // d日目をコンテストqに変更した時の最終満足度
    void modify(Int d, Int q_new){

        // 元のコンテストの情報の削除
        Int q_old = schedule[d]; // 変更前のコンテスト
        score -= S[d][q_old];

        auto itr_old = held[q_old].find(d);
        auto r_old = next(itr_old);
        auto l_old = prev(itr_old);
        score += C[q_old] * range(*l_old, *r_old);
        score -= C[q_old] * range(*l_old, *itr_old);
        score -= C[q_old] * range(*itr_old, *r_old);

        held[q_old].erase(d);

        // 新しいコンテストの情報の追加
        score += S[d][q_new];
        held[q_new].insert(d);
        schedule[d] = q_new; 

        auto itr_new = held[q_new].find(d);
        auto r_new = next(itr_new);
        auto l_new = prev(itr_new);
        score -= C[q_new] * range(*l_new, *r_new);
        score += C[q_new] * range(*l_new, *itr_new);
        score += C[q_new] * range(*itr_new, *r_new);
    }
};



int main(){
    cin >> D;
    rep(i,Q) cin >> C[i];
    rep(i,D) rep(j,Q) cin >> S[i][j];

    ContestInformation CI(D);
    CI.ReadSchedule();
    CI.CalcScore();

    int M; cin >> M;
    rep(i,M){
        Int d, q; cin >> d >> q; d--; q--;
        CI.modify(d,q);
        cout << CI.score << endl;
    }
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long total = 0;
		for (long idx = 1;n >= idx * idx ;idx++) {
			if (n % idx != 0) {
				continue;
			}
			long a = n / idx;
			if (a != 1 && n / (a - 1) == n % (a - 1)) {
				total += a - 1;
			} else {
				break;
			}
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 23380
N = int(input())
A = map(int, input().split())
Q = int(input())

change_pair = []
for i in range(Q):
    b, c = map(int, input().split())
    change_pair.append((b, c))

# Aの出現値毎に回数をカウント
counts = {}
total = 0
for a in A:
    if a in counts:
        counts[a] += 1
    else:
        counts[a] = 1
    total += a

# 置き換え毎に回数を移動
for b, c in change_pair:
    if b in counts:
        count = counts[b]
        counts[b] = 0
        total -= b * count
    else:
        count = 0
    if c in counts:
        counts[c] += count
    else:
        counts[c] = count
    total += c * count
    print(total)


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
    double l; cin >> l;
    double a = l/3;
    cout << fixed;
    cout << setprecision(9) << a*a*a << endl;

    return 0;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n, ans1=0, ans2=0;
    cin >> n;
    while(n>=10){
        ans1 += n%10;
        ans2 += 9;
        n /= 10;
    }
    ans1 += n;
    ans2 += n-1;
    cout << max(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 3620
S = input()
if ((S[0] == S[1]) and (S[0] !=S[2]) and (S[2] == S[3]))or((S[0] != S[1]) and (S[0] ==S[2]) and (S[1] == S[3]))or((S[0] != S[1]) and (S[1] == S[2]) and (S[0] == S[3])):
  print("Yes")
else:
  print("No")
  


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	int n;
	cin >> n;
	cout << n * n << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
using namespace std;

constexpr long long int MOD = 1000000007; // = 10^9 + 7

void solve()
{
	long long int n, k;
	cin >> n >> k;

	// (n+1)Ck + nC(k+1) + ... + (n+1)C(n+1)
	//=(n+1)C(n-k+1) + nC(n-k) + ... + (n+1)C(0)

	long long int ans = 0;
	for(long long int i = k; i <= n + 1; ++i)
	{
		ans = (ans + (long long)((n+1) * i) % MOD - (long long)(i * i) % MOD + 1) % MOD;
	}
	if (ans < 0)
	{
		ans += MOD;
	}
	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#define sn(n) scanf("%d",&n)
#define pr(n) printf("%lld",n)
#define pn printf("\n")
#define ll long long
#define p 1000000005
using namespace std;
int n,m;
ll ans;
ll a[100005];
ll b[100005];
ll c[100005];
ll look;
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1);
    if(n%2==0)
    {
        for(int i=1;i<=n/2-1;i++)
        {
            ans+=a[n-i+1];
            ans-=a[i];
        }
        ans*=2;
        ans+=a[n/2+1];
        ans-=a[n/2];
    }
    else
    {
        for(int i=1;i<=n/2-1;i++)
        {
            ans+=a[n-i+1];
            ans-=a[i];
        }
        ans*=2;
        int x=a[n/2+2]*2-a[n/2+1]-a[n/2];
        int y=a[n/2+2]+a[n/2+1]-2*a[n/2];
        ans+=max(x,y);
    }
    pr(ans);
    pn;
    return 0;
}


/*

Lucas(卢卡斯)定理

ll pow_quick(ll a, ll b)

{

    ll  ans =1;

    while(b)

    {

        if(b &1)  ans = ans * a % p;

        b>>=1;

        a = a*a % p;

    }

    return  ans;

}

ll C(ll n, ll m)

{

    if(m > n)  return 0;

    ll ans = 1;
    for(ll i=1; i<=m; i++)
    {
        ll a = (n+i-m)%p;

        ll b = i%p;

        ans = (ans*(a*pow_quick(b,p-2)%p))%p;

    }
    return ans;
}

ll Lucas(ll n, ll m )

{

    if(m ==0)  return 1;

    else return  (C(n%p, m%p)*Lucas(n/p, m/p))%p;

}


*/


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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int N,H,W;
    cin >> N >> H >> W;
    
    int A,B,cnt = 0;
    for(int i=0;i<N;i++){
        cin >> A >> B;
        if(A>=H && B>=W) cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}


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

int main() {
	int n, ans[4]{0};
	string result;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> result;
		if (result == "AC") 		ans[0]++;
		else if (result == "WA") 	ans[1]++;
		else if (result == "TLE") 	ans[2]++;
		else 						ans[3]++;
	}

	cout << "AC x "s << ans[0] << "\n"s;
	cout << "WA x "s << ans[1] << "\n"s;
	cout << "TLE x "s << ans[2] << "\n"s;
	cout << "RE x "s << ans[3] << "\n"s;
}


Measured memory_bytes: 3180
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))
t = 0
for i in b:
    t += (bisect.bisect_left(a, i) * (n - bisect.bisect_right(c, i)))
print(t)


Measured memory_bytes: 23744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int MAX_D = 50;
ll dp[100][2];

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

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for(int d = 0; d < MAX_D; d++){
        ll mask = 1LL<<(MAX_D-d-1);

        ll num1 = 0;
        rep(i,n) if (a[i] & mask) num1++;

        ll cost0 = num1 * mask;
        ll cost1 = (n-num1) * mask;

        if (dp[d][1] != -1){
            chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1));
        }

        if (dp[d][0] != -1){
            if (k & mask) chmax(dp[d+1][1], dp[d][0] + cost0);
        }

        if (dp[d][0] != -1){
            if (k & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
            else chmax(dp[d+1][0], dp[d][0] + cost0);
        }
    }
    cout << max(dp[MAX_D][0], dp[MAX_D][1]) << endl;

    return 0;
}

Measured memory_bytes: 4028
//#pragma GCC optimize(\"Ofast,no-stack-protector\")
//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx\")
//#pragma GCC target(\"avx,tune=native\")
// Neil

#include<bits/stdc++.h>

using namespace std;

typedef complex<double> base;
typedef long double ld;
typedef long long ll;

#define endl "\n"
#define pb push_back
#define pii pair<int,int>
#define pll pair< ll , ll >
#define vi vector<int>
#define vvi vector< vi >
const int MAXN=(int)15;
const ll MOD=(ll)(1e9+7);
int t;
int arr[15][15];
int cost[15];
int s[15];
int n,m, x;


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            if(j==0)
                cin>>cost[i];
            else{
                cin>>arr[i][j-1];
                s[j-1]+=arr[i][j-1];
            }
        }
    }
    for(int i=0;i<m;i++){
        if(s[i]<x){
            cout<<-1<<endl;
            return 0;
        }
    }
    int mn_cst = INT_MAX;
    for(int i=1;i<(1<<n);i++){
        memset(s,0,sizeof(s));
        int c = 0;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                c+=cost[j];
                for(int k=0;k<m;k++){
                    s[k]+=arr[j][k];
                }
            }
        }
        bool fl = 0;
        for(int j=0;j<m;j++){
            if(s[j]<x){
                fl = 1;
                break;   
            }
        }
        if(fl==0 and mn_cst>c)
            mn_cst = c;
    }
    cout<<mn_cst<<endl;
    return 0;
}

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

int main() {
  int H, W, ans=0, cury, curx, y, x, dy[4]={0,-1,0,1}, dx[4]={1,0,-1,0}, cnt;
  cin >> H >> W;
  vector<vector<char>> Map(H, vector<char>(W));
  vector<vector<int>> Reached(H, vector<int>(W,-1));
  deque<tuple<int, int, int>> dq;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> Map[i][j];
      if(Map[i][j]=='#') {
        dq.push_back(make_tuple(i,j,0));
        Reached[i][j]=0;
      }
    }
  }
  while(!dq.empty()){
    tie(cury, curx, cnt) = dq.front();
    dq.pop_front();
    cnt++;
    for (int k=0; k<4; k++) {
      y=cury+dy[k]; x=curx+dx[k];
      if(y<0||y>=H||x<0||x>=W) continue;
      else if(Map[y][x]=='#'||Reached[y][x]!=-1) continue;
      else {
        Reached[y][x]=cnt;
        dq.push_back(make_tuple(y,x,cnt));
        ans = max(ans, cnt);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 17296
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()] 

su = [0 for _ in range(n)] #鉄の棒の切れ目の座標
for i in range(n):
    su[i] = su[i-1] + a[i]
#print(su)

tmp = 2 * pow(10, 10) + 1
for i in su:
    if abs(i - su[-1]/2) < tmp:
        tmp = abs(i - su[-1]/2)
#print(su[-1]/2, tmp)

"""
#中心に一番近い鉄の棒の切れ目と中心との距離の差
l = 0
r = n-1
while (l - r) >= 1:
    c = (l + r) // 2
    #print(l, r, c)
    if su[c] < su[-1] / 2:
        l = c
    elif su[c] > su[-1] / 2:
        r = c
#print(su[l], su[r])
tmp = min(abs(su[l] - su[-1]/2), abs(su[r] - su[-1]/2))
print(tmp)
"""

ans = 2 * tmp
print(int(ans))


Measured memory_bytes: 25740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>




#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

int N;
double T, A;
double h[1010];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	double min = INF;
	cin >> N;
	cin >> T >> A;
	REP(i, N) {
		cin >> h[i];
	}
	int idx = 0;
	REP(i, N) {
		double ave = T - h[i] * 0.006;
		if (abs(ave - A) < min) {
			idx = i;
			min = abs(ave - A);
		}
	}
	print(idx + 1);
}

Measured memory_bytes: 256
n = int(input())
xl = []
for i in range(n):
    x, l = map(int, input().split())
    xl.append([x, l])
xl.sort()
count = 1
edge = xl[0][0] + xl[0][1]
for i in range(n - 1):
    if xl[i + 1][0] - xl[i + 1][1] < edge:
        edge = min(edge, xl[i + 1][0] + xl[i + 1][1])
    else:
        count += 1
        edge = xl[i + 1][0] + xl[i + 1][1]
print(count)

Measured memory_bytes: 20072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

string s;
vector<PCC> v;
int N,Q;
int move(int pos){
  rep(i,Q){
    if(s[pos] == v[i].first){
      if(v[i].second=='L')--pos;
      else ++pos;
    }
  }
  return pos;
}


int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> Q;
  cin >> s;
  s = " " + s + " ";
  v.resize(Q);
  rep(i,Q)cin >> v[i].first >> v[i].second;
  //左に落ちる最大の位置
  int ls = 0,le = N+1;
  while(le-ls>1){
    int lm = (ls+le)/2;
    if(move(lm) == 0) ls = lm;
    else le = lm;
  }

  //右に落ちる最小の位置
  int rs = 0,re = N+1;
  while(re-rs>1){
    int rm = (rs+re)/2;
    if(move(rm) == N+1) re = rm;
    else rs = rm;
  }
  cout << N - ls - (N+1-re) << endl;
  return 0;
}


Measured memory_bytes: 976
import java.util.Scanner;
public class Main {
	void circle(){
		Scanner s = new Scanner(System.in);
		double r = s.nextDouble();
		System.out.println(String.format("%.9f", Math.PI*(double)(r*r)) + " " + String.format("%.9f", Math.PI * (double)(r*2)));
	}
	public static void main(String args[]){
		Main m = new Main();
		m.circle();
	}
}

Measured memory_bytes: 28068
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
// typedef Graph vector<vector<int>>; // グラフ型
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n, tmp, ans = 0, a, b, c;
    cin >> n;
    vi l(n);
    rep(i, n)cin >> l[i];
    sort(l.begin(),l.end());
    rep(i, n-2){
        REP(j, i+1, n-1){
            REP(k, j+1, n){
                a=l[i];
                b=l[j];
                c=l[k];
                if(c < a + b){
                    ans++;
                }else break;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
  float a=0, count=0;
  int num=0;
  scanf("%d\n", &num);
  char s[4];
  for (int i=0; i<num; i++) {
    scanf("%f %[^\n]", &a, s);
    if (!strcmp(s, "JPY")) count += a;
    else if (!strcmp(s, "BTC")) count += a*380000;
  }
  printf("%f\n", count);
  return 0;
}
    


Measured memory_bytes: 128
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,k; cin>>n>>k; 
    int a,mx=0,g=0;
    for (int i=0;i<n;i++){
        cin >> a ; 
        g = __gcd(g,a); 
        mx=max(mx,a);
    }
    if (k>mx or k%g) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		
		long bar1 = 0;
		
		//1
		long ans1 = Long.MAX_VALUE;
		for(long i = 1; i < H; i++) {
			bar1 = i * W;
			long bar2 = ((H - i) / 2) * W;
			long bar3 = H * W - bar1 - bar2;
			long max = Math.max(bar1, Math.max(bar2, bar3));
			long min = Math.min(bar1, Math.min(bar2, bar3));
			ans1 = Math.min(ans1, max - min);
		}
		
		//2
		long ans2 = Long.MAX_VALUE;
		for(long i = 1; i < H; i++) {
			bar1 = i * W;
			long bar2 = (H - i) * (W / 2);
			long bar3 = H * W - bar1 - bar2;
			long max = Math.max(bar1, Math.max(bar2, bar3));
			long min = Math.min(bar1, Math.min(bar2, bar3));
			ans2 = Math.min(ans2, max - min);
		}
		
		//3
		long ans3 = Long.MAX_VALUE;
		for(long i = 1; i < W; i++) {
			bar1 = i * H;
			long bar2 = ((W - i) / 2) * H;
			long bar3 = H * W - bar1 - bar2;
			long max = Math.max(bar1, Math.max(bar2, bar3));
			long min = Math.min(bar1, Math.min(bar2, bar3));
			ans3 = Math.min(ans3, max - min);
		}
		
		//4
		long ans4 = Long.MAX_VALUE;
		for(long i = 1; i < W; i++) {
			bar1 = i * H;
			long bar2 = (W - i) * (H / 2);
			long bar3 = H * W - bar1 - bar2;
			long max = Math.max(bar1, Math.max(bar2, bar3));
			long min = Math.min(bar1, Math.min(bar2, bar3));
			ans4 = Math.min(ans4, max - min);
		}
		
		System.out.println(Math.min(ans1, Math.min(ans2, Math.min(ans3, ans4))));
	}
}


Measured memory_bytes: 21972
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string dir = "NWSE";
    vint nwse(4,0);
    string s;
    cin >> s;
    int l = s.length();
    REP(i,l){
        REP(j,4){
            if(s[i]==dir[j]){
                nwse[j]++;
                break;
            }
        }
    }
    bool ans = true;
    REP(i,4){
        if(nwse[i]==0){
            if(nwse[(i+2)%4]>0){
                ans = false;
            }
        }
    }
    if(ans){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    string S; cin >> S;
    int acPos = S.find("AC");
    string ans = "Yes";
    
    if(acPos == -1) ans = "No";

    cout << ans << ln;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
const static int INT_INF = 2147483647;

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

	vector<int> vec;
	for (size_t i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		vec.emplace_back(tmp);
	}

	int min_num = INT_INF;
	for (size_t t = 1; t < n; t++)
	{
		int sum_l = 0;
		int sum_r = 0;
		for (size_t j = 0; j < t+1; j++)
		{
			sum_l += vec[j];
		}
		for (size_t j = t+1; j < n; j++)
		{
			sum_r += vec[j];
		}
		int sum_abs = abs(sum_l - sum_r);
		min_num = min(sum_abs, min_num);
	}

	cout << min_num << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
/* #include <atcoder/all> */
#include <iostream>
using namespace std;
/* using namespace atcoder; */
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int n;
    cin >> n;
    FOR(i, 1, n+1) {
        double now = 1.*i;
        now *= 1.08;
        if (floor(now) == n) {
            cout << i << endl;
            return;
        }
    }
    cout << ":(" << endl;
}


int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<string>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define S second
#define F first
using namespace std;



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

	ll n;
	cin >> n;
	ll ans = 0;
	if (n % 2 == 0) {
		ll st = 10;
		while (st <= n) {
			ans = ans + (n / st);
			st = st * 5;
		}
	}
	else {
		ans = 0;
	}

	cout << ans << '\n';
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
int main(void) {
    long long a, b, c;
    cin >> a >> b >> c;
    long long now = 0;
    for (int i = 0; i < 10000000; i++) {
        if (c % (a + b) <= a) {
            cout << c << endl;
            return 0;
        }
        c += 60;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}





void test_case()
{

    int n, m;
	cin >> n >> m;
	vector < int > a(n);
	set < int > s;	
	for(int &i : a) {
		cin >> i;
		i /= 2;
		int cur = i,cnt = 0;
		while(cur % 2 == 0) {
			cur /= 2;
			cnt++;
		}
		s.insert(cnt);
	}
	if(s.size() > 1) {
		cout << 0 << endl;
		return ;
	}
	int lcm = a[0];
	for(int &i : a) {
		lcm = (i * lcm) / gcd(lcm, i);
		if(lcm > m) {
			cout << 0 << endl;
			return ;
		}
	}
	int ans = m / lcm;
	ans = (ans + 1) / 2;
	cout << ans << endl;


    




    
    
    
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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

Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define MAXN 1000005
using namespace std;

int n,pos,ans,head,tail;
int q[MAXN];
char s[MAXN],t[MAXN];

int min(int a,int b) {return a<b?a:b;}
int max(int a,int b) {return a>b?a:b;}

template<class T>inline void read(T &res)
{
    static char ch;T flag=1;
    while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
    while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
}

int main()
{
    read(n);
    scanf("%s%s",s+1,t+1);
    if(strcmp(s+1,t+1)==0){putchar('0');return 0;}
    pos=n;head=1;tail=0;
    for(int i=n;i>=1;i--)
    {
        if(t[i]==t[i-1]) continue;
        pos=min(pos,i);
        while(pos&&t[i]!=s[pos]) pos--;
        if(pos==0) {putchar('-');putchar('1');return 0;}
        while(head<=tail)
        {
            if(q[head]-(tail-head+1)+1>i) head++;
            else break;
        }
        q[++tail]=pos;
        if(i!=pos) ans=max(ans,tail-head+1);
    }
    printf("%d\n",ans+1);
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  double ans=0;
  double x;
    string y;
  for(int i=0;i<N;i++){
    
    cin>>x>>y;
    if(y=="BTC"){
      x=x*380000;
    }
    ans+=x;
  }
  cout<<ans<<endl;
}

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

int n, k, h[101010];

int main(){
  cin >> n >> k;
  k--;
  rep(i, n) cin >> h[i];
  sort(h, h + n);
  //rep(i, n) cerr << h[i] << " ";
  int res = 1e9;
  for(int i = 0; i < n - k; i++){
    res = min(h[i + k] - h[i], res);
  }
  cout << res << endl;
  return 0;
}

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

int main(){
  int A[6];
  int s[6];
  for(int i=0; i <5 ;i++) cin >> A[i] ;
  int min=10;
  int last=0;
  for(int i=0; i <5 ;i++){
    s[i]=A[i]%10 ;
    if(min>s[i] && s[i] > 0){
      min=s[i];
      last=i;
    }
  }

  int sum=0;
  for(int i=0; i <5 ;i++){
    if(s[i]==0) sum =sum+A[i];
    if(s[i]>0) sum =sum+A[i]+10-s[i];
    if(i==last && s[last]!=0) sum =sum-10+s[i];
  }
 
    
  cout<< sum << endl;
  }
  


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int m=sc.nextInt();
        int a[]=new int[m];
        int flag=0;
        int count=0;
        for(int i=0;i<m;i++) {
            a[i] = sc.nextInt();
            if (a[i] % 2 == 0) {
                count++;
                if (a[i] % 3 == 0 || a[i] % 5 == 0)
                    flag++;
            }
        }
        if(flag==count)
            System.out.println("APPROVED");
        else
            System.out.println("DENIED");
    }
}


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

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

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


using namespace std;

const int N = 1e5 + 7;
char str[N];
int n;
struct Pair{
	int x,y;
}p[N];
int tot;
void Add(int x,int y){
	p[++tot] = (Pair){x,y};
}
int main(){
#ifdef WTY
	freopen("in","r",stdin);
#endif
	scanf("%s",str + 1);
	n = strlen(str + 1);
	if(str[1] == '0' || str[n] == '1')return !puts("-1");
	for(int i = 1,j = n - 1; i <= j; i++,j--)
		if(str[i] != str[j])return !puts("-1");
	int cnt = 1;
	Add(cnt,cnt + 1);
	++cnt;
	for(int i = 2,cur = 2; i < n; i++){
		Add(cur,cnt + 1);
		++cnt;
		if(str[i] == '1')cur = cnt;
	}
	for(int i = 1; i <= tot; i++)
		printf("%d %d\n",p[i].x,p[i].y);
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mem(a,b) memset(a,(b),sizeof(a))
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define all(cont) cont.begin(),cont.end()
#define rall(cont) cont.rbegin(),cont.rend()
#define mp make_pair
#define pb push_back
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x=x%p;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res%MOD;}  

int main(){
   ll x;
   cin>>x;
   ll ans = 0;
   ll amt = 100;
   ll k=0;
   while(1){
       ll amt1 = amt * 101.0 / 100.0;
       k++;
       if(amt1 >= x){
           ans = k;
           break;
       }
       amt = amt1;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=50;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n;
ll f[N][N][N],g[N][N][N];
char s[N][N];

int main() {
	cin>>n;n<<=1;
	for(int i=1;i<=n;i++) {
		scanf("%s",s[i]+1),f[i][i][i]=1;
		for(int x=1;x<i;x++) if(s[x][i]=='1') g[i][i][x]=1;
	}
	for(int len=3;len<=n;len+=2)
		for(int l=1;l<=n-len+1;l++) {
			int r=l+len-1;
			for(int a=l;a<r;a+=2)
				for(int b=r;b>a;b-=2) {
					ll sum=0;
					for(int x=l;x<=a;x++) sum+=f[l][a][x]*g[b][r][x];
					for(int t=a+1;t<b;t++) f[l][r][t]+=f[a+1][b-1][t]*sum;
				}
			for(int x=1;x<l;x++)
				for(int y=l;y<=r;y++) if(s[x][y]=='1') g[l][r][x]+=f[l][r][y];
		}
	ll ans=0;
	for(int i=2;i<=n;i++) if(s[1][i]=='1') ans+=f[2][n][i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main() {
  int y1, y2, m1, m2, d1, d2;
  int day;
  int count;

  while(1) {
    scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2);
    if(y1 == -1 && m1 == -1 &&d1 == -1 && y2 == -1 && m2 == -1 && d2 == -1) break;
    count = 0;

    while(!(y1 == y2 && m1 == m2 && d1 == d2)) {
      switch(m1) {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
	day = 31;
	break;
      case 4:
      case 6:
      case 9:
      case 11:
	day = 30;
	break;
      case 2:
	if(y1 % 400 == 0) day = 29;
	else if(y1 % 100 == 0) day = 28;
	else if(y1 % 4 == 0) day = 29;
	else day = 28;
	break;
      }
  
      if(y1 == y2 && m1 == m2) {
	count += d2 - d1;
	d1 = d2;
      } else {
	if(d1 != 1) {
	  count += day - d1 + 1;
	  d1 = 1;
	  m1++;
	  if(m1 > 12) {
	    m1 = 1;
	    y1++;
	  }
	} else {
	  count += day;
	  m1++;
	  if(m1 > 12) {
	    m1 = 1;
	    y1++;
	  }
	}
      }
    }
    printf("%d\n", count);
  }

  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
using namespace std;
bool check(string);
int main(){
    string str;
    string temp;
    cin>>str;
    if(!check(str)){
        cout<<"No"<<endl;
        return 0;
    }
    int N=str.length();
    int point=((N-1)/2);
    temp=str.substr(0,point);
    if(!check(temp)){
        cout<<"No"<<endl;
        return 0;
    }
    point=((N+3)/2)-1;
    temp=str.substr(point);
    if(!check(temp)){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}
bool check(string s){
    int mid=s.length()/2;
    bool ch=true;
    for(int i=0;i<mid;i++){
        if(s[i]!=s[s.length()-1-i]){
            ch=false;
        }
    }
    return ch;
}

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

int main() {
	int h, w; cin >> h >> w;
	vector<string> vec(h); rep(i, 0, h) cin >> vec[i];

	vector<string> ans(h + 2);
	rep(i, 0, h + 2) {
		if (i == 0 || i == h + 1) {
			rep(j, 0, w + 2) ans[i] += '#';
		}
		else {
			ans[i] += '#' + vec[i - 1] + '#';
		}
	}

	for (auto& x : ans) cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int K[] = new int[N-1];
        for(int i=0; i<N-1; i++) {
            K[i] = 0;
        }
        for (int i=0; i<N-1; i++) {
            for (int j=i+1; j<N; j++) {
                // 最短距離
                int d = Math.min(Math.abs(i-j),
                        Math.min(Math.abs(X-1-i) + 1 + Math.abs(Y-1-j),
                                 Math.abs(Y-1-i) + 1 + Math.abs(X-1-j)));
                K[d-1] += 1;
            }
        }
        for (int k: K) {
            System.out.println(k);
        }
    }
}

Measured memory_bytes: 22356
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

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

    int maxs = 0;
    for(int i=0;i<=sqrt(N);i++){
        if(i*i<=N) maxs = i*i;
        else break;
    }
    cout << maxs << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <numeric>
#include <cmath>
#include <set>
#include <functional>
#include <vector>
#include <queue>

using namespace std;

#define ll long long
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl;



int func(string S, string T){
    int ans = 0;
    for (char c = 'a'; c <= 'z'; c++) {
        bool founds = false, foundt = false;
        for (int i = 0; i < S.size(); i++) {
            if (S[i] == c) {
                founds = true;
            }
        }
        for (int j = 0; j < T.size(); j++) {
            if (T[j] == c) {
                foundt = true;
            }
        }
        if (founds&&foundt)ans++;
    }
    return ans;
}


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

    int ans = 0;
    for (int i = 0; i <= N; i++) {
        int tmp = func(S.substr(0, i), S.substr(i));
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int> P;
vector<int> ny={-1,0,1,0},nx={0,-1,0,1};
int main(){
    int h,w;
    cin>>h>>w;
    queue<P> Q;
    vector<string> s(h);
    for(int i=0;i<h;i++)cin>>s.at(i);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s.at(i).at(j)=='#'){
                Q.push(P(i,j));
            }
        }
    }
    bool flag=false;
    while(!Q.empty()){
        P q=Q.front();
        Q.pop();
        int x=q.second;
        int y=q.first;
        flag=false;
        for(int i=0;i<4;i++){
             int dx=x+nx.at(i);
             int dy=y+ny.at(i);
             if(dx<0||dx>=w||dy<0||dy>=h)continue;
             if(s.at(dy).at(dx)=='#'){
                 flag=true;
                 break;
             }
        }
        if(!flag){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
S=int(input())
As,Bs=input().split()
#A=input().split()
#A = list(map(int, input().split()))
ans=0

A=int(As)
B=int(Bs)
tmp=A%S
if (A+(S-tmp))<=B:
    print("OK")
elif tmp==0:
    print("OK")

else:
    print("NG")

Measured memory_bytes: 9184