akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rb(x) ((x)&(-(x)))
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;

const int MAXN = 20005;

struct BITMX {
	BITMX() { init(); }
	int d[MAXN];
	void init() { fill(d, d+MAXN, -INF); }
	void upd(int x, int r) {
		for(; x < MAXN; x += rb(x))
			upmax(d[x], r);
	}
	int get(int x) {
		int r = -INF;
		for(; x; x -= rb(x))
			upmax(r, d[x]);
		return r;
	}
};
struct BITMN {
	BITMN() { init(); }
	int d[MAXN];
	void init() { fill(d, d+MAXN, INF); }
	void upd(int x, int r) {
		for(; x < MAXN; x += rb(x))
			upmin(d[x], r);
	}
	int get(int x) {
		int r = INF;
		for(; x; x -= rb(x))
			upmin(r, d[x]);
		return r;
	}
};

BITMX bitmx;
BITMN bitmn;

int P[MAXN], O[MAXN];
int A[MAXN], B[MAXN];

int N;

int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", &P[i]);
	for(int i = 1; i <= N; i++) O[P[i]] = i;

	for(int i = 2; i <= N; i++) {
		int dt = O[i] - O[i-1];
		A[i] = A[i-1]; B[i] = B[i-1];
		if(dt < 0) {
			B[i] += dt;
		} else {
			A[i] += dt;
		}
	}

	{
		int mn = *min_element(A+1, A+N+1);
		for(int i = 1; i <= N; i++)
			A[i] -= mn - 1;
	}

	{
		int mn = *min_element(B+1, B+N+1);
		for(int i = 1; i <= N; i++)
			B[i] -= mn - 1;
	}

	for(int i = 1; i <= N; i++) {
		A[i] += i;
		B[i] -= i;

		B[i] += 5*N;
	}

if(0)
	{
		int C[MAXN];
		for(int i = 1; i <= N; i++) C[i] = A[P[i]] + B[P[i]];
		for(int i = 2; i <= N; i++) if(C[i-1] >= C[i]) {
			printf("FUCK at %d\n", i);
			exit(-1);
		}
	}

	for(int i = 1; i <= N; i++) printf("%d ", A[i]); puts("");
	for(int i = 1; i <= N; i++) printf("%d ", B[i]); puts("");
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>

void GetMaxPrime(int n){
 int i,j;
 int flg=0;

 for(i=n-1;i>=2;i--){
  flg=0;

  for(j=2;j<=sqrt(i);j++)
   if(i % j ==0){
     flg=1;
     break;
   }

  if(flg==0){
   printf("%d ",i);
   return;
  }

 }

return;
}


void GetMinPrime(int n){
 int i,j;
 int flg=0;

 for(i=n+1;i>=0;i++){
  flg=0;

  for(j=2;j<=sqrt(i);j++)
   if(i % j ==0){
     flg=1;
     break;
   }

  if(flg==0){
   printf("%d\n",i);
   return;
  }

 }

return;
}



int main(){
 int n;

 while(scanf("%d",&n)!=EOF){

  GetMaxPrime(n);
  GetMinPrime(n);

 }

return 0;

}


Measured memory_bytes: 2028
n=int(input())
d=[int(i) for i in input().split()]
m=[0]*n
s=0
for i in range(n):
    if i%2==0:
        s+=d[i]
    else:
        s-=d[i]
m[0]=s
for i in range(1,n):
    m[i]=2*d[i-1]-m[i-1]
print(*m)

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

const ll INF = 1e17;
const ll MOD = 1e9+7;


int main() {
    // input, ready
    string S;
    cin >> S;
    map<string,int> weekmap;
    weekmap["SUN"]=7;
    weekmap["MON"]=6;
    weekmap["TUE"]=5;
    weekmap["WED"]=4;
    weekmap["THU"]=3;
    weekmap["FRI"]=2;
    weekmap["SAT"]=1;

    cout << weekmap[S] << endl;

    return 0;
}


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

int main(){ 
    int n,d;
    int a=0;
    int b=0;
    int c=0;
    cin>>n>>d;
    vector<vector<int>> data(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> data.at(i).at(j);
    }
  }
  vector<int> vec(130);
for (int i = 0; i < 130; i++) {
  vec.at(i)=(i+1)*(i+1);
}

for (int i = 0; i < n; i++) {
    for (int j = 1; j < n-i; j++) {
        for(int k=0;k<d;k++){
      a+=(data.at(i).at(k)-data.at(i+j).at(k))* (data.at(i).at(k)-data.at(i+j).at(k));
      
          }
          for(int l=0;l<130;l++){
          if(a==vec.at(l)){
              b++;
              break;
          }
      }
      a=0;
      }
    }
  cout <<b;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define maxn 100005
using namespace std;

int fac[maxn], n, m, sn, ifac[maxn], inv[maxn], f[21][maxn], ans, a[21], digit[maxn];
int C(int u, int v){
    if(u < v) return 0;
    return 1ll * fac[u] * ifac[v] % mod * ifac[u - v] % mod; 
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin >> n; cin >> m; sn = 1 << n;
    fac[0] = 1; inv[0] = 1; ifac[0] = 1;
    for(int i = 1; i <= sn; i++) {
        fac[i] = 1ll * fac[i - 1] * i % mod;
        inv[i] = (i == 1) ? 1 : 1ll * inv[mod % i] * (mod - mod / i) % mod;
        ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod; 
    }
    for(int i = 1; i <= m; i++) cin >> a[i];
    sort(a + 1, a + m + 1);
    f[m + 1][0] = 1;
    for(int i = m; i >= 1; i--)
        for(int j = 0; j < sn; j++){
            (f[i][j] += f[i + 1][j]) %= mod;
            for(int k = 0; k < n; k++){
                if(j & (1 << k)) continue;
                int p = sn - j - a[i];
                (f[i][j + (1 << k)] += 1ll * f[i + 1][j] * C(p, (1 << k) - 1) % mod * fac[1 << k] % mod) %= mod;
            }
        }
    for(int i = 0; i < sn; i++) {
        digit[i] = digit[i >> 1] + (i & 1);
        f[1][i] = 1ll * f[1][i] * fac[sn - i - 1] % mod;
        if(digit[i] % 2 == 0) ans = (ans + f[1][i]) % mod;
        else ans = (ans + mod - f[1][i]) % mod;
    }
    cout << 1ll * ans * sn % mod<< endl;
    return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
    IOS;
    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
      cout<<"unsafe"<<endl;
    }
    else
      cout<<"safe"<<endl;
  
}

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

using namespace std;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if((int)s.size() <= k){
        cout << s << "\n";
    }
    else{
        cout << s.substr(0, k) << "...\n";
    }
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector <int> road(2*M);
    for(int i=0;i<2*M;i++){
        cin >> road.at(i);
    }//入力を配列に格納
    int ans=0;
    for(int i=1;i<=N;i++){
        for(int j=0;j<2*M;j++){
            if(road.at(j)==i){
                ans++;
            }
        }
        cout << ans << endl;
        ans=0;
    }
}


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

void solve(){
  int K; cin >> K;
  if(K%2==0 || K%5==0) {
    cout<< -1 << endl;
    return;
  }
  int i = 1;
  int r = 7;
  while(1){
    r %= K;
    if(r == 0) {
      cout << i << endl;
      break;
    }
    r = r*10 + 7;
    i++;
  }
}

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


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

// input
int N;
vector<string> S;


void input() {
    cin >> N;
    S = vector<string>(N);
    rep(i, N) cin >> S[i];
}


ll comb3(ll n) {
    ll ret = n * (n - 1) * (n - 2) / 6;
    return ret;
}


ll comb2(ll n) {
    return n * (n - 1) / 2;
}


int main() {
    input();
    set<char> s{'M', 'A', 'R', 'C', 'H'};
    map<char, int> m;
    int n = 0;
    rep(i, N) {
        if (s.count(S[i][0])) {
            m[S[i][0]]++;
            n++;
        }
    }
    ll ans = comb3(n);
    for (auto p : m) {
        int v = p.second;
        ans -= comb2(v) * (n - v);
        ans -= comb3(v);
    }
    cout << ans << endl;
}


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

namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans;
            if ((x[0] + x[1]) % 2 == 1) ans = (x[0] + x[1] + 1) / 2;
            else ans = (x[0] + x[1]) / 2;
            Console.WriteLine(ans.ToString());
        }
    }
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

int X;

int main() {
    cin >> X;
    if(X == 7 || X == 5 || X == 3) {
        cout << "YES"
             << "\n";
    } else {
        cout << "NO"
             << "\n";
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int people[N];
    for(int i=0;i<N;i++) people[i]=0;
    for(int i=1;i<N;i++){
        int a;
        cin >> a;
        people[a-1]++;
    }

    for(int i=0;i<N;i++){
        cout << people[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4420
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
ll mod=1000000007;

int main()
{
    ll N,M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    for(int i=0; i<N; i++){
        cin >> S[i];
    }
    for(int i=0; i<M; i++){
        cin >> T[i];
    }

    ll dp[N+1][M+1];//Sのi文字目までとTのj文字目を使う
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<=N; i++){
        dp[i][0]=1;
    }
    for(int i=0; i<=M; i++){
        dp[0][i]=1;
    }

    for(int n=1; n<=N; n++){
        for(int m=1; m<=M; m++){
            dp[n][m]=dp[n-1][m]+dp[n][m-1];
            if(S[n-1]!=T[m-1]){
                dp[n][m]-=dp[n-1][m-1];
                if(dp[n][m]<0) dp[n][m]+=mod*3;
            }
            dp[n][m]%=mod;
        }
    }

    cout << dp[N][M] << endl;

    return 0;
}

Measured memory_bytes: 31488
#include <stdio.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, mi = -1, ma = 1e12 + 1, now, cnt;
  scanf("%lld%lld", &n, &k);
  ll a[n], f[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) scanf("%lld", &f[i]);
  sort(a, a + n), sort(f, f + n, greater<ll>());
  while(mi != ma - 1) {
    now = (mi + ma) / 2, cnt = 0;
    for(i = 0; i < n; ++i) if(a[i] * f[i] > now) cnt += a[i] - (now / f[i]);
    if(cnt > k) mi = now;
    else ma = now;
  }
  printf("%lld", ma);
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int ans=0;
    rep(i,n) {
        cin >> a[i];
    }
    vector<int> b=a;
    sort(all(b));
    map<int,int> m;
    rep(i,n){
        m[b[i]]=i;
    }
    rep(i,n){
        a[i]=m[a[i]];
    }
    rep(i,n){
        if (abs(i-a[i])%2==1) ans++;
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int n,x,y,ans[20010];

int main() 
{	cin>>n>>x>>y;
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
		{
			if(i<=x)
			{
				if(j<=x)
					ans[j-i]++;
				else if(j<=y)
					ans[min(j-i,(x-i)+1+(y-j))]++;
				else
					ans[x-i+1+j-y]++;
			}
			else if(i<=y)
			{
				if(j<=y)
					ans[min(j-i,i-x+1+y-j)]++;
				else
					ans[min(j-i,j-y+1+i-x)]++;
			}
			else
				ans[j-i]++;
		}
	for(int i=1;i<n;++i)
		cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String c[] = new String[3];
    for(int i = 0;i < 3;i++){
      c[i] = sc.next();
    }
    String ans = c[0].substring(0,1) + c[1].substring(1,2) + c[2].substring(2,3);
    System.out.println(ans);
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main(){
    int D;
    cin>>D;
    int c[26];
    for(int i=0;i<26;i++)cin>>c[i];
    int s[D][26];
    for(int i=0;i<D;i++)for(int j=0;j<26;j++){
        cin>>s[i][j];
    }
    int t[D];
    for(int i=0;i<D;i++)cin>>t[i];
    int score=0;
    int last[26]={};
    for(int i=1;i<=D;i++){
        last[t[i-1]-1]=i;
        score+=s[i-1][t[i-1]-1];
        for(int j=0;j<26;j++){
            score-=(i-last[j])*c[j];
        }
        cout<<score<<endl;
    }
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] s = br.readLine().split(" ");
		ArrayList<Integer> l = new ArrayList<Integer>();
		for(int i =0;i <2*N;i++){
			l.add(Integer.parseInt(s[i]));
		}
		Collections.sort(l);
		int result = 0;
		for(int i =0;i<2*N;i+=2){
			result += l.get(i) > l.get(i+1)? l.get(i+1):l.get(i);
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 20820
#include<iostream>

using namespace std;

int main(void)
{
	int n,m;
	cin >> n >> m;
	int a[m],b[m];
	for(int i=1;i<=m;i++)
		cin >> a[i-1] >> b[i-1];
	
	int cangolist[n];
	for(int i=1;i<=n;i++)
		cangolist[i-1]=0;
	cangolist[0]=1;
	int tag = 0;

	int count = 0;
	

	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
			cangolist[j-1]=0;
		cangolist[0]=1;
		tag=0;
		bool bridge = false;

		bool cango[n];
		for (int j=1;j<=n;j++)
			cango[j-1]=false;
		cango[0]=true;

			for(int k=1;k<=tag+1;k++)
			{
				for(int l=1;l<=m;l++)
				{
					if(i==l)
					{

					}
					else if(a[l-1]==cangolist[k-1] && cango[b[l-1]-1]==false)
					{
						cango[b[l-1]-1]=true;
						tag++;
						cangolist[tag]=b[l-1];
						//cout << k << ":" << l << ":cango" << endl;
					}
					else if(b[l-1]==cangolist[k-1] && cango[a[l-1]-1]==false)
					{
						cango[a[l-1]-1]=true;
						tag++;
						cangolist[tag]=a[l-1];
						//cout << k << ":" << l << ":cango" << endl;
					}
					else
					{
						//cout << k << ":" << l << ":canNOTgo" << endl;
					}

				}
			}
			for(int k=1;k<=n;k++)
			{
				if(cango[k-1]==false)
					bridge = true;
			}

		
		if(bridge == true)
			count++;
		//cout << "bridge:" << bridge << endl;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli N = 1e6+5;
lli can[N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i, j, ans = 0;
    
    for(i=1;i<N;i++)
    {
        for(j=i;j<N;j += i)
        {
            can[j]++;
        }
    }
    
    for(i=1;i<n;i++) ans += can[i];
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 11416
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int N = scanner.nextInt();
		    int count = 0;
		    
		    while( N != 1 ) 
		    {
		    	N = N /2;
		    	count = count + 1;
		    }
		    System.out.println((int) Math.pow(2,count) );
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
n, l = map(int, input().split())
alist = list(map(int, input().split()))

preva = alist[0]
is_possible = False
for i, a in enumerate(alist[1:]):
  if preva + a >= l:
    is_possible = True
    break
  preva = a

if not is_possible:
  print('Impossible')
else:
  print('Possible')
  for j in range(1, i+1):
    print(j)
  for j in range(n-1, i+1, -1):
    print(j)
  print(i + 1)


Measured memory_bytes: 14076
#include <iostream>
using namespace std;
main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for( int i= 0; i<s.size(); i++ )
    {
        if( s[i] == 'o' ) cnt++;
    }    
    if( 15 - s.size() + cnt >= 8 ) puts( "YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;

    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);

    for(int i=2;i<n;i++)
        dp[i]  = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 5180
N=int(input())
A=[]
for i in range(N):
  A.append(input())

K=int(input())
for i in range(K):
  s=input()
  if (str(s) in A)==1:
    A.remove(s)
B=set(A)
ans=0
for i in B:
  if A.count(i)>ans:
    ans=A.count(i)
print(ans)

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

using namespace std;

int main(void) {
    long n;
    cin >> n;
    vector<long> p(n), q(n);
    for(auto &e: p) cin >> e;

    q[0] = p[0];
    for(int i=1; i<n; i++)
        q[i] = min(p[i], q[i-1]);

    long r = 0;

    for(int i=0; i<n; i++)
        if(p[i] <= q[i])
            r++;

    cout << r << endl;

}


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

#define For(i, j, k) for (int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (int i = j; i >= k; -- i)

typedef long long ll;

using namespace std;

inline void File() {
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
}

ll n, s;

inline ll calc(ll x, ll b) {
	ll res = 0; while (x) res += x % b, x /= b; return res;
}

int main() {

	cin >> n >> s;
	int lim = sqrt(n + 1);		

	For(i, 2, lim + 1) if (calc(n, i) == s) return printf("%d\n", i), 0;

	Forr(x1, lim - 1, 1) { 
		if ((n - s) % x1 > 0) continue;
		ll b = (n - s) / x1 + 1;
		if (b > lim && x1 <= s && s - x1 < b) {
			return printf("%lld\n", b), 0;
		}
	}

	if (n == s) return printf("%lld", n + 1), 0;
	puts("-1");

	return 0;
}


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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int n,m,q;
int l[200000],r[200000];
int p_arr[100000],q_arr[100000];
int dp[501][501];
int mem_num[501][501]; 

int main(){
  cin>>n>>m>>q;
  REP(i,n){
    REP(j,n){
      dp[i+1][j+1]=0;
      mem_num[i+1][j+1]=0;
    }
  }
  REP(i,m){
    cin>>l[i]>>r[i];
    mem_num[l[i]][r[i]]++;
  }
  REP(i,q)
    cin>>p_arr[i]>>q_arr[i];

  FOR(d,0,n){
    FOR(c,1,n+1-d){
      if(d==0)
	dp[c][c] = mem_num[c][c];
      else{
	dp[c][c+d] = dp[c][c+d-1];
	FOR(k,c,c+d+1)
	  dp[c][c+d] += mem_num[k][c+d];
      }
    }
  }
  
  REP(i,q){
    cout<<dp[p_arr[i]][q_arr[i]]<<endl;
  }
  return 0;
}


Measured memory_bytes: 5248
import java.io.*;
import java.util.*;

    public class Main extends PrintWriter {
        Main() { super(System.out, true); }
        Scanner sc = new Scanner(System.in);
        public static void main(String[] $) {
            Main o = new Main(); o.main(); o.flush();
        }

        void main(){
            long K = sc.nextLong();
            long X = sc.nextLong();

            long T = K * 500;

            if(T >= X){
                print("Yes");
            }
            else{
                print("No");
            }


    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b;int k;cin>>a>>b>>k;
  for(int i=0;i<k;i++){if(i%2==0){a/=2;b+=a;}else{b/=2;a+=b;}}
  cout<<a<<' '<<b<<endl;
}
   


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

const int maxn=2e5+7;
int a[maxn],ans,n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	int c=1;
	for(int i=1;i<=n;++i) {
		if(a[i]==c) c++;
		else ans++;
	}
	if(ans==n) printf("-1");
	else printf("%d",ans);
}

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

int main() {
	stack<char>st;
	st.push('#');
	int l;
	cin>>l;
	string s,a="",b="";
	cin>>s;
    for(int i=0;i<l;i++)
    {
    	if(s[i]==')') 
    	{
    		if(st.top()=='(')
    		st.pop();
    		else
    		st.push(s[i]);
    	}
    	else
    	st.push(s[i]);
    }
    while(!st.empty())
    {
    	if(st.top()==')') 
    	a+="(";
    	else if(st.top()=='(')
    	b+=")";
    	st.pop();
    }
    string tp=a+s+b;
    cout<<tp;
	return 0;
}

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


long long int ST[800001];
long long int A[200001],value[200001];

int compare(const pair<int,int> p1,const pair<int,int> p2){
	if(p1.first==p2.first) return p1.second>p2.second;
	return p1.first<p2.first;
}


void buildTree(int pos,int start,int end,int index,long long int val){
	if(index<start||index>end) return;
	if(start==end){
		ST[pos]=val;
		return;
	}
	int mid=(end+start)/2;
	
	buildTree(pos*2,start,mid,index,val);
	buildTree(pos*2+1,mid+1,end,index,val);
	
	ST[pos]=max(ST[pos*2],ST[pos*2+1]);
}

long long int findMax(int pos,int start,int end,int left,int right){
//	cerr<<start<<" - "<<end<<"..."<<left<<"- "<<right<<"\n";
	if(left<=start&&end<=right) return ST[pos];
	
	if(left>end||right<start){
		return 0;
	}
	
	int mid=(end+start)/2;
	
	return max(findMax(pos*2,start,mid,left,right),findMax(pos*2+1,mid+1,end,left,right));
}

void debug(){
	for(int i=1;i<=7;i++){
		cerr<<ST[i]<<"|";
	}
}
long long int solve(int N){
	pair<int,int> p[N];
	for(int i=0;i<N;i++){
		p[i].first=A[i];
		p[i].second=i;
	}
	sort(p,p+N,compare);
	
	for(int i=0;i<N;i++){
		buildTree(1,1,N,p[i].second+1,findMax(1,1,N,1,p[i].second+1)+value[p[i].second]);
//		debug();
//		cerr<<"\n";
	}
	return ST[1];
}


int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N;i++){
		cin>>value[i];
	}
	cout<<solve(N)<<"\n";
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));

  rep(i, n) {
    cin >> c[i];
    rep(j, m) { cin >> a[i][j]; }
  }
  // rep(i, n) {
  //   rep(j, m) cout << a[i][j] << " ";
  //   cout << endl;
  // }
  ll res = INF;
  for (ll bits = 0; bits < (1 << n); bits++) {
    vector<int> score(m, 0);
    ll cost = 0;
    rep(book, n) {
      if (bits & (1 << book)) {
        rep(skill, m) {
          score[skill] += a[book][skill];
        }
          cost += c[book];
      }
    }
    bool isok = true;
    rep(skill, m) { isok &= (score[skill] >= x); }
    if (isok) res = min(res, cost);
  }
  if (res == INF) {
    cout << -1 << endl;
  } else {
    cout << res << endl;
  }

  return 0;
}


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

typedef long long ll;

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin>>n>>k;

    int A[n];
    vector<int> factors;
    int sum = 0;
    for (int i=0;i<n;++i){
        cin>>A[i];
        sum += A[i];
    }

    for (int i=1;i*i<=sum;++i){
        if (sum%i == 0){
            factors.push_back(i);
            factors.push_back(sum/i);
        }
    }

    multiset<int> s;
    int ans = 0;
    for (int j=0;j<(int)factors.size();++j){
        int d = factors[j];
        //cout<<"d : " <<d<<endl; 
        int totalCost = 0;
        s.clear();
        for (int i=0;i<n;++i){
            int mod = A[i]%d;
            s.insert(mod);
            totalCost += (d-mod);
        }

        int cnt = 0;
        for (auto e : s){
            //cout<<e<<" ";
            cnt += e;
            totalCost -= d;
            if (totalCost == 0 && cnt<=k){
                ans = max(ans, d);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
    int h, w; cin >> h >> w;
    ll ans = 0;
#if 0
    rep(i, h) {
        if (i % 2 == 0) {
            ans += (ll)(w+1) /2;
        }
        else
            ans += w/2;
    }
#endif
if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
}
    ans  = ((ll)(w+1) /2) * (h/2);
    ans += (ll)(w/2) * (h/2);

    if (h%2 != 0) {
        ans+= (ll)(w+1) /2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b;
	for(int i=0;i<b.size();i++){
		c+=a[i];
		c+=b[i];
		}
	
	if(a.size()>b.size()){
			c+=a[a.size()-1];
		}
	cout<<c<<endl;
	return 0;	
}

Measured memory_bytes: 256
N = int(input())
H_list = list(map(int, input().split()))
con_cnt = 0
max_con = 0
for i in range(1, N):
    if H_list[i-1]>=H_list[i]:
        con_cnt += 1
    else:
        if max_con < con_cnt:
            max_con = con_cnt
        con_cnt = 0
if max_con < con_cnt:
            max_con = con_cnt
print(max_con)

Measured memory_bytes: 14224
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr double BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;

//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    const auto isPrime = [](ll x)
    {
        for (int i = 2; i * i < x; ++i)
        {
            if (x % i == 0)
            {
                return false;
            }
        }
        return true;
    };

    for (int i=X;;++i)
    {
        if (isPrime(i))
        {
            cout << i;
            return 0;
        }
    }
    return 0;
}

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

int main()
{int sx,sy,tx,ty;
cin>>sx>>sy>>tx>>ty;
int x=tx-sx,y=ty-sy;
for(int i=0;i<y;i++)
    cout<<"U";
for(int i=0;i<x;i++)
    cout<<"R";
for(int i=0;i<y;i++)
    cout<<"D";
for(int i=0;i<x+1;i++)
    cout<<"L";
for(int i=0;i<y+1;i++)
    cout<<"U";
for(int i=0;i<x+1;i++)
    cout<<"R";
    cout<<"DR";
for(int i=0;i<y+1;i++)
    cout<<"D";
for(int i=0;i<x+1;i++)
    cout<<"L";
    cout<<"U";
return 0;
 }


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int l,c=0,i,j;
  char s[102]={0};
  while(~scanf("%s",s)){
    for(i=0;s[i];i++);
    for(j=0;j<=i--;j++){//printf("%c %c\n",s[i],s[j]);
      if(s[i]-s[j])break;
    }
    if(j>i)c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N, K; cin >> N >> K;
    //K達成するより前に，裏が出たら負けですか？
    //何回連続で表を出さなければならないか？
    //各目ごとに考えればいいですね
    double ans = 0, p_dice = 1.0 / double(N);
    for(int i = 1; i <= N; ++i) {
        int tmp = i;
        double p_coin = 1;
        while(tmp < K) {
            p_coin *= 0.5;
            tmp *= 2;
        }
        ans += p_coin * p_dice;
    }
    cout << fixed << setprecision(15) << ans << endl;
}


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

const int N = 1e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
ll OOL = 0x3f3f3f3f3f3f3f3f;
int n, h;
bool cmp(pair<int, int> x, pair<int, int> y)
{
    return x.second < y.second;
}
pair<int, int> arr[N];
int main()
{
    scanf("%d %d", &n, &h);
    for(int i = 0 ; i < n ; i++)
        scanf("%d %d", &arr[i].first, &arr[i].second);
    sort(arr, arr+n);
    int tmp = h;
    int ans = 0;
    int mx = arr[n-1].first;
    sort(arr, arr+n, cmp);
    for(int i = n-1 ; i !=-1 ; i--)
    {
        if(arr[i].second >= mx)
        {
            tmp -= arr[i].second;
            ans++;
        }
        if(tmp<= 0)
            break;
    }
    if(tmp >  0)
    {
        // cout<<tmp<<endl;
        ans += (tmp + mx -1) / mx;
    }
    // memset(mem , -1, sizeof mem);
    // cout<<dp(h, 0, 0);
    cout<<ans<<endl;
    return 0;
}

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

# In[9]:


S = input()


# In[10]:


ans = 0
tmp = 0
for i in range(3):
    if S[i] == "R":
        tmp += 1
    else:
        tmp = 0
    ans = max(ans,tmp)
print(ans)


# In[ ]:






Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007
double dp[3000][3000];

int main()
{
    int n,i,j,k;
    cin>>n;
    double p[n+1],ans=0;
    fo(i,1,n+1) cin>>p[i];
    dp[0][0]=1;
    fo(i,1,n+1) dp[0][i]=(dp[0][i-1])*(1-p[i]);
    fo(i,1,n+1)
    {
        fo(j,1,n+1)
        {
            if(i<=j){
                dp[i][j]=(dp[i][j-1])*(1-p[j]) + (dp[i-1][j-1])*(p[j]);
            }
        }
    }
    fo(i,((n+1)/2),n+1) ans+=dp[i][n];
    cout<<fixed<<setprecision(15)<<ans<<endl;

}


Measured memory_bytes: 70016
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  writeln(s.length/2-s.count('p'));
}


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

int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[n+1];
    ll dp[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>arr[i];
        dp[i] = 10e15;
    }

    dp[0] = 0;
    dp[1] = 0;
    for(ll i=2;i<=n;i++)
    {
        ll j =  i-1;
        while(j>0 && j>=(i-k))
        {
            dp[i] = min(dp[i],dp[j] + abs(arr[i]-arr[j]));
            j--;
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b && b < c)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
  
  return 0;
}



Measured memory_bytes: 3104
function main(input) {
    var N = parseInt(input.split("\n")[0]);
    var Hs = input.split("\n")[1].split(" ").map(i => parseInt(i));
    var count = 0;
    Hs.map((hi, i) => {
        var f = true;
        Hs.slice(0, i).map(hj => {
            if (hj > hi) {
                f = false;
            }
        })
        if (f) {
            count += 1;
        }
    })
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        foreach (var input in Enumerable.Range(0, int.MaxValue).Select(x => Console.ReadLine()).TakeWhile(x => !string.IsNullOrEmpty(x)))
        {
            Console.WriteLine(new string(input.Reverse().ToArray()));
        }
    }
}

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

using namespace std;

vector<vector<int> > G;

vector<bool> used;

vector<int> rings;

int rec(int pos)
{
    used[pos] = true; int ret = 1;
    
    for(int i = 0; i < rings[pos]; i++)
    {
        if(!used[G[pos][i]])
        {
            ret = max(ret, rec(G[pos][i]) + 1);
        }
    }
    
    used[pos] = false;
    
    return ret;
}

int main()
{
    int N, A, B;
    
    while(true)
    {
        scanf("%d", &N);
        
        if(N == 0) { break; }

        G = vector<vector<int> >(100, vector<int>());
        
        used = vector<bool>(100);
        
        rings = vector<int>(100);
    
        for(int i = 0; i < N; i++)
        {
            scanf("%d", &A); A--;
            scanf("%d", &B); B--;
        
            G[A].push_back(B);
            G[B].push_back(A);
        }
        
        for(int i = 0; i < 100; i++)
        {
            rings[i] = G[i].size();
        }
        
        int nodes = 0;
        
        for(int i = 0; i < 100; i++)
        {
            if(rings[i])
            {
                nodes++;
            }
        }
    
        int ret = 0;
    
        for(int i = 0; i < 100; i++)
        {
            ret = max(ret, rec(i));
                
            if(ret == nodes) { break; }
        }
        
        printf("%d\n", ret);
    }
    
    return 0;
}

Measured memory_bytes: 3232
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	int count = 0;
	for (int i = 0; i < S.size(); ++i) {
		if ('p' == S[i]) {
			count++;
		}
	}
	cout << S.size() / 2 - count << endl;
	return 0;
}


Measured memory_bytes: 3720
//start of sethsahin' template
#include <bits/stdc++.h>

#define LL long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define SQ(a) a*a

using namespace std;

inline int nxt(){
  int x;
  scanf("%d",&x);
  return x;
}
//end of sethsahin template

int main(){                   
	
	ios::sync_with_stdio(0);	
	cin.tie(0);
    int n,m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl; 
    
		
	return 0;
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int A,B,C;
 cin >> A >> B >> C;
 if (A == 5 && B == 5 && C == 7){
   cout << "YES" << endl;
 }
 else if (A == 5 && B == 7 && C == 5){
   cout << "YES" << endl;
 }
 else if (A == 7 && B == 5 && C == 5){
   cout << "YES" << endl;
 }
 else{
   cout << "NO" << endl;
 }
}
   

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

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

    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    for (int i = 0; i < n; i++) if (dp[i]) {
        if (i + 5 <= n and s.substr(i, 5) == "dream")   dp[i + 5] = 1;
        if (i + 7 <= n and s.substr(i, 7) == "dreamer") dp[i + 7] = 1;
        if (i + 5 <= n and s.substr(i, 5) == "erase")   dp[i + 5] = 1;
        if (i + 6 <= n and s.substr(i, 6) == "eraser")  dp[i + 6] = 1;
    }

    puts(dp[n] ? "YES" : "NO");

    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int SIZE_H = 10005, SIZE_N = 1005;
int dp[SIZE_N][SIZE_H];
int main(){
    int inf = 1e9;
    int h, n, A[SIZE_N], B[SIZE_N];
    cin >> h >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> A[i] >> B[i];
    }
    
    for (int i = 0; i < SIZE_N; i++)
    {
        dp[i][0] = 0;
    }
    for (int i = 1; i < SIZE_H; i++)
    {
        dp[0][i] = inf;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= h; j++)
        {
            if (j <= A[i])
            {
                dp[i][j] = min(dp[i-1][j], B[i]);
                continue;
            }
            dp[i][j] = min(dp[i][j-A[i]] + B[i], dp[i-1][j]);
        }
    }
    cout << dp[n][h];
    
}

Measured memory_bytes: 39424
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
for i in range(1,n+100):
    if int(i*1.08) == n:
        print(i)
        break
else:
    print(':(')

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

constexpr int LEN = 100005;
int dp[LEN];
vector<int> g[LEN];

int path_len(int u, const int n) {
    if (dp[u] > -1) return dp[u];
    int l = 0;
    for (int x : g[u]) l = max(l, path_len(x, n) + 1);
    return dp[u] = l;
}

int main() {
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        g[--x].push_back(--y);
    }

    int ans = 0;
    memset(dp, -1, sizeof(dp));
    rep(i, n) ans = max(ans, path_len(i, n));

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

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    string s, t;
    cin >> s >> t;
    int ns = s.length(), nt = t.length();
    vector<vector<int>> dp(ns + 2, vector<int>(nt + 2, 0));
    vector<vector<P>> prev(ns + 2, vector<P>(nt + 2, P(-1, -1)));
    for(int i = 0; i < ns; ++i){
        for(int j = 0; j < nt; ++j){
            if(s[i] == t[j]){
                if(chmax(dp[i + 1][j + 1], dp[i][j] + 1)){
                    prev[i + 1][j + 1] = P(i, j);
                }
            }
            else{
                if(chmax(dp[i + 1][j + 1], dp[i][j + 1])){
                    prev[i + 1][j + 1] = P(i, j + 1);
                }
                if(chmax(dp[i + 1][j + 1], dp[i + 1][j])){
                    prev[i + 1][j + 1] = P(i + 1, j);
                }
            }
        }
    }
    string ans = "";
    if(dp[ns][nt]){
        int x = ns, y = nt;
        while(x > 0 && y > 0){
            int nxt_x = prev[x][y].first, nxt_y = prev[x][y].second;
            if(x - nxt_x == y - nxt_y)  ans += s[x - 1];
            x = nxt_x, y = nxt_y;
        }
        reverse(ans.begin(), ans.end());
    }
    cout << ans << endl;
}

Measured memory_bytes: 109000
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,a,b,j,k;
    cin>>a>>b;


    cout<<max(a+b,max(a*b,a-b));

    return 0;
}





Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long sum=0;
		for(int i=1;i<n;i++){
			if(n%i!=0){sum=sum+(n/i);}
			else{sum=sum+(n/i-1);}
		}
		System.out.println(""+sum);
	}
}

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

using namespace std;

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

	bool ans = 0;

	for (int i = 0; i < b; i++) {
		if ((a*i) % b == c) {
			cout << "YES" << endl;
			ans = 1;
			break;
		}
	}
	if (ans == 0)cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
    int n, m;

    while (1){
        int ban[1000] = {0};
        int sai[1000] = {0};
        int sum = 1;
        int pt;

        scanf("%d %d", &n, &m);

        if (n == 0 && m == 0){
            break;
        }

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

        for (int i = 0; i < m; i++){
            scanf("%d", &sai[i]);
        }

        for (int i = 0; i < m; i++){
            sum += sai[i];
            sum += ban[sum - 1];
            //printf("sum = %d\n", sum);
            if (sum >= n){
                pt = i + 1;
                break;
            }
        }
        printf("%d\n", pt);
    }

    return (0);
}

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

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

  int disp_num = 1;
  for (int i = 0; i < N; i++) {
    if (disp_num * 2 < disp_num + K) {
      disp_num *= 2;
    }
    else {
      disp_num += K;
    }
  }

  cout << disp_num << endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll n, m;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    if (n<m) swap(n,m);
    if (n-m>1)out(0);

    ll ans = n==m ? 2: 1;

    while (n) {
	ans *= n;
	ans %= mod;
	n--;
	swap(n, m);
    }


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> X(n), Y(n), x(n), y(n);
  rep(i, n) {
    cin >> X[i] >> Y[i];
    x[i] = X[i] + Y[i];
    y[i] = X[i] - Y[i];
  }
  sort(all(x));
  sort(all(y));
  cout << max({*x.rbegin()-*x.begin(),
               *y.rbegin()-*y.begin()}) << endk;
  return 0;
}


Measured memory_bytes: 9492
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi v(100002);
	int n;
	cin >> n;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		v[b-1]--;
		v[a - 2]++;
	}
	int ans = 0;
	REP(i, v.size() - 1)v[i + 1] += v[i];
	REP(i, v.size()) {
		if (i + 1 <= v[i])ans = i + 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 5 != 0 && i % 3 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620