akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

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

	string ans = "";
	while(n > 0){
		char x = 'a' + (n - 1) % 26;
		n -= 1;
		n /= 26;
		ans = x + ans;
	}
	print(ans)
	return 0;
}

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



int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int len=s.size();
    for(int i=0;i<len;i++)
    {
        int num=s[i]+n;
        if(num>90)
        {
           num=num-90;
           num+=64;
        }
        cout<<(char)num;
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
//AtCoderC++.cpp

using namespace std;


inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}
int count_digit(int n) {
	auto count = 0;
	while (n > 0) {
		++count;
		n /= 10;
	}
	return count;
}

int main() {
	int N; cin >> N;
	auto answer = 0;
	for (size_t i = 1; i <= N; i++) {
		if (count_digit(i) % 2 != 0)++answer;
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
count=0
for i in range(len(A)):
  if A[i]%2==0:
    if A[i]%3==0 or A[i]%5==0:
      count+=1
  else:
    count+=1
if count==len(A):
  print("APPROVED")
else:
  print("DENIED")

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

#define MAX 1000000000

int main(void){
    long long N, K;
    vector<long long> A;
    int a;

    cin >> N >> K;
    for(int i = 0; i < N; ++i){
        cin >> a;
        A.push_back(a);
    }

    long long max = MAX + 1;
    long long min = 0;
    long long mid;
    int d, CountCut;
    while(max - min > 1){
        CountCut = 0;
        mid = (max + min) / 2;
        for(int i = 0; i < N; ++i){
            d = (A[i] - 1) / mid;
            if(d > 0) CountCut += d;
        }
        if (CountCut <= K) max = mid;
        else min = mid;
    }

    cout << max << endl;
}

Measured memory_bytes: 5308
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <bitset>

using namespace std;
typedef long long LL;
const int maxn = 2005;
char g[maxn][maxn];int n,m,ans;
int e[maxn][maxn],p[maxn][maxn];
int l[maxn],r[maxn],a[maxn],cov[maxn],ord[maxn];

bool comp(int x,int y) {return a[x]>a[y];}
int main()
{
	#ifdef Amberframe
		freopen("arc081f.in","r",stdin);
		freopen("arc081f.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);ans=max(n,m);
	for (int i=1;i<=n;i++) scanf("%s",g[i]+1);
	for (int i=2;i<=n;i++) ord[i]=i;
	for (int i=2;i<=n;i++)
	for (int j=2;j<=m;j++)
		e[i][j]=(g[i][j]^g[i][j-1]^g[i-1][j]^g[i-1][j-1])==0;
	for (int i=2;i<=n;i++)
	for (int j=m;j>=2;j--)
		p[i][j]=e[i][j]?p[i][j+1]+1:0;
	
	for (int j=2;j<=m;j++)
	{
		for (int i=2;i<=n;i++)
			cov[i]=0,l[i]=r[i]=0,a[i]=p[i][j];
		sort(ord+2,ord+n+1,comp);
		
		for (int i=2;i<=n;i++)
		{
			int x=ord[i],L=x,R=x;cov[x]=true;
			if (cov[x-1]) L=l[x-1];
			if (cov[x+1]) R=r[x+1];
			r[L]=R;l[R]=L;ans=max(ans,(a[x]+1)*(R-L+2));
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;int N,a,b,i,V[1<<20],f[1<<20];pair<int,int>R[1<<20];main(){for(cin>>N;i<N;cin>>a>>b,R[i]={a,a+b},i++);for(sort(R,R+N),V[N]=1;i--;V[i]=(V[i+1]+V[f[i]=a])%998244353)for(a=i+1;a<N&&R[a].first<R[i].second;a=f[a]);cout<<*V;}

Measured memory_bytes: 5888
N, A, B = map(int, input().split())

def digsum(n):
  s = str(n)
  sum = 0
  for i in range(len(s)):
    sum += int(s[i])
  return sum

sum = 0
for i in range(1, N+1):
  tmp = digsum(i)
  if tmp >= A and tmp <= B:
    sum += i
print(sum)


Measured memory_bytes: 2940
n = int(input())
sl = list(input())

w = [0]
e = []
w_tmp = 0
e_tmp = 0
for s in sl:
    if s == "W":
        w_tmp += 1
    else:
        e_tmp += 1
    w.append(w_tmp)
    e.append(e_tmp)

ans = float("inf")
for i in range(n):
    tmp = w[i] + e[-1] - e[i]
    if ans > tmp:
        ans = tmp

print(ans)

Measured memory_bytes: 95392
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::BinaryHeap;

struct Dijkstra {
    pub edges: Vec<Vec<(usize, i64)>>,
    pub start: usize,
}

impl Dijkstra {
    fn get_shortest_path(&self) -> Vec<i64> {
        let node_num = self.edges.len();
        assert!(self.start < node_num, "invalid start node");

        let mut pque: BinaryHeap<(i64, usize)> = BinaryHeap::new();
        let mut distance = vec![std::i64::MAX; node_num];

        pque.push((0, self.start));
        distance[self.start] = 0;

        while !pque.is_empty() {
            let (min_distance, idx) = pque.pop().unwrap();
            if distance[idx] < -min_distance { continue; }
            for i in 0..self.edges[idx].len() {
                let (to, cost) = self.edges[idx][i];
                let new_cost = distance[idx] + cost;
                if distance[to] > new_cost {
                    distance[to] = new_cost;
                    pque.push((-new_cost, to));
                }
            }
        }

        distance
    }
}

#[allow(unused_mut)]
fn main() {
    input!(
        v: usize,
        e: usize,
        r: usize,
        std: [(usize, usize, i64); e],
    );
    let mut dj = Dijkstra {
        edges: vec![Vec::new(); v],
        start: r,
    };

    for &(s,t,d) in std.iter() {
        dj.edges[s].push((t, d));
    }

    let distance = dj.get_shortest_path();
    for (_, d) in distance.iter().enumerate() {
        if *d == std::i64::MAX {
            println!("INF");
        }
        else {
            println!("{}", d);
        }
    }
}


Measured memory_bytes: 43880
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve(){
	int n,s=0,t=0,b=10000000; cin>>n; int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		s+=a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		t+=a[i];
		s-=a[i];
		b=min(b,abs(s-t));
	}
	cout<<b;
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (k >= s.size()) {
        cout << s << endl;
    } else {
        int l = s.size() - k;
        rep(i, l) {
            s.pop_back();
        }
        s += "...";
        cout << s << endl;
    }
}

Measured memory_bytes: 3600
import sys
from sys import stdin

n, m, k = map(int, stdin.readline().rstrip().split())
ans = 0
for i in range(n+1):
    for j in range(m+1):
        if i * m + j * n - i * j * 2 == k:
            print("Yes")
            sys.exit()

print('No')

Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define NO {puts("0");return 0;}
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=1e5+_;
const int mod=1e9+7;
inline int ad(int x,int y){return x>=mod-y?x-mod+y:x+y;}
inline int re(int x,int y){return x<y?x-y+mod:x-y;}
inline int mu(int x,int y){return (LL)x*y%mod;}
inline int qp(int x,LL y){int r=1;while(y){if(y&1)r=mu(r,x);x=mu(x,x);y>>=1;}return r;}
inline int iv(int x){return qp(x,mod-2);}
inline int dv(int x,int y){return mu(x,qp(y,mod-2));}
inline int gcd(int x,int y){return x?gcd(y%x,x):y;}

int fac[maxn],fac_inv[maxn],Bin[maxn];
int C(int n,int m){return mu(fac[n],mu(fac_inv[m],fac_inv[n-m]));}
void yu()
{
	fac[0]=Bin[0]=1;for(int i=1;i<maxn;i++)fac[i]=mu(fac[i-1],i),Bin[i]=ad(Bin[i-1],Bin[i-1]);
	fac_inv[maxn-1]=iv(fac[maxn-1]);
	for(int i=maxn-2;i>=0;i--)fac_inv[i]=mu(fac_inv[i+1],i+1);
}

int n,ans,to[maxn],du[maxn];
int num[maxn],v[maxn];
int main()
{
	yu();
	scanf("%d",&n); ans=1;
	for(int i=1;i<=n;i++)
		scanf("%d",&to[i]),du[to[i]]++;
	
	for(int i=1;i<=n;i++)
		if(du[i]==0)
		{
			v[i]++; int c=1,x=to[i];
			while(du[x]==1)v[x]++,c++,x=to[x];
			if(v[x])NO v[x]++;
			num[x]=c;
		}
	for(int i=1;i<=n;i++)
		if(du[i]==2&&v[i]==1)
		{
			v[i]++; int c=1,x=to[i];
			while(x!=i)
			{
				v[x]++;
				if(num[x])
				{
					if(c<num[x])NO
					if(c>num[x])ans=ad(ans,ans);
					c=0;
				}
				c++;x=to[x];
			}
			if(c<num[i])NO
			if(c>num[i])ans=ad(ans,ans);
		}
	
	memset(num,0,sizeof(num));
	for(int i=1;i<=n;i++)
		if(du[i]==1&&!v[i])
		{
			v[i]=true; int x=to[i],c=1;
			while(x!=i)v[x]=true,c++,x=to[x];
			num[c]++;
		}
	for(int i=1;i<=n;i++)
		if(num[i])
		{
			int sum=0,inv2=mod/2+1;
			for(int j=0,t=1,inv=1;j+j<=num[i];j++,t=mu(t,i),inv=mu(inv,inv2))
				sum=ad(sum, mu( ((i&1)&&i!=1)?Bin[num[i]-2*j]:1 , mu(t,mu(mu(C(num[i],2*j),inv),mu(fac[2*j],fac_inv[j]))) ) );
			ans=mu(ans,sum);
		}

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

	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <sstream>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int m,num[7],val[7],n,solve;

void dfs(int sum,int pos){

	if(sum == n && pos == m)solve++;

	if(sum > n || pos >= m)return;
	
	for(int i=0;i<=val[pos];i++){
		dfs(sum+(i*num[pos]) , pos+1);
	}
}
int main(){
	while(cin >> m ,m){
		rep(i,m){
			int a,b;
			cin >> num[i] >> val[i];
		}
		
		int g; cin >> g;
		rep(i,g){
			cin >> n;
			solve = 0 , dfs(0,0);
			cout << solve << endl;
		}
	}
}

Measured memory_bytes: 868
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

typedef pair<double, double> P;

int cross(P a, P b, P c) {
  int x0 = b.first - a.first, y0 = b.second - a.second;
  int x1 = c.first - a.first, y1 = c.second - a.second;
  return x0*y1 - x1*y0;
}

vector<P> convex_hull(vector<P> ps) {
  sort(ps.begin(), ps.end());
  int n = ps.size();
  vector<P> qs(2*n);
  int k = 0;
  for(int i=0; i<n; ++i) {
    while(k>1 && cross(qs[k-2], qs[k-1], ps[i])<=0) --k;
    qs[k++] = ps[i];
  }
  int t = k;
  for(int i=n-1; i>=0; --i) {
    while(k>t && cross(qs[k-2], qs[k-1], ps[i])<=0) --k;
    qs[k++] = ps[i];
  }
  qs.resize(k);
  return qs;
}

int main() {
  int n;
  while(cin >> n && n) {
    vector<P> ps, qs;
    for(int i=0; i<n; ++i) {
      double x, y; char dum;
      cin >> x >> dum >> y;
      ps.push_back(P(x, y));
    }
    qs = convex_hull(ps);
    cout << (n - qs.size() + 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
lim = 1000000000000000000
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    if a[i] == 0:
        print(0)
        exit()

ans = 1
for i in range(n):
    ans *= a[i]
    if ans > lim:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21792
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	string s;
	cin >> s;
	vector<int> a(4);
	rep(i,4) a[i] = s[i]-'0';

	for(int bit = 0; bit<(1<<3); bit++){
		string t = to_string(a[0]);
		int sum = a[0];
		for(int i = 0; i<3; i++){
			if(bit&(1<<i)){
				sum+=a[i+1];
				t+=("+" + to_string(a[i+1]));
			}else{
				sum-=a[i+1];
				t+=("-" + to_string(a[i+1]));
			}
		}

		if(sum == 7){
			cout << t << "=7" <<endl;
			return 0;
		}
	}


	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  int ans = 1000000;
  rep(i, n) {
    int t1 = 0, t2 = 0;
    for(int j = 0; j <= i; j++) t1 += a[j];
    for(int j = i + 1; j < n; j++) t2 += a[j];
    ans = min(ans, abs(t1 - t2));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int x;
            cin>>x;
            cout<<1-x<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
int main(int argc, char const *argv[]) {
    int N;std::cin >> N;
    int sum=0;
    int s;
    int min=10000;
    for (size_t i = 0; i < N; i++) {
        std::cin >> s ;
        sum+=s;
        if (s%10!=0 && s< min) {
            min=s;
        }
    }
    if (sum%10!=0) {
        std::cout << sum << '\n';
    }else if(min!=10000){
        std::cout << sum-min << '\n';
    }else{
        std::cout << 0 << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  vector<ll> b(n+1, 0);
  map<ll, ll> mp;
  mp[0]++;
  REP(i, n){
    b[i+1] = (a[i]+b[i])%m;
    mp[b[i+1]]++;
  }
  ll ans = 0;
  for(auto p : mp){
    ans += p.second*(p.second-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#define MOD 1000000007

using namespace std;

int n;
vector<vector<long long> > m;

vector<vector<long long> > init() {
    vector<vector<long long> > mat2(50, vector<long long>(50, 0));
    for (int i = 0; i < 50; i++) mat2[i][i] = 1;
    return mat2;
}

void mm(vector<vector<long long> > &a, vector<vector<long long> > &b, vector<vector<long long> > &c) {
    vector<vector<long long> > mat2 = init();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            mat2[i][j] = 0;
            for (int k = 0; k < n; k++) {
                mat2[i][j] += a[i][k] * b[k][j];
                mat2[i][j] %= MOD;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) c[i][j] = mat2[i][j];
    }
}

vector<vector<long long> > me(long long a) {
    vector<vector<long long> > mat2 = init();
    while (a) {
        if (a % 2) { mm(mat2, m, mat2); a--; }
        else { mm(m, m, m); a /= 2; }
    }
    return mat2;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n; long long k; cin >> k;
    m = init();
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> m[i][j];
    vector<vector<long long> > mev = me(k);
    long long ans = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
        ans += mev[i][j];
        ans %= MOD;
    }
    cout << ans;
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

ll N;
string S;
ll ans = 0;

void dfs(ll count, ll now, ll total){
    if(count == N){
        // cout << total + now << endl;
        ans = ans+total+now;
    }
    else{
        ll a = S[count]-'0';
        dfs(count+1, a, total+now);
        dfs(count+1, now*10+a, total);
    }
}

int main()
{
    cout << fixed << setprecision(15);
    cin >> S;

    N = S.length();
    dfs(1, S[0]-'0', 0);

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int a[50], b[50], c[50], d[50];
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < m; i++){
    cin >> c[i] >> d[i];
  }
  for(int i = 0; i < n; i++){
    int min = 1000000000;
    int minn;
    for(int j = 0; j < m; j++){
      int dif = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(dif < min){
        min = dif;
        minn = j + 1;
      }
    }
    cout << minn << endl;
  }
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n, x, t; cin >> n >> x >> t;
    int res;
    if(n % x == 0) res = n/x;
    else res = n/x+1;
    cout << res * t << endl;
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int t = cin.Int();
			var ab = new Tuple<int, int>[n];
			for (int i = 0; i < n; i++) {
				int a = cin.Int();
				int b = cin.Int();
				ab[i] = new Tuple<int, int>(a, b);
			}

			Array.Sort(ab, (x, y) => x.Item1.CompareTo(y.Item1));

			int[,] dp = new int[n + 1, t + 1];

			for (int i = 0; i < n; i++) {
				for (int j = 0; j <= t; j++) {
					if (j + ab[i].Item1 > t) {
						if (j != t) {
							dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j]);
							dp[i + 1, t] = Math.Max(dp[i + 1, t], dp[i, j] + ab[i].Item2);
						} else {
							dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j]);
						}
					} else {
						dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j]);
						dp[i + 1, j + ab[i].Item1] = Math.Max(dp[i + 1, j + ab[i].Item1] , dp[i, j] + ab[i].Item2);
					}
				}
			}

			int ans = 0;
			int temp1 = dp[n, t];
			int temp2 = dp[n, t - 1];
			int temp = Math.Max(temp1, temp2);

			ans = Math.Max(ans, temp);

			Console.WriteLine(ans);
		}
	}



	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 48224
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<pair<int, int>> A(n);
   vector<int> x,y;
   for(int i = 0; i < n; ++i){
      cin >> A[i].F >>  A[i].S;
      x.push_back(A[i].F-A[i].S);
      y.push_back(A[i].F+A[i].S);
   }
   sort(all(x));
   sort(all(y));
   cout << max(x.back()-x.front(),y.back()-y.front());
   return 0;
}

Measured memory_bytes: 9812
#include <stdio.h>
#include <cassert>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <sstream>
#include <cstring>
using namespace std ;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)

#define sc1(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y)
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)

#define scll1(x) scanf("%lld",&x)
#define scll2(x,y) scanf("%lld%lld",&x,&y)
#define scll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)

#define pr1(x) printf("%d\n",x)
#define pr2(x,y) printf("%d %d\n",x,y)
#define pr3(x,y,z) printf("%d %d %d\n",x,y,z)

#define prll1(x) printf("%lld\n",x)
#define prll2(x,y) printf("%lld %lld\n",x,y)
#define prll3(x,y,z) printf("%lld %lld %lld\n",x,y,z)

#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const int mod = 1e9 + 7;

int ADD(int a, int b, int m = mod) {
    int s = a;
    s += b;
    if( s >= m )
      s -= m;
    return s;
}

int MUL(int a, int b, int m = mod) {
    return (1LL * a * b % m);
}

int power(int a, int b, int m = mod) {
    int res = 1;
    while( b ) {
        if( b & 1 ) {
            res = 1LL * res * a % m;
        }
        a = 1LL * a * a % m;
        b /= 2;
    }
    return res;
}

ll nC2(ll x) {
    return ( x * ( x - 1 ) / 2 );
}
const int maxn = 2 * 1000000 + 10;
int C[maxn], B[maxn];
int main() {
    int n; cin >> n;
    vii A;
    int i;
    bool ok = true;
    fr(i, 1, n) {
        int x; cin >> x;
        B[i] = x;
        if(B[1]) ok = false;
        if(i != 1 && B[i] - B[i-1] > 1) ok = false; 
        A.pb(mp(x, -1 * i));
    }
    sort(all(A));
    if(!ok) cout << -1 << "\n";
    else {
        // bool ok = true;
        ll ans = 0;
        for( auto it: A ) {
            int idx = -1 * it.sd;
            ans +=  it.ft - C[idx-1];
            C[idx] = it.ft;
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 6768
from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 6)


def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n - 2)


def solve(N):
    result = f(N)
    count = 0
    for x in str(result)[::-1]:
        if x == '0':
            count += 1
        else:
            break
    return count


def solve2(N):
    if N % 2 == 1:
        return 0
    if N == 0:
        return 0

    a = N // 50
    b = N // 10

    ans = a + b

    for i in range(2, 100000000000):
        x = (5 ** i) * 10
        y = N // x
        if y == 0:
            break
        ans += y

    return ans

    # c = N // 250
    # d = N // 1250
    # e = N // 6250
    # return b + a + c + d + e


def main():
    N = int(stdin.readline().rstrip())
    result = solve2(N)
    print(result)

    # result = solve(N)
    # print(result)

    # ans = []
    # for x in range(1, 300):
    #     result = solve(x)
    #     ans.append((x, result))

    # for x in ans:
    #     a, b = x
    #     print(a, b)

    # current = 0
    # count = 0
    # for x in ans:
    #     a, b = x
    #     if a % 2 == 1:
    #         continue
    #     if b == current:
    #         count += 1
    #     elif b == current + 1:
    #         print(current, count)
    #         current = b
    #         count = 0
    #     else:
    #         print(current, count)
    #         print(current + 1, 0)
    #         current = b
    #         count = 0


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;

int GetDigit(int n){
	int digit=0;
	while(true){
		if(n==0) break;
		n/=10;
		digit+=1;
	}
	return digit;
}

int ReverseDigits(int n){
	int reverse=0;
	int keta=GetDigit(n);
	while(true){
		if (n==0) break;
		reverse+=n%10*pow(10,keta-1);
		keta-=1;
		n/=10;
	}
	return reverse;
}

int main(){
	int A,B;
	int ans=0;
	cin>>A>>B;
	for (int i=A;i<=B;i++){
		if (i==ReverseDigits(i)) ans+=1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
/* ex3_2
   moka223711 */

#include <stdio.h>

int main(void){
  int N, K, i = 1;
  scanf("%d %d", &N, &K);
  
  // NがK^i以上のとき、K進法はi桁で表せる
  // NをKで割り続けて何回割れるかをiでカウントする
  while(N >= K){
    N /= K;
    i++;
  }
  
  printf("%d", i);
  
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] argv){

        Scanner scan = new Scanner(System.in);

        String ss = scan.nextLine();
        String t = scan.nextLine();

        StringBuilder s = new StringBuilder(ss);

        boolean already = false;

    for (int i = s.length() - t.length(); i >= 0 && !already; i--) {


        boolean possible = true;

        for (int j = 0; j < t.length() && possible; j++) {

            if (s.charAt(i + j) != t.charAt(j) && s.charAt(i + j) != '?') {
                possible = false;
            }
        }

        if (possible) {
            for (int j = 0; j < t.length(); j++) {
                s.setCharAt(i + j, t.charAt(j));
            }
            already = true;
        }

    }


    // ? -> a
    if (already) {
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '?') {
                s.setCharAt(i, 'a');
            }
        }
        System.out.println(s);
    } else {
        System.out.println("UNRESTORABLE");
    }



    }

}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
 
int main(){
    ll n,m ;
    cin >> n >> m;
    vector<ll> g[n];
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        g[a].pb(b);
    }
    ll d[n][3];
    ll visit[n][3];
    rep(i,n) rep(j,3) {
        d[i][j]=inf;
        visit[i][j]=false;
    }
    
    queue<Pair> que;//頂点とどの段階か
    ll s,t;
    cin >> s >> t;
    s--;t--;
    que.push(make(s,0));
    d[s][0]=0;
    
    while(!que.empty()){
        Pair ima=que.front();
        que.pop();
        visit[ima.first][ima.second]=true;
        for(ll b : g[ima.first]){
            ll modit=(ima.second+1)%3;
            if(d[b][modit]!=inf) continue;
            else{
                d[b][modit]=d[ima.first][ima.second]+1;
                que.push(make(b,modit));
            }
        }
    }
    if(d[t][0]==inf) {kaku(-1);}
    else{kaku(d[t][0]/3);}
}



Measured memory_bytes: 10368
n = int(input())
a = list(map(int, input().split()))

c = [0, 0, 0]
ans = 1
for i in range(n):
    count = 0
    for j in range(3):
        if a[i] == c[j]:
            if count == 0:
                c[j] += 1
            count += 1
    ans = ans * count % 1000000007
print(ans)

Measured memory_bytes: 52952
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int m,n;
 
  while(cin>>m>>n,m+n){
 int cnt=0;
  int now=m;
      bool flag[7368800]={};
      while(cnt!=n){
	while(flag[now])now++;
	for(int i=now;i<7368792;i+=now)
	  flag[i]=true;
	cnt++;
      }
      for(int i=now;;i++)
	if(flag[i]==false){cout<<i<<endl;break;}
  }
  return 0;
}



Measured memory_bytes: 10296
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll n, ans;
ll dp_1[80], dp_2[80], dp_3[80], dp_4[80];

ll gv_naive(ll T)
{
	ll i, j, ret=0;
	for(i=0 ; i<=T ; i++)
		for(j=0 ; j<=min(i,T-i) ; j++)
			if((i&j)==j) ret++;
	return ret;
}

int main(void)
{
	cin>>n; ll i, j, u, v, w;
	dp_1[0]=1; dp_2[0]=1; dp_3[0]=1; dp_4[0]=1;
	for(i=1 ; i<=61 ; i++)
	{
		u=(1LL<<(i-1)); v=(1LL<<i); w=(1LL<<(i+1));
		if(!(n&u)) dp_1[i]=dp_1[i-1];
		if(n&u) dp_1[i]=(dp_1[i-1]+dp_2[i-1])%mod;
		if(!(n&v)) dp_2[i]=dp_1[i];
		if(n&v) dp_2[i]=(dp_3[i-1]+dp_4[i-1]+dp_2[i-1])%mod;
		dp_3[i]=(3LL*dp_3[i-1])%mod;
		if(!(n&v)) dp_4[i]=(dp_2[i-1]+dp_4[i-1]+dp_3[i-1])%mod;
		if(n&v) dp_4[i]=dp_3[i];
	}
	cout<<dp_1[61]%mod;
	return 0;
}

// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
#define print(x) cout<<'>'<<#x<<':'<<x<<endl;
#define F first
#define S second
const int mod=1000000007;

void solve(){
    int n;
    cin>>n;
    int a[n],b[n];
    for (int i=0;i<n;i++)cin>>a[i];
    for (int i=0;i<n;i++)cin>>b[i];
    int p[n];
    p[0]=a[0];
    for (int i=1;i<n;i++){
        p[i]=p[i-1]+a[i];
    }int s[n];
    s[n-1]=b[n-1];
    for (int i=(n-2);i>=0;i--){
        s[i]=s[i+1]+b[i];
    }int m=0;
    for (int i=0;i<n;i++){
        m=max(p[i]+s[i],m);
    }cout<<m<<endl;
}

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

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int y,m,d;
while(cin>>y){
cin>>m;
cin>>d;
if(y>1989||(y==1989&&((m>1)||(d>7)))){
cout<<"heisei "<<y-1988<<" "<<m<<" "<<d<<endl;
}else if(y>1926||(y==1926&&(m==12&&d>24))){
cout<<"showa "<<y-1925<<" "<<m<<" "<<d<<endl;
}else if(y>1912||(y==1912&&(m>7||d>29))){
cout<<"taisho "<<y-1911<<" "<<m<<" "<<d<<endl;
}else if(y>1868||(y==1868&&(m>9||d>7))){
cout<<"meiji "<<y-1867<<" "<<m<<" "<<d<<endl;
}else{
cout<<"pre-meiji"<<endl;
}
}
return 0;
}

Measured memory_bytes: 1164
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static int N;
    private static int K;
    private static int L;

    public static void main(String[] args) {
	N = Integer.parseInt(scan.next());
	K = Integer.parseInt(scan.next());
	L = Integer.parseInt(scan.next());

	UnionFind k = new UnionFind(N);
	UnionFind l = new UnionFind(N);
	
	for (int i = 0; i < K; i++) {
	    int p = Integer.parseInt(scan.next()) - 1;
	    int q = Integer.parseInt(scan.next()) - 1;
	    k.connect(p, q);
	}
	for (int i = 0; i < L; i++) {
	    int r = Integer.parseInt(scan.next()) - 1;
	    int s = Integer.parseInt(scan.next()) - 1;
	    l.connect(r, s);
	}

	Map<Pair, Integer> map = new HashMap<Pair, Integer>(N);
	for (int i = 0; i < N; i++) {
	    Pair p = new Pair(k.root(i), l.root(i));
	    if(map.containsKey(p)) {
		int count = map.get(p).intValue();
		map.put(p, count+1);
	    } else {
		map.put(p, 1);
	    }
	}

	for (int i = 0; i < N; i++) {
	    if(i>0) System.out.print(' ');
	    Pair p = new Pair(k.root(i), l.root(i));
	    System.out.print(map.get(p).intValue());
	}
	System.out.println();
	scan.close();
    }

    private static class UnionFind {
	int[] uni;

	public UnionFind(int N) {
	    uni = new int[N];
	    for (int i = 0; i < N; i++) {
		uni[i] = -1;
	    }
	}

	public int root(int a) {
	    if(uni[a] < 0) return a;
	    else return uni[a] = root(uni[a]);
	}

	public boolean connect(int a, int b) {
	    a = root(a);
	    b = root(b);

	    if(a == b) return false;
	    if(uni[a] > uni[b]) {
		int tmp = a;
		a = b;
		b = tmp;
	    }
	    uni[a] += uni[b];
	    uni[b] = a;
	    return true;
	}
    }

    private static class Pair implements Comparable<Pair>{
	private final int x;
	private final int y;

	public Pair(int x, int y) {
	    this.x = x;
	    this.y = y;
	}

	@Override
	public boolean equals(Object obj) {
	    if(obj instanceof Pair) {
		Pair p = (Pair)obj;
		return this.x == p.x && this.y == p.y;
	    } else {
		return false;
	    }
	}

	@Override
	public int hashCode() {
	    return Objects.hash(x, y);
	}

	@Override
	public int compareTo(Pair p) {
	    if(this.x == p.x) return this.y - p.y;
	    else return this.x - p.x;
	}
    }
}


Measured memory_bytes: 107560
x, y = map(int,input().split())

ans = abs(abs(x)-abs(y))
if x * y > 0 and y >= x:
    pass
elif x * y < 0:
    ans += 1
elif x * y == 0:
    if x > y:
        ans += 1
else:
    ans += 2
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#include <array>
#include <time.h>
#include <limits.h>
#pragma comment(lib, "winmm.lib")
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
using namespace std;

vector<int> W(101);
vector<int> V(101);
int n, sum;
int memo[101][10001];

int dp(int x, int w){
	if (memo[x][w] != -1) return memo[x][w];

	if (x == n) return 0;
	if (w - W[x] < 0) return dp(x + 1, w);

	return memo[x][w] = max(dp(x + 1, w), dp(x + 1, w - W[x]) + V[x]);
}

void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif


	cin >> n >> sum;
	rep(i, n) cin >> V[i] >> W[i];
	rep(i, 101) rep(j, 10001) memo[i][j] = -1;
	
	cout << dp(0, sum) << endl;

}

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

	solve();
	return 0;
}

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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

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

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    char prev = s[0];
    for(int i = 1; i < s.size(); i++) {
        ans += (prev != s[i]);
        prev = s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main()
{
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  rep(i, N) cin >> m[i];
  cout << N + (X - accumulate(all(m), 0)) / *min_element(all(m)) << endl;
}

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

int main()
{
	int64_t n, mod = 1000000007;
	cin >> n;
	vector<vector<int>> as(n, vector<int>(n));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> as[i][j];
		}
	}
	vector<vector<int64_t>> dp(1 << n, vector<int64_t>(n + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < (1 << n); i++)
	{
		int j = __builtin_popcount(i);
		for (int k = 0; k < n; k++)
		{
			if ((i >> k) & 1)
			{
				continue;
			}
			if (as[k][j])
			{
				(dp[i | (1 << k)][j + 1] += dp[i][j]) %= mod;
			}
		}
	}
	cout << dp[(1 << n) - 1][n] << endl;
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc = 1;
  // cin >> tc;
  while(tc--) {
    int b[3][3];
    for(int i = 0; i < 3; ++i)for(int j = 0; j < 3; ++j)cin >>b[i][j];
    int n, x;
    cin >> n;
    while(n--) {
      cin >> x;
      for(int i = 0; i < 3; ++i)for(int j = 0; j < 3; ++j)if(x == b[i][j]) {
        b[i][j] = 0;
      }
    }
    vector<int>diag(3,0);
    vector<int>row(3, 0);
    vector<int>col(3, 0);
    diag[2] = 1;
    bool ans = false;
    for(int i = 0; i < 3; ++i)for(int j = 0; j < 3; ++j) {
      row[i] += b[i][j];
      col[j] += b[i][j];
      if(i == j)diag[0]+=b[i][j];
      if(i+j == 2)diag[1]+=b[i][j];
    }
    for(int i = 0; i < 3; ++i) {
      ans |= (row[i] == 0);
      ans |= (col[i] == 0);
      ans |= (diag[i] == 0);
    }
    cout << (ans ? "Yes\n" : "No\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

	
int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	vector<ll> X[3];
	for (ll i = 0; i < N; ++i)
		for (ll j = 0; j < 3; ++j)
		{
			ll num; cin >> num;
			X[j].push_back(num);
		}
	ll res{0};
	for (ll bits = 0; bits < (1 << 3); ++bits)
	{
		vector<ll> b;
		for (ll i = 0; i < N; ++i)
		{
			ll tmp{0};
			for (ll j = 0; j < 3; ++j)
			{
				if (bits & (1 << j)) tmp -= X[j][i];
				else tmp += X[j][i];
			}
			b.push_back(tmp);
		}
		sort(b.begin(), b.end(), greater<ll>());
		ll sum = accumulate(b.begin(), next(b.begin(), M), 0ll);
		res = max(res, sum);
	}
	std::cout << res << std::endl;
}


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

using namespace std;

#define SIDE 4
#define N 16
#define LIMIT 100

struct Board {
  int state[N];
  int zero_pos;
  int md;
};

int DX[4] = { 0, 1, 0, -1 };
int DY[4] = { 1, 0, -1, 0 };
char DIR[4] = { 'u', 'r', 'd', 'l' };

int MDs[N][N];
int path[LIMIT];
Board b;
int limit;

bool dfs(int depth, int prev) {
  if (b.md == 0) return true;
  if (depth + b.md > limit) return false;

  int sx = b.zero_pos / SIDE;
  int sy = b.zero_pos % SIDE;

  Board tmp;

  for (int i = 0; i < 4; i++) {
    int new_x = sx + DX[i];
    int new_y = sy + DY[i];

    if (new_x < 0 || new_x >= SIDE || new_y < 0 || new_y >= SIDE) continue;
    if (max(prev, i) - min(prev, i) == 2) continue;

    tmp = b; // preserve current board

    b.md -= MDs[new_x * SIDE + new_y][b.state[new_x * SIDE + new_y] - 1];
    b.md += MDs[sx * SIDE + sy][b.state[new_x * SIDE + new_y] - 1];

    swap(b.state[sx * SIDE + sy], b.state[new_x * SIDE + new_y]);
    b.zero_pos = new_x * SIDE + new_y;

    if (dfs(depth + 1, i)) {
      path[depth] = i;
      return true;
    }

    b = tmp; // restore current board
  }

  return false;
}

int get_MD_sum(Board in) {
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (in.state[i] == N) continue;
    sum += MDs[i][in.state[i] - 1];
  }
  return sum;
}

void ida(Board in) {
  in.md = get_MD_sum(in);

  for (limit = in.md; limit <= LIMIT; limit++) {
    b = in;
    if (dfs(0, -100)) {
      string ans = "";
      for (int i = 0; i < limit; i++) ans += DIR[path[i]];

      cout << ans.size() << endl;
      return;
    }
  }
}

int main() {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      MDs[i][j] = abs(i / SIDE - j / SIDE) + abs(i % SIDE - j % SIDE);

  Board in; 

  for (int i = 0; i < N; i++) {
    cin >> in.state[i];
    if (in.state[i] == 0) {
      in.state[i] = N;
      in.zero_pos = i;
    }
  }

  ida(in);
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
	}
	ll ans=0;
	rep(k,62){//立ってるビット
		ll cnt=0;
		rep(i,n){
			if(a[i] & 1ll<<k){
				cnt++;
			}
		}
		//cout<<k<<' '<<(1ll <<k)<<endl;
		ll now=(n-cnt)*cnt;
		now%=mod;
		ll now2=(1ll <<k);
		now2%=mod;
		ans+=(now2*now)%mod;
		ans%=mod;
		//cout<<k<<' '<<cnt<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
<?php

fscanf(STDIN, "%s", $str);
 
$len = strlen($str);
$a_count = substr_count($str, 'a');
$b_count = substr_count($str, 'b');
$c_count = substr_count($str, 'c');
 
$arr = [$a_count, $b_count, $c_count];
sort($arr);
 
$max = sprintf("%d", $len / 3);
$mid = sprintf("%d", $len / 3);
$min = sprintf("%d", $len / 3);
 
if (0 == $len % 3) {
} elseif ($len % 3 == 1) {
	$max++;
} else {
	$max++;
	$mid ++;
}
 
if ($arr[2] <= $max
	and $arr[1] <= $mid
	and $arr[0] <= $min) {
	echo 'YES';
} else {
	echo 'NO';
}


Measured memory_bytes: 3828