akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
from functools import partial, reduce
from operator import mul
prod = partial(reduce, mul)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, M = LI()
    for i in range(N, int(M ** 0.5) + 1):
        if M % i == 0:
            return M // i
    for i in range(min(N - 1, int(M ** 0.5), M // N), 0, -1):
        if M % i == 0:
            return i
    return 1

print(main())

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

#define LL long long
LL a, b, c, d;

LL f(LL x) {
    LL i = (a + x - 1) / x;
    LL j = b / x;
    return j - i + 1;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    cin >> a >> b >> c >> d;
    LL g = __gcd(c, d);
    g = (c * d) / g;
    cout << (b - a + 1 - f(c) - f(d) + f(g));   
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>

using namespace std ;
int main () {
  char S[101010];
  scanf("%s", S);
  bool app[26];
  for(int i=0;i<26;i++) {
    app[i] = false;
  }
  for(int i=0;S[i] != '\0';i++) {
    app[S[i]-'a'] = true;
  }
  for(int i=0;i<26;i++) {
    if(!app[i]) {
      printf("%c\n", (char)(i + 'a'));
      return 0;
    }
  }
  puts("None");
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
vector<ll> v;
//primeiro a escolher
ll dp[3005][3005];
//segundo a escolher
ll s[3005][3005];


void solve(int i, int j)
{
	if(dp[i][j] >= 0)
		return;

	if(i == j)
	{
		dp[i][j] = v[i];
		s[i][j] = 0;
		return;
	}

	solve(i+1, j);
	solve(i, j-1);


	ll t1 = v[i] + s[i+1][j];
	ll t2 = v[j] + s[i][j-1];

	if(t1 > t2)
	{
		dp[i][j] = t1;
		s[i][j] = dp[i+1][j];
	}
	else
	{
		dp[i][j] = t2;
		s[i][j] = dp[i][j-1];
	}


}


int main()
{

	cin >> n;

 	memset(dp, -1, sizeof(dp));
 
 	ll num;
 	for (int i = 0; i < n; ++i)
 	{
 		cin >> num;
 		v.push_back(num);
 	}

 
 	solve(0, n - 1);


 	cout << dp[0][n-1] - s[0][n-1] << endl;














    return 0;
}

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

using namespace std;
const int N=2e5+5;
long long a[N];
int n;
long long val(long long x)
{
    long long ret=0;
    for(int i=1;i<=n;i++)
    {
        long long t=a[i]+x;
        ret+=abs(t);
    }
    return ret;
}
long long bs()
{
    int s=-2e9,e=2e9,mid;
    while(s<e)
    {
        long long mid=(s+e)/2;
        if(val(mid+1)<val(mid))
            s=mid+1;
        else if(val(mid-1)<val(mid))
            e=mid-1;
        else return mid;
    }
    return s;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]-=i;
    }
    long long x=bs(),ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=abs(a[i]+x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  int a[n];
  rep(i,n) R a[i];
  int ans=-1;
  rep(i,n) {
    REP(j,i+1,n) {
      int x=a[i]*a[j];
      stringstream ss;
      string s;
      ss << x;
      ss >> s;
      bool f=1;
      rep(k,s.size()-1) {
        if(s[k]>=s[k+1]||abs(s[k]-s[k+1])!=1) f=0;
      }
      if(f) ans=max(ans,x);
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
#define pui pair<int, pair<int,int> >
using namespace std;
 
 
void solve(){
    
    int n;
    cin>>n;

    vecl arr(n);
    bool zer0 = false;
    rep(i,n) {
        cin>>arr[i];
        if(arr[i] == 0) {
            zer0 = true;
        }
    }

    if(zer0) {
        cout<<0;
        return ;
    }

    int64_t ans = 1;

    rep(i,n) {
       // cout<<ans<<" ";
        if(ans  > 1000000000000000000 / arr[i]) {
            ans = -1;
            break;
        } else {
            ans = ans * arr[i];
        }
       // cout<<ans<<endl;
    }

    cout<<ans;


   
}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(10);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}



Measured memory_bytes: 3916
n,m=map(int,input().split())
mod = 10**9+7
fac = [1]
caf = [1]

def pow(n,p):
    res=1
    while p >0:
        if p%2==0:
            n = n**2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod

for i in range(1,2*(10**5)):
    fac.append((fac[i-1]*i)%mod)
    caf.append(pow(fac[i],mod-2))

def ncr(n,r):
    if n < r: return 0
    return fac[n]*caf[r]*caf[n-r]

import collections

fl = [1] * 10**5
fl[0] = 0
fl[1] = 0
lprime=[]
for i in range(10**5):
    if fl[i] == 1:
        lprime.append(i)
        ti = i*2
        while ti < n:
            fl[ti] = 0
            ti += i

def prime_factorize(n):
    global lprime
    a = []
    for p in lprime:
        if p * p > n:break
        while n % p == 0:
            a.append(p)
            n //= p
    if n != 1:
        a.append(n)
    return a

tres = prime_factorize(m)
ctres = collections.Counter(tres)
res = 1
for sc in ctres.values():
    res *= ncr(n+sc-1,sc)
    res %= mod
print(res)

Measured memory_bytes: 68700
import math
data = [int(s) for s in input().split()]
sum = 0
for i in range(1, data[0]+1):
  if i >= data[1]:
    sum += 1/data[0]
  else:
    l = (math.ceil(math.log2(data[1]/i)))
    sum += (1 / data[0]) * (1/2) ** l
print(sum)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
  int p_price[3], j_price[2], i, pmin, jmin;

  for(i = 0; i < 3; i++)
    scanf("%d", &p_price[i]);

  for(i = 0; i < 2; i++)
    scanf("%*c%d", &j_price[i]);
 
    pmin = p_price[0];
    jmin = j_price[0];

    for(i = 1; i < 3; i++){
      if(pmin > p_price[i])
	pmin = p_price[i];
    }

    if(jmin > j_price[1])
      jmin = j_price[1];

    printf("%d\n", pmin+jmin-50);

    return 0;
}

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

int main()
{
    int k = 0, s = 0, i = 0, x = 0, j = 0;
    cin >> k >> s;
    for(i = 0; i <= k; i++)
    {
        for(j = 0; j <= k; j++)
        {
                if((s - i - j) <= k && s - i - j >= 0)
                    {
                        x++;

                    }
        }
    }
    cout << x;


return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long l = sc.nextLong();
        long r = sc.nextLong();
        long gap = Math.min((r - l), 2018);
        l %= 2019;
        r %= 2019;
        
        long ans = 2019;

        if (r <= l) {
            ans = 0;
        } else {
            for (long i = l; i < l + gap; i++) {
                for (long j = i + 1; j <= l + gap; j++) {
                    long value = i * j % 2019;
                    ans = Math.min(ans, value);
                    if (ans == 0) {
                        break;
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int count = 0;
  for(int i=0;i<c;i++) {
    b -= a;
    if(b >= 0) {
      count++;
    }
    else {
      break;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(x==0)return 0;if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}




int main()
{       io 
int testcases=1;      //  cin>>testcases;
while(testcases--)
{

int n;
cin>>n;

ll a[n];
for(int i=0;i<n;i++)
{cin>>a[i];
a[i]*=-1;
}

vi dp;

for(int i=0;i<n;i++)
{
	int pos=lte(dp,a[i]);
	if(pos==dp.size())
	dp.pb(a[i]);
	else
	dp[pos]=a[i];
}

cout<<dp.size();

}return 0;}


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

int main(){
	string s;
	cin >> s;
	int cnt=0,ans=0;
	char prev;
	for(int i=0;i<(int)s.length();i++){
		if(i==0) {
			prev=s[i];
			cnt=1;
		}
		else{
			if(s[i]==prev) cnt++;
			if(s[i]!=prev){
				if(prev=='R') ans=max(cnt,ans);
				cnt=1;
				if(prev=='R') prev='S';
				else prev='R';
			}
		}
	}
	if(prev=='R') ans=max(cnt,ans);
	cout << ans << '\n';
}

Measured memory_bytes: 3620
<?php
    $n = trim(fgets(STDIN));
	$p = explode(" ", trim(fgets(STDIN)));
	
	for($i=1; $i<=$n; $i++){
	    $a[$i] = $i * 30000;
	    $b[$i] = ($n - $i) * 30000 + 1;
	}
	for($i=0; $i<$n; $i++){
	    $a[$p[$i]] += $i;
	}
	
	for($i=1; $i<=$n; $i++){
	    echo $a[$i];
	    if($i<$n) echo " ";
	}
	echo "\n";
	for($i=1; $i<=$n; $i++){
	    echo $b[$i];
	    if($i<$n) echo " ";
	}
	
?>

Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int MOD=1e9+7;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
ULL pw(ULL a, ULL n){ ULL b=1; while(n){ if(n&1){ b=(b*a)%MOD; } a=(a*a)%MOD; n>>=1; } return b; }

int main(){
ULL N, ans=0; cin >> N;
ans=(pw(10, N)+pw(8, N))%MOD;
ans=(ans+MOD-((2*pw(9, N))%MOD))%MOD;
cout << ans << "\n";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){

    int a, b;
    cin >> a >> b;

    if(a > 2*b) cout << a-2*b;
    else cout << "0";

    return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
anser_list = []
anser_list.append(abs(b-a) + abs(c-b))
anser_list.append(abs(c-a) + abs(b-c))
anser_list.append(abs(a-b) + abs(c-a))
anser_list.append(abs(c-b) + abs(a-c))
anser_list.append(abs(a-c) + abs(b-a))
anser_list.append(abs(b-c) + abs(a-b))

print(min(anser_list))


Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	if (a == b && b == c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = []
for _ in range(N):
    S.append(str(input()))

n_ac = S.count("AC")
n_wa = S.count("WA")
n_tle = S.count("TLE")
n_re = S.count("RE")

print(f"AC x {n_ac}")
print(f"WA x {n_wa}")
print(f"TLE x {n_tle}")
print(f"RE x {n_re}")

Measured memory_bytes: 16204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char c[] = in.next().toCharArray();
            int sum = 0;
            for (int i = 0; i < c.length; ++i) {
                sum += c[i] - '0';
            }
            if (sum % 9 == 0) out.println("Yes");
            else out.println("No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int s;
    cin >> s;
    int dp[s + 1] = {};
    dp[3] = 1;
    for(int i = 4; i <= s; i++){
        dp[i] = 1;
        for(int j = 3; j <= i; j++){
            dp[i] += dp[i - j];
            dp[i] %= mod;
        }
    }

    cout << dp[s] << '\n' ;
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c;
    scanf("%d",&n);
    int a[n+5];
    for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(i=1;i<n;i++)
    {
        if((a[i]-a[i-1])==0)
        {
            c=1;
            break;
        }
        else if((a[i]-a[i-1])!=0)
        {
            c=0;
        }
    }
    if(c==0)
    {
        printf("YES\n");
    }
    else if(c==1)
    {
         printf("NO\n");
    }
    return 0;

}


Measured memory_bytes: 1024
/*Ph@n^0m Dec0d3r*/
/*----------------*/
/* 	^_HAR HAR MAHADEV_^
   	|Om namah shivaya|
*/
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define fast std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pb(temp) push_back(temp)
#define mp make_pair
#define mod (ll)1000000007
//using namespace boost::multiprecision;
using namespace std ;
typedef unsigned long long int ulli;

ulli gcd(ulli x,ulli y) {
	if(x==0) return y;
	return gcd(y%x,x);
}
ulli factorial(ulli n) {
	if (n == 0)
		return 1;
	return n * factorial(n - 1);
}
ll findS(ll s) {
	return (sqrtl(8*s + 1) - 1)/2;
}
bool prime(ll a) {
	if(a==1)return false;
	if(a==2 || a==3)return true;
	if(a%2==0 ||a%3==0)return false;
	for(ll i=5; i<=sqrt(a); i+=6)
		if(a%i==0 || a%(i+2)==0)
			return false;

	return true;
}
ll power(ll x,ll y) {
	if (y == 0)
		return 1;
	ll p = power(x, y/2) % mod;
	p = (p * p) % mod;

	return (y%2 == 0)? p : (x * p) % mod;
}
ll powermod(ll x,ll y) {
	ll res = 1;
	x = x % mod;
	while (y > 0) {
		if (y & 1)
			res = (res*x) % mod;
		y = y>>1;
		x = (x*x) % mod;
	}
	return res;
}
ll nCr(ll n,ll k) {
	ll C[k+1];
	//memset(C, 0, sizeof(C));

	C[0] = 1;

	for (ll i = 1; i <= n; i++) {
		for (ll j = min(i, k); j > 0; j--)
			C[j] = (C[j] + C[j-1])%(ll)(1e9 + 7);
	}
	return C[k];
}
ll LOGN(ll n , ll r) {
	return (n > r-1) ? (1 + LOGN(n / r , r)) : 0 ;
}
void dfs(vector<ll> v[], bool visited[], ll current_node) {
	visited[current_node]=true;
	for(ll nxt_node : v[current_node]) {
		if(visited[nxt_node]==false) {
			dfs(v , visited, nxt_node);
		}
	}
	return;
}

void bfs(vector<ll> v[], bool visited[], ll root) {

	int current_node;
	queue<int> q;

	q.push(root);

	while(!q.empty()) {

		current_node=q.front();

		visited[current_node]=true;

		for(int x:v[current_node])
			if(!visited[x])
				q.push(x);
	}
}
ll computeXOR(ll n) {
	switch(n & 3) {
		case 0:
			return n;
		case 1:
			return 1;
		case 2:
			return n + 1;
		case 3:
			return 0;
	}
}
int maxSubArraySum(int a[], int size) {
	int max_so_far = a[0];
	int curr_max = a[0];
	for (int i = 1; i < size; i++) {
		curr_max = max(a[i], curr_max+a[i]);
		max_so_far = max(max_so_far, curr_max);
	}
	return max_so_far;
}
int main() {
	fast;
	ll x ;
	cin >> x ;
	if(prime(x))cout << x ;
	else {
		ll tmp = x ;
		while(!prime(tmp)) {
			tmp ++ ;
		}
		cout << tmp ; 
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n,a,count=0;
    scanf("%d",&n);
    if(n<=100)
    {
        int x[n];
        for(i=0;i<n;i++)
        {
            scanf("%d",&a);
            if(a>=0 && a<=1000)
            {
                x[i]=a;
                count++;
            }
        }
        if(count==n)
        {
            for(i=n-1;i>=0;i--)
            {
                if(i==0)
                    printf("%d\n",x[i]);
                else
                    printf("%d ",x[i]);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1844
n, k = map(int, input().split())
h = list(map(int, input().split()))
INF = 10**18

dp = [INF] * (n)
dp[0] = 0

for i in range(n):
    for j in range(1, k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))
        else:
            break
print(dp[-1])

Measured memory_bytes: 52592
//suhan lee,saitama university

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <complex>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n) for(int i=0;i<n;i++)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
#define pb push_back 
#define pf push_front

string rev(string s){
  string ret = s;
  repn(i,s.size()/2) {
    swap(ret[i], ret[s.size() - i - 1]);
  }
  return ret;
}

int solve(){
  string s;
  cin >> s;
  set<string> ss;
  int n = s.size();
  rep(i, 1, n) {
    string sl = s.substr(0, i);
    string sr = s.substr(i);
    //cout << sl << ", " << sr << endl;
    ss.insert(sr + sl);
    ss.insert(rev(sr) + sl);
    ss.insert(sr + rev(sl));
    ss.insert(rev(sr) + rev(sl));
    ss.insert(sl + sr);
    ss.insert(rev(sl) + sr);
    ss.insert(sl + rev(sr));
    ss.insert(rev(sl) + rev(sr));
  }
  return ss.size();
}

int main(){

  int m;
  cin >> m;
  repn(i,m) cout << solve() << endl;

  return 0;
}

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

int main(){
  int n ,num;
  string seg="0000000"; // a b c d e f g の順
  string set[10]={ /* 各数字のビット */
    "0111111", // 0
    "0000110", // 1
    "1011011", // 2
    "1001111", // 3
    "1100110", // 4
    "1101101", // 5
    "1111101", // 6
    "0100111", // 7
    "1111111", // 8
    "1101111"  // 9
  };

  while( true ){ // -1まで
    cin >> n;
    if( n == -1 ){
      break;
    }

    for( int i=0 ; i<n ; i++ ){
      cin >> num;
      for( int j=0 ; j<7 ; j++ ){
	if( seg[j] != set[num][j] ){ // ビットが違ったら
	  cout << '1';
	}
	else{ // 同じなら
	  cout << '0' ;
	}
      }
      seg = set[num];
      cout << endl;
    }

    seg = "0000000"; // セグメントを0のに初期化
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <map>

using namespace std;

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

	long long S = 0;
	map<long long, int> m;
	for (int i = 0; i < N; ++i) {
		long long A;
		cin >> A;
		S += A;
		++m[A];
	}

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		long long B, C;
		cin >> B >> C;
		int cnt = m[B];
		S -= B * cnt;
		S += C * cnt;
		m[B] = 0;
		m[C] += cnt;

		cout << S << endl;
	}
}


Measured memory_bytes: 9572
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
// 配列中の重複削除
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,ans=0;
    cin >> n;
    string s[200002];
    map<string, llong> mp;
    rep(i,n){
        cin >> s[i];
        mp[s[i]]++;
        if(mp[s[i]] == 1) ans++;
    }
    cout << ans << endl;
}

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

ans = 0
for i in range(A,B+1):
    s = str(i)
    N = len(s)-1
    l = (len(s) // 2) + 1
    for j in range(l):
        if s[j] == s[N-j]:
            continue
        else:
            break
    else:
        ans += 1

print(ans)


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll T[100005];
//! 右回り、左回りでi番目まで取った時のエネルギー最大値
ll R[100005], L[100005];

int main()
{
    ll N, C;
    cin >> N >> C;
    REP(i, N)
    {
        cin >> T[i].first >> T[i].second;
    }
    ll rv = 0, lv = 0;
    REP(i, N)
    {
        ll l = T[i].first;
        lv += T[i].second;
        L[i] = lv - l;
        ll r = C - T[N - 1 - i].first;
        rv += T[N - 1 - i].second;
        R[i] = rv - r;
        if (i > 0)
        {
            L[i] = std::max(L[i], L[i - 1]);
            R[i] = std::max(R[i], R[i - 1]);
        }
    }

    ll max = 0;
    rv = 0;
    lv = 0;
    REP(i, N)
    {
        {
            //! 左回りにiまで歩いて食べ、そこから右回りに戻ってi+1までの最大値分食べる
            ll l = T[i].first;
            lv += T[i].second;
            ll m = std::max(lv - 2 * l + R[N - 2 - i], lv - l);
            max = std::max(max, m);
        }
        {
            //! 右回りにiまで〜
            ll r = C - T[N - 1 - i].first;
            rv += T[N - 1 - i].second;
            ll m = std::max(rv - 2 * r + L[N - 2 - i], rv - r);
            max = std::max(max, m);
        }
    }
    cout << max << endl;
    return 0;
}

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

int main() {
  vector<long int> L(87);
  int N;
  L[0]=2;L[1]=1;
  cin>>N;
  for(int i=2;i<=N;i++){
    L[i]=L[i-1]+L[i-2];
  }
  cout<<L[N];
}

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

int main() {
  long long n, k;
  cin >> n >> k;

  if (n % k == 0) {
    cout << 0 << endl;
    return 0;
  }

  long long temp;
  temp = n - k * (n / k);
  if (temp < abs(temp - k)) cout << temp << endl;
  else cout << abs(temp - k) << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

fn main() {
    let n = read_i64() as usize;
    let xs = read_vec_i64();
    let mut even_sum = vec![0; n+1];
    for i in 0..n {
        even_sum[i+1] = even_sum[i] + tf!(i % 2 == 0, xs[i], 0);
    }
    let mut odd_sum = vec![0; n+1];
    for i in 0..n {
        odd_sum[i+1] = odd_sum[i] + tf!(i % 2 == 1, xs[i], 0);
    }
    if n % 2 == 0 {
        let even_s = even_sum[n] - even_sum[0];
        let odd_s  = odd_sum[n] - odd_sum[0];
        println!("{} {}", max(even_s, odd_s), min(even_s, odd_s));
    }
    else {
        let mut lower = 0;
        let mut upper = 1i64 << 30;
        while upper - lower != 1 {
            let x = (lower+upper)/2;
            let mut ys = xs.clone();
            let mut l = 0;
            let mut r = n;
            while r - l != 1 {
                if ys[l] >= x && ys[l+1] >= ys[l] {
                    l += 2;
                }
                else {
                    ys[l+2] = ys[l] - ys[l+1] + ys[l+2];
                    l += 2;
                }
            }
            let yes = ys[l] >= x;
            if yes {
                lower = x;
            }
            else {
                upper = x;
            }
        }
        let black = lower + odd_sum[n];
        let white = even_sum[n] + odd_sum[n] - black;
        println!("{} {}", black, white);
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 22256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();

		char[] ca = str.toCharArray();
		for (int i = 0; i < ca.length; i++) {
			System.out.print( ca[ca.length-1 - i] );
		}
		System.out.println();
	}

}

Measured memory_bytes: 26280
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n >= 30){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 35644
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
double dp[310][310][310];
int main()
{
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  rep(i,n+1) rep(j,n+1) rep(k,n+1) dp[i][j][k] = -1;
  dp[0][0][0] = 0;
  
  auto rec = [&](auto f, int i, int j, int k)-> double{
	       if(i < 0 || j < 0 || k < 0) return 0;
	       if(dp[i][j][k] >= 0) return dp[i][j][k];
	       double res = n;
	       res += i*f(f, i-1, j, k);
	       res += j*f(f, i+1, j-1, k);
	       res += k*f(f, i, j+1, k-1);
	       res /= (double)(i + j + k);
	       return dp[i][j][k] = res;
	     };
  
  vector<int> cnt(3, 0);
  rep(i,n) cnt[a[i]-1]++;
  printf("%.9f\n", rec(rec, cnt[0], cnt[1], cnt[2]));
  
  return 0;
}


Measured memory_bytes: 227584
def main ():
  N = int(input())
  A = list(map(int,input().split()))
  if 0 in A:
    print (0)
    return
  prod = 1 
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod) 
main ()

Measured memory_bytes: 21580
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
typedef long long int llint;

int main(void){
  char c;
  std::cin >> c;
  std::cout << char(c+1) << std::endl;
  return 0;
}


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

int main(){
string s;
cin>>s;
int ans=0;
rep(i,s.size()){
    int count=0;
    for(int j=i;j<s.size();j++){
        
    if(!(s[j]=='A'||s[j]=='G'||s[j]=='C'||s[j]=='T')){
    break;
    }
    count++;
   
    
    }
 ans=max(ans,count);
}
cout<<ans;
}




Measured memory_bytes: 3592
n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())
mn_h=min(h)
mx_h=max(h)
for C_x in range(101):
  for C_y in range(101):
    for i in range(n):
      H=h[i]+abs(x[i]-C_x)+abs(y[i]-C_y)
      if H>0:
        if all(max(H-abs(x[j]-C_x)-abs(y[j]-C_y),0)==h[j] for j in range(n)):
          print(C_x,C_y,H)
          exit()

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
  int s,w; cin>>s>>w;
  if(w>=s)cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;
}

Measured memory_bytes: 3632
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    rep(i,0,n) cout<<a[i]<<b[i];
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;

const int MOD = 1000000007;

void solve()
{
    int H, W;
    cin >> H >> W;

    vector<vector<char>> grid(H, vector<char>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> grid[i][j];
        }
    }

    vector<vector<int>> dp(H, vector<int>(W, -1));
    dp[0][0]=1;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (grid[i][j]=='#') {
                continue;
            }
            if (i==0&&j==0) {
                dp[i][j]=1;
                continue;
            }
            int left;
            if (j==0) {
                left=0;
            } else if (grid[i][j-1]=='#') {
                left=0;
            } else {
                left=dp[i][j-1];
            }
            int top;
            if (i==0) {
                top=0;
            } else if (grid[i-1][j]=='#') {
                top=0;
            } else {
                top=dp[i-1][j];
            }
             
            dp[i][j]=(left+top) % MOD;
        }
    }
    //dbg(dp);
    cout << dp[H-1][W-1] << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 5248
dic={"A":{"0":"X","1":"Y"},
     "X":{"0":"E","1":"Z"},
     "Y":{"0":"X","1":"E"},
     "Z":{"0":"W","1":"B"},
     "W":{"0":"B","1":"Y"},
     "B":{"0":"Y","1":"X"},
     "E":{"0":"E","1":"E"}}

while True:
    route=raw_input()
    if route=="#":break
    state="A"
    for r in route:
        state=dic[state][r]
    print "Yes" if state=="B" else "No"

Measured memory_bytes: 4236
package main

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

func main() {
	A := nextInt64()
	B := nextInt64()

	N := gcd(A, B)
	divisors := map[int64]bool{}

	for i := int64(1); i*i <= N; i++ {
		if N%i != 0 {
			continue
		}
		if isPrime(i) {
			divisors[i] = true
		}
		if isPrime(N/i) && i < N/i {
			divisors[N/i] = true
		}
	}
	// fmt.Println(N, divisors)
	fmt.Println(len(divisors))
}

func gcd(a, b int64) int64 {
	if b > a {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func root(a int64) int64 {
	i := int64(1)
	for i*i <= a {
		i++
	}
	return i
}

func isPrime(a int64) bool {
	if a == 2 {
		return true
	}
	if a%2 == 0 {
		return false
	}

	for i := int64(3); i*i <= a; i += 2 {
		if a%i == 0 {
			return false
		}
	}
	return true
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        
        int h = 0;
        int count = 0;
        
        for (int i = 0; i < n; i ++) {
            int in = s.nextInt();
            if (in >= h) {
                h = in;
                count ++;
            }
        }
        
        System.out.println(count);
        
    }
    
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define mst(a,b) memset(a,b,sizeof(a))
typedef long long ll;
ll a[10000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        ll sum=0;
        for(int i=0;i<=n-1;i++){
            cin>>a[i];
            sum+=a[i];
            sum--;
        }
        cout<<sum<<endl;
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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; }

int main()
{   
    ll a;
    double b;
    cin >> a >> b;
    ll nb = (b+0.005)*100;
    cout << a * nb / 100 << endl;

    return 0;
}


Measured memory_bytes: 3696
#include<stdio.h>
#include<string.h>
int main()
{	
	int a,b,c,i,k,p,q;
	scanf("%d%d",&a,&b);
	char z[a][b];
	getchar();
	for(i=0;i<a;i++){
	for(p=0;p<b;p++)scanf("%c",&z[i][p]);
	getchar();}
	for(i=0;i<a-1;i++)
	for(p=0;p<a-1-i;p++)
	{
		if(strcmp(z[p],z[p+1])>0)
		for(q=0;q<b;q++)
		{
			c=z[p][q];
			z[p][q]=z[p+1][q];
			z[p+1][q]=c;
		}	
	}
	for(i=0;i<a;i++)
	for(p=0;p<b;p++)printf("%c",z[i][p]);
	printf("\n");
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string a,b;
	cin>>a>>b;
	a+=b;
	int t=stoi(a);
	rep(i,10000)if(i*i==t){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
}











Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	
	public static void main(String args[]){
      
	  Scanner scanner = new Scanner(System.in);
      String input = scanner.nextLine();
      
	  String nums[] = input.split(" ");
	  
	  long blue = Long.parseLong(nums[1]);
	  long red = Long.parseLong(nums[2]);
	  long sum = Long.parseLong(nums[0]);
	  
	  long count = sum / (blue + red);
	  long amari = sum % (blue + red);
	  
	  if(amari < blue){
	    System.out.println((count * blue)+amari);
	  }else{
	    System.out.println((count * blue)+blue);
	  }
	  
	}
}


Measured memory_bytes: 23764
n = int(input())
b = []
c = []
answer = 0
for i in range(0,5):
    c.append(int(0))
for i in range(0,n):
    b.append(input())
for i in range(0,n):
    if b[i][0] == 'M':
        c[0] += 1
    else:
        if b[i][0] == 'A':
            c[1] += 1
        else:
            if b[i][0] == 'R':
                c[2] += 1
            else:
                if b[i][0] == 'C':
                    c[3] += 1
                else:
                    if b[i][0] == 'H':
                        c[4] += 1
for i in range(0,3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            answer += c[i]*c[j]*c[k]
print(answer)
        

Measured memory_bytes: 10144
n = int(input())
line = [[] for i in range(n)]
for i in range(n):
    inputlist = input().split()
    line[i].append(inputlist[0])
    line[i].append(int(inputlist[1]))
    line[i].append(i+1)
line.sort(key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(line[i][2])

Measured memory_bytes: 38256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        ulong x = ulong.Parse(input[1]);
        ulong y = ulong.Parse(input[0]) - x;
        ulong sum = 0;
        sum += x;
        sum += y;
        while (x != 0)
        {
            sum += (2 * x) * (y / x);
            ulong tmp = y;
            y = x;
            x = tmp % x;
        } 
        sum -= y;
        Console.WriteLine(sum);
    }
}

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

using namespace std;

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

	long long A[N];
	for (int i=0; i<N; i++) {
		cin >> A[i];
	}
	sort(A, A+N);

	long long S = 1;
	int use = 0;

	long long before = -1;
	for (int i=N-1; i>=0; i--) {
		if (before == A[i]) {
			// 2 stick
			use++;
			S *= A[i];
			if (use == 2) {
				cout << S << endl;
				return 0;
			}
			before = -1;
		} else {
			before = A[i];
		}
	}
	cout << 0 << endl;


	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int main(){
    int nam;
    int counter = 0;
    double omosa;
    double takasa;
    double BMI = 0;
    while (scanf("%d,%lf,%lf",&nam,&omosa,&takasa)!=EOF) {
        BMI=omosa/pow(takasa,2);
        if (BMI >= 25) {
            printf("%d\n",nam);
            counter++;
        }
    }
    if (counter == 0) {
        printf("該当なし\n");
        }
    return 0;
}

Measured memory_bytes: 628
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

s = input_s
t = input_s

if t[0..-2] == s
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14328