akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n;
  cin>>n;
  int ans=0;
  rep(i,1000000){
    if(i*i>n)break;
    ans=i*i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,m,num[N],ans1,ans2;char s[10];
int main(){
    // freopen("test.in","r",stdin);
    scanf("%d%d",&n,&m);
    for(int i=1,x;i<=m;i++){
        scanf("%d%s",&x,s);
        if(s[0]=='W'){
            if(~num[x])num[x]++;
        }
        else {
            if(~num[x])ans1++,ans2+=num[x],num[x]=-1;
        }
    }
    printf("%d %d\n",ans1,ans2);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int b = 0;
  for(int i = 0;i< 4;i++){
    if(a.at(i) == '+')
      b++;
    else
      b--;
  }
  cout << b << endl;
}


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

int main() {
int n,Y;
cin>>n>>Y;
for(int x=0;x<=n;x++){
  for(int y=0;y<=n-x;y++){
    int z=n-x-y;
    int sum=x*10000+y*5000+z*1000;
    if(sum==Y){
      cout<<x<<" "<<y<<" "<<z<<endl;
      return 0;
    }
  }
}
cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;
int N;
long long L,T;
long long Xs[100008];
int Sols[100008];
int Sols_sorted[100008];
vector<int> cw;
vector<int> ccw;
int cmp(const void *ka,const void *kb) {
	int a=*(int *)ka;
	int b=*(int *)kb;
	return a-b;
}
int main() {
	scanf("%d%lld%lld",&N,&L,&T);
	int cwccw=1;
	for(int i=0;i<N;i++) {
		int vb;
		scanf("%lld%d",&Xs[i],&vb);
		if(vb==1) {
			cw.push_back(i);
		} else {
			ccw.push_back(i);
		}
		if(i==0&&vb==2) cwccw=2;
		if(vb==1) {
			Sols[i]=(Xs[i]+T)%L;
		} else {
			Sols[i]=(L*T-T+Xs[i])%L;
		}
		Sols_sorted[i]=Sols[i];
	}
	qsort(Sols_sorted,N,sizeof(int),cmp);
	if(cw.size()==0||ccw.size()==0) {
		//corner
		int base;
		for(int i=0;i<N;i++) {
			if(Sols_sorted[i]==Sols[0]) base=i;
		}
		for(int i=base;i<N;i++) printf("%d\n",Sols_sorted[i]);
		for(int i=0;i<base;i++) printf("%d\n",Sols_sorted[i]);
		return 0;
	}
	long long minv=0;
	long long maxv=T*10;
	while(minv<maxv) {
		long long hf=(minv+maxv+1)/2;
		long long n_cw=(hf+1)/2;
		long long n_ccw=(hf+1)/2;
		if(hf%2==0) {
			if(cwccw==1) n_cw++;
			if(cwccw==2) n_ccw++;
		}
		long long cw_dist=0;
		long long ccw_dist=0;
		cw_dist+=(n_cw-1)/cw.size()*L;
		int rem=n_cw-(n_cw-1)/cw.size()*cw.size();
		if(cw[0]==0) {
			cw_dist+=(L-Xs[cw[(cw.size()-rem+1)%cw.size()]])%L;
		} else {
			cw_dist+=(L-Xs[cw[(cw.size()-rem)%cw.size()]])%L;
		}
		ccw_dist+=(n_ccw-1)/ccw.size()*L;
		rem=n_ccw-(n_ccw-1)/ccw.size()*ccw.size();
		ccw_dist+=Xs[ccw[rem-1]];
		//if(hf==1) printf("%lld %lld\n",cw_dist,ccw_dist);
		if(cw_dist+ccw_dist<=T*2) {
			minv=hf;
		} else {
			maxv=hf-1;
		}
	}
	//printf("%lld\n",minv);
	int base;
	long long n_cw=(minv+1)/2;
	long long n_ccw=(minv+1)/2;
	if(minv%2==0) {
		if(cwccw==1) n_cw++;
		if(cwccw==2) n_ccw++;
	}
	if(minv%2==1&cwccw==1||minv%2==0&cwccw==2) {
		//ccw
		int rem=n_ccw-(n_ccw-1)/ccw.size()*ccw.size();
		int id=ccw[rem-1];
		for(int i=N-1;i>=0;i--) {
			if(Sols_sorted[i]==Sols[id]) base=i;
		}
	} else {
		//cw
		int rem=n_cw-(n_cw-1)/cw.size()*cw.size();
		int id;
		if(cw[0]==0) {
			id=cw[(cw.size()-rem+1)%cw.size()];
		} else {
			id=cw[(cw.size()-rem)%cw.size()];
		}
		for(int i=0;i<N;i++) {
			if(Sols_sorted[i]==Sols[id]) base=i;
		}
	}
	for(int i=base;i<N;i++) printf("%d\n",Sols_sorted[i]);
	for(int i=0;i<base;i++) printf("%d\n",Sols_sorted[i]);
	return 0;
}


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

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

using namespace std;

int main(){
  int n;cin>>n;
  vector<int> p(n);
  rep(i, n){
    cin>>p[i];
    p[i]--;
  }

  vector<int> dp(n+1, 0);
  int max_c = 0;
  rep(i, n){
    int t=p[i];
    dp[t] = dp[t-1]+1;
    max_c = max(max_c, dp[t]);
  }

  cout<<n-max_c;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){

  string s;
  cin>>s;

  int ans=700;
  
  if(s[0]=='o'){
    ans+=100;
  }
  if(s[1]=='o'){
    ans+=100;
  }
  if(s[2]=='o'){
    ans+=100;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

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

    ll N, A, B; cin >> N >> A >> B;
    if (A >= N) cout << N;
    else {
        ll loop = N / (A+B);
        ll rem = N % (A+B);
        ll rst = loop * A;
        if (rem >= A) rst += A;
        else rst += rem;
        cout << rst;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  vector<vector<pii>> G(N);
  rep(i,N-1) {
    int u, v, w; cin >> u >> v >> w;
    u--, v--;
    G[u].push_back({v,w&1});
    G[v].push_back({u,w&1});
  }

  vector<int> c(N,-1);
  queue<int> q;
  q.push(0);
  c[0] = 0;
  while(!q.empty()){
    int now = q.front(); q.pop();
    for (auto e : G[now]){
      int n = e.first;
      int d = e.second;
      if (c[n]!=-1) continue; 
      c[n] = (c[now] + d)%2;
      q.push(n);
    }
  }
  rep(i,N) cout << c[i] << endl;
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 9552
#include <stdio.h>

int main(void)
{
	char array[11];
	int i, j;
	
	while (scanf("%s", array) != EOF){
		for (i = 8; i >= 0; i--){
			for (j = 0; j <= i; j++){
				array[j] = (array[j] + array[j+1] - ('0' * 2)) % 10 + '0';
			}
		}
		
		printf("%c\n", array[0]);
	}
	
	return (0);
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

int main(){
  string s;
  cin >> s;

  bool ans = true;
  int half=(s.size()-1)/2;

  // all
  for(int i=0; i<half; i++){
    if(s.at(i) != s.at(s.size()-i-1)) ans=false;
  }

  // left
  for(int i=0; i<half/2; i++){
    if(s.at(i) != s.at(half-i-1)) ans=false;
  }

  // right
  for(int i=half; i<(s.size()-1)/2; i++){
    if(s.at(i) != s.at(s.size()-i-1)) ans=false;
  }

  if(ans)  cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>

int count(int num[3], int x, int step){
  if(step>3){
      return 0;
  }
  
  int result = 0;
  int coin;
  if(step==0) coin = 500;
  if(step==1) coin = 100;
  if(step==2) coin = 50;
  
  for(int i=0; i<=num[step];i++){
    //for(int j=0;j<step;j++)
    //  std::cout <<" ";
    //std::cout << i << std::endl;
    int tmp = x-coin*i;
    if(tmp<0)
      break;
    else if(tmp==0){
      result++;
      break;
    }else{
      result += count(num,tmp,step+1);  
    }
  }
  return result;
}
 
int main(){
  int num[3], x;
  std::cin >> num[0]; std::cin >> num[1]; std::cin >> num[2]; std::cin >> x;
  
  int result = count(num,x,0);
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  long h, w;
  readf("%s %s\n", &h, &w);
  
  auto x = h * w;
  if (h == 1 || w == 1) {
    writeln(1);
  } else if (x % 2) {
    writeln(x/2+1);
  } else {
    writeln(x/2);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin >> N;
VS S; 
set<char> march{'M', 'A', 'R', 'C', 'H'};
vector<char> mvec{'M', 'A', 'R', 'C', 'H'};
map<char, int64_t> cntmarch;
for (char c:mvec) cntmarch[c] = 0;

rep(i, 0, N) {
    string s;  cin >> s;
    if (march.count(s[0])) ++cntmarch[s[0]];
}
if (cntmarch.size() < 3) {
    cout << "0\n";
    return 0;
}
int64_t cnt = 0;
rep(bit, 1, (1<<5))
    if (bitset<5>(bit).count() == 3){
        int64_t s = 1;
        rep(i, 0, 5)
            if (bit & (1<<i)) s *= cntmarch[mvec[i]];
        cnt += s;
    }

cout << cnt << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	if(n % 2 == 0) (n / 2 - 1).writeln;
	else (n / 2).writeln;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
#define ld long double
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define endl '\n'
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define mod 1000000007
#define MEM(a, b) memset(a, (b), sizeof(a))
#define addmod(a,b,mod) (a%mod + b%mod)%mod
#define submod(a,b,mod) (a%mod - b%mod + mod)%mod
#define N 1000000
const ld EPS = 10e-9;
const int MAX = 1e6;

int main(){
    ios_base:: sync_with_stdio(false); 
    cin.tie(0);
    
    ll a, b, k;
    cin >> a >> b >> k;
    (k >= a)? cout << 0 << " " << ((b - k + a > 0)? b - k + a : 0 ) : cout << a - k << " " << b;
    
    return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int n, m;
	cin >> n >> m;
	int graph[100][100] = {};
	int unused[100][100] = {};
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		graph[a][b] = c;
		graph[b][a] = c;
		unused[a][b] = 1;
		unused[b][a] = 1;
	}
	priority_queue<pair<int, pair<int, int> > > qu;
	for (int i = 0; i < n; i++) {
		// cout << i << endl;
		vector<int> minCost(n, MOD);
		qu.push(make_pair(0, make_pair(i, i)));
		while (!qu.empty()) {
			int prev = ((qu.top()).second).first;
			int now = ((qu.top()).second).second;
			int cost = -(qu.top()).first;
			qu.pop();
			if (cost > minCost[now]) continue;
			if (cost == minCost[now]) {
				unused[prev][now] = 0;
				unused[now][prev] = 0;
				continue;
			}
			// cout << "\t" << now << " " << cost << endl;
			minCost[now] = cost;
			unused[prev][now] = 0;
			unused[now][prev] = 0;
			for (int j = 0; j < n; j++) {
				if (graph[now][j] == 0) continue;
				int nextcost = cost + graph[now][j];
				if (nextcost < minCost[j]) {
					// cout << "\t\t" << j << endl;
					qu.push(make_pair(-nextcost, make_pair(now, j)));
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans += unused[i][j];
		}
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 384
import sys

n = int(input())
l = list(map(int, input().split(" ")))
dp= [0]*n
dp[1] = abs(l[1] - l[0])

for i in range(2, n):
	one = dp[i - 1] + abs(l[i] - l[i-1])
	two = dp[i - 2] + abs(l[i] - l[i-2])	
	dp[i] = min([one, two])

print(dp[n-1])

Measured memory_bytes: 13980
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define maxn 500010
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
ll a,b,v,w,t;
int main()
{
	 a=read(); v=read();
	 b=read(); w=read();
	 t=read();
	 if((v-w)*t<std::abs(a-b))puts("NO");
	 else puts("YES");
	 return 0;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
    int n;
    double ans = 0.0;
    cin >> n;

    REP(i,n){
        int a;
        cin >> a;
        ans += (1.0/a);
    }
    ans = 1/ans;
    
    printf("%.8f\n",ans);
}

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

#define fi first
#define se second
#define pb push_back
 
#define limit (int) (2e5 + 5) 
#define mod (long long int) (1e9 + 7)
 
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

int l[102];

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

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

    sort(l , l+n);

    int ans = 0;

    for (int i = 0; i < n; ++i)
    {
        for (int j = i+1; j < n; ++j)
        {
            for (int k = j+1; k < n; ++k)
            {
                if (l[j]==l[i] || l[j]==l[k])
                {
                    continue;
                }
                
                if (l[i]+l[j] > l[k])
                    ans++;
                else
                    break;
            }
        }
    }

    cout << ans;
    return 0;
}














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

int n, m, k;
int main () {
    while (scanf("%d %d %d", &n, &m, &k) == 3) {
        vector<int> a(n), b(m);
        for (auto &x : a) scanf("%d", &x);
        for (auto &x : b) scanf("%d", &x);

        long long sa = 0, sb = 0;
        int ia = 0, ib = 0;
        while (ia < n && sa + a[ia] <= k) sa += a[ia++];
        while (ib < m && sa + sb + b[ib] <= k) sb += b[ib++];
        int res = ia + ib;
        while (ia > 0) {
            sa -= a[ia - 1];
            ia--;
            while (ib < m && sa + sb + b[ib] <= k) sb += b[ib++];
            res = max(res, ia + ib);
        }

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



Measured memory_bytes: 4860
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <functional>
#include <map>
#include <numeric>
#include <random>
#include <vector>
#include <bitset>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	// エラトステネスのふるい
	int MAX = 101010;
	vector<int> is_prime(MAX, 1);
	is_prime[0] = 0, is_prime[1] = 0;
	for (int i = 2; i < MAX; ++i) {
		if (!is_prime[i]) {
			continue;
		}
		for (int j = i * 2; j < MAX; j += i) is_prime[j] = 0;
	}

	// 2017-like 数かどうか
	vector<int> a(MAX, 0);
	for (int i = 0; i < MAX; ++i) {
		if (i % 2 == 0) continue;
		if (is_prime[i] && is_prime[(i + 1) / 2]) a[i] = 1;
	}

	// 累積和
	vector<int> s(MAX + 1, 0);
	for (int i = 0; i < MAX; ++i) s[i + 1] = s[i] + a[i];

	// クエリ処理
	int Q; cin >> Q;
	for (int q = 0; q < Q; ++q) {
		int l, r;
		cin >> l >> r;
		++r;

		cout << s[r] - s[l] << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    ll X;
    cin >> X;
   ll Y = floor(X/100);
   ll Z = X%100;
   if(Y*5>=Z){
       cout << "1" << endl;
   }else{
       cout << "0" << endl;
   }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
	int A , P ;
	cin >> A >> P ;
	cout << (3*A + P ) / 2 << " " ;
	
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
template<class T> inline void chmin(T& a, T b) { if(a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if(a < b) a = b; }

int main(){
	int N;
	std::cin >> N;
	std::vector<int> d1(N), d2(N);
	bool ok = false;
	int cnt = 0;
	rep(i, N){
		int x, y;
		std::cin >> x >> y;
		if(x == y) cnt++;
		else cnt = 0;

		if(cnt == 3) ok = true;
	}
	if(ok){
		std::cout << "Yes" << std::endl;
	}else{
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

long long tab[51][51];

void comb(){
    for(int i=0; i<=50; i++){
        tab[i][0] = 1;
        tab[i][i] = 1;
    }

    for(int i=1; i<=50; i++){
        for(int j=1; j<i; j++){
            tab[i][j] = tab[i-1][j-1] + tab[i-1][j];
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, P;
    cin >> N >> P;
    int ev = 0, od = 0;
    for(int i=0; i<N; i++){
        int A;
        cin >> A;
        if(A % 2 == 0) ev++;
        else od++;
    }

    comb();

    long long ans = 1;
    for(int i=0; i<ev; i++) ans *= 2;
    long long tmp = 0;
    if(P == 0)
        for(int i=0; i<=od; i+=2) tmp += tab[od][i];
    else
        for(int i=1; i<=od; i+=2) tmp += tab[od][i];
    ans *= tmp;
    cout << ans << endl;
    return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    int n,m;
    cin>>n>>m;
    vector<ll> x(m);
    rep(i,0,m)cin>>x[i];
    if(n>=m){ cout<<0<<endl; return 0;}
    sort(x.begin(),x.end());
    
    vector<ll> diff(m-1);
    rep(i,0,m-1){
        diff[i]=abs(x[i+1]-x[i]);
    }
    sort(diff.begin(), diff.end());

    ll ans=0;
    rep(i,0,m-n){
        ans+=diff[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if (a%3==0||b%3==0||(a+b)%3==0) {
        cout<<"Possible"<<endl;
    } else {
        cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 256
def main():
    N = [int(_) for _ in input().split()]
    A = N[0]
    B = N[1]
    C = N[2]

    tmp = B
    B = A
    A = tmp

    tmp = C
    C = A
    A = tmp

    print(A, B ,C)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,t;
	while(cin>>n,n){
		int c[10];fill(c,c+10,0);
		for(int i=0;i<n;i++)cin>>t,c[t]++;
		for(int i=0;i<10;i++){if(!c[i])cout<<'-';else for(int j=0;j<c[i];j++)cout<<'*';cout<<endl;}
	}
}

Measured memory_bytes: 1152
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val mod = 1000000007L
  println(
    calPattern(readLine.trim, readLine.trim)
  )
  def calPattern(stone: String, voodoo: String): Long = {
    val result = Array.tabulate(voodoo.length + 1){ _ ⇒ 0L}.also{ arr ⇒ arr(0) = 1L}
    for (c ← stone){
      for (i ← voodoo.indices.reverse){
        if (c == voodoo(i)){
          result(i + 1) += result(i)
          result(i + 1) %= mod
        }
      }
    }
    result.last
  }
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
/*


 */


Measured memory_bytes: 44480
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int x, y, w, h, n, m;
    int[] cx, cy;
    int i, j, count;

    m = sc.nextInt();

    for(i = 0;i < m;i++){
      x = sc.nextInt();
      y = sc.nextInt();
      w = sc.nextInt();
      h = sc.nextInt();
      n = sc.nextInt();
      count = 0;
      cx = new int[n];
      cy = new int[n];      

      for(j = 0;j < n;j++){
        cx[j] = sc.nextInt();
        cy[j] = sc.nextInt();
      }

      for(j = 0;j < n;j++){
        if(x <= cx[j] && cx[j] <= (x + w) && y <= cy[j] && cy[j] <= (y + h)){
          count++;
        }
      }

      System.out.println(count);
    }

    sc.close();

  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 24656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;  //文字列型変数ｓ

            s = Console.ReadLine();　　//キーボードから文字列を読み込む

            char[] cs = s.ToCharArray();  //char型配列に変換する

            cs[3] = '8';　　//4番目の文字を8に書き換える

            Console.WriteLine(cs);　　//結果を表示する

            Console.ReadKey();  //キー入力待ち


        }
    }
}


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

N,X = map(int,input().split())
x = list(map(int,input().split()))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

length = []

for i in range(N):
    length.append(abs(x[i] - X))

ans = length[0]

for i in range(1,N):
    ans = gcd(ans,length[i])

print(ans)


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

#define println(msg) cout << msg << endl
#define yes_or_no(flag) if (flag) { println("Yes"); } else { println("No"); }

int main() {
  // 入力
  int N, K;
  cin >> N >> K;

  // 計算
  int count = 0;
  int n = N;
  while (n > 0) {
    int k = (n % K);
    n /= K;
    count ++;
  }
  
  // 出力
  println(count);
}


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

typedef long long LL;

int main () {
	int n;
	cin >> n;
	if (n%2==0) {
		cout<<n<<' '<<n<<' '<<n/2<<endl;
	}
	else {
		for (LL i=1;3500>=i;i++) {
			for (LL j=1;3500>=j;j++) {
				LL k=i*j/(4*i*j*1.0/n-i-j);
				if (k<0) continue;
				if (4*i*j*k/n == i*j + j*k + i*k) {
					cout<<i<<' '<<j<<' '<<k<<endl;
					return 0;
				}
			}
		}
	}
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N=scan.nextInt();
		int[] a = new int[N];
		int cnt =0;
		boolean[] used = new boolean[8];

		for(int i=0;i<N;i++){
			a[i]=scan.nextInt();
			if(a[i]>=3200){
				cnt++;
			}else{
				used[a[i]/400]=true;
			}
		}


		int max=0;
		int min=0;
		for(int i=0;i<8;i++){
			if(used[i]){
				max++;
				min++;
			}
		}
//		max = Math.min(8, max+cnt);
		max = max+cnt;
		min = Math.max(1, min);
		System.out.println(min+" "+max);
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; 
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int res = 0;
    while(1){
        //for each height
        if(*max_element(ALL(h)) == 0) break;
        int i = 0;
        while(i < n){
            if(h[i] == 0) i++;
            else{
                res++;
                while(i < n && h[i] > 0){
                    --h[i];
                    i++;
                }
            }
        }
    }
    cout << res << endl;
}

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

int main()
{
	long long int Q, H, S, D, N, ans;

	cin >> Q >> H >> S >> D >> N;

	Q *= 4;
	H *= 2;

	ans = min({ Q, H, S })*N;

	if (N % 2 != 0 && N / 2 * D + min({ Q,H,S }) < ans) {
		ans = N / 2 * D + min({ Q,H,S });
	}
	else if (N % 2 == 0 && N / 2 * D < ans)ans = N / 2 * D;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
Imports System.Console
Module Module1
    Dim w As Int64
    Dim ii, iii As Int64
    Dim ans As Int64
    Dim md As Int64 = (10 ^ 9) + 7
    Dim max, min As Int64
    Dim n, k, x, t, d As Int64
    Sub Main()
        n = ReadLine()
        Dim s() As String = ReadLine().Split
        Dim a(n) As Integer
        For i = 1 To n
            a(i) = s(i - 1)
        Next
        Dim asum As Int64
        For i = 1 To n
            asum += a(i)
            asum = asum Mod md
        Next
        w = asum
        For i = 1 To n - 1
            'w = 0
            'For ii = i + 1 To n
            '    w += a(ii)
            '    w = w Mod md
            'Next
            w -= a(i)
            If w < 0 Then
                w += md
            End If
            ans += (w * a(i)) Mod md
            'ii = 0
            'Dim ww As Int64 = a(i) * (10 ^ 2)
            'Dim www As Int64
            'For ii = 1 To w \ (10 ^ 2)
            '    www += ww
            '    www = www Mod md
            'Next
            'www += (a(i) * (w Mod (10 ^ 2)))
            'www = www Mod md
            'ans += www
            ans = ans Mod md
        Next
        WriteLine(ans)
        ReadLine()
    End Sub
    Sub Add(ByRef arr() As Integer, ByVal num As Integer)
        If arr Is Nothing Then
            ReDim arr(0)
            arr(0) = num
        Else
            ReDim Preserve arr(arr.Length)
            arr(arr.Length - 1) = num
        End If
    End Sub
End Module


Measured memory_bytes: 46880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll k, x;
  cin >> k >> x;
  if (500 * k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,memo[50][26];
string s,ans;

main() {
    cin >> n;
    rep(i,n) {
        cin >> s;
        rep(j,s.size()) {
            memo[i][s[j]-'a']++;
        }
    }
    rep(j,26) {
        int cnt=3000;
        rep(i,n) cnt = min(cnt,memo[i][j]);
        rep(i,cnt) ans.pb((char)('a'+j))
    }
    sort(all(ans));
    rep(i,ans.size()) cout << ans[i];
    cout << endl;
}




Measured memory_bytes: 256
n,t[999];int main(i){
	for(;n*=scanf("%d",&n);puts("")){bzero(t,999*4);
	for(;n--;t[i]=*t)scanf(" %c %c",&i,t);
	for(scanf("%d",&n);n--;putchar(!t[i]*i+t[i]))scanf(" %c",&i);
	}
return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,r;
    Scd2(N,r);
    printf ("%d\n", r-min(0,-1000+100*N));

    return 0;
}



Measured memory_bytes: 256
N = gets.to_i
x =[]
5.times {
  x << gets.to_i
}
ind = 0
x.each_with_index { |v,i|
  if x[ind] > v
    ind = i
  end
}

def dceil(x,y)
  return (x + y - 1) / y
end
p dceil(N,x[ind]) + 4

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int, int>;
using LL = long long;
vector<int> G[100005];
int deg[100005], depth[100005];
vector<PII> edges;
void dfs(int from, int id) {
	depth[id] = depth[from] + 1;
	int x = 0;
	for (auto x: G[id]) {
		if (depth[x] == -1) {
			dfs(id, x);
		} else {
			if (depth[x] > depth[id]) {
				edges.emplace_back(id, x);
				deg[id]++;
			}
		}
	}
	if (deg[id] % 2) {
		if (from != 0) {
			edges.emplace_back(id, from);
			deg[id]++;
		}
	} else {
		if (from != 0) {
			edges.emplace_back(from, id);
			deg[from]++;
		}
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i <= n; i++) depth[i] = -1;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if (m % 2 == 1) {
		cout << "-1\n";
		return 0;
	}
	dfs(0, 1);
	for (auto p: edges) {
		cout << p.first << ' ' << p.second << '\n';
	}
	return 0;
}


Measured memory_bytes: 14836
//39
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int w,h;
    cin>>w>>h;
    int g[100][100]={{}};
    while(n--){
      int x,y;
      cin>>x>>y;
      g[y][x]=1;
    }
    int s,t;
    cin>>s>>t;
    int m=0;
    for(int i=1;i<=w-s+1;i++){
      for(int j=1;j<=h-t+1;j++){
	int f=0;
	for(int k=0;k<s;k++){
	  for(int l=0;l<t;l++){
	    f+=g[j+l][i+k];
	  }
	}
	if(m<f){
	  m=f;
	}
      }
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2e5+7;
//const int MAXN = 1e3+7;

int X[MAXN], Y[MAXN];
int idX[MAXN];

int p[MAXN], q[MAXN];
int bam[MAXN], dan[MAXN];
int n;

int durotto(int i, int j) {
    i = idX[i];
    j = idX[j];
    return abs(X[i]-X[j])+abs(Y[i]-Y[j]);
}

int counter;
map< int , LL >dp[2][MAXN];
LL solve(int l, int r, bool side, int mn, int mx) {
    auto it = dp[side][l].find(r);
    if (it != dp[side][l].end()) return it->second;

    vector< LL >options;
    if (l > 1 && (p[l-1]==mn-1||p[l-1]==mx+1)) {
        LL tmp = solve(bam[l-1], r, false, min(mn, p[bam[l-1]]), max(mx, p[bam[l-1]]));
        tmp += (side ? durotto(bam[l-1], r) : durotto(bam[l-1], l));
        options.push_back(tmp);
    }
    if (r < n && (p[r+1]==mn-1||p[r+1]==mx+1)) {
        LL tmp = solve(l, dan[r+1], true, min(mn, p[dan[r+1]]), max(mx, p[dan[r+1]]));
        tmp += (side ? durotto(r, dan[r+1]) : durotto(l, dan[r+1]));
        options.push_back(tmp);
    }
    LL ans = l-r;
    if (options.size() >= 1) {
        ans = options.front();
        if (options.size() >= 2) {
            ans = min(ans, options[1]);
        }
    }
    counter++;
    return dp[side][l][r] = ans;
}

LL ans[MAXN];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    vector< int >idY(n, 0);
    for (int i = 1; i <= n; i++) {
        cin >> X[i] >> Y[i];
        idX[i] = i;
        idY[i-1] = i;
    }

    sort(idX+1, idX+n+1, [&](int i, int j) {
        return X[i] < X[j];
    });
    sort(idY.begin(), idY.end(), [&](int i, int j) {
        return Y[i] < Y[j];
    });
    for (int i = 0; i < n; i++) {
        q[idY[i]] = i+1;
    }
    for (int i = 1; i <= n; i++) {
        p[i] = q[idX[i]];
    }

    bam[1] = 1;
    for (int i = 2; i <= n; i++) {
        bam[i] = i;
        if (abs(p[i]-p[i-1])==1) bam[i] = bam[i-1];
    }
    dan[n] = n;
    for (int i = n-1; i > 0; i--) {
        dan[i] = i;
        if (abs(p[i]-p[i+1])==1) dan[i] = dan[i+1];
    }

    for (int i = 1; i <= n; i++) {
        ans[idX[i]] = solve(i, i, false, p[i], p[i]);
    }

//    cout << "counter: " << counter << endl;
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 82016
package main

import (
	"fmt"
)

func main() {
	var n, m int

	fmt.Scan(&n, &m)

	a := makeMatrix(n, m)
	b := makeMatrix(m, 1)
	c := makeMatrix(n, 1)

	for i := range a {
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}

	for i := range b {
		fmt.Scan(&b[i][0])
	}

	for i := range c {
		tmp := 0
		for j := range b {
			tmp += a[i][j] * b[j][0]
		}
		c[i][0] = tmp
	}

	for i := range c {
		fmt.Println(c[i][0])
	}
}

func makeMatrix(n, m int) (a [][]int) {
	a = make([][]int, n)

	for i := range a {
		a[i] = make([]int, m)
	}

	return
}



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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, 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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll s; cin>>s;
  ll v=1e9;
  if(s<v*v){
    ll x=v-s%v;
    ll y=(s+x)/v;
    cout<<0<<" "<<0<<" "<<v<<" "<<1<<" "<<x<<" "<<y<<endl;
  }else{
    cout<<0<<" "<<0<<" "<<v<<" "<<0<<" "<<0<<" "<<v<<endl;
  }
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n,m; cin >>n >>m;
  vector<int> wa(n,0),ac(n,0);
  int cnt_ac=0,cnt_wa=0;
  rep(i,m){
    int p; cin >>p; p--;
    string str; cin >>str;
    if(ac.at(p))continue;
    if(str=="WA"){
      wa.at(p)++;
    }else{
      ac.at(p)++;
      cnt_ac++;
      cnt_wa+=wa.at(p);
    }
  }
  printf("%d %d",cnt_ac,cnt_wa);
}

/// confirm df==0 ///


Measured memory_bytes: 1024
#include <string>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>

using namespace std;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

bool solve(vector<char>& s,int sz){
	if(sz == 0) return true;
	for (int i = 1; i <= 9; i++){
		int cnt = s[i];
		if(cnt >= 2){
			if(sz % 3 == 2){
				s[i] -= 2;
				if(solve(s,sz - 2)) return true;
				s[i] += 2;
			}
		}
		if(cnt >= 3){
				s[i] -= 3;
				if(solve(s,sz - 3)) return true;
				s[i] += 3;
		}
		if(i <= 7 && s[i] > 0 && s[i+1] > 0 && s[i+2] > 0){
			s[i]--; s[i+1]--; s[i+2]--;
			if(solve(s,sz - 3)) return true;
			s[i]++; s[i+1]++; s[i+2]++;
		}
	}

	return false;
}

int main()
{
	string s;
	while(cin>>s){
		vector<char> sv(10);
		for (int i = 0; i < (int)s.length(); i++) sv[s[i]-'0']++;
		vector<char> ans;
		for (int i = 1; i <= 9; i++){
			if(sv[i] == 4) continue;
			vector<char> arg(sv);
			arg[i]++;
			if(solve(arg,14))
				ans.push_back(i);
		}
		if(ans.empty())
			puts("0");
		else 
			for (int i = 0; i < (int)ans.size(); i++){
				printf("%c%c",ans[i] + '0' ,i == (int)ans.size()-1 ? '\n' : ' ');
			}
	}

}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

bool intersecting(pii a, pii b) {
	bool p = a.se < b.fi;
	bool q = b.se < a.fi;
	return !p and !q;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

	int n, m;
	cin >> n >> m;

	bool bad = 0;
	pii p = {1, N};
	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		pii q = {l, r};
		if (!intersecting(p, q)) {
			bad = 1;
		}
		p = {max(p.fi, q.fi), min(p.se, q.se)};
	}

	if (bad) {
		cout << "0\n";
	} else {
		cout << p.se - p.fi + 1 << "\n";
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;



int main() {
	int n;
	cin >> n;
	lint* d = new lint[n];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	
	lint sum = 0;
	for (int i = 0; i < n-1; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += d[i] * d[j];
		}
	}

	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 256
while 1:
    try:
        s=input()
        if s[0]==s[1]==s[2]!="s":
            print(s[0])
        elif s[3]==s[4]==s[5]!="s":
            print(s[3])
        elif s[6]==s[7]==s[8]!="s":
            print(s[6])
        elif s[0]==s[3]==s[6]!="s":
            print(s[0])
        elif s[1]==s[4]==s[7]!="s":
            print(s[1])
        elif s[2]==s[5]==s[8]!="s":
            print(s[2])
        elif s[0]==s[4]==s[8]!="s":
            print(s[0])
        elif s[2]==s[4]==s[6]!="s":
            print(s[2])
        else:
            print("d")
    except:break


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

using namespace std;

int main()
{
#define S_MAX	3000
#define T_MAX	3000

	static int dp[S_MAX + 1][T_MAX + 1] = {0};
	string s, t, r;
	int slen, tlen;
	int i, j;

	cin >> s >> t;
	slen = s.length();
	tlen = t.length();
	for (i = 0; i < slen; i++) {
		for (j = 0; j < tlen; j++) {
			if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
			else              dp[i + 1][j + 1] = max(dp[i+1][j], dp[i][j+1]);
		}
	}
	r = "";
	i = slen;
	j = tlen;
	while ((dp[i][j] > 0) && (i > 0) && (j > 0)) {
		if (s[i - 1] == t[j - 1]) r = s[i - 1] + r;
		else if (dp[i - 1][j] == (dp[i][j] - 1)) i++;
		else if (dp[i][j - 1] == (dp[i][j] - 1)) j++;
		else if (dp[i][j - 1] == (dp[i][j])) j++;
		i--;
		j--;
	}
	cout << r;
    
	return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1<<29;
/****** define constant end ********/


/****** define variable start ******/
string s;
/******* define variable end *******/
ll solve() {
    cin >> s;
    if(s.substr(0, 1) == s.substr(1, 1) && s.substr(1,1) == s.substr(2, 1)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    
    return (int)end_solve;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	string s;
	cin >> s;
	deque<char> dq;
	rep(i,s.size()) {
		dq.push_back(s[i]);
	}
	int q;
	cin >> q;

	int sw = 0;
	rep(i,q) {
		int t;
		cin >> t;
		if (t == 1) {
			sw = 1 - sw;
		} else {
			int f;
			char c;
			cin >> f >> c;
			if (sw == 0) {
				if (f == 1) dq.push_front(c);
				else dq.push_back(c);
			} else {
				if (f == 2) dq.push_front(c);
				else dq.push_back(c);
			}
		}
	}
	string ans = "";
	if (sw == 0) {
		while(!dq.empty()) {
			char c = dq.front(); dq.pop_front();
			ans += c;
		}
	} else {
		while(!dq.empty()) {
			char c = dq.back(); dq.pop_back();
			ans += c;
		}
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

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

typedef long long ll;

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n =0;
    cin >> n;


    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += (i * ((n/i) * (n/i + 1))/2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  cout << (n + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    ll N, K;
    cin>>N>>K;
    ll Keta=0;
    while(N>0){
        Keta++;
        N/=K;
    }
    cout<<Keta<<endl;
}

Measured memory_bytes: 256