akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define N 8
  
int main() 
{ 

/////////////////////////////////////
    
    fastio;
  
  lli n;
  cin>>n;
  lli a[n+1],b[n];

  loopl(i,0,n+1) cin>>a[i];
  loopl(i,0,n) cin>>b[i];

  lli cnt=0;
  lli k = min(b[0],a[0]);
  b[0]-=k;
  a[0]-=k;
  cnt+=k;

  for(lli i=n-1;i>=0;i--)
  {
    lli k=min(b[i],a[i+1]);
    cnt += min(b[i],a[i+1]);
    b[i]-=k;
    a[i+1]-=k;
    k = min(b[i],a[i]);
    cnt += min(b[i],a[i]);
    b[i]-=k;
    a[i]-=k;
  }

  cout<<cnt<<endl;
} 

Measured memory_bytes: 1792
import math
a,b=map(int,input().split())
c=[[int(i) for i in input().split()] for i in range(a)]


count=0
sum1=0
sum1=0
for i in range(a):
    for z in range(i+1,a,1):
        for j in range(b):
            sum1+=(c[i][j]-c[z][j])**2
        
        if math.sqrt(sum1)%1.0==0:
            count+=1
        sum1=0
print (count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,j,a[n],dp[n+1][n+1];
    memset(dp,0LL,sizeof(dp));
    
    for(i=0;i<n;i++) cin>>a[i];
    
    for(i=n-1;i>=0;i--)
        for(j=i+1;j<=n;j++)
            dp[i][j]=max(a[i]-dp[i+1][j], a[j-1]-dp[i][j-1]);
    
    cout<<dp[0][n]<<endl;
    return 0;
}

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

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

    vector<string> s(n);
    for (int i = 0; i < n; i++){
        cin >> s.at(i);
    }

    int m;
    cin >> m;

    vector<string> t(m);
    for (int i = 0; i < m; i++){
        cin >> t.at(i);
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        int r = 0;
        for (int j = 0; j < n; j++){
            if (s.at(j) == s.at(i)){
                r ++;
            }
        }
        for (int k = 0; k < m; k++){
            if (t.at(k) == s.at(i)){
                r --;
            }
        }
        ans = max(ans, r);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func pf(N int) map[int]int {
	r := make(map[int]int, 0)
	n := N
	for i := 2; i*i <= N; i++ {
		for n%i == 0 {
			r[i]++
			n /= i
		}
	}
	if n > 1 {
		r[n]++
	}
	return r
}

func main() {
	var N int
	fmt.Scan(&N)
	pfs := make(map[int]int, 0)
	for i := 1; i <= N; i++ {
		for k, v := range pf(i) {
			pfs[k] += v
		}
	}
	// fmt.Printf("N %d, pfs %v\n", N, pfs)
	// 1. a^2*b^4*c^4のパターン
	// 2. a^4*b^14のパターン
	// 1. a^2*b^24のパターン
	// 2. a^74のパターン
	var v2, v4, v14, v24, v74 int
	for _, vv := range pfs {
		if vv >= 2 {
			v2++
		}
		if vv >= 4 {
			v4++
		}
		if vv >= 14 {
			v14++
		}
		if vv >= 24 {
			v24++
		}
		if vv >= 74 {
			v74++
		}
	}
	// fmt.Printf("v2 %d, v4 %d, v14 %d, v24 %d, v74 %d\n", v2, v4, v14, v24, v74)
	ans := 0
	if v74 >= 1 {
		ans += v74
	}
	if v24 >= 1 && v2 >= 2 {
		ans += v24 * (v2 - 1)
	}
	if v14 >= 1 && v4 >= 2 {
		ans += v14 * (v4 - 1)
	}
	if v4 >= 2 && v2 >= 3 {
		// nC2 * (v2-2)
		ans += (v4 * (v4 - 1)) / 2 * (v2 - 2)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  vector<int> a(5);
  cin >> a;
  rep(i, 5) {
    if (a[i] != i + 1) cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3564
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v: Vec<i32> = procon_read();
	let n = v[0];
	let m = v[1];
	let x = v[2];
	let y = v[3];
	let v: Vec<i32> = procon_read();
	let mut xi = v.clone();
	let v: Vec<i32> = procon_read();
	let mut yi = v.clone();
	xi.sort();
	yi.sort();
	let mut flag = false;
	if yi[0] - xi[(n - 1) as usize] >= 1 {
		for i in 1..(yi[0] - xi[(n-1) as usize] + 1) {
			if xi[(n-1) as usize] + i > x && xi[(n-1) as usize] + i <= y {
				flag = true;
				break;
			}
		}
		if flag {
			println!("No War");
		}else{
			println!("War");
		}
	}else{
		println!("War");
	}
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] ar=new int[n];
        int max=0;
        int min=Integer.MAX_VALUE;
        for(int i=0;i<n;i++){
            ar[i]=sc.nextInt();
            max=Math.max(ar[i], max);
            min=Math.min(ar[i], min);
        }
        double b=max-min;
        int c=(int)Math.abs(b);
        System.out.println(c);
    }    
}

Measured memory_bytes: 23124
from math import sqrt

x = int(input())
xr = int(sqrt(x))

l=[1]
for i in range(1,xr+1):
    t=[]
    for j in range(2,xr):
        if i**j <= x:
            t.append(i**j)
        else:
            break
    l = l+t
l = list(set(l))
l.sort()


left=0
right=len(l)
center=0

while left < right:
    center = (left+right)//2
    if l[center] == x:
        break
    elif l[center] < x:
        left = center+1
    else:
        right = center

print(l[center])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    int a, b;
    cin >> a >> b;
    if (a * b % 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

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


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var k, a, b int
	var f bool
	fmt.Scanf("%d", &k)
	fmt.Scanf("%d %d", &a, &b)

	for i := a; i <= b; i++ {
		if i%k == 0 {
			f = true
			println(i)
			// break
		}
	}
	if f == true {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}


Measured memory_bytes: 1816
#include <bits/stdc++.h>
#define INF 1e9+7
using namespace std;
using ll=long long;
ll sum;
int val[101],wt[101];
ll dp[101][100010];

void debug(int n,int w) {
    cout<<endl<<"============"<<endl;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=w;j++) {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<"#####################"<<endl;
}

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,w; cin>>n>>w;
    for(int i=1;i<=n;i++) {
        cin>>wt[i]>>val[i]; sum+=val[i];
    }
    for(int i=0;i<=n;i++) {
        for(int j=1;j<=sum;j++) {
            dp[i][j]=INF;
        }
    }
    //debug(n,w);

    for(int i=1;i<=n;i++) {
        for(int j=1;j<=sum;j++) {
            dp[i][j]=dp[i-1][j];
            if(val[i]<=j) dp[i][j]=min(dp[i][j],wt[i]+dp[i-1][j-val[i]]);
        }
    }
    ll ans=0;
    for(int i=1;i<=sum;i++) {
        if(dp[n][i]<=w) ans=i;
    }
    cout<<ans<<endl;
    //debug(n,w);
}


Measured memory_bytes: 79232
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
 
int main() {
  int N, C; cin >> N >> C;
  int program[C][100001]={0}, p_num[100001]={0};
  int s, t, c;
  for (int i=0; i<N; i++) {
    cin>>s>>t>>c; s--; t--; c--;
    program[c][s]++; program[c][t]--;
  }
  
  for (int c=0; c<C; c++) {
    int p_tmp[100001] = {0};
    for (int i=0; i<100000; i++) {
      p_tmp[i] += program[c][i];
      if ( program[c][i] == -1 ) {
        p_tmp[i] ++;
        p_tmp[i+1] --;
      }
    }
    for (int i=1; i<100001; i++) p_tmp[i] += p_tmp[i-1];
    for (int i=0; i<100001; i++) p_num[i] += p_tmp[i];
  }
  int result = 0;
  for (auto i: p_num) result = max(result, i);

  cout << result << endl;
  return 0;
}

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

int main() {
	bool boad[26] = {};
	for (int i = 0; i < 7; ++i)boad[i];
	for (int i = 7; i < 16; ++i)boad[i]++;
	for (int i = 16; i < 20; ++i)boad[i];
	for (int i = 20; i < 21; ++i)boad[i]++;
	for (int i = 21; i < 24; ++i)boad[i];
	boad[24]++; boad[25];
	string s;
	while (cin >> s, s != "#") {
		int sup = s.size() - 1, ans = 0;
		for (int i = 0; i < sup; i++) {
			if (boad[s[i] - 'a'] != boad[s[i + 1] - 'a'])ans++;
		}
		cout << ans << endl;
	}
}

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

using namespace std;

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

	int n,ans = 0;
	vector<int> l;

	cin >> n;
	l.resize(2*n);

	for (auto &a : l)
		cin >> a;

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

	for (int i = 1; i <= n; i++)
		ans += l[l.size() - i*2];

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int maxn=200010;
ll cnt[maxn];
ll a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<setiosflags(ios::fixed)<<setprecision(12);
    int N;
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    ll sum=0;
    for(int i=1;i<=maxn;i++)
    {
        if(cnt[i])
        {
            sum+=cnt[i]*(cnt[i]-1)/2;
        }
    }
    for(int k=1;k<=N;k++)
    {
        ll cur=a[k];
        ll num1=cnt[cur];
        ll num2=num1-1;
        ll ans=sum-1LL*num1*(num1-1)/2+1LL*num2*(num2-1)/2;
        cout<<ans<<"\n";
    }
    return 0;
}


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

int main(){
  int n, l; cin>>n>>l;
  vector<string> s;

  while(n--){
		string q; cin>>q;
		s.push_back(q);
		}
	sort(s.begin(), s.end());
	for(auto i: s) cout<<i;

  return 0;
  }


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    char a[101][101];
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }
    int cnt = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (a[i][j] == '.') {
                cnt++;
            }
        }
        if (cnt == w) {
            for (int i2 = i; i2 <= h; i2++) {
                for (int j = 1; j <= w; j++) {
                    a[i2][j] = a[i2 + 1][j];
                }
                if (i2 == h) {
                    h--;
                }
            }
            i--;
        }
        cnt = 0;
    }
    /*
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cout << a[i][j];
        }
        cout << endl;
    }*/
    
    
    
    
    for (int j = 1; j <= w; j++) {
        for (int i = 1; i <= h; i++) {
            if (a[i][j] == '.' || a[i][j] == '+') {
                cnt++;
            }
        }
        if (cnt == h) {
            for (int j2 = j; j2 <= w; j2++) {
                for (int i = 1; i <= h; i++) {
                    a[i][j2] = a[i][j2 + 1];
                }
                if (j2 == w) {
                    w--;
                }
            }
            j--;
        }
        cnt = 0;
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cout << a[i][j];
        }
        cout << endl;
    }
}



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

using namespace std;

using ll = long long;

int main() {
    string s[3];
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
    }
    int ptr[3] = {};
    int cur = 0;
    while (true) {
        if (ptr[cur] == (int) s[cur].length()) {
            char player = 'A' + cur;
            cout << player;
            return 0;
        }
        int tp = s[cur][ptr[cur]] - 'a';
        ptr[cur]++;
        cur = tp;
    }
    return 0;
}


Measured memory_bytes: 256
n = input()
a = int(n[-1])
if (a == 2) or (a == 4) or (a == 5) or (a == 7) or (a == 9):
	print("hon")
elif (a == 0) or (a == 1) or (a == 6) or (a == 8):
	print("pon")
elif (a == 3):
	print("bon")

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;
    sort(a.rbegin(), a.rend());

    int64_t e1 = 0, e2 = 0;
    for (int i = 0, ecnt = 0; i < n - 1 && ecnt < 2; ++i) {
        if (a[i] != a[i + 1]) continue;

        if (ecnt) e1 = a[i];
        else e2 = a[i];

        ++ecnt;
        ++i;
    }

    cout << e1 * e2 << endl;
}



Measured memory_bytes: 3792
k = int(input())
sq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(sq[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	int n;
	cin>>n;
	int p[n];
	int mini[n];
	for(int i=0;i<n;i++)
		cin>>p[i];
	mini[0]=p[0];
	for(int i=1;i<n;i++){
		mini[i]=min(mini[i-1],p[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		if(p[i]<=mini[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 1792
def main():
    n = int(input())
    a = list(map(int, input().split()))
    MAX = 10**18
    if 0 in set(a):
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if ans > MAX:
            print(-1)
            return
    print(ans)
    return
    

if __name__ == "__main__":
    main()

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

const int N = 1e5;

int n;
int a[N][3];
int dp[N][3];

int calc(int i, int j) {
    // cout << i << endl;
    if(i == n) return 0;

    int &r = dp[i][j];
    if(r != -1) return r;

    int res = 0;
    fore(k, 0, 3) {
        if(k != j) res = max(res, a[i][k] + calc(i + 1, k));
    }
    // cout << i << " " << j << " " << res << endl;
    return r = res;
}


int main() {
    cin >> n;
    fore(i, 0, n) fore(j, 0, 3) cin >> a[i][j];
    memset(dp, -1, sizeof dp);
    int m = max({a[0][0] + calc(1, 0), a[0][1] + calc(1, 1), a[0][2] + calc(1, 2)});
    cout << m << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
string s;
int n,mi,p[1000010];
int tr(int x){
	int mi=0;
	for (int i=0,j=0;i<n;i++){if (s[i]=='1') j++;else j--;p[i]=(x-j)/2;}
	for (int i=n-2;i>=0;i--)p[i]=min(p[i+1],p[i]);
	for (int i=0,j=0,k=0;i<n;i++){
		if (s[i]=='1')j++;if (s[i]=='0')j--;
		if (s[i]=='?'){if (k<p[i])k++,j++;else j--;}
		mi=min(mi,j);
	}
	return x-mi;
}
int main(){
	cin>>s;n=s.length();mi=0;
	for (int i=0,j=0;i<n;i++){if (s[i]=='1')j++;else j--;mi=max(mi,j);}
	cout<<min(tr(mi),tr(mi+1))<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max();
 
 
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int ans = 0, sum = 0;
  for(int i=0;i<N;i++){
    int a, b;
    cin >> a >> b;
    sum += a*b;
    ans += b;
  }
  ans--;
  cout << ans+((sum-1)/9) << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

const (
	a = 10000
	b = 5000
	c = 1000
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	for x := 0; x <= n; x++ {
		for y := 0; y <= n; y++ {
			if x+y > n {
				continue
			}
			if x*a+y*b+(n-x-y)*c == m {
				fmt.Println(x, y, (n - x - y))
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(){
    int X, Y, Z;
    int swap;

    cin >> X >> Y >> Z;

    swap = X;
    X = Y;
    Y = swap;

    swap = X;
    X = Z;
    Z = swap;

    cout << X << " " << Y << " " << Z << endl;

    return 0;
}

Measured memory_bytes: 888
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}


fn f(s: &Vec<i32>) -> bool{

    


    return true;
}

use std::iter::Iterator;
use std::cmp;


fn main() {
    input! {
       n : i32,
        d : i32
    }

    let mut cnt = 0;
    let mut target = n;
    for i in 0..20 {
        
        target = target - (d * 2 + 1);
        cnt = cnt + 1;

        if target <= 0 {
            break;
        }
    }

    println!("{}", cnt);


}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int,input().split()))
ans = 0
sum = 0
for i in range(n):
    sum += a[i]
    if sum*(-1)**i<=0:
        ans += abs(sum)+1
        sum = (-1)**i
ans2 = 0
sum = 0
for i in range(n):
    sum += a[i]
    if sum*(-1)**i>=0:
        ans2 += abs(sum)+1
        sum = -(-1)**i
print(min(ans,ans2))


Measured memory_bytes: 14332
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗

int main() {
  int N;
  ci(N);
  map<st, int> S;
  rep(i, N){
    st a;
    ci(a);
    S[a] += 1;
  }
  int b;
  ea(x, S){
    b = max(b, x.sc);
  }
  ea(x, S){
    if(x.sc == b){
      co(x.ft);
    }
  }
}

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

int main(){
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }

    int a[3]={},b[3]={};
    for(int i=0;i<3;i++){
        b[i]=c[0][i];
    }
    for(int i=1;i<3;i++){
        a[i]=c[i][0]-b[0];
    }
    bool ans=true;

    for(int i=1;i<3;i++){
        for(int j=1;j<3;j++){
            if(c[i][j]!=a[i]+b[j]) ans=false;
        }
    }

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

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  string S;
  cin>>S;

  if(S.back()=='s') S+="es";
  else S+="s";
  cout<<S<<endl;

  return 0;
}


Measured memory_bytes: 3660
n,k=map(int,input().split())
a=list(map(str,input().split()))
ans = n
tmp=0
while tmp==0:
    ans_str=str(ans)
    t=0
    for i in range(len(ans_str)):
        for j in range(len(a)):
            if ans_str[i] == a[j]:
                t=1
                break
    if t == 0:
        print(ans_str)
        tmp=1
    ans+=1


Measured memory_bytes: 3060
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]

se1 = set()
se2 = set()

for a, b in AB:
    if a > b:
        a, b = b, a
    if a == 1:
        se1.add(b)
    if b == N:
        se2.add(a)

se = se1 & se2
answer = "POSSIBLE" if se else "IMPOSSIBLE"
print(answer)


Measured memory_bytes: 58896
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long int b;
    cin>>n;
    std::deque<long long int> B;
    for (int i=0;i<n-1;i++) {
        cin>>b;
        B.emplace_back(b);
    }
    std::deque<long long int> A;
    if (n==1) {
        A.emplace_back(B[0]);
        A.emplace_back(B[0]);
    } else {
        A.emplace_back(B[0]);
        for (int j=0;j<n-2;j++) {
            A.emplace_back(min(B[j],B[j+1]));
        }
        A.emplace_back(B[B.size()-1]);
    }
    /*
    for (int hoge=0;hoge<A.size();hoge++) {
        cout<<A[hoge]<<" ";
    }
    cout<<endl;*/
    long long int sum=0;
    for (int k=0;k<A.size();k++) {
        sum+=A[k];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    int ls = s.size(), lt = t.size();
    int m = lt;
    for (int i = 0; i + lt <= ls; i++) {
        int c = 0;
        for (int j = 0; j < lt; j++) {
            if (s[i + j] != t[j]) {
                c++;
            }
        }
        if (c < m) {
            m = c;
        }
    }
    cout << m << endl;
}



Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N,M;
    while (cin >> N >> M) {
        if (abs(N-M) > 1) 
            cout << 0 << endl;
        else {
            LL a = 1, b = 1;
            FOR(x,1,N+1) {
                a *= x; a %= mod;
            }
            FOR(x,1,M+1) {
                b *= x; b %= mod;
            }
            LL ans = a*b * (N==M ? 2 : 1) % mod;
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

mi = min(a,b,c,d,e)
t = (n + (mi - 1)) // mi
print(4 + t)


Measured memory_bytes: 9040
#include <bits/stdc++.h>
        using namespace std;
         
        int main() {
          string S;
          cin >> S;
          
          if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
            cout << "Yes" <<endl;
          }
          else{
            cout << "No" <<endl;
          }
            
        return 0;
        }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define W 30

int lot[W];

void init_lots(int w) {
    for (int i=1; i<=w; i++) lot[i] = i;
}

int main() {
    int w, n;
    int a, b, tmp;
    std::cin >> w;
    std::cin >> n;
    init_lots(w);
    for (int i=0; i<n; i++) {
        scanf("%d,%d", &a, &b);
        tmp = lot[a];
        lot[a] = lot[b];
        lot[b] = tmp;
    }
    for (int i=1; i<=w; i++) std::cout << lot[i] << std::endl;
    return 0;
}



Measured memory_bytes: 3252
import Data.Functor( (<$>))
import Control.Monad( replicateM)

main = do
    let
	readLine = (read <$>) . words <$> getLine   ::IO [Int]

    n <- read <$> getLine
    dices <- replicateM n readLine
    let
	isId d1 d2
	  = case matchedState d2 [d1!!0, d1!!1] of
		[]  -> False
		list -> or $ ((drop 2 d1 ==) . (drop 2)) <$> list
	  where
	    matchedState dice [top, front]
	      = filter checkFront checkList
	        where
		    roll d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
		    roll d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
		    roll d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
		    roll d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]

		    rolls d dirs = foldl roll d dirs

		    checkTop d = top == head d
		    checkFront d = front== d!!1
		    rot d = rolls d "ESW"
		    candidate = filter checkTop
				[ dice
				, rolls dice "S"
				, rolls dice "SS"
				, rolls dice "SSS"
				, rolls dice "E"
				, rolls dice "EE"
				, rolls dice "EEE"]
		    checkList = do
			c <- candidate
			[c, rot c, rot.rot $ c, rot.rot.rot $ c]

    if or $ uncurry isId <$>
	[(dices!!ix1, dices!!ix2) | ix1<-[0..n-2], ix2<-[ix1+1..n-1]]
    then putStrLn "No"
    else putStrLn "Yes"



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

const long long MOD = 1000000007LL;

int main(){

    long long d;
    string n;
    cin >> n >> d;
    
    //dp[i][j][k] := 左からi桁目,　桁和がj(mod D), flag, の時の数え上げdp
    vector<vector<vector<long long> > > dp(n.size() + 1, vector<vector<long long> > (d, vector<long long> (2, 0ll)));
    dp[0][0][0] = 1;
    for(int i = 0; i < n.size(); i++){
        for(int j = 0; j < d; j++){
            
            //cout << "( ";
            for(int k = 0; k < 2; k++){
                //cout << dp[i][j][k] << " ";

                int num = (int)(n[i] - '0');
                for(int l = 0; l <= 9; l++){
                    if(k == 0 && l <= num){
                        dp[i + 1][(j + l) % d][l != num] += dp[i][j][k];
                        dp[i + 1][(j + l) % d][l != num] %= MOD;               
                    }else if(k == 1){
                        dp[i + 1][(j + l) % d][k] += dp[i][j][k];
                        dp[i + 1][(j + l) % d][k] %= MOD;
                    }
                }
            }

            //cout << ") ";
        }
        //cout << endl;
    }


    //cout << endl;
    cout << (dp[n.size()][0][0] + dp[n.size()][0][1] - 1 + MOD) % MOD << endl;

    return 0;
}


Measured memory_bytes: 55296
n = int(input())
s = input()
x = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(len(s)):
    if x.index(s[i]) + n > 25:
        print(x[x.index(s[i]) + n - 26], end='')
    else:
        print(x[x.index(s[i]) + n], end='')


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 100000000000;
typedef pair<int,int> P;
typedef long long ll;
struct Sho {
    int X; 
    int Y; 
    Sho(int x, int y) : X(x), Y(y) { }
};
using Graph = vector<vector<Sho>>;

/*
*/

int main() {
  int N;
  cin >> N;
  Graph G(N);

  rep(i,N){
    int A = 0;
    cin >> A;
    rep(j,A){
      int X,Y;
      cin >> X >> Y;
      X--;
      
      G[i].push_back(Sho(X,Y));
    }
  }
  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
     bitset<15> s(tmp);//i番目のビットが1なら、i番目の人は正直者
     // (ビット列sに対する処理)
     
     bool flag = true;
     for(int i = 0;i<N;i++){//人を全探索
       if(s.test(i)){//i番目の人が正直者のとき
         for(Sho Sh : G[i]){//G[i]はi番目の人の発言
           if(s.test(Sh.X) && Sh.Y == 0){//i番目の人が言及する人が、bitでは正直者であるのに、不親切と言ってる場合
             flag = false;
             break;
           }
           if(!s.test(Sh.X) && Sh.Y == 1){//i番目の人が言及する人が、bitでは不親切であるのに、正直者と言ってる場合
             flag = false;
             break;
           }  
         }
       }
     }
    int c = (int)s.count();
    if(flag) ans = max(c,ans);
}

  cout << ans << endl; 
  

}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);
int n, M[N][N];
int D[N];
void bfs(int S) {
	queue<int>Q;
	Q.push(S);
	for (int i = 0; i < n; i++) D[i] = INFTY;
	D[S] = 0;
	int U;
	while (!Q.empty()) {
		U = Q.front(); Q.pop();
		for (int V = 0; V < n; V++) {
			if (M[U][V] == 0) continue;
			if (D[V] != INFTY) continue;
			D[V] = D[U] + 1;
			Q.push(V);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((D[i] == INFTY) ? (-1) : D[i]) << endl;
	}
}
int main() {
	int U, K, V;

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> U >> K;
		U--;
		for (int j = 0; j < K; j++) {
			cin >> V;
			V--;
			M[U][V] = 1;
		}
	}
	bfs(0);
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

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

vector<ll> checklist;

string zero(string ume, ll keta)
{
  while (ume.length() < keta)
  {
    ume = "0" + ume;
  }
  return ume;
}

ll checktolist(ll hoge)
{
  for (int i = 0; i < checklist.size(); i++)
  {
    if (checklist[i] == hoge)
      return i;
  }
  return -1;
}

int main()
{
  while (1)
  {
    string a;
    ll b;
    ll count = 0;

    cin >> a >> b;

    checklist = {stoi(a)};
    if (a == "0" && b == 0)
      exit(0);

    // 0埋め
    string kazu = zero(a, b);

    while (1)
    {
      count++;

      // v: ソート用配列
      vector<char> v;

      // 文字列をvectorに
      for (int i = 0; i < b; i++)
        v.push_back(kazu[i]);

      // sortした
      sort(all(v));

      // 小さい数
      string nekazu;
      for (int i = 0; i < b; i++)
        nekazu += v[i];


      // reverse
      sort(rall(v));

      // 大きい数
      string rekazu;
      for (int i = 0; i < b; i++)
        rekazu += v[i];

      ll hoge = stoi(rekazu) - stoi(nekazu);

//      cout << stoi(rekazu) << " - " << stoi(nekazu) << " = " << hoge << endl;

      if (checktolist(hoge) != -1)
      {
        if (a == "0")
          cout << 0 << " ";
        else
          cout << checktolist(hoge) << " ";
        cout << hoge << " ";
        cout << count - checktolist(hoge) << endl;
        break;
      }

      checklist.push_back(hoge);

      kazu = zero(to_string(hoge), b);
    }
  }
}


Measured memory_bytes: 3212
# coding: utf-8
# Your code here!

A, B, C, D = map(int, input().split())

# 上皿天秤が左に傾くなら Left を、釣り合うなら Balanced を、右に傾くなら Right を出力してください。

if (A + B) == (C + D):
    print('Balanced')    
elif (A + B) > (C + D):
    print('Left')    
else:
    print('Right')

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


//int main()
//{
//    int x, a, b,k,l,syou;
//    bool ok = false;
//    int ans1 = 0;
//    int ans2 = 0;
//    cin >> x;
//
//    if (x >= 0) {
//        for (int i = 1; i <= x; i++) {
//            if (x % i != 0) {
//                continue;
//            }
//            else {
//                syou = x / i;
//                b = -x;
//                while (true) {
//                    a = b + i;
//                    k = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b + b * b * b * b;
//                    if (k == syou) {
//                        ans1 = a;
//                        ans2 = b;
//                        ok = true;
//                        break;
//                    }
//                    if (b > k)break;
//                    b++;
//                }
//                if (ok)break;
//            }
//
//        }
//
//    }
//    else {
//
//        x = abs(x);
//        for (int i = 1; i <= x; i++) {
//            if (x % i != 0) {
//                continue;
//            }
//            else {
//                syou = x / i;
//                a = -x;
//                while (true) {
//                    b = a + i;
//                    k = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b + b * b * b * b;
//                    if (k == syou) {
//                        ans1 = a;
//                        ans2 = b;
//                        ok = true;
//                        break;
//                    }
//                    if (a > k)break;
//                    a++;
//                }
//            }
//            if (ok)break;
//        }
//
//
//    }
//
//    cout << ans1 << " " << ans2 << endl;
//    return 0;
//}

int main() {
	int x;
	bool ok = false;
	int a, b;
	cin >> x;
	int left;
	for ( a = -118; a <= 119; a++) {
		for ( b = -119; b <= 118; b++) {
			left = a * a * a * a * a - b * b * b * b * b;
			if (left == x) {
				ok = true;
				break;
			}
			
		}
		if (ok)break;
	}

	cout << a << " " << b << endl;
}

Measured memory_bytes: 3172
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
        if(n == 3 || n == 5 || n == 7) {
          System.out.println("YES");
        }else {
          System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    int X, A, B;
    if (scanf("%d%d%d", &X, &A, &B) < 3) return 0;

    printf("%d\n", (X - A) % B);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

const int INF = (1LL << 25);

template<typename T>
class LazySegTree {
public:
    explicit LazySegTree(int n, T init, T def) : N(calcN_(n)), def(def) {
        mVal.assign(2*N+1, init);
        mLazy.assign(2*N+1, 0);
        mDirty.assign(2*N+1, 0);
    }
    void update(int l, int r, T value){
        updateImpl_(l, r, value, 0, 0, N);
    }
    T get(int l, int r){
        return getImpl_(l, r, 0, 0, N);
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, T value, int idx, int rangeL, int rangeR){
        eval_(idx, rangeL, rangeR);
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            setLazy_(idx, value);
            eval_(idx, rangeL, rangeR);
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
            mVal[idx] = operate_(mVal[2*idx+1], mVal[2*idx+2]);
        }
    }
    void setLazy_(int idx, T value){
        mLazy[idx] = value;
        mDirty[idx] = 1;
    }
    T getImpl_(int l, int r, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return def;
        eval_(idx, rangeL, rangeR);
        if(l <= rangeL && rangeR <= r) return mVal[idx];
        int rangeM = (rangeL+rangeR)/2;
        T a = getImpl_(l, r, 2*idx+1, rangeL, rangeM);
        T b = getImpl_(l, r, 2*idx+2, rangeM, rangeR);
        return operate_(a, b);
    }
    void eval_(int idx, int rangeL, int rangeR){
        if(!mDirty[idx]) return;
        mVal[idx] = mLazy[idx];
        if(idx < N-1){
            setLazy_(2*idx+1, mLazy[idx]);
            setLazy_(2*idx+2, mLazy[idx]);
        }
        mLazy[idx] = 0;
        mDirty[idx] = 0;
    }
    T operate_(T a, T b) const { return min(a, b); }
    const int N;
    const T def;
    vector<T> mVal;
    vector<T> mLazy;
    vector<int> mDirty;
};

int main(){
    int H, W; cin >> H >> W;
    LazySegTree<int> seg(W, 0, INF);
    for(int i=1;i<=H;i++){
        int A, B; cin >> A >> B;
        --A;
        if(B < W && seg.get(0, B+1) < INF){
            int L = 0, R = B+1;
            while(R-L > 1){
                int mid = (L+R)/2;
                if(seg.get(mid, B+1) < INF) L = mid;
                else R = mid;
            }
            seg.update(B, B+1, seg.get(L, L+1)+B-L);
        }
        seg.update(A, B, INF);
        int res = seg.get(0, W);
        cout << (res < INF ? res + i : -1) << endl;
    }
}

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

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

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

    string t;
    cin >> t;
    for (char c : t) {
        if (c == '?') {
            cout << 'D';
        } else {
            cout << c;
        }
    }
    cout << endl;

    return 0;
}



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

int main(){
  
 string s;
  cin >> s;
  
  int acount = 0;
  int zcount = 0;
  
  for(int i = 0; i < s.size(); i++){
    acount++;
    if(s.at(i) == 'A'){ 
      break;
    }
  }
    reverse(s.begin(),s.end());
  
  for(int i = 0; i < s.size(); i++){ 
    zcount++;   
    if(s.at(i) == 'Z'){
      break;
    }
  }

  cout << s.size() - acount - zcount + 2 << endl;
}

 

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int x, a;
    cin >> x >> a;
    if(x < a) puts("0");
    else puts("10");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int n,d;
  cin >> n >> d;
  double x, y;
  int count = 0;
  rep(i, n){
    cin >> x >> y;
    double tmp = (x*x) + (y*y);
    if(sqrt(tmp) <= d){
      count++;
    }
  }
  cout << count << endl;
  
  
  return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
 
 
int main(void){
	int a,b,k;
	int ans[105];
	cin>>a>>b>>k;
	rep(i,min(a,b)+1){
		if(i==0){
			continue;
		}
		if(a%i==0 && b%i==0){
			ans[i] = true;
		}else{
			ans[i] = false;
		}
	}

	rep(i,min(a,b)){
		if(ans[min(a,b)-i]){
			if(k==1){
				cout<<min(a,b)-i<<endl;
				return 0;
			}else{
				k--;
			}
		}
	}

 
	return 0;
}

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

using namespace std;

int main(){
  
  int X,N;
  cin>>X>>N;
  
  int ans1 = X;
  int ans2 = X;
  int p[N];

  for(int i=0; i<N; i++) cin>>p[i];
  
  for(int j=0; j<100; j++){
    for(int i=0; i<N; i++){
      if(p[i]==ans1){
        ans1++;
        break;
      }
    }
  }

  for(int j=0; j<100; j++){
    for(int i=0; i<N; i++){
      if(p[i]==ans2){
        ans2--;
        break;
      }
    }
    if(ans2<0){
      break;
    }
  }
  
  if(abs(X-ans2)<=abs(X-ans1)){
    cout<<ans2<<endl;
  } else{
    cout<<ans1<<endl;
  }

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N=2e5+10; 
int h[N];
map<int,int>mp;
signed main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		int j=i-h[i];
		sum += mp[j];
		
		mp[h[i]+i]++;
	}
	cout << sum<<endl;
	return 0;
}


Measured memory_bytes: 27696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

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

    //2つ目の条件を満たすRGBの組み合わせの個数
    ll hiku = 0;
    rep(i, n)
    {
        rep(j, n)
        {
            if (i + 2 * j >= n)
                break;
            if (s[i] != s[i + j] && s[i] != s[i + 2 * j] && s[i + j] != s[i + 2 * j])
                hiku++;
        }
    }

    ll r = 0, g = 0, b = 0;
    rep(i, n)
    {
        if (s[i] == 'R')
            r++;
        if (s[i] == 'G')
            g++;
        if (s[i] == 'B')
            b++;
    }

    cout << r * g * b - hiku << endl;
}

Measured memory_bytes: 3600
main :: IO ()
main = do
  _ <- getInt
  xs <- getInts
  print . sum . map f $ xs
  where
    f = length . takeWhile even . iterate (`div` 2)

getInt :: IO Int
getInt = read <$> getLine

getInts :: IO [Int]
getInts = map read . words <$> getLine


Measured memory_bytes: 7548
# https://beta.atcoder.jp/contests/abc104/tasks/abc104_b

import re


def solve():
    S = input()

    if S[0] == 'A' and S[2:-1].count('C') == 1:
        if S.replace('A', '').replace('C', '').islower():
            print('AC')
            exit()

    print('WA')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188