akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;
vector<int> v(5);
int calc(int x){
  return (x%10==0)?0:(10-x%10);
}

int main(void) {

  int x=1000*5;
  for(int i=0; i<5; i++)
    cin>>v[i];
  for(int i=0; i<5; i++) {
    for(int j=0; j<5; j++) {
      if(j==i) continue;
      for(int k=0; k<5; k++) {
	if(i==k or j==k) continue;
	for(int n=0; n<5; n++) {
	  if(i==n or j==n or k==n) continue;
	  for(int m=0; m<5; m++) {
	    if(i==m or j==m or k==m or n==m) continue;
	    int y = v[i]+calc(v[i])+v[j]+calc(v[j])+v[k]+calc(v[k])+v[n]+calc(v[n])+v[m];
	    x = min(x, y);
	  }
	}
      }
    }
  }
  std::cout << x << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

int main(){
    int q;
    cin >> q;
    ll s0=0,s1=0;
    priority_queue<ll> left;
    priority_queue<ll,vector<ll>,greater<>> right;

    left.push(-INF);
    right.push(INF);
        
    for(int i = 0;i < q;i ++){
        int que;
        cin >> que;
        if(que==1){
            ll a,b;
            cin >> a >> b;
            s1 += b;

            if(left.size()==right.size()){ 
                if(a<left.top() || a>right.top())
                    s0 += min(abs(left.top()-a),abs(a-right.top()));
            }else{
                s0 += abs(left.top()-a);
            }

            if(a>=right.top()) right.push(a);
            else left.push(a);

            if(right.size()>left.size()){
                left.push(right.top());
                right.pop();
            }else if(left.size()>right.size()+1){
                right.push(left.top());
                left.pop();
            }
        }else{
            cout << left.top() << " " << s0 + s1 << endl;
        }
    }
    return 0;
}

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

const int N=1e5+5;
int n,m,q;
long long a[N],b[N],c;

void init()
{
	int i;
	scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=n;++i) scanf("%lld",&a[i]);
	for(i=1;i<=m;++i) scanf("%lld",&b[i]);
	a[0]=b[0]=-1e12;a[n+1]=b[m+1]=1e12;
}

long long fimin(long long pos,long long *A,int mx)
{
	int l=0,r=mx+1;
	while(l<r)
	{
		int mid=(l+r+1)>>1;
		if(A[mid]<=pos) l=mid;
		else r=mid-1;
	}
	return A[l];
}
long long fimax(long long pos,long long *A,int mx)
{
	int l=0,r=mx+1;
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(A[mid]>=pos) r=mid;
		else l=mid+1;
	}
	return A[l];
}

void work()
{
	while(q--)
	{
		scanf("%lld",&c);
		long long ans=1e15;
		long long wpos=fimin(c,a,n),epos=fimax(c,a,n);
		long long WPOS=fimin(c,b,m),EPOS=fimax(c,b,m);
		
		ans=min(ans,c-min(wpos,WPOS));
		ans=min(ans,(c-wpos)*2+EPOS-c);
		ans=min(ans,c-wpos+(EPOS-c)*2);
		ans=min(ans,(c-WPOS)*2+epos-c);
		ans=min(ans,c-WPOS+(epos-c)*2);
		ans=min(ans,max(epos,EPOS)-c);
		
		printf("%lld\n",ans);
	}
}

int main()
{
	init();work();
	return 0;
}

Measured memory_bytes: 2816
import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    N, L = inputs()
    apple = range(L, N + L)
    apple = np.array(apple)
    apple = np.delete(apple, np.argmin(np.abs(apple)))
    return sum(apple)


if __name__ == '__main__':
    print(main())


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

int main ()
{
    double n,m,d;
    cin >> n >>m >> d;
    if (d == 0) cout << fixed << setprecision(12) << (m-1)*(n-d)/n/n << endl;
    else cout << fixed << setprecision(12) << (m-1)*2*(n-d)/n/n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n;
	cin>>n;
	ll seq[n+1];
	ll sum = 0;
	for(int i=1;i<=n;i++){
		cin>>seq[i];
		seq[i]-=i;
		sum += abs(seq[i]);
	}
	sort(seq+1,seq+n+1);
	//cout<<avg<<endl;
	ll final1=0,avg;
	avg = seq[n/2+1];
	for(int i=1;i<=n;i++){
		final1 += abs(seq[i]-avg);
	}

	cout<<final1<<"\n";
	
	return 0;
	//cout<<avg<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<string>W(N);
    set<string>Set;
    for(int i = 0; i < N; i++) { 
        cin >> W[i];
        Set.insert(W[i]);
    }
    if(Set.size() != N) {
        cout << "No" << endl;
        return 0;
    }
    char usiro = W[0][W[0].size()-1];
    for(int i = 1; i < N; i++) {
        if(usiro != W[i][0]) {
            cout << "No" << endl;
            return 0;
        }
        usiro = W[i][W[i].size()-1];
    }
    cout << "Yes" << endl;
}

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

void solve(){	
	
	int n ;
	cin>>n ;

	vector<int> v(n) ;

	rep(i,n){
		cin>>v[i] ;
	}	

	unordered_map<int,int> mp ;

	rep(i,n){
		if(mp[v[i]]==1){
			cout<<"NO" ;
			return ;
		}
		mp[v[i]]=1 ;

	}

	cout<<"YES" ;
}


int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;0

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 12052
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll a, b, x;
    cin>>a>>b>>x;
    ll ans = b/x-(a-1)/x;
    if(a == 0){
        ans = b/x+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int n,k;
    int sum = 0;
    cin >>n >> k;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    REP(i,k) sum += a[i];
    println(sum);
    return 0;
}

Measured memory_bytes: 3600
n=int(input())
dp=[[0]*(3) for i in range(n)]
a,b,c=map(int,input().split())
dp[0][0]=a
dp[0][1]=b
dp[0][2]=c
for i in range(1,n):
    a,b,c=map(int,input().split())
    dp[i][0]+=max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1]+=max(dp[i-1][2],dp[i-1][0])+b
    dp[i][2]+=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))
    
    

Measured memory_bytes: 60268
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k; ci(n>>k);
  vll A(200000);
  vll B(200000);
  FOR(i,0,n){
    ll a;
      ci(a)
    A[a-1]++;
    B[a-1]=1;
  }
  SORT(A);
  ll count=0;
  FOR(i,0,200000){
    count+=B[i];
  }
  ll ans=0;
  FOR(i,0,200000){
    if(count<=k){
      co(ans)
        break;
    }
    else if(A[i]!=0){
      ans+=A[i];
      count--;
    }
  }
}

Measured memory_bytes: 3328
t1,n1 = map(int,input().split())
t2,n2 = map(int,input().split())
t3,n3 = map(int,input().split())
t4,n4 = map(int,input().split())
ti = [t1,t2,t3,t4,0]
ni = [n1,n2,n3,n4,0]
i = 0
while ti[i] != 0:
    if ti[i] == 1:
        print(ni[i]*6000)
    elif ti[i] == 2:
        print(ni[i]*4000)
    elif ti[i] == 3:
        print(ni[i]*3000)
    else:
        print(ni[i]*2000)
    i += 1



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

int n;
int l[222];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n << 1; ++i) scanf("%d", l + i);
    sort(l + 1, l + 2 * n + 1);
    int cnt = 0;
    for (int i = 1; i <= 2 * n; i += 2) cnt += min(l[i], l[i + 1]);
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
from bisect import bisect_right

n = int(input().strip())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for elem in b:
    idx_c = bisect_right(c, elem)
    rep = (n - idx_c)
    idx_a = bisect_left(a, elem)
    ans += rep * idx_a
print(ans)


Measured memory_bytes: 105572
import math

n = int(input())
x_min = int(n/1.08)
x_max = int((n+1)//1.08+1)

ans = 0
for i in range(x_min, x_max+1):
  if math.floor(i*1.08) == n:
    ans=i
    print(i)
    break

if ans==0:
  print(':(')

Measured memory_bytes: 3060
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) for(auto &i:vec)fprintf(stderr,"%ld ",i);puts("");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

struct UnionFind {
        using ll = int_fast64_t;
        std::vector<ll> data;

        UnionFind(ll size): data(size){
                for(ll i=0; i<size; i++) data[i] = -1;
        }

        ll root(ll x){
                if(data[x]<0) return x;
                return data[x] = root(data[x]);
        }

        void unite(ll x, ll y){
                x = root(x);
                y = root(y);
                if(x==y) return;

                if(data[x]<data[y]){
                        data[x] += data[y];
                        data[y] = x;
                }else{
                        data[y] += data[x];
                        data[x] = y;
                }
        }

        bool find(ll x, ll y){
                return root(x)==root(y);
        }
};

int main(){
	ll n, m;
	scanf("%ld %ld", &n, &m);
	V a(n);
	scan(a);
	
	UnionFind uf(n*2);
	rep(i, 0, n) uf.unite(i, n+a[i]-1);
	rep(i, 0, m){
		ll x, y;
		scanf("%ld %ld", &x, &y);
		uf.unite(x-1, y-1);
	}
	ll ans = 0;
	rep(i, 0, n){
		if(uf.find(i, n+i)) ans++;
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> v(h);
  REP(i, h) cin >> v[i];

  vvi ans(h, vi(w, -1));
  int cnt = 1;
  REP(i, h) {
    bool f = false;
    REP(j, w) if (v[i][j] == '#') f = true;
    if (!f)
      continue;
    vi pos;
    REP(j, w) {
      if (v[i][j] == '#') {
        pos.push_back(j);
      }
    }

    pos.push_back(w);
    REP(j, pos[0]) { ans[i][j] = cnt; }
    REP(j, pos.size() - 1) {
      FOR(k, pos[j], pos[j + 1]) { ans[i][k] = cnt; }
      cnt++;
    }
  }
  FOR(i,1, h) {

    bool f = false;
    REP(j, w) if (v[i][j] == '#') f = true;
    if (f)continue;
    REP(j, w)ans[i][j] = ans[i - 1][j];
  }
  RREP(i, h - 1) {

    bool f = false;
    REP(j, w) if (v[i][j] == '#') f = true;
    if (f)continue;
    REP(j, w)ans[i][j] = ans[i + 1][j];
  }
  REP(i, h) {
    REP(j, w)cout << ans[i][j] << " ";
    cout << endl;
  }
}


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

typedef long long ll;
const int N = 1000054, mod = 1000000007;

int n;
int f[N];
ll F[N];

int main() {
	int i; ll t;
    scanf("%d", &n), t = (n - 1ll) * (n - 1ll) % mod;
    for (F[n] = f[n] = n, i = n - 1; i; --i)
    	f[i] = (f[i + 1] + t + i + (i != n - 1) + F[i + 3]) % mod,
    	F[i] = F[i + 1] + f[i];
    printf("%d\n", f[1]);
    return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int h,w,k;
    cin>>h>>w>>k;
    char c[h][w];
    rep(i,h){
        rep(j,w) cin>>c[i][j];
    }
    int ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int cnt=0;
            rep(l,h){
                if(i&(1<<l)) continue;
                rep(m,w){
                    if(j&(1<<m)) continue;
                    if(c[l][m]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

void solve() {
    LL h,w,k;
    cin >> h >> w >> k;
    VLL x(2), y(2);
    REP(i,0,2) cin >> x[i] >> y[i];
    REP(i,0,2) {
        --x[i];
        --y[i];
    }
    VS a(h);
    REP(i,0,h) cin >> a[i];
    priority_queue<pair<int,PII>, vector<pair<int,PII>>, greater<pair<int,PII>>> q;
    q.emplace(0,MP(x[0],y[0]));
    VVI d(h,VI(w,1<<30));
    while (!q.empty()) {
        auto p = q.top();
        q.pop();
        int dis = p.first, px = p.second.first, py = p.second.second;
        if (d[px][py] < dis) continue;
        REP(i,0,4) {
            REP(j,1,k+1) {
                int nx = px + dx[i] * j;
                int ny = py + dy[i] * j;
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) break;
                if (a[nx][ny] == '@') break;
                if (d[nx][ny] < dis+1) break;
                if (d[nx][ny] <= dis+1) continue;
                d[nx][ny] = dis + 1;
                q.emplace(dis+1,MP(nx,ny));
            }
        }
    }
    if (d[x[1]][y[1]] == 1<<30) cout << -1 << endl;
    else cout << d[x[1]][y[1]] << endl;
}

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

Measured memory_bytes: 12060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int N, W; cin >> N >> W;
	vector<pair<int, int>>vec(N);
	rep(i, 0, N) {
		int a, b; cin >> a >> b;
		vec[i] = { a,b };
	}
	vector<vector<int>>dp(N + 1, vector<int>(W + 1, 0));
	rep(i, 0, W + 1)dp[0][i] = 0;
	rep(i, 0, N) {
		rep(j, 0, W + 1) {
			chmax(dp[i + 1][j], dp[i][j]);
			if (!(j + vec[i].second > W))chmax(dp[i + 1][j + vec[i].second], dp[i][j] + vec[i].first);
		}
	}
	int ans = 0;
	rep(i, 0, W + 1)chmax(ans, dp[N][i]);
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 6848
s=input();q=int(input());r,a=0,[[],[]]
for _ in range(q):
  t=input()
  if t=='1':r=-(-~r%2)
  else:a[~-r+int(t[2])].append(t[4])
print(''.join(a[~-r+1][::-1])+s[::r or 1]+''.join(a[~-r+2]))

Measured memory_bytes: 6252
using System;
class P
{
public static void Main()
{
            //????????????????????????
            string x = Console.ReadLine();
            var split = x.Split(' ');

            int a = Int32.Parse(split[0]);
            int b = Int32.Parse(split[1]);

            //??¢???
            int S = a * b;
            //??¨???
            int L = 2 * a + 2 * b;

            //??????
            Console.WriteLine(S + " " + L);
}
}

Measured memory_bytes: 9160
import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int i = 1;
        while(sc.hasNext()){
            int x = sc.nextInt();
            if(x == 0)
                System.out.println(i);
            i++;
        }

    }
}


Measured memory_bytes: 27008
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    String B = sc.next();
    String C = sc.next();
    if (A.charAt(A.length()-1) == B.charAt(0) && B.charAt(B.length()-1) == C.charAt(0)){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
  }
}

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

int main()
{
  int n, m;
  int ans = 0;
  ll k, tmp;
  vector<ll> a;
  vector<ll> b;
  a.push_back(0);
  b.push_back(0);

  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> tmp;
    a.push_back(a[i - 1] + tmp);
  }
  for (int i = 1; i <= m; i++) {
    cin >> tmp;
    b.push_back(b[i - 1] + tmp);
  }

  for (int i = 0; i <= n; i++) {
    ll res = k - a[i];
    if (res < 0) break;
    else if (res == 0) {
      ans = max(ans, i);
      break;
    }
    int bmax = upper_bound(b.begin(), b.end(), res) - b.begin() - 1;
    ans = max(ans, i + bmax);
  }
  cout << ans << endl;

  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
int P, Q, R;
int main(){
    scanf("%d%d%d", &P,&Q,&R);
    int m = P + Q+R;
    if(P<Q){
        P=Q;
    }
    if(P<R){
        P = R;
    }
    printf("%d", m - P);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n,a,b,c;
	a=read(),b=read(),c=read();
	int Max=max(a,max(b,c));
	int val=Max*3-a-b-c;
	if(val%2==0)printf("%d\n",val/2);
	else printf("%d\n",val/2+2);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>
#include <queue>

using namespace std;

int H, W, N;
char c[1010][1010];
int d[1010][1010];
bool check = false;
using P = pair<int, int>;

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

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

    vector<int> sy(N+1);
    vector<int> sx(N+1);
    for(int i = 0; i < H; ++i) for(int j = 0; j < W; ++j){
        cin >> c[i][j];
        if(c[i][j] == 'S'){
            sx[0] = j;
            sy[0] = i;
        }
        if('0' <= c[i][j] && c[i][j] <= '9'){
            int po = int(c[i][j] - '0');
            sx[po] = j;
            sy[po] = i;
        }
    }

    int ans = 0;
    for(int k = 0; k < N; ++k){
        for(int i = 0; i < H; ++i) for(int j = 0; j < W; ++j){
            d[i][j] = 0;
        }

        queue<P> que;
        que.push(P(sx[k], sy[k]));
        while(!que.empty()){
            P p = que.front();
            que.pop();

            for(int i = 0; i < 4; ++i){
                int nx = p.first + dx[i];
                int ny = p.second + dy[i];
                if(0 <= nx && nx < W && 0 <= ny && ny < H && c[ny][nx] != 'X' && d[ny][nx] == 0){
                    d[ny][nx] = d[p.second][p.first] + 1;
                    que.push(P(nx, ny));
                }
                if(nx == sx[k+1] && ny == sy[k+1]){
                    break;
                }
            }
        }
        ans += d[sy[k+1]][sx[k+1]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 7960
def solve(N, K, heights):
  dp = [0] * N
  for i in range(1, N):
    min_cost = float('inf')
    for k in range(max(0, i - K), i):
      # min_cost = min(min_cost, dp[k] + abs(heights[i] - heights[k]))
      temp = dp[k] + abs(heights[i] - heights[k])
      if temp < min_cost:
        min_cost = temp
    dp[i] = min_cost
  print(dp[N - 1])


 
def iin(): return int(input())
def iln(): return list(map(int, input().split()))
 
N, K = iln()
solve(N, K, iln())


Measured memory_bytes: 13980
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1ll<<60)
using namespace std;
map<pii ,int> mp;
char s[40];
int n;
long long ans;
void solve1(int x,int v1,int v2){
	if (!x){
		mp[pii(v1,v2)]++;
		return;
	}
	solve1(x-1,(27ll*v1+s[x]-'a'+1)%1000000007,v2);
	solve1(x-1,v1,(27ll*v2+s[x]-'a'+1)%1000000007);
}
void solve2(int x,int v1,int v2){
	if (x>2*n){
		ans+=mp[pii(v2,v1)];
		return;
	}
	solve2(x+1,(27ll*v1+s[x]-'a'+1)%1000000007,v2);
	solve2(x+1,v1,(27ll*v2+s[x]-'a'+1)%1000000007);
}
int main(){
	scanf("%d%s",&n,s+1);
	solve1(n,0,0);
	solve2(n+1,0,0);
	printf("%lld",ans);
}

Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
cin >> N >> K;
long long  H[N];
for(int i = 0; i< N; i++) cin >> H[i];
sort (H,H+N);
reverse(H,H+N);
long long count = 0;
if(K<N){
  for(int i = K; i < N; i++){
    count+= H[i];
  }
}
cout << count << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int n ;
  cin >> n  ;
  vector<int> hei(n) ;
  vector<int> vec(n-1) ;
  int count = 0 ;
  int ans = 0 ;

  REP(i,n){
    cin >> hei.at(i) ;
  }
  
  REP(i,n-1){
    if(hei.at(i)>=hei.at(i+1)){
      vec.at(i) = 1 ;
    }
  }
  
  int i = 0 ;
  while(i<n-1){
    if(vec.at(i)==1){
      count++ ;
      ans = max(ans,count) ;
    }
    else{
      count = 0 ;
    }
    i++ ;
  }
  
  cout << ans <<endl ;

  return 0 ;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;


int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int l;
  cin >> l;
  std::cout << std::fixed;
  cout << setprecision(6) <<pow((double)(l) / 3.0, 3 ) << endl;
  return 0;
}




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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    sort(_all(a));
 
    ll res = a[n - 1] - a[0];
    rep(i, n / 2 - 1){
        res += a[n-1 - i - 1] - a[i];
        res += a[n-1 - i] - a[i + 1];
    }
    if(n % 2 == 1){
        res += max(a[n/2] - a[n/2 - 1], a[n/2 + 1] - a[n/2]);
    }
 
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 640
// ABC055_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll S_num, c_num;
    cin >> S_num >> c_num;
    
    // calculation
    if (S_num >= c_num) {
        // ex) S:c = 4:2
        // 小さい方に合わせる
        cout << c_num/2 << "\n";
    } else {
        // S_num < c_num
        // ex) S:c = 10:11, 1:10
        if (S_num*2 <= c_num) {
            // 2 倍以上
            ll res = S_num;
            c_num -= 2*S_num;  // 残り
            if (c_num <= 3) {
                cout << res << "\n";
            } else if (c_num == 4) {
                // 4 だとちょうど 1 セット作れる
                cout << res+1 << "\n";
            } else {
                cout << res + c_num/4 << "\n";
            }
        } else {
            // 2 倍未満
            cout << c_num/2 << "\n";
        }
    }
    
    return 0;
}

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

int main(){
    // input
    char r, g, b; cin >> r >> g >> b;
    // compute
    string S;
    S = S + r + g + b;
    int num = atoi(S.c_str());
    if(num % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    // output
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
int n,m,x,y,a[200],b[200];

bool check()
{
    return a[n]<b[0];
}
    

int main()
{
    cin>>n>>m>>x>>y;
    for (int i=0; i<n; ++i)
        cin>>a[i];
    a[n]=x;
    for (int i=0; i<m; ++i)
        cin>>b[i];
    b[m]=y;
    sort(a,a+n+1);
    sort(b,b+m+1);
    if (check())
        cout<<"No War"<<endl;
    else cout<<"War"<<endl;
    return 0;
}



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

int A[55];
bool boleh[55];
int B[55];
int C[55];
int indx[55];
long long ncr[55][55];

long long ncrUpTo[55][55];

int cnt2[(1<<18)+5];

int main(){
    int N, K, S, T;
    scanf("%d%d%d%d", &N, &K, &S, &T);

    if( ((S&T) == S) && ((S|T) == T) ){
    }else{
        printf("0");
        return 0;
    }

    memset(ncr, 0, sizeof(ncr));
    ncr[0][0] = 1;
    for(int i = 1; i <= N; i ++){
        ncr[i][0] = 1;
        for(int j = 1; j <= i; j ++){
            ncr[i][j] = ncr[i-1][j] + ncr[i-1][j-1];
        }
    }

    ncrUpTo[0][0] = 0;
    for(int i = 1; i <= N; i ++){
        ncrUpTo[i][0] = 0;
        for(int j = 1; j <= N; j ++){
            ncrUpTo[i][j] = ncrUpTo[i][j-1] + ncr[i][j];
        }
    }

    for(int i = 0; i < N; i ++){
        scanf("%d", &A[i]);
        boleh[i] = true;
        //printf("A[%d]=%d\n", i, A[i]);
    }

    int L = 0;
    for(int i = 0; i < 20; i ++){
        if( (S&(1<<i)) == (T&(1<<i)) ){
            for(int j = 0; j < N; j ++){
                if( (S&(1<<i)) != (A[j]&(1<<i)) ){
                    boleh[j] = false;
                    //printf("boleh[%d]=false\n", j);
                }
            }
        }else{
            indx[L ++] = i;
        }
    }

    for(int i = 0; i < L; i ++){
        for(int j = 0; j < N; j ++){
            if(A[j]&(1<<indx[i])){
                B[j] |= (1<<i);
            }
        }
    }

    int M = 0;
    for(int i = 0; i < N; i ++){
        if(boleh[i]){
            C[M ++] = B[i];
        }
    }

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

    memset(cnt2, 0, sizeof(cnt2));
    long long ans = 0;
    vector<int> s;
    for(int U = 0; U < (1<<L); U ++){
        long long f = 0;

        s.clear();
        for(int i = 0; i < M; i ++){
            if(!cnt2[U&C[i]]){s.emplace_back(U&C[i]);}
            cnt2[U&C[i]] ++;
        }

        for(int j: s){
            int cnt = cnt2[j];
            f += ncrUpTo[cnt][K];
            cnt2[j] = 0;
        }

        int temp = __builtin_popcount(U);
        if(temp&1){
            ans -= f;
        }else{
            ans += f;
        }
    }

    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 4856
from operator import itemgetter

N = int(input())
shops = []
for i in range(N):
    S,P = input().split()
    P = int(P)
    shops.append([S,P,i+1])
shops = sorted(shops)
shops.append(["",0,0])

last = shops[0][0]
lasti = 0

for i in range(N+1):
    if shops[i][0] != last:
        ans = sorted(shops[lasti:i],key=itemgetter(1),reverse=True)
        for a in ans:
            print(a[2])
        last = shops[i][0]
        lasti = i 



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

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> A;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        pair<int, int> P(tmp, i);
        A.push_back(P);
    }
    sort(A.begin(), A.end());
    for(int i=0;i<N;i++){
        cout << A[i].second + 1 << " ";
    }
    cout << endl;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
  os << "[";
  REP(i, SZ(v)) {
    if (i) os << ", ";
    os << v[i];
  }
  return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
  return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  if(s.back() == 's') {
    cout << s + "es" << endl;
  } else {
    cout << s + "s" << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	int N;
	cin >> N;
	vector<int>H(N);
	rep(i, N)cin >> H[i];
	vector<bool>v(N, true);
	for (int i = 0; i < N; i++)
	{
		for (int j = i - 1; j >= 0; j--)
		{
			if (H[i] < H[j])v[i] = false;
		}
	}
	int cnt = 0;
	rep(i, N)if (v[i] == true)cnt++;
	cout << cnt;
}

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

int atn(char a){
  return a-'a';
}

int main(){
  string A,B,C;cin>>A>>B>>C;
  int a=0,b=0,c=0;
  int next=atn(A[a]);a++;
  while(true){
    if(next==0){
      if(A.size()==a){cout<<"A"<<endl;break;}
      next=atn(A[a]);a++;
      
    }else if(next==1){
      if(B.size()==b){cout<<"B"<<endl;break;}
      next=atn(B[b]);b++;
      
    }else if(next==2){
      if(C.size()==c){cout<<"C"<<endl;break;}
      next=atn(C[c]);c++;
      
    }
  }
}

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

using namespace std;


int main() {
    int W, a, b;
    while (cin >> W >> a >> b) {
        int distance = 0;
        if (a + W <= b) {
            distance = b - (a + W);
        } else if (b + W <= a) {
            distance = a - (b + W);
        }
        cout << distance << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

class WeightedEdge {
	int from;
	int to;
	int weight;

	WeightedEdge(int from, int to, int weight){
		this.from = from;
		this.to = to;
		this.weight = weight;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		List<PriorityQueue<WeightedEdge>> edges = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			edges.add(new PriorityQueue<>(Comparator.comparingInt(w -> w.from)));
		}
		for (int i = 0; i < N - 1; i++) {
			int u = Integer.parseInt(sc.get()) - 1;
			int v = Integer.parseInt(sc.get()) - 1;
			int w = Integer.parseInt(sc.get());
			edges.get(u).add(new WeightedEdge(u, v, w));
			edges.get(v).add(new WeightedEdge(v, u, w));
		}

		BitSet black = new BitSet();
		dfs(new BitSet(), black, 0, edges);
		StringJoiner joiner = new StringJoiner("\n");
		for (int i = 0; i < N; i++) {
			joiner.add(black.get(i) ? "1" : "0");
		}
		System.out.println(joiner.toString());
	}

	void dfs(BitSet visited, BitSet black, int start, List<PriorityQueue<WeightedEdge>> ki) {
		if (visited.get(start)) return;
		visited.set(start);
		PriorityQueue<WeightedEdge> edges = ki.get(start);
		while (!edges.isEmpty()) {
			WeightedEdge w = edges.remove();
			if (w == null || w.weight <= 0) {
				continue;
			}
			if (w.weight % 2 == 0) {
				black.set(w.to, black.get(start));
			} else {
				black.set(w.to, !black.get(start));
			}
			dfs(visited,black, w.to, ki);
		}
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

Measured memory_bytes: 70288
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

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

const int INF=100000000;
const bool debug=1;

int main(){
  int N,M,P;
  while(cin>>N>>M>>P,N|M|P){
    int a[N];
    int sum=0;
    REP(i,N){cin>>a[i];sum+=a[i];}
    sum=sum*(100-P);
    if(a[M-1]==0)cout << 0 << endl;
    else cout << sum/a[M-1]<< endl;;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
main(){while(true){int x[11000],n,i,j,k,l,m,y[11000],b,c,d,p[11000],w;scanf("%d", &n);
if(n==0){break;}
for(i=0;i<n;i++){scanf("%d", &y[i]);p[i]=x[i]=y[i];}c=0;d=0;m=n;d=m;w=99999;
for(i=0;i<n;i++){for(j=1;j<=3;j++){if(i>=1&&y[i-1]!=j&&y[i+1]!=j){goto z;}
p[i]=x[i]=j;b=1;d=n;
while(true){c=0;
for(k=0;k<m;k++){if(p[k]==p[k+1]){b++;}
else{if(b >= 4){
for(l=k+1;l<m;l++){p[l-b]=p[l];}
d -= b;c++;
for(l=d;l<m;l++){p[l]=0;}
}
b=1;}m=d;}
if(c==0){break;}
else{c=0;}}
w=std::min(w,m);x[i]=y[i];
for(k=0;k<n;k++){p[k]=y[k];}
z:;
}}printf("%d\n",w);}}

Measured memory_bytes: 3216
#include <stdio.h>
int main(){
  int n,card[4][13]={},rank,i,j;
  char gara,space;

  scanf("%d",&n);
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){card[i][j]=0;}
  }

  for(n;n>0;n--){
    scanf("%c",&space);
    scanf("%c %d",&gara,&rank);
    if(gara=='S')i=0;
    else if(gara=='H')i=1;
    else if(gara=='C')i=2;
    else if(gara=='D')i=3;
    j=rank-1;
    card[i][j]=1;
  }

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(card[i][j]==0){
	if(i==0)gara='S';
	else if(i==1)gara='H';
	else if(i==2)gara='C';
	else if(i==3)gara='D';
	rank=j+1;
	printf("%c %d\n",gara,rank);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

	int a = n % 10;
	int b = n / 10;

	puts(a == 9 || b == 9 ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]


class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)


ans_list = []
graph = UnionFind(N)
last = N * (N-1) // 2
ans_list.append(last)
for i in range(M-1, -1, -1):
    a, b = AB[i]
    if graph.same(a-1, b-1):
        ans_list.append(ans_list[-1])
    else:
        ans_list.append(ans_list[-1] - graph.size(a-1) * graph.size(b-1))
    graph.unite(a-1, b-1)

for i in range(M-1, -1, -1):
    print(ans_list[i])

Measured memory_bytes: 38116
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''
#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,d=mii()

cnt=0

for i in range(n):
    x,y=mii()

    if d*d >=x**2 +y**2:
        cnt+=1

print(cnt)

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

using namespace std;
int n,k,i;
int a[200005];
int main(int argc, char **argv)
{
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>a[i];
		
	for(i=k+1;i<=n;i++)
	{
		if(a[i]>a[i-k])
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}



Measured memory_bytes: 4396
class StarrySkyTree:
    def __init__(self,num):
        leaf=1<<(num-1).bit_length()
        self.leaf=leaf
        self.data=[0]*leaf*2
        self.lazy=[0]*leaf*2
    def indices(self,l,r):
        L,R=l+self.leaf,r+self.leaf
        lm=(L//(L&-L))>>1
        rm=(R//(R&-R))>>1
        while L<R:
            if R<=rm:
                yield R
            if L<=lm:
                yield L
            L>>=1; R>>=1
        while L:
            yield L
            L>>=1
    def zeroindices(self,k):
        K=k+self.leaf
        limit=(K//(K&-K))>>1
        while K:
            if K<=limit:
                yield K
            K>>=1
    def _propagates(self,*ids):
        for i in reversed(ids):
            v=self.lazy[i-1]
            if v==0:
                continue
            self.lazy[2*i-1]+=v; self.lazy[2*i]+=v
            self.data[2*i-1]+=v; self.data[2*i]+=v
            self.lazy[i-1]=0
    def add(self,l,r,x):
        L,R=l+self.leaf,r+self.leaf
        while L<R:
            if L&1:
                self.lazy[L-1]+=x; self.data[L-1]+=x
                L+=1
            if R&1:
                R-=1
                self.lazy[R-1]+=x; self.data[R-1]+=x
            L>>=1; R>>=1
        for i in self.indices(l,r):
            self.data[i-1]=max(self.data[2*i-1],self.data[2*i])+self.lazy[i-1]
    def add1(self,k,x): #add[k,k+1)
        k+=self.leaf
        self.data[k-1]+=x
        while k:
            k>>=1
            self.data[k-1]=max(self.data[2*k-1],self.data[2*k])+self.lazy[k-1]
    def query(self,l,r): #[l,r)
        self._propagates(*self.indices(l,r))
        L,R=l+self.leaf,r+self.leaf
        ret=0
        while L<R:
            if L&1:
                ret=max(ret,self.data[L-1])
                L+=1
            if R&1:
                R-=1
                ret=max(ret,self.data[R-1])
            L>>=1; R>>=1
        return ret
    def query0(self,k):
        self._propagates(*self.zeroindices(k))
        L,R=self.leaf,k+self.leaf
        ret=0
        while L<R:
            if L&1:
                ret=max(ret,self.data[L-1])
                L+=1
            if R&1:
                R-=1
                ret=max(ret,self.data[R-1])
            L>>=1; R>>=1
        return ret

import sys
input=sys.stdin.readline
n,m=map(int,input().split())
sst=StarrySkyTree(n+1)
R=[[] for _ in range(n+1)]
for _ in range(m):
    l,r,a=map(int,input().split())
    R[r].append((l,a))
for i in range(1,n+1):
    v=sst.query0(i)
    sst.add1(i,v)
    for l,a in R[i]:
        sst.add(l,i+1,a)
print(sst.query0(n+1))

Measured memory_bytes: 104176