akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int N; cin>>N;
  ll x[N],y[N],u[N],v[N];
  REP(i,N){
    cin >> x[i] >> y[i];
  }
  
  int odd = abs(x[0]+y[0])%2;
  REP(i,N){
    if( abs(x[i]+y[i])%2!=odd ){
      cout << -1 << "\n"; return 0;
    }
    u[i] = x[i]+y[i];
    v[i] = x[i]-y[i];
  }
  vector<ll> d;
  REPR(i,30){
    d.push_back(pow(2,i));
  }
  if(!odd){ d.push_back(1LL); }
  int m = d.size();
  cout << m << "\n";
  REP(i,m){
    if(i<m-1){
      cout << d[i] << " ";
    }else{
      cout << d[i] << "\n";
    }
  }

  REP(i,N){
    bool ru,rd;
    ll us = 0LL, vs = 0LL;
    REP(idx,m){
      if(us <= u[i]){ 
        ru = 1; us += d[idx];
      }else{
        ru = 0; us -= d[idx];
      }
      if(vs <= v[i]){
        rd = 1; vs += d[idx];
      }else{
        rd = 0; vs -= d[idx];
      }
      if(ru){
        if(rd){
          cout << "R";
        }else{
          cout << "U";
        }
      }else{
        if(rd){
          cout << "D";
        }else{
          cout << "L";
        }
      }
    }
    cout << "\n";
  }

}


Measured memory_bytes: 4144
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 1000000007
using namespace std;

int main() {
  ull n,ans=1;
  cin >> n;
  for(ull i=1;i<=n;i++) {
    ans *= i;
    if(ans>=MAX) {
      ans %= MAX;
    }
  }
  cout << ans%MAX << endl;
}

Measured memory_bytes: 256
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
count1 = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i]>A[j]:
            count1 += 1
count2 = 0
for i in range(N):
    for j in range(N):
        if A[i]>A[j]:
            count2 += 1
count1sum = count1*K
count2sum = K*(0+count2*(K-1))//2
print((count1sum+count2sum)%(10**9+7))

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

using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;

  vector<ll> d(n);
  for(int i=0;i<n;i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());

  ll div1=d.at(n/2);
  ll div2=d.at(n/2-1);
  ll div=div1-div2;

  cout << div << endl;
  
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  for(int i=0; i<s.size(); i++){
    if(s.at(i) != t.at(i)){
      cout << "No" << endl;
      return 0;
    }
    }
if(s.size() == t.size() -1){
  cout << "Yes" << endl;
}
    else{cout << "No" << endl;}
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,d;
  cin>>a;
  vector<int>b(a);
  vector<int>c(a);
  rep(i,a){
    cin>>d;
    b[i]=d;
    c[i]=d;
  }
  d=a/2;
  sort(c.begin(), c.end());
  rep(i,a){
    if(b[i]>=c[d])cout<<c[d-1]<<endl;
    else cout<<c[d]<<endl;
  }
}

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

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

  int n, k;
  string s;
  cin >> n >> k >> s;

  int ans = 0, seg = 0;
  for (int i = 1; i < n; i++)
    if (s[i] == s[i - 1]) ans++;
    else seg++;
  ans += min(k * 2, seg);
  cout << ans << endl;
}


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


int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    r(i,n)cin>>a.at(i);
    int cnt=0,max=0;


      for(int j=0;j<n-1;j++){
        if(a.at(j)>=a.at(j+1)){
          cnt++;
          if(max<cnt){max=cnt;}

        }else{
//          if(cnt!=0)j=j+cnt;

          cnt=0;
          
        }
      }
cout<<max<<endl;



return 0;

}


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	
	
	int ans=0;ll d;ll x,y;
	int test1;cin>>test1>>d;d*=d;while(test1--){ 
		cin>>x>>y;
		x*=x;
		y*=y;
		x+=y;
		if(x<=d) ans++;
	 }
	 db(ans);
	 //*/
return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
char g[330][330];
char ng[330][330];
int main(){
    int n;cin >> n;
    rep(i,n){
        rep(j,n){
            cin>>g[i][j];
        }
    }
    ll ans=0;
    rep(shift,n){
        rep(i,n){
            rep(j,n){
                ng[i][j]=g[i][(j+shift)%n];
            }
        }
        bool ok=true;
        rep(i,n){
            rep(j,n){
                if(ng[i][j]!=ng[j][i]) ok=false;
            }
        }
        if(ok){
            ans+=n;
        }
    }
    cout << ans << endl;
    return 0;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            Console.WriteLine((n / 2) * ((n+1) / 2));
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;
 
const int INF = 6e9;
 
int n, m;
int d[110][110];
 
void init(int n){
    rep(i, 0, n){
        rep(j, 0, n){
            d[i][j] = INF;
            if(i == j) d[i][j] = 0;
        }
    }
}
 
void warshall_floyd(){
    rep(k, 0, n){
        rep(i, 0, n){
            rep(j, 0, n){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}
 
signed main(){
    cin >> n >> m;
    init(n);
    rep(i, 0, m){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;    
    }
    warshall_floyd();
    rep(i, 0, n){
        if(d[i][i] != 0){
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }
    rep(i, 0, n){
        rep(j, 0, n){
            if(j != 0) cout << " ";
            if(d[i][j] >= 3e9) cout << "INF";
            else cout << d[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3172
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
total = 0
cnt = 0

for i in range(N):
    for j in range(M):
        total += (A[i][j]*B[j])
    if (total+C)>0:
        cnt += 1
    total = 0

print(cnt)

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

int main(){
    int i,j,k,n;
    while(1){
        cin>>n;
        if(!n){break;}
        int dp[33000][5]={0};
        dp[0][0]=1;
        for(int i=1;i*i<=n;i++){
            for(int k=1;k<=4;k++){
                for(int j=i*i;j<=n;j++){
                    dp[j][k] += dp[j-i*i][k-1];
                }
            }
        }
        cout<<dp[n][1]+dp[n][2]+dp[n][3]+dp[n][4]<<endl;
    }
    return 0;
}




Measured memory_bytes: 3636
#include <stdio.h>
int main(){
    int H[100],W[100],i,k,ix,o;
    i=0;
    while(1){
        scanf("%d %d",&H[i],&W[i]);
        if(H[i]==0&&W[i]==0){
            ix=i;
            break;
        }
        i++;
    }
    for(i=0;i<ix;i++){
        for(o=0;o<H[i];o++){
            for(k=0;k<W[i];k++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

int main() {
  int n, r = 0, b = 0;
  string S;
  cin >> n >> S;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'R') r++;
    else b++;
  }
  if(r > b) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
N = input()
A =  [int(n) for n in input().split()]

Flg = True
COUNT  = 0

while(Flg):    
    for n in A:        
        if n%2 != 0:
            Flg=False
            break
        
    if Flg:
        A =  [n / 2 for n in A]
        COUNT+=1

print(COUNT) 


Measured memory_bytes: 9188
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;

int main(void)
{
	int a, b;

	cin >> a >> b;

	if (a % 2 == 0 || b % 2 == 0)
	{
		cout << "Even" << '\n';
	}
	else
	{
		cout << "Odd" << '\n';
	}

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int N, K;
    cin >> N >> K;
    vector<int> h(N);

    int sol = 0;
    FOR(i, N) {
        cin >> h[i];
        sol += h[i] >= K;
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	int n;
	cin >> n;

	int a[n][3];
	for(int i=0;i<n;i++){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}

	int dp[n][3];
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];

	for(int i=1;i<n;i++){
		dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = a[i][1] + max(dp[i-1][2], dp[i-1][0]);
		dp[i][2] = a[i][2] + max(dp[i-1][0], dp[i-1][1]);
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}

Measured memory_bytes: 5968
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a,const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b) {if(b<a){a=b; return 1;} return 0;}
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,c;

int main() {
  IOS;
  cin >> n >> c;
  vector<ll> x(n),v(n);
  REP(i,n) cin >> x[i] >> v[i];

  vector<ll> s(n+1);
  vector<ll> s2(n+1);
  ll ans = 0;
  REP(i,n) {
    s[i+1] = s[i] + v[i] - x[i];
    s2[i+1] = s2[i] + v[i] - x[i]*2;
    if (0 < i) {
      s[i+1] += x[i-1];
      s2[i+1] += x[i-1]*2;
      chmax(ans,s[i+1]);
    }
  }

  vector<pair<ll,ll>> dp(n+1);
  REP(i,n) {
    dp[i+1] = { max(dp[i].first,s[i+1]), max(dp[i].second,s2[i+1]) };
  }

  ll sum = 0;
  for (int i = n-1; 0 <= i; i--) {
    sum += v[i];
    chmax(ans, sum - (c-x[i]) + dp[i].second);
    chmax(ans, sum - (c-x[i])*2 + dp[i].first);
  }

/*
  REP(i,n+1) { cout << s[i] << " "; }
  cout << endl;
  REP(i,n+1) { cout << s2[i] << " "; }
  cout << endl;
  REP(i,n+1) {
    cout << dp[i].first << " " << dp[i].second << endl;
  }
*/

  COUT(ans);
  return 0;
}

Measured memory_bytes: 7952
import sys
input = sys.stdin.readline

def main():
    h,w=map(int,input().split())
    if h==1 or w==1:
        ans=1
    else:
        if w%2==1:
            if h%2==1:
                ans=(w*h+1)/2
            else:
                ans=(w*h)/2
        else:
            ans=(w*h)/2
    print(int(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n, t = map(int, input().split())

k = [list(map(int, input().split())) for i in range(n)]
"""
114514 810
931 893
364 364

c1=k[0][0] t1=k[0][1]
"""
m=[]
for i in range(n):
    if t >= k[i][1]:
        m.append(k[i][0])

m.sort()
if m != []:
    print(m[0])
else:
    print("TLE")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj0051().doIt();
	}
	class aoj0051{
		int sum(int a[]){
			double result = 0;
			for(int i = 0;i < 8;i++){
				result = result + (a[7-i] - a[i])*Math.pow(10, 7-i);
			}
			int ans = (int) result;
			return ans;
		}
		void doIt(){
			int n = sc.nextInt();
			int a[] = new int [8];
			for(int i = 0;i < n;i++){
				String str = sc.next();
				char ctr[] = str.toCharArray();
				for(int j = 0;j < 8;j++)a[j] = Integer.parseInt(ctr[j]+"");
				Arrays.sort(a);
				System.out.println(sum(a));
			}
		}
	}
}

Measured memory_bytes: 17200
// Code by H~$~C
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;

static const int Maxn = 20005;

int n;
int x[Maxn], y[Maxn];
vector<pair<int, int> > pos;

namespace two_sat {
  int n;
  vector<vector<int> > g;
  vector<int> dfn, scc, low;
  vector<bool> instk;
  int scc_size, indx;
  stack<int> stk;
  void tarjan(int u) {
    dfn[u] = low[u] = ++indx;
    stk.push(u);
    instk[u] = true;
    for (int &v: g[u]) {
      if (!dfn[v]) {
        tarjan(v);
        low[u] = min(low[u], low[v]);
      }
      else if (instk[v]) {
        low[u] = min(low[u], dfn[v]);
      }
    }
    if (dfn[u] == low[u]) {
      scc_size++;
      do {
        int v = stk.top(); stk.pop();
        scc[v] = scc_size;
        instk[v] = false;
        if (v == u) break;
      } while (1);
    }
  }
  inline int inv(int x) { return x ^ 1; }
  inline void clear() {
    n = 0, g.clear();
    while (!stk.empty()) stk.pop();
    scc_size = indx = 0;
    instk.clear();
  }
  inline int newnode() {
    g.push_back(vector<int>());
    g.push_back(vector<int>());
    return 2 * n++;
  }
  inline void init(int x) {
    clear();
    while (n < x) newnode();
  }
  inline void imply(int a, int b) {
    g[a].push_back(b);
    g[inv(b)].push_back(inv(a));
  }
  bool solve() {
    dfn.assign(n * 2, 0);
    low.assign(n * 2, 0);
    scc.assign(n * 2, 0);
    instk.assign(n * 2, false);
    scc_size = indx = 0;
    for (int i = 0; i < n * 2; ++i) {
      if (!dfn[i]) {
        tarjan(i);
      }
    }
    for (int i = 0; i < n; ++i) {
      if (scc[2 * i] == scc[2 * i + 1])
        return false;
    }
    return true;
  }
}

#define ls (p * 2 + 1)
#define rs (p * 2 + 2)
#define mid (l + r >> 1)
int tr[Maxn << 2];
void build(int p, int l, int r) {
  tr[p] = two_sat::newnode();
  if (l == r) {
    two_sat::imply(tr[p], two_sat::inv(pos[l].second));
    return ;
  }
  build(ls, l, mid);
  build(rs, mid + 1, r);
  two_sat::imply(tr[p], tr[ls]);
  two_sat::imply(tr[p], tr[rs]);
}
void link_edge(int p, int l, int r, int L, int R, int id) {
  if (L > r || l > R) return ;
  if (L <= l && r <= R) {
    two_sat::imply(id, tr[p]);
    return ;
  }
  link_edge(ls, l, mid, L, R, id);
  link_edge(rs, mid + 1, r, L, R, id);
}
#undef ls
#undef rs
#undef mid

bool check(int d) {
  two_sat::init(n);
  build(0, 0, n * 2 - 1);
  for (int i = 0; i < n * 2; ++i) {
    int st = lower_bound(pos.begin(), pos.end(), make_pair(pos[i].first - d + 1, 0)) - pos.begin();
    int ed = lower_bound(pos.begin(), pos.end(), make_pair(pos[i].first + d, 0)) - pos.begin();
    if (i > st) link_edge(0, 0, n * 2 - 1, st, i - 1, pos[i].second);
    if (i < ed - 1) link_edge(0, 0, n * 2 - 1, i + 1, ed - 1, pos[i].second);
  }
  return two_sat::solve();
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", x + i, y + i);
    pos.push_back({x[i], i * 2});
    pos.push_back({y[i], i * 2 + 1});
  }
  sort(pos.begin(), pos.end());
  int l = 0, r = 1000000000, ans = 0;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid)) l = mid + 1, ans = mid;
    else r = mid - 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 20776
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  ll a,b,c,d,n;
  cin >> a >> b >> c >> d >> n;
  //1Lについて
  ll oneLma = 0;
  oneLma = min(a*4,b*2);
  oneLma = min(oneLma,c);
  //2Lについて
  ll twoLma = 0;
  twoLma = min(a*8,b*4);
  twoLma = min(twoLma,c*2);
  twoLma = min(twoLma,d);
  
//  cout << oneLma << endl;
//  cout << twoLma << endl;
  if(n==1) cout<<oneLma<<endl;
  else{
    if(n%2==0){
      ll k = n/2;
      cout << twoLma * k << endl;
      return 0;
    }
    else{
      ll k = n/2;
      cout << twoLma * k + oneLma << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3588
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 21
#define INF 0x3f3f3f3f
#define p 1000000007
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, ans, s[MAXN];

int main()
{
	scanf("%d", &n);
	for(rint i=0; i<n; ++i)
		for(rint j=0, x; j<n; ++j)
		{
			scanf("%d", &x);
			s[i]|=(x<<j);
		}
	for(rint sta=0; sta<(1<<n); ++sta)
	{
		int siz=0, val=1;
		for(rint i=0; i<n; ++i)
			siz+=((sta>>i)&1);
		for(rint i=0; i<n; ++i)
		{
			int temp=s[i]&sta, num=0;
			for(rint j=0; j<n; ++j)
				num+=((temp>>j)&1);
			val=1LL*val*num%p;
		}
		if((n-siz)&1) ans=(ans+p-val)%p;
		else ans=(ans+val)%p; 
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemC
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var M = read[1];

            var Hs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var As = new int[M];
            var Bs = new int[M];
            var maxs = new int[N];
            for (int i = 0; i < M; i++)
            {
                read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                As[i] = read[0];
                Bs[i] = read[1];
                maxs[As[i] - 1] = Math.Max(Hs[Bs[i] - 1], maxs[As[i] - 1]);
                maxs[Bs[i] - 1] = Math.Max(Hs[As[i] - 1], maxs[Bs[i] - 1]);
            }

            var goods = Hs.Select((x, i) => Hs[i] > maxs[i]).Where(x => x);
            Console.WriteLine(goods.Count());

        }
    }
}


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

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(all(A));
    vector<ll> Aa(N + 1);
    Aa[0]               = 0;
    rep(i, N) Aa[i + 1] = A[i] + Aa[i];

    ll l = 0, r = 1e10;
    ll ans = 0;

    while (r - l > 1) {
        ll c = (l + r) / 2;
        ll m = 0;
        ans  = 0;
        rep(i, N) {
            int index = lower_bound(all(A), c - A[i]) - A.begin();
            ans += (Aa[N] - Aa[index] + A[i] * (N - index));
            m += (N - index);
        }
        M > m ? (r = c) : (l = c);
        DEBUG(m-M);
        DEBUG(l);
        DEBUG(m);
        ans -= l * (m - M);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int n; cin>>n;
    vector <double> a(n); 
    rep(i,n) cin>>a[i];
     double shita=0;
    rep(i,n) shita += 1.0/ a[i];
    printf("%lf", 1.0/shita);
 }


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import qualified Data.Map.Strict as M
import Data.List
 
main = do
  [n, k] <- map read . words <$> getLine
  as <- B.words <$> B.getLine
  let dict = mkDict as
  print $ solve k dict
 
mkDict = foldr (\x y -> M.insertWith (+) x 1 y) M.empty
 
solve k dict = sum . drop k . sortOn negate $ M.elems dict

Measured memory_bytes: 56700
#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define fastIO cout << fixed << setprecision(3), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 4e5 + 5, M = 205, OO = 1e9, MOD2 = 1e9 + 7;
const ll INF = 1e18;

vector<ll> pos, neg, revNeg;

ll solve(ll x) {
    ll ret = 0;
    int r = SZ(pos) - 1;
    for (int i = 0; i < SZ(pos); ++i) {
        while(r >= 0 && pos[i] * pos[r] > x)
            --r;
        ret += max(0, r - i);
    }
    r = SZ(neg) - 1;
    for (int i = 0; i < SZ(neg); ++i) {
        while(r >= 0 && neg[i] * neg[r] > x)
            --r;
        ret += max(0, r - i);
    }
    r = 0;
    for (int i = 0; i < SZ(pos); ++i) {
        while(r < SZ(revNeg) && pos[i] * revNeg[r] <= x)
            ++r;
        ret += r;
    }
    return ret;
}

void runtestcase() {
    ll n, k, x;
    cin >> n >> k;

    for (int i = 0; i < n; ++i) {
        cin >> x;
        if(x >= 0)
            pos.push_back(x);
        else
            neg.push_back(x);
    }
    sort(pos.begin(), pos.end());
    sort(neg.rbegin(), neg.rend());
    revNeg = neg;
    reverse(revNeg.begin(), revNeg.end());
    ll start = -INF, end = INF, mid, ans;
    while(start <= end) {
        mid = start + (end - start) / 2;
        if(solve(mid) >= k) {
            ans = mid;
            end = mid - 1;
        } else {
            start = mid + 1;
        }
    }
    cout << ans;
}

int main() {
    fastIO;
#ifdef LOCAL
    freopen("input.in", "rt", stdin);
//    freopen("output.in", "wt", stdout);
#endif
    int t = 1, tt = 1;
//    cin >> t;
    while(t) {
//		cout << "Case #" << tt << ':' << ' ';
        runtestcase();
//        cout << '\n';
        --t, ++tt;
    }
}


Measured memory_bytes: 6288
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include<cmath>
#include<cstdio>
using namespace std;

const int LOOP = 10000; //??????????????°
const double EPS = 1e-6; //??????????????¨(?°??????????????????????)
int L;
int N; //???????????±???????????°



//???????????±????????????????????????????????¨?????¨???????¨????????¨??????????
double Evaluate(int r[12]) {
	double val = r[0] + r[N-1];
	for (int i = 0; i < N - 1; i++)
	{
		int a = abs(r[i] - r[i+1]), c = r[i] + r[i+1];
		val += sqrt(c*c - a*a);
	}
	return val;
}

//?????¨?????????????????°???????????¨??????????????????????§???????????±???????
//(????§?????????????true)
bool Changes(int cnt) {
	return cnt < rand()%LOOP;
}

//?????????????????????????????¢??°
//?????????????°??????????????¨?????????????
//int r[12] : ???????????±?????????0??????N-1???????????????????????????????????????????????????????´???????
double Solve(int r[12]) {
	double score = Evaluate(r); //?????¨?????¶???r[]????¨???????????´????????????°
	double mi = score; //???????????§?????¶???????¨???????????°???????????´????????????°
	for (int cnt = 0; cnt < LOOP; cnt++)
	{
		//===============================================
		//???????????????
		int a=rand()%N,b=rand()%N;
		swap(r[a],r[b]);
		score=Evaluate(r);
		if(mi>score){
            mi=score;
            continue;
		}
		if(mi<score){
            if(Changes(cnt)){
                mi=score;
                continue;
            }
            swap(r[a],r[b]);
		}
		//===============================================
	}
	return mi; //????°?????????????
}

//??\?????¢????????????????????¢????????£????????§???????????????
int main() {
	while (cin >> L)
	{
		N = 0;
		int r[12];
		string S;
		getline(cin, S);
		stringstream SS(S);
		while (!SS.eof()) SS >> r[N++];
		double ans;
		if (N == 1) ans = r[0]*2;
		else ans = Solve(r);
		if (L - ans + EPS > 0) puts("OK");
		else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 1212
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N,K=MI()
ans = 0
for k in range(K,N+2):
    ans += (k*(N-k+1)+1)
    ans = ans%MOD
print(ans)


Measured memory_bytes: 73064
#include <stdio.h>
#include <vector>
std::vector<bool> IsPrime;

bool isPrime(long num){
for(long i=2;i<num;i++){
    if(num%i==0){
        return false;
    }
}

return true;
}


int main(void)
{
 
 long x;

scanf("%ld",&x);

bool ret=false;

while(!ret){
    ret=isPrime(x);
    x++;
}

printf("%ld",x-1);
  return 0;
}


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

int main(void) {
	long long int a;
	char b[6];
	scanf("%lld%s", &a, b);

	char *n = strchr(b, '.');
	*n++ = '\0';

	int x = atoi(b);
	int y = atoi(n);

	printf("%lld\n", a*x + a*y/100);
}


Measured memory_bytes: 1736
#include <iostream>

using namespace std;

template<typename T>
struct node
{
    T n;
    node<T> *l;
    node<T> *r;
    //node(T a, node<T> b, node<T> c){ n = a; l = b; r = c; }
};

template<typename T>
node<T>* reconstruct(T *p, T *i, int l)
{
    if (l == 0) return NULL;
    node<T> *ans = new node<T>;
    ans->n = *p;
    if (l == 1) ans->l = ans->r = NULL;
    else
    {
        int j = 0;
        while (j < l && *p != *(i + j)) j++;
        ans->l = reconstruct<T>(p + 1, i , j);
        ans->r = reconstruct<T>(p + j + 1, i + j + 1, l - j - 1);
    }
    return ans;
}

template<typename T>
T* postsearch(node<T>* root, T *p)
{
    if (root->l) p = postsearch(root->l, p);
    if (root->r) p = postsearch(root->r, p);
    *p = root->n;
    return ++p;
}

int main(void)
{
    int N;
    cin >> N;
    int pre[40], in[40], post[40];
    for (int i = 0; i < N; i++) cin >> pre[i];
    for (int i = 0; i < N; i++) cin >> in[i];
    node<int> *root = reconstruct<int>(pre, in, N);
    postsearch<int>(root, post);
    cout << post[0];
    for (int i = 1; i < N; i++) cout << " " << post[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3124
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int C[501],F[501],S[501];
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif

	int n;cin>>n;
	for(int i=0;i<n-1;i++)
		cin>>C[i]>>S[i]>>F[i];

	for(int i=0;i<n;i++)
	{
		int t=0;
		for(int j=i;j<n-1;j++)
		{
			if(t<S[j])t=S[j];
			else if(t%F[j]!=0)t=t+F[j]-t%F[j];
			t+=C[j];
		}
		cout<<t<<"\n";
	}




	
}

Measured memory_bytes: 3628
n = [int(i) for i in input().split()]
flag = False
if(abs(n[0]-n[2]) <= n[3]):
  flag = True
elif(abs(n[0]-n[1]) <= n[3] and abs(n[1]-n[2]) <= n[3]):
  flag = True
if(flag == True):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))[:N]

i = 0
color = 0
T = list(filter(lambda x:x>=3200,A))
A = list(filter(lambda x:x<3200,A))

for R in range(0,2801,400):
    if len(list(filter(lambda x:x>=R and x<R+400,A)))>0: color+=1
    
min_color = color
max_color = color+len(T)

if min_color==0 and len(T)>0: min_color = 1
    
print(min_color,max_color)

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

# input
s = input()

# solve
ans = list()
for i in range(len(s)):
    if s[i] == '0':
        ans.append('0')
    elif s[i] == '1':
        ans.append('1')
    else:
        if ans:
            ans.pop()

# output
print(*ans, sep='')


Measured memory_bytes: 2940
N, K = gets.split.map &:to_i
X = gets.split.map &:to_i
K -= 1 if X.delete 0
L, R = X.partition{|n|n < 0}
L.map!{|n|-n}.sort!
L.unshift 0
R.unshift 0
p (0..K).map{|li|
  ri = K - li
  if !L[li] || !R[ri]
    1.0/0
  else
    [L[li] + R[ri] * 2, L[li] * 2 + R[ri]].min
  end
}.min


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

int k[1000][1000][2];
int m[1000];
int o[1000];
int v[36];
string L;

int main(){
	int n,e,MIN,MIN2,sum=0;
	char T[11]="0123456789";
	char S[5]="SHCD";

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>L;
		for(int j=0;j<10;j++){
			if(L[1]==T[j]){
				k[0][i][0]=j;
			}
		}
		for(int j=0;j<4;j++){
			if(L[0]==S[j]){
				k[0][i][1]=j;
			}
		}
	}
	e=0;
	for(int i=1;i<=9;i++){
		for(int j=0;j<n;j++){
			if(k[0][j][0]==i){
				m[e]=i*4+k[0][j][1];
				e++;
			}
		}
	}

	for(int i=0;i<n;i++){
		cout<<S[m[i]%4]<<T[m[i]/4];
		if(i<n-1){
			cout<<' ';
		}
		else{
			cout<<endl;
		}
	}
	cout<<"Stable"<<endl;

	//sort.

	for(int i=0;i<n-1;i++){
		MIN=1000000;
		MIN2=0;
		for(int j=i+1;j<n;j++){
			if(k[i][j][0]<MIN){
				MIN=k[i][j][0];
				MIN2=j;
			}
		}
		for(int j=0;j<n;j++){
			k[i+1][j][0]=k[i][j][0];
			k[i+1][j][1]=k[i][j][1];
		}
		if(MIN<k[i][i][0]){
			k[i+1][i][0]=k[i][MIN2][0];
			k[i+1][MIN2][0]=k[i][i][0];
			k[i+1][i][1]=k[i][MIN2][1];
			k[i+1][MIN2][1]=k[i][i][1];
		}
	}
	for(int i=0;i<n;i++){
		cout<<S[k[n-1][i][1]]<<T[k[n-1][i][0]];
		o[i]=k[n-1][i][0]*4+k[n-1][i][1];
		if(i==n-1){
			cout<<endl;
		}
		else{
			cout<<' ';
		}
	}
	for(int i=0;i<n;i++){
		if(o[i]!=m[i]){
			cout<<"Not stable"<<endl;
			goto Exit2;
		}
	}
	cout<<"Stable"<<endl;
	goto Exit2;
Exit2:;
	return 0;
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
#define MAX 10000005
#define ll long  long
#define upperlimit 1000100
#define INF 1e18
#define inf 1e9
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mod 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define ios ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
ll a[100004],b[100003];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    ll t=0,ans=0;
    for(int i=n;i>=1;i--)
    {
        ll h=a[i]+t;
        ll u=b[i];
        h=h%u;
        if(h==0)h=u;
        h=u-h;
        t+=h;
        ans+=h%u;



    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <list>
 
using namespace std;
 
int main() {
	int d,t,s;
	cin >> d >> t >> s;
	if(s*t >= d){
	    cout << "Yes" << endl;
	}else{
	    cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

const int N = 1234567;

vector <int> g[N];
int a[N];
int k;

int ans;

int dfs(int v) {
  int sz = g[v].size();
  int steps = 0;
  for (int j = 0; j < sz; j++) {
    int u = g[v][j];
    int cur = dfs(u);
    steps = max(steps, cur + 1);
  }
  if (steps == k - 1 && a[v] != 0) {
    a[v] = 0;
    steps = -1;
    ans++;
  }
  return steps;
}

int main() {
  int n;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    a[i]--;
  }
  ans = 0;
  if (a[0] != 0) {
    a[0] = 0;
    ans++;
  }
  for (int i = 1; i < n; i++) {
    g[a[i]].push_back(i);
  }
  dfs(0);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 37376
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

const int N = 100005;
vector<int> G[N];
int C;
int comp[N];
int vtx[N];

int dfs(int v)
{
    comp[v] = C;
    int sz = 1;
    for (int &u : G[v]) if (comp[u] == -1)
    {
        sz += dfs(u);
    }
    return sz;
}

void no()
{
    cout << "No\n";
    exit(0);
}
void yes()
{
    cout << "Yes\n";
    exit(0);
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    int n;
    ll m;
    cin >> n >> m;
    int Q;
    cin >> Q;
    vector<pii> many;
    while (Q--)
    {
        int a, b, c;
        cin >> a >> b >> c;
        if (c == 0)
        {
            G[a].pb(b);
            G[b].pb(a);
        }
        else many.pb({a, b});
    }
    C = 0;
    memset(comp, 255, sizeof(comp));
    ll forest = 0;
    for (int v = 0; v < n; ++v) if (comp[v] == -1)
    {
        vtx[C] = v;
        int sz = dfs(v);
        ++C;
        forest += sz - 1;
    }

    if (m < forest)
    {
        no();
    }

    for (auto e : many)
    {
        int v = e.fi;
        int u = e.se;
        if (comp[v] == comp[u])
        {
            no();
        }
    }

    m -= forest;
    if (m < C - 1)
    {
        no();
    }
    if (m == C - 1)
    {
        if (!many.empty())
            no();
        else
            yes();
    }
    ll mx = C * (ll)(C - 1) / 2;
    if (m > mx)
    {
        no();
    }
    yes();

    return 0;
}

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

int main() {
	int n, d, ans = 1;
	cin >> n >> d;

	while (true) {
		if (n <= (2 * d + 1) * ans) {
			cout << ans << endl;
			return 0;
		}
		ans++;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  int p[10][10];
  int a[h][w];
  for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) cin >> p[i][j];
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> a[i][j];
  for(int k = 0; k < 10; k++) for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) p[i][j] = min(p[i][j], p[i][k] + p[k][j]);
  int ans = 0;
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(a[i][j] >= 0) ans += p[a[i][j]][1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.math.*

fun main(args: Array<String>) {
    readInputLine()
    val S = readInputLine()
    
    var ans = S
    var cnt = 0

    for (c in S) {
        if (c == '(') {
            cnt++
        } else {
            if (cnt == 0) {
                ans = "(" + ans
            } else {
                cnt--
            }
        }
    }
    
    cnt = 0
    
    for (c in ans.reversed()) {
        if (c == ')') {
            cnt++
        } else {
            if (cnt == 0) {
                ans += ")"
            } else {
                cnt--
            }
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 32000
from operator import add
from functools import reduce

n, m = map(int, input().split(' '))
aa = list(map(int, input().split(' ')))

threshold = (1 / (4 * m)) * reduce(add, aa)
count = 0
for a in aa:
    if threshold <= a:
        count += 1
if m <= count:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main() {
	string s; cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i + 1] == s[i]) {
			cnt++;
			if (s[i + 1] == '0')s[i + 1] ='1';
				
			else s[i + 1] = '0';
				
			
		}
	}
	cout << cnt;

	return 0;
}

Measured memory_bytes: 512
/*
 * aoj/alds1_10_b_2nd/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const ll INF = 100000000000000000;
// 1 1
// 1 1
// 1 1
//
// 1 1 1
// 1 1 1
//
struct Mat {
  ll r, c, count;
  Mat operator * (Mat v) {
    assert(c == v.r);
    ll numOp = r * v.c * c;
    return (Mat){ r, v.c, numOp + count + v.count };
  }
  bool operator == (const Mat &v) const {
    return r == v.r && c == v.c;
  }
  bool operator < (const Mat &v) const {
    assert(v.count == INF or (r == v.r and c == v.c));
    return count < v.count;
  }
  bool operator > (const Mat &v) const {
    // cout << r << " " << v.r << " " << c << " " << v.c << " " << count << " " << v.count << endl;
    assert(v.count == INF or count == INF or (r == v.r and c == v.c));
    return count > v.count;
  }
};

const int MAX = 110;
ll N;
vector<Mat> A;

// dp[l][r] := [l:r)の範囲の行列を掛け算する時の最小回数.
Mat dp[MAX][MAX];

void input() {
  cin >> N;
  ll r, c;
  loop(n,0,N) {
    cin >> r >> c;
    A.push_back({ r, c, 0 });
  }
}

ll receive() {
  for (int len=0; len<=N; len++) {
    for (int l=0; l+len<=N; l++) {
      int r = l+len;
      dp[l][r] = Mat({ 0, 0, INF });
    }
  }

  for (int l=0; l<N; l++) dp[l][l+1] = A[l];
  for (int len=2; len<=N; len++) {
    for (int l=0; l+len<=N; l++) {
      int r = l+len;
      for (int k=l+1; k<r; k++) {
        chmin(dp[l][r], dp[l][k] * dp[k][r]);
      }
    }
  }

  return dp[0][N].count;
}

void solve() {
  cout << receive() << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}



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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

struct Edge
{
	int to;
	int id;
};

vector<vector<Edge>> g;
vi ans;

void dfs(int v, int c = -1, int p = -1) {
	int k = 1;
	for (int i = 0; i < g[v].size(); ++i) {
		int u = g[v][i].to, ei = g[v][i].id;
		if (u == p) continue;
		if (k == c) ++k;
		ans[ei] = k; 
		++k;
		dfs(u, ans[ei], v);
	}
}

int main() {
	int n;
	cin >> n;
	g.resize(n);

	ans = vi(n - 1);

	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		Edge edge1 = { b, i };
		Edge edge2 = { a, i };
		g[a].push_back(edge1);
		g[b].push_back(edge2);
	}
	dfs(0);

	int mx = 0;
	rep(i, n) mx = max(mx, int(g[i].size()));
	cout << mx << endl;
	rep(i, n - 1) {
		cout << ans[i] << endl;
	}
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	ll N;
	cin >> N;
	ll ans = 1;
	if (N == 1)cout << 1 << endl;
	else {
		rep(i, N) {
			ll x = i*i;
			if (x > N)break;
			if (x <= N&&x>0)ans = i*i;
		}
		cout << ans << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	vector<LL> A(N);
	int i;
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	int aw=0;
	for (i=0;i<N;i++){
		if (A[i]%2==1){
			cout<<aw<<endl;
			return 0;
		}
		A[i]/=2;
		if (i==N-1){
			aw++;
			i=-1;
		}
	}

	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

S = input()

A = []
for i in range(len(S) - 1):
    if S[i] == 'R' and S[i + 1] == 'L':
        A.append(i)
B = [-a for a in reversed(A)]
dp = [0 for _ in range(len(S))]
for i in range(len(S)):
    if S[i] == 'R':
        j = bisect_left(A, i)
        k = A[j]
        if (k - i) % 2 == 0:
            dp[k] += 1
        else:
            dp[k + 1] += 1
    if S[i] == 'L':
        j = bisect_left(B, -i)
        k = -B[j]
        if (k - i) % 2 == 0:
            dp[k] += 1
        else:
            dp[k + 1] += 1

ans = ' '.join(
    str(x)
    for x in dp
)

print(ans)


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int A; cin >> A;
    int B; cin >> B;
    for (int i = 1; i <= 3; i++) {
        if (i != A && i!= B) cout << i << endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int a[25], b[25], c[25];

int main(){
    cin>>n;
    REP(i,n)cin>>a[i];
    REP(i,n)cin>>b[i];
    REP(i,n-1)cin>>c[i];
    REP(i,n)a[i]--;
    int ans = 0;
    REP(i,n){
        ans += b[a[i]];
    }
    REP(i,n-1){
        if(a[i]+1 == a[i+1]){
            ans += c[a[i]];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256