akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  IN(k);
  string s;
  cin >> s;
  int temp=1;
  int c=0;
  vector<int> v;
  REP(i,n){
    if (s[i]==(temp==1 ? '1' : '0')) c++;
    else {
      v.push_back(c);
      temp=1-temp;
      c=1;
    }
    if (i==n-1) v.push_back(c);
  }
  // REP(i,v.size()){
  //   cout<<v[i]<<',';
  // }
  //even index: '1'     odd: '0'
  int m=v.size()/2;
  int maxN=0;
  if (m<=k) maxN=accumulate(ALL(v), 0);
  else{
    REP(i,m-k+1){
      if (2*(i+k)>=v.size())
	maxN=max(maxN, accumulate(v.begin()+2*i, v.begin()+2*(i+k), 0));
      else
	maxN=max(maxN, accumulate(v.begin()+2*i, v.begin()+2*(i+k)+1, 0));
    }
  }
  cout<<maxN<<endl;
}


Measured memory_bytes: 1020
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int a, b;

	scanf("%d%d", &a, &b);
	if (a <= 5) {
		puts("0");
	}
	else if (a <= 12) {
		PRINTD(b / 2);
	}
	else {
		PRINTD(b);
	}
}


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

#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define F first
#define S second
#define all(v) v.begin(),v.end()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif

    ll t=1,tc;
    //cin>>t;
    for(tc=1;tc<=t;tc++){
      string s,v;
      ll n,i,l,r,c=0;
      cin>>n>>s;
      v=s;
      sort(all(v));
      if(v[0]==v[n-1]){
          cout<<"0";
          continue;
      }
      l= 0; r= n-1;
      while(l<=r){
          if(s[l]=='W' && s[r]=='R'){
              c++;
              swap(s[l],s[r]);
          }
          else if(s[l]=='R')
           l++;
          else if(s[r]=='W')
           r--;
      }
      cout<<c;
    }
	return 0;
}

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

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

  int i = 0, j = s.length()-1;
  int ans = 0;
  while (1) {
    int c1 = 0;
    while (s[i] == 'x') {
      ++c1;
      ++i;
    }
    int c2 = 0;
    while (s[j] == 'x' && j > -1) {
      ++c2;
      --j;
    }

    if (i == j) {
      ans += abs(c1 - c2);
      break;
    }
    if (i > j) { break; }
    if (s[i] != s[j]) {
      ans = -1;
      break;
    }

    ans += abs(c1 - c2);
    ++i;
    --j;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  int ans=0;
  cin>>p[0];
  int cnt=1;
  
  repo(i,n){
  cin>>p[i];
    if(p[i]!=p[i-1]) {
      ans+=cnt/2;
      cnt=1;
    }
    else cnt++;
  }
    
  ans+=cnt/2;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,k;
	cin>>n>>k;
	double score = 0;
	for(int i=1;i<=n;i++) {
		int coin = i;
		int cnt = 0;
		while(coin<k) {
			coin=coin*2;
			cnt++;
		}
		score+=(1.0d/n)*pow(0.5d,cnt);
	}
	if(n<=k)
	printf("%.09lf",score);
	else printf("%.09lf",score);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	int n, k; cin >> n >> k;
	cout << n-k+1 << endl;
    system("pause");
}


Measured memory_bytes: 504
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String steps = br.readLine();
		boolean often_pattern = true;

		for(int i = 1; i <= steps.length(); i++){
			char step = steps.charAt(i-1);
			if(i % 2 == 0){
				if(step == 'R'){
					often_pattern = false;
					break;
				}
			} else {
				if(step == 'L'){
					often_pattern = false;
					break;
				}
			}
		}

		String answer;
		if(often_pattern){
			answer = "Yes";
		} else {
			answer = "No";
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 21332
#include<stdio.h>

int main(){
	int n,x;
	int count;
	int i,j,k;
	
	while(1){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)   break;
		
		count=0;
		for(i=1;i<=n-2;i++){
			for(j=i+1;j<=n-1;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k == x)   count++;
				}
			}
		}
		printf("%d\n",count);
		count=0;
	}
	
	return 0;
}

Measured memory_bytes: 600
S = str(input())

S = list(S)

R = [] 
for i in S:
  R.append(i)
# print(R)

t = len(R) -2

a = 0
b = 3
min = 643

for i in range(t):
  n = R[a:b]
  # print(n)

  n = "".join(n)
  # print(n)
  z = abs(753 - int(n))
  if z < min:
    min = z

  a +=1
  b +=1

print(min)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    
    for(int i=0;i<N;i++){
        int ball[10];
        bool isYES=true;
        int b=0, c=0;

        for(int j=0;j<10;j++)cin>>ball[j];

        for(int j=0;j<10;j++){
            if(ball[j]>b){
                b=ball[j];
            }else if(ball[j]>c){
                c=ball[j];
            }else{
                isYES=false;
                break;
            }
        }

        cout<<(isYES?"YES":"NO")<<endl;
    }

    return 0;
}


Measured memory_bytes: 3084
use std::cmp::*;
use std::io::*;
const MOD: usize = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut g = vec![Vec::new(); n];
    for _ in 1..n {
        let a = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let b = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        g[b].push(a);
    }

    let mut ans = k;
    let mut q = std::collections::VecDeque::new();
    let mut d = vec![1; n];
    q.push_back((0, 0));
    while let Some((v, p)) = q.pop_front() {
        for i in 0..g[v].len() {
            if v != p && i == g[v].len() - 1 {
                break;
            }
            ans = ans * (k - i - min(2, d[v])) % MOD;
        }
        for &nv in g[v].iter() {
            if nv != p {
                d[nv] = d[v] + 1;
                q.push_back((nv, v));
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 18684
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

vector<int> g[100100];

bool done[100100][2];
ll memo[100100][2];

ll solve(int i, int c, int p){
	int j,v;
	if(done[i][c]){
		return memo[i][c];
	}
	done[i][c] = true;
	memo[i][c] = 1ll;
	for(j=(g[i].l_ength()-1); j>=0; --j){
		v = g[i][j];
		if(v==p){
			continue;
		}
		mul_mod(memo[i][c],((c)?(solve(v,0,i)):((solve(v,0,i)+solve(v,1,i))%MOD)));
	}
	return memo[i][c];
}

int main(void){
	int i,n,x,y;
	fill(done[0],done[100100],false);
	cin >> n;
	for(i=1; i<n; ++i){
		cin >> x >> y;
		--x; --y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	cout << ((solve(0,0,-1)+solve(0,1,-1))%MOD) << endl;
	return 0;
}


Measured memory_bytes: 17152
import java.util.Scanner;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int [] d = new int [20];
		int dmax;
		
		dmax = input (d);
		
		for (int i = 0; i < dmax; i++) {
			integration(d[i]);
		}
	}
	
	private static int input (int [] d)
	{
		int i = 0;
		
		Scanner cin = new Scanner (System.in);
		while (cin.hasNext()) {
			d[i] = cin.nextInt();
			i++;
		}
		
		return (i);
	}
	
	private static void integration (int d) 
	{
		int end = (600 - d) / d;
		int c = 0;
		
		for (int i = 1; i <= end; i++) {
			c += d * f(i * d);
		}
		
		System.out.println(c);
	}
	
	private static int f (int a) 
	{
		return (a * a);
	}
}

Measured memory_bytes: 25812
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    double d;
    cin >> d;
    double pos[11];
    for (int i = 0; i <= 10; i++) {
        if (i > d) {
            pos[i] = -1;
            continue;
        }
        pos[i] = sqrt(d * d - i * i);
    }
    double dis[11];
    for (int i = 0; i <= 10; i++) {
        if (pos[i] == -1) {
            dis[i] = -1;
            continue;
        }
        if (i > 0 && pos[i] < 1) {
            dis[i] = i * 1.0 + 1;
        } else {
            dis[i] = i * 1.0 + pos[i];
        }
    }
    double ans = 0;
    for (int i = 0; i <= 10; i++) {
        if (ans < dis[i]) {
            ans = dis[i];
        }
    }
    ans = max(ans, d * sqrt(2));
    cout << setprecision(12);
    cout << ans << endl;
}



Measured memory_bytes: 3284
integer(16)N,ans
read*,N
if(N==10.or.N==100.or.N==1000.or.N==10000.or.N==100000)then
  ans=10
else
  ans=0
  do i=4,0,-1
    ans=ans+N/(10**i)
    N=N-(N/10**i)*(10**i)
  end do
endif
print"(i0)",ans
    
end

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(){
  int a,b,c,x,i=0;
  scanf("%d %d %d",&a,&b,&c);
  x = a%b;
  for(i=0;i<=200;i++){
    if(c == (x*i)%b){
      i = 1000;
      printf("YES\n");
    }
  }
  if(i==201){
    printf("NO\n");
  }
  return 0;
}

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

int main() {
  int N, K, num;
  cin >> N >> K;
  num = 1;
  for(int i = 0; i < N; i++) {
    int a, b;
    a = num * 2;
    b = num + K;
    if (a <= b) {
      num = a;
    }
    else {
      num = b;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
        int n,k; int cnt=0;
        cin >> n >> k;
        int a[n]; int c[n+1]={200002};
        for(int i=0; i<n; i++) {
                cin >> a[i];
                c[a[i]]++;
        }
        sort(c,c+n+1);
        for(int i=0; i<n+1; i++) {
                if(c[i]!=200002) cnt++;
                if(c[i]==200002) break;
        }
        int m=cnt-k; int ans=0;
        for(int i=0; i<m; i++) {
                ans+=c[i];
        }
        cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define in insert
#define mk make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define INF (1<<28)
#define all(a) a.begin(),a.end()
typedef long long int ll;typedef long int l; typedef pair<int, int> pii;
const double PI = acos(-1);

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    vector<int> overall(3,0);
    int n;cin>>n;
    for(int i=0;i<n;++i){
        vector<int> local(3,0);
        vector<int> cost(3);
        for(int i=0;i<3;i++)    cin>>cost[i];
        for(int i=0;i<3;++i){
            for(int j=0;j<3;++j){
                if(i != j){
                    local[j] = max(local[j], overall[i]+cost[j]);
                }
            }
        }
        overall = local;
    }
    cout<<max(overall[0], max(overall[1], overall[2]))<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int h, n;
    cin >> h >> n;
    vector<pi> mag(n);
    for (int i = 0; i < n;++i) cin >> mag[i].first >> mag[i].second;
    vector<int> dp(h+1,-1);
    dp[0] = 0;
    for (int dmg = 0; dmg < h;++dmg){
        if (dp[dmg] < 0) continue;
        for(int i=0;i<n;++i){
            int next = min(dmg + mag[i].first,h);
            if (dp[next] < 0) dp[next] = dp[dmg] + mag[i].second;
            else dp[next] = min(dp[next], dp[dmg] + mag[i].second);
        }
    }
    cout << dp[h];
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long


const int INF = 1e9 + 5;
int main()
{
	load;
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	for (int i=0; i<n;i++){
		cin >> v[i];
	}
	vector<int> dp(n, INF); //cost to reach certain index
	dp[0] = 0;
	for (int i=0; i<n;i++){
		for (int j=i+1; j<=i+k; j++){
			if(j<n){
				dp[j] = min(dp[j], dp[i]+ abs(v[i]- v[j]));
			}
		}
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


map<LL,LL> factorize(LL val){
    assert(val > 0);
    map<LL,LL> factor;
    while(val % 2 == 0){
        val /= 2;
        factor[2]++;
    }
    while(val % 5 == 0){
        val /= 5;
        factor[5]++;
    }
    return factor;
}


LL read_float(){
    string s;
    cin >> s;
    LL ans = 0;
    bool flag = false;
    LL d = 0;
    for(LL i = 0; i < s.size(); ++i){
        if(s[i] == '.'){
            flag = true;
            continue;
        }
        if(flag) d += 1;
        ans *= 10;
        ans += s[i] - '0';
    }
    for(LL i = d; i < 9; ++i){
        ans *= 10;
    }
    return ans;
}

int main(){
    LL n;
    cin >> n;
    vector<pair<LL,LL>> cand;
    for(LL i = 0; i < n; ++i){
        LL d2 = read_float();
        //cerr << "d2=" << d2 << endl;
        map<LL,LL> f = factorize(d2);
        cand.emplace_back(f[2], f[5]);
    }
    sort(cand.begin(), cand.end());
    vector<LL> part(19);
    LL cur = n-1;
    LL ans = 0;
    //cerr << cand << endl;
    for(LL i = 0; i < n; ++i){
        while(cand[i].first + cand[cur].first >= 18 and i < cur){
            ++part[min<LL>(18, cand[cur].second)];
            --cur;
        }
        for(LL j = 0; j < 19; ++j){
            if(cand[i].second + j >= 18) ans += part[j];
        }
        //cerr << "debug " << ans << " " << cur << " " << part << endl;
        if(i == cur){
            ++cur;
            if(cur < n){
                --part[min<LL>(18, cand[cur].second)];
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7376
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		while (h-->0) {
			String tok = sc.next();
			System.out.println(tok);
			System.out.println(tok);
		}
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 37392
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define cin1(x) scanf("%d",&x)
#define cin2(x,y) scanf("%d%d",&x,&y)
#define cin3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define rr read()
#define ll long long
#define CloseIo ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int N = 1e3 + 5;
int main(){
	CloseIo;
	int a,b;
	cin>>a>>b;
	long long k=a+b;
	if(k%2==0)
		cout<<k/2<<"\n";
	else
		cout<<"IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define INF 9999999
#define uint unsigned int
#define ms(a) memset(a,0,sizeof(a))
#define ll long long
#define lb lower_bound
using namespace std;
#define MAXN 100010
int n,D,a,b;
class Dot{
public:
int x;int y;int id;
void read(int i){
scanf("%d%d",&x,&y);
id=i;
}
void rotate(){
int xx=x+y,yy=x-y;
x=xx;y=yy;
}
void chg(){
swap(x,y);
}
};Dot dot[MAXN];
Dot getdot(int x,int y,int id){
Dot d1;
d1.x=x;d1.y=y;d1.id=id;
return d1;
}
bool operator<(Dot d1,Dot d2){
if(d1.x!=d2.x)return d1.x<d2.x;
if(d1.y!=d2.y)return d1.y<d2.y;
return d1.id<d2.id;
}
int dsu[MAXN];
void init(){
for(int i=1;i<=n;i++)
dsu[i]=i;
}
int getfa(int pos){
if(dsu[pos]==pos)return pos;
dsu[pos]=getfa(dsu[pos]);
return dsu[pos];
}
void unite(int a,int b){
a=getfa(a);b=getfa(b);
dsu[a]=b;
}
int same(int a,int b){
return getfa(a)==getfa(b);
}
int s(int v){
if(v)return INF;
return v;
}
int du[MAXN];
void getdu(){
ms(du);
for(int j=0;j<2;j++){
sort(dot,dot+n);
for(int i=0;i<n;i++)
du[dot[i].id]+=
(lb(dot,dot+n,getdot(dot[i].x-D,dot[i].y+D,s(!j)))-dot)-
(lb(dot,dot+n,getdot(dot[i].x-D,dot[i].y-D,s(j)))-dot)+
(lb(dot,dot+n,getdot(dot[i].x+D,dot[i].y+D,s(!j)))-dot)-
(lb(dot,dot+n,getdot(dot[i].x+D,dot[i].y-D,s(j)))-dot)
;
if(j==1)return;
for(int i=0;i<n;i++)dot[i].chg();
}
}
void getlian(){
init();
int sum[MAXN];
for(int j=0;j<2;j++){
ms(sum);
sort(dot,dot+n);
for(int i=0;i<n;i++){
int u=lb(dot,dot+n,getdot(dot[i].x-D,dot[i].y-D,0))-dot;
int d=lb(dot,dot+n,getdot(dot[i].x-D,dot[i].y+D,INF))-dot;
if(u==d)continue;
unite(dot[u].id,dot[i].id);
sum[u]++;sum[d-1]--;
}
for(int i=0;i<n;i++){
if(i)sum[i]+=sum[i-1];
if(sum[i])unite(dot[i].id,dot[i+1].id);
}
if(j==1)return;
for(int i=0;i<n;i++)dot[i].chg();
}
}
int main(){
scanf("%d%d%d",&n,&a,&b);
for(int i=0;i<n;i++)
dot[i].read(i);
a--;b--;
D=abs(dot[a].x-dot[b].x)+abs(dot[a].y-dot[b].y);
for(int i=0;i<n;i++)
dot[i].rotate();
getdu();
getlian();
ll ans=0;
for(int i=0;i<n;i++)
if(same(i,a))
ans+=du[i];
ans/=2;
printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long n,z,w;
	cin >> n >> z >> w;
	vector<long long> a(n);
	for(long long i=0;i<n;i++)
		cin >> a[i];
	if(n==1)
		cout << abs(a[0]-w) << endl;
	else
		cout << max(abs(a[n-1]-a[n-2]),abs(a[n-1]-w)) << endl;;




}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(), (x).end()

int N,M;
char A[1000][1000], B[1000][1000], C[1000][1000], S[1000][1000];
int main(){
	scanf("%d%d",&N,&M);
	repp(i,N) scanf("%s",S[i]+1);

	repp(i,N) repp(j,M) A[i][j] = B[i][j] = S[i][j];
	repp(i,M) A[1][i] = B[N][i] = '#';
	for(int j=2;j<=M-1;j++){
		if( j%2 == 0 ){
			for(int i=1;i<=N-1;i++) A[i][j] = '#';
		}
		else{
			for(int i=2;i<=N;i++) B[i][j] = '#';
		}
	}

	repp(i,N){
		repp(j,M) printf("%c",A[i][j]);
		printf("\n");
	}
	printf("\n");
	repp(i,N){
		repp(j,M) printf("%c",B[i][j]);
		printf("\n");
	}

	// printf("\n");
	// repp(i,N){
	// 	repp(j,M){
	// 		if( A[i][j] == '#' && B[i][j] == '#' ) printf("#");
	// 		else printf(".");
	// 	}
	// 	printf("\n");
	// }
}





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

namespace ABC139
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(decimal.Parse);
            var A = input.First();
            var B = input.Skip(1).First();

            Console.WriteLine(Math.Ceiling((B - 1) / (A - 1)));
        }
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

class UF {
private:
	vector<int> par;
	vector<int> sz;

public:
	UF(int n){ 
		par = vector<int>(n);
		sz = vector<int>(n);
		for(int i = 0; i < n; i++){
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if (sz[x] < sz[y]) swap(x,y);
		par[y] = x;
		sz[x] += sz[y];
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

int main() {
	int n,m,k;
	cin >> n >> m >> k;
	int v1[n+10] = {},v2[n+10] = {};
	UF uf(n+10);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		v1[a]++;
		v1[b]++;
		uf.unite(a,b);
	}

	rep(i,k){
		int c,d;
		cin >> c >> d;
		if(uf.same(c,d)){
			v2[c]++;
			v2[d]++;
		}
	}
	for(int i = 1; i <= n; i++){
		cout << uf.size(i)-1-v1[i]-v2[i] << (i!=n ? ' ':'\n');
	}

	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main() {
    string s;
    cin>>s;
    if(s[0]=='9'||s[1]=='9') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    cout << A[0] * A[1] / 2 << endl;
}


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

int main()
{
  char x, xx;
  int y, m, d;

  cin >> y >> x >> m >> xx >> d;

  if(m<=4){
    cout << "Heisei";
  }
  else
  {
    cout << "TBD";
  }

}


Measured memory_bytes: 3596
import java.io.*;
import java.util.*;
class Main{
 public static void main(String[] args) throws IOException {
        // TODO code application logic here
         BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
       
              int t = Integer.parseInt(bf.readLine()); 
      int ac=0,wa=0,tle=0,re=0;
   while(t-->0){
  String s = bf.readLine();
     if(s.equals("AC"))
       ac++;
     else if(s.equals("WA"))
       wa++;
     else if(s.equals("TLE"))
       tle++;
     else
       re++;
     
     
   }
  
 
     System.out.println("AC x "+ac);
     System.out.println("WA x "+wa);
     System.out.println("TLE x "+tle);
     System.out.println("RE x "+re);
   
  
        
 }
  
  
  
}

Measured memory_bytes: 42760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scan = new Scanner(System.in)) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			int div = a / b;
			int rem = a % b;
			double flo = (double)a / (double)b;

			String f = String.format("%.5f",flo);
			System.out.println(div + " " + rem + " " + f);
		}
	}
}

Measured memory_bytes: 26456
n, c, k = map(int, input().split())
T = sorted([int(input()) for i in range(n)])

ans = 0
t_lim = 0
cnt = 0
for t in T:
    cnt += 1
    if t_lim == 0:
        t_lim = t+k
    if t > t_lim:
        ans += 1
        t_lim = t+k
        cnt = 1
    if cnt == c:
        ans += 1
        t_lim = 0
        cnt = 0
if cnt != 0:
    ans += 1
print(ans)


Measured memory_bytes: 8276
S = list(input())
Q = int(input())
q = [list(input().split()) for _ in range(Q)]
head = []
tail = []
flip = 0
for i in range(len(q)):

    if q[i][0] == "1":
        flip ^= 1
    else:
        if flip == 0 and q[i][1] == "1":
            head.append(q[i][2])
        elif flip == 0 and q[i][1] == "2":
            tail.append(q[i][2])
        elif flip == 1 and q[i][1] == "1":
            tail.append(q[i][2])
        else:
            head.append(q[i][2])

if flip == 0:
    ans = "".join(head[::-1] + S + tail)
    # print(head)
    # print(S)
    # print(tail)
    print( ans )
else:
    ans = "".join(tail[::-1] + S[::-1] + head)
    print( ans )



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

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int count = 0;
  for(int i=0; i<1000; i++){
    string x = to_string(i);
    if(x.size()==1) x = "00" + x;
    if(x.size()==2) x = "0" + x;
    
    bool keta3=false,keta2=false,keta1=false;
    
    for(int j=0; j<n; j++){
      if(x[0]==s[j] && keta3==false){
        keta3=true;
        continue;
      }
      if(x[1]==s[j] && keta3==true && keta2==false){
        keta2=true;
        continue;
      }
      if(x[2]==s[j] && keta3==true && keta2==true){
        keta1=true;
        count++;
        break;
      }
    }

  }
  
  cout << count << endl;
  
  return 0;
}

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

typedef long long int ll;

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

    ll a,b;
    cin>>a>>b;
    if(a==b)
        {cout<<"0";
        return 0;}

    double c = (a+b)/2.0;
    ll k = (a+b)/2;
    if(c==k)
        cout<<k;
    else
        cout<<"IMPOSSIBLE";

    return 0;
}


Measured memory_bytes: 256
import java.util.*
import java.math.*

fun main(args: Array<String>) {

//    var (N, K) = readLine()!!.split(" ").map { it.toLong() }
    var N = readLine()!!.toLong()
//    val S = readLine()!!

    val list = mutableListOf<Pair<Long,Long>>()
    for (n in 0 until N) {
        val (A, B) = readLine()!!.split(" ").map { it.toLong() }
        list.add(A to B)
    }
    list.sortBy { it.second }
    var time = 0L
    for ((a,b) in list) {
        time += a
        if (time > b) {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 133920
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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


const ll mod = 1000000007;
ll fact[210200];
ll invfact[210200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    if(k == 0){
        return 1;
    }
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


ll N, M, K;
ll calc(ll i, ll j){
    ll res = 0;
    res = add(res, (N-i+M-j-2)*(N-i)*(M-j) / 2);
    res = add(res, (M-j+i-1)*(i+1)*(M-j) / 2);
    res = add(res, (N-i+j-1)*(j+1)*(N-i) / 2);
    res = add(res, (i+j)*(i+1)*(j+1) / 2);
    res = sub(res, (N-i-1)*(N-i)/2);
    res = sub(res, (M-j-1)*(M-j)/2);
    res = sub(res, (j+1)*j/2);
    res = sub(res, (i+1)*i/2);

    return res;
}


int main(){
    cin >> N >> M >> K;

    ll res = 0;
    make_fact(210000);
    make_invfact(210000);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            res = add(res, mul(calc(i, j), comb(N*M-2, K-2)));
        }
    }

    res = mul(res, mod_inv(2));

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)

int main(){
    ll x;cin>>x;
    ll a=100;
    ll sum=0;

    rep(i,10000){
    sum++;
        a=a*1.01;
        if(a>=x)break;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3632
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  if(n==25)
    cout<<"Christmas"<<endl;
  else if(n==24)
    cout<<"Christmas Eve"<<endl;
  else if(n==23)
    cout<<"Christmas Eve Eve"<<endl;
  else if(n==22)
    cout<<"Christmas Eve Eve Eve"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;
const int INF = 0x3f3f3f3f;
int k,x;
int main(){
	scanf("%d%d",&k,&x);
	for(int i=x-k+1; i<=x+k-1; i++){
		printf("%d ",i);
	}
	return 0;
}


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

namespace ABC128
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int P = int.Parse(s[1]);
            
            Console.WriteLine((A * 3 + P) / 2);
        }
    }
}

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

int main() {
    int h,w,sy,sx,gy,gx;
    cin>>h>>w>>sy>>sx>>gy>>gx;
    sy--,sx--,gy--,gx--;
    string s[h];
    for (int i=0;i<h;i++)
        cin>>s[i];
    int dis[h][w];
    rep(i,h) rep(j,w) dis[i][j]=1e9;
    dis[sy][sx]=0;
    deque<pair<int,int>> q;
    q.push_back({sy,sx});
    int dy[]={0,0,-1,1},dx[]={-1,1,0,0};
    while (q.size()) {
        auto a=q.front();q.pop_front();
        int y=a.first,x=a.second;
        rep(i,4) {
            int ny=y+dy[i],nx=x+dx[i];
            if (0<=ny&&ny<h&&0<=nx&&nx<w&&s[ny][nx]=='.'&&dis[y][x]<dis[ny][nx]) {
                dis[ny][nx]=dis[y][x];
                q.push_front({ny,nx});
            }
        }
        for (int i=-2;i<=2;i++) for (int j=-2;j<=2;j++) {
            int ny=y+i,nx=x+j;
            if (0<=ny&&ny<h&&0<=nx&&nx<w&&s[ny][nx]=='.'&&dis[y][x]+1<dis[ny][nx]) {
                dis[ny][nx]=dis[y][x]+1;
                q.push_back({ny,nx});
            }
        }
    }
    if (dis[gy][gx]==1e9)
        cout<<-1<<endl;
    else
        cout<<dis[gy][gx]<<endl;
    return 0;
}

Measured memory_bytes: 9380
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)      ((int)(n).size())
#define all(n)     (n).begin(), (n).end()
#define anal         '\n'
#define mod 1000000007
#define fst first
#define sec second
#define pr(n) cerr << n  << " ";
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
       int n;
       cin >> n;
       string s;
       cin >> s;
       if(n&1){
           cout << "No\n";
           return 0;
       }
       bool ans = true;
       for(int i = 0; i < n/2; i++){
            if(s[i] != s[n/2 + i]){
                 ans = false;
                 break;
            }
       }
       if(ans){
          cout << "Yes\n";
       }
       else{
           cout << "No\n";
       }




//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>A(N+1); rep(i, 0, N+1) { cin >> A[i]; }
	vector<int>B(N); rep(i, 0, N) { cin >> B[i]; }

	auto solve = [N](vector<int>A, vector<int>B) {
		int ans = 0;
		rep(i, 0, N) {
			int m = min(A[i], B[i]);
			A[i] -= m;
			B[i] -= m;
			ans += m;

			int n = min(A[i + 1], B[i]);
			A[i + 1] -= n;
			B[i] -= n;
			ans += n;
		}
		return ans;
	};


	int ans = solve(A, B);
	reverse(all(A));
	reverse(all(B));
	int ans2 = solve(A, B);

	cout << max(ans, ans2) << endl;
	

	return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int ans=0;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        ans += min(k-x, x);
    }
    cout << 2*ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    int i = 1;
    int x;
    while (true) {
        cin >> x;
        if (x == 0)
            break;

        printf("Case %d: %d\n", i, x);
        i++;
    }

    return 0;
}


Measured memory_bytes: 3204
#include <stdio.h>

int main (void)
{
int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if (0<=x-r && x+r<=W && 0<=y-r && y+r<=H)
  puts("Yes");
else
  puts("No");

return 0;
}


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

int main() {
  string S;
  cin >> S;
  vector<string> vec(S.size());
  bool flag = true;
  for (int i = 0; i < S.size(); i++) {
    vec.at(i) = S.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < S.size() - 1; i++){
    if (vec.at(i) == vec.at(i + 1)) {
      flag = false;
    }
  }
  if (flag == true) {
    cout << "yes" << endl;
  }
  else {
    cout << "no" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int flag = 0;
        for(int i=0 ; i<=x ; i++){
            if((2*x+2*i)==y){
                System.out.println("Yes");
                flag=1;
                break;
            }
        }
        if(flag == 0){
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 35688
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long ll;

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


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

int main(void)
{
	char s1[10],s2[10],s3[10];
	scanf("%s%s%s",s1,s2,s3);
	int a,b;
	a=strlen(s1);
	b=strlen(s2);
	if(s1[a-1] == s2[0] && s2[b-1] == s3[0])
		{printf("YES");}
	else
		{printf("NO");}
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<vector>
#include<map>
#include<functional>
#include<algorithm>

using namespace std;
typedef pair<int,int> P;
int n,m,p,a,b;
int t[20];
vector<P> G[35];
double dp[31][1<<8];

class data{
public:
	int v,bit;
	double cost;
	bool operator<(const data &d1)const{
		return d1.cost<cost;
	}
};

double dijk(){
	priority_queue<data> que;
	data ind;
	for(int i=0;i<=m;i++){
		for(int j=0;j<(1<<8);j++){
			dp[i][j]=-1.0;
		}
	}
	ind.v=a;
	ind.cost=0.0;
	ind.bit=0;
	que.push(ind);
	double res=-1.0;
	while(que.size()){
		data d=que.top();
		que.pop();
		if(dp[d.v][d.bit]!=-1.0 && dp[d.v][d.bit]<d.cost)continue;
		dp[d.v][d.bit]=d.cost;
		if(d.v==b){
			res=min(res,d.cost);
			if(res==-1.0)res=d.cost;
		}
		for(int i=0;i<G[d.v].size();i++){
			int nv=G[d.v][i].first,f=G[d.v][i].second;
			for(int j=0;j<n;j++){
				if(!((d.bit >> j) & 1)){
					int nbit=d.bit|(1<<j);
					if(dp[nv][nbit]>d.cost+(double)f/t[j] || dp[nv][nbit]==-1.0){
						dp[nv][nbit]=d.cost+(double)f/t[j];
						data nd;
						nd.v=nv;
						nd.bit=nbit;
						nd.cost=d.cost+(double)f/t[j];
						que.push(nd);
					}
				}
			}
		}
	}
	return res;
}

int main(void){
	while(1){
		scanf("%d %d %d %d %d",&n,&m,&p,&a,&b);
		if(n+m+p+a+b==0)break;
		for(int i=0;i<=m;i++){
			G[i].clear();
		}
		for(int i=0;i<n;i++){
			scanf("%d",&t[i]);
		}
		for(int i=0;i<p;i++){
			int x,y,z;
			scanf("%d %d %d",&x,&y,&z);
			G[x].push_back(P(y,z));
			G[y].push_back(P(x,z));
		}
		double res=dijk();
		if(res!=-1.0)printf("%.7f\n",dijk());
		else printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 2600
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }	
using namespace std;
//?
int main(){
	SPEED;
	int a,b,c,x;
	cin>>a>>b>>c;
	 x =c-(a-b);
	cout<<(x>0?x:0);
}

Measured memory_bytes: 384
s=input()
n=len(s)
flag=0

kai1=s[0:(n-1)//2]
kai2=s[((n+3)//2)-1::]
#print(s)
#print(kai1)
#print(kai2)
if (s==s[::-1] and kai1==kai1[::-1] and kai2==kai2[::-1]):
    print("Yes")
else:
    print("No")

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
int X;
int A[8] = {400,600,800,1000, 1200, 1400, 1600,1800};

int32_t main(){
	fast;
	cin>>X;
	
	cout<<8 - (upper_bound(A,A+8,X) - A - 1);
	
}


Measured memory_bytes: 3644
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val MOD = 2*K
  val dp = Array.ofDim[Long](2*K, 2*K)

  for(_ <- 1 to N) {
    val _x, _y = in.next().toInt
    val c = in.next()
    var x = _x; var y = _y

    if(c == "W"){
      x += K
    }

    dp(y % MOD)(x % MOD) += 1L
  }

  val imos = Array.ofDim[Long](2*K, 2*K)
  for(y <- 0 until 2*K; x <- 0 until 2*K) {
    if(x == 0)
      imos(y)(x) = dp(y)(x)
    else
      imos(y)(x) = dp(y)(x) + imos(y)(x-1)
  }

  

  for(x <- 0 until 2*K; y <- 0 until 2*K) {
    if(y == 0)
      imos(y)(x) = imos(y)(x)
    else
      imos(y)(x) = imos(y)(x) + imos(y-1)(x)
  }


  def safeImos(x: Int, y: Int): Long = {
    if(x < 0 || y < 0) 0
    else imos(y)(x)
  }

  def calc(leftUp: (Int, Int)): Long = {
    var res: Long = 0L
    val (x, y) = leftUp
    val rightDown = (x + K-1, y + K-1)
    val (rx, ry) = rightDown

    if(rx < 2*K && ry < 2*K) {
      res += (imos(ry)(rx) - safeImos(x-1, ry) - safeImos(rx, y-1) + safeImos(x-1, y-1))
    }
    else if(rx >= 2*K && ry >= 2*K) {
      res +=
      (imos(2*K-1)(2*K-1) - safeImos(x-1, 2*K-1) - safeImos(2*K-1, y-1) + safeImos(x-1, y-1)
        + imos(ry % MOD)(rx % MOD)
        + imos(2*K-1)(rx % MOD) - safeImos(rx % MOD, y-1)
        + imos(ry % MOD)(2*K-1) - safeImos(x-1, ry % MOD)
      )
    }
    else if(rx >= 2*K) {
      val tmp = (imos(ry)(2*K-1) - safeImos(x-1, ry) - safeImos(2*K-1, y-1) + safeImos(x-1, y-1) +
        imos(ry)(rx % MOD) - safeImos(rx % MOD, y-1)
      )
      res += tmp
    }
    else if(ry >= 2*K) {
      val tmp =
        (imos(2*K-1)(rx) - safeImos(x-1, 2*K-1) - safeImos(rx, y-1) + safeImos(x-1, y-1)
          + imos(ry % MOD)(rx) - safeImos(x-1, ry % MOD)
        )
      res += tmp
    }

    res
  }

  var ans = 0L
  for(y <- 0 until 2*K; x <- 0 until 2*K) {
    val tmp = calc(x, y) + calc((x+K)%MOD, (y+K)%MOD)
    ans = Math.max(ans, tmp)
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 165256