akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 1000000007
#define INF 1e14
typedef long long int ll;
const ll N=1e5+5;
bool x[N+1]={false};
ll fast(ll n,ll a)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a)%Mod;
        if(n%2==0)
        {
            return (((res%Mod)*(res%Mod))%Mod);
        }
        else{
            return (((((res%Mod)*a)%Mod)*res)%Mod);
        }
    }
}

int main()
{
    ll n,i;
    cin>>n;
    ll a[n];
    ll j;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n+1];
    dp[1]=1;
    for(i=2;i<=n;i++)
    {
        if(a[i-1]<=a[i-2])
            dp[i]=dp[i-1]+1;
        else
            dp[i]=1;
    }
    ll ans=0;
    for(i=1;i<=n;i++)
        ans=max(ans,dp[i]);

    cout<<ans-1;




}


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

int N, M, i, j, Ans, sub, judg, r, L[100000], R[100000];
int main()
{
	cin >> N >> M;
	for (i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
		if (L[0] < L[i])
			L[0] = L[i];
		if (R[0] > R[i])
			R[0] = R[i];	
	}
	if (R[0] >= L[0])
		Ans = R[0] - L[0] + 1;
	else
		Ans = 0;
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define P pair<ll,ll>
#define F first
#define S second
#define vll vector<ll>
#define pb push_back
#define M 1000000007
#define for1(i,n) for(ll i=1;i<=n;i++)
#define for0(i,n) for(ll i=0;i<n;i++)
#define forab(i,a,b,c) for(ll i=a;i<=b;i+=c)
using namespace std;
int main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	ll a[n];
	ll sum = 0;
	ll freq[100000];
	memset(freq, 0, sizeof(freq));
	ll vis[100000];
	memset(vis, 0, sizeof(vis));
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
		vis[a[i]] = 1;
		freq[a[i]]++;
	}
	ll q;
	cin >> q;
	while (q--)
	{
		ll x, y;
		cin >> x >> y;
		if (vis[x] == 1)
		{	sum -= freq[x] * x;
			sum += freq[x] * y;
			freq[y] += freq[x];
			freq[x] = 0;
			vis[x] = 0;
			vis[y] = 1;
		}
		cout << sum << "\n";
	}
	return 0;
}

Measured memory_bytes: 5928
#include <bits/stdc++.h>
using namespace std;
#define fastt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define enl "\n"
#define ll long long
#define pb push_back
#define fi first
#define se second
#define vvl vector<vector<ll>> 
#define vl vector<ll> 
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define mtc ll t; cin>>t; while(t--)
#define rep(i,s,n) for(ll i = s; i < n; ++i)
#define sz(a) (ll)a.size()
#define PI 3.14159265 
ll mod=1e9+7;
ll k;

pll find(string &s1,string &s2,int i,int j,vector<vector<pll>> &dp){
    if(i>=sz(s1)||j>=sz(s2))return {0,i};
    if(dp[i][j].fi!=-1)return dp[i][j];
    pll ans;
    if(s1[i]==s2[j]){
        ans=find(s1,s2,i+1,j+1,dp);
        return dp[i][j]={ans.fi+1,i};
    }
    ans=find(s1,s2,i+1,j,dp);
    pll a2=find(s1,s2,i,j+1,dp);
    ans=ans.fi>a2.fi?ans:a2;
    return dp[i][j]=ans;
}

 int main(){
     fastt;
     string s1,s2;
     cin>>s1>>s2;ll i,j,k;
     vector<vector<pll>> dp(sz(s1),vector<pll>(sz(s2),{-1,-1}));
     pll ans=find(s1,s2,0,0,dp);string st="";
    k=ans.fi;
    rep(i,ans.se,sz(s1)){
        for(j=0;j<sz(s2);j++){
            if(k==0)break;
            if(dp[i][j].fi==k&&i==dp[i][j].se){st+=s1[i];k--;break;}
        }
    }
    cout<<st<<enl;
}


Measured memory_bytes: 141824
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(vector<int> a, vector<int> b){
    for (int i=0;i<a.size();i++) {
        for (int j=0;j<b.size();j++) {
            cout << a[i] << " " << b[j] << endl;
        }
    }
    return 0;
}

int main(){
    int N;
    cin >> N;
    
//    P_list[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
//
//    int P;
//    for (int i=0;i<15;i++) {
//        if (N%P_list[i]==0 or (N+1)%P_list[i]==0) {
//            P = Plist[i];
//            break;
//        }
//    }
//
//    vector<int> v[50];
//    if (N%P==0) {
//
//    }
    
    int P;
    vector<int> v[59];
    if (N%2==0) {
        P = N/2;
        for (int i=0;i<P;i++) {
            v[i].push_back(1+i);
            v[i].push_back(N-i);
        }
        if (P!=2){
            cout << 4*P << endl;
            for (int i=0;i<P;i++) {
                Func(v[i],v[(i+1)%P]);
            }
        }
        else {
            cout << 4*(P-1) << endl;
            Func(v[0],v[1]);
        }
    }
    else {
        P = (N+1)/2;
        v[0].push_back(N);
        for (int i=1;i<P;i++) {
            v[i].push_back(i);
            v[i].push_back(N-i);
        }
        if (P!=2){
            cout << 4*(P-2) + 2*2 << endl;
            for (int i=0;i<P;i++) {
                Func(v[i],v[(i+1)%P]);
            }
        }
        else {
            cout << 2 << endl;
            Func(v[0],v[1]);
        }
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k,no,top=1;
int ans[15];
void dfs(int digit) {
	// cout<<"digit = "<<digit<<" ans[digit] = "<<ans[digit]<<'\n';
	if(digit==top) {
		no++;
		// cout<<"no = "<<no<<'\n';
		if(no==k) {
			for(int i=1;i<=top;i++)
				printf("%d",ans[i]);
			exit(0);
		}
		if(digit!=1) return;
	}
	// cout<<"went here\n";
	if(digit==1) {
		ans[digit]++;
		if(ans[digit]==10) ans[digit]=1,top++;
		if(top!=digit) {
			if(ans[digit]!=0) ans[digit+1]=ans[digit]-1,dfs(digit+1);
			ans[digit+1]=ans[digit],dfs(digit+1);
			if(ans[digit]!=9) ans[digit+1]=ans[digit]+1,dfs(digit+1);
		}
		// cout<<"went here\n";
		dfs(digit);
	}
	if(ans[digit]!=0) ans[digit+1]=ans[digit]-1,dfs(digit+1);
	ans[digit+1]=ans[digit],dfs(digit+1);
	if(ans[digit]!=9) ans[digit+1]=ans[digit]+1,dfs(digit+1);
	
}
int main() {
	scanf("%d",&k);
	ans[1]=1;dfs(1);
	return 0;
}

Measured memory_bytes: 384
from collections import deque
import sys
sys.setrecursionlimit(10**9)
n=int(input())
g=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
q=deque([0])
v=[0]*n
v[0]=1
gp=[[] for i in range(n)]
while q:
    p=q.popleft()
    for i in g[p]:
        if v[i]==0:
            v[i]=1
            gp[p].append(i)
            q.append(i)
MOD=10**9+7
flag=[0]*n
dp=[[0,0] for i in range(n)]
def f(i):
    if flag[i]:
        return 0
    flag[i]=1
    dp[i][0]=1
    dp[i][1]=1
    for j in gp[i]:
        f(j)
        dp[i][0]=dp[i][0]*(dp[j][0]+dp[j][1])%MOD
        dp[i][1]=dp[i][1]*dp[j][0]
        dp[i][0]%=MOD
        dp[i][1]%=MOD
    return 0
f(0)
print((dp[0][0]+dp[0][1])%MOD)


Measured memory_bytes: 120968
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}







int main() {
   string s,t;
    cin>>s>>t;
    for(int i=s.size()-t.size();i>=0;i--){
        bool ok=true;
        for(int j=0;j<t.size();j++){
            
            if(s[i+j]!='?' && s[i+j]!=t[j]){
                
                ok=false;
                break;
            }
        }
        if(ok==true){
            for(int k=0;k<s.size();k++){
                if(k==i){
                    cout<<t;
                    k+=t.size()-1;
                }
                else{
                    if(s[k]=='?')cout<<'a';
                    else cout<<s[k];
                }
            }
            cout<<endl;
            return 0;
           
        }
    }
    cout<<"UNRESTORABLE"<<endl;
}


  
  


Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int a,b;
  char op;

  scanf("%d %c %d",&a,&op,&b);

  while(op != '?') {
    if(op == '+') {
      printf("%d\n",a+b);
    } else if(op == '-') {
      printf("%d\n",a-b);
    } else if (op == '*'){ 
      printf("%d\n",a*b);
    } else if(op == '/') {
      printf("%d\n",a/b);
    } 
    scanf("%d %c %d",&a ,&op, &b);

  }

  return 0;

}



Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100001];
char s[100001];
signed main()
{
	cin>>s+1;
	int n=strlen(s+1);
	for(int i=1;i<n;i++)
		if(s[i]!=s[i+1])
		{
			printf("Yes");
			return 0;
		}
	printf("No");
	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 N=sc.nextInt();

      int n=N+1;

      int[] a = new int[n];

      for(int i=1;i<n;i++){
        a[i]=sc.nextInt();
      }

      int[] ans = new int[n];

      int sum1=0;

      for(int i=n-1;i>=1;i--){
      //////////////////////////////////////////////////////
      if(n/2<i){
          ans[i] = a[i];
        }
        else{
          for(int j=2*i;j<n;j+=i){ //there is 2*i, and 2*i<=N<n
            sum1 = sum1 + ans[j];
          }
          //////////////////////////////////////////
          if(sum1%2==a[i]){
            ans[i] = 0;
          }
          else{
            ans[i] = 1;
          }
          /////////////////////////////////////////
        }
        sum1=0;
      /////////////////////////////////////////////////////
      }

    ////////////////////////////////////////
      int m=0;
      for(int i=1;i<n;i++){
        m = m + ans[i];
      }

      System.out.println(m);

      for(int i=1;i<n;i++){
        if(ans[i]==1){
          System.out.print(i+" ");
        }
      }
    /////////////////////////////////////////

    }
}


Measured memory_bytes: 88660
using System;

namespace TokyoKaizyo
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputList = input.Split(" ");
            int.TryParse(inputList[0], out var a);
            int.TryParse(inputList[1], out var v);

            var input2 = Console.ReadLine();
            var inputList2 = input2.Split(" ");
            int.TryParse(inputList2[0], out var b);
            int.TryParse(inputList2[1], out var w);

            var input3 = Console.ReadLine();
            long.TryParse(input3, out var t);

            // 逃げる方が早かったら無理
            if (w >= v)
            {
                Console.WriteLine("NO");
                return;
            }

            if (t * (v - w) >= Math.Abs(a - b))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 27556
using System;

namespace ABC150A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            if (a * 500 >= b)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
const int N=2100;
 
int g0[N][N],g1[N][N],g2[N][N],g3[N][N],g4[N][N];
int h0[N][N],h1[N][N],h2[N][N],h3[N][N],h4[N][N];
int i,j,m,n,s,x,y,z;
char c;
 
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		z=x/m+y/m;
		x=x%m+1,y=y%m+1;
		getchar(),c=getchar();
		if (z&1)
			if (c=='B')
				c='W';
			else
				c='B';
		if (c=='B')
			g0[x][y]++;
		else
			h0[x][y]++;
	}
	for (i=1;i<=2*m;i++)
		for (j=1;j<=2*m;j++)
			g1[i][j]=g1[i-1][j]+g1[i][j-1]+g0[i][j]-g1[i-1][j-1];
	for (i=2*m;i>0;i--)
		for (j=1;j<=2*m;j++)
			g2[i][j]=g2[i+1][j]+g2[i][j-1]+g0[i][j]-g2[i+1][j-1];
	for (i=1;i<=2*m;i++)
		for (j=2*m;j>0;j--)
			g3[i][j]=g3[i-1][j]+g3[i][j+1]+g0[i][j]-g3[i-1][j+1];
	for (i=2*m;i>0;i--)
		for (j=2*m;j>0;j--)
			g4[i][j]=g4[i+1][j]+g4[i][j+1]+g0[i][j]-g4[i+1][j+1];
	for (i=1;i<=2*m;i++)
		for (j=1;j<=2*m;j++)
			h1[i][j]=h1[i-1][j]+h1[i][j-1]+h0[i][j]-h1[i-1][j-1];
	for (i=2*m;i>0;i--)
		for (j=1;j<=2*m;j++)
			h2[i][j]=h2[i+1][j]+h2[i][j-1]+h0[i][j]-h2[i+1][j-1];
	for (i=1;i<=2*m;i++)
		for (j=2*m;j>0;j--)
			h3[i][j]=h3[i-1][j]+h3[i][j+1]+h0[i][j]-h3[i-1][j+1];
	for (i=2*m;i>0;i--)
		for (j=2*m;j>0;j--)
			h4[i][j]=h4[i+1][j]+h4[i][j+1]+h0[i][j]-h4[i+1][j+1];
	for (i=1;i<=2*m;i++)
		for (j=1;j<=2*m;j++)
			if (g1[i][j]+g4[i+1][j+1]+h2[i+1][j]+h3[i][j+1]>s)
				s=g1[i][j]+g4[i+1][j+1]+h2[i+1][j]+h3[i][j+1];
	for (i=1;i<=2*m;i++)
		for (j=1;j<=2*m;j++)
			if (h1[i][j]+h4[i+1][j+1]+g2[i+1][j]+g3[i][j+1]>s)
				s=h1[i][j]+h4[i+1][j+1]+g2[i+1][j]+g3[i][j+1];
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 155776
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())

if N == 1:
    print("0")
    exit()

factors = factorization(N)

ans = 0
for factor in factors:
    num = factor[1]
    x = 1
    for i in range(num+1):
        if i**2 + i > 2*num:
            x = i-1
            break
#    print(num,x)                                                                                      
    ans += x

print(ans)


Measured memory_bytes: 9352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

mint dp[200100];
int l[200100];
int main() {
  int n;
  cin >> n;
  vi c(n+1,0);
  rep(i,n){
    cin >> c[i];
  }
  Fill(l,-1);
  dp[0] = 1;
  rep(i,n){
    dp[i+1] += dp[i];
    if(l[c[i]]>=0 && l[c[i]]<i-1)dp[i+1]+=dp[l[c[i]]+1];
    l[c[i]] = i;
    
  }
  cout<<dp[n].x<<endl;
  return 0;
}

Measured memory_bytes: 6412
# E
n = int(input())
from collections import deque
import bisect
first = int(input())
a = [first]
a = deque(a) # でキュー化

for i in range(n-1):
    num = int(input())
    
    if num <= a[0]:
        a.appendleft(num)
    else:
        ind = bisect.bisect_left(a, num)
        ind-=1
        a[ind]=num
print(len(a))

Measured memory_bytes: 47320
using System;
using System.Linq;

namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            int max = 0;

            for (int i = 0; i < S.Length - T.Length + 1; i++)
            {
                var str = S.Substring(i, T.Length);
                int num = 0;
                for (int j = 0; j < T.Length; j++)
                {
                    if (T.ElementAt(j) == str.ElementAt(j))
                        num++;
                }
                max = Math.Max(max, num);
            }

            System.Console.WriteLine(T.Length - max);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 42156
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

H=I()
W=I()
n=I()
ans=inf

for i in range(H+1):
    for j in range(W+1):
        if i*W-j*H-i*j>=n:
            ans=min(ans,i+j)
            

for j in range(W+1):
    for i in range(H+1):
        if i*H-j*W-i*j>=n:
            ans=min(ans,i+j)

print(ans)


Measured memory_bytes: 40300
n = int(input())
a = list(map(int,input().split()))
ans1 = abs(a[0]-1)
ans2 = abs(a[0]+1)
ans3 = 0
def f(x,y):
  for i in range(1,n):
    if y > 0:
      y += a[i]
      if y < 0:
        continue
      else:
        x += abs(y+1)
        y = -1
    else:
      y += a[i]
      if y > 0:
        continue
      else:
        x += abs(y-1)
        y = 1
  return x
if a[0] == 0:
  ans3 = float("inf")
else:
  ans3 = f(ans3,a[0])
print(min(ans3,f(ans1,1),f(ans2,-1)))

Measured memory_bytes: 63216
#include <bits/stdc++.h>
#define re return
#define ull unsigned long long
#define ll long long
#define ld long double
#define mid (l+r)/2
#define f first
#define s second
#define oo 1e9
#define pi acos(-1)
#define OO 1e18
#define EPS 1e-12
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define Hossam_Yehia ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
string s;
int main(){
    Hossam_Yehia;
    cin >> s;
    for(int i=0;i<s.size();++i)
        if(i%2==0)cout<<s[i];
    re 0;
}

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

int main(){
  int N;cin>>N;
  vector<int> a;
  a.resize(N);
  for (int i=0;i<N;++i) cin>>a[i];
  
  int ans=0;
  for (int i=1;i<N;++i){
    if (a[i]==a[i-1]){
      a[i]=-1;
      ++ans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;


int main(void) {

    char b; cin>>b;

    if(b=='A') cout<<'T'<<endl;
    if(b=='T') cout<<'A'<<endl;
    if(b=='C') cout<<'G'<<endl;
    if(b=='G') cout<<'C'<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d, am, bm, cm;
  cin >> N;

  a = N / 1000;
  am = 1000 * a;

  b = (N - am) / 100;
  bm = 100 * b;

  c = (N - am - bm) / 10;
  cm = 10 * c;

  d = N - am - bm - cm;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string a,b,ans="";
	cin>>a>>b;
	rep(i,a.size()+b.size()){
		if(i%2==0)ans+=a[i/2];
		else ans+=b[i/2];
	}
	cout<<ans<<endl;
	return 0;
}

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

static const int N = 1000;

int lcs(std::string X, std::string Y)
{
    int c[N + 1][N + 1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;

    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 0; i <= m; i++)
    {
        c[i][0] = 0;
    }
    for (int i = 0; i <= n; i++)
    {
        c[0][i] = 0;
    }

    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (X.at(i) == Y.at(j))
            {
                c[i][j] = c[i - 1][j - 1] + 1;
            }
            else
            {
                c[i][j] = std::max(c[i-1][j],c[i][j-1]) ;
            }
            maxl = std::max(maxl,c[i][j]) ;
        }
    }
    return maxl ;
}

int main()
{
    std::string s1,s2 ;
    int n;
    std::cin >> n ;
    for (int i = 0; i < n; i++)
    {
        std::cin >> s1 >> s2 ;
        std::cout << lcs(s1,s2) << std::endl ;
    }
    return 0 ;
}


Measured memory_bytes: 7064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		for(int j=1;j*j<=n-i;j++)
		{
			if((n-i)%j==0)
			{
				s++;
				if((n-i)/j!=j)s++;
			}
		}
	}
	printf("%d\n",s);
}

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

int main(){
    int N;
    string S, T, ans;
    cin>>N;
    cin>>S>>T;
    for(int i=0;i<N;i++){
        ans+=S[i];
        ans+=T[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
s=input().strip()
l=len(s)
t=s[::-1]
if s!=t:
    print('No')
    exit()
u=s[:l//2]
v=u[::-1]
if u!=v:
    print('No')
    exit()
u=s[(l+1)//2:]
v=u[::-1]
if u!=v:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            var str = Console.ReadLine().ToArray();

            if (str.Count() % 2 == 1) Console.WriteLine("No");
            else
            {
                for (int i = 0; i < str.Count(); i += 2)
                {

                    if (str[i] != 'h' || str[i + 1] != 'i')
                    {

                        Console.WriteLine("No");
                        return;

                    }


                }

                Console.WriteLine("Yes");
            }

        }


    }
}


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

int main(){
    ll n,m,x,a[12][12],sum[12],c[12],price,goal,ans=-1;
    cin >> n >> m >> x ;
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<(1<<n);i++){
        goal=0;
        price=0;
        for(int j=0;j<m;j++){
            sum[j]=0;
        }
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                price+=c[j];
                for(int k=0;k<m;k++){
                    sum[k]+=a[j][k];
                }
            }
        }
        for(int j=0;j<m;j++){
            if(sum[j]<x){
                goal=1;
            }
        }
        if(goal==0){
            if(ans==-1||ans>price){
                ans=price;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(int argc, char *argv[])
{
  int R[MAX], n;

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

  int maxv = -2000000000;
  int minv = R[0];

  for (int i=1; i < n; ++i) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}



Measured memory_bytes: 3868
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    ll a[n+1], b[n];
    ll sum = 0;
    for(ll i = 0; i < n+1; i++){
        cin >> a[i];
        sum+=a[i];
    }
    for(ll i = 0; i < n; i++)
        cin >> b[i];
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        a[i]-=b[i];
        if(a[i]<0){
            a[i+1]-=abs(a[i]);
            a[i]=0;
        }
        if(a[i+1]<0) a[i+1] = 0;
    }
    ll check = 0;
    for(ll i = 0; i < n+1; i++)
        check += a[i];
    cout << sum-check << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-6;
const double pi = atan2(0, -1);
const int ABC = 26;

/*struct node
{
    ll x, pr, sum, v, sum_v;
    node *L, *R;
    node()
    {
        L = R = NULL;
    }
    node(ll x, ll v)
    {
        this->x = x;
        this->pr = rand() << 15 | rand();
        this->sum = 1;
        this->v = v;
        this->sum_v = this->v;
        L = R = NULL;
    }
}

ll get_sum(node *t)
{
    if (t == NULL)
        return 0;
    else

}

void split()*/

struct coin
{
    ll a, b, c;
    coin() {}
    coin(ll a, ll b, ll c) : a(a), b(b), c(c) {}
};

bool operator < (coin x, coin y)
{
    return (x.a - x.b) > (y.a - y.b);
}

struct my_coin
{
    ll a, b;
    my_coin() {}
    my_coin(ll a, ll b) : a(a), b(b) {}
};

bool operator < (my_coin x, my_coin y)
{
    return (x.a - x.b) > (y.a - y.b);
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m, k;
    cin >> n >> m >> k;
    int s = n + m + k;
    vector<coin> A(s);
    rep(i, 0, s)
        cin >> A[i].a >> A[i].b >> A[i].c;
    sort(A.begin(), A.end());
    multiset<my_coin> mmm;
    ll cnt1[s], cnt2[s];
    fill(cnt1, cnt1 + s, -big);
    fill(cnt2, cnt2 + s, -big);
    ll sum = 0;
    rep(i, 0, n)
    {
        sum += A[i].a;
        mmm.insert(my_coin(A[i].a, A[i].c));
    }
    cnt1[n - 1] = sum;
    rep(i, n, n + k)
    {
        sum += A[i].a;
        mmm.insert(my_coin(A[i].a, A[i].c));
        my_coin d = *--mmm.end();
        mmm.erase(--mmm.end());
        sum -= d.a;
        sum += d.b;
        cnt1[i] = sum;
    }
    //
    mmm.clear();
    sum = 0;
    rep(i, 0, m)
    {
        sum += A[s - i - 1].b;
        mmm.insert(my_coin(A[s - i - 1].b, A[s - i - 1].c));
    }
    cnt2[s - (m - 1) - 1] = sum;
    rep(i, m, m + k)
    {
        sum += A[s - i - 1].b;
        mmm.insert(my_coin(A[s - i - 1].b, A[s - i - 1].c));
        my_coin d = *--mmm.end();
        mmm.erase(--mmm.end());
        sum -= d.a;
        sum += d.b;
        cnt2[s - i - 1] = sum;
    }
    ll ans = -big;
    rep(i, 0, s - 1)
        ans = max(ans, cnt1[i] + cnt2[i + 1]);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, d, x;
	cin >> n >> d >> x;

	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		x++;
		x += (d - 1) / a;
	}

	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> s(N);
    int res = 0;
    REP(i, N) {
        cin >> s[i];
        res += s[i];
    }

    if (res % 10 != 0) {
        cout << res << "\n";
        return 0;
    }
    SORT(s);
    REP(i, N) {
        if (s[i] % 10 == 0) {
            continue;
        } else {
            res -= s[i];
            break;
        }
    }
    if (res % 10 == 0) {
        cout << 0 << "\n";
    } else {
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
 
ALPHABET = "abcdefghijklmnopqrstuvwxyz"
 
 
def main(s, t):
    positions = {char: [] for char in ALPHABET}
    for i, char in enumerate(s):
        positions[char].append(i)
 
    current = 0
    answer = 0
    for char in t:
        pos_num = len(positions[char])
        if pos_num < 1:
            return -1
        idx = bisect_left(positions[char], current)
        if idx < pos_num:
            current = positions[char][idx] + 1
        else:
            answer += len(s)
            idx = bisect_left(positions[char], 0)
            current = positions[char][idx] + 1
 
    answer += current
    return answer
 
 
s = input()
t = input()
print(main(s, t))

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

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

    auto adjacency_list = vector<vector<int>>(N);
    for (auto i = 0; i < N-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    auto matched = vector<bool>(N);
    const function<void(int, int)> dfs = [&](const int v, const int parent)
    {
        for (const auto child : adjacency_list[v]) if (child != parent)
        {
            dfs(child, v);
            if (!matched[child] && !matched[v])
                matched[child] = matched[v] = true;
        }
    };
    dfs(0, -1);

    cout << (all_of(begin(matched), end(matched), [](const bool x) { return x; }) ? "Second" : "First") << endl;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  map<int, int> mp;
  rep(i, n) {
    int a; cin >> a;
    ++mp[a];
  }
  int ans = 0;
  for(int x = 0; x <= 100000; ++x) chmax(ans, mp[x-1]+mp[x]+mp[x+1]);
  cout <<  ans << endl;
}


Measured memory_bytes: 8292
import kotlin.math.min

fun main() {
    val n = readLine()!!.toInt()
    val leaves = readLine()!!.split(" ").map { it.toLong() }
    if (n == 0) {
        if (leaves[0] == 1L) {
            println(1)
        } else {
            println(-1)
        }
        return
    }
    var curr = 0L
    for (j in n downTo 1) {
        curr += leaves[j]
        curr = (curr + 1L) / 2L
    }
    curr += leaves[0]
    if (curr != 1L) {
        println(-1)
        return
    }
    val dp = LongArray(n + 2)
    for (j in n downTo 0) {
        dp[j] = dp[j + 1] + leaves[j]
        if (j <= 60) {
            dp[j] = min(dp[j], 1L shl j)
        }
    }
    for (j in 1..n) {
        dp[j] = min(dp[j], 2L * (dp[j - 1] - leaves[j - 1]))
    }
    println(dp.sum())
}

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

using namespace std;

int main()
{
    long long n,m3,m5,m15;
    cin>>n;
    long long sg=n*(n+1)/2;
    m3=3*(n/3*(n/3+1)/2);
    m5=5*(n/5*(n/5+1)/2);
    m15=15*(n/15*(n/15+1)/2);
    cout<<sg-m3-m5+m15;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
    #ifdef DGC
        freopen("a.txt", "r", stdin);
        //freopen("b.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> dif;
    vector<vector<int>> eq(n), adj(n);
    for (int i = 0, x, y, z; i < m; ++i)
    {
        cin >> x >> y >> z;
        --x, --y;
        if (z&1)
        {
            dif.emplace_back(x, y);
        }
        else
        {
            eq[x].push_back(y);
            eq[y].push_back(x);
        }
    }

    int id = 0;
    vector<int> comp(n, -1);
    function<void(int)> dfs = [&](int u)
    {
        comp[u] = id;
        for (auto v : eq[u])
            if (comp[v] == -1)
                dfs(v);
    };

    for (int u = 0; u < n; ++u)
        if (comp[u] == -1)
            dfs(u), ++id;

    for (auto i : dif)
        if (comp[i.F] != comp[i.S])
        {
            adj[comp[i.F]].push_back(comp[i.S]);
            adj[comp[i.S]].push_back(comp[i.F]);
        }

    int ans = 0;
    comp.assign(id, -1);
    function<void(int)> dfs2 = [&](int u)
    {
        comp[u] = ans;
        for (auto v : adj[u])
            if (comp[v] == -1)
                dfs2(v);
    };

    for (int u = 0; u < id; ++u)
        if (comp[u] == -1)
            dfs2(u), ++ans;

    cout << ans << "\n";

    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int x = 1900 * m + (n - m) * 100;
    int p = 1;
    rep(i, m) {
        p *= 2;
    }
    cout << p * x << endl;
    return 0;
}


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

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 200005;

ll mpow(ll base,ll ep) {
    if (ep == 0) {
        return 1;
    }
    ll hf = mpow(base,ep>>1);
    hf = hf * hf % MOD;
    return ep & 1 ? hf * base % MOD : hf;
}

ll fc[MAXN],ifc[MAXN];
void build() {
    fc[0] = ifc[0] = 1;
    REP1 (i,MAXN-1) {
        fc[i] = fc[i-1] * i % MOD;
        ifc[i] = mpow(fc[i],MOD-2);
    }
}

ll C(ll m,ll r) {
    return fc[m] * ifc[r] % MOD * ifc[m-r] % MOD;
}

ll n,a,b,c;
ll add;
/********** Good Luck :) **********/
int main()
{
    IOS();
    build();
    cin >> n >> a >> b >> c;
    add = 100 * mpow(100-c,MOD-2) % MOD;
    pii nw = {a*mpow(a+b,MOD-2)%MOD,b*mpow(a+b,MOD-2)%MOD};
    a = nw.X;
    b = nw.Y;
    ll e = 0;
    REP (i,n) {
        ll cur = C(n+i-1,i)*mpow(a,n) % MOD * mpow(b,i) % MOD;
        e = (e + cur*(i+n)) % MOD;
        // e = (e + cur ) % MOD;
    }

    REP (i,n) {
        ll cur = C(n+i-1,i)*mpow(a,i) % MOD * mpow(b,n) % MOD;
        e = (e + cur*(i+n)) % MOD;
        // e = (e + cur ) % MOD;
    }
    
    debug(e,add,e*add);
    cout << (e * add % MOD) << endl;
    return 0;
}


Measured memory_bytes: 3328
// AOJ Volume 1 Problem 0185 Goldbach's Conjecture II

#include <stdio.h>
#include <string.h>

char prime[1000000];

int main(void)
{
    int i, j;
    int n;
    int cnt;
    
    
    // ツ素ツ青板づーツ仰づ淞づゥ
    memset(prime, 0, sizeof(prime));
    prime[2] = 0;
    
    for (i = 2; i * i < 1000000; i++){
        if (prime[i] == 0){
            for (j = i + i; j <= 1000000; j += i){
                prime[j] = 1;
            }
        }
    }
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        cnt = 0;
        for (i = 2; i <= n / 2; i++){
            if (prime[i] == 0 && prime[n - i] == 0){
                cnt++;
            }
        }
        printf("%d\n", cnt);
    }
    
    
    return (0);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long a = in.nextLong();
    double b = in.nextDouble();
    long flooredB = (long) (b * 100 + 0.5);
    System.out.println(a * flooredB / 100);
    in.close();
  }
}

Measured memory_bytes: 36884
//Author: nimishkhurana
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(i=a;i<b;i++)
#define rrep(i,b,a) for(i=b;i>=a;i--)
#define ld long double
#define ll long long
#define umapi unordered_map<int,int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int> 
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define INF 1000000000000

template <typename T>
ostream& operator << (ostream& stream, const pair<T,T> &p) {
    return stream<<"("<<p.first<<","<<p.second<<") ";
}

const int mxn = 100, mxv = 1000;
ll dp[mxn][mxn*mxv+1]; //stores weight
int price[mxn];
ll weight[mxn];
int n;
ll w;

ll solve(int i, int val){
    if(val==0) return 0;
    if(i==n){
        return INF;
    }

    if(~dp[i][val]) return dp[i][val];

    ll &ans = dp[i][val];
    ans = solve(i+1, val);
    
    ll nxt = solve(i+1, val-price[i]);
    // if(nxt + weight[i] <= w)
        ans = min(ans, nxt + weight[i]);

    return ans;
}


int main(){
    fastIO
    
    cin>>n>>w;
    ll maxval = 0;
    for(int i = 0; i < n; i++){
        cin>>weight[i]>>price[i];
        maxval += price[i];
    }
    memset(dp, -1, sizeof(dp));
    int ans = 0;
    for(int i = maxval; i>=1; i--){
        if(solve(0, i) <= w){
            ans = i;
            break;
        }
    }

    // for(int i = 0; i < n; i++){
    //     for(int j = 0; j <= maxval; j++){
    //         cerr<<dp[i][j]<<" ";
    //     }
    //     cerr<<"\n";
    // }

    cout<<ans;
   
    return 0;
}

Measured memory_bytes: 78464
#include<stdio.h>

int main(void){
  struct{
    int i,p,q,r,c;
  }Kashi[1000];
  int P,Q,R,C;
  int i,j,k,n;

  while(scanf("%d",&n) && n){
    for(i=0;i<n;i++){
      scanf("%d%d%d%d",&Kashi[i].i,&Kashi[i].p,&Kashi[i].q,&Kashi[i].r);
      Kashi[i].c=4*(Kashi[i].p+Kashi[i].r)+9*Kashi[i].q;
    }
    scanf("%d%d%d%d",&P,&Q,&R,&C);
    for(i=j=0;i<n;i++)
      if(Kashi[i].p<=P && Kashi[i].r<=R && Kashi[i].q<=Q&& Kashi[i].c<=C)
	printf("%d\n",(j=1,Kashi[i].i));
    if(!j) puts("NA");
  }
  return 0;
}

Measured memory_bytes: 628
a,b,c,d = map(int,input().split())

from fractions import gcd
def f(n):
    #cとdの約数の個数をxに入れる
    x = n//c
    x += n//d
    #最小公倍数の約数を引く　例えば3,5であれば15の倍数を引く15,30,45...
    lcm = c*d // gcd(c,d)
    x -= n // lcm
    #どちらでも割れない
    return n-x

ans = f(b) - f(a-1)
print(ans)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll x,t; cin >> x >> t;
    out(max(0LL,x-t));
}


Measured memory_bytes: 256