akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
	int N, M;
	int ans = 0;
	int a[20][20], b[1000], c;
	
	cin >> N >> M >> c;
	int sum = c;
	for (int i = 0; i < M; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			sum += a[i][j] * b[j];
		}
		if (sum > 0)ans++;
	
		sum = c;

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


Measured memory_bytes: 3612
n, y = map(int, input().split())
ans = [-1, -1, -1]

for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if k>=0 and 10000*i + 5000*j + 1000*k == y:
            ans[:] = [i, j, k]

print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int i;
	char x[10];
    i = 0;
  if(scanf("%s", &x)== 1);
	
	if (strcmp(x,"SUN")==0){
		i = i + 7;
		printf("%d", i);
	}
	if (strcmp(x,"MON")==0){
		i = i + 6;
		printf("%d", i);
	}
	if (strcmp(x,"TUE")==0){
		i = i + 5;
		printf("%d", i);
	}
	if (strcmp(x,"WED")==0){
		i = i + 4;
		printf("%d", i);
	}
	if (strcmp(x,"THU")==0){
		i = i + 3;
		printf("%d", i);
	}
	if (strcmp(x,"FRI")==0){
		i = i + 2;
		printf("%d", i);
	}
	if (strcmp(x,"SAT")==0){
		i = i + 1;
		printf("%d", i);
	}

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e18;
const int max1=1e5+5;

ll a[max1],n,zero=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(!a[i])zero=1;
	}
	if(zero){
		cout<<0;
	}
	else{
		ll tmp=1;
		for(int i=0;i<n;i++){
			if(a[i]<=maxn/tmp){
				tmp*=a[i];
			}
			else{
				tmp=-1;
				break;
			}
		}
		cout<<tmp;
	}
	return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll N, K;
ll dp[102][20001];

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret *a % mod;
    return ret;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    dp[N+1][0] = 1;
    for(ll i = N; i >= 1; i--) {
        ll Over = K - i;
        chmax(Over, 0LL);
        for(ll before = 0; before <= 10000; before++) {
            if(dp[i+1][before] == 0) continue;
            dp[i][before] += Over * dp[i+1][before];
            dp[i][before] %= mod;
            ll under = (i * 10000 - before) % i;
            ll carry = before / i;
            if(under == 0) under = i;
            chmin(under, min(i, K) + 1);
            //cerr << i << " " << before << " " << under << endl;
            dp[i][before+carry] += under * dp[i+1][before];
            dp[i][before+carry] %= mod;
            for(ll delta = 1; ; delta++) {
                ll New = under + delta * i;
                chmin(New, min(i, K) + 1);
                //cerr << i << " " << before << " " << delta << " " << New << " " << New - (under + (delta-1)*i) << endl;
                dp[i][before+carry+delta] += (New - (under + (delta - 1) * i)) * dp[i+1][before];
                dp[i][before+carry+delta] %= mod;
                if(New != under + delta * i) break;
            }
        }
    }
    /*
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= N * K; j++) {
            cerr << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    */
    ll ans = beki(K + 1, N - 1) * K;
    ans %= mod;
    ans *= (K + 1);
    ans %= mod;
    ans *= beki(2, mod - 2);
    ans %= mod;
    ans *= N;
    ans %= mod;
    //cerr << ans << endl;
    for(int i = 0; i <= 10000; i++) {
        ans -= dp[1][i] * i;
        ans %= mod;
        ans += mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define MAXN 200005
#define LL long long
#define sum(l,r) (l<=r?(s[r] - s[l-1]):0)
using namespace std;
 
int N;
LL a[MAXN], s[MAXN];
int nxt[MAXN];
 
int main(){
	
	cin>>N;
	cin>>a[1];
	
	int N1 = 1;
	char op;
	int x, f = 1; 
	for(int i=1;i<N;i++){
		cin>>op;
		cin>>x;
		if(op=='-') a[++N1] = -x, f = 0;
		else{
			if(f) a[N1] += x;
			else a[++N1] = x, f = 1; 
		}
	}

	N = N1;
	if(N==1){
		cout<<a[1]<<endl;
		return 0;
	}
	
	for(int i=1;i<=N;i++){
		//cout<<a[i]<<" ";
		s[i] = s[i-1] + abs(a[i]);
	}
	//cout<<endl;
	
	nxt[N] = N;
	for(int i=N-1;i>=1;i--){
		if(a[i+1] < 0) nxt[i] = i;
		else nxt[i] = nxt[i+1];
	}
	
	LL ans = -1e18; 
	LL sum = a[1];
	for(int i=2;i<=N;i++){
		
		if(a[i] < 0) ans = max(ans, sum - sum(i,nxt[i]) + sum(nxt[i]+1,N));
		sum += a[i];
	} 
	
	ans = max(ans, sum);
//	
//	for(int i=2;i<=N;i++){
//		ans = max(ans, a[1]-sum(2,i)+sum(i+1,N));
//	}
	cout<<ans<<endl;
	return 0;
}

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

int x, y;

int gcd(int i, int j) {
  if (i < j) return gcd(j, i);
  if (j == 0) return i;
  return gcd(j, i%j);
}

int main() {
  cin >> x >> y;
  cout << gcd(x, y) << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a < 13 && a >= 6) cout << b/2 << endl;
    else if(a < 6) cout << 0 << endl;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int a[100][100];
int b[50][50];
int n,m;

void rotate()
{
	int temp[50][50];
	memset(temp,0,sizeof(temp));

	rep(i,m) rep(j,m) temp [i][j] = b[j][m-1-i];

	rep(i,m) rep(j,m) b[i][j] = temp[i][j];
}

void show(int y,int x)
{
	cout << "show" << endl;
	rep(i,n)
	{
		rep(j,n)
		{
			if(y == i && x == j)
			{
				cout << "X ";
			}
			else cout << a[i][j] << " ";
		}
		cout << endl;
	}
}


int main()
{
	while(cin >> n >> m)
	{
		if(n == 0 && m == 0) break;

		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));

		rep(i,n) rep(j,n) cin >> a[i][j];

		rep(i,m) rep(j,m) cin >> b[i][j];

		vector<pair<int,int> > v;

		rep(i,n-m+1)
		{
			rep(j,n-m+1)
			{
				bool flag = true;

				rep(k,m)
				{
					rep(l,m)
					{
						if(a[i+k][j+l] != b[k][l] && b[k][l] != -1)
						{
							flag = false;	
						}
					}
				}


				if(flag)
				{
					int minx=100,miny=100;
					bool flag2 = true;
					rep(k,m)
					{
						rep(l,m)
						{
							if(a[i+k][j+l] == b[k][l] && flag2)
							{
								miny = i+k;
								minx = j+l;
								flag2 = false;
							}
						}
					}
					v.push_back(make_pair(miny,minx));
				}
			}
		}

		rotate();

		rep(i,n-m+1)
		{
			rep(j,n-m+1)
			{
				bool flag = true;
				rep(k,m)
				{
					rep(l,m)
					{
						if(a[i+k][j+l] != b[k][l] && b[k][l] != -1)
						{
							flag = false;
						}
					}
				}

				if(flag)
				{
					int minx=100,miny=100;
					bool flag2 = true;
					rep(k,m)
					{
						rep(l,m)
						{
							if(a[i+k][j+l] == b[k][l] && flag2)
							{
								miny = i+k;
								minx = j+l;
								flag2 = false;	
							}
						}
					}
					v.push_back(make_pair(miny,minx));
				}
			}
		}

		rotate();

		rep(i,n-m+1)
		{
			rep(j,n-m+1)
			{
				bool flag = true;
				rep(k,m)
				{
					rep(l,m)
					{
						if(a[i+k][j+l] != b[k][l] && b[k][l] != -1)
						{
							flag = false;
						}
					}
				}

				if(flag)
				{
					int minx=100,miny=100;
					bool flag2 = true;
					rep(k,m)
					{
						rep(l,m)
						{
							if(a[i+k][j+l] == b[k][l] && flag2)
							{
								miny = i+k;
								minx = j+l;
								flag2 = false;	
							}
						}
					}
					v.push_back(make_pair(miny,minx));
				}
			}
		}

		rotate();

		rep(i,n-m+1)
		{
			rep(j,n-m+1)
			{
				bool flag = true;
				rep(k,m)
				{
					rep(l,m)
					{
						if(a[i+k][j+l] != b[k][l] && b[k][l] != -1)
						{
							flag = false;
						}
					}
				}

				if(flag)
				{
					int minx=100,miny=100;
					bool flag2 = true;
					rep(k,m)
					{
						rep(l,m)
						{
							if(a[i+k][j+l] == b[k][l] && flag2)
							{
								miny = i+k;
								minx = j+l;
								flag2 = false;	
							}
						}
					}
					v.push_back(make_pair(miny,minx));
				}
			}
		}

		if(v.size() != 0)
		{
			sort(v.begin(),v.end());
			cout << v[0].second+1 << " " << v[0].first+1 << endl;
		}
		else cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1392
#include<bits/stdc++.h>
#define ll long long int 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<ll> v;
  v.push_back(a*c);
  v.push_back(a*d);
  v.push_back(b*c);
  v.push_back(b*d);
//  for(ll x:v){
//  	cout<<x<<" ";
//  }
//  cout<<endl;
cout<<*max_element(v.begin(),v.end())<<endl;
  
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}


Measured memory_bytes: 256
/*input
3 1
10 20 10
*/
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}
int n,k;
int a[100001];
int dp[100001];
int solve(int i)
{

	if(i>=n)
	{
		return 0;
	}
	if(dp[i]!=-1)
		return dp[i];
	int ans = 2e18;
	for(int j=1;j<=k;j++)
	{
		if(i+j<=n)
			ans=min(abs(a[i]-a[i+j])+solve(i+j),ans);
	}
	dp[i]=ans;
	return dp[i];
}

signed main() {
	IOS;
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	a[n]=a[n-1];
	cout<<solve(0);
	
return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++)
    cin >> d.at(i);
  
  for(int i=0;i<N;i++){
    if(d.at(i)==0)
      continue;
    for(int k=0;k<N;k++){
      if(d.at(i)==d.at(k)){
        if(i==k)
          continue;
        d.at(k)=0;
      }
    }
  }
  int k=0;
  for(int i=0;i<N;i++){
    if(d.at(i)!=0)
      k++;
  }
  cout << k;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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 int INF = 1e9;

int N;
int h[100];
int a[100];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];
    int hmax = 0;
    for (int i = 0; i < N; i++) chmax(hmax,h[i]);
 
    int res = 0;
    for (int k = 0; k < hmax; k++) {
        int i = 0;
        while (i < N) {
            while (i < N && h[i] <= a[i]) i++;
            bool flag = false;
            while (i < N && h[i] > a[i]) {
                a[i++]++;
                flag = true;
            }
            if (flag) res++;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma optimize("O2")
#define IOS cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false)
using namespace std;

int A[100002];
vector<int> t(400000);
map<int, vector<int>> M;

int main(){
	IOS;
	int n, m;
	cin >> n >> m;
	if(n == m){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>

int main() {
  int n, m;
  int a[1001], b[1001];
  std::cin >> n;
  for (int i = 0; i < n; ++i)
    std::cin >> a[i];
  std::cin >> m;
  for (int i = 0; i < m; ++i)
    std::cin >> b[i];

  std::cout << (std::lexicographical_compare(a, a + n, b, b + m)) << std::endl;
}



Measured memory_bytes: 3136
a=[]
n=int(input())
for i in range(2**n):
    a.append(int(input()))
while len(a)>1:
    t=[]
    for i in range(0,len(a),2):
        x,y=a[i],a[i+1]
        if x==y:
            t.append(x)
        else:
            t.append(abs(x-y))
    a=t
print(*t)


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

const llong MOD = 1e9+7;
const llong inf = 1<<30;

string s;
int N;
vector<int> res;

int main() {
    cin >> s; N = s.size(); res.resize(N);

    //尺取り法
    int cnt = 0;
    int l = 0;
    for (int r = 0; r < N; r++) {
        if (s[r] != 'L') {
            cnt++;
            continue;
        }
        res[r] += cnt/2 + 1;
        res[r-1] += cnt/2 + cnt%2;
        cnt = 0;

        l = r;
        while(s[r+1] == 'L') {
            cnt++;    
            r++;
            res[l-(cnt%2)]++;
        }
        cnt = 0;
    }

    for (int i = 0; i < N; i++) cout << res[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
/*
ID: alec3
LANG: C++14
PROG: ttwo
*/

#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

ifstream fin("ttwo.in");
ofstream fout("ttwo.out");

int dp[100001];
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& it : a) cin >> it;

    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);

    for (int i = 2; i < n; i++)
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{   ios_base::sync_with_stdio(false); cin.tie(0);

    int n,A[505*505];
    cin>>n;
    for(int i = 0; i < n*n; i++){
        cin >> A[i];
    }
    int map[n+2][n+2];
    int fill[n+2][n+2];
    for(int y = 0; y < n+2; y++){
        for(int x = 0; x < n+2; x++){
            int X = x-1;
            int Y = y-1;
            map[y][x] = max(0, min(min(min(X,Y),n-X-1),n-Y-1));
            fill[y][x] = 1;
          //  cout << map[y][x];
        }
      //  cout << endl;
    }
    long cost = 0;
    int currentX[505*505];
    int currentY[505*505];
    int currentX2[505*505];
    int currentY2[505*505];
    int currentCount = 0;
    int currentCount2 = 0;
    for(int i = 0; i < n*n; i++){
        int a = A[i] - 1;
        int y = a/n + 1;
        int x = a%n + 1;
        cost += map[y][x];
    //    cout << y << ", " << x << ", " << map[y][x] << endl;
        fill[y][x] = 0;
        currentX[currentCount] = x; currentY[currentCount] = y; currentCount = 1;

        while(currentCount){
            currentCount2 = 0;
            for(int j = 0; j < currentCount; j++){
                int yy = currentY[j], xx = currentX[j];
                int newCost = map[yy][xx] + fill[yy][xx];
                if(map[yy][xx-1] > newCost){
                    map[yy][xx-1] = newCost;
                    currentX2[currentCount2] = xx - 1; currentY2[currentCount2] = yy; currentCount2++;
                }
                if(map[yy-1][xx] > newCost){
                    map[yy-1][xx] = newCost;
                    currentX2[currentCount2] = xx; currentY2[currentCount2] = yy-1; currentCount2++;
                }
                if(map[yy][xx+1] > newCost){
                    map[yy][xx+1] = newCost;
                    currentX2[currentCount2] = xx + 1; currentY2[currentCount2] = yy; currentCount2++;
                }
                if(map[yy+1][xx] > newCost){
                    map[yy+1][xx] = newCost;
                    currentX2[currentCount2] = xx; currentY2[currentCount2] = yy+1; currentCount2++;
                }
            }
            currentCount = currentCount2;
            for(int j = 0; j < currentCount2; j++){
                currentX[j] = currentX2[j];
                currentY[j] = currentY2[j];
            }
        }
        
    }
    cout << cost << endl;


}

Measured memory_bytes: 6616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=b-1;i>=a;i--)
#define mod 1000000007
#define pb push_back
#define son ll t; cin>>t;while(t--)
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL);
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define mpr make_pair
#define ff first
#define ss second
#define inf 5e18
#define dex(x,y) fixed<<setprecision(x)<<y
void start()
{
    #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    fst
//    start();
   int l,r,d,c=0;
  cin>>l>>r>>d;
  fr(i,l,r+1)
    if(i%d==0)
      c++;
  cout<<c;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  ll sumbuf=0;
  rep(i,0,n)sumbuf+=a[i];
  ll x=0,y=0;
  rep(i,0,n){
    x+=a[i];
    if(x>=sumbuf/2){
      y=x-a[i];
      break;
    }
  }
  cout<<min(abs(2*x-sumbuf),abs(2*y-sumbuf))<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int r;
  cin>>r;
  cout<<2*M_PI*r<<endl;
  return 0;
}


Measured memory_bytes: 3788
n = gets.to_i
t, a = gets.split(' ').map{ |i| i.to_i }
h = gets.split.map{|i| i.to_i}
c = t - 0.006 * h[0]
ans = [1, (a - c).abs]
for i in 0..n-1 do
  c = t - 0.006 * h[i]
  if (a - c).abs <= ans[1]
    ans[0] = i + 1
    ans[1] = (a - c).abs
  end
end

puts ans[0]

Measured memory_bytes: 1788
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}




#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

//gp_hash_table<long long, int, custom_hash> cnt;

const int mx = 1e5+123;
int a[mx];

int main()
{
    optimize();

    unordered_map < ll, int > cnt;

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

    int ans = 0;
    for ( int i = 1; i <= n; i++ ) {
        if ( cnt[a[i]] >= a[i] ) ans += ( cnt[a[i]] - a[i] );
        else ans += cnt[a[i]];
        cnt[a[i]] = 0;
    }

    cout << ans << endl;



    return 0;
}


















Measured memory_bytes: 4644
n=int(input())
a=[0]+[int(i) for i in input().split()]
m=0
ans=[]
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
for i in range(n,0,-1):
    if a[i]%2==1:
        m+=1
        ans.append(i)
        l=make_divisors(i)
        for j in l:
            a[j]+=1
print(m)
if ans!=[]:
    for i in range(m):
        if i!=m-1:
            print(ans[i],end=" ")
        else:
            print(ans[i])


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

#define MOD 1000000007

int main() {
	int n; cin >> n;
	vector<int> t(n),a(n);
	for(auto&e:t) cin >> e;
	for(auto&e:a) cin >> e;
	vector<bool> used(n);
	used[0]=used[n-1]=true;
	bool miss=false;
	for(int i=1;i<n;++i) {
		if(t[i-1]<t[i]) {
			used[i]=true;
			if(a[i]<t[i]) miss=true;
		}
		if(t[i-1]>t[i]) miss=true;
	}
	for(int i=n-2;i>=0;--i) {
		if(a[i+1]<a[i]) {
			used[i]=true;
			if(t[i]<a[i]) miss=true;
		}
		if(a[i+1]>a[i]) miss=true;
	}
	if(miss||t[n-1]!=a[0]) {
		cout << 0 << endl;
		return 0;
	}
	long long ans=1;
	for(int i=0;i<n;++i)
		if(!used[i]) (ans*=min(t[i],a[i]))%=MOD;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int LEN;
char S[55];
LL dp[21][21];

void MAIN() {
    scanf("%d", &N);
    scanf("%s", S);
    LEN = N * 2;

    LL ans = 0;
    string P;
    REP (blue_mask, 1<<N) {
	P.clear();
	int blue_cnt = 0, red_cnt = 0;
	REP (i, N) if (~blue_mask>>i&1) {
	    P.push_back(S[i]);
	    red_cnt++;
	}
	for (int i=N; i--;) if (blue_mask>>i&1) {
	    P.push_back(S[i]);
	    blue_cnt++;
	}

	memset(dp, 0, sizeof dp);
	dp[0][red_cnt] = 1;
	REP (i, N) REP (r, N+1) if (dp[i][r]) {
	    int b = N + i - r;
	    if (r+1 <= N && S[N+i] == P[r]) {
		dp[i+1][r+1] += dp[i][r];
	    }
	    if (b+1 <= N && S[N+i] == P[N-1-b]) {
		dp[i+1][r] += dp[i][r];
	    }
	}

	ans += dp[N][N];
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
N = gets.chomp.to_i
a = Array.new(1,10**9+1)
color = 0
left = 0
right = 0
center = 0
for i in 1..N do
    x = gets.chomp.to_i
    if x <= a[color]
        a.push(x)
        color += 1
    else
        left = 0
        right = color
        while left != right
            center = (left+right)/2
            if a[center] < x
                right = center
            elsif
                left = center+1
            end
        end
        a[left] = x
    end
end
puts color

Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+20;
long long v[N], c[51][51];
void init()
{
	memset(c, 0, sizeof(c));
	c[0][0] = 1;
	for (int i = 1; i <= 50; i++)
	{
		c[i][0] = 1;
		for (int j = 1; j <= i; j++)
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
	}
}
int main()
{
	int n, a, b;
	init();
	while(cin >> n >> a >> b)
	{
		double ave;
		for (int i = 0; i < n; i++)
			cin >> v[i];
		sort(v, v + n);
		reverse(v, v + n);
		for (int i = 0; i < a; i++) 
			ave += v[i];
		ave /= a;
		int num = 0, k = 0;
		for (int i = 0; i < n; i++)
		{
			if (v[i] == v[a - 1])
			{
				num++;
				if (i < a) k++;
			}
		}	
		long long ans = 0; 
		if (k == a)
		{
			for (int i = a; i <= b; i++)
				ans += c[num][i];
		}
		else ans += c[num][k];
        cout.precision(20);
 		cout << fixed << ave << endl << ans;
	}
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,Z,W;
vector<ll> a;

ll memo[2001][2];

ll dfs(int idx,int p,ll x,ll y){
    if(memo[idx][p]>0) return memo[idx][p];
    if(idx==N) return abs(x-y);
    if(p==0){
        ll tmp = 0;
        // [idx,i]
        for(int i=idx;i<N;i++){
            tmp = max(tmp,dfs(i+1,p^1,a[i],y));
        }
        return memo[idx][p] = tmp;
    }else{
        ll tmp = mod;
        for(int i=idx;i<N;i++){
            tmp = min(tmp,dfs(i+1,p^1,x,a[i]));
        }
        return memo[idx][p] = tmp;
    }
}

ll dfs2(int idx,int p,ll x,ll y){
    if(idx==N) return abs(x-y);
    if(p==0){
        ll tmp = abs(x-y);
        // [idx,i]
        for(int i=idx;i<N;i++){
            tmp = max(tmp,dfs(i+1,p^1,a[i],y));
        }
        return tmp;
    }else{
        ll tmp = abs(x-y);
        for(int i=idx;i<N;i++){
            tmp = min(tmp,dfs(i+1,p^1,x,a[i]));
        }
        return tmp;
    }
}

int main(){
    cin >> N >> Z >> W;
    a = vector<ll>(N,0);
    rep(i,N) cin >> a[i];

    if(N==1){
        cout << abs(a[N-1] - W) << endl;
        return 0;
    }

    if(N<26){
        ll ans = dfs2(0,0,Z,W);
        cout << ans << endl;
        return 0;
    }

    ll ans = dfs(0,0,Z,W);
    cout << ans << endl;
}


Measured memory_bytes: 512
/*
    code was
    created by
    Bayel
    Abdikarimov
*/

# include <bits/stdc++.h>
# define frein freopen("input.in","r", stdin)
# define freout freopen("output.out","w", stdout)
# define fr first
# define sc second;
# define pb push_back
# define ll long long

const int N = 1e5 + 5;
const int INF = 1e9 + 10;
const int mod = 1e9;
const int prime = 271;

using namespace std;

int main ()
{
    long long x, y, ans = 0;
    cin >> x >> y;
    if (2 * x <= y)
        ans = x + ((y - 2 * x) / 4);
    else
        ans = y / 2;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define scani(i) scanf("%d", &(i))
#define scanc(c) scanf("%c", &(c))
#define scand(d) scanf("%lf", &(d))

#define printi(i) printf("%d", (i))
#define pr printf("\n")

#define NUM (100)

int main(int argc, char** argv){
    int a, b;
    scani(a);
    scani(b);

    int sum = max(0, a - b * 2);

    printi(sum);
    pr;

    return 0;
}



Measured memory_bytes: 128
#include<iostream>
int main(){
    int A, B, C, K;
    std::cin >> A >> B >> C >> K;
    int cost = 0;
    if(K >= A) {K-=A;cost+=A;}
    else {cost+=K;K=0;}
    if(K >= B) {K-=B;}
    else {K=0;}
    if(K >= C) {K-=C;cost-=C;}
    else {cost-=K;K=0;}
    std::cout << cost << "\n";
}

Measured memory_bytes: 3640
#include<stdio.h>

int main() {
	int N;
	long long max = -1000000, min = 1000000;
	long long sum = 0;
	long long scan;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &scan);
		if (scan > max) max = scan;
		if (scan < min) min = scan;
		sum += scan;
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}


Measured memory_bytes: 2748
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

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

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll n; cin >> n;
  ll maxi = 1000000;
  ll cnt = 0;
  for(ll i = 1; i < n; i++){
    if(i * maxi < n){
      cnt += maxi;
    }
    else{
      maxi--;
      if(maxi == 0) break;
      i--;
      continue;
    }
  }
  cout << cnt << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3568
# D - Dice in Line

N, K = map(int, input().split())
P = list(int(x) for x in input().split())

S = [0] * (N+1)

for i in range(N):
    S[i+1] = S[i] + P[i]

ans = 0

for j in range(K, N+1):
    if S[j]-S[j-K]>ans:
        ans = S[j]-S[j-K]

print(0.5*(K+ans))

Measured memory_bytes: 24548
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d, N, ans=0;
    vector<int> v(3);
    vector<char> L(3);
    char tmp, tmp2;
    string S, S2, S3;
    bool flag=true;
    
    cin >> N;

    ans = (N%2==0) ?N : 2*N ;
    cout << ans << endl;
    // ans = a<=b ? a:a-1;

    
    // ans = min(A, B) + min(C, D);
    // cout << ans<< endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(abs(a-b) <=d && (b-c) <=d ||abs(c-a)<=d)
    // 	puts("Yes");
    // else
    // 	puts("No");
}



Measured memory_bytes: 256
n,l = map(int,input().split())
a = list(map(int,input().split()))
for i in range(1,n):
	if a[i-1] + a[i] >= l:
		print("Possible")
		for j in range(1,i,1):
			print(j)
		for j in range(n-1,i-1,-1):
			print(j)
		break
else:
	print("Impossible")


Measured memory_bytes: 14060
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

struct edge{ int to,cost; };
vector<int> dikstra(int s,vector<vector<edge>> G){
  typedef pair<int, int> P;
  const int INF = 1LL << 60;

  priority_queue<P,vector<P>,greater<P>> que;
  vector<int> d(G.size(),INF); //sからの最短距離
  d[s] = 0;
  que.push({0,s}); //{最短距離,頂点}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }
  return d;
}

signed main(){

  int n, m; cin >> n >> m;
  vector<vector<edge>> G(n * 3);
  for(int i = 0; i < m; i++){
    int u, v; cin >> u >> v;
    u--, v--;
    G[u].push_back({v + n, 1});
    G[u + n].push_back({v + n * 2, 1});
    G[u + n * 2].push_back({v, 1});
  }

  int s, t; cin >> s >> t;
  s--, t--;
  auto dp = dikstra(s, G);
  cout << (dp[t] == INF ? -1 : dp[t] / 3) << endl;

  return 0;
}


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

int main(void){
	int k;
	char s[101];
	scanf("%d",&k);
	scanf("%s",s);
	
	if(strlen(s)<=k){
		for(int i=0;i<strlen(s);i++){
			printf("%c",s[i]);
		}
	}else{
		for(int i=0;i<k;i++){
			printf("%c",s[i]);
		}
		printf("...");
	}
	return 0;
}

Measured memory_bytes: 1728
#include<iostream>

using namespace std;

int main(){
    int x, y; cin >> x >> y;
    int t = (y-2*x)/2;
    int c = 2*x - y/2;
    if(t < 0 || c < 0 || (c + t != x) || (2*c+4*t != y)){
        cout << "No\n";
    } else{
        cout << "Yes\n";
    }
    return 0;
}

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

int main(){
   int a,i,n,sum=0;
   cin>>n;
   a=n;
   for(i=0;a>0;i++){
    sum+=a%10;
    a=a/10;
   }
   if(n%sum==0){
    cout<<"Yes"<<endl;
   }else{
       cout<<"No"<<endl;

   }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;
const int MAXB = 60;

int n;
ll a[MAXN], sum, mk, fmask[MAXB];

void ins (ll val) {
    for (int i=MAXB-1; i>=0; i--) {
        if ((val & (1LL<<i)) == 0) {
            continue;
        }
        if (fmask[i] == 0) {
            fmask[i] = val;
            return;
        }

        val ^= fmask[i];
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    REP (i, n) {
        cin >> a[i];
        sum ^= a[i];
    }

    mk = sum ^ ((1LL<<MAXB) - 1);
    REP (i, n) {
        ins(a[i] & mk);
    }

    ll res = 0;
    for (int i=MAXB-1; i>=0; i--) {
        if ((res & (1LL<<i)) == 0) {
            res ^= fmask[i];
        }
    }

    debug(res, sum);
    cout << res*2 + sum << endl;

}


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;

  int cnt = 0;
  while (N >= K) {
    N = N / K;
    cnt++;
  }
  cnt++;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int s=0;
	for(int i=0;i<=a.size()-1;i++)
	{
		if(a[i]==b[i])
		{
			s++;
		}
	}
	cout<<s;
	return 0;
 } 

Measured memory_bytes: 256
// finish date: 2018/01/22
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}


int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    int pos = 0;
    for (int i = n - 1; i >= 0; i -= 2) {
        b[pos] = a[i];
        pos++;
    }
    int s = (n % 2 == 0) ? 0 : 1;
    for (int i = s; i < n; i += 2) {
        b[pos] = a[i];
        pos++;
    }
    rep(i, n) cout << b[i] << " ";
    cout << endl;

    return 0;
}



Measured memory_bytes: 3712
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    string s;
    cin>>s;
    int cnt=0;
    REP(i,N){
        if(s[i]=='R') cnt++;
    }

    int ans=0;
    if(cnt!=0){
        REP2(i,cnt,N){
            if(s[i]=='R') ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(void){
	int h, ans, hoge,count;
	int table[10][5];
	bool b[5];

	while(1){
		scanf("%d", &h);
		if(h==0) break;

		ans=0;

		for(int i=0; i<h; i++){
			for(int j=0; j<5; j++){
				scanf("%d", &table[i][j]);
			}
		}

		hoge =0;
		while(1){
			for(int i=0; i<h; i++){
				fill(b, b+5, false);
				count=0;
				if(table[i][2]==0) continue;
				if(table[i][2] == table[i][1]){
					b[1]=true;
					count++;
					if(table[i][2] ==table[i][0]){
						b[0]=true;
						count++;
					}
				}
				if(table[i][2] == table[i][3]){
					b[3]=true;
					count++;
					if(table[i][2] ==table[i][4]){
						b[4]=true;
						count++;
					}
				}

				if(count>=2){
					b[2] = true;
					count++;
					ans += (table[i][2]*count);

					for(int j=0; j<5; j++){
						if(b[j]==true){
							table[i][j]=0;
						}
					}
				}
			}//endfor

			if(hoge == ans) break;
			hoge = ans;

			for(int i=0; i<h; i++){
				for(int j=0; j<5; j++){
					if(table[i][j] == 0){
						for(int k =i; k>0; k--){
							int tmp;
							tmp =table[k-1][j];
							table[k-1][j] = table[k][j];
							table[k][j] = tmp;
						}
					}
				}
			}

		}//endwhile

		printf("%d\n", ans);
	}//endwhile

	return 0;
}


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

int main() {
	double q;
	while (cin >> q, q >= 0.0) {
		double x = q / 2.;
		while (fabs(x * x * x - q) >= 0.00001 * q) {
			x = x - (x * x * x - q) / (3 * x * x);
		}
		printf("%.6lf\n", x);
	}
	return 0;
}

Measured memory_bytes: 1236
package main

import (
	"fmt"
)

// 最大公約数
func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// 最小公倍数
func lcm(a int, b int) int {
	return a * b / gcd(a, b)
}

func main() {
	var A int
	fmt.Scanf("%d", &A)
	A--
	var B int
	fmt.Scanf("%d", &B)
	var C int
	fmt.Scanf("%d", &C)
	var D int
	fmt.Scanf("%d", &D)
	R := B - A
	X := B/C - A/C
	Y := B/D - A/D
	Z := B/lcm(C, D) - A/lcm(C, D)

	fmt.Println(R - (X + Y - Z))
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
struct BIT
{
	// [0,size)
	vector<LL> tree;
	int size;
	BIT(int s){
		size=s;
		tree.resize(size+1);
	}
	void init(int s){
		size=s;
		tree.clear();
		tree.resize(size+1);
	}
	void add(int i,LL v){
		i++;
		while(i<=size){
			tree[i]+=v;
			i+=(i&-i);
		}
	}

	// [0,i]
	LL collect(LL i){
		i++;
		LL r=0;
		while(i>0){
			r+=tree[i];
			i-=(i&-i);
		}
		return r;
	}

	// [a,b]
	LL collect(int a, int b){
		return collect(b)-collect(a-1);
	}
};

const int L=1e5;
int a[L];
P s[L];
int main() {
	BIT bit(0);

	LL N;
	scanf("%lld",&N);
	for(int i=0;i<N;i++){
		scanf("%d",a+i);
		s[i]=P(a[i],i);
	}
	sort(s,s+N);
	/*
	for(int i=0;i<N;i++){
		cerr << s[i] << " ";
	}
	cerr << endl;
	*/
	int low=0;
	int hi=N;
	while(low+1<hi){
		int m=(low+hi)/2;
		P v=s[m];
		const int S=3e5;
		int cur=S/2;
		bit.init(S);
		LL p=0,q=0,r=0;
		for(int i=0;i<N;i++){
			bit.add(cur,1);
			if(P(a[i],i)<v){
				cur++;
			}
			else {
				cur--;
			}
			p+=bit.collect(0,cur-1);
			r+=bit.collect(cur,cur);
			q+=bit.collect(cur+1,S-1);
		}
		LL t=(N*(N+1)/2)/2;
		//cerr << m << ": " << v << ", " << p << ", " << r << ", " << q << ", " << t << ", " << N*(N+1)/2 << endl;
		if(p<=t){
			low=m;
		}
		else{
			hi=m;
		}
	}
	printf("%d\n",s[low].first);

	return 0;
}



Measured memory_bytes: 3712
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys


input = sys.stdin.readline


def main():
    a, b = map(int, input().split())
    if a <= 0 and b >= 0:
        print('Zero')
        sys.exit(0)
    elif b < 0 and (b-a) % 2 == 0:
        print('Negative')
    else:
        print('Positive')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// BufferedReader stdIn = new BufferedReader(new FileReader(new
		// File("c:\\2024-input.txt")));

		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while ((s = stdIn.readLine()) != null) {
			int setc = Integer.valueOf(s);
			for (int i = 0; i < setc; i++) {
				// read initial cards and deal cards
				String ini = stdIn.readLine();
				String deal = stdIn.readLine();
				String[] inis = ini.split(" ");
				String[] deals = deal.split(" ");
				// process dealers action
				Dealer d = new Dealer(inis);
				d.action(deals);
			}
		}
		System.exit(0);
	}
}

class Dealer {
	private int score = 0;
	private int ace11 = 0;
	private int piece = 0;

	// first 2 cards
	Dealer(String[] inis) {
		this.addcard(inis[0]);
		this.addcard(inis[1]);
	}

	// hits card until stand, and output result. otherwise
	public void action(String[] deals) {
		for (int i = 0; this.isHit(); i++)
			this.addcard(deals[i]);
		;
		if (score == 21 && piece == 2)
			System.out.println("blackjack");
		else if (score > 21)
			System.out.println("bust");
		else
			System.out.println(score);

	}

	// judge hits or stand
	private boolean isHit() {
		if (score > 21 && ace11 > 0) {
			score -= 10;
			--ace11;
			return (isHit());
		}
		if (score == 17 && ace11 > 0)
			return true;
		if (score > 16)
			return false;
		else
			return true;
	}

	// hits one card
	private void addcard(String s) {
		switch (s) {
		case ("A"):
			score += 11;
			ace11 += 1;
			break;
		case ("T"):
		case ("J"):
		case ("Q"):
		case ("K"):
			score += 10;
			break;
		default:
			score += Integer.valueOf(s);
			break;
		}
		piece += 1;
	}
}

Measured memory_bytes: 24360
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<set>

using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
	
int main()
{
	int n;
	cin >> n;
	
	REP(i,n)
	{
		string _input,_left,l_rev,_right,r_rev;
		set<string> s;
		
		cin >> _input;
		
		REP(j,_input.size())
		{
			_left  = l_rev = _input.substr(0,j);
			_right = r_rev = _input.substr(j);
			reverse(l_rev.begin(),l_rev.end());
			reverse(r_rev.begin(),r_rev.end());
			s.insert(_left + r_rev);
			s.insert(l_rev + _right);
			s.insert(l_rev + r_rev);
			s.insert(_right + _left);
			s.insert(r_rev + _left);
			s.insert(_right + l_rev);
			s.insert(r_rev + l_rev);
		}
		
		cout << s.size() << endl;
		
	}
	return 0;
	
}
	
	

Measured memory_bytes: 3144
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    // input
    int N; cin >> N;
    int A; cin >> A;
    // compute
    bool can = false;
    for (int i = 0; i <= A; i++){
        if ((N - i)%500 == 0) {
            can = true;
            break;
        }
    }

    // output
    cout << (can ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
A.sort()
u, d = A[-1], A[0]
print(sum(abs(a) for a in A) - 2*min(abs(u), abs(d))*int(u*d>0))
for a in A[1:-1]:
    if a<0:
        print(u, a)
        u -= a
    else:
        print(d, a)
        d -= a
print(u, d)

Measured memory_bytes: 20504
import sys
n = int(input())
d = {}
for op in sys.stdin.readlines():
    op = op.split()
    if op[0] == 'insert':
        d[op[1]] = 1  
    elif op[0] == 'find':
        if op[1] in d:
            print('yes')
        else:
            print('no')

Measured memory_bytes: 112372