akhauriyash/Code-Regression huggingface dataset:
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> orderedMultiset;
int solve()
{
	int r;
	cin>>r;
	cout<<3*r*r;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int N;
    scanf("%d", &N);
    
    int tmp;
    int * max = (int*) malloc (sizeof(int) * N);
    for(int i = 0; i < N ; i++){
        scanf("%d", &tmp);
        max[i] = (i == 0)? tmp : max[i-1]+tmp;
    }
    
    for(int i = 0; i < N; i++){
        scanf("%d", &tmp);
        int fromleft = (i == 0)? 0: max[i-1] + tmp;
        int fromtop  = max[i]+tmp;
        if(fromleft > fromtop){
            max[i] = fromleft;
        }else{
            max[i] = fromtop;
        }
    }
    printf("%d\n",max[N-1]);
}

Measured memory_bytes: 128
a, b, c = gets.split.map { |t| t.to_i }

k = gets.to_i

[0, 1].repeated_permutation(k) do |bits|
  x, y, z = a, b, c
  bits.each do |bit|
    if bit.zero?
      y *= 2
    else
      z *= 2
    end
  end
  
  if x < y && y < z
    puts "Yes"
    exit
  end
end

puts "No"

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

s = 0
m = 1000
for i in range(n-1):
  if a[i] < a[i+1]:
    tmp = m // a[i]
    s += tmp
    m -= tmp * a[i]
  else:
    m += s * a[i]
    s = 0
m += s * a[n-1]
s = 0
print(m)

Measured memory_bytes: 9184
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    char[] c = s.toCharArray();

    Arrays.sort(c);

    for (int i = 0; i < s.length()-1; i++) {
      if (c[i] == c[i+1]) {
        System.out.println("no");
        return;
      }
    }

    System.out.println("yes");

  }

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  int a[3][3],b[3][3];
  for(int i=0;i<3;i++)

  {
    for(int j=0;j<3;j++)
    {b[i][j]=0;
      cin>>a[i][j];
    }
    
  }
  int n;
  cin>>n;
  for(int k=1;k<=n;k++)
  {
    int x;
    cin>>x;
    for(int i=0;i<3;i++)
    {
      int ff=0;
      for(int j=0;j<3;j++)
      {
        if(a[i][j]==x)
        {
          b[i][j]++;
          ff=1;
          break;
        }

      }
      if(ff)
      {
        break;
      }
    }

  }
  /*cout<<"####"<<endl;
  for(int i=0;i<3;i++)
  {
    for(int j=0;j<3;j++)
    {
      cout<<b[i][j]<<" ";
    }
    cout<<endl;;
  }
  cout<<"#####"<<endl;*/
  int g=0;
  for(int i=0;i<3;i++)
  {int f=0;
    for(int j=0;j<3;j++)
    {
      if(b[i][j]<1)
      {
        f=1;
        break;
      }
    }
    if(f==0)
    {
      g=1;
      //cout<<"1"<<endl;
    }
    
  }
  if(g==0)
  {
    for(int i=0;i<3;i++)
    {
      int f=0;
      for(int j=0;j<3;j++)
      {
        if(b[j][i]<1)
        {
            f=1;
            break;
        }
      }
      if(f==0)
      {
        g=1;
        //cout<<2<<endl;
        
      }
    }
  }
  if(g==0)
  {
    if(b[0][0]>=1&&b[1][1]>=1&&b[2][2]>=1)
    {
      g=1;
    }
    if(g==0)
    {
      if(b[2][0]>=1&&b[1][1]>=1&&b[2][0]>=1)
    {
      g=1;
      //cout<<3<<endl;
    }
    }
  }
  if(g)
  {
    Yes
  }
  else
  {
    No
  }

}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef long long LL;
const int INF = 100000000;

using namespace std;
int main()
{
#ifdef LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int a;
    string s;

    cin >> a >> s;

    if(a >=3200){
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] s = sc.next().toCharArray();
        if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ) {
            System.out.println("Bad");
        } else {
            System.out.println("Good");
        }


    }

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
ll  N,A,B;
ll  x,now,pre;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>A>>B;
	cin>>pre;
	ll ans=0;
	for(int i=2;i<=N;i++){
		cin>>x;
		now=(x-pre)*A;
		ans+=min(now,B);
		pre=x;
	}
	cout<<ans<<"\n";
	return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

struct st{
	int x,y,k;P c;
};
bool operator<(st a,st b){
	return a.c>b.c;
}

int dx[]{1,-1,0,0},dy[]{0,0,1,-1};

int main(){
	int h,w,K;
	cin>>h>>w>>K;
	int sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy;
	sx--;sy--;gx--;gy--;
	vector<string>s(h);
	rep(i,h){
		cin>>s[i];
	}
	vector<vector<vector<P>>>d(h,vector<vector<P>>(w,vector<P>(5,P(INF,INF))));
	queue<st>que;
	d[sx][sy][4]=P(0,0);
	que.push({sx,sy,4,P(0,0)});
	while(!que.empty()){
		st p=que.front();que.pop();
		if(d[p.x][p.y][p.k]!=p.c)continue;
		rep(k,4){
			int nx=p.x+dx[k],ny=p.y+dy[k];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]!='@'){
				P cost=p.c;
				if(k==p.k&&cost.second<K)cost=P(cost.first,cost.second+1);
				else cost=P(cost.first+1,1);
				if(d[nx][ny][k]>cost){
					d[nx][ny][k]=cost;
					que.push({nx,ny,k,cost});
				}
			}
		}
	}
	P ans(INF,INF);
	rep(k,4){
		ans=min(ans,d[gx][gy][k]);
	}
	if(ans.first==INF)puts("-1");
	else cout<<ans.first<<endl;
}

Measured memory_bytes: 144952
import java.util.*;
import java.io.*;
import java.math.*;



public class Main {
	
	private static long gcd(long n, long m) {
//		int tmp = 0;
		while(n != m) {
			if(n > m) {
				n -= m;
			}
			else {
				m-= n;
			}
		}
		
		
		return n;
	}

//	private static int lcm(int n, int m) {
//		return n*m/gcd(n,  m);
//	}
	
	public static void main(String[] args) throws IOException{
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
        	long n = scan.nextInt();
        	long m = scan.nextInt();
        	long gcd = gcd(n, m);
        	System.out.println(gcd + " " + n * m / gcd);
        	
        }

        
	}
}
 

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

const int N = 100001;
int n, c[N * 21], s[N * 21], a[N];

inline int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - 48;
		ch = getchar();
	}
	return x * flag;
}

void add(int x) {
	for (int i = x; i <= 2 * N; i += i & -i) c[i]++;
}

int query(int x) {
	int res = 0;
	for (int i = x; i > 0; i -= i & -i) res += c[i];
	return res;
}

bool check(int x) {
	memset(c, 0, sizeof(c));
	s[0] = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] >= x) s[i] = s[i - 1] + 1;
		else s[i] = s[i - 1] - 1;
	}
	int res = 0;
	for (int i = 0; i <= n; ++i) {
		res += query(s[i] + N);
		add(s[i] + N);
	}
	return res >= (n + 1) * n / 4;
}

signed main() {
	n = read();
	int l = 0, r = 0, ans;
	for (int i = 1; i <= n; ++i) {
		a[i] = read();
		r = max(r, a[i]);
	}
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) l = mid + 1, ans = mid;
		else r = mid - 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


int main() {
    LL X, A;
    cin >> X >> A;
    if (X < A) {cout << "0" << endl;return 0;}
    cout << "10" << 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;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<int> L(n);
  rep(i,n) cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  rep(b,n)rep(a,b){
    int l = b+1;
    int r = lower_bound(L.begin(), L.end(), L[a]+L[b]) - L.begin();
    ans += r - l;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import sys

read = sys.stdin.buffer.read


def main():
    M, *DC = map(int, read().split())

    total = digits = 0
    for d, c in zip(DC[::2], DC[1::2]):
        total += d * c
        digits += c

    print(digits - 1 + (total - 1) // 9)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 96068
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;


namespace debug
{
    class Program
    {
        static void Main(string[] args)
        {
            ProgramB a = new ProgramB();
            a.main();

        }
    }

    //ABC096
    class ProgramA
    {
        public void main()
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            Console.WriteLine((a -1)*(b-1));
        }
    }

    class ProgramB
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());

            int ans = 0;
            for (int i = 1; i <= n; i = i + 2)
            {
                int count = 0;
                for (int j = 1; j < Math.Sqrt(i);j++)
                {
                    if(i % j == 0)
                    {
                        if (i == j * j)
                            count++;
                        else
                            count += 2;
                    }
                }

                if (count == 8)
                    ans++;
            }

            Console.WriteLine(ans);
            

        }
    }

    class ProgramC
    {
        public void main()
        {
            long n = long.Parse(Console.ReadLine());
            string[] xi = Console.ReadLine().Split(' ');

            long[] a = new long[n];

            for (int i = 0; i < n; i++)
                a[i] = long.Parse(xi[i]);

            //ソートする
            Array.Sort(a);

            //
            for (int i = 0; i < n; i++)
            {
                if (a[n / 2 - 1] >= long.Parse(xi[i]))
                    Console.WriteLine(a[n / 2]);
                else
                    Console.WriteLine(a[n / 2 - 1]);
            }
            
            

        }
    }

    class ProgramD
    {
        public void main()
        {
            long n = long.Parse(Console.ReadLine());
            string[] xi = Console.ReadLine().Split(' ');

            long[] a = new long[n];

            for (int i = 0; i < n; i++)
                a[i] = long.Parse(xi[i]);

            //ソートする
            Array.Sort(a);

            //最大値候補
            long sum = a[n - 1] / 2;

            //二分探索
            long min = -1;
            long max = n;
            while(min + 1 != max)
            {
                long temp = (min + max) / 2;
                if (a[temp] <= sum)
                    min = temp;
                else
                    max = temp;
            }

            if(min == -1)
            {
                Console.WriteLine(a[n - 1] + " " + a[0]);
                return;
            }

            if (min == n - 2)
            {
                Console.WriteLine(a[n - 1] + " " + a[n - 2]);
                return;
            }

            if (sum - a[min] < a[max] - sum)
                Console.WriteLine(a[n - 1] + " " + a[min]);
            else
                Console.WriteLine(a[n - 1] + " " + a[max]);

        }

    }

    

}


Measured memory_bytes: 27500
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll h, w, n;

bool grid_inside(int y, int x) {
  if(1 <= y && y < h - 1 && 1 <= x && x < w - 1) return true;
  else return false;
}

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

  cin >> h >> w >> n;

  vector<P> vp;

  REP(i, n) {
    int a, b;
    cin >> a >> b; a--; b--;
    vp.push_back(P(a, b));
  }

  map<P, int> mp;

  REP(i, n) {
    P p = vp[i];

    REP(i, 9) {
      int nx = dx9[i] + p.first;
      int ny = dy9[i] + p.second;
      if(grid_inside(nx, ny)) mp[P(nx, ny)]++;
    }
  }

  ll ans[11] = {0};
  for(auto& x:mp) {
    ans[x.second]++;
  }

  ans[0] = (w - 2) * (h - 2) - mp.size();
  REP(i, 10) cout << ans[i] << endl;
}


Measured memory_bytes: 57332
#include<iostream>
#include<vector>

using namespace std;

#define ll long long

int main(){
    int n, w;
    cin >> n >> w;
    vector<ll> dp(w+1);
    for(int i = 0; i < n; ++i){
        int weight, value;
        cin >> weight >> value;

        for(int weight_cal = w-weight; weight_cal >= 0; --weight_cal){
            dp[weight_cal+weight] = max(dp[weight_cal+weight], dp[weight_cal]+value);
        }
    }

    ll ans = 0;
    for(int i = 0; i <= w; ++i){
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in range(i, N):
            for k in range(j, N):
                tmp = [L[i], L[j], L[k]]
                tmp.sort()
                if len(tmp) == len(set(tmp)) and tmp[0] + tmp[1] > tmp[2]:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9120
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    mp[a] += b;
  }

  for (auto it = mp.begin(); it != mp.end(); it++) {
    int value = it->first;
    long long cnt = it->second;
    if (k <= cnt) {
      cout << value << endl;
      return 0;
    }
    k -= cnt;
  }
  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 998244353;
ll fact[210200];
ll invfact[210200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll powMod(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return powMod(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


vector<int> v[101000];
int dp[101000];


int dfs(int s){
    if(dp[s] != -1){
        return dp[s] + 1;
    }
    int ret = 0;
    for(auto vv: v[s]) {
        ret = max(ret, dfs(vv));
    }
//    cout << s << " " << ret << endl;
    dp[s] = ret;
    return ret + 1;
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;

        v[x].push_back(y);
    }

    fill(dp, dp+101000, -1);
    int res = 0;
    for(int i = 0; i < N; i++){
        dfs(i);
//        for(int j = 0; j < N; j++){
//            cout << dp[j] << endl;
//        }
//        cout << endl;
    }
    for(int i = 0; i < N; i++){
        res = max(res, dp[i]);
    }



    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define rep(i, _N) for ( int i = 0; i < _N; ++i )
typedef long long ll ;


int main() {
  int n = 0 ;
  cin >> n ;
  
  vector<int> b( n-1 ) ;
  rep( i, n-1 ) cin >> b[i] ;
  
  vector<int> a( n ) ;
  a[0] = b[0] ;
  for ( int i = 1 ; i < n-1 ; ++i ) {
    a[i] = min( b[i-1], b[i] ) ;
  }
  a[n-1] = b[n-2] ;
  
  int sum = std::accumulate(a.begin(), a.end(), 0);
  cout << sum << endl ;
  
  
  return 0 ; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 100000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define pii pair<long long int,long int>
#define mii map<long long int,long long int>
#define w(t) 	int t; cin>>t; while(t--)

using namespace std;

//ll c[MAX];




int main() {
	int n,k;
	cin>>n>>k;
	int cnt=0;
	vector<int> v;
	forn(i,n)	v.pb(0);
	forn(i,k){
		int d;
		cin>>d;
		forn(j,d){
			int x;
			cin>>x;
			v[x-1]++;
		}
	}
	forn(i,n){
		if(v[i]==0)		cnt++;
	}
	cout<<cnt;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int maxm=a[0];
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        if(maxm>a[i])
        {
            ans+=maxm-a[i];
        }
        else
        {
            maxm=a[i];
        }
    }
    cout<<ans;
  	return 0;
}







Measured memory_bytes: 5188
import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getVar(c):
    return map(c, input().split())
def getArray():
    return list(map(int, input().split()))
def getArray(c):
    return list(map(c, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')
def getNumpy(c):
    return np.array(list(map(c, input().split())))

def main():
    str = input().split()
    A = Decimal(str[0])
    B = Decimal(str[1])

    print(math.floor(A*B))


main()

Measured memory_bytes: 27200
# your code goes here
#polland
def nu(x):
    if x=="+" or x=="-" or x=="*":
        return 0
    else:
        return 1
def c(a,b,l):
    if l=="+":
        d=a+b
    elif l=="-":
        d=a-b
    else:
        d=a*b
    return d
F=[i for i in input().split()]
i=0
S=[]
while i<len(F):
    if nu(F[i])==0:
        S[-2]=c(S[-2],S[-1],F[i])
        S.pop(-1)
    else:
        S.append(int(F[i]))
    i+=1
print(S[0])

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,t;
    string str;
    cin>>str;
    if(str=="SUN")cout<<7<<"\n";
    else if(str=="MON")cout<<6<<"\n";
    else if(str=="TUE")cout<<5<<"\n";
    else if(str=="WED")cout<<4<<"\n";
    else if(str=="THU")cout<<3<<"\n";
    else if(str=="FRI")cout<<2<<"\n";
    else if(str=="SAT")cout<<1<<"\n";
 
 
    return 0;  
}

Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left
N=int(input())
d=deque()
for i in range(N):
    A=int(input())
    b=bisect_left(d,A)-1
    if b==-1:
        d.appendleft(A)
    else:
        d[b]=A
print(len(d))

Measured memory_bytes: 76228
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (B > N * A) {
			System.out.println(N*A);
		}else {
			System.out.println(B);
		}
	}
}

Measured memory_bytes: 21972
#include <iostream>
using namespace std;
int main(void){
string S;
cin>>S;
for(int i=0;i<S.length();i++){
    for(int j=i+1;j<S.length();j++){
        if(S[i]==S[j]){
            cout<<"no"<<endl;
            return 0;
        }
    }
}
cout<<"yes"<<endl;
}

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

int main(){
	string s;
	cin>>s;
	int start,finish;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A'){
			start=i;
			break;
		}
	}
	for(int i=s.length()-1;i>=0;i--){
		if(s[i]=='Z'){
			finish=i;
			break;
		}
	}
	cout<<finish-start+1;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;

int main()
{
    fastio;
    int N, K, Q;
    vector<int> As;
    cin >> N >> K >> Q;
    copy_n(istream_iterator<int>(cin), Q, back_inserter(As));

    vector<int> scores(N, K);
    for (auto a : As)
    {
        scores[a - 1]++;
    }
    transform(scores.begin(), scores.end(), scores.begin(), [Q](int score) { return score - Q; });

    for (auto score : scores)
    {
        cout << ((score > 0) ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 1528
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int n, x;
	while (cin >> n >> x && n > 0) {
		int ans = 0;
		for (int i = 1; i <= n; ++i) {
			for (int j = i + 1; j <= n; ++j) {
				for (int k = j + 1; k <= n; ++k) {
					if (i + j + k == x)
						ans++;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
     
int main(){
  int a,b,c,d,e,f,g,h,A,B;
  cin>>a>>b>>c>>d>>e>>f>>g>>h;
  A=a+b+c+d;
  B=e+f+g+h;
  if(A>B){
    cout<<A<<endl;
  }else{
    cout<<B<<endl;
  }
  return 0;
}

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

lst = [['.'] * N for _ in range(N)]

def calc3(x, y): #基準x, yから3×3マスを塗る
    lst[x][y] = 'a'
    lst[x][y + 1] = 'a'

    lst[x][y + 2] = 'b'
    lst[x + 1][y + 2] = 'b'

    lst[x + 2][y + 2] = 'c'
    lst[x + 2][y + 1] = 'c'

    lst[x + 2][y] = 'd'
    lst[x + 1][y] = 'd'

if N % 3 == 0:
    for h in range(0, N, 3):
        for w in range(0, N, 3):
            calc3(h, w)

    for i in lst:
        print (*i, sep = '')
    exit()

def calc4(x, y):
    lst[x][y] = 'a'
    lst[x][y + 1] = 'a'

    lst[x + 1][y] = 'b'
    lst[x + 1][y + 1] = 'b'

    lst[x + 2][y + 2] = 'c'
    lst[x + 2][y + 3] = 'c'


    lst[x + 3][y + 2] = 'd'
    lst[x + 3][y + 3] = 'd'

    lst[x + 2][y] = 'e'
    lst[x + 3][y] = 'e'

    lst[x + 2][y + 1] = 'f'
    lst[x + 3][y + 1] = 'f'

    lst[x][y + 2] = 'g'
    lst[x + 1][y + 2] = 'g'

    lst[x][y + 3] = 'h'
    lst[x + 1][y + 3] = 'h'

if N % 4 == 0:
    for h in range(0, N, 4):
        for w in range(0, N, 4):
            calc4(h, w)

    for i in lst:
        print (*i, sep = '')
    exit()

def calc5(x, y):
    lst[x][y] = 'a'
    lst[x][y + 1] = 'a'

    lst[x][y + 2] = 'b'
    lst[x][y + 3] = 'b'

    lst[x][y + 4] = 'c'
    lst[x + 1][y + 4] = 'c'


    lst[x + 1][y] = 'd'
    lst[x + 2][y] = 'd'

    lst[x + 1][y + 1] = 'e'
    lst[x + 2][y + 1] = 'e'

    lst[x + 2][y + 4] = 'f'
    lst[x + 3][y + 4] = 'f'

    lst[x + 3][y] = 'g'
    lst[x + 4][y] = 'g'

    lst[x + 3][y + 2] = 'h'
    lst[x + 3][y + 3] = 'h'

    lst[x + 4][y + 1] = 'i'
    lst[x + 4][y + 2] = 'i'

    lst[x + 4][y + 3] = 'j'
    lst[x + 4][y + 4] = 'j'

if N % 5 == 0:
    for h in range(0, N, 5):
        for w in range(0, N, 5):
            calc5(h, w)

    for i in lst:
        print (*i, sep = '')
    exit()

def calc7(x, y):
    lst[x][y + 1] = 'a'
    lst[x][y + 2] = 'a'

    lst[x][y + 3] = 'b'
    lst[x][y + 4] = 'b'

    lst[x][y + 5] = 'c'
    lst[x][y + 6] = 'c'

    lst[x + 1][y] = 'd'
    lst[x + 2][y] = 'd'

    lst[x + 1][y + 3] = 'e'
    lst[x + 1][y + 4] = 'e'

    lst[x + 1][y + 5] = 'f'
    lst[x + 1][y + 6] = 'f'

    lst[x + 3][y] = 'g'
    lst[x + 4][y] = 'g'

    lst[x + 3][y + 1] = 'h'
    lst[x + 4][y + 1] = 'h'

    lst[x + 3][y + 2] = 'i'
    lst[x + 4][y + 2] = 'i'

    lst[x + 5][y] = 'j'
    lst[x + 6][y] = 'j'

    lst[x + 5][y + 1] = 'k'
    lst[x + 6][y + 1] = 'k'

    lst[x + 5][y + 2] = 'l'
    lst[x + 6][y + 2] = 'l'
    
    lst[x + 2][y + 3] = 'm'
    lst[x + 2][y + 4] = 'm'

    lst[x + 2][y + 5] = 'n'
    lst[x + 2][y + 6] = 'n'

if N % 7 == 0:
    for h in range(0, N, 7):
        for w in range(0, N, 7):
            calc7(h, w)

    for i in lst:
        print (*i, sep = '')
    exit()

if N <= 2:
    print (-1)
    exit()

count = 0
n = N
while True:
    if n % 5 == 0:
        flag = True
        break
    if n % 7 == 0:
        flag = False
        break
    n -= 4
    count += 1

for i in range(count):
    calc4(4 * i, 4 * i)


if flag:
    for i in range(4 * count, N, 5):
        calc5(i, i)
else:
    for i in range(4 * count, N, 7):
        calc7(i, i)


for i in lst:
        print (*i, sep = '')



Measured memory_bytes: 13476
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
} Node;

Node *nil;

Node *listSearch(int key){
  Node *now =nil->next;
  while (now !=nil && now->key !=key)
    {
      now = now->next;
    }
  return now;
  
}

void init(){
  nil =(Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if ( cur == nil ) break;
    if ( isf++ > 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  
  if(t==nil) return ;
  t->prev->next =t->next;
  t->next->prev =t->prev;
  free(t);
}



void deleteFirst(){
  deleteNode(nil->next);
}


void deleteLast(){
  deleteNode(nil->prev);
}

void deletekey(int key){
  deleteNode (listSearch(key));
}


void insert(int key){
  Node *x=(Node *) malloc(sizeof(struct node));
  x->key = key;
  x->next =nil->next;
  nil->next->prev =x;
  nil->next =x;
  x->prev =nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20],b[20]="insert",c[20]="delete",d[20]="deleteFirst",e[20]="deleteLast";
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s",com);
    if ( strcmp(com,b)==0 ) {
       scanf("%d",&key);
      insert(key);
      np++;
      size++;
    }
    else if ( strcmp(com,c)==0 )
      { scanf("%d",&key);
	deletekey(key);
	nd++;
	size--;
      }
    else if (strcmp(com,d)==0 )
      {
	deleteFirst();
	size--;
      }
    else if (strcmp(com,e)==0 )
      {
	deleteLast();
	size--;
      }
  }
  
  printList();
  return 0;
}



Measured memory_bytes: 33016
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;

void solve(){
    int x,y,z;cin>>x>>y>>z;
    cout << (x-z)/(y+z) <<endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
using ll = long long;

int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

int lcm(int a,int b){
    return a*b/gcd(a,b);
}

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>n>>d;
    
    
    cout<<(n-1)/(d*2+1)+1<<endl;
}






Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>
#include <set>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;
// Union Find begin

class UnionFind {
 private:
  vector<ll> _par;
  vector<ll> _rank;
 public:
  explicit UnionFind(ll n);
  ll find(ll x);
  void unite(ll x, ll y);
  bool isSame(ll x, ll y);
};

UnionFind::UnionFind(ll n) {
  for (ll i = 0; i < n; ++i) {
    _par.push_back(i);
    _rank.push_back(0);
  }
}

ll UnionFind::find(ll x) {
  if (_par.at(static_cast<unsigned long>(x)) == x) return x;
  else return _par.at(static_cast<unsigned long>(x)) = find(_par.at(static_cast<unsigned long>(x)));
}

void UnionFind::unite(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (_rank.at(static_cast<unsigned long>(x)) < _rank.at(static_cast<unsigned long>(y)))
    _par.at(static_cast<unsigned long>(x)) = y;
  else {
    _par.at(static_cast<unsigned long>(y)) = x;
    if (_rank.at(static_cast<unsigned long>(x)) == _rank.at(static_cast<unsigned long>(y)))
      ++_rank.at(static_cast<unsigned long>(x));
  }

}

bool UnionFind::isSame(ll x, ll y) {
  return find(x) == find(y);
}

// Union Find end

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n, k, l;
  ccin >> n >> k >> l;
  UnionFind unf_k(n), unf_l(n);
  rep(i, k) {
    ll p, q;
    ccin >> p >> q;
    --p;
    --q;
    unf_k.unite(p, q);
  }
  rep(i, l) {
    ll r, s;
    ccin >> r >> s;
    --r;
    --s;
    unf_l.unite(r, s);
  }

  map<pair<ll, ll>, ll> mp;

  rep(i, n) {
    ++mp[pair<ll, ll>(unf_k.find(i), unf_l.find(i))];
  }
  rep(i, n) {
    ccout << mp[pair<ll, ll>(unf_k.find(i), unf_l.find(i))] << " ";
  }
  ccout << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 18660
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>	
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{};
	cin>>n;
	vector<int>v(n);
	vector<int >res(n);
	For(i,0,n){cin>>v[i];res[i]=v[i];}
	sort(all(res));
	For(i,0,n)
	{
		if(v[i]<res[n-1])cout<<res[n-1]<<'\n';
		else cout<<res[n-2]<<'\n';
	}
	//system("pause");
	return 0;
	
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  //sの最速ソートとtの最速ソートの逆を比較すれば良い
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s<t) cout << "Yes";
  else cout << "No";
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C;
    cin >> A >> B >> C;
    cout << (A + B >= C ? "Yes" : "No") << endl;
    return 0;
}

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

int main () {
  long long N ;
  cin >> N ;
  int pre = 0 ;
  int a = N ;
  while(a>0){
    pre += a%10 ;
    a /=10 ;
  }
  if(N%pre==0) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string a,b;
  cin >> a;
  b = a;
  reverse(b.begin(),b.end());
  if(a != b){
    cout << "No" << endl;
  }
  else{
    int size = a.size();
    string a1 = a.substr(0,size/2);
    string a2;
    a2 = a1;
    reverse(a2.begin(),a2.end());
    string b1 = b.substr((size/2)+1);
    string b2;
    b2 = b1;
    reverse(b2.begin(),b2.end());
    if(a1 != a2 || b1 != b2){
    cout << "No" << endl;
    return 0;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}
    
  
  

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

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

    static class TaskAFG011A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int c = in.nextInt();
            int k = in.nextInt();

            int[] t = new int[n];
            for (int i = 0; i < n; i++) {
                t[i] = in.nextInt();
            }

            Arrays.sort(t);

            int index = 0;
            int currBus = 0;

            while (index < n) {
                currBus++;
                int currBusCap = 0;

                int earliestTime = t[index];
                int currTime = earliestTime;

                while (currBusCap < c && currTime <= earliestTime + k) {
                    currBusCap++;
                    index++;

                    if (index == n) break;
                    currTime = t[index];
                }
            }
            System.out.println(currBus);
        }
    }
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  vector<vector<int>> ot(n);
  rep(i,m) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    to[s].push_back(t);
    ot[t].push_back(s);
  }

  vector<double> dp(n);
  dp[n-1] = 0;
  for (int v = n-2; v >= 0; --v) {
    int deg = to[v].size();
    for (int u : to[v]) dp[v] += (dp[u]+1)/deg;
  }

  vector<double> p1(n);
  p1[0] = 1;
  for (int v = 1; v < n; ++v) {
    for (int u : ot[v]) {
      p1[v] += p1[u]/to[u].size();
    }
  }

  double ans = dp[0];
  for (int v = 0; v <= n-2; ++v) {
    int deg = to[v].size();
    if (deg == 1) continue;
    double x = dp[v]*deg/(deg-1);
    for (int u : to[v]) {
      double nx = x - (dp[u]+1)/(deg-1);
      ans = min(ans, dp[0] + p1[v]*(nx-dp[v]));
    }
  }

  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	ll k,a,b;
    cin >> k >> a >> b;
    if((b-a)<=2 || k<a+1){
        cout << 1+k << endl;
        return 0;
    }
    else{
        if((k-a-1)%2==0){
            cout << b+(k-a-1)/2*(b-a) << endl;
        }
        else{
            cout << b+(k-a-1)/2*(b-a)+1 << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[50], b[50], c[50], d[50];
int main() {
	int n, m;
	cin >> n >> m ;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int j = 0; j < m; j++) {
		cin >> c[j] >> d[j];
	}
	for (int i = 0; i < n; i++) {
		int min = 1000000007;
		int ans;
		for (int j = 0; j < m; j++) {
			int k = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (k < min) {
				min = k;
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, t, q, ans, sum, a[200001];
struct Edge { LL to,cost; };
string str, ss;
bool f;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	//YN(f);
	//yn(f);
	cout << n / 3 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
const int N_MAX = 505;

using namespace std;

int f[N_MAX][N_MAX];
int s[N_MAX] = {}, g[N_MAX] = {};

int main() {
    int N, M, Q;

    cin >> N >> M >> Q;
    vector< int > L(M), R(M);
    vector< int > p(Q), q(Q);
    map< int, vector< int > > mp;

    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
        s[L[i]]++;
        g[R[i]]++;
        mp[L[i]].push_back(R[i]);
    }
    for (int i = 0; i < Q; i++) {
        cin >> p[i] >> q[i];
    }

    f[0][N] = M;
    for (int i = 1; i <= N; i++) {
        f[i][N] = f[i - 1][N] - s[i - 1];
        for (auto x : mp[i - 1]) {
            g[x]--;
        }
        for (int j = N - 1; j >= i; j--) {
            f[i][j] = f[i][j + 1] - g[j + 1];
        }
    }

    // cout << "-------------------" << endl;
    for (int i = 0; i < Q; i++) {
        cout << f[p[i]][q[i]] << endl;
    }
    // for (int i = 0; i <= N; i++) {
    //     printf("%3d ", i);
    // }
    // cout << endl;
    // for (int i = 1; i <= N; i++) {
    //     printf("%3d ", i);
    //     for (int j = 1; j <= N; j++) {
    //         printf("%3d ", f[i][j]);
    //     }
    //     cout << endl;
    // }
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int count = 0;
  rep(i,3) {
    if ( S.at(i) == T.at(i) ) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int x = scan.nextInt();
			if (x % 2 == 0) {
				cnt++;
				if (x %3 == 0 || x % 5 == 0) {
					cnt--;
				}
			}
		}
		
		if (cnt == 0) {
			System.out.println("APPROVED");
		} else {
			System.out.println("DENIED");
		}
	}

}

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

using namespace std;

bool check(vector<int>& A, vector<int>& B, int C, int M){
    int sum = C;
    for(int i = 0; i < M; i++){
	sum += A.at(i) * B.at(i);
    }
    return (sum > 0);
}

int main(){

    int N, M;

    cin >> N >> M;

    vector<pair<long,long>> O(N);

    for(int i = 0; i < N; i++){
	cin >> O.at(i).first >> O.at(i).second;
    }

    sort(O.begin(), O.end(), [](pair<long,long> a, pair<long,long> b) -> bool {return a.first < b.first;});

    long sum = 0;
    int m = M;
    int i;
    for(i = 0; i < N; i++){
	if(m <= O.at(i).second) break;
	sum += O.at(i).first * O.at(i).second;
	m -= O.at(i).second;
    }
    // rest
    sum += m * O.at(i).first;
    
    cout << sum << endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,h;
    cin >> n >> h;
    vi a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    sort(b.begin(),b.end(),greater<ll>());
    sort(a.begin(),a.end(),greater<ll>());
    ll sum = 0;
    ll cnt = 0;
    int bi=0;
    while(h>0 && bi<n){
        if(b[bi]>=a[0]){
            h -= b[bi];
            bi++;
            cnt++;
        }else{
            break;
        }
    }
    if(h>0) cnt += (h + a[0] -1)/a[0];
    cout << cnt << endl;
}

Measured memory_bytes: 1024
package main

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

func main() {
	X, N := ReadInt(), ReadInt()
	p := ReadInts(N)
	m := make(map[int]bool)
	for _, pi := range p {
		m[pi] = true
	}
	for i := 0; true; i++ {
		if !m[X-i] {
			fmt.Println(X - i)
			return
		}
		if !m[X+i] {
			fmt.Println(X + i)
			return
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1860
#include <iostream>

using namespace std;

int main(){
  int N; cin>>N;
  int ans=0;
  for(int i=3;i<=N;i++){
    int num=i,c=0;
    for(int j=1;j<=num;j++){
      if(num%j==0) c++;
    }
    if(c==8&&(i%2!=0)) ans++;
  }

  cout<<ans<<endl;

  return 0;
}


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

int main(){
	int t;
	// cin>>t;
	t =1;
	for (int z = 0; z < t; ++z)
	{	
		long long int n;
		cin>>n;
		long long int answer = 0;
		for (int i = 1; i < n; ++i)
		{
			if (n%i == 0)
			{
				answer += ((n/i) -1);
			}
			else answer +=(n/i);
		}
		cout<<answer;
	}
}


Measured memory_bytes: 3636