akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<vector>
using namespace std;

int main(){
    map<string, vector<int>> m;
    m["north"] = vector<int>({1, 0, 4, 5});
    m["south"] = vector<int>({5, 4, 0, 1});
    m["east"] = vector<int>({3, 0, 2, 5});
    m["west"] = vector<int>({5, 2, 0, 3});

    int n;
    while(cin >> n, n){
        int a[6] = {1, 2, 3, 4, 5, 6};
        while(n-- > 0){
            string s;   cin >> s;
            int cp = a[m[s][0]];
            for(int i = 0; i < 3; i++)  a[m[s][i]] = a[m[s][i+1]];
            a[m[s][3]] = cp;
        }
        cout << a[0] << endl;
    }
    return 0;
}


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

int main(void){
    int N;
    char x;
    int n;
    vector<int> d(14);
    vector<int> c(14);
    vector<int> h(14);
    vector<int> s(14);

    cin >> N;

    while(cin >> x >> n){
        if(x == 'D') d.at(n) = 1;
        else if(x == 'C') c.at(n) = 1;
        else if(x == 'H') h.at(n) = 1;
        else s.at(n) = 1;
    }
    for(int i=1; i<14; i++) if(s.at(i)==0) cout << "S" << " " << i << endl;
    for(int i=1; i<14; i++) if(h.at(i)==0) cout << "H" << " " << i << endl;
    for(int i=1; i<14; i++) if(c.at(i)==0) cout << "C" << " " << i << endl;
    for(int i=1; i<14; i++) if(d.at(i)==0) cout << "D" << " " << i << endl;

    return 0;
}


Measured memory_bytes: 3084
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger N = BigInteger.valueOf(sc.nextLong());
		BigInteger A = BigInteger.valueOf(sc.nextLong());
		BigInteger B = BigInteger.valueOf(sc.nextLong());
		BigInteger APlusB = A.add(B);
		BigInteger dev = N.divide(APlusB);
		BigInteger mul = dev.multiply(A);
		BigInteger rem = N.remainder(APlusB);
		BigInteger total = BigInteger.valueOf(0);
		
		if (rem.equals(0)) {
			total = mul;
		} else if (rem.compareTo(A) >= 1) {
			total = mul.add(A);
		} else {
			total = mul.add(rem);
		}
		
		System.out.println(total);
	}
}	

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

int main()
{
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  int i, j, k, l;
  for(i = 0; i < n; i++)
  {
    for(j = 0; j < d; j++)cin >> x.at(i).at(j);
  }
  int ans = 0;
  for(i =0 ; i < n; i++)
  {
    for(j = i+1; j < n; j++)
    {
      int dis = 0;
      for(k = 0; k < d; k++)
      {
        dis += (x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
      }
      int p = (int)sqrt(dis);
      if(p*p == dis)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

N, X, Y = map(int, input().split())

graph = [[] for _ in range(N + 1)]
for i in range(1, N):
    graph[i].append(i + 1)
    graph[i + 1].append(i)
graph[X].append(Y)
graph[Y].append(X)

def dfs(st, graph):
    INF = 10 ** 18
    dist = [INF] * len(graph)
    dist[st] = 0
    stack = [st]
    while stack:
        s = stack.pop()
        for t in graph[s]:
            if dist[t] > dist[s] + 1:
                dist[t] = dist[s] + 1
                stack.append(t)
    return dist

answer = [0] * (N + 1)
for i in range(1, N + 1):
    dist = dfs(i, graph)
    for j in range(1, N + 1):
        answer[dist[j]] += 1

for i in range(1, N):
    print(answer[i] // 2)

Measured memory_bytes: 46556
import java.util.Scanner;

//AtCoder Beginner Contest 159
//B	String Palindrome
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		for (int i = 0; i < S.length()/2; i++) {
			if (S.charAt(i) != S.charAt(S.length()-1-i)) {
				System.out.println("No");
				return;
			}
		}
		for (int i = 0; i < S.length()/2; i++) {
			if (S.charAt(i) != S.charAt((S.length()/2-1)-i)) {
				System.out.println("No");
				return;
			}
			if (S.charAt(S.length()/2+1+i) != S.charAt(S.length()-1-i)) {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");
	}
}


Measured memory_bytes: 23764
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    string o, e;
    cin >> o >> e;

    string ans = "";
    for(int i = 0; i < o.size() + e.size(); i++){
        if(i % 2 == 0){
            ans += o[i / 2];
        } else {
            ans += e[i / 2];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
struct energy_shop{
  long long price;
  long long amount;
};
int main()
{
  int n,m,count=0;
  long long res=0;
  std::vector<energy_shop> shop_list;
  std::cin >> n >> m;
  for(int i=0; i<n; i++){
    int price,amount;
    std::cin >> price >> amount;
    shop_list.push_back({price, amount});
  }
  std::sort(
      shop_list.begin(),
      shop_list.end(),
      [](const energy_shop& x, const energy_shop& y){return x.price < y.price;}
      );
  for(auto a: shop_list){
    res += a.price * ((count+a.amount>m)?m-count:a.amount);
    count += a.amount;
    if (count>m)
      break;
  }
  std::cout << res;

  return 0;
}


Measured memory_bytes: 2420
#n=int(input())
#a,b=map(int,input().split())
sl=list(input())
tl=list(input())
#l=[list(map(int,input().split())) for i in range(n)]

sdic={}
tdic={}
flag=True
for i in range(len(sl)):
    s=sl[i]
    t=tl[i]
    if sdic.get(s,-1)==-1:
        sdic[s]=t
    else:
        if sdic[s]!=t:
            flag=False
            break
    if tdic.get(t,-1)==-1:
        tdic[t]=s
    else:
        if tdic[t]!=s:
            flag=False
            break
if flag:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 6704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[33;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
const int maxn=2e5+7;
vector<int> G[maxn];
typedef pair<int,int> PII;
PII dfs(int u,int fa=-1)
{
	PII ret={u,0};
	for(auto v:G[u])
	{
		if(v==fa) continue;
		PII tmp=dfs(v,u);
		tmp.second++;
		if(tmp.second>ret.second) ret=tmp;
	}
	return ret;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++)
	{
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	auto v=dfs(1);
	auto ans=dfs(v.first);
	if(ans.second%3==1) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
}


Measured memory_bytes: 23680
/*
* Problem link
* 
*/

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

typedef long long LL;
typedef vector<double> V;
typedef vector<V> VV;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
template<typename T>
inline bool chmax(T &a, T b) {
	bool res = a < b;
	if (res)a = b;
	return res;
}
int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	int T;
	cin >> T;
	while (T--) {
		LL money;
		int t,n;
		cin >> money >> t >> n;
		vector<VV> cost(2);
		REP(i, n) {
			LL type;double  a, b;
			cin >> type >> a >> b;
			cost[type].push_back({ a,b });
		}
		LL res=-114514;
		for(auto &it:cost[0]){
			LL mine = money;
			LL other = 0;
			REP(i, t) {
				other += mine*it[0];
				mine -= it[1];
			}
			chmax(res, mine + other);
		}
		for (auto &it : cost[1]) {
			LL mine = money;
			LL other = 0;
			REP(i, t) {
				mine += mine*it[0];
				mine -= it[1];
			}
			chmax(res, mine + other);
		}

		cout << res << endl;



	}
	

	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned int
#define inf 0x3f3f3f3f
#define db double
using namespace std;
const int maxn=1e6+10;
int d[2][6], cnt1=0,cnt2=0;

int main() {
	ll a;
	cin>>a;
	a=a*a*a+a*a+a;
	cout<<a<<endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  
  int N;
  string S;
  cin >> N >> S;

  for (int i = 0; i < S.size(); i++) {
    S.at(i) = 'A' + (S.at(i) - 'A' + N) % 26;
  }
  cout << S << '\n';
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n = int(input().rstrip())
    ans = [0 for _ in range(n)]
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                tmp = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x
                if tmp > n:
                    break
                # if x == y == z:
                #     ans[tmp - 1] = 1
                # elif x == y or y == z or z == x:
                #     ans[tmp - 1] = 3
                # else:
                #     ans[tmp - 1] = 6
                ans[tmp - 1] += 1
    for v in ans:
        print(v)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9372
#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 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 int inf = 1 << 30;
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=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int n;
vll a;

ll solve(bool isp){
    ll sum = 0LL;
    ll ret = 0LL;
    rep(i, n){
        sum += a[i];
        if(isp and sum <= 0){
            ret += -sum + 1;
            sum = 1LL;
        }
        if(not isp and sum >= 0){
            ret += sum + 1;
            sum = -1LL;
        }
        isp ^= 1;
    }
    return ret;
}

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

    cin >> n;
    a = vll(n); for(auto& e : a) cin >> e;

    ll res = min(solve(0), solve(1));
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (1'000'000'007)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    int ans=0;
    int d = 0;
    while(d <= x){
        d += l[ans++];
    }
    pr(ans>n?n+1:ans);
}

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

int main() {
  int  N, N1, N2, N3, N4;
  
  cin >> N;
  
  N1 = N / 1000;
  N2 = N / 100 - N1 * 10;
  N3 = N / 10 - N1 * 100 - N2 * 10;
  N4 = N - N1 * 1000 - N2 * 100 - N3 * 10;
  
  if ( N2 == N3 && (N1 == N2 || N3 == N4) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  string s;
  cin >> s;
  in6 size = s.size();
  in6 ans = 0;
  in6 cand = 0;
  rep(i,size) {
    if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') cand++;
    else {ans = max(ans,cand); cand = 0;}
  }
  ans = max(ans,cand);
  cout << ans;
}

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

typedef long long ll;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define all(x) (x).begin() ,(x).end()

const int p = 1e9 + 7;

ll binpow(ll a, ll b , ll mod) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res % mod;
}

const int dx[] = {1 , -1 , 0 , 0};
const int dy[] = {0 , 0 , -1 , 1};
const ll inf = 1e18 - 5LL;
const int N = 1e5 + 9;



void solve() {
     
     int x;
     cin>>x;
     cout<<(x^1)<<"\n";
}
int main() {

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

	int t = 1;
	//cin >> t;

	while (t--)
		solve();

	return 0;
}

Measured memory_bytes: 3648
def gcd(x,y):
	return gcd(y,x%y) if y else x
n,a,b,c=int(input()),list(map(int,input().split())),[],[]
for i in range(n):
	b.append(gcd(b[i-1],a[i-1]) if i else 0)
	c.append(gcd(c[i-1],a[n-i]) if i else 0)
print(max([gcd(b[i],c[n-i-1]) for i in range(n)]))

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

int main() {
	int x[5];
	for (int i = 0; i < 5; i++)
	{
		cin >> x[i];
	}

	for (int i = 0; i < 5; i++)
	{
		if (x[i] == 0)
		{
			cout << i + 1 << endl;
		}
	}
}

Measured memory_bytes: 3592
//
// Created by 13783 on 2020/3/30.
//
#include<iostream>
using namespace std;
const int N=1E5+2;
int n;
int h[N];
int dp[N];
//do[i]为前i个数的最小代价
void solve(){
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 1024
n = gets.to_i
v = gets.split(' ').map(&:to_i)

s = Hash.new(0)
t = Hash.new(0)
n.times do |i|
  if i % 2 == 0
    s[v[i]] += 1
  else
    t[v[i]] += 1
  end
end
s = s.to_a
s.sort_by!{|k| k[1]}.reverse!
s.push([0, 0])
t = t.to_a
t.sort_by!{|k| k[1]}.reverse!
t.push([0, 0])

if s[0][0] != t[0][0]
  puts  n - s[0][1] - t[0][1]
else
  k = [s[1][1] + t[0][1], s[0][1] + t[1][1]].max
  puts n - k
end

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

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

  //1:増加
  //-1:減少
  //0:未知
  int judge = 0;
  int ans = 0;
  for ( int i = 0; i < n - 1; ++i) {
    if ( a[i] == a[i + 1] ) continue;
    if ( a[i] < a[i + 1] ){
      if ( judge == 0 ){
	judge = 1;
      }
      if ( judge == -1 ){
	judge = 0;
	ans++;
      }
    }
    if ( a[i] > a[i + 1] ) {
      if ( judge == 0 ) {
	judge = -1;
      }
      if ( judge == 1 ) {
	judge = 0;
	ans++;
      }
    }
  }
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#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 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n;
  vector<pair<string, int>> s;

  cin >> n;
  REP(i, n)
  {
    string si;
    cin >> si;
    bool ed = false;
    REP(i, s.size())
    {
      if (s[i].first == si)
      {
        s[i].second++;
        ed = true;
        break;
      }
    }
    if (!ed)
      s.push_back({si, 1});
  }

  cin >> n;
  REP(i, n)
  {
    string si;
    cin >> si;
    bool ed = false;
    REP(i, s.size())
    {
      if (s[i].first == si)
      {
        s[i].second--;
        ed = true;
        break;
      }
    }
  }

  int r = 0;
  REP(i, s.size())
  {
    if (r < s[i].second)
      r = s[i].second;
  }

  cout << r << '\n';

  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int H, W, N; scanf("%d %d %d", &H, &W, &N);
  int a, b;
  vector<pair<int, int>> V;
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &a, &b);
    for (int dr = -2; dr <= 0; ++dr) {
      for (int dc = -2; dc <= 0; ++dc) {
        int nr = a + dr, nc = b + dc;
        if (1 <= nr and nr + 2 <= H and 1 <= nc and nc + 2 <= W) {
          V.push_back(make_pair(nr, nc));
        }
      }
    }
  }
  vector<ll> ans(10, 0);
  ans[0] = 1LL * (H - 2) * (W - 2);
  sort(V.begin(), V.end());
  int n = V.size();
  for (int i = 0, j; i < n; i = j) {
    j = i;
    while (j < n and V[j] == V[i]) { ++j; }
    int cnt = j - i;
    ++ans[cnt];
    --ans[0];
  }
  for (int i = 0; i < 10; ++i) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 10476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
    int n;
    cin >> n;
    vector<int> d;
    int x;
    for(int i=0; i < n; i++){
        cin >> x;
        d.emplace_back(x);
    }
    sort(d.begin(), d.end());

    // for(auto i: d){
        // cout << i << ", ";
    // }
    // cout << endl;
    if(n % 2 != 0){
        cout << 0;
        return 0;
    }
    int chuo = n/2;
    // cout << d[chuo-1] << endl;
    // cout << d[chuo] << endl;
    cout << d[chuo] - d[chuo-1] << endl;

    // 出力
    return 0;
}


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

using namespace std;

int main(){
long long a,b,c;
cin >> a >> b >> c;
vector<long long >p(3);
p[0] = a;
p[1] = b;
p[2] = c;
if(a%2 == 0 || b%2 == 0|| c%2 ==0){
	cout << 0 <<endl;
} 
else{
sort(p.begin(),p.end());
cout << p[0]*p[1] <<endl;
}

return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x; cin>>x;
    cout<<1-x<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <unordered_map>
#include <utility>
#include <algorithm>
using namespace std;
int n, k;
unordered_map<int, int> mp;
int main() {
	cin >> n >> k;
  	int a;
  	for (int i = 0; i < n; i++) {
    	cin >> a;
      	if (mp.find(a) == mp.end()) {
          mp[a] = 1;
        } else {
          mp[a] = mp[a] + 1;
        }
    }
  	int nums[mp.size()];
  	int i = 0;
  	for (pair<int, int> element : mp) {
      	nums[i++] = element.second;
      	
    }
  	sort(nums, nums+mp.size());
  	int k2 = 0;
  	if (mp.size() < k) {
    	cout << 0 << endl;
      	return 0;
    }
  	for (int i = 0; i < mp.size()-k; i++) {
     	k2 += nums[i];
    }
  	cout << k2 << endl;
 	return 0;
}


Measured memory_bytes: 11420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n,k,s;
    cin>>n>>k>>s;
    REP(i,k){
        cout<<s<<" ";
    }
    long long int machigai;
    if(s<2000000){
        machigai = s * 3;
    }else{
        machigai = s - 1;
    }
    REP(i,n-k-1){
        cout<<machigai<<" ";
    }
    if(n!=k){
        cout << machigai << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define testcases() int t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
 //----------------------------------------------------------------------------------------------------------------------------------------------------

int func(int n)
{
	int cnt=0;
	while(n)
	{
		n/=10;
		cnt++;
	}
	return cnt%2;
}

int main()
{
	fast;
	int n,cnt;
	cin>>n;
	cnt=0;
	for(int i=1;i<=n;i++)
	{
		cnt+=func(i);
	}
	cout<<cnt;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

// 最大公約数 : 3,4 ->  1
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve()
{
  int n, a, ans;
  cin >> n;
  cin >> a;
  ans = a;
  for(int i = 1; i < n; ++i)
  {
    cin >> a;
    ans = gcd(a, ans);
  }

  cout << ans;

}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3620
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x; cin >> x;
    int ans = x == 3 || x == 5 || x == 7;
    cout << "YES\0NO" + !ans * 4 << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;

int n;
long long q[1000010];
bool b[1000010];
long long memo[100010][2];

long long solve(int i = 0, int prevIsE = true) {
	int pear = 1, berry = 1;
	bool flaga = false, flagb = false;
	if (i == n) {
		return 1;
	}
	if (memo[i][prevIsE] != -1) {
		return memo[i][prevIsE];
	}
//	cout << i << " " << b[q[i]] << " " << q[i - 1 - prevIsE] << " " << q[i] << endl;
	if (i != 0 && b[q[i]] && q[i - 1 - prevIsE] < q[i]
	 || i == 0 && b[q[i]]) {
//	if (sosu[q[i]] && prevSosu < q[i]) {
//		cout << i << " is q" << endl;
		pear = pear * solve(i + 1, false) % MOD;
		flaga = true;
	}
	if (!prevIsE) {
//		cout << i << " is e" << endl;
		berry = berry * solve(i + 1, true) % MOD;
		flagb = true;
	}
	pear *= flaga;
	berry *= flagb;
//	cout << i << " " << pear + berry << endl;
	return memo[i][prevIsE] = (pear + berry) % MOD;
}


signed main() {
	cin >> n;
	rep (i, n) {
		cin >> q[i];
		b[q[i]] = true;
		for (int j = 2; j * j <= q[i]; j++) b[q[i]] = b[q[i]] && (q[i] % j != 0);
	}
	rep (i, 100010) rep (j, 2) memo[i][j] = -1;
	cout << solve() << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 1; i <= n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  ll n;
  cin >> n;

  ll ans = 0;

  REP(i, n) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    else
      ans += i;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

ll N;
string a,b;
int main(){
    cin>>a>>b;
    if(a.length()<b.length()){
        cout<<"LESS"<<endl;
    }else if(a.length()==b.length()){
        if(a<b){
            cout<<"LESS"<<endl;
        }else if(a==b){
        cout<<"EQUAL"<<endl;
        }else{
          
        cout<<"GREATER"<<endl;  
        }
    }else{
        cout<<"GREATER"<<endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define MOD 1000000007
#define f(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define rep(i, n) f(i, 0, n)
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
#define wh(t) while (t--)
#define inf 1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n";

const ll N = 5005;
ll dx[4] = { -1, 0, 1, 0};
ll dy[4] = {0, -1, 0, 1};


ll binpow(ll a, ll n)
{
	ll i = 1;
	while (n > 0)
	{
		if (n & 1)
			i = (i * a);
		a = (a * a);
		n = n >> 1;
	}
	return i;
}

ll isprime(ll n)
{
	if (n == 0 || n == 1)
		return n;
	if (n % 2 == 0)
		return (ll)2;
	if (n % 3 == 0)
		return (ll)3;
	else
	{
		for (ll i = 5; i * i <= n; i += 6)
		{
			if (n % i == 0)
				return i;
			if (n % (i + 2) == 0)
				return (i + 2);
		}
		return n;
	}
}

int main() {
	fast;/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	ll l, r, n, m, i, j, k, a, b, c, t, x, y, d;
	cin >> n;
	map<ll, ll> mp;
	rep(i, n) {
		cin >> j;
		mp[j]++;
	}
	ll ans = 0;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		x = it->ff; y = it->ss;
		ll sum = y; if (mp.find(x + 1) != mp.end()) sum += mp[x + 1];
		if (mp.find(x - 1) != mp.end()) sum +=	mp[x - 1];
		ans = max(sum, ans);

		sum = y; if (mp.find(x + 1) != mp.end()) sum += mp[x + 1];
		if (mp.find(x + 2) != mp.end()) sum +=	mp[x + 2];
		ans = max(sum, ans);

		sum = y; if (mp.find(x - 2) != mp.end()) sum += mp[x - 2];
		if (mp.find(x - 1) != mp.end()) sum +=	mp[x - 1];
		ans = max(sum, ans);
	}
	pp(ans);
}

Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'a' || s[i] == 'c' || s[i] == 'b')continue;
		else {
			cout << "No";
			return 0;
		}
	}
	if (s[0] == s[1] || s[0] == s[2] || s[1] == s[2]) {
		cout << "No";
		return 0;
	}
	else cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int dinner[5] = {};
    int losstime[5] = {};
    int i = 0;
    
    while(i < 5){
        cin >> dinner[i];
        i++;
    }
    
    for(i=0;i < 5;i++){
        if(dinner[i]%10 == 0){
            losstime[i] = 0;
        }else{
            
        losstime[i] = 10-(dinner[i]%10);
        }
    }
    sort(losstime,losstime+5);
    
    int ans = 0;
    for(i=0;i < 5;i++){
        ans += dinner[i];
    }
    for(i=0;i < 4;i++){
        ans += losstime[i];
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn s(n: i64) -> i64 {
    let mut sum = 0;
    let mut nn = n;
    while nn >= 1 {
        sum += nn % 10;
        nn /= 10
    }
    sum
}

const MAX: i64 = 1e15 as i64;

fn generate_snuke() -> Vec<(i64, i64)> {
    let mut candidate_snuke = vec![];
    let mut pow10 = 1;

    for _ in 1..15 {
        for i in 1..100000 {
            let n = i * pow10 - 1;
            if n > MAX {
                break;
            }
            if n >= 1 {
                candidate_snuke.push((n, s(n)));
            }
        }
        pow10 *= 10;
    }
    candidate_snuke
}

fn compare((a, sa): (i64, i64), (b, sb): (i64, i64)) -> Ordering {
    if a * sb < b * sa {
        Ordering::Less
    } else if a * sb > b * sa {
        Ordering::Greater
    } else {
        Ordering::Equal
    }
}

fn main() {
    let mut k: i32 = read();
    let mut snuke = generate_snuke();
    snuke.sort_by(|&a, &b| compare(a, b));
    let mut max = 0;
    for &(a, s) in snuke.iter().by_ref() {
        if max < a {
            max = a;
            println!("{}", max);
            k -= 1;
            if k == 0 {
                break;
            }
            // println!("{} -> {} ({})", max, s, max as f64 / s as f64);
        }
    }
}


Measured memory_bytes: 36088
#include<stdio.h>

int main(void) {
   int n;
   scanf("%d", &n);
   int v[n];
   int c[n];

   for(int i = 0; i < n; i++) {
      scanf("%d", &v[i]);
   }

   for(int i = 0; i < n; i++) {
      scanf("%d", &c[i]);
   }

   int sum = 0;

   for(int i = 0; i < n; i++) {
      if(v[i] > c[i]) {
         sum += v[i]-c[i];
      }
   }

   printf("%d\n" ,sum);

   return 0;
}


Measured memory_bytes: 128
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[])

solver [s,w] = if s <= w then "unsafe" else "safe"


Measured memory_bytes: 3920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
//#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEsL 2e9
#define PIE 3.1415a926535

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main() {
    int n;cin>>n;
    if (n%2==0)
        cout << n / 2 << endl;
        else
            cout << n / 2 + 1 << endl;
}

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

int n, t, a, h[1010];
int main()
{
    std::cin >> n >> t >> a;
    for (int i = 0; i < n; ++i)
        std::cin >> h[i];
    double res = 10000000000000;
    double ans;
    for (int i = 0; i < n; ++i)
    {
        double tmp = a - (t - h[i] * 0.006);
        if (tmp < 0)
            tmp *= -1;
        if (res > tmp)
        {
            res = tmp;
            ans = i + 1;
        }
    }

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


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
As=[0]*(10**6 + 1)
for i in range(N): 
    As[A[i]]+=1
count=N
for i in range(1,10**6 + 1):
    if As[i]:
        for j in range(i*2,10**6 + 1,i):
            if As[j]:
                count-=As[j]
                As[j]=0
for i in range(1,10**6 + 1):
    if As[i]>1:
        count-=As[i]
print(count)

Measured memory_bytes: 32376
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int LL;
LL s[205];

LL check(LL t){
	LL m[5];
	m[0]=0,m[1]=1e9+7;
	while(m[1]-m[0]>1LL){
		m[2]=(m[0]+m[1])/2LL;
		if(t>m[2]*m[2])m[0]=m[2];
		else m[1]=m[2];
	}
	return m[0];
}

int main(){
	int n;
	LL a,b,c;
	int i;
	LL sa=0;
	LL p;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		if(a==1 && b==1){
			s[i]=0;
			continue;
		}
		p=a*b;
		sa=check(p);
		s[i]=sa*2LL-1LL;
		if(a>b){c=a;a=b;b=c;}
		if(a<=sa)s[i]--;
		if((p-1LL)/sa>sa)s[i]++;
	}
	for(i=0;i<n;i++){
		cout<<s[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			int x = sc.nextInt();
			int t = sc.nextInt();
			
			System.out.println((n+x-1)/x*t);
			
	    }
				
	}
	


Measured memory_bytes: 35728
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stdlib.h>
#include <functional>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
using namespace std;
const int N = 5e5 + 10;
const int mod = 1e9 + 7;
int n, m;
int rcnt[2];
int lcnt[2];

int main()
{
	int i, j, k, x, y, u, v, num, t, test;
	string s;
	cin >> n >> s;

	for (i = 0; i < n; ++i) {
		if (s[i] == 'W') rcnt[0]++;
		else rcnt[1]++;
	}



	int mini = INF;
	for (i = 0; i < n; ++i) {
		if (s[i] == 'W') rcnt[0]--;
		else rcnt[1]--;
		mini = min(mini, lcnt[0] + rcnt[1]);
		if (s[i] == 'W') lcnt[0]++;
		else lcnt[1]++;
	}
	printf("%d\n", mini);
}

Measured memory_bytes: 900
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc044/tasks/abc044_b

"""
import sys
from sys import stdin
from collections import Counter
input = stdin.readline


def solve(w):
    is_beautiful = True
    alphabets = list(w)
    for _, c in Counter(alphabets).most_common():
        if c % 2 != 0:
            is_beautiful = False
            break
    if is_beautiful:
        return 'Yes'
    else:
        return 'No'


def main(args):
    w = input().strip()
    ans = solve(w)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  long long i, Minimum = 1000000000000, N;
  cin >> N;
  
  for (i = 1; i * i <= N; i++){
   if (N % i == 0 && N / i - i - 2 < Minimum){ 
      
     Minimum = N / i + i - 2;
   }
  }
  cout << Minimum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
	int n, c, i, j, a, x, y, N, W, H, map[101][101] = {{0}};
	scanf("%d %d %d", &W, &H, &N);
	for ( n = 0; n < N; n++ ){
		scanf("%d %d %d", &x, &y, &a);
		if ( a == 1 ){
			for ( i = 0; i < x; i++ ){
				for ( j = 0; j < H; j++ ){
					map[i][j] = 1;
				}
			}
		} else if ( a == 2 ){
			for ( i = x; i < W; i++ ){
				for ( j = 0; j < H; j++ ){
					map[i][j] = 1;
				}
			}
		} else if ( a == 3 ){
			for ( i = 0; i < W; i++ ){
				for ( j = 0; j < y; j++ ){
					map[i][j] = 1;
				}
			}
		} else if ( a == 4 ){
			for ( i = 0; i < W; i++ ){
				for ( j = y; j < H; j++ ){
					map[i][j] = 1;
				}
			}
		}
	}
	for ( c = 0, i = 0; i < W; i++ ){
		for ( j = 0; j < H; j++ ){
				fprintf(stderr, "%c", map[i][j]==0?'-':'*');
			if ( map[i][j] == 0 ){
				c++;
			}
		}
		fprintf(stderr, "\n");
	}
	printf("%d\n", c);
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = map(int, read().split())

    X = [x - A for x in X]
    base = 2500
    dp = [[0] * 5001 for _ in range(N + 1)]
    dp[0][base] = 1

    for i in range(N):
        for s in range(5001):
            dp[i + 1][s] = dp[i][s]
            if 0 <= s - X[i] <= 5000:
                dp[i + 1][s] += dp[i][s - X[i]]

    print(dp[N][base] - 1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 67136
import java.util.Scanner;
 
public class Main {
	static Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		int W = in.nextInt(), a = in.nextInt(), b = in.nextInt();
		if(b <= a + W && a <= b + W){
			System.out.println(0);
		}else{
			if(a < b){
				System.out.println(b - a - W);
			}else{
				System.out.println(a - b - W);
			}
		}
	}
}

Measured memory_bytes: 23124
(function(input) {
    var p = input.split('\n');
    var n = p.shift();
    var a = p.shift().split(' ', n);
    var c1 = [].concat(a);
    var c2 = [].concat(a);
    sortBubble(c1);
    console.log(check(c1, a) ? 'Stable' : 'Not stable');
    sortSelection(c2);
    console.log(check(c2, a) ? 'Stable' : 'Not stable');
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function getNumber(a) {
    return Number(a.slice(1, a.length));
}

function getWords(a, n) {
    var r = '';
    for (var i = 0; i < a.length; i++) {
        if (getNumber(a[i]) === n) {
            r += a[i];
        }
    }
    return r;
}

function sortBubble(a) {
    var count = 0;
    var flag = true;
    while (flag) {
        flag = false;
        for (var i = a.length - 1; i >= 1; i--) {
            if (getNumber(a[i]) < getNumber(a[i - 1])) {
                var tmp = a[i];
                a[i] = a[i - 1];
                a[i - 1] = tmp;
                flag = true;
                count++
            }
        }
    }
    console.log(a.join(' '));
    //console.log(count);
}

function sortSelection(a) {
    var count = 0;
    for (var i = 0; i < a.length; i++) {
        var min = i;
        for (var j = i; j < a.length; j++) {
            if (getNumber(a[j]) < getNumber(a[min])) {
                min = j;
            }
        }
        if (min !== i) {
            var tmp = a[i];
            a[i] = a[min];
            a[min] = tmp;
            count++;
        }
    }
    console.log(a.join(' '));
    //console.log(count);
}

function check(c, a) {
    var i = 0;
    while (i < a.length) {
        var n = getNumber(c[i]);
        if (getWords(c, n) !== getWords(a, n)) {
            return false;
        }

        i++;
    }
    return true;
}

Measured memory_bytes: 8520
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 7;
const ll mod = 998244353;
ll qpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1)res = res*a%mod;
        a = a*a%mod;
        n>>=1;
    }
    return res;
}
int d[N];
ll cnt[N];

int main()
{
    int n;
    scanf("%d", &n);
    int Max = 0;
    bool flag = 0;
    for(int i=1;i<=n;i++){
        scanf("%d",&d[i]);
        cnt[d[i]]++;
        Max = max(Max, d[i]);
        if(i > 1 && d[i] == 0)flag = 1;
    }
    if(d[1] != 0 || flag){
        puts("0");
        return 0;
    }
    ll ans = 1;
    for(int i=2;i<=Max;i++){
        ans = ans * qpow(cnt[i-1], cnt[i]) % mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 5120
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func left(i int) int {
	return 2 * i
}

func right(i int) int {
	return 2*i + 1
}

func maxHeapify(A []int, i int) {
	l := left(i)
	r := right(i)
	N := len(A) - 1
	largest := i
	if l <= N && A[l] > A[i] {
		largest = l
	}
	if r <= N && A[r] > A[largest] {
		largest = r
	}
	if largest != i {
		A[i], A[largest] = A[largest], A[i]
		maxHeapify(A, largest)
	}
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := make([]int, N+1)
	for i := 1; i <= N; i++ {
		A[i] = sc.nextInt()
	}
	for i := N / 2; i >= 1; i-- {
		maxHeapify(A, i)
	}

	for i := 1; i <= N; i++ {
		fmt.Fprint(wtr, " ", A[i])
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}



Measured memory_bytes: 10028
n, x = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * (n+1)
for i in range(n):
  l[i+1] = l[i] + a[i]
ans = 0
for i in l:
  if i <= x:
    ans += 1
print(ans)

Measured memory_bytes: 9176