akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=1e9+7;
vector<pair<LL,LL> > f[200010],v[200010];
int n,dep[500010],son[500010],cnt[500010],len[500010],fa[500010],too[500010],nxt[500010],nedge,hed[500010];
LL p2[500010],ans,p[500010];
pair<LL,LL> F[500010];
void ae(int x,int y){
	nxt[++nedge]=hed[x];
	hed[x]=nedge;
	too[nedge]=y;
}
void mkt(int x){
	if (x) dep[x]=dep[fa[x]]+1;
	++cnt[dep[x]];
//	L[x]=++dfn;
//	w[dfn]=x;
	for (int i=hed[x];i;i=nxt[i]){
		int y=too[i];
		mkt(y);
		if (len[y]+1>len[x]){
			len[x]=len[y]+1;
			son[x]=y;
		}
	}
//	R[x]=dfn;
}
void dfs(int x){
	for (int i=hed[x];i;i=nxt[i]){
		int y=too[i];
		if (y==son[x]) continue;
		dfs(y);
	}
	if (son[x]){
		dfs(son[x]);
		F[dep[x]]=mp(1ll,1ll);
		int d=0;
		for (int i=hed[x];i;i=nxt[i]){
			int y=too[i];
			if (y==son[x]) continue;
			FOR(j,0,len[y]) v[j+dep[y]].pb(f[y][j]),d=max(d,j+dep[y]);
		}
		FOR(i,dep[x]+1,d) if (SZ(v[i])){
			LL tot=(F[i].fi+F[i].se)%MO;
			LL q=F[i].se;
			FOR(j,0,SZ(v[i])-1){
				tot=tot*(v[i][j].fi+v[i][j].se)%MO;
				if (j==0) p[j]=v[i][j].se; else p[j]=p[j-1]*v[i][j].se%MO;
			}
			F[i].fi=F[i].fi*p[SZ(v[i])-1]%MO;
			FORD(j,SZ(v[i])-1,0){
				(F[i].fi+=q*v[i][j].fi%MO*(j>0?p[j-1]:1ll))%=MO;
				q=q*v[i][j].se%MO;
			}
			F[i].se=(tot-F[i].fi)%MO;
			v[i].clear();
		}
		
	}
	else{
		F[dep[x]]=mp(1ll,1ll);
	}
	if (x!=0 && x!=son[fa[x]]){
		FOR(j,0,len[x]) f[x].pb(F[dep[x]+j]),F[dep[x]+j]=mp(0ll,0ll);
	}
}
int main(){
	p2[0]=1;
	FOR(i,1,500000) p2[i]=p2[i-1]*2%MO;
	scanf("%d",&n);
	FOR(i,1,n) getint(fa[i]),ae(fa[i],i);
	mkt(0);
	dfs(0);
	FOR(i,0,len[0]) (ans+=F[i].fi*p2[n+1-cnt[i]])%=MO;
	ans=(ans%MO+MO)%MO;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 51412
S=input()
K=int(input())

L=len(S)

D=[0]*(2*L)

D[0]=1
n=0
for i in range(1,2*L):
    if S[(i-1)%L]==S[i%L]:
        D[i]=D[i-1]+1
        n+=1
    else:
        D[i]=1

X=[]
if D[L-1]==L:
        print((L*K)//2)
else:
    if S[0]==S[-1]:
        f,g=True,False

        i=0
        while f:
            g=g or (S[i]!=S[i+1])
            
            if D[i]>=D[i+1]:
                if g:
                    X.append(D[i])
                    if i>=L-1:
                        f=False
                        
            i+=1

        A=sum(map(lambda n:n//2,X[1:]))*(K-1)+sum(map(lambda n:n//2,X[1:-1]))+(X[0]//2)+(D[L-1]//2)
    
    else:
        for i in range(L):
            if D[i]>D[i+1]:
                X.append(D[i])


        A=sum(map(lambda n:n//2,X))*K

    print(A)


Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut info = vec![vec![]; n];
    for i in 0..n {
        let cnt = read::<usize>();
        for _j in 0..cnt {
            let to = read::<usize>() - 1;
            let v = read::<usize>();
            info[i].push((to, v));
        }
    }
    let mut ans = 0;
    'outer_loop: for iter in 0..(1 << n) {
        for from in 0..n {
            if ((iter >> from) & 1) == 0 {
                continue;
            }
            for &(to, v) in info[from].iter() {
                if ((iter >> to) & 1) != v {
                    continue 'outer_loop;
                }
            }
        }
        ans = std::cmp::max(ans, iter.count_ones() as usize);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int N = 100000 + 5;
int main(){
	int a,b=2;
	scanf("%d", &a);
	if( a < 1 ) { printf("0"); return 0;}
	while( b <= a ) b *= 2;
	printf("%d", b/2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	bool a=s==t;
	for (int i=1;i<s.size()&&!a;i++)
		a=s.substr(i)+s.substr(0,i)==t;
	cout<<(a ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int a,b;
    cin>>a>>b;
    int ans=-1;
    if(a%2){
        if(!(25*(a+1)/2<=10*b||10*(b+1)<=(25*a+2)/2)){
            rep2(i,10*b,10*(b+1)){
                if((25*a+2)/2<=i&&i<25*(a+1)/2){
                    ans=i;
                    goto OUT;
                }
            }
        }
    }
    else{
        if(!(25*(a+1)/2+1<=10*b||10*(b+1)<=25*a/2)){
            rep2(i,10*b,10*(b+1)){
                if(25*a/2<=i&&i<25*(a+1)/2+1){
                    ans=i;
                    goto OUT;
                }
            }
        }
    }
    OUT:
    cout<<ans<<endl;
}

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


int main() {
int n;
cin>>n;
bool cond = false;
for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
        if(i*j == n){
            cond = true;
            break;
        }
    }
}

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

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache

class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def map_int():
        return [int(x) for x in Scanner.string().split()]
    def string_list(n):
        return [input() for i in range(n)]
    def int_list_list(n):
        return [Scanner.mapInt() for i in range(n)]
    def int_cols_list(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N = Scanner.int()
    A = Scanner.map_int()
    if N == 1:
        print(A[0])
        return
    B = [0] * N
    i = 0
    j = N - 1 - N % 2
    for i in range(N // 2):
        B[i] = A[j]
        j -= 2
    i += 1
    B[i] = A[0]
    j = 2
    for i in range(i + 1,N):
        B[i] = A[j]
        j += 2
    if N % 2 == 1:
        B.reverse()
    print(*B)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 89680
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int[] nums = new int[100001]; 
		long sum = 0;
		for(int i = 0; i < length; i++) {
			int temporal = scanner.nextInt();
			nums[temporal]++;
			sum += temporal;
		}
		int q = scanner.nextInt();
		for(int i = 0; i < q; i++) {
			int replace = scanner.nextInt();
			int newNum = scanner.nextInt();
			nums[newNum] += nums[replace];
			sum += nums[replace] * (newNum - replace);
			nums[replace] = 0;
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 57456
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static List<long> table;
    static List<string> table753;
    static int point;
    static void Main(string[] args)
    {
        table = new List<long>();
        table753 = new List<string>();
        //入力を受け取る
        long N = int.Parse(Console.ReadLine());
        Semi753("");
        Regist357();
        Console.WriteLine(table.Count(value => value  <= N));

    }
    static void Semi753(string str)
    {
        if (str.Length < 9)
        {
            table753.Add(str+"3");
            Semi753(str + "3");
            table753.Add(str + "5");
            Semi753(str + "5");
            table753.Add(str + "7");
            Semi753(str + "7");
        }
    }

    static void Regist357()
    {
        foreach (string num in table753)
        {
            if (num.Contains("3") && num.Contains("5") && num.Contains("7"))
            {
                table.Add(long.Parse(num));
            }
        }
    }

}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, l;
  cin >> n >> l;
  
  int min = 1e5;
  int eat = 1e5;
  
  for (int i = 1; i <= n; i++) {
    if (abs(l + i -1) < min) {
      eat = i;
      min = abs(l+i-1);
    }
  }

  cout << ( (n-1)*(l-1) +(n*(n+1))/2 - eat) << "\n";

}


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

int main(){
	int x,n,p[1000],sw=0,ans,pp[110]={};
  cin >> x >> n;
  ans = x;
  for(int i=0; i<n; i++){
  	cin >> p[i];
    pp[p[i]]=1;
    if(ans == p[i]) sw++;
  }
  if(x==0) {
    cout << -1;
    return 0;
  }
  if(sw==0) {
    cout << x;
    return 0;
  }
  
  for(int i=0; i<110; i++){
  	if(x-i >= 0 && pp[x-i] == 0){
    	ans = x-i;
      //cout << x-i << " " << pp[x-i] << "\n";
      break;
    }
    if(pp[x+i] == 0){
    	ans = x+i;
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<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 (b<a) {a=b; return 1;} return 0;}

vector<vector<int>> to, ot;
const long long INF = 1LL<<60;
int v, e;
vector<tuple<int, int, long long>> es;
vector<long long> d;
vb seen, seen_1, seen_n;

void dfs(int v) {
    seen_1[v] = true;
    for (auto u : to[v]) {
        if (seen_1[u]) continue;
        dfs(u);
    }
}

void rdfs(int v) {
    seen_n[v] = true;
    for (auto u : ot[v]) {
        if (seen_n[u]) continue;
        rdfs(u);
    }
}

bool bellmanford(int s) {
    d = vector<long long>(v, INF);
    d[s] = 0;
    for (int t = 0; t < v; ++t){
        bool update = false;
        for (int i = 0; i < e; ++i) {
            int from, to;
            long long cost;
            tie(from, to, cost) = es[i];
            if (!seen[from] || !seen[to]) continue;
            if (d[from] != INF && d[to] > d[from] + cost) {
                update = true;
                d[to] = d[from] + cost;
            }
        }
        if (!update) break;
        if (t == v-1) return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll p;
    cin >> v >> e >> p;
    to.resize(v);
    ot.resize(v);
    rep(i, e) {
        int a, b; ll c;
        cin >> a >> b >> c;
        a--; b--;
        c -= p;
        c = -c;
        to[a].pb(b);
        ot[b].pb(a);
        es.eb(a, b, c);
    }
    seen = seen_1 = seen_n = vb(v, false);
    dfs(0);
    rdfs(v-1);
    rep(i, v) seen[i] = seen_1[i] && seen_n[i];
    bool ans = bellmanford(0);
    cout << (ans ? -1 : max(-d[v-1], 0LL)) << endl;
}

Measured memory_bytes: 768
import math
from decimal import *

def cnt_prime(p, n):
    div = Decimal(str(n))
    s = 0

    while True:
        div /= p
        if div < 1:
            break
        if p == 2:
            s += int(div.quantize(Decimal('0.0'), rounding=ROUND_FLOOR))
        else:
            s += int(div.quantize(Decimal('0.0'), rounding=ROUND_FLOOR)) // 2
    return s

N = int(input())


if N % 2 == 1:
    print(0)
else:
    print(min(cnt_prime(2, N), cnt_prime(5, N)))

Measured memory_bytes: 10084
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	cin >> N;
	int A, B;
	cin >> A >> B;
	int x = 0, y = 0, z = 0;
	for (int i = 0; i < N; i++) {
		int P;
		cin >> P;
		if (P <= A) x++;
		else if (P <= B) y++;
		else z++;
	}
	cout << min(x, min(y, z)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  int f=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        f=1;
      }
    }
  }
  if(f==1){
    cout<<"DENIED"<<endl;
  }
  else{
    cout<<"APPROVED"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M_PI  3.1415926535
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
// -----------------------------------------------CKMKB-----------------------------------------------------------
// -----------------------------------------------PKMKB-----------------------------------------------------------
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
      ll l,r,d;
      cin>>l>>r>>d;
      if( r<d ) cout<<0;
      else {
        ll ans = 0 ;
        if( l%d==0 ) ans++;
        if( r%d==0 ) {
            ans++;
            ans += ( r/d - l/d - 1 );
            cout<<ans;
        }
        else{
            ans += ( r/d - l/d );
            cout<<ans;
        }

      }
  }
  return 0;

}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){ T x; cin >> x; return (x); }
template<typename T=int,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if(n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

ll powermod(ll a,ll b,ll m){
	if(b==0){
		return 1LL;
	}
	if(b%2){
		return (a*powermod(a,b-1LL,m))%m;
	}
	return powermod((a*a)%m,b/2LL,m);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),A=in(),B=in();
	Combination comb(B);
	vector<ll> dp(B+1);
	dp[0]=1;
	REP(i,B){
		dp[i+1] = ((dp[i]*(N-i))%atcoder_mod);
		dp[i+1] %= atcoder_mod;
	}

	int L=(dp[A]*comb.GetFInv(A))%atcoder_mod+(dp[B]*comb.GetFInv(B))%atcoder_mod;
	L%=atcoder_mod;
	out((powermod(2,N,atcoder_mod)-1-L+atcoder_mod)%atcoder_mod);
	return 0;
}


Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int n = sc.nextInt();
	  long res = 0;
	  
	  for (int i = 0; i < n; i++) {
		  int num = sc.nextInt();
		  res += (num - 1);
	  }
	  
	  System.out.println(res);
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using lli = long long int;
lli in_minus(lli k, vector<lli> minus, vector<lli> plus){
  rep(i, minus.size()) minus[i] = -minus[i];
  lli up = 1e18;
  lli low = 0;
  k = minus.size() * plus.size() - k;
  sort(minus.begin(), minus.end());
  sort(plus.begin(), plus.end());
  while(up-low>1){
    lli mid ((up+low)>>1);
    lli tmp = 0;
    rep(i, minus.size())
      tmp += lower_bound(plus.begin(), plus.end(), (mid+minus[i]-1)/minus[i]) - plus.begin();
    if(tmp <=k){
      low = mid;
    }else {
      up = mid;
    }
    //cout << up << " " << low << endl;
  }
  return -low;
}
lli in_plus(lli k, vector<lli> minus, vector<lli> plus){
  k--;
  rep(i, minus.size()) minus[i] = -minus[i];
  lli up = 1e18;
  lli low = 0;
  sort(minus.begin(), minus.end());
  sort(plus.begin(), plus.end());
  while(up-low>1){
    lli mid ((up+low)>>1);
    lli tmp = 0;
    rep(i, (int)plus.size()-1)
    {
      auto beg = plus.begin() + i + 1;
      tmp += lower_bound(beg, plus.end(), (mid+plus[i]-1)/plus[i]) - beg;
    }
    rep(i, (int)minus.size()-1)
    {
      auto beg = minus.begin() + i + 1;
      tmp += lower_bound(beg, minus.end(), (mid+minus[i]-1)/minus[i]) - beg;
    }
    if(tmp <=k){
      low = mid;
    }else {
      up = mid;
    }
   // cout << up << " " << low << endl;
  }
  return low;
}
int main()
{
  lli n, k;
  cin >> n >> k;
  vector<lli> a(n);
  vector<lli> plus, zero, minus;
  rep(i, n) {
    cin >> a[i];
    if(a[i]==0)zero.push_back(a[i]);
    else if(a[i]>0)plus.push_back(a[i]);
    else minus.push_back(a[i]);
  }
  lli num_minus= plus.size() * minus.size();
  if(num_minus>=k){
    cout << in_minus(k, minus, plus);
    return 0;
  }
  k -= num_minus;
  lli num_zero = zero.size() * (zero.size()-1)/2 + zero.size() * (n - zero.size());
  if(num_zero>=k){
    cout << 0 << endl;
    return 0;
  }
  //cout << num_minus << " " << num_zero << endl;
  k -= num_zero;
  cout << in_plus(k, minus, plus) << endl;
  return 0;
}


Measured memory_bytes: 4972
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  ll N, x; cin >> N >> x;
  vector<ll> A(N+1, 0);
  rep(i, 1, N+1) cin >> A[i];
  ll ans = 0;

  rep(i, 1, N+1)
  {
     if(A[i]+A[i-1]>x)
     {
         ans  += ((A[i]+A[i-1])-x);
         A[i] -= ((A[i]+A[i-1])-x);
     }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
// abc138_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B;
    cin >> A >> B;

    int ans = 0;
    REP(i, 1000){
        if ((A-1) * (i-1) + A >= B){
            ans = i;
            break;
        }
    }
    print(ans);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
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;
}

struct City {
    int city, year, id, in;
};

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

    int N, M;
    cin >> N >> M;
    vector<City> atc(M);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        atc[i].city = a;
        atc[i].year = b;
        atc[i].in   = i;
    }
    sort(ALL(atc), [&](const City x, const City y) {
        if (x.city == y.city) {
            return x.year < y.year;
        }
        return x.city < y.city;
    });
    int cnt   = 1;
    atc[0].id = 1;
    FOR(i, 1, M) {
        if (atc[i - 1].city == atc[i].city) {
            cnt++;
            atc[i].id = cnt;
        } else {
            cnt       = 1;
            atc[i].id = cnt;
        }
    }

    sort(ALL(atc), [&](const City x, const City y) { return x.in < y.in; });

    REP(i, M) {
        std::cout << setfill('0') << setw(6) << atc[i].city;
        std::cout << setfill('0') << setw(6) << atc[i].id << '\n';
    }

    return 0;
}

Measured memory_bytes: 3072
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;

long long inv(int a, int p) { return a==1 ? 1 : (1-p*inv(p%a,a))/a+p; }
static const int MODVAL = 1000000007;
struct mint {
  int val;
  mint():val(0){}
  mint(int x):val(x%MODVAL) { if(val<0) val+= MODVAL; }
  mint(size_t x):val(x%MODVAL) {}
  mint(long long x):val(x%MODVAL) { if(val<0) val+= MODVAL; }
  mint& operator+=(mint y) { val+=y.val; if(val>=MODVAL) val-=MODVAL; return *this; }
  mint& operator-=(mint y) { val-=y.val; if(val<0) val+= MODVAL; return *this; }
  mint& operator*=(mint y) { val=(val*(long long)y.val)%MODVAL; return *this; }
  mint& operator/=(mint y) { val=(val*inv(y.val,MODVAL))%MODVAL; return *this; }
};
inline mint operator+(mint x, mint y) { return x+=y; }
inline mint operator-(mint x, mint y) { return x-=y; }
inline mint operator*(mint x, mint y) { return x*=y; }
inline mint operator/(mint x, mint y) { return x/=y; }
mint POW(mint x, long long n) { mint r(1); for(;n;x*=x,n>>=1) if(n&1) r*=x; return r; }
mint FAC(int n) { static vector<mint> FAC_(1,1);
  while(int(FAC_.size())<=n) FAC_.push_back(FAC_.back()*FAC_.size()); return FAC_[n]; }
inline mint CMB(int n, int k) { return k<0||n<k ? 0 : FAC(n) / (FAC(k) * FAC(n-k)); }
inline ostream& operator<<(ostream& os, mint a) { return os << a.val; }

int n;
vector<int> g[200000+10];
mint ans;

int go(int p, int u) {
  vector<int> cs;
  int sum = 0;
  for(int v : g[u]) {
    if(v == p) {
      continue;
    }
    int cur = go(u, v);
    cs.push_back(cur);
    sum += cur;
  }
  if(p != -1) {
    cs.push_back(n - sum - 1);
  }
  if(cs.size() > 1u) {
    mint allWhite = 1;
    mint oneBlack = 0;
    REP(i, cs.size()) {
      oneBlack += POW(2, cs[i]) - 1;
    }
    ans += POW(2, n-1) - (allWhite + oneBlack);
  }
  return sum + 1;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n-1) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  ans = 0;
  go(-1, 0);
  ans /= POW(2, n);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 24704
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N,L;
    cin >> N >> L;
    vector<string> v(N);
    for(int i=0;i<N;i++){
        cin >> v.at(i);
    }

    sort(v.begin(),v.end());

    string ans;
    for(int i=0;i<N;i++){
        ans += v.at(i);
    }
    cout << ans << endl;
    
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int ans = a+b+c-max({a,b,c});
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3596
#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 long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    ll n = nxt(), w = nxt();

    vector <ll> dp(n*1000 + 1, (ll)1e18);
    dp[0] = 0;

    for(ll i=0; i<n; i++)
    {
        ll weight = nxt(), value = nxt();

        for(ll j=n*1000-value; j>=0; j--)
        {
            dp[j+value] = min(dp[j+value], dp[j] + weight);
        }
    }

    ll ans = 0;

    for(ll i=0; i<=n*1000; i++)
    {
        if(dp[i] <= w)
        {
            ans = max(ans, i);
        }
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long

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

	int A,B,C;
	cin>>A>>B>>C;
	if(A<=C&&C<=B){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, cnt = 0;
  double M;
  cin >> N >> M;
  double arr[N], sum = 0;
  for (int i = 0; i < N; i++){
    cin >> arr[i];
    sum += arr[i];
  }
  for (int i = 0; i < N; i++)
    if (arr[i] >= sum / (4 * M))
      cnt++;
  cout << ((cnt >= M)? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3748
#include<stdio.h>
int main()
{
  int n,m;
  scanf("%d %d",&n,&m);
  if(n>=10)
  {
    printf("%d",m);
  }
  else
  {
      m = m + 100*(10-n);
      printf("%d",m);
  }
  return 0;
}


Measured memory_bytes: 1716
#include<iostream>
 
using namespace std;
int main()
{
	int n,k;
	long long ans=2e15,x[100010];
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> x[i];
	}
	for(int i=0; i+k-1<n; i++){
		int l = i, r = i+k-1;
		ans = min(ans, x[r]-x[l] + min(abs(x[r]), abs(x[l])));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n, k, a[210000];
int bit[210000];
int bsum(int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= (i & -i);
  }
  return s;
}
void badd(int i, int x){
  while(i <= n){
    bit[i] += x;
    i += (i & -i);
  }
}

signed main(){
  cin>>n>>k;rep(i,n)cin>>a[i+1],a[i+1]-=k,a[i+1] += a[i];
  vector<int> b(n+1);
  rep(i,n+1)b[i] = a[i];
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  int ans = 0;
  n++;
  rep(i,n){
    a[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin() + 1;    
  }
  rep(i,n){
    ans += bsum(a[i]);
    badd(a[i], 1);
  }
  cout << ans << endl;
}


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

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	long double a[n];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}	
	long double dp[2][n + 1];
	memset(dp, 0, sizeof dp);
	dp[1][0] = 1;
	for(int i = 0; i < n; ++i) {
		long double p = a[i];
		long double q = (long double)1 - p;
		int curr = i & 1;
		for(int j = 0; j <= n; ++j) {
			dp[curr][j] = dp[curr ^ 1][j] * q;
			if(j - 1 >= 0) {
				dp[curr][j] = dp[curr][j] + dp[curr ^ 1][j - 1] * p; 
			}
		}
	}
	long double ans = 0;
	for(int i = n/2 + 1; i <= n; ++i) {
		ans += dp[0][i];
	}
	cout<<fixed<<setprecision(20)<<ans;
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

bool prime(int n){
    for (int i = 2; i*i <= n; ++i) {
        if(n%i == 0) return false;
    }
    return n != 1;
}

int main() {
    int n;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    string s = {};
    while(n != 0){
        if(n % -2 == 0) s += "0";
        else{
            n--;
            s += "1";
        }
        n /= -2;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#define mod 998244853 
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int l, n, x;
	cin >> n >> x;
	int d = 0;
	for(int i = 2; i <= n+1; i++)
	{
	    cin >> l;
	    d+=l;
	    if(d > x)
	    {
	        cout << i-1 << '\n';
	        return 0;
	    }
	}
	cout << n+1 << '\n';
}


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

int h[100001];
vector<int> graph[100001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    FOR(i, 1, n + 1) cin >> h[i];
    while (m--) {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    int ans = 0;
    FOR(i, 1, n + 1) {
        bool good = true;
        for (int j : graph[i]) good &= (h[i] > h[j]);
        ans += good;
    }
    cout << ans;
    return 0;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n, m;
  cin >> n >> m;
  int total_price = 0;
  vector<int> price(n);
  REP(i,n) {
    cin >> price[i];
    total_price += price[i];
  }
  while(m>0) {
    SORTR(price);
    int i = 0;
    int max_n = price[0] / 2;
    while(max_n <= price[i]) {
      total_price -= ceil(price[i]/2.0);
      price[i] /= 2;
      max_n = max(max_n, price[i]);
      --m;
      ++i;
      if(i >= n || m <= 0) break;
    }
  } 
  cout << total_price;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

template<typename T>
void init(vector<T> &v){
    int h = v.size();
    int w = v[0].size();
    for(int i = 0; i < h; i++){
        for(int j = 1; j < w; j++){
            v[i][j] += v[i][j-1];
        }
    }
    for(int j = 0; j < w; j++){
       for(int i = 1; i < h; i++){
           v[i][j] += v[i-1][j];
       } 
    }
}

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> v(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c; cin >> c;
            v[i][j] = c-'0';
        }
    }
    init(v);
    auto f = [&](int i, int j, int k, int l)->int{
        return v[k][l]-(i==0 ? 0 : v[i-1][l])-(j==0 ? 0 : v[k][j-1])+(i>0&&j>0 ? v[i-1][j-1] : 0);
    };
    int ret = 1<<30;
    for(int i = 0; i < 1<<(h-1); i++){
        int tmp = 0;
        vector<int> split;
        split.push_back(0);
        for(int j = 0; j < h-1; j++){
            if((i>>j)&1){
                tmp++;
                split.push_back(j+1);
            }
        }
        if(split.back() != h)   split.push_back(h);
        bool valid = true;
        int wpos = 0;
        while(wpos < w){
            int nw = w;
            for(int j = 0; j+1 < split.size(); j++){
                int from = split[j], to = split[j+1];
                if(f(from, wpos, to-1, wpos) > k){
                    valid = false;
                    break;
                }
                int npos = wpos;
                while(npos+1 < w && f(from, wpos, to-1, npos+1) <= k)   npos++;
                nw = min(nw, npos+1);
            }
            if(!valid)  break;
            tmp += (nw!=w);
            wpos = nw;
        }
        if(valid)   ret = min(ret, tmp);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include"math.h"
#include<vector>
#include<deque>
#include<map>
#include<set>
#define ll long long
#define dou(s) atof(s.c_str())
#define lll(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define delete(a,i) a.erase(a.begin()+i)
#define fion(n) fixed<<setprecision(n)
#define endl "\n"
#define OR ||
#define AND &&
#define NOT !
#define line(s) getline(cin,s)
#define START int main(){cin.tie(0);ios::sync_with_stdio(false);
#define END }
using namespace std;
struct pro{string na;ll ti;};
START
ll n,q;cin>>n>>q;
deque<pro> p(n);
rep(i,0,n)cin>>p[i].na>>p[i].ti;
ll t=0;
while(p.size()!=0){
  if(p[0].ti<=q){
    t+=p[0].ti;
    cout<<p[0].na<<' '<<t<<endl;
    p.pop_front();
  }else{
    t+=q;
    p[0].ti-=q;
    p.push_back(p[0]);
    p.pop_front();
  }
}
END


Measured memory_bytes: 5944
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unordered_set<ll> uset;
typedef unordered_map<ll,ll> umap;
typedef pair<ll,ll> pr;

void print(const vector<pr>& v ){
  for( auto p : v ) cerr << " (" << p.first << "," << p.second << ")";
  cerr << endl;
}
 
void print( const vector<int>& v ){
  for( auto x : v ) cerr << " " << x; cerr << endl;
}
 
int main( int argc, char* argv[] ){
  int N;
  cin >> N;
  int N2 = N/2;
  vector<ll> v1(N2), v2(N2);
  for( int i=0; i<N2; ++i ){
      cin >> v1[i];
      cin >> v2[i];
  }
  umap c1, c2;
  for( auto x : v1){
      c1[x]++;
  }
  for( auto x : v2){
      c2[x]++;
  }

  vector<pr> l1 = vector<pr>( c1.begin(), c1.end() );
  vector<pr> l2 = vector<pr>( c2.begin(), c2.end() );
  std::sort( l1.begin(), l1.end(), [](const pr& p1, const pr& p2) { return p1.second > p2.second; });
  std::sort( l2.begin(), l2.end(), [](const pr& p1, const pr& p2) { return p1.second > p2.second; });
  if( l1[0].first != l2[0].first ){
      cout << N - l1[0].second - l2[0].second << endl;
      return 0;
  }
  if( l1.size() == 1 && l2.size() == 1 ){
      cout << N2 << endl;
      return 0;
  }
  if( l1.size() == 1 ){
      cout << N2 - l2[1].second << endl;
      return 0;
  }
  if( l2.size() == 1 ){
      cout << N2 - l1[1].second << endl;
      return 0;
  }
  auto ret = std::min( N-l1[0].second-l2[1].second, N-l1[1].second-l2[0].second );
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 6668
#include <bits/stdc++.h>
using namespace std;
const int64_t MAX = 1000005;
int64_t N;

bool pairwize(vector<int64_t> &A)
{
  vector<bool> divs(MAX, false);
  for (int i = 0; i < N; i++)
  {
    if (divs.at(A.at(i)) && A.at(i) != 1)
    {
      return false;
    }
    divs.at(A.at(i)) = true;
    for (int64_t j = 2; j * j <= A.at(i); j++)
    {
      if (A.at(i) % j != 0)
        continue;
      if (divs.at(j))
      {
        return false;
      }
      divs.at(j) = true;
      int64_t k = A.at(i) / j;
      if (j != k)
      {
        if (divs.at(k))
        {
          return false;
        }
        divs.at(k) = true;
      }
    }
  }
  return true;
}

int main()
{
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  if (pairwize(A))
  {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int64_t g = gcd(A.at(0), A.at(1));
  for (int i = 2; i < N; i++)
  {
    g = gcd(g, A.at(i));
  }
  if (g == 1)
  {
    cout << "setwise coprime" << endl;
  }
  else
  {
    cout << "not coprime" << endl;
  }
}

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

int main(){
  char b;
  cin >> b;
  if(b=='A') cout << 'T' << endl;
  if(b=='T') cout << 'A' << endl;
  if(b=='C') cout << 'G' << endl;
  if(b=='G') cout << 'C' << endl;
}

Measured memory_bytes: 256
H, N = list(map(int, input().split()))
dp = [[float('inf')] * (H + 1)]
dp[0][0] = 0
magic = []
for i in range(N):
  magic.append(list(map(int, input().split())))
  
for i in range(H+1):
  next = dp[i]
  if dp[i][i] != float('inf'):
    for j in magic:
      next[min(H, i + j[0])] = min(dp[i-1][i] + j[1], dp[i][min(H, i + j[0])])
  dp.append(next)

print(dp[-1][-1])

Measured memory_bytes: 74440
#include<stdio.h>
#include <stdlib.h>

#define N 10000

int main(){
  int i,j,n,a,c,k,C[N+1];
  unsigned long *in,*result;

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

  in = malloc(sizeof(long)*n+1);
  result = malloc(sizeof(long)*n+1);
  
  for(i=0;i<n;i++){
    scanf("%d",&in[i+1]);
    C[in[i+1]]++;
  }

  for(i=1;i<=N;i++){
    C[i] = C[i] + C[i-1];
  }

  for(j=1;j<=n;j++){
    result[C[in[j]]] = in[j];
    C[in[j]]--;
  }
  
  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",result[i]);
  }
  
  printf("\n");
  return 0;
}



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

int main()
{
    /* ------- 宣言と入力 ------- */

    int N;

    cin >> N;

    long long int A[N];

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    /* ------- 計算 ------- */

    sort(A, A + N);
    for (int i = 0; i < N - 1; i++)
    {
        if (A[i] == A[i + 1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x;
  cin>>n>>d>>x;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    x+=d/a+(bool)(d%a);
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
H,W,N = map(int,input().split())

ab = []

dic = {}

for i in range(N):

    a,b = map(int,input().split())

    for x in range(3):
        x -= 1
        for y in range(3):
            y -= 1

            if (1 < a+x  and a+x < H) and (1 < b+y and b+y < W):

                if (a+x,b+y) not in dic:
                    dic[(a+x,b+y)] = 1
                else:
                    dic[(a+x,b+y)] += 1

ans = [0] * 10
d = 0
for i in dic:
    ans[dic[i]] += 1

for i in range(10):
    d += ans[i]
ans[0] = (H-2) * (W-2) - d

for i in range(10):
    print (ans[i])


Measured memory_bytes: 142708
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int h = int.Parse(Console.ReadLine());
        Console.WriteLine((a!=b)?(a+b)*h/2:a*h);
    }
}

Measured memory_bytes: 2776
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::vector<ll> M, std::vector<ll> D) {
  bool r = M.at(0) != M.at(1);
  if (r)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  std::vector<ll> M(2);
  std::vector<ll> D(2);
  for (int i = 0; i < 2; i++) {
    scanf("%lld", &M[i]);
    scanf("%lld", &D[i]);
  }
  solve(std::move(M), std::move(D));
  return 0;
}


Measured memory_bytes: 256