akhauriyash/Code-Regression huggingface dataset:
var
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
 n:longint;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
begin
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 read(n);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 writeln(n*800-((n div 15)*200));
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 end.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 //O ;pbr xku

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

typedef long long ll;
class Union_Find {
private:
public:
    std::vector<int> par;
    std::vector<int> rank;

    Union_Find(int n) { // 初期化: O(n)
	par = rank = std::vector<int>(n);
	for(int i=0; i<n; i++) {
	    par[i]  = i;
	    rank[0] = 0;
	}
    }

    int root(int x) { // 木の根を求める: O(α(n)) 
	if(par[x] == x) return x;
	return par[x] = root(par[x]); // 親を辿りながら根に付け替える
    }

    void unite(int x, int y) { // x,yを含む集合を結合: O(α(n)) 
	x = root(x); y = root(y);
	if( x == y ) return;

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

    bool same(int x, int y) { //x,yが同じ集合に含まれるかどうか: O(α(n)) 
	return root(x) == root(y);
    }
};

int main () {

    int N,M;
    cin >> N >> M;

    // 言語 i を話せる人集合 : g[i]
    vector<vector<int>> g(M);
    for(int i=0; i<N; i++) {
	int K; cin >> K;
	for (int j=0; j<K; ++j) {
	    int in; cin >> in; in--; // 0-index
	    assert(0<=in and in<M);
	    g[in].push_back(i);
	}
    }
    Union_Find uf(N+1);
    // 同じ言語が話せる人はマージ
    for(int i=0; i<M; i++) {
	for(int j=0; j<g[i].size(); j++) { 
	    uf.unite(g[i][0], g[i][j]);
	}
    }

    // 全員同じ集合ならYES
    bool ans = true;
    for(int i=0; i<N; i++) {
//	cout << uf.par[i] << " " ;
	if( !uf.same(0,i) ) {
	    ans = false;
	}
    }
    if(ans) cout << "YES" << endl;
    else    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 4608
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int h,i;
  int s[256];
  for(i=2;i<=9;i++)
    s[i+'0']=i;
  s['A']=1;
  s['T']=s['J']=s['Q']=s['K']=10;
  int n;
  cin>>n;
  for(h=0;h<n;h++){
    int sm=0,ct=0,bj=0;
    for(i=0;i<2;i++){
      char t;
      cin>>t;
      sm+=s[(int)t];
      if(t=='A')
	ct=1;
    }
    if(sm==11&&ct)
      bj=1;
    for(i=0;i<8;i++){
      char t;
      cin>>t;
      if(ct){
	if(0){
	}else if(sm+10<=17){
	  sm+=s[(int)t];
	}else if(sm+10<=21){
	}else if(sm<=16){
	  sm+=s[(int)t];
	}
      }else{
	if(sm<=16){
	  sm+=s[(int)t];
	  if(t=='A')
	    ct=1;
	}
      }
    }
    if(bj){
      cout<<"blackjack"<<endl;
    }else{
      if(ct){
	if(0){
	}else if(sm>21){
	  cout<<"bust"<<endl;
	}else if(sm+10>21){
	  cout<<sm<<endl;
	}else{
	  cout<<sm+10<<endl;
	}
      }else{
	if(sm>21){
	  cout<<"bust"<<endl;
	}else{
	  cout<<sm<<endl;
	}
      }
    }
  }
  return 0;
}

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF 2000000000
#define int long long
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
int a[10001];
signed main(){
	int n;
	cin>>n;
	lp(i,n){
		int hoge;
		cin>>hoge;
		a[hoge]++;
	}
	int st=0;
	lp(i,10001){
		while(a[i]!=0){
			if(st==1) cout<<" ";
			cout<<i;
			st=1;
			a[i]--;
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3128
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

let inline gcd x y =
    let zero = LanguagePrimitives.GenericZero
    let rec loop x y = if y = zero then x else loop y (x % y)
    loop (abs x) (abs y)

let inline lcm x y =
    let zero = LanguagePrimitives.GenericZero
    if x = zero || y = zero then zero else abs ((x / gcd x y)) * y

[<EntryPoint>]
let main _ =
    let [|A;B|] = reads int64
    printfn "%i" (lcm A B)
    0

Measured memory_bytes: 14160
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m,l,r,lmax=0,rmin=1000000;
    cin >> n >> m;
    
    for(int i=0; i<m; i++){
        cin >> l >> r;
        lmax = l > lmax ? l : lmax;
        rmin = r < rmin ? r : rmin;
    }
    if(rmin >= lmax){
        cout << rmin - lmax + 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    N, M = [int(x) for x in input().split()]
    K = []
    S = []
    
    for i in range(M):
        temp = [int(x) for x in input().split()]
        K.append(temp.pop(0))
        S.append(temp)

    P = [int(x) for x in input().split()]

    ans = 0

    for i in range(2**N):
        tentoucount = 0
        swich = []
        num = bin(i).lstrip('0b').zfill(N)
        for j in num:
            swich.append(int(j))

        for j in range(M):
            onswich = 0
            for k in S[j]:
                onswich += swich[k-1]
            if onswich%2 == P[j]:
                tentoucount += 1

        if tentoucount == M:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	
	int step=0,ans=-1;
	
	while(step<35)
	{
		if(a%2 || b%2 || c%2)
		{
			cout<<step;
			return 0;
		}
		
		int ta=a,tb=b,tc=c;
		a=(b+c)/2;
		b=(ta+c)/2;
		c=(ta+tb)/2;
		step++;
	}
	
	cout<<"-1";
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	while(true){
		int N;
		cin >> N;
		if(N == 0)break;
		string c;
		cin >> c;
		int mai[10];
		for(int i = 0; i < N;i++){
			mai[i] = 0;
		}
		int ba = 0;
		int turn = 0;
		for(int i = 0; i < 100; i++){
			if(c[i] == 'M'){
				mai[turn]++;
			}
			else if(c[i] == 'S'){
				mai[turn]++;
				ba += mai[turn];
				mai[turn] = 0;
			}
			else{
				mai[turn]++;
				mai[turn] += ba;
				ba = 0;
			}
			turn++;
			turn %= N;

		}
		sort(mai,mai+N);
		for(int i = 0; i < N; i++){
			cout << mai[i] << " ";
		}
		cout << ba << endl;
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {os << "{" <<p.first << ", " << p.second << "}";return os;}
struct fast_ios{ fast_ios(){cin.tie(0);ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;
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; }

#ifdef DEBUG
#define dump(x) cerr<<#x<<": "<<x<<endl;
#else
#define dump(x)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    string S, T;
    cin >> S >> T;
    int N = S.size();
    int M = T.size();
    ll ans = INFLL;
    for(int i = 0; i < N; i++){
        // if(i + M > N)continue;
        string tmp = S.substr(i, M);
        if(tmp.size() < M)continue;
        dump(tmp);
        ll cnt = 0;
        rep(j,M)cnt += T[j] != tmp[j];
        chmin(ans, cnt);
    }
    cout << ans << endl;
}


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

using namespace std;

#define maxN 3010

typedef long long ll;

int n;
ll as[maxN];
ll sum = 0;

ll cache[maxN][maxN];

ll rec(int i, int j, ll remainingSum) {
    if (i == j) return as[i];
    if (cache[i][j] != -1) return cache[i][j];
    return cache[i][j] =
                   max(remainingSum - rec(i + 1, j, remainingSum - as[i]),
                       remainingSum - rec(i, j - 1, remainingSum - as[j]));
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        sum += as[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cache[i][j] = -1;
        }
    }
    ll X = rec(0, n - 1, sum);
    cout << X - (sum - X) << endl;
    return 0;
}

Measured memory_bytes: 71040
#include<bits/stdc++.h>
using namespace std;
int n,a[1111111],c,cnt;
char s[1111111];
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	for (int i=0;i<n-1;i++)
	{
		a[i]=abs(s[i]-s[i+1]);
	}
	if (n==2)
	{
		printf("%d\n",a[0]);
		return 0;
	}
	for (int i=0;i<n-1;i++)
	{
		if (((n-2)&i)==i)
		{
			if (a[i]==1) c^=1;
		}
	}
	if (c)
	{
		printf("1\n");
		return 0;
	}
	for (int i=0;i<n-1;i++)
	{
		if (a[i]==1)
		{
			printf("0\n");
			return 0;
		}
	}
	c=0;
	for (int i=n-2;i>=0;i--)
	{
		if (((n-2)&i)==i) 
		{
			if (a[i]==2) c^=1;
		}
	}
	if (c) printf("2\n");
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 5120
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int ans = a - b * 2;
  if(ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int ll;
#define MOD (1000000007);
#define INF (2e9)


int check_p(int n){
	int p=2;
	while(p*p<=n){
		if(n%p==0){
			return 0;
		}
		p++;
	}
	return 1;
}

int main(void){
	int n;
	cin>>n;
	int p[1002];
	int k=0;
	for(int i=0;i<1002;i++){
		p[i]=0;
	}
	for(int i=2;i<=n;i++){
		if(check_p(i)){
			for(int j=1;pow(i,j)<=n;j++){
				p[k]+=n/pow(i,j);
			}
			k++;
		}
	}
	int i=0;
	ll ans=1;
	while(p[i]!=0){
		ans=(ans*(p[i]+1))%MOD;
		i++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
@SuppressWarnings("unused")
public class Main{
    static long val[];
    static int wt[];
    public static void main(String args[]) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String s[] = br.readLine().trim().split(" ");
        int n = Integer.parseInt(s[0]);
        int w = Integer.parseInt(s[1]);
        val = new long[n];
        wt = new int[n];
        for(int i=0;i<n;i++) {
            String st[] = br.readLine().trim().split(" ");
            wt[i] = Integer.parseInt(st[0]);
            val[i] = Integer.parseInt(st[1]);
        }
        dp = new long[n+1][(int)w+1];
        for(int i=0;i<=n;i++) Arrays.fill(dp[i], -1);
        long ans = find(n, w);
        out.println(ans);
        out.flush();
    }
    static long dp[][];
    
    public static long find(int n, int w) {
        if(dp[n][w]!=-1) return dp[n][w];
        if(n==0 || w==0) return dp[n][w] = 0;
        if(wt[n-1] > w) return dp[n][w] = find(n-1, w);
        return dp[n][w] = Math.max( find(n-1, w), val[n-1] + find(n-1, w-wt[n-1]));
    }
}

Measured memory_bytes: 136940
#include <stdio.h>
 
int main() {
char a;
char ch[120];
char c[120];
char b[120];
int i,j,k,l,m,n,o;
m = 0;
n = 0;
i=0;
l=0;
 
while(1) {
scanf("%c",&a);
 
if(a == '\n') {
 break;
}
 
ch[i] = a;
i=i+1;
 
}
 
j=0;
while(1) {
scanf("%c",&a);
if(a == '\n') {
break;
}
c[j] = a;
j +=1;
}
/*??????????????§??\??????*/
 
for(k=0;k<i;k++) {
 
if(c[0] == ch[k] ) {       /*???????????????????????¨?????????????????? */
 l = k;
n = 0;                         /* ??????????????´???????????????*/
for(m=0;m<i-k;m++) {         /* c[k]????????????????§????????????? */
n = n +1;
l  +=1;
b[m] = ch[l-1];
}
l=0;
for(m=n;m<n+1+k;m++) {
l +=1;
b[m] = ch[l-1];            
}
o=0;
for(n=0;n<j;n++) {
/*printf("b[%d] = %c\n c[%d] = %c\n",n,b[n],n,c[n]); */
if(b[n] == c[n]){
o +=1;
}
}
}
 
/* printf("i = %d\nj = %d\n",i,j); */
 
 
if(o == j) {
printf("Yes\n");
break;
} else if(k==i-1) {
printf("No\n");
}
}
  
return 0;
 
}



Measured memory_bytes: 2112
N = int(input())

strings = []
for i in range(N):
    strings.append(''.join(sorted(input().strip())))
strings.sort()

ans = 0
last_string = ''
c = 1
for s in strings:
    if last_string == s:
        c += 1
    else:
        last_string = s
        if c != 1:
            ans += c * (c - 1) // 2
        c = 1
if c != 1:
    ans += c * (c - 1) // 2

print(ans)


Measured memory_bytes: 57312
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   int a, b;

   cin >> a >> b;

   cout<<max(0LL, a - 2*b);
   

   return 0;
}

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

struct QuickFind{
  vector<int> r,p;
  vector<vector<int> > v;
  QuickFind(){}
  QuickFind(int size){init(size);}
  void init(int size){
    r.resize(size,0);
    p.resize(size,0);
    v.resize(size);
    for(int i=0;i<size;i++){
      r[i]=1,p[i]=i;
      v[i].resize(1,i);
    }
  }
  bool same(int x,int y){
    return p[x]==p[y];
  }
  void unite(int x,int y){
    x=p[x];y=p[y];
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    for(int i=0;i<(int)v[y].size();i++){
      p[v[y][i]]=x;
      v[x].push_back(v[y][i]);
    }
    v[y].clear();
  }
};
signed main(){
  int n,q;
  cin>>n>>q;
  QuickFind qf(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<qf.same(x,y)<<endl;
    else qf.unite(x,y);
  }
  return 0;
}
/*
verified on 2017/04/28
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
*/

Measured memory_bytes: 3916
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


def divisors(n, sort=False):
    """
    nの約数をO(√n)で列挙する
    """
    d = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.append(i)
            if i != n // i:
                d.append(n//i)
    if sort:
        d.sort()
    return d


N = I()

ans = 0
for d in divisors(N - 1):
    if d > 1:
        ans += 1
for d in divisors(N):
    if d == 1:
        continue
    num = N
    while num % d == 0:
        num = num // d
    if num % d == 1:
        ans += 1
print(ans)



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

int N,H,A,D,S;
int h,a,d,s;
vector<ll> x,y;
int t[40000];

ll sum,cnt;

bool f(const int &a,const int &b){
  ll A=x[a]*(y[a]-1)+x[b]*(y[a]+y[b]-1);
  ll B=x[b]*(y[b]-1)+x[a]*(y[a]+y[b]-1);
  return (A<B);
}

int solve(){
  N=x.size();
  for(int i=0;i<N;i++){
    t[i]=i;
    cnt+=x[i];
  }
  if(H<=sum)return -1;  
  sort(t,t+N,f);
  for(int i=0;i<N;i++){
    int id=t[i];
    sum+=x[id]*(y[id]-1);
    cnt-=x[id];
    sum+=cnt*y[id];
    if(H<=sum)return -1;
  }
  return sum;
}

int main(){
  scanf("%d %d %d %d %d",&N,&H,&A,&D,&S);
  for(int i=0;i<N;i++){
    scanf("%d %d %d %d",&h,&a,&d,&s);
    if(s>S)sum+=(max(a-D,0));
    if( a-D <= 0 )continue;
    if( A-d <= 0 ){
      cout<<-1<<endl;
      return 0;
    }
    x.push_back( a-D );
    y.push_back( (h+A-d-1)/(A-d) );
  }
  cout<<solve()<<endl;      
  return 0;  
}

Measured memory_bytes: 2144
"use strict"
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
let stdout = [];
function input(){return stdin.pop()};
function maput(){return input().split(" ").map(n=>parseInt(n))};
function print(x){stdout.push(x)};
function exist(x, xs){return new Set(xs).has(x)}
function max(x){return x.reduce(function(a,b){ return Math.max(a,b) }) }
function min(x){return x.reduce(function(a,b){ return Math.min(a,b) }) }
function sum(x){return x.reduce(function(a,b){ return a+b }) }
function sorting(x, index){x.sort((a, b) => a[index] - b[index])}
function all(x){return x.reduce(function(a,b){ return a && b }) }
function any(x){return x.reduce(function(a,b){ return a || b }) }
function list(iterable){return Array.from(iterable)}
function vint(iterable){return Array.from(iterable, x => parseInt(x))}
function tile(val, len){return Array(len).fill(val)}
const range = (start, stop, step) => Array.from(
    { length: (stop - start) / step }, (_, i) => start + (i * step));
/*START*/


function f(n){
    let ans = 0
    while (n % 2 == 0){
        n /= 2
        ans++
    }
    return ans
}

let n = parseInt(input())
let a = maput()
let b = new Array(n)
for (let i = 0; i < n; i++){
    b[i] = f(a[i])
}
print(min(b))






/*END*/
stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define pii pair<int,int>
typedef long long ll;
ll num[111111],dp[111111][2];
int main()
{
    int n;scanf("%d",&n);
    ll res=0;
    for(int i=1;i<=n;i++)scanf("%lld",&num[i]),dp[i][0]=dp[i][1]=-1e18;
    dp[1][0]=num[1],dp[1][1]=-num[1];
    rep(i,1,n)rep(j,0,2)
    {
        rep(k,0,2)
        dp[i+1][k]=max(dp[i+1][k],dp[i][j]+((j^k)?-num[i+1]:num[i+1]));
    }
    printf("%lld\n",dp[n][0]);
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

const ll mod = 1000000007LL;

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

	constexpr int K = 16;

	constexpr ll v_e[] = { 869418286, 727008098, 660103155, 183023413, 471090892, 417297686, 237315285, 542573865, 444014759, 927321758, 184117322, 5655049, 347662323, 346175634, 765144583, 0};
	constexpr ll v_o[] = { 869418286, 727008098, 660103155, 183023413, 471090892, 417297686, 237315285, 542573865, 444014759, 927321758, 184117322, 962779130, 404391958, 700407153, 729548371, 539588932 };

	ll T, N; cin >> T;
	for (int _t = 0; _t < T; _t++) {
		cin >> N;
		ll ans = v_e[0];
		if (N & 1) {// odd
			for (int i = 1; i < K; i++) {
				ans = ans * N + v_o[i];
				if(ans >= mod) ans %= mod;
			}
		}
		else {// even
			for (int i = 1; i < K; i++) {
				ans = ans * N + v_e[i];
				if (ans >= mod) ans %= mod;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3192
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n;
  cin >> n;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  map<int, int> mp1, mp2;
  for (int i = 0; i < n; i++) {
    mp1[a[i]] = i, mp2[b[i]] = i;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (mp1[a[i]] % 2 != mp2[a[i]] % 2) cnt++;
  }
  cout << cnt / 2 << "\n";
}



Measured memory_bytes: 14336
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var n = ScanInt();
      long Y = 0;
      double B = .0;
      for(int i=0; i<n; i++){
        var input = ScanStrArray();
        if(input[1] == "JPY")
          Y += long.Parse(input[0]);
        else
          B += double.Parse(input[0]);
      }
      WriteLine($"{Y+B*380000.0}");
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
    static public string RegaxReplace(this string arg1, string pattern, string replacement)
    {
      return Regex.Replace(arg1, pattern, replacement);
    }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main() {
	int r,c;
	int hyou[105][105] = {0};
	cin >> r >> c;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> hyou[i][j];
		}
	}
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			hyou[r][j] += hyou[i][j];
			hyou[i][c] += hyou[i][j];
		}
	}
	for (int i = 0; i < c; i++) {
		hyou[r][c] += hyou[r][i];
	}
	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
			if (j != 0) {
				cout << ' ' << flush;
			}
			cout << hyou[i][j] << flush;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - i +1):
    if i * 10000 + j * 5000 + (n - i -j) * 1000 == y:
      print(i, j, n-i-j)
      exit()
print("-1 -1 -1")

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

typedef long long ll;

ll n;
int a[200005];

ll k;

vector<int> g;
ll tmp;
ll u;
bool use[200005];
int dist[200005];

void dfs(int v, ll d)
{

    if (use[v])
    {
        u = v;
        tmp = d - dist[v];

        return;
    }

    g.push_back(v);
    use[v] = true;
    dist[v] = d;
    dfs(a[v], d + 1);
    return;
}
int main()
{

    cin >> n >> k;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    dfs(0, 0);

    ll i = 0;

    /*for (int i = 0; i < g.size(); i++)
    {
        cout << g[i] << endl;
    }
    
     cout << "tmp = " << tmp << endl;*/
    while (u != g[i])
    {
        i++;
        k--;
        if (k == 0)
        {
            cout << g[i] + 1 << endl;
            return 0;
        }
    }

    k %= tmp;
    //cout << k << endl;
    cout << g[i + k] + 1 << endl;
}

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

int solve(int n,vector<int> x){
    int min=INT_MAX,suumo;
    for(int i=0;100>=i;i++){
        suumo=0;
        for(int j=0;n>j;j++){
            suumo += pow((x[j]-i),2);
            }
        if(min>suumo){
            min = suumo;
            }
    }
    return min;
}

int main(void){
    int n,ans;
    vector<int> x(100);
    scanf("%d",&n);
    for (int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    ans = solve(n,x);
    printf("%d\n",ans);
    return 0;
}   



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n%1000==0)
        cout<<0<<'\n';
    else
        cout<<abs((n%1000)-1000)<<'\n';
    return 0;
}


Measured memory_bytes: 3676
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
  int X=int.Parse(Console.ReadLine());
  int A=int.Parse(Console.ReadLine());
  int B=int.Parse(Console.ReadLine());
    int ans=X;
      ans-=A;
      while(ans>=B){
        ans-=B;
      }
      Console.WriteLine(ans);
}
  }

}


Measured memory_bytes: 27364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    string s;
    cin >> s;
    ll n = s.length();

    //2文字条件
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == s[i + 1])
        {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }

    //3文字条件
    for (int i = 0; i < n - 2; i++)
    {
        if (s[i] == s[i + 2])
        {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    int K; cin >> K;
    string S; cin >> S;

    if (S.size() <= K)
        cout << S;
    else {
        rep (i, 0, K) cout << S.at(i);
        cout << "...";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N + 1), v(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, -1e9));
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (i == 0) {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j + w[i] <= W) {
                dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i - 1][j] + v[i]);
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i <= W; i++) {
        ans = max(ans, dp[N][i]);
    }
    cout << ans << endl;
}

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

int main() {
  int K;
  cin >> K;
  if (K % 2 == 0 || K % 5 == 0)
    cout << -1 << endl;
  else {
    vector<long long> vec(K);
    vec.at(0) = 7 % K;
    for (int i = 1; i < K; i++)
      vec.at(i) = vec.at(i-1) % K * 10 + 7;
    int counter = -1;
    for (int i = 0; i < K; i++) {
      if (vec.at(i) % K == 0) {
        counter = i + 1;
        break;
      }
    }
    cout << counter << endl;
  }
}


Measured memory_bytes: 11172
#include <bits/stdc++.h>
#define int long long

using namespace std;




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

    int x, y;
    cin >> x >> y;
    if(y % 2 == 0) {
        if(y <= 4*x && y >= 2*x) cout << "Yes\n";
        else cout << "No\n";
    }
    else cout << "No\n";



    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long k = sc.nextLong();
		long ans = 0;
		char front = s.charAt(0);
		int frnum = 0;
		for(int i = 0; i < s.length(); i++) {
			if(front == s.charAt(i)) {
				frnum++;
			} else {
				break;
			}
		}
		if(frnum == s.length() && s.length() % 2 == 1) {
			ans = s.length() * k / 2;
		} else {
			int num = 0;
			for(int i = 0; i < s.length(); i++) {
				if(front == s.charAt(i)) {
					num++;
				} else {
					ans += num / 2;
					num = 1;
					front = s.charAt(i);
				}
			}
			ans += num / 2;
			ans *= k;
			if(frnum % 2 == 1 && num % 2 == 1 && s.charAt(0) == s.charAt(s.length() - 1)) {
				ans += k - 1;
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
n = int(input())
nums = [int(i) for i in input().split()]

cnt = 0
for num in nums:
    if num < 0:
        cnt += 1

nums = [abs(num) for num in nums]
if cnt % 2 == 0:
    print(sum(nums))
else:
    print(sum(nums) - 2 * min(nums))


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

int main(){
  int n,k; cin>>n>>k;
  vector<int> a(n);
  for(int i=0; i<n; ++i)cin>>a[i];

  sort(a.begin(), a.end());
  vector<int> kind;
  int l=1, memo=a[0];
  for(int i=1; i<n; ++i){
    if(a[i]==memo)++l;
    else{
      kind.push_back(l);
      memo=a[i];
      l=1;
    }
  }
  kind.push_back(l);

  sort(kind.begin(), kind.end());
  if(kind.size()<=k)cout<<0<<endl;
  else{
    int ans=0;
    for(int i=0; i<kind.size()-k; ++i)ans+=kind[i];
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 2168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		int l[] = new int[m];
		int r[] = new int[m];

		int maxL = 0;
		int minR = Integer.MAX_VALUE;

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			l[i] = Integer.parseInt(str[0]);
			r[i] = Integer.parseInt(str[1]);
			maxL = Math.max(maxL, l[i]);
			minR = Math.min(minR, r[i]);
		}
		int ans = (minR - maxL) + 1;
		if (ans < 0) {
			ans = 0;
		}
		System.out.println(ans);
	}
}

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

int main(){
    int N; cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
    }

    sort(S.begin(), S.end());
    int i = 0;
    int ans = 1;
    for(int j = 0; j < N; j++){
        if(S.at(i) != S.at(j)){
            ans ++;
            i = j;
        }
    }
    cout  << ans << endl;
}

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

int main() {
    int N, K, x, ans = 0;
    cin >> N >> K;

    rep (i, N) {
        cin >> x;
        if (x <= K){
            if ((K - x) < x){
                ans += 2 * (K - x);
            }
            else{
                ans += 2 * x;
            }
        }
        else{
            if ((x - K) < x){
                ans += 2 * (x - K);
            }
            else{
                ans += 2 * x;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
        int x, y;
        string ans = "";
        cin >> x >> y;
        int mn = x*2, mx = x*4;
        if(x == 1 && (y == 2 || y == 4)){
                ans = "Yes";
        }else if(y >= mn && y <= mx) {
                int q = (2*x) - (y/2);
                int k = x-q;
                if((q+k == x) && (y == 4*k + 2*q)) {
                        ans = "Yes";
                }else {
                        ans = "No";
                }
        }else {
                ans = "No";
        }
        cout << ans << "\n";
        return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<queue>
#include<stack>
#include<ctype.h>
#define MAX_N 100000000

using namespace std;

int main(){
    char str[1010];
    for(int i=0;i<1000;i++){
        scanf("%c",&str[i]);
        if(str[i]=='\n')break;
        if(str[i]!='A'&&str[i]!='B'&&str[i]!='C')str[i]=str[i]-3;
        else str[i]=str[i]+23;
    }

    for(int i=0;i<1000;++i){
        printf("%c",str[i]);
        if(str[i]=='\n')break;
    }
    return 0;
}

Measured memory_bytes: 1104
#include<iostream>
#include<vector>
using namespace std;
#define FOR(i,a) for(int i=0;i<a;i++)
int goisi[1000000];
int hennka[1000000];

int kaitou(){
	int kosu;
	cin>>kosu;
	if(kosu==0){return 1;}
	FOR(i,kosu){cin>>goisi[i];}
	int lastgoisi=0;
	int lasthennka=0;
	FOR(i,kosu){
		if(i%2==0){
			if(goisi[i]!=lastgoisi){
					lastgoisi=goisi[i];
					hennka[lasthennka]=i;
					lasthennka++;
				}
		}
		if(i%2==1){
			if(goisi[i]!=lastgoisi){
				lastgoisi=goisi[i];
				if(lasthennka!=0){hennka[lasthennka-1]=0;lasthennka--;}
			}
		}
	}
	int ans=0;
	for(int i=lasthennka-1;i>=0;i=i-2){
		if(i!=0){ans=ans+hennka[i]-hennka[i-1];}
		else{ans=ans+hennka[0];}
	}
	if(lastgoisi==0){ans=kosu-ans;}
	cout<<ans<<endl;return 0;
}

int main(){
while(1){
	int r=kaitou();
	if(r==1){break;}
}
return 0;
}

Measured memory_bytes: 3396
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    int K, T, s, ans;   cin >> K >> T;
    vector<int> v(T);
    s = 0;
    for(int i=0; i<T; i++){
        cin >> v[i];
        s += v[i];
    }
    ans = 0;
    for(int i=0; i<T; i++){
        if(v[i] >= (s+1)/2) ans += v[i] - (s - v[i]) - 1;
    }
    cout << ans;
}

Measured memory_bytes: 3572
N,M=map(int,input().split())
roads=[[] for i in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  roads[a].append(b)
  roads[b].append(a)
  
for i in range(N):
  print(len(roads[i]))

Measured memory_bytes: 3060
// atcoder/abc170/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int x, y;
  while (cin >> x >> y) {
    bool f = false;
    for (int i = 0; i <= 100; ++i) {
      for (int j = 0; j <= 100; ++j) {
        f = f || (i + j == x && i * 2 + j * 4 == y);
      }
    }
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 3692
a=-1,A=65,d;
char
*N="GKSOCNWLDFVTBRXHAJUPEMQI",
*E="PHLTIDOXQAGWECSUMBKVJFNR",
*R="BCDAFGHEJKLINOPMRSTQVWXU",
s[9];
main(c)
{
for(;c-48&&scanf("%s",s);a+=d/4+1)
{
(c=*s)<A?~a&&printf("%d\n",a),a=d=0:0;
if(c==78)d=N[d]-A;
if(c==69)d=E[d]-A;
if(c==82)d=R[d]-A;
if(c==83)d=N[N[N[d]-A]-A]-A;
if(c==87)d=E[E[E[d]-A]-A]-A;
if(c==76)d=R[R[R[d]-A]-A]-A;
}}

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

int main(){
	int n,i,ans = 0;
	cin >> n;
	int b[n - 1];
	for(i = 0; i < n - 1; i++){
		cin >> b[i];
	}

	ans = ans + b[0];
	for(i = 0; i < n - 2; i++){
		if(b[i] <= b[i+1]){
			ans = ans + b[i];
		}
		else if(b[i] > b[i+1]){
			ans = ans + b[i+1];
		}
	}
	ans = ans + b[n-2];

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
class WarshallFloyd:
    #O(V^3)で任意２頂点の最短距離
    def __init__(self,n,_first_index=0):
        self.v = n
        self._first_idx=_first_index
        self.d = [[float("INF")]*(n) for _ in range(n)]
        for i in range(n):
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        f=self._first_idx
        self.d[x-f][y-f] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
        return self.d
h,w=map(int,input().split())
war=WarshallFloyd(10)
for i in range(10):
    s=list(map(int,input().split()))

    for j in range(10):
        war.path(i,j,s[j])
dis=war.build()
from collections import Counter as co
l=[list(map(int,input().split())) for i in range(h)]
l=sum(l,[])
var=co(l).items()
print(sum([0]+[v*dis[k][1] for k,v in var if k!=-1]))

Measured memory_bytes: 96348
#include <iostream>
using namespace std;
int main()
{
  int N;
	cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    ans += 1.0/A;
  }
  cout << 1.0/ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int n = (x - z) / (y + z);

        System.out.println(n);
    }
}


Measured memory_bytes: 23764
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import math
def prime_division(x):
    q = int(math.sqrt(x))
    a = []
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            a.append([i,ex])
    if x>q:
        a.append([x,1])
    return a

def modinv2(x,r):
  return pow(x,r-2,r)

def comb(n,a,R):
    dend = 1
    for i in range(a):
        dend = (dend*(n-i))%R
    sor = 1
    for i in range(2,a+1):
        sor = (sor*i)%R
    return (dend*modinv2(sor,R))%R

n,m = inm()
pl = prime_division(m)
prod = 1
for p,e in pl:
    prod = (prod * comb(e+n-1,e,R))%R
print(prod)


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

// ABC043 B - バイナリハックイージー
int main(){
  string s;
  cin >> s;

  string ans;
  rep(i,s.size()){
    if (s[i] == '0') {
      ans += "0";
    } else if (s[i] == '1') {
      ans += "1";
    } else {
      if (ans.size() > 0) {
        ans.pop_back();
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, q;
string s;

int main() {
	cin >> n >> s >> q;
	s = string(n, '-') + s;
	
	inc(qq, q) {
		int k;
		cin >> k;
		
		LL d = 0, m = 0, dm = 0, ans = 0;
		inc(ii, n) {
			int i = ii + n;
			if(s[i - k] == 'D') { d--; dm -= m; }
			if(s[i - k] == 'M') { m--; }
			if(s[i] == 'D') { d++; }
			if(s[i] == 'M') { m++; dm += d; }
			if(s[i] == 'C') { ans += dm; }
		}
		
		cout << ans << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3332
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b; //隣り合う辺の長さ
    int c; //対角線の長さ
    int rectangular = 0, rhombus = 0; //長方形と菱形の個数
     
    while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
        if(a * a + b * b == c * c) rectangular++;
        else if(a == b) rhombus++;
    }
    cout << rectangular << endl;
    cout << rhombus << endl;
}


Measured memory_bytes: 3068
#include<iostream>
#include<iterator>
#include<vector>
using namespace std;
int gcd(int a,int b){
    return b == 0 ?  a : gcd(b,a%b);
}

int main()
{
	int a,b,k;
	cin >> a >> b >> k;
	int memo_i =0;
  	int count = 0;
	for(int i = gcd(a,b);i>=1;i--){
	    if(a % i == 0 && b % i ==0){
	        memo_i=i;
          	count++;
	    }
	    if(k<=count)
	        break;
	}
	cout << memo_i;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

using namespace std;
int main(){
    int N;
    cin >> N;
    if (N%10==9||N/10==9){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
int A,B,C,D;
bool x;
cin>>A>>B>>C>>D;
for(int i=0;A>=0||C>=0;i++){
    C-=B; if(C<=0){x=true;break;}
    A-=D; if(A<=0){x=false;break;}
}
if(x)cout<<"Yes";
else cout<<"No";

return 0;
}

Measured memory_bytes: 3104