akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef long long ll;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); puts("");}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(x); return v;}
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) {cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}

#define all(x)  (x).begin(),(x).end()
#define tr(c, it)   for(auto it=c.begin(); it!=c.end(); it++)
#define clr(a, b)   memset(a, b, sizeof(a))
#define forn(i, n)   for(int i=0; i<n; i++)

const double eps = 1e-6;

const int N = 100010;

int n;
struct Node{
    int x, y, idx;
}p[N];

bool cmp1(const Node& a, const Node& b){
    if(a.x == b.x) return a.y < b.y;
    return a.x < b.x;
}

bool cmp2(const Node& a, const Node& b){
    if(a.y == b.y) return a.x < b.x;
    return a.y < b. y;
}

int head[N], e;
struct E{
    int u, v, w, next;
}edge[N << 1];

void addedge(int u, int v, int w){
    edge[e].u = u;
    edge[e].w = w;
    edge[e].v = v, edge[e].next = head[u];
    head[u] = e++;
}

bool cmp3(const E& a, const E& b){
    return a.w < b.w;
}




int pa[N];
int find(int x)	{while (x != pa[x]) pa[x] = pa[pa[x]], x = pa[x];return x;}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif

    //scanf("%d",&T);


    while(~scanf("%d",&n))
    {
        for(int i=1; i<=n; i++)
        {
            p[i].idx = i;
            scanf("%d%d",&p[i].x, &p[i].y);
        }

        clr(head, -1), e = 0;

        sort(p+1, p+1+n, cmp1);
        for(int i=1; i<n; i++)
        {
            int w = p[i+1].x - p[i].x;
            addedge(p[i].idx, p[i+1].idx, w);
            //addedge(p[i+1].idx, p[i].idx, w);
        }

        sort(p+1, p+1+n, cmp2);
        for(int i=1; i<n; i++)
        {
            int w = p[i+1].y - p[i].y;
            addedge(p[i].idx, p[i+1].idx, w);
            //addedge(p[i+1].idx, p[i].idx, w);
        }

        LL ans = 0;
        for(int i=1; i<=n; i++)
            pa[i] = i;

        sort(edge, edge+e, cmp3);
        for(int i=0; i<e; i++)
        {
            int a = edge[i].u;
            int b = edge[i].v;

            int fa = find(a);
            int fb = find(b);
            if(fa == fb) continue;

            pa[fb] = fa;
            ans += edge[i].w;
        }
        cout << ans << endl;





    }
    return 0;
}

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

int main()
{
  int K;
  string S;
  cin >> K >> S;

  if (S.size() > K)
  {
    cout << S.substr(0, K) << "..." << endl;
  }
  else
  {
    cout << S << endl;
  }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back
ll cntone(ll n)
{
    ll cnt = 0,i;
    for(i=60;i>=0;i--)
        if((n>>i)&1)
            cnt++;
    return cnt;
}
ll power(ll x,ll y, ll p)  
{  
    ll res = 1;  
    x = x % p;    
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  
int main() 
{ 
    ll n;
    cin>>n;
    string x;
    cin>>x;
    ll i,j,ans = 0,cnt = 0,s = 0 , s2 = 0;
    for(i=n-1;i>=0;i--)
        if(x[i]=='1')
            cnt++;
    if(n==1)
    {
        if(x[0]=='1')
            cout<<0;
        else
            cout<<1;
        return 0;
    }
    if(cnt==0)
    {
        for(i=0;i<n;i++)
            cout<<1<<"\n";
        return 0;
    }
    if(cnt==1)
    {
        for(i=0;i<n;i++)
        {
            if(x[i]=='1')
                cout<<0<<"\n";
            else
            {
                if(x[n-1]=='1')
                    cout<<2<<"\n";
                else{
                    if(i==n-1)
                        cout<<2<<"\n";
                    else
                        cout<<1<<"\n";
                }
            }
        }
        return 0;
    }
    for(j=0,i=n-1;i>=0;i--,j++)
    {
        if(x[i]=='1'){
            s = (s+power(2,j,cnt+1))%(cnt+1);
            if(cnt-1!=0)
            s2 = (s2+power(2,j,cnt-1))%(cnt-1);
        }
        // cout<<s<<" "<<s2<<"\n";
    }
    for(j=0,i=n-1;i>=0;i--,j++)
    {
        ll w = 0;
        ans = 1;
        if(x[j]=='1'){
            if(cnt-1!=0)
                w = (s2-power(2,i,cnt-1)+cnt-1)%(cnt-1);
            else{
                w = 0;
                ans = 0;
            }
        }
        else
            w = (s+power(2,i,cnt+1))%(cnt+1);
        // cout<<w<<" ";
        while(w!=0)
        {
            w = w%cntone(w);
            ans++;
        }
        cout<<ans<<"\n";
    }
    return 0; 
} 

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#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 pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, a, c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int p = -1;
  FOR(i, 0, n){
    cin >> a;
    if(a == p){
      c++;
      p = -1;
    }else{
      p = a;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	ll x, y;
	int c = 0;
	cin >> x >> y;
	while(x <= y) {
		c++;
		x *= 2;
	}
	cout << c;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min = sorted(a)[0]+sorted(b)[0]
for i in range(M):
    x, y, c = map(int, input().split())
    d = a[x-1]+b[y-1]-c
    if min > d:
        min = d
print(min)

Measured memory_bytes: 18736
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int c = sc.nextInt();
        char[] arr = sc.next().toCharArray();

        int[] left = new int[k];
        int[] right = new int[k];

        int idx = 0;

        Left:
        for (int i=0; i<k; i++) {
            if (n<=idx) break Left;
            if (arr[idx]=='o') {
                left[i] = idx;
                idx += (c + 1);
            } else {
                while (arr[idx]!='o') {
                    idx++;
                }
                i--;
            }
        }

        idx = n-1;

        Right:
        for (int i=k-1; i>=0; i--) {
            if (idx<=-1) break Right;
            if (arr[idx]=='o') {
                right[i] = idx;
                idx -= (c + 1);
            } else {
                while (arr[idx]!='o') {
                    idx--;
                }
                i++;
            }
        }

        List<Integer> L = new ArrayList<>();
        List<Integer> R = new ArrayList<>();

        for (int i=0; i<k; i++) L.add(left[i]);
        for (int i=0; i<k; i++) R.add(right[i]);

        int cnt = 0;

        StringBuilder sb = new StringBuilder();

        for (int i=0; i<k; i++) {
            if (left[i]==right[i]) sb.append(left[i]+1+"\n");
        }

//        System.out.println(L);
//        System.out.println(R);
        System.out.println(sb.toString());

    }

}

Measured memory_bytes: 52552
#include <iostream>

int main() {
  int n;

  std::cin >> n;

  if ('A' <= n && n <= 'Z') {
    std::cout << 1 << std::endl;
  } else if ('a' <= n && n <= 'z') {
    std::cout << 2 << std::endl;
  } else {
    std::cout << 0 << std::endl;
  }

  return 0;
}



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

using namespace std;

typedef long long ll;

map<ll, ll> memo;

ll rec(ll x){
	if(memo.count(x) > 0) return memo[x];
	if(x == 1) return memo[x] = 1;
	return memo[x] = rec(x / 2) + rec(x / 2) + 1;
}

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

	ll h;
	cin >> h;

	cout << rec(h) << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    String n = sc.next();
    
    String n1 = n.substring(0,1);
    String n2 = n.substring(1,2);
    String n3 = n.substring(2,3);
    
    if( (n1.equals("7")) ||(n2.equals("7"))||(n3.equals("7"))){
      System.out.println("Yes");
      return;
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26996
#!python3

def LI():
    return list(map(int, input().split()))

# input
N, M, K = LI()

MOD = 10 ** 9 + 7
MAX = 10 ** 5 * 2
fac, finv, inv = [None] * MAX, [None] * MAX, [None] * MAX


def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = -inv[MOD%i] * int(MOD / i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


def s(x):
    return x * (x + 1) // 2


def cal(a, b):
    ret = a * s(b - 1) + b * s(a - 1)
    return ret % MOD


def main():
    comb_init()
    ans = 0
    for i in range(N):
        for j in range(M):
            v = cal(N - i, M - j) + cal(N - i, j + 1) - (s(j) + s(N - i - 1))
            ans = (ans + v) % MOD

    ans = ans * comb(N * M - 2, K - 2) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 26868
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

int N,M;
const int maxN=100100,maxM=2*100100;
int A[maxM],B[maxM];
vector<int> G[maxN];

int depth[maxN];
int pre[maxN];

void add_edge(int from,int to){
    G[from].push_back(to);
    G[to].push_back(from);
}

void bfs(int s){
    queue<int> q;
    fill(depth,depth+N,-1);
    fill(pre,pre+N,-1);
    q.push(s);
    depth[s]=0;
    while(!q.empty()){
        int u=q.front();q.pop();
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            if(depth[v]<0){
                depth[v] = depth[u]+1;
                pre[v]=u;
                q.push(v);
            }
        }
    }
}

void input(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int from,to;
        cin >> from >> to;
        add_edge(from-1,to-1);
    }
}

int main(){
    input();
    bfs(0);
    bool c=true;
    for(int i=1;i<N;i++){
        if(pre[i]<0) c=false;
    }
    if(!c) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        for(int i=1;i<N;i++){
            cout << pre[i]+1 << endl;
        }
    }

}




Measured memory_bytes: 10392
from collections import deque
H,W = map(int,input().split()); INF = float("inf")
G = []
for i in range(H):
  temp = str(input()); temp = list(temp)
  G.append(temp)

dp = [[INF]*W for _ in range(H)]
dp[0][0] = 0
if G[0][0] == "#":
  dp[0][0] += 1
for i in range(H):
  for j in range(W):
    #横への遷移
    if j+1 <= W-1: #一番右以外
      if G[i][j] == "." and G[i][j+1] == "#":
        dp[i][j+1] = min(dp[i][j+1],dp[i][j] + 1)
      else:
        dp[i][j+1] = min(dp[i][j+1],dp[i][j])
    #下への遷移
    if i+1 <= H-1: #一番右以外
      if G[i][j] == "." and G[i+1][j] == "#":
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1)
      else:
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
#print(dp)
ans = dp[-1][-1]
print(ans)

Measured memory_bytes: 74768
#include <bits/stdc++.h>
#define rp(i, n) for(int i = 0; i < n; i++)
#define rp2(i, a, n) for(int i = a; i < n; i++)

using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    int l = s.length();
    bool exist = true;
    rp(i, (l-1)/2){
        if(s[i] == s[(l-1)/2-i-1])
            continue;
        exist = false;
        break;
    }
    rp2(i,(l+1)/2, l){
        if (s[i] == s[l-i-1])
            continue;
        exist = false;
        break;
    }

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

    return 0;
}

Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n;
    cin >> n;

    int cnt = (n + 999) / 1000;

    cnt *= 1000;

    cout << cnt - n;
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans;
  string s;
  bool l,r,c;
  while(1){
    cin>>n;
    if(n==0) break;
    l=r=false;
    c=true;
    ans=0;
    for(int i=0;i<n;i++){
      cin>>s;
      if(s=="lu") l=true;
      else if(s=="ld") l=false;
      else if(s=="ru") r=true;
      else if(s=="rd") r=false;

      if(l && r && c){
	c=false;
	ans++;
      }
      if(!l && !r && !c){
	c=true;
	ans++;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>

void playit(char *y,int *t,int b,int i,int n){
  int a[n];
  int j;
  for(j=0;j<n;j++){
    a[j]=t[j];
  }

  if(i==100){
    for(j=0;j<n;j++){
      int k;
      for(k=j+1;k<n;k++){
	if(a[k]<a[j]){
	  int tmp=a[k];
	  a[k]=a[j];
	  a[j]=tmp;
	}
      }
    }
    for(j=0;j<n;j++){
      printf("%d ",a[j]);
    }
    printf("%d\n",b);
  }
  else{
    int bn;
    a[i%n]++;
    if(y[i]=='S'){
      bn=b+a[i%n];
      a[i%n]=0;
    }
    else if(y[i]=='L'){
      a[i%n]+=b;
      bn=0;
    }
    else if(y[i]=='M'){
      bn=b;
    }
    playit(y,a,bn,i+1,n);
  }
}

void bonze(int n){
  char yama[101];
  int te[n];
  int i;

  scanf("%s",yama);
  for(i=0;i<n;i++){
    te[i]=0;
  }
  playit(yama,te,0,0,n);
}

void doit(){
  int n;
  scanf("%d",&n);
  if(n!=0){
    bonze(n);
    doit();
  }
}

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

Measured memory_bytes: 620
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int h = scan.nextInt();

		int[] a = new int[h + 1];

		for (int i = 1; i <= h; i++)
			a[i] = scan.nextInt();

		for (int i = 1; i <= h; i++)
			print(a, i);

		scan.close();
		System.exit(0);
	}

	private static void print(int[] a, int i) {
		System.out.print("node " + i + ": ");
		System.out.print("key = " + a[i] + ", ");
		if (i > 1)
			System.out.print("parent key = " + a[i / 2] + ", ");
		if (i * 2 < a.length)
			System.out.print("left key = " + a[i * 2] + ", ");
		if (i * 2 + 1 < a.length)
			System.out.print("right key = " + a[i * 2 + 1] + ", ");
		System.out.print("\n");
	}
}

Measured memory_bytes: 27416
M, D = [int(x) for x in input().split()]
dates = list(range(22,D+1))
c = 0
 
for i in range(len(dates)):
  d1 = int(str(dates[i])[-1])
  d2 = int(str(dates[i])[-2])
  if d1*d2 <= M and d1 > 1 and d2 > 1:
    #print(d2,d1)
    c += 1
print(c)

Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

class SegTree:
    def __init__(self, N, ele):
        self.num = 2**(N-1).bit_length()
        self.el = ele
        self.data = [ele]*(2*self.num)

    def calc(self, x, y):
        return max(x, y)

    def update(self, idx, x):
        idx += (self.num - 1)
        self.data[idx] = x
        while idx > 0:
            idx = (idx-1)//2
            self.data[idx] = self.calc(self.data[2*idx+1], self.data[2*idx+2])

    def query(self, l, r):
        L = l + self.num
        R = r + self.num
        res = self.el
        while L < R:
            if L & 1:
                res  = self.calc(res, self.data[L-1])
                L += 1
            if R & 1:
                R -= 1
                res = self.calc(res, self.data[R-1])
            L >>= 1
            R >>= 1
        return res
    
    def get(self, idx):
        idx += (self.num - 1)
        return self.data[idx]

n, k = map(int, input().split())
A = [int(input()) for _ in range(n)]
seg = SegTree(330000, 0)
max_a = 300010
for a in A:
    l = max(0, a-k)
    r = min(max_a, a+k+1)
    now = seg.query(l, r)
    seg.update(a, now+1)

print(seg.query(0, max_a))


Measured memory_bytes: 92168
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int solve(int x,int y);
char room[30][30];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
int w,h;
int main(void){
  int ans;
  while(1){
    scanf("%d %d",&w,&h);
    if(w==0 && h==0) break;
    ans=0;
    for(int i=0;i<h;i++) scanf("%s",room[i]);
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(room[i][j]=='@') ans=solve(i,j);
      }
      if(ans)break;
    }
    printf("%d\n",ans);
  }
}

int solve(int x,int y){
  int res=1;
  room[x][y]='#';
  for(int i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(0<=nx && nx<h && 0<=ny && ny<w){
      if(room[nx][ny]=='.') res+=solve(nx,ny);
    }
  }
  return res;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int N;
  while (cin>>N, N) {
    vector<string> s(N);
    int num[] = {5, 7, 5, 7, 7};
    for (int i=0; i<N; i++) cin>>s[i];
    
    
    for (int i=0; i<N; i++) {
      bool ok=true;
      int idx=i;

      for (int j=0; j<5; j++) {
        int len = s[idx].size();
        ++idx;
        while (idx<N && len<num[j]) len+=s[idx++].size();

        if(idx > N) {
          ok = false;
          break;
        }
        
        if (len != num[j]) {
          ok=false;
        }
      }

      if (ok) {
        cout << i+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int n,m,x,y,a[200005],b[200005];
int main()
{
    cin>>n>>m;
    int k=0,f=0;
    for(int i=0;i<m;i++)
    {
            cin>>x>>y;
            if(x==1) {a[k]=y;k++;}
            if(y==n) {b[x]=1;}
    }
    for(int i=0;i<k;i++)
        if(b[a[i]]==1) f=1;
    if(f) printf("POSSIBLE");
    else printf("IMPOSSIBLE");
}


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


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;


#define MAX_N 100000
int par[MAX_N];
int myrank[MAX_N];

void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        myrank[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(myrank[x] < myrank[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if(myrank[x] == myrank[y])  myrank[x]++;
    }
}

//xとyが同じ集合に属するかどうか
bool same(int x, int y){
    return find(x) == find(y);
}


int main(){
    int n, m;   cin >> n >> m;
    init(n);

    for(int i = 0; i < m; i++){
        int x, y, z;    cin >> x >> y >> z;
        x--; y--;
        unite(x, y);
    }

    vector<bool> res(n, false);
    int count = 0;
    for(int i = 0; i < n; i++){
        int p = find(i);
        if(!res[p]){
            count++;
            res[p] = true;
        }
    }

    cout << count << endl;




    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X, N;
  IN(X,N);
  set<ll> p;
  REP(i,N){
    ll h;
    IN(h);
    p.emplace(h);
  }

  ll ans = X;
  ll diff = 0;
  while(true){
    ll tmp;
    tmp = ans-diff;
    if(p.find(tmp)==p.end()){
      OUT(tmp);
      return 0;
    }
    tmp = ans+diff;
    if(p.find(tmp)==p.end()){
      OUT(tmp);
      return 0;
    }
    diff++;
  }



  return 0;
}


Measured memory_bytes: 3648
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include <cassert>
using namespace std;
 
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end());
    int kijun;
    if(sum%(4*m) == 0) kijun = sum/(4*m);
    else kijun = sum/(4*m) + 1;
    if(a[n-m] < kijun) cout << "No" << endl;
    else cout << "Yes" << endl;
 }

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep (i, 3)
        ans += s[i] == t[i];
    print(ans);

    return 0;
}


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

int main()
{
	string S,T;
	cin >> S >> T;
	bool flag = true;
	rep(i,S.size())
	{
		if (S[i] != T[i]) flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3592
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() -> () {
    input!{
        h: usize,
        w: usize,
        aij: [[u8; w]; h],
    }

    let mut list = Vec::<(usize, usize)>::new();
    for y in 0..h {
        for x in 0..w {
            let x = if y % 2 == 0 { x } else { w - x - 1 };
            if aij[y][x] % 2 != 0 {
                list.push((y, x));
            }
        }
    }
    let mut moves = Vec::<(usize, usize, usize, usize)>::new();
    for l in list.as_slice().chunks(2) {
        if l.len() != 2 {
            break;
        }
        let mut p1 = l[0];
        let p2 = l[1];
        while p1 != p2 {
            let t = next(p1.1, p1.0, w);
            moves.push((p1.0, p1.1, t.0, t.1));
            p1 = t;
        }
    }

    println!("{}", moves.len());
    for m in moves.iter() {
        println!("{} {} {} {}", m.0 + 1, m.1 + 1, m.2 + 1, m.3 + 1);
    }
}

fn next(mut x: usize, mut y: usize, w: usize)-> (usize, usize) {
    if y % 2 == 0 {
        if x == w - 1 {
            y += 1;
        } else {
        x += 1;
        }
    } else {
        if x == 0 {
            y += 1;
        } else {
            x -= 1;
        }
    }
    (y, x)
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int a = sc.NextInt();

        int answer = n * n - a;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
s=input()
k=int(input())
st=[[] for i in range(26)]
n=len(s)
for i in range(n):
    st[ord(s[i])-97].append(i)

pre=0
now=set()
for i in st:
    for v in i:
        for c in range(v+1,min(n+1,v+6)):
            now.add(s[v:c])
    if len(now)+pre<k:pre+=len(now);now=set()
    else:
        print(sorted(list(now))[k-pre-1]);exit()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i%2==1){
			ans++;
		}
	}
	cout<<fixed<<setprecision(10)<<ans*1.0/n<<endl;
	return 0;
}

Measured memory_bytes: 256
r = 3
c = 4

a1 = 0
a2 = 0
b1 = 1
b2 = 2

r,c,a1,a2,b1,b2 = gets.split(" ").map(&:to_i)

DIV = 100000007

def fact(n)
	if n == 0
		1
	else
		(1..n).inject(:*)
	end
end

def f(x,y)
	fact(x+y)/fact(x)/fact(y)
end

xls = [(b1-a1).abs , (b1>a1)? a1+r-b1 : r-a1+b1]
yls = [(b2-a2).abs , (b2>a2)? a2+c-b2 : c-a2+b2]

as = xls.map {|lx|
	yls.map {|ly|
		[lx,ly]
	}
}.flatten(1).map {|x,y| [x+y,f(x,y)%DIV]}

h=Hash.new(0)
as.each {|x,y|
	h[x]=(h[x]+y)%DIV
}
p (a1==b1 and a2==b2)? 1 : h[as.map{|a,b|a}.min]

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...)
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



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

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

	int n;
	cin >> n;
	vector<int> b(n-1);
	for (auto &i : b) cin >> i;

	ll ans = b[0];
	//cout << b[0];
	for (int i = 1; i < n-1; ++i)
		ans += min(b[i-1], b[i]);
		//cout << " " << min(b[i-1], b[i]);
	ans += b.back();
	//cout << " " << b.back() << "\n";

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
   int n;
   cin>>n;
   for (int i = 1; i <= 9; i++)
   {
       if(n%i==0){
           if(1<=n/i && n/i<=9) {
           
               cout<<"Yes"<<endl;
            return 0;
           }
       }
   }
   cout<<"No"<<endl;
   
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main()
{
	int n;
	ll x,ans=1;
	for(scanf("%d",&n);n--;)
		scanf("%lld",&x),ans=ans/gcd(ans,x)*x;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define lk 32

typedef struct{
  int lp;
  int par;
  int bkw;
  int chi[lk];
}trn;

int trc=0;
trn trie[524288];

void trinit(){
  int i;
  trie[0].lp=0;
  trie[0].par=-1;
  trie[0].bkw=-1;
  for(i=0;i<lk;i++){
    trie[0].chi[i]=-1;
  }
  trc=1;
}

void crn(int x,int pt){
  int i;
  trie[x].chi[pt]=trc;
  trie[trc].par=x;
  trie[trc].bkw=pt;
  trie[trc].lp=trie[x].lp+1;
  for(i=0;i<lk;i++){
    trie[trc].chi[i]=-1;
  }
  trc++;
}

int run(char s[]){
  int i,l=strlen(s),v=0,c;
  for(i=0;i<=l;i++){
    if(i!=l){c=s[i]-'`';}
    else{c=0;}
    if(trie[v].chi[c]==-1){
      crn(v,c);
    }
    v=trie[v].chi[c];
  }
  return v;
}

void tricomp(){
  int i,j,c,tac;
  for(i=0;i<trc;i++){
    if(trie[i].par==-1){continue;}
    c=0;
    for(j=0;j<lk;j++){
      if(trie[i].chi[j]!=-1){tac=trie[i].chi[j];c++;}
    }
    if(c==1){
      trie[trie[i].par].chi[trie[i].bkw]=tac;
      trie[tac].par=trie[i].par;
      trie[tac].bkw=trie[i].bkw;
    }
  }
}

int main(){
  trinit();
  int n,i,j,w[524288]={0},id[524288]={0},q,k,res,v,vp,f;
  char s[524288],p[32];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%s",s);
    id[i]=run(s);
    w[id[i]]++;
  }
  tricomp();
  for(i=trc-1;i>=0;i--){
    if(trie[i].par==-1){continue;}
    w[trie[i].par]+=w[i];
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d%s",&k,p);
    res=0;
    v=id[k];
    while(trie[v].par!=-1){
      vp=trie[v].par;
      f=0;
      if(trie[v].bkw==0){f=1;}
      for(j=0;j<26;j++){
        if(f==1 && trie[vp].chi[p[j]-'`']!=-1){
          res+=w[trie[vp].chi[p[j]-'`']];
        }
        if(trie[v].bkw==p[j]-'`'){f=1;}
      }
      v=vp;
    }
    printf("%d\n",n-res);
  }
}

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

int main(){
	int D,N,hoge = 1;
	cin >> D >> N;
	while(D > 0){
		hoge *= 100;
		D --;
	}
	if (N != 100){
		cout << hoge*N <<endl;
	}else{
		cout << hoge*N + hoge<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main (String[] args){
        solve1600();
    }

    public static void solve1600() {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int m = sc.nextInt();
            int n_min = sc.nextInt();
            int n_max = sc.nextInt();
            if(m == 0 && n_min == 0 && n_max == 0){
                break;
            }
            int[] P = new int[m];
            int[] gap = new int[m-1];
            for (int i = 0; i < m; i++){
                if(i == 0) {
                    P[i] = sc.nextInt();
                } else {
                    P[i] = sc.nextInt();
                    gap[i-1] = P[i-1] - P[i];
                }
            }
            int gap_max = 0;
            int ans = 0;
            for (int j = n_min - 1; j < n_max; j++) {
                if(gap_max <= gap[j]){
                    gap_max = gap[j];
                    ans = j;
                }
            }
            System.out.println(ans + 1);
        }
    }
}

Measured memory_bytes: 58704
#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define pb push_back
#define si second
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  mod 100000000000
#define double long double
#define all(o) o.begin(),o.end()
using namespace std;

int power(int x, int y)
{
    int res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1; // y = y/2
        x = (x*x) % mod;
    }
    return res%mod;
}
int inv(int n)
{
    return power(n,mod-2)%mod;
}



int32_t main() {

  //  fast
    int d,l,r;
    cin>>l>>r>>d;
    cout<<r/d-(l-1)/d<<"\n";

}


Measured memory_bytes: 3632
/**
 *    author:  math2do
 *    created: 04.09.2020 13:08:32
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector <double> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  } 
  vector <double> dp(n + 1);
  dp[0] = 1;
  for (int c = 0; c < n; c++) {
    double h = p[c];
    for (int i = c + 1; i >= 0; i--) {
      dp[i] = (i == 0 ? 0 : dp[i - 1] * h) + dp[i] * (1 - h);
    } 
  } 
  double ans = 0.0;
  for (int h = 0; h <= n; h++) {
    int t = n - h;
    if (h > t) {
      ans += dp[h];
    } 
  } 
  cout << fixed << setprecision(17) << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 1e5 + 10;

typedef pair<int, int> pi;

int n, a[N], b[N], num[N];
vector<pi> p;
ll ans, cur;

int main() {
  scanf("%d", &n);
  ll suma = 0, sumb = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    p.push_back(pi(a[i], i));
    p.push_back(pi(b[i], i));
    suma += a[i];
    sumb += b[i];
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < n; i++) {
    cur += p[i].first;
    num[p[i].second]++;
  }
  for (int i = 1; i <= n; i++) if (num[i] == 2) {
    cout << cur << endl;
    return 0;
  }
  ans = min(suma, sumb);
  for (int i = 0; i < n; i++) {
    if (i != n - 1) {
      ans = min(ans, cur - p[i].first + a[p[i].second] + b[p[i].second] - p[n - 1].first);
    } else {
      ans = min(ans, cur - p[i].first + a[p[i].second] + b[p[i].second] - p[n - 2].first);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3056
#include<stdio.h>

int main(void)
{
	int i,n,s,a,b,ans=0;
	scanf("%d%d%d",&n,&a,&b);
	for(i=1;i<=n;i++){
		s=i/10000+i/1000%10+i/100%10+i/10%10+i%10;
		if(s>=a && s<=b)
			ans+=i;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
# Keyence B

N = int(input())
robot_list = []
robot_count = 0

for _ in range(N):
    x, l = map(int, input().split())
    robot_list.append([x + l, x - l])

robot_list.sort()
r = - 10**9 - 1

for i in range(N):
    if r <= robot_list[i][1]:
        robot_count += 1
        r = robot_list[i][0]

print(robot_count)

Measured memory_bytes: 20104
#include<bits/stdc++.h>
using namespace std;
int s,k,ans;
int main(){
	cin>>k>>s;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if(s-i-j>=0&&s-i-j<=k){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  double a, b;
  cin >> a >> b;
  printf("%.15f\n", a * b / (a + b));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> A(a);
    vector<int> B(b);
    rep (i, a) cin >> A[i];
    rep (i, b) cin >> B[i];

    int ans = inf;
    for (int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        int p;
        p = A[x-1] + B[y-1] - c;

        ans = min(ans, p);
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    ans = min(ans, A[0] + B[0]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3996
require 'matrix'

$<.gets.to_i.times do
  given = $<.gets.split.map(&:to_r).each_slice(2).map {|x, y| Vector[x, y]}
  p1, p2, p3, k, s = given
  calc = ->(r) { Matrix.columns([p2 - p1, p3 - p1]).lup.solve(r - p1).to_a }
  s1, t1 = calc.(k)
  s2, t2 = calc.(s)
  f1 = s1 + t1 < 1 && s1 > 0 && t1 > 0
  f2 = s2 + t2 < 1 && s2 > 0 && t2 > 0
  puts f1 ^ f2 ? "OK" : "NG"
end


Measured memory_bytes: 7224
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    int n,k,s;
    cin>>n>>k>>s;
    for(int i  = 0 ; i < k;i++){
        cout<<s<<" ";
    }
    if(s==1000000000){
        s=2;
    }

    for(int i = 0 ; i < (n-k);i++){
        cout<<1000000000-s<<" ";
    }
 

 
    
 
    return 0;
}


Measured memory_bytes: 1280
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
#print(b)
 
for i in range(n-1):
    #print(a[i])
    b[a[i]-1] += 1
    #print(b)
 
for j in range(n):
    print(b[j])
  

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int N;
    cin>>N;
    for(int i=0;i<s.size();i++){
        if(s[i]=='a')continue;
        if('z'+1-s[i]<=N)N-='z'+1-s[i],s[i]='a';
    }
    N%=26;
    s.back()+=N;
    s.back()='a'+(s.back()-'a')%26;
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  cin >> A >> B >> C >>K;
  int x[] = {A,B,C};
  sort(x,x+3);
  cout << x[0] + x[1] + x[2]*pow(2,K)<< endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    ll ans=1;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3560
N, K, Q = map(int, input().split())
dic = {i: 0 for i in range(1, N+1)}
for i in range(Q):
  S = int(input())
  dic[S] += 1
for j in dic.keys():
  if K - Q + dic[j] > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 15084