akhauriyash/Code-Regression huggingface dataset:
#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)

using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

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

typedef long long ll;

const int N = 20 + 10;
char s[N]; int vis[N];
ll ans;

inline ll getnum(int ss, int t) {
	ll res = 0;
	For(i, ss, t) res = res * 10 + (s[i] ^ 48);
	return res;
}

int main() {

	scanf("%s", s + 1);
	int n = strlen(s + 1);

	int all = (1 << n - 1) - 1;
	
	For(st, 0, all) {
		int cnt; vis[cnt = 1] = 1;
		For(i, 1, n - 1) if ((st >> i - 1) & 1) vis[++ cnt] = i + 1; vis[++ cnt] = n + 1;
		For(i, 1, cnt - 1) ans += getnum(vis[i], vis[i + 1] - 1);
	}
	cout << ans << endl;

	return 0;
}


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

int main()
{
	string s;
	cin >> s;
	map<char, int> a;
	for (int i = 0; i < s.size(); i++)
	{
		a[s[i]]++;
	}

	if (abs(a['a'] - a['b']) <= 1 && abs(a['a'] - a['c']) <= 1 && abs(a['b']- a['c']) <= 1)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
}

Measured memory_bytes: 512
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")
for i in range(n):
  for j in range(i,n):
    if 2*j-i>=n:
      break
    else:
      if s[i]!=s[j]!=s[2*j-i]!=s[i]:
        ans-=1
print(ans)

Measured memory_bytes: 68060
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int value = Integer.parseInt(a + b);
		if(value % 2 == 0){
			for(int i = value; i > 0; i -= 2){
				if(i * i == value){
					System.out.println("Yes");
					return;
				}
			}
		}else{
			for(int i = value; i > 0; i -= 2){
				if(i * i == value){
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 22868
#include <stdio.h>
#include <math.h>
int main()
{
  int a,b;
  char c;
  scanf("%d",&a);
  scanf(" %c",&c);
  scanf("%d",&b);
  while (!((c=='?'))){
    if (c=='+'){
      printf("%d\n",a+b);
    }else if(c=='-'){
      printf("%d\n",a-b);
    }else if(c=='*'){
      printf("%d\n",a*b);
    }else if(c=='/'){
      printf("%d\n",a/b);
    }
    scanf("%d",&a);
    scanf(" %c",&c);
    scanf("%d",&b);
  }
    return 0;
}

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

#define __ ios::sync_with_stdio(0),  cin.tie(0);
#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

const int MXN = 1e5+10;
ll n, ft[MXN];

void add1(int idx, int val){
  idx++;
  while (idx < MXN){
    ft[idx] += val;
    idx += idx & -idx;
  }
}

void add(int l, int r, int val){
  add1(l, val);
  add1(r+1, -val);
}

ll csum(int idx){
  idx++;
  ll ret = 0;
  while (idx > 0){
    ret += ft[idx];
    idx -= idx & -idx;
  }
  return ret;
}

ll query(int idx){
  return csum(idx);
}


int main(){__
  cin >> n;
  ll a[n+1];
  for (int i = 0; i < n+1; ++i){
    cin >> a[i];
  }
  if(n==0){
    if(a[0]<=1){
      cout << a[0] << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }
  if(a[0]){
    cout << -1 << endl;
    return 0;
  }
  // ll ache[n+1];
  // memset(ache, 0, sizeof(ache));
  // ache[0] = 2;
  add(0, 0, 2);
  ll used[n+1];
  memset(used, 0, sizeof(used));
  int j = 0;
  ll ans = 1;
  for (int i = 1; i <= n; ++i){
    while(a[i]){
      if(j==i) {
        cout << -1 << endl;
        return 0;
      }
      ll ache  = query(j);
      if(ache-used[j]<=a[i]){
        a[i] -= ache-used[j];
        ans += 1LL*(ache-used[j])*(i-j);
        if(j+1<=i-1){
          add(j+1, i-1, ache-used[j]);
        }
        // add(j+1, i)
        // for (int k = j+1; k < i; ++k){
        //   ache[k] += ache[j]-used[j];
        // }
        j++;
      } else {
        used[j] += a[i];
        ans += 1LL*a[i]*(i-j);
        if(j+1<=i-1){
          add(j+1, i-1, a[i]);
        }
        // for (int k = j+1; k < i; ++k){
        //   ache[k] += a[i];
        // }
        a[i]=0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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


typedef long long ll;

using namespace std;


const ll mod=1000000007;


typedef vector<vector<int> > Graph;

Graph g;


ll suji[100001];

int  main(){

    ll N;
    cin>>N;

    ll a;

    ll sum=0;
   

    for(int i=0;i<N;i++){
        cin>>a;
        ++suji[a];
        sum+=a;
    }
    ll Q;
    cin>>Q;
    ll b,c;
    ll ans[Q];
    for(ll q=0;q<Q;q++){
        cin>>b>>c;
        sum+=suji[b]*(c-b);
        suji[c]+=suji[b];
        suji[b]=0;
        ans[q]=sum;
    } 

    for(ll q=0;q<Q;++q){
        cout<<ans[q]<<endl;
    }
}


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

int main() {
	int n,i,c=0,x;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	x=a[0];
	for(i=0;i<n;i++){
	    if(a[i]<=x){
	        c++;
	        x=a[i];
	    }
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	count := 0
	for {
		for d := 0; d < n; d++ {
			if a[d]%2 != 0 {
				fmt.Println(count)
				return
			}
			a[d] /= 2
		}
		count++
	}
}

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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(" ");
        int n = int.Parse(input[0]);
        int d = int.Parse(input[1]);
        double d2 = Math.Pow(d, 2);
        int ans = 0;

        for (int i = 0; i < n; i++)
        {
            int[] tmp = Array.ConvertAll(Console.ReadLine().Split(" "), int.Parse);
            if (Math.Pow(tmp[0], 2) + Math.Pow(tmp[1], 2) <= d2)
            {
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 40756
N, K = map(int, input().split(' '))

V = list(map(int, input().split(' ')))

dp = [[[-10000000000] * (K+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][N][0] = 0
for i in range(N) :
    for j in range(N, i-1, -1) :
        for k in range(1, K+1) :
            dp[i][j][k] = max(dp[i][j][k], dp[i][j][k-1])
            if 0 <= i-1 < N:
                dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k-1] + V[i-1])
            if 0 <= j+1 <= N :
                dp[i][j][k] = max(dp[i][j][k], dp[i][j+1][k-1] + V[j])
            if k >= 2 :
                if 0 <= i-1 < N :
                    dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k-2])
                if 0 <= j+1 <= N :
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j+1][k-2])

ans = 0
for i in range(N+1) :
    for j in range(N+1) :
        for k in range(K+1) :
            ans = max(ans, dp[i][j][k])
            #print(i, j, k, dp[i][j][k])

print(ans)


Measured memory_bytes: 6804
#include<bits/stdc++.h>
using namespace std;
#define int long long
int s,x2,y2,x3,y3;
signed main(){
	cin>>s;
	if(s<=1e9) cout<<"0"<<" "<<"0"<<" "<<s<<" "<<"0"<<" "<<"69"<<" "<<"1";
	else{
		x2=1e9;
		y3=(s-1)/x2+1;
		x3=x2*y3-s;
		cout<<"0"<<" "<<"0"<<" "<<x2<<" "<<"1"<<" "<<x3<<" "<<y3;
	}
}

Measured memory_bytes: 256
N=int(input())
A=[int(input())for _ in range(N)]

from collections import*
A.sort()
ans1=deque()
ans1.append(A[0])
i=j=1
while i<=N-j:
    if i<=N-j:
        ans1.append(A[-j])
        j+=1
    if i<=N-j:
        ans1.appendleft(A[-j])
        j+=1
    if i<=N-j:
        ans1.append(A[i])
        i+=1
    if i<=N-j:
        ans1.appendleft(A[i])
        i+=1
ans1=list(ans1)
ans1=sum(abs(x-y)for x,y in zip(ans1,ans1[1:]))

A=A[::-1]
ans2=deque()
ans2.append(A[0])
i=j=1
while i<=N-j:
    if i<=N-j:
        ans2.append(A[-j])
        j+=1
    if i<=N-j:
        ans2.appendleft(A[-j])
        j+=1
    if i<=N-j:
        ans2.append(A[i])
        i+=1
    if i<=N-j:
        ans2.appendleft(A[i])
        i+=1
ans2=list(ans2)
ans2=sum(abs(x-y)for x,y in zip(ans2,ans2[1:]))

print(max(ans1,ans2))

Measured memory_bytes: 14708
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val memo = LongArray(n + 1) { 0 }
    memo[0] = 2L
    memo[1] = 1L

    fun f(i: Int): Long {
        if (memo[i] != 0L) return memo[i]
        memo[i] = f(i - 1) + f(i - 2)
        return memo[i]
    }

    println(f(n))
}


Measured memory_bytes: 29856
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=1000;
const ll mod=1e9+7;
int h,w,k;
vector<int>vec;
ll dp[N][N];

void pcal(){
	int lim=(1<<(w-1));
	FER(i,0,lim){
		bool f=true;
		for(int j=i;j;j>>=1)if(j%4==3)f=false;
		if(f)vec.pb(i);
	}
}

int ver(int pos,int mask){
	if((mask>>pos)&1)return pos+1;
	if(pos&&((mask>>(pos-1))&1))return pos-1;
	return pos;
}

ll solve(){
	dp[h][w-k]=1;
	IFR(hh,h-1,0)FER(i,0,w){
		//cout<<"estado"<<endl;
		//cout<<hh<<" "<<i<<endl;
		for(int mask: vec){
			int i2=ver(i,mask);
			//cout<<i<<" "<<mask<<" "<<i2<<endl;
			//cout<<setw(3)<<mask<<" "<<i2<<endl;
			dp[hh][i]=(dp[hh][i]+dp[hh+1][i2])%mod;
		}
	}
	//FER(i,0,h+1){
	//	IFR(j,w-1,0)cout<<setw(7)<<dp[i][j];
	//	cout<<endl;
	//}
	//cout<<"lle"<<endl;
	return dp[0][w-1];
}

int main(){	
	fastio;
	cin>>h>>w>>k;
	pcal();
	cout<<solve()<<endl;
	return 0;
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int c[10][10];

void warshallfloyd(int n) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                chmin(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }
}

int main()
{
    int h, w;
    cin >> h >> w;
    
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    warshallfloyd(10);
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int a;
            cin >> a;
            if (a != -1) {
                ans += c[a][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll H,W,N;
    cin>>H>>W>>N;
    vl a(N);
    rep(i,N)cin>>a[i];
    string num="1";
    vector<vs> vec(H,vs(W));
    rep(i,H){
        rep(j,W){
            ll x=atoi(num.c_str());
            a[x-1]--;
            vec[i][j]=num;
            if(!a[x-1]){
                x++;
                num=to_string(x);
            }
        }
        if(i%2==1){
            reverse(all(vec[i]));
        }
    }
    rep(i,H){
        rep(j,W){
            cout<<vec[i][j];
            if(j==W-1)cout<<endl;
            else cout<<' ';
        }
    }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 1;
ll n, a[N], b[N];
int main() {
	scanf("%lld", &n);
	ll sumA = 0, cnt = 0;
	ll mx = 0;
	bool ok = false;
	for(int i=0; i<n; ++i) {
		scanf("%lld%lld", a+i, b+i);
		sumA += a[i];
		if(a[i] == b[i])
			++cnt;
	}
	if(cnt == n) return puts("0"), 0;
	ll mn = 1e9;
	for(int i=0; i<n; ++i) {
		if(a[i] > b[i]) {
			mn = min(mn, b[i]);
		}
	}
	cout << sumA - mn << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll prime = 10000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

int main() {

	ll n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 - 1 << endl;
	}
	else {
		cout << n / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 888
//
// Created by たかえすみずき on 2017/07/15.
//

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

int main() {
    string s;
    cin >> s;

    int l = s.size();

    while (l > 0) {
        l--;
        int n = (l - 1) / 2;
        string str1 = "";
        string str2 = "";
        for(int i = 0; i < l; i++){
            if(i <= n){
                str1 += s[i];
            }else{
                str2 += s[i];
            }
        }

        if(str1 == str2) break;

    }
    cout << l << endl;

}


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

const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nHigh;
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
    m_nDept(END), m_nHigh(END), m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

void fnInput(vector<StNod> &rvoNod)
{
  StNod oNod;
  int nMaxSiz;

  cin >> nMaxSiz;
  rvoNod.resize(nMaxSiz, oNod);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nLeft, nRigt;
    cin >> nParnt >> nLeft >> nRigt;

    rvoNod[nParnt].m_nLeft = nLeft;
    rvoNod[nParnt].m_nRigt = nRigt;
    if (nLeft != END)  rvoNod[nLeft].m_nParnt = nParnt;
    if (nRigt != END)  rvoNod[nRigt].m_nParnt = nParnt;
  }
}

void fnSetDepth(vector<StNod> &rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nLeft != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLeft, nDept + 1);

  if (rvoNod[nx].m_nRigt != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRigt, nDept + 1);
}

int fnSetHight(vector<StNod> &rvoNod, int nx)
{
  int nLHigh =0, nRHigh = 0;

  if (rvoNod[nx].m_nLeft != END)
    nLHigh = fnSetHight(rvoNod, rvoNod[nx].m_nLeft) + 1;
  if (rvoNod[nx].m_nRigt != END)
    nRHigh = fnSetHight(rvoNod, rvoNod[nx].m_nRigt) + 1;
  
  return rvoNod[nx].m_nHigh = max(nLHigh, nRHigh);
}

void fnBinTree(vector<StNod> &rvoNod)
{
  int nx = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  int nDept = 0;
  fnSetDepth(rvoNod, nx, nDept);
  fnSetHight(rvoNod, nx);
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    if (cnrvoNod[i].m_nDept == END)  break;
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", sibling = ";

    if (cnrvoNod[i].m_nParnt == END)  cout << END;
    else
    {
      int nx = cnrvoNod[i].m_nParnt;
      if (i == cnrvoNod[nx].m_nLeft)  cout << cnrvoNod[nx].m_nRigt;
      else                            cout << cnrvoNod[nx].m_nLeft;
    }
    
    cout << ", degree = ";
    int nCCnt = 0;
    if (cnrvoNod[i].m_nLeft != END)  nCCnt++;
    if (cnrvoNod[i].m_nRigt != END)  nCCnt++;
    cout << nCCnt << ", depth = " << cnrvoNod[i].m_nDept << ", height = " << cnrvoNod[i].m_nHigh;

    if (!cnrvoNod[i].m_nDept)       cout << ", root";
    else if (!cnrvoNod[i].m_nHigh)  cout << ", leaf";
    else                            cout << ", internal node";
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnBinTree(voNod);
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 1200
import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans = 0
for k in range(29):
    a = np.sort(np.hstack((A%(2**(k+1)),A%(2**(k+1))-2**(k+1))))
    b = B%(2**(k+1))
    ans += (np.sum(np.searchsorted(a,2**(k+1)-b)-np.searchsorted(a,2**k-b)))%2*2**k

print(ans)

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL<<60;

int main() {
    ll H, N;
    cin >> H >> N;
    vector<ll> Health(N), Point(N);
    for (ll i = 0; i < N; ++i){
        cin >> Health[i] >> Point[i];
    }

    vector<ll> dp(H+1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            //cout<<"First : "<<dp[min(j+Health[i], H)]<<" "<<dp[j] + Point[i]<<endl;
            chmin(dp[min(j+Health[i], H)], dp[j] + Point[i]);
            //cout<<"Second : "<<dp[min(j+Health[i], H)]<<" "<<dp[j] + Point[i]<<endl;
        }
    }
    cout << dp[H] << endl;
    return 0;
}


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

seq = list(map(int, input().split()))

count = 0

print(*sorted(seq))

for i in range(len(seq)):
    for j in reversed(range(i + 1, len(seq))):
        if seq[j] < seq[j - 1]:
            seq[j], seq[j - 1] = seq[j - 1], seq[j]
            count += 1

print(count)


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (100006)
ll n,a,b,A[MAXN],dp[MAXN][2],psum[MAXN],ans,mod=1e9+7;
int main()
{
	FAST
	cin>>n>>a>>b;
	FOR(i,1,n)cin>>A[i];
	if(a<b) swap(a,b); // now, a is the larger one
	FOR(i,2,n) psum[i]=psum[i-1]+((A[i]-A[i-1])>=b);
	dp[0][0]=1;
	deque<ll> p1; ll ofs1=0, u1=-1;
	deque<ll> p2; ll ofs2=0, u2=-1;
	auto cool=[&](ll x) {
		if(x<=1) return bool(1);
		if(x==n) return bool(1);
		return (A[x+1] - A[x-1]) >= b;
	};
	p1.pb(0), u1=0, ofs1+=dp[0][0];
	FOR(i,1,n) {
		while(p1.size()) {
			ll x=p1[0];
			if(i-1 < x+1) break;
			if(psum[i-1]-psum[x+1] == (i-1) - (x+1)) break;
			if(u1 >= 0) ofs1 -= dp[x][0], ofs1 += mod, ofs1 %= mod, --u1;
			p1.pop_front();
		}
		while(p2.size()) {
			ll x=p2[0];
			if(i-1 < x+1) break;
			if(psum[i-1]-psum[x+1] == (i-1) - (x+1)) break;
			if(u2 >= 0) ofs2 -= dp[x][1], ofs2 += mod, ofs2 %= mod, --u2;
			p2.pop_front();
		}
		while(u1+1 < p1.size() && (p1[u1+1] == 0 || A[i]-A[p1[u1+1]] >= a)) {
			++ u1, ofs1+=dp[p1[u1]][0],ofs1%=mod;
		}
		while(u2+1 < p2.size() && (p2[u2+1] == 0 || A[i]-A[p2[u2+1]] >= a)) {
			++ u2, ofs2+=dp[p2[u2]][1],ofs2%=mod;
		}
		// dp(i,0) a alone
		dp[i][0] = ofs1 + ofs2, dp[i][0]%=mod;
		// dp(i,1) a *not* alone
		if(i-1 && A[i]-A[i-1] >= a) dp[i][1] = dp[i-1][0]+dp[i-1][1], dp[i][1]%=mod;
		-- i;
		if(i && cool(i)) p1.pb(i);
		p2.pb(i);
		++ i;
		if(cool(i)&&(n==i||psum[n]-psum[i+1]==n-(i+1))) ans += dp[i][0], ans %= mod;
		if((n==i||psum[n]-psum[i+1]==n-(i+1))) ans += dp[i][1], ans %= mod;
	}
	cout<<(ans+(psum[n]==n-1))%mod<<'\n';
}
/*
5 7 3
1
3
6
9
12
*/ 


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main()
{
    int a[10000],
        x,
        c;
    
    for(c = 0; c < 10000; c++)
    {
        cin >> x;
        
        if(x == 0)
        {  
            a[c] = x;
            break;
        }
            
        else
            a[c] = x;
    }
    
    for(c = 0; c < 10000; c++)
    {
        if(a[c] != 0)
            cout << "Case " << c + 1 << ": " << a[c] << endl;
        
        else
            break;
    }
    
    return 0;
}

Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int A = n[0], B = n[1], AB = n[2], X = n[3], Y = n[4];
        int O_AB = A + B;
        long ans = 0;
        ans = Math.Min(X, Y) * Math.Min(O_AB, AB * 2);
        ans += (Math.Max(X, Y) - Math.Min(X, Y)) * Math.Min((Math.Max(X, Y) == X ? A : B), AB * 2);
        Console.WriteLine(ans);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 13268
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;
class Main {
	
	static int[][] map;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int minN = n;
		int maxN = n;
		while(true) {
			boolean mnN = check(minN);
			boolean mxN = check(maxN);
			
			if(mnN) {
				System.out.println(minN);
				break;
			}
			if(mxN) {
				System.out.println(maxN);
				break;
			}
			minN--;
			maxN++;
			
		}
		
	}
	
	static boolean check(int a) {
		char[] A = String.valueOf(a).toCharArray();
		char[] B = new char[A.length];
		for(int i = 0; i < A.length; i++) {
			B[i] = A[A.length - i - 1];
		}
		int b = Integer.parseInt(String.valueOf(B));
		
		return a == b;
		
	}
 	
}

Measured memory_bytes: 17288
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

#define intmax 1299710
int isprime[intmax];
void makeprime(){
	REP(i,intmax) if(i%2!=0) isprime[i] = true;
	isprime[1] = false;
	isprime[2] = true;
	for(ll int i=3;i<sqrt(intmax);i+=2){
		for(ll int j=i+2;j<intmax;j+=2){
			if(j%i==0) isprime[j] = false;
		}
	}
}

int main(){
	makeprime();
	int n;
	while(cin >> n,n){
		ll int a,b;
		if(!isprime[n]){
			for(int i = n+1;i<intmax;i++){
				if(isprime[i]) {
					a = i;
					break;
				}
			}
			for(int i= n-1;i>-1;i--){
				if(isprime[i]){
					b = i;
					break;
				}
			}
			cout << a-b << endl;
		}else{
			cout << 0 << endl;
		}

	}
}

Measured memory_bytes: 6236
#include<iostream>
using namespace std;
int main()
{
    int i,j=0;
    char S[5];
    char T[5];
    cin>>S;
    cin>>T;
    for(i=0;i<3;i++)
    {
        if(S[i]==T[i])
        {
            j=j+1;
        }
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
string str;
ll a, b;

int main()
{
	cin >> str;
	for (ll i = 0; i < str.length(); i++)
	{
		if (str[i] == '0') a++;
	}
	b = str.length() - a;
	cout << str.length() - abs(a - b) << endl;
}

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

int main(){
    for (int i = 1; ;i++)
    {
        int x, y, s;
        cin>>x>>y;
        if (x == 0 && y == 0)
        {
            break;
        }

        if (x > y)
        {
            s = y;
            y = x;
            x = s;
        }
        cout<<x<<" "<<y<<endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define R register
#define ll long long
#define mp make_pair
#define pii pair<int, int>
using namespace std;
const int N = 110000;

int x, f[N];

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    read(x);
    f[0] = 1;
    for (R int i = 0; i <= 5; ++i)
        for (R int j = 100 + i; j <= x; ++j)
            f[j] |= f[j - i - 100];
    cout << f[x] << endl;
    return 0;
}

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

int main() {
	string a, b, c; cin >>a>>b>>c;
	if(a.substr(a.length() -1 ,1) == b.substr(0,1) 
	&& b.substr(b.length() -1 ,1) == c.substr(0,1)) {
		cout<<"YES"<<endl;
	} else {
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    if(n%10 == 3) cout<<"bon"<<endl;
    else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8){
        cout<<"pon"<<endl;
    }
    else cout<<"hon"<<endl;
}

Measured memory_bytes: 3624
open Printf
open Scanf

let id x = x

let fib n =
  let dp = Array.make (n+1) 1 in
  let rec iter i =
    if i > n then dp.(n)
    else begin
        dp.(i) <- dp.(i-2) + dp.(i-1);
        iter (i+1)
      end
  in iter 2

let () =
  let n = scanf "%d\n" id in
  fib n |> printf "%d\n"

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

int main(){
    int n,digit,sum=0,naux;
    
    cin>>n;

    naux = n;

    while(n){
        digit = n%10;
        n /= 10;

        sum += digit;
    }

    if(naux%sum == 0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3568
class SegTree:
    X_unit = 0
    X_f = max

    def __init__(self, N):
        self.N = N
        self.X = [self.X_unit] * (N + N)

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)

n,k = map(int,input().split())
seg = SegTree(300001)
# a = [0]*n
# seg.build(a)
for i in range(n):
    a = int(input())
    seg.set_val(a,seg.fold(max(0,a-k),min(300001,a+k+1)) + 1)

print(seg.fold(0,300001))

Measured memory_bytes: 85428
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};


vector<int> a(10000000,0);
void f(int ma){
    rep(i,ma+1){
        if(a[i] != 0){
            for(int j = i+i;j <= ma; j+=i){
                if(a[j] == 1) a[j] = 0;
            }
        }
    }
}

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

    int n;
    int ma = 0;
    cin >> n;
    rep(i,n){
        int x;
        cin >> x;
        ma = max(ma,x);
        if(a[x] == -1) continue;
        if(a[x] == 1) a[x] = -1;
        else a[x] = 1;
    }
    ll ans = 0;
    f(ma);
    rep(i,ma+1){
        if(a[i] == 1) ans++;
    }
    cout << ans << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 42224
#include <iostream>
#include <vector>
#include <set>
using namespace std;
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int N;
	// for removing duplication
	set<int> x_set, y_set;

	cin >> N;
	vector<int> x(N), y(N);

	int M = 2e5;
	auto uf = UnionFind(M + 1);

	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		x_set.insert(x[i]);
		y_set.insert(y[i]);
	}

	for (int i = 0; i < N; i++) {
		int x_idx = *x_set.lower_bound(x[i]);
		int y_idx = *y_set.lower_bound(y[i]);
		uf.unite(x_idx, 1e5 + y_idx);
	}
	vector<set<int>> xs(M + 1), ys(M + 1);
	for (int i = 0; i < N; i++) {
		int x_idx = *x_set.lower_bound(x[i]);
		int y_idx = *y_set.lower_bound(y[i]);
		int root = uf.root(x_idx);
		xs[root].insert(x_idx);
		ys[root].insert(y_idx);
	}

	set<int> s;
	for (int i = 0; i < M; i++) {
		s.insert(uf.root(i));
	}

	long long ans = 0;
	for (auto& i : s) {
		ans += (long long)xs[i].size() * ys[i].size();
	}

	cout << ans - N << endl;
}

Measured memory_bytes: 34688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
    vector<int>vec = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin >> x >> y;
    if (vec.at(x) == vec.at(y)){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll u, v ; ll cost; };
int V, E;
int N;
vector<edge> es;
vector<P> vx, vy;
ll llabs(ll x){
  return x >= 0 ? x : - x;
}

// union - find tree !!!!!!!!!!!!!!!!!!!!!!!!!
vector<int> par; //oya
vector<int> rnk; //ki no hu ka sa
// n要素で初期化
void init(int n){
    par.resize(n);rnk.resize(n);
    FOR(i, 0, n){par[i] = i;rnk[i] = 0;}
}
//木の根を求める
int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}
//xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y])par[x] = y;
    else{par[y] = x;if(rnk[x] == rnk[y]) rnk[x]++;}
    return;
}
bool isSame(int x, int y){return find(x) == find(y);}

ll kruskal(){
  sort(es.begin(), es.end(), [](edge& e1, edge& e2){
    return e1.cost < e2.cost;
  });
  init(V);
  ll res = 0;
  FOR(i,0,E){
    edge e = es[i];
    if(!isSame(e.u, e.v)){
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

int main(){
  cin >> N;
  vx.resize(N);
  vy.resize(N);
  es.resize(2*(N-1));
  FOR(i,0,N){
    ll x, y;
    cin >> x >> y;
    vx[i] = P(x,i);
    vy[i] = P(y,i);
  }
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  FOR(i,0,N-1){
    edge e;
    e.u = vx[i+1].second;
    e.v = vx[i].second;
    e.cost = vx[i+1].first - vx[i].first;
    es[2 * i] = e;
  }
  FOR(i,0,N-1){
    edge e;
    e.u = vy[i+1].second;
    e.v = vy[i].second;
    e.cost = vy[i+1].first - vy[i].first;
    es[2 * i + 1] = e;
  }
  V = N;
  E = 2 * (N - 1);
  ll ans = kruskal();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8960
import static java.lang.String.valueOf;
import static java.lang.System.out;
import static java.util.regex.Pattern.compile;
import java.io.File;
import java.util.Scanner;


public class Main extends BaseExe {

    public static void main(String[] args) {
        new Main().exeSysIn();
    }

    @Override
    protected void execute() {
        while (judgeInData())
            exeUOC();
    }

    private void exeUOC() {
        char[] dataes = getInData().toCharArray();
        // String outStr = valueOf(dataes);
        for (int count = 0; !judgeBreak(valueOf(dataes)) && count < 26; count++) {
            dataes = editList(dataes);
        }
        out.println(dataes);
    }

    private boolean judgeBreak(String outStr) {
        return compile("the|this|that").matcher(outStr).find();
    }

    private char[] editList(char[] dataes) {
        for (int index = 0; index < dataes.length; index++) {
            if ('a' <= dataes[index] && dataes[index] < 'z') {
                dataes[index]++;
            } else if (dataes[index] == 'z') {
                dataes[index] = 'a';
            }
        }
        return dataes;
    }
}


abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) {
        this.scan = scan;
        execute();
    }

    protected abstract void execute();

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        return !"".equals(inData = nextLine());
    }

    protected String getInData() {
        return inData;
    }

}

Measured memory_bytes: 26420
N=int(input())
H=[int(i) for i in input().split(" ")]

j=0
for i in range(N):
  if i==0:
    H[i]-=1
  elif H[i]>H[i-1]:
    H[i]-=1
  elif H[i]==H[i-1]:
    H[i]-=0
  elif H[i]<H[i-1]:
    j+=1

if j==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14276
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,d,r;
	double f;
	cin>>a>>b;
d=a/b;
r=a%b;
f=1.0*a/b;

    cout<<d<<" "<<r<<" ";
	printf("%.5lf\n",f);
return 0;
}


Measured memory_bytes: 3228
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, i;
  cin >> N >> i;

  cout << N - i + 1 << endl;
  return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
int main()
{
	long long N,A,B,sum=0;
	scanf("%lld %lld %lld",&N,&A,&B);
	sum+=(N/(A+B))*A;
	if(N%(A+B)<=A)   sum+=(N%(A+B));
	else if(N%(A+B)>A)  sum+=A;
	printf("%lld\n",sum);
	return 0;
 } 

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

int main()
{
	int a, b, c;
	bool f = 0;

	cin >> a >> b;

	if (b / 10 == 0)
		c = a * 10 + b;
	else if (b / 100 == 0)
		c = a * 100 + b;
	else
		c = a * 1000 + b;

	for (int i = 1; i <= sqrt(c); i++) {
		if (c % i == 0 && c / i == i)
			f = 1;
	}

	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

    return 0;
}


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

int main() {
	int n,k,p=0,i,m,x;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	{
	    p++;
	    i+=k-1;
	    if(i<n-1)
	    i--;
	}
	cout<<p<<endl;
}


Measured memory_bytes: 640
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let ab: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut add = 0;
    for i in (0..n).rev() {
        //
        let a = ab[i].0 + add;
        let b = ab[i].1;
        let c = (a + b - 1) / b * b - a;
        add += c;
    }
    println!("{}", add);
}


Measured memory_bytes: 5576
N, K = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
mod = 10**9+7

def matrixmul(A, B):
    n = len(A)
    C = []
    for i in range(n):
        c = []
        for j in range(n):
            num = 0
            for k in range(n):
                num = (A[i][k]*B[k][j] + num)%mod
            c.append(num)
        C.append(c)
    return C

now = [[1 if i == j else 0 for i in range(N)] for j in range(N)]        

while K:
    if K&1 == 1:
        now = matrixmul(now, A)
    K //= 2
    A = matrixmul(A, A)

ans = 0
for i in range(N):
    for j in range(N):
        ans = (now[i][j]+ans)%mod
print(ans)

Measured memory_bytes: 43724
from collections import deque
n,q=map(int,input().split())
eage=[[] for i in range(n)]
visited=[False]*n
point=[0]*n
for i in range(n-1):
    a,b=map(int,input().split())
    eage[a-1].append(b-1)
    eage[b-1].append(a-1)
for i in range(q):
    p,x=map(int,input().split())
    point[p-1]+=x

q=deque([0])
while q:
    v=q.popleft()
    visited[v]=True
    for nv in eage[v]:
        if visited[nv]==True:
            continue
        point[nv]+=point[v]
        q.append(nv)
print(*point)



Measured memory_bytes: 105236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var x = Input().ToInt();
		long min = DpInf;
		for(int i = 1; i <= 100; i++)
		{
			long wa = 0;
			for(int j = 0; j < n; j++)
			{
				wa += (i-x[j])*(i-x[j]);
			}
			min = Math.Min(wa, min);
		}
		Console.WriteLine(min);
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	 }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>

using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if(n==0){
        cout << "0";
    }else if(n>0){
        ll max = 1;
        ll tmp = 1;
        ll k = 1;
        while(max<n){
            tmp *= 4;
            max += tmp;
            k += 2;
        }
        char c[k];
        tmp = max-n;
        for(int i = 0;i<k;i++){
            if(i%2==0){
                if((tmp>>i)&1){
                    c[i] ='0';
                }else{
                    c[i] = '1';
                }
            }else{
                if((tmp>>i)&1){
                    c[i] ='1';
                }else{
                    c[i] = '0';
                }
            }
        }
        REP(i,k) cout << c[k-1-i];
    }else{
        ll min = -2;
        ll tmp = -2;
        ll k = 2;
        while(min>n){
            tmp *= 4;
            min += tmp;
            k += 2;
        }
        char c[k];
        tmp = n-min;
        for(int i = 0;i<k;i++){
            if(i%2==0){
                if((tmp>>i)&1){
                    c[i] ='1';
                }else{
                    c[i] = '0';
                }
            }else{
                if((tmp>>i)&1){
                    c[i] ='0';
                }else{
                    c[i] = '1';
                }
            }
        }
        REP(i,k) cout << c[k-1-i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> v(h);
    for (int i = 0; i < h; i++) {
        string vi;
        cin >> vi;
        v[i] = vi;
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (v[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        if (row[i] == false) {
            continue;
        }
        for (int j = 0; j < w; j++) {
            if (col[j] == false) {
                continue;
            }
            cout << v[i][j];
        }
        cout << endl;
    }


    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

def equalfind(A):#配列中の等しい要素の組をカウント　オーダーはO(NlogN)
    A.sort()
    s=1
    count=0
    if len(A)==1:
        return count
    else:
        for i in range(0,len(A)-1):
            if A[i]==A[i+1]:
                s+=1
            else:
                count+=s*(s-1)//2
                s=1
        return count+s*(s-1)//2

N,P=map(int,input().split())
S=input()

def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)%P
    x = (x*x)%P
    n = n >> 1 #ビットシフト
  return ans%P

if P!=2 and P!=5:
    data=[(int(S[i])*(pow(10,N-1-i)))%P for i in range(0,N)]
    ans=list(accumulate(data))
    ans=[ans[i]%P for i in range(0,N)]
    ans.append(0)
    print(equalfind(ans))
elif P==2:
    ans=0
    for i in range(0,N):
        if int(S[i])%2==0:
            ans+=i+1
    print(ans)
else:
    ans=0
    for i in range(0,N):
        if int(S[i])%5==0:
            ans+=i+1
    print(ans)

Measured memory_bytes: 75672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long ;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int H, int W, vector<vector<char>> const &area, bool &ans){

    int up, down, left, right;
    for(int h = 0; h != H; ++h){
        for(int w = 0; w != W; ++w){

            bool a = true, b = true, c = true, d = true; 

            up = h-1;
            down = h+1;
            left = w-1;
            right = w+1;

            if(area.at(h).at(w) == '#'){
                if(up == -1 || area.at(up).at(w) == '.') a = false;
                if(down == H || area.at(down).at(w) == '.') b = false;
                if(left == -1 || area.at(h).at(left) == '.') c = false;
                if(right == W || area.at(h).at(right) == '.') d = false;
            }

            if( !(a || b || c || d)) ans = false;
        }
    }    

    return;
}

int main(){

    int H, W;
    cin >> H >> W;
    vector<vector<char>> area(H, vector<char>(W));
    for(int h = 0; h != H; ++h){
        for(int w = 0; w != W; ++w){
            cin >> area.at(h).at(w);
        }
    }

    bool ans = true;
    solver(H, W, area, ans);

    if(ans) cout << "Yes"s << endl;
    else cout << "No"s << endl;

    return 0;
}

Measured memory_bytes: 3624