akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e3 + 10;
int dp[3][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> dp[1][i];
	for (int i = 1; i <= n; i++) cin >> dp[2][i];
	for (int i = 1; i <= 2; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			dp[i][j] += max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	cout << dp[2][n] << endl;
	return 0;
}


Measured memory_bytes: 256
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn solve(_n: usize, a: Vec<u64>) {
    let mut a = a.clone();
    a.dedup();
    let a = a;
    //dbg!(&a);
    let n = a.len();
    let mut assests: (u64, u64) = (1000, 0);
    let mut buy_day = 0;
    while buy_day < n {
        let mut sell_day = buy_day + 1;
        if sell_day >= n {
            break;
        }
        if a[buy_day] > a[sell_day] {
            buy_day += 1;
            continue;
        }
        while sell_day + 1 < n && a[sell_day] < a[sell_day + 1] {
            sell_day += 1;
        }
        //dbg!(buy_day, sell_day);
        let sell_day = cmp::min(n - 1, sell_day);
        //buy
        let new_stock = assests.0 / a[buy_day];
        assests = (assests.0 - new_stock * a[buy_day], new_stock);
        //sell
        assests = (assests.0 + assests.1 * a[sell_day], 0);
        buy_day = sell_day + 1;
    }
    println!("{}", assests.0);
}

// 1000, 0 -> 0, 10 -> 2000, 0, -> 0, 20,
fn main() {
    let n: usize = read_as_vec::<usize>()[0];
    let a = read_as_vec::<u64>();
    solve(n, a);
}


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

int main() {
  
  while(true){
   int m,f,r;
   cin >> m >> f >> r;
   int result=m+f;
    if(m==-1 && f==-1 && r==-1) break;
    
    if(m==-1 || f==-1) cout <<"F"<<endl;
    else if(result >= 80) cout << "A" <<endl;
    else if(result >= 65 && result < 80) cout << "B" <<endl;
    else if((result >= 50 && result < 65) || (result >= 30 && result < 50 && r>=50)) cout << "C" <<endl;
    else if(result >= 30 && result < 50) cout << "D" <<endl;
    else if(result < 30) cout << "F" << endl;
  }
  
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
  int N;
  cin >> N;
  vi a(3 * N);
  rep(i, 3 * N) cin >> a[i];

  uint64_t res = 0;
  sort(all(a), greater<int>());
  rep(i, N) res += a[2 * (i + 1) - 1];

  cout << res << endl;
}

Measured memory_bytes: 1536
n,m,x=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
cntF=0
cntL=0

for i in range(x):
    if i in a:
        cntF +=1
for i in range(x+1, n+1):
    if i in a:
        cntL +=1
print(min(cntF, cntL))


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


vector<long long> makedivisor(long long n) {
    vector<long long> divisor;
    long long tmp = pow(n, 0.5) + 1;
    for (long long i = 1; i < tmp; i++) {
        if (n % i == 0) {
            divisor.push_back(i);
            if (i != n / i) {
                divisor.push_back(n / i);
            }
        }
    }
    sort(divisor.begin(), divisor.end());
    return divisor;
}

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

    ll N; cin >> N;
    vector<ll> p = makedivisor(N);
    ll l = p.size();
    ll res = INF;
    rep(i, l) {
        res = min(res, p[i] - 1 + p[l-i-1] - 1);
    }
    cout << res << endl;
}

Measured memory_bytes: 384
// seabreeeze //
 
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli unsigned long long
lli MOD=1e9+7;
 
#define MAXN 2000006 
 
// Template function //
lli powermod(lli x, lli y)  
{  
    lli res = 1;  
    x = x % MOD;
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % MOD;  
        y = y>>1;   
        x = (x*x) % MOD;  
    }  
    return res;  
}
lli modinv(lli x)
{
    return powermod(x,MOD-2);
}
// Template functions end //
 
// Custom funtions //
void preprocess()
{

}

int mex(int a[],int n)
{
    vector<int> c(n+1,0);
    for(int i=0;i<n;i++)
    {
        c[a[i]]=1;
    }
    for(int i=0;i<n+1;i++)
    {
        if(c[i]==0)
        return i;
    }
    return 0;
}
 
// Custom functions end //
 
int main()
{
    lli q=1;
    // cin>>q;
    time_t start, end;
    time(&start);
    preprocess();
    for(lli tc=1;tc<=q;tc++)
    {
        // Start solution //
        int h,w,k;
        cin>>h>>w>>k;
        char c[h][w];
        int ans = 0;
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                cin>>c[i][j];
            }
        }
        for(int i=0;i<pow(2,h);i++)
        {
            for(int j=0;j<pow(2,w);j++)
            {
                int C=0;
                for(int I=0;I<h;I++)
                {
                    for(int J=0;J<w;J++)
                    {
                        if(c[I][J]=='#'&&((int)pow(2,I)&i)&&((int)pow(2,J)&j))
                        C++;
                    }
                }
                if(C==k)
                ans++;
                //cout<<ans<<endl;
            }
        }
        cout<<ans<<endl;
        // End Solution //
        end:;
    }
    
    time(&end);
    // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
    return 0;
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
int sumd(int a,int b)
{
	int sum=0;
	while(a>0)
	{
	sum+=a%10;
	a/=10;	
	}
	while(b>0)
	{
	sum+=b%10;
	b/=10;	
	}
	return sum;
}
int main()
{
	int n,i,min=999999;
	cin>>n;
	for(i=1;i<n;i++)
	{
		int x=sumd(i,n-i);
		if(x<min)
		min=x;
	}
	cout<<min<<endl;
}

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

# O(NlogN)構築、クエリO(1)のRMQ
# 変更はできない
class SparseTable():
    def __init__(self, N, A):
        self.N = N
        self.logN = N.bit_length()
        self.A = A
        self.table = [[i for i in range(N)]]
        for k in range(self.logN):
            tab = []
            for i in range(self.N-(1<<(k+1))+1):
                ind1 = self.table[-1][i]
                ind2 = self.table[-1][i+(1<<k)]
                if self.A[ind1] <= self.A[ind2]:
                    tab.append(ind1)
                else:
                    tab.append(ind2)
            self.table.append(tab)
    
    # [l, r)のminの(val, key)
    def query_min(self, l, r):
        k = (r-l).bit_length()-1
        indl = self.table[k][l]
        indr = self.table[k][r-(1<<k)]
        if self.A[indl] <= self.A[indr]:
            return self.A[indl], indl
        return self.A[indr], indr

import heapq as hp
N = int(input())
A = list(map(int, input().split()))

def main():
    SP1 = SparseTable((N+1)//2, A[::2])
    SP2 = SparseTable(N//2, A[1::2])

    ans = []
    q = []
    v, k = SP1.query_min(0, N//2)
    dic = {}
    dic[v] = (k, 0, N//2, True)
    hp.heappush(q, v)
    for _ in range(N//2):
        valuea = hp.heappop(q)
        ka, l, r, is1 = dic[valuea]
        ans.append(str(valuea))
        if is1:
            valueb, kb = SP2.query_min(ka, r)
            if ka < kb:
                m2, nk2 = SP2.query_min(ka, kb)
                hp.heappush(q, m2)
                dic[m2] = (nk2, ka, kb+1, False)
            if l < ka:
                m1, nk1 = SP1.query_min(l, ka)
                hp.heappush(q, m1)
                dic[m1] = (nk1, l, ka, True)
            if kb+1 < r:
                m3, nk3 = SP1.query_min(kb+1, r)
                hp.heappush(q, m3)
                dic[m3] = (nk3, kb+1, r, True)
        else:
            valueb, kb = SP1.query_min(ka+1, r)
            if ka+1 < kb:
                m1, nk1 = SP1.query_min(ka+1, kb)
                hp.heappush(q, m1)
                dic[m1] = (nk1, ka+1, kb, True)
            if l < ka:
                m2, nk2 = SP2.query_min(l, ka)
                hp.heappush(q, m2)
                dic[m2] = (nk2, l, ka+1, False)
            if kb < r-1:
                m3, nk3 = SP2.query_min(kb, r-1)
                hp.heappush(q, m3)
                dic[m3] = (nk3, kb, r, False)

        ans.append(str(valueb))

    print(" ".join(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 143896
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n,S;

    while(cin >> n >> S){
        if(n+S == 0) break;
        vector<int> r(n);
        int ret=0;
        for(int i=0;i<n;i++){
            cin >> r[i];
        }

        if(n == 1){
            cout << 0 << endl;
            continue;
        }

        sort(r.begin(), r.end());
        for(int i=0;i<n;i++){
            if(r[i] > (double)S/2){
                ret += n-i-1;
            }else{
                ret += r.end() - upper_bound(r.begin(), r.end(), S-r[i]); 
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 940
a_ls1 = list(map(int,input().split()))
a_ls2 = list(map(int,input().split()))
a_ls3 = list(map(int,input().split()))
n = int(input())
b_ls = [int(input()) for _  in range(n)]

a_ls4 = [a_ls1[0],a_ls2[0],a_ls3[0]]
a_ls5 = [a_ls1[1],a_ls2[1],a_ls3[1]]
a_ls6 = [a_ls1[2],a_ls2[2],a_ls3[2]]
a_ls7 = [a_ls1[0],a_ls2[1],a_ls3[2]]
a_ls8 = [a_ls1[2],a_ls2[1],a_ls3[0]]
lss = [a_ls1,a_ls2,a_ls3,a_ls4,a_ls5,a_ls6,a_ls7,a_ls8]

for i in b_ls:
    for j in lss:
        for k in j:
            if i ==k:
                j.pop(j.index(k))
for i in lss:
    if i ==[]:
        print('Yes')
        exit()
print('No')

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

struct CumulativeSum {
  vector<long long> csum;
  template<typename T>
  CumulativeSum(vector<T> input) : csum(input.size() + 1, 0) {
    for(int i = 0; i < (int)input.size(); i++) csum[i+1] = csum[i] + input[i];
  }
  long long query(int l, int r) { /* 0-indexed, inclusive */ return csum[r+1] - csum[l]; }
};

struct CumulativeSum2D {
  vector<vector<long long>> csum;
  template<typename T>
  CumulativeSum2D(vector<vector<T>> input) : csum(input.size() + 1, vector<long long>(input[0].size() + 1, 0)) {
    for(int i = 0; i < (int)input.size(); i++) for(int j = 0; j < (int)input[i].size(); j++)
      csum[i+1][j+1] += csum[i+1][j] + csum[i][j+1] - csum[i][j] + input[i][j];
  }
  CumulativeSum2D(vector<string> input, char target) : csum(input.size() + 1, vector<long long>(input[0].size() + 1, 0)) {
    for(int i = 0; i < (int)input.size(); i++) for(int j = 0; j < (int)input[i].size(); j++)
      csum[i+1][j+1] += csum[i+1][j] + csum[i][j+1] - csum[i][j] + (input[i][j]==target);
  }
  long long query(int y_top, int x_left, int y_bottom, int x_right) { /* 0-indexed, inclusive */
    return csum[y_bottom+1][x_right+1] - csum[y_top][x_right+1] - csum[y_bottom+1][x_left] + csum[y_top][x_left];
  }
};

signed main() {
#if 1 // https://atcoder.jp/contests/abc122/tasks/abc122_c
  int n,q; cin >> n >> q;
  string s; cin >> s;
  vector<bool> ac(n);
  for(int i=0; i<n-1; ++i) ac[i] = s[i] == 'A' && s[i+1] == 'C';
  CumulativeSum cs(ac);
  while(q--) {
    int l,r; cin >> l >> r; --l, r-=2;
    cout << cs.query(l,r) << endl;
  }
#elif 1 // https://atcoder.jp/contests/abc005/tasks/abc005_4
  int n; cin >> n;
  vector<vector<int>> grid(n, vector<int>(n, 0));
  for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) cin >> grid[i][j];
  CumulativeSum2D cs(grid);

  vector<int> ans(n*n+1);
  for(int y1=0; y1<n; ++y1) for(int x1=0; x1<n; ++x1) for(int y2=y1; y2<n; ++y2) for(int x2=x1; x2<n; ++x2) {
    int w = x2 - x1 + 1, h = y2 - y1 + 1;
    ans[w*h] = max(ans[w*h], (int)cs.query(y1,x1,y2,x2));
  }
  for(int i=1; i<= n*n; ++i) ans[i] = max(ans[i], ans[i-1]);

  int q; cin >> q;
  while(q--) {
    int p; cin >> p;
    cout << ans[p] << endl;
  }
#else // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0560
  int n,m,k; cin >> m >> n >> k;
  vector<string> grid(m);
  for(int i=0; i<m; ++i) cin >> grid[i];

  CumulativeSum2D J(grid, 'J');
  CumulativeSum2D O(grid, 'O');
  CumulativeSum2D I(grid, 'I');

  for(int i=0; i<k; ++i) {
    int x1,y1,x2,y2; cin >> y1 >> x1 >> y2 >> x2;
    --x1, --y1, --x2, --y2;
    cout << J.query(y1,x1,y2,x2) << " ";
    cout << O.query(y1,x1,y2,x2) << " ";
    cout << I.query(y1,x1,y2,x2) << endl;
  }
#endif
}


Measured memory_bytes: 4324
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define ll long long int 
#define PI 3.1415926535897932384626

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	string arr[]={"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
	int index=0;
	for(int i=0;i<7;i++)
	{
	     if(s==arr[i]){
	     index=i;
	     break;
	     }
	}
	cout<<7-index;
	return 0;
}

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

using namespace std;

int main (void) {
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for ( int i = 0; i < N; i++ ) cin >> a.at(i);

    long long ans = 0;
    for ( int i = 1; i < N; i++ ) {
        int rest = max(0, a.at(i) + a.at(i-1) - x);
        long long sum = (long long)a.at(i-1) + a.at(i);
        /* i番目とi-1番目の隣り合う2つを考える
         * 次に一つ右隣りを見るときに有利になるように右側から減らす */
        int n = min(rest, a.at(i));
        a.at(i) -= n;
        rest -= n;
        ans += n;
        /* 右側だけではx以下を達成できない場合のみ左側も減らす */
        n = min(rest, a.at(i-1));
        a.at(i-1) -= n;
        rest -= n;
        ans += n;
    }

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


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

int main() {
    int N, K, S;
    cin >> N >> K >> S;

    rep(i, K) { cout << S << " "; }
    if (S != pow(10, 9))
        rep(i, N - K) { cout << S + 1 << " "; }
    else
        rep(i, N - K) { cout << 1 << endl; }
    cout << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H + 2);
  
  for (int i = 0; i <= H + 1; i++) {
    for (int j = 0; j <= W + 1; j++) {
      S.at(i) += ".";
    }
  }
  
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> S.at(i).at(j);
    }
  }
  
  bool result = true;
  
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (S.at(i).at(j) == '#') {
        if(S.at(i - 1).at(j) == '.' && S.at(i).at(j - 1) == '.' 
           && S.at(i + 1).at(j) == '.' && S.at(i).at(j + 1) == '.') {
          result = false;
          break;
        }
      }
    }
  }
  
  if (result) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
a_list = list(map(int, input().split()))

b_list = [0 for _ in range(N)]
c_list = []
for i in range(N,0,-1):
  # print(i)
  tmp = sum(b_list[i-1::i]) # i-1 番以降の N の倍数を取り出す
  # print(i, b_list[i-1::i])
  if tmp %2 != a_list[i-1]: # 偶奇が合っているかを確認
    b_list[i-1] = 1
    c_list.append(str(i))
if len(c_list)!=0:
  print(len(c_list))
  print(" ".join(c_list))
elif all(elem == 0 for elem in a_list):
  print("0")
else:
  print("-1")

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

int main() {
    int n;
    cin>>n;
    int no=floor(log10(n)+1),res=no/2,sum=0;
    if(no%2==0)
    {
        while(res--){
            no-=2;
            sum=sum+(9*pow(10,no));
        }
        cout<<sum<<endl;
    }
    else{
        sum+=(n-pow(10,(no-1)));
        no--;
        while(res--){
            no-=2;
            sum+=(9*pow(10,no));
        }
        cout<<sum+1<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
const double EPS= 1e-12;
 
struct zahyo{
    double x;
    double y;
};
 
 
int main(){
    zahyo a , b , c , d , ab , cd;
    int n;
    std::cin >> n;
    for(int i=0 ; i<n ; ++i){
        std::cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
        ab.x=b.x-a.x;
        ab.y=b.y-a.y;
        cd.x=d.x-c.x;
        cd.y=d.y-c.y;
        if (abs(ab.x*cd.y-ab.y*cd.x)<EPS){ //gaiseki
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }           
    }
    return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void){
	int n, m;

	cin >> n >> m;

	cout << pow(2, m) * (100*n + 1800*m) << endl;

	return 0;
}

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

int main(void){

	int n;
	int a[100];
	int count = 0;

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

	bool flg = true;
	while (flg){
		flg = false;
		for (int i = n - 1; i > 0; i--){
			if (a[i] < a[i - 1]){
				swap(a[i], a[i - 1]);
				flg = true;
				count++;
			}
		}
	}
	for (int i = 0; i < n - 1; i++)
		cout << a[i] << ' ';
	cout << a[n - 1] << endl << count << endl;
}

Measured memory_bytes: 1160
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::ops::*;
use std::slice::*;
use std::*;

const MOD: isize = 1000000007;
fn main() {
    let v: Vec<char> = read::<String>().chars().collect();
    let n = v.len();
    let mut v2: Vec<char> = vec![];
    let mut v3: Vec<char> = vec![];
    let mut ans = isP(&v);
    for i in 0..(n - 1) / 2 {
        v2.push(v[i]);
    }
    for i in (n + 3) / 2 - 1..n {
        v3.push(v[i]);
    }
    ans &= isP(&v2);
    ans &= isP(&v3);
    println!("{}", if ans { "Yes" } else { "No" });
}
fn isP(s: &Vec<char>) -> bool {
    let mut t = s.clone();
    t.reverse();
    let ret: bool = (*s == t);
    ret
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace() // iter
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		sc.close();
		System.out.println(A*B/GCD(A,B));
	}

	private static long GCD(long a, long b){
		if(a < b){
			return GCD(b,a);
		}
		if(b == 0){
			return a;
		}
		return GCD(b, a%b);
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N+1);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N+1, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[1] = 0;
    que.push(1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    cout << "Yes" << endl;
    for (int v = 2; v <= N; ++v) cout << dist[v] << endl;

    return 0;
}

Measured memory_bytes: 10164
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(int *a, int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int a[7][7],b[7][7],c[7],d[7],e,f,g,n,i,h,w,k,j,l,count,coun=0,temp1,temp2;
  char s[8];

scanf("%d%d%d",&h,&w,&k);
	for(i=0;i<h;i++){
        scanf("%s",s);
        for(l=0;l<w;l++){
          //printf("%c\n",s[l]);
        if(s[l]=='#'){
        a[i][l]=1;//黒が1
          b[i][l]=1;
        }
  else{
  a[i][l]=0;
    b[i][l]=0;
  }
      }
	}
  

  for(c[0]=0;c[0]<2;c[0]++){for(c[1]=0;c[1]<2;c[1]++){for(c[2]=0;c[2]<2;c[2]++){for(c[3]=0;c[3]<2;c[3]++){for(c[4]=0;c[4]<2;c[4]++){for(c[5]=0;c[5]<2;c[5]++){for(c[6]=0;c[6]<2;c[6]++){for(d[0]=0;d[0]<2;d[0]++){for(d[1]=0;d[1]<2;d[1]++){for(d[2]=0;d[2]<2;d[2]++){for(d[3]=0;d[3]<2;d[3]++){for(d[4]=0;d[4]<2;d[4]++){for(d[5]=0;d[5]<2;d[5]++){for(d[6]=0;d[6]<2;d[6]++){
 count=0;
    temp1=0;
    temp2=0;
    for(i=h;i<7;i++){
    temp1+=c[i];
    }
    for(j=w;j<7;j++){
    temp2+=d[j];
    }
    
    if(temp1>0||temp2>0){
    break;
    }
    
    for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      
  if(d[j]==1||c[i]==1){
    b[i][j]=2;
  }  
    }
  }
    
    
    for(i=0;i<h;i++){
    for(j=0;j<w;j++){
    if(b[i][j]==1){
    count++;
    }
      
      b[i][j]=a[i][j];
    }
    }
    
    if(count==k){
    coun++;
          }

  
    
    
    
  
  }}}}}}}}}}}}}}
    
    
  
  printf("%d",coun);
return 0;

}


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

int main(){
  int N;
  int A;

  cin >> N;
  cin >> A;

  if ( A >= N ){
    cout << "Yes" << endl;
  }
  else if ( (N % 500) - A <= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define DRVI(N, X) VI X(N); for (int ___I=0; ___I<n; ___I++) scanf("%d", &(X[___I]))  
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    set<string> r;
    int n;
    cin>>n;
    REP(i,n){
        string s;
        cin>>s;
        r.insert(s);
    }
    cout<<SZ(r)<<endl;

}


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

using namespace std;
long long n,i,j,val1,val2,v[100005],ok;

bool cmp(int a, int b)
{
    return a>b;
}

int main()
{
    cin>>n;
    for(i=1;i<=n;i++) cin>>v[i];
    sort(v+1,v+n+1,cmp);
    ok=0; i=2;
    while(!ok && i<=n)
    {
        if(v[i]==v[i-1]) val1=v[i], ok=1;
        else i++;
    }
    ok=0; i+=2;
    while(!ok && i<=n)
    {
        if(v[i]==v[i-1]) val2=v[i], ok=1;
        else i++;
    }
    cout<<val1*val2<<'\n';
    return 0;
}


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


int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i <= n; ++i) {
		if (floor(i * 1.08) == n) {
			cout << i;
			return 0;
		}
	}

	cout << ":(";
	return 0;
}

Measured memory_bytes: 256
class Combination

  def initialize(n)
    @mod=10**9+7
    @fact=Array.new(n){0}
    @inv=Array.new(n){0}

    @fact[0]=1
    (1...n).each{|i| @fact[i]=(@fact[i-1]*i)% @mod}
    (0...n).each{|i| @inv[i]=makeinv(@fact[i], @mod)% @mod}
  end

  def mypow(x, n)
    if n==0
      1
    elsif n%2==0
      mypow(x*x% @mod, n/2)% @mod
    else
      x*mypow(x, n-1)% @mod
    end
  end

  def makeinv(x, p)
    mypow(x, p-2)
  end

  def comb(n, r)
    @fact[n]*@inv[n-r]*@inv[r]% @mod
  end
end

n=gets.to_i
a=gets.split.map(&:to_i)

cnt=Array.new(n+1){0}
a.each{|e| cnt[e]+=1}
c=0
cnt.each_with_index do |e, i|
  if e==2
    c=i
    break
  end
end
raise unless c!=0

l, r=a.index(c), a.rindex(c)
m=l+(n-r)

cmb=Combination.new(n+5)
mod=10**9+7
(1..n+1).each do |k|
  if k-1<=m
    puts (cmb.comb(n+1, k)-cmb.comb(m, k-1)+mod)%mod
  else
    puts cmb.comb(n+1, k)%mod
  end
end


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

int main(){
	string s,t;
	int ans=0;
	cin>>s>>t;
	for(int i=0;i<3;i++){
		if(s[i]==t[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=0;
  cin >> n;
  for(int i=1; i<=n; i++) {
    if(i%3==0||i%5==0) {
      continue;
    }
    else {
      ans+=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    string s; cin >> s;
    if (s=="ARC") cout << "ABC";
    else cout << "ARC";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,ans;
  rep(i,5) {
    cin>>x;
    if(x==0) ans=i+1;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3636
n = int(input())
monster = list(map(int, input().split()))
hero = list(map(int, input().split()))
hero.append(0)
rest = 0
score = 0
for m, h in zip(monster, hero):
  x = min(m, rest)
  score += x
  m -= x
  if h < m:
    score += h
    rest = 0
    continue
  score += m
  rest = h - m
  
print(score)  
  

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

int main() {
	int n ; cin >> n;
	vector<int> A(n);
	for(int i = 0 ; i < n ; i++){
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	cout << A[n-1] - A[0] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    ll a,b,c,d;
    while(cin>>a>>b,a+b){
        c=max(a,b); d=min(a,b);
        ll hoge=0;
        while(d){
            c=c%d;swap(c,d);hoge++;
        }
        cout<<c<<" "<<hoge<<endl;
    }
}

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

int main() {
	int h,w;
	cin >> h >> w;
	char a[h][w];
	bool bw[w];
	bool bh[h];
	rep(i,w) bw[i]=0;
	rep(i,h) bh[i]=0;
	rep(i,h){
		rep(j,w){
			char c;
			cin >> c;
			a[i][j]=c;
		}
	}
	//行を見る
	rep(i,h){
		int cnt=0;
		rep(j,w){
			if(a[i][j]=='.')
				cnt++;
		}
		if(cnt==w) bh[i]=true;
	}
	//列を見る
	rep(i,w){
		int cnt=0;
		rep(j,h){
			if(a[j][i]=='.')
				cnt++;
		}
		if(cnt==h) bw[i]=true;
	}
	rep(i,h){
		rep(j,w){
			if(bh[i]==0&&bw[j]==0)
				cout << a[i][j];
		}
		if(bh[i]==0)
			cout << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i,n) for( ll i=0 ; i<n ; i++ )
#define f(i, a, b) for( ll i=a ; i<b ; i++ )
#define vi vector<int>
#define pb push_back
#define MOD 1000000007

ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}
vector<ll> SieveOfEratosthenes(ll n,ll a)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    vector<ll>v;
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {

            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for (ll p= a; p<=n; p++)
       if (prime[p])
          v.push_back(p);
    return v;
}
void permute(string a, int l, int r)
{
    // permutes string
    if (l == r)
    {
        cout<<a<<endl;
    }
    else
    {
        for (int i = l; i <= r; i++)
        {
            swap(a[l], a[i]);
            permute(a, l+1, r);
        }
    }
}
int main()
{
    string s;
    cin>>s;
    int n = s.size();
    if(s[n - 1]=='s')
        s += "es";
    else
        s += 's';
    cout<<s;

}


Measured memory_bytes: 3720
s = list(map(int, input()))[::-1]
mods = [0] * 2019
mods[0] = 1

v = 0
d = 1
for n in s:
    v = (v + n * d) % 2019
    d = (d * 10) % 2019

    mods[v] = mods[v] + 1

print(sum([m*(m-1)//2 for m in mods]))


Measured memory_bytes: 12072
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dp[(1<<21)];
ll d[MAXn][MAXn];

void add(ll &a,ll b)
{
    a += b;
    if(a >= MOD)a -= MOD;
}

ll u[30];

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP(i,n)REP(j,n)cin>>d[i][j];
    dp[0] = 1;
    REP1(I, (1<<n) - 1)
    {
        FILL(u, 0);
        ll ct = 0;
        REP(i, n)if((1<<i) & I)u[i] = 1, ct++;
        ll i = ct - 1;
        REP(j,n)if(u[j] && d[i][j])add(dp[I], dp[I - (1<<j)]);
    }
    
    cout<<dp[(1<<n) - 1]<<endl;
}


Measured memory_bytes: 16640
X, N = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
ans = -1
tmp = 1000
for i in range(0, 102):
    if i in P: continue
    if abs(X-i) < tmp:
        ans = i
        tmp = abs(X-i)
print(ans)


Measured memory_bytes: 61728
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
 
signed main(){
    int A,B;cin>>A>>B;
    if(abs(A-B)%2==0)cout<<(A+B)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
struct rucsac{
long long v,w;
}a[105];
long long n,g,i,G[100001],maxim,j,aux;
int main()
{
    cin>>n>>g;
    for(i=1;i<=n;i++)
        cin>>a[i].w>>a[i].v;
    for(i=1;i<=n;i++)
        {
            for(j=g-a[i].w;j>=1;j--)
        if(G[j]!=0)
            {aux=G[j]+a[i].v;
                G[j+a[i].w]=max(G[j+a[i].w],aux);}
            if(G[a[i].w]==0)G[a[i].w]=a[i].v;
        }
    for(i=1;i<=g;i++)
        if(G[i]>maxim)maxim=G[i];
    cout<<maxim;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
 
#define int long long

#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007

 
int32_t main(){

   
     IOS
    int n;
    cin>>n;
    assert(n<1000);
    int rem=n%10;

    if(rem==2||rem==4||rem==5||rem==7||rem==9)
    cout<<"hon";
    else if(rem==0||rem==1||rem==6||rem==8) 
        cout<<"pon";
    else
        cout<<"bon";
    return 0;
}



Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <algorithm>
static const int MAXN = 1e5 + 3;

int n, a[MAXN];

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

    int max = *std::max_element(a, a + n),
        min = *std::min_element(a, a + n);

    if (max - min > 1) {
        puts("No");
    } else if (max - min == 0) {
        puts(max == n - 1 || max <= n / 2 ? "Yes" : "No");
    } else {
        int ct = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] == min) ++ct;
        }
        int w = min - (ct - 1);
        puts(w > 0 && (w == (n - ct) / 2 - 1 || w <= (n - ct) / 2) ? "Yes" : "No");
    }

    return 0;
}


Measured memory_bytes: 512
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const lines = input.split("\n");
	const params = lines[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	const r = parseInt(params[0], 10);
	const D = parseInt(params[1], 10);
	var x = parseInt(params[2], 10);
	//出力
    for (var i=0; i<10; i++){
      x = r * x - D;
      console.log(x);
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21448
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": # "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		int res=0;
		while(n)
			res+=n/=5;
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
N = int(input())
H = [int(i) for i in input().split()]

t = 0
s = 0
if N >= 2:
  for i in range(N-1):
    if H[i] > H[i+1]:
      t += 1
      if t == 2:
        s += 1
    if H[i] < H[i+1]:
      t = 0
    if H[i] >= H[i+1] +2:
      s += 1
if s == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14396
N, K, Q = map(int, input().split())
A = [0]*N
# print(A)

for i in range(Q):
    A[int(input())-1] +=1
    # print(A)

for i in range(N):
    if K-Q+A[i] <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 4680
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N;
    int S[4];
    cin >> N;
    for (int i = 0; i < 4; i++) {
        S[i] = 0;
    }

    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (s == "AC") {
            S[0]++;
        } else if (s == "WA") {
            S[1]++;
        } else if (s == "TLE") {
            S[2]++;
        } else {
            S[3]++;
        }
    }

    cout << "AC x " << S[0] << endl;
    cout << "WA x " << S[1] << endl;
    cout << "TLE x " << S[2] << endl;
    cout << "RE x " << S[3] << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;

main(){
    int n;cin>>n;
    rep(i,50000){
        double t=i;
        t*=1.08;
        if(n==floor(t)){
            cout<<i<<endl;return 0;
        }
    }
    cout<<":(";
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	ll h, w, n;
	cin>>h>>w>>n;
	vector<string> a(h);
	vector<vector<ll> > dist(h, vector<ll>(w, INF));
	ll time = 0;
	P sp;
	REP(i, h) cin>>a[i];
	bool det = false;
	REP(i, h) {
		REP(j, w) {
			if(a[i][j] == 'S') {
				sp.first = i;
				sp.second = j;
				det = true;
				break;
			}
		}
		if(det) break;
	}
	REP(i, n) {
		queue<P> c;
		c.push(sp);
		dist[sp.first][sp.second] = 0;
		while(true) {
			P cp = c.front();
			c.pop();
			if(a[cp.first][cp.second] - '1' == i) {
				time += dist[cp.first][cp.second];
				sp = cp;
				break;
			}
			REP(j, 4) {
				ll nx = cp.first + dx[j];
				ll ny = cp.second + dy[j];
				if(nx >= 0 && nx < h && ny >= 0 && ny < w && dist[nx][ny] == INF && (a[nx][ny] == 'S' || a[nx][ny] == '.' || (a[nx][ny] >= '1' && a[nx][ny] <= '9'))) {
					c.push(P(nx, ny));
					dist[nx][ny] = dist[cp.first][cp.second] + 1;
				}
			}
		}
		REP(j, h) {
			REP(k, w) {
				dist[j][k] = INF;
			}
		}
	}
	cout<<time<<endl;
}

Measured memory_bytes: 11848
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


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

string solve(ll a, ll b, ll c, ll d) {
    if ((d < b) || (a < b))
        return "No";
    if (c >= b - 1)
        return "Yes";
    ll gd = gcd(b, d);
    ll r = ((b - (a % b)) % b) % gd;
    if (r == 0)
        r = gd;
    if (r <= b - c - 1)
        return "No";
    return "Yes";

}

void solve() {
    int t;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << solve(a, b, c, d) << "\n";
    }
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 256
<?php 
    $array = explode(' ',trim(fgets(STDIN)));
    $x = $array[0];
    $y = $array[1];
    if($x<$y){
        echo "a < b";
    }else if($x>$y){
        echo "a > b";
    }else{
        echo "a == b";
    }
 ?>

Measured memory_bytes: 14980