akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<cctype>
using namespace std;
const int inf=0x7fffffff;
const double eps=1e-10;
const double pi=acos(-1.0);
//char buf[1<<15],*S=buf,*T=buf;
//char getch(){return S==T&&(T=(S=buf)+fread(buf,1,1<<15,stdin),S==T)?0:*S++;}
inline int read(){
	int x=0,f=1;char ch;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}
	if(f)return x;else return -x;
}
using namespace std;
const int M=3e5+10;
int idx[M],id[M],n;
vector<int> L,R;
bool cheak(int l,int r){
	L.clear();R.clear();
	for(int i=l+1;i<=r;i+=2)if(idx[i]!=i)return 0;
	for(int i=l;i<=r;i+=2){
		if(idx[i]<=i) R.push_back(idx[i]);
		else L.push_back(idx[i]);
	}
	if(L.size()>=2)
	for(int i=0;i<L.size()-1;i++)if(L[i]>L[i+1])return 0;
	if(R.size()>=2)
	for(int i=0;i<R.size()-1;i++)if(R[i]>R[i+1])return 0;
	return 1;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){idx[i]=read();id[idx[i]]=i;}
	int nl=1,nr=1;
	for(int i=1;i<=n;){
		for(;i<=n;i++){
			if(id[i]>nr)nr=id[i];
			if(i==nr)break;
		}
		if(!cheak(nl,nr)){printf("No\n");return 0;}
		i=nl=nr+1;
		++nr;
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 3900
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ul x,y,s;
inline void solve2(){
  IN(x);
  if(x<=6){
    OUT(1);
    return;
  }
  if(x<=11){
    OUT(2);
    return;
  }
  y=x/11;
  s=y*11;
  if(s==x)OUT(y*2);
  else if(x<=s+6)OUT(y*2+1);
  else if(x<s+11)OUT(2*(y+1));
}

// int num[2]={5,6};
// ul ans,score,i,x;
// inline void solve(){
//   IN(x);
//   score=0;
//   while(1){
//     if(x<=score){
//       OUT(i);
//       return;
//     }
//     i++;
//     score+=num[i%2];
//   }
// }

int main(int argc,char**argv){
  BEGIN;
  solve2();
  END;
}


Measured memory_bytes: 256
N = int(input())
S = input()
# N桁のSからN-3桁の数字を削除して(N<30000)３桁の数字を残す．残った数字の組み合わせて押してありえるのは何通りか？
# 実際に10^4通りから３通り選ぶのは 10^4C3通りくらい計算量的には計算できる?
# 更にあり得る組み合わせの上限==1000通りを終えた時点で終了すれば更に早い？
# 右の数字から数えていって1を取れるかみたいにしていけば最大１０００のループで終わる？
# 0001がNの中から取れるかの判定まず最初の0について左側からとっていって，0があれば存在すればとり，そこのindexを記録，．次に1として次のindexから検索していく

#for n in N_str:
#なぜ224とかの時に上手く行かないのだ?
#0224
count=0
NUM = [str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
for i in NUM:
    i_3d = i
    S_mid = S
    for j,i_s in enumerate(i_3d): # 1,2
        if i_s in S_mid: # S_mid中にi_sがそんざいしていたら
            ind = S_mid.index(i_s)
            if j == len(i_3d)-1:  # 最後の文字がマッチングした
                count+=1
                break # break はforとwhileを抜け出すのに使われる
            elif ind+1 == len(S): # 文字はマッチングしたが最後の文字ではなく次の探索ができない場合
                break
            S_mid = S_mid[ind+1:]
        else: # S_mid中に存在しない
            break
print(count)




Measured memory_bytes: 3188
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = Counter(LIST())

tmp = 0
f = False
for x in a:
  while a[x] > 1:
    if a[x] == 2:
      a[x] -= 1
      if f:
        f = False
      else:
        tmp += 1
        f = True
    else:
      a[x] -= 2
      tmp += 1
ans = n - tmp*2      
print(ans)

Measured memory_bytes: 22748
using System;

namespace ATCoder
{
    class Program
    {
        static void Main( string[] args )
        {
            var input = Console.ReadLine();
            string[] token = input.Split( ' ' );
            int N = int.Parse( token[ 0 ] );
            int M = int.Parse( token[ 1 ] );
            if((N-M) == 0)
            {
                Console.WriteLine( "Yes" );
            }
            else
            {
                Console.WriteLine( "No" );
            }
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

int main(){
	int n;
	int R[200000];
	int cur_min;
	int res;
	
	scanf("%d\n", &n);
	for (int i = 0;i<n;i++){
		scanf("%d\n", &R[i]);
	}
	
	cur_min = R[0];
	res = R[1] - R[0];
	
	for (int i = 1; i < n; i++){
		if (R[i] - cur_min > res){
			res = R[i] - cur_min;
		}
		if (R[i] < cur_min){
			cur_min = R[i]; 
		}
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 3472
import Control.Applicative
import Data.List
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readIntBS = fst . fromJust . BS.readInt

main = do
  n <- getLine
  as <- sort . map read . words <$> getLine :: IO [Int]
  let bs = scanl (+) 0 as

  print $ (last . cut . map (\(a,b) -> a > b*2)) (zip as bs)

  where
    cut [] = []
    cut (True:xs) = (length a + 1) : cut b
      where (a,b) = span (not . id) xs
  


Measured memory_bytes: 39932
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = IntArray(20)
    // 誰が
    val X = Array(20) { IntArray(20) }
    // どうなのか 正直者/不親切な人
    val Y = Array(20) { IntArray(20) }

    for (i in 1..N) {
        A[i] = readLine()!!.toInt()
        for (j in 1..A[i]) {
            val (x, y) = readLine()!!.split(" ").map(String::toInt)
            X[i][j] = x
            Y[i][j] = y
        }
    }

    // 1の数をカウント
    fun counter(value: Int): Int {
        if (value == 0) {
            return 0
        }
        return counter(value.shr(1)) + value.and(1)
    }

    var ans = 0

    // {0, 1, ..., n-1} の部分集合の全探索
    for (bits in 0 until (1.shl(N))) {
        var ok = true
        for (i in 1..N) {
            // 正直者かどうかを判定している
            // 不親切だと仮定している人の証言は無視する
            if (((bits shr (i - 1)) and 1) == 0) {
                continue
            }
            // 証言の数だけ繰り返す

            for (j in 1..A[i]) {
                // 発言と仮定している値に矛盾がないか判定している
                // XORで発言に矛盾がないかを見ている
                // 0,0 → 1
                // 0,1 → 0
                // 1,0 → 0
                // 1,1 → 1
                if ((((bits shr (X[i][j] - 1)) and 1) xor Y[i][j]) == 1) {
                    ok = false
                    break
                }
            }

        }
        if (ok) {
            ans = Math.max(ans, counter(bits))
        }
    }
    println(ans)
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 3e3+5;
int grid[N][N];
int dp[N][N][4];
signed main(){
	fastio
	int r,c,k;
	cin >> r >> c >> k;
	while(k--){
		int x,y,v;
		cin >> x >> y >> v;
		grid[x][y] = v;
	}
	for(int i = 1;i <= r;i++){
		for(int j = 1;j <= c;j++){
			for(int k = 0;k < 4;k++){
				if(i) dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k]);
				if(j) dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k]);
				if(k){
					dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + grid[i][j]);
					for(int l = 0;l < 4;l++){
						dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][l] + grid[i][j]);
					}
				}
			}
		}
	}
	/*for(int i = 1;i <= r;i++){
		for(int j = 1;j <= c;j++){
			cout << i << " " << j << "\n";
			for(int k = 0;k < 4;k++){
				cout << dp[i][j][k] << " ";
			}
			cout << "\n";
		}
	}*/
	cout << max({dp[r][c][0],dp[r][c][1],dp[r][c][2],dp[r][c][3]});
}

Measured memory_bytes: 355740
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
else:
    x=max(h,w)
    y=min(h,w)
    ans=y
    for hi in range(1,h):
        M=max(hi*w,(h-hi)*((w+1)//2),(h-hi)*(w//2))
        m=min(hi*w,(h-hi)*((w+1)//2),(h-hi)*(w//2))
        ans=min(ans,M-m)
    for wi in range(1,w):
        M=max(wi*h,(w-wi)*((h+1)//2),(w-wi)*(h//2))
        m=min(wi*h,(w-wi)*((h+1)//2),(w-wi)*(h//2))        
        ans=min(ans,M-m)
    print(ans)

Measured memory_bytes: 77772
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int n, m, q, ans;
int a[60], b[60], c[60], d[60];
int A[15];

void dfs(int i) {
  if (i == n) {
    int sm = 0;
    for (int j = 0; j < q; j++) {
      if (A[b[j]] - A[a[j]] == c[j]) {
        sm += d[j];
      }
    }
    ans = max(ans, sm);
    return;
  }
  
  for (int j = A[i]; j <= m; j++) {
    A[i+1] = j;
    dfs(i+1);
  }
}

int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  
  A[0] = 1;
  dfs(0);
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
void tile(int *x,int *y,char d[101][101] ){
	if(d[*y][*x]=='m')
		*x=50000;
	else if(d[*y][*x]!='.'){
	if(d[*y][*x]=='>'){
	d[*y][*x]='m';
		*x=*x+1;
	}
	else if(d[*y][*x]=='<'){
	d[*y][*x]='m';
		*x=*x-1;
	}
	else if(d[*y][*x]=='^'){
		d[*y][*x]='m';
		*y=*y-1;
	}
	else if(d[*y][*x]=='v'){
		d[*y][*x]='m';
		*y=*y+1;
	}
		tile(x,y,d);
	}
	
}
int main(){
	
	int w,h;
	
	while(cin>>h>>w,h!=0&&w!=0){
	char d[101][101];
	int x=0,y=0;
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>d[i][j];
		}
	}
	tile(&x,&y,d);
	
	if(x==50000)
		cout<<"LOOP"<<endl;
	else
		cout<<x<<" "<<y<<endl;
	}
	
}

Measured memory_bytes: 1168
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,d; cin >> n >> d;
    vvl x(n, vl(d));
    rep(i,n){
        rep(j,d){
            cin >> x[i][j];
        }
    }
    double sum;
    ll cnt=0;
    rep(i,n-1){
        REP(j,i+1,n){
            sum = 0.0;
            rep(k,d){
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            sum = sqrt(sum);
            //cout << sum << "\n";
            if(ceil(sum) == floor(sum)) cnt++;
        }
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

#define int ll
map<pair<int, int>, int> dp[6];
set<pair<int, int>> spots;
int dx[2][7] = { {0,1,1,0,-1,-1,0},{0,1,1,0,-1,-1,0} };
int dy[2][7] = { {1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0} };
void solve(){
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    int n;
    cin >> n;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        spots.insert(mp(a, b));
    }
    dp[0][mp(sx, sy)] = 0;
    deque<tuple<int, int, int>> next;
    next.push_back(make_tuple(0, sx, sy));
    int lx, ly;
    cin >> lx >> ly;
    while (next.empty() == false) {
        tuple<int, int, int> now = next.front();
        next.pop_front();
        if (spots.count(mp(get<1>(now), get<2>(now)))) continue;
        REP(q, 7) {
            int x = get<1>(now) + dx[llabs(get<1>(now))%2][q];
            int y = get<2>(now) + dy[llabs(get<1>(now))%2][q];
            if (llabs(x) <= lx && llabs(y) <= ly) {
                int cost = dp[get<0>(now)][mp(get<1>(now), get<2>(now))];
                int target = get<1>(now) * get<2>(now) * get<0>(now);
                target = llabs(target) % 6;
                if (target != q) cost++;
                int goi = get<0>(now) + 1;
                goi %= 6;
                if (dp[goi].count(mp(x, y)) == 0) {
                    dp[goi][mp(x, y)] = cost;
                    if (target != q) {
                        next.push_back(make_tuple(goi, x, y));
                    }
                    else {
                        next.push_front(make_tuple(goi, x, y));
                    }
                }
                else {
                    if (dp[goi][mp(x, y)] > cost) {
                        dp[goi][mp(x, y)] = cost;
                        if (target != q) {
                            next.push_back(make_tuple(goi, x, y));
                        }
                        else {
                            next.push_front(make_tuple(goi, x, y));
                        }
                    }
                }
            }
        }
    }
    int ans = 1e9;
    REP(i, 6) {
        if (dp[i].count(mp(gx, gy)) == 0) continue;
        ans = min(ans, dp[i][mp(gx, gy)]);
    }
    if (ans == 1e9) ans = -1;
    cout << ans << endl;
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 18320
import itertools
import math
n = int(input())
x = [0]
y = [0]
for i in range(1,n+1):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
    
num_list = [int(i) for i in range(1,n+1)]
keiro = []
for v in itertools.permutations(num_list, n):
    keiro.append(list(v))
kensu = math.factorial(n)
#print(keiro)
#print(kensu)
ans = 0
for i in range(kensu):
    for j in range(n-1):
        ans += math.sqrt((x[keiro[i][j]]-x[keiro[i][j+1]])**2+(y[keiro[i][j]]-y[keiro[i][j+1]])**2)
print(ans/kensu)

Measured memory_bytes: 14652
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    for(int i = 0; i < 2; ++i) {
        vector<int> v;
        for(int j = 0; j < 10; ++j) {
            int n;
            cin >> n;
            v.push_back(n);
        }
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        cout << v[0]+v[1]+v[2] << (i==0?' ':'\n');
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  int l=s.length();
  rep(i,l-1){
    if(s[i]==s[i+1]){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
  }
  rep(i,l-2){
    if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<-1<<" "<<-1<<endl;
  return 0;

}


Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i=1;i<=(ty-sy);i++){
        cout << 'U';
    }
    for(int i=1;i<=(tx-sx);i++){
        cout << 'R';
    }
    for(int i=1;i<=(ty-sy);i++){
        cout << 'D';
    }
    for(int i=1;i<=(tx-sx);i++){
        cout << 'L';
    }

    cout << 'L';
    for(int i=0;i<=(ty-sy);i++){
        cout << 'U';
    }
    for(int i=0;i<=(tx-sx);i++){
        cout << 'R';
    }
    cout << 'D';
    cout << 'R';
    for(int i=0;i<=(ty-sy);i++){
        cout << 'D';
    }
    for(int i=0;i<=(tx-sx);i++){
        cout << 'L';
    }
    cout << 'U';
}

Measured memory_bytes: 256
'use strict'
function main(input: string) {
    const n: number = Number(input);
    for (let i = 1; i <= 9; i++) {
        for (let j = 1; j <= 9; j++) {            if (i * j === n) {
                console.log("Yes");
                return;
            }
        }
    }
    console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] x = new int[10];
        for (int i = 0;i <= 9;i++){
            x[i] = scan.nextInt();
        }
        
        Arrays.sort(x);
        
        System.out.println(x[9]);
        System.out.println(x[8]);
        System.out.println(x[7]);
    }
}

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

int main(){
  ll x;
  cin>>x;
  ll ans=x>=5;
  ans+=2*((max(0LL,x-6))/11);
  x=max(0LL,(x-6)%11);
  ll num[2]={5,6},cnt=0;
  while(x>0) ans++,x-=num[cnt++%2];
  cout<<max(1LL,ans)<<endl;
  return 0;
}


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

using namespace std;

typedef long long LL;

const int N=132005;

struct pr{
	LL in,out;
	pr(LL _i=0,LL _o=0){in=_i,out=_o;}
};
vector<pr>dp[N],temp1,temp2;
vector<int>e[N];
int n,fa[N],dis[N],son[N][2],d[N];
LL deep[N],lim;

void insert(vector<pr>&v,const pr&i){
	int p=v.size()-1;
	if(!~p)v.push_back(i);
	else if(v[p].in==i.in)v[p].out<i.out?:v[p].out=i.out;
	else if(i.out<v[p].out)v.push_back(i);
}

void vector_merge(vector<pr>&v,vector<pr>&l,vector<pr>&r){
	v.clear();
	int x=l.size(),y=r.size(),p=0,q=0;
	if(!y)return;
	while(p!=x){
		while(q!=y&&l[p].out+r[q].in<=lim)q++;
		if(q)q--;
		if(l[p].out+r[q].in<=lim)v.push_back(pr(l[p].in,r[q].out));
		p++; 
	}
}

void merge_sort(vector<pr>&v,vector<pr>&l,vector<pr>&r){
	v.clear();
	int x=l.size(),y=r.size(),p=0,q=0;
	while(p!=x||q!=y){
		if(p==x)insert(v,r[q++]);
		else if(q==y)insert(v,l[p++]);
		else if(l[p].in<r[q].in)insert(v,l[p++]);
		else insert(v,r[q++]);
	}
}

void dfs(int x){
	if(!d[x]){
		dp[x].clear();
		dp[x].push_back(pr(deep[x],deep[x]));
		return;
	}
	int ls=son[x][0],rs=son[x][1];
	dfs(ls),dfs(rs);
	lim+=2*deep[x];
	vector_merge(temp1,dp[ls],dp[rs]);
	vector_merge(temp2,dp[rs],dp[ls]);
	merge_sort(dp[x],temp1,temp2);
	lim-=2*deep[x];
}

int main(){
#ifdef whzzt
	freopen("travel.in","r",stdin);
	freopen("travel.out","w",stdout);
#endif
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		scanf("%d%d",fa+i,dis+i);
		deep[i]=deep[fa[i]]+dis[i];
		son[fa[i]][d[fa[i]]++]=i;
	}
	LL l=0,r=1E13,ans=(l+r)>>1;
	while(l<r){
		lim=ans,dfs(1);
		if(dp[1].size())
			r=ans;
		else
			l=ans+1;
		ans=(l+r)>>1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 33512
n = int(input())
h = list(map(int, input().split()))
max_count = 0
i = 0
count = 0
for i in range(0, n-1):
  if h[i] >= h[i+1]:
    count += 1
  else:
    if max_count < count:
      max_count = count
    count = 0

if max_count < count:
      max_count = count
    
print(max_count)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n,h,res=0;
  	cin >> h >> n;
  	vector<int> s(n);
  	for(int i=0;i<n;i++){
    	cin >> s.at(i);
      	res += s.at(i);
    }
  	if(res >= h) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
int n;
int a[105];
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	bool ok = 1;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(a[i] % 2 == 0){
			if(a[i] % 3 != 0 && a[i] % 5 != 0) ok = 0;
		}
	}
	if(ok) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin >> n;
		ll int arr[n+1];
		ll int total_xor = 0;
		for(ll int i = 1; i <= n; i++)
		{
			cin >> arr[i];
			total_xor ^= arr[i];		
		}
		for(ll int i = 1; i <= n; i++)
		{
			cout << (total_xor ^ arr[i]) << ' ';
		}
	}
	return 0;
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
ll power(const ll p, const ll n)
{
    if (n == 0) {
        return 1;
    }
    if (n % 2 == 1) {
        return (power(p, n - 1) * p) % MOD;
    } else {
        const ll pp = power(p, n / 2);
        return (pp * pp) % MOD;
    }
}
int main()
{
    ll M, N;
    cin >> M >> N;
    cout << power(M, N) << endl;
    return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

#define ll long long
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

// 過去問第3問ABC113Bまでdone

int main(){
    ll A,B;
    cin >> A >> B;

    bool flag = false;
    for(ll i=0; i<1000000009; i++){
        if(abs(A-i)==abs(B-i)){
            cout << i << endl;
            flag = "true";
            break;
        }
    }
    if(flag==false) cout << "IMPOSSIBLE" << endl;
    
    return 0;
}

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

using namespace std;
//
//class Square {
//
//private:
//    isBomb = false;
//
//public:
//    setBomb(bool is);
//};


int main() {

    int H, W;
    cin >> H >> W;
    int N = H * W;

    vector <vector<int> > a(H, vector<int>(W));
    vector <vector<int> > c(H, vector<int>(W));
    vector<int> v(3);
    v[0] = 0;
    v[1] = 1;
    v[2] = -1;



    char temp;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> temp;
            if (temp == '#') {
                a[i][j] = 1;
            } else {
                a[i][j] = 0;
            }
        }
    }


    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {

            // bombだったら-1
            if(a[i][j] == 1){
                c[i][j] = -1;
                continue;
            }

            // 座標がbombでないとき
            for (int k = 0; k < 3; ++k) {
                for (int l = 0; l < 3; ++l) {


                    int x, y;
                    int h, w;
                    h = i + v[k];
                    w = j + v[l];

                    if (h < 0 || w < 0) {
                        continue;
                    }
                    if (h >= H || w >= W ) {
                        continue;
                    }
                    if (h == i && w == j) {
                        continue;
                    }
                    if (!a[h][w]) {
                        continue;
                    }
                    if (a[h][w] == 1) {
                        c[i][j]++;
                    }
                }
            }
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if  (c[i][j] == -1) {
                cout << "#";
            }
            if  (c[i][j] > -1){
                cout << c[i][j];
            }
        }
        cout << endl;
    }

}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a.begin(), a.end());
	int b;
	if (n % 2 == 0) {
		b = (a[n / 2 - 1] + a[n / 2]) / 2;
	}
	else {
		b = a[(n-1) / 2];
	}
	int ans = 0;
	rep(i, n) {
		ans += abs(a[i] - b);
	}
	print(ans);
}

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

void dfs(string s, int n) {
  if (s.size() == n) {
    cout << s << "\n";
    return;
  } else {
    char mx = *max_element(s.begin(), s.end());
    for (char c = 'a'; c <= mx + 1; c++) {
      dfs(s + c, n);
    }
  }
}

int main() {
  int N;
  cin >> N;
  dfs("a", N);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return x ? mod - x : 0;}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  friend ostream& operator << (ostream& os, const mint& m) noexcept {
    return os << m.x;
  }

  friend istream& operator<< (istream& is, mint& m) noexcept {
    return is >> m.x;
  }
};

struct combination {
  vector<mint> fact, ifact;  // 階乗と階乗の逆元
  combination(int n):fact(n+1),ifact(n+1) {  // 階乗と階乗の逆元を n まで求める
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

  int x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  ll tot = (x + y) / 3;
  ll dif = abs(x - y);

  combination comb(tot);
  mint ans = comb(tot, dif + (tot - dif) / 2);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

ll modPow(ll x, ll y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  if (y % 2 == 0) return modPow((x * x) % MOD, y / 2);
  else return (x * modPow((x * x) % MOD, y / 2)) % MOD;
}

vl table1(ARRAY, -1);
vl table2(ARRAY, -1);

ll dp1(ll k) { //すでにLより小さい前提
  if (table1[k] != -1) return table1[k];
  return table1[k] = modPow(3, N - k);
}

ll dp2(ll k) { //Lより小さいか未定
  if (table2[k] != -1) return table2[k];
  int d = s[k] - '0';
  ll ans = 0;
  if (d == 1) {
    if (k == N-1) ans = 3;
    else ans = 2 * dp2(k+1) + dp1(k+1);
  } else {
    if (k == N-1) ans = 1;
    else ans = dp2(k+1);
  }
  return table2[k] = ans % MOD;
}

int main(void){
  
  I(s);
  N = s.size();

  ret = dp2(0);

  P(ret);

}


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

typedef pair<int,int> pii;
const int N = 1e5;

int x;
int k;
int r[N+5];
int q;

vector<pii> lq;

int main(){
	scanf("%d",&x);
	scanf("%d",&k);
	for(int i=1;i<=k;i++){
		scanf("%d",&r[i]);
	}
	r[k+1] = (int) 1e9;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		lq.push_back(make_pair(a,b));
	}
	int id = 0;
	int baw = 0;
	int at = x;
	int ps = 0;
	int maksi = x;
	int mini = 0;
	int ibaw = 0;
	int iat = x;
	for(int i=1;i<=k+1;i++){
		int dif = r[i] - r[i-1];
		while(id < lq.size() && lq[id].first <= r[i]){
			int y = lq[id].second;
			int ans = y - ps;
			if(y <= baw){
				ans = ibaw;
			}
			if(y >= at){
				ans = iat;
			}
			if(i&1){
				ans -= lq[id].first - r[i-1];
			} else {
				ans += lq[id].first - r[i-1];
			}
			ans = max(0,ans);
			ans = min(ans,x);
//			if(!(i&1)) ans = x-ans;
			printf("%d\n",ans);
			id++;
		}
		if(i&1){
			ps+=dif;
			maksi-=dif;
			mini-=dif;
			ibaw-=dif;
			iat-=dif;
			if(ibaw < 0) ibaw = 0;
			if(iat < 0) iat = 0;
			if(mini < 0) baw -= mini, mini=0;
		} else {
			ps-=dif;
			maksi+=dif;
			mini+=dif;
			ibaw+=dif;
			iat+=dif;
			if(ibaw > x) ibaw = x;
			if(iat > x) iat = x;
			if(maksi > x) at -= maksi - x,maksi = x;
		}
//		cout << "baw " << baw << " and " << at << endl;
	}
	return 0;
}

/*

0 5 9 13 14 20

1-10, 1-5,

5,6,7,8,9,10

0,1,2,3,4,5 => 4,5,6,7,8,9

*/

Measured memory_bytes: 2548
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  
  int mx = 0;
  vector<int> nums(N);
  for (int n = 0; n < N; ++n) {
    cin >> nums[n];
    mx = max(mx, nums[n]);
  }
  vector<int> mods(mx+1);
  mods[1] = 1;
  for (int i = 2; i <= mx; ++i) {
    if (mods[i] != 0) {
      continue;
    }
    mods[i] = i;
    int tmp = i;
    while (tmp + i <= mx) {
      tmp += i;
      if (mods[tmp] != 0) continue;
      mods[tmp] = i;
    }
  }
  bitset<1000001> already;
  unordered_map<int, int> cnts;
  bool pairwise = true;
  for (int n : nums) {
    while (n > 1) {
      int tmp = mods[n];
      while (n % tmp == 0) {
        n /= tmp;
      }
      if (already.test(tmp)) {
        pairwise = false;
      }
      if (++cnts[tmp] == N) {
        cout << "not coprime" << endl;
        return 0;
      }
      already.set(tmp);
    }
  }
  if (pairwise) {
    cout << "pairwise coprime" << endl;
  } else {
    cout << "setwise coprime" << endl;
  }

  return 0;
}


Measured memory_bytes: 14376
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        mut m: usize
    };
    let mut sum = 0;
    let num = std::cmp::min(n, m / 2);
    sum += num;
    m -= 2 * num;
    sum += m / 4;
    println!("{}", sum);
}


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

int main() {
  int h, w;
  char t;
  cin >> h >> w;
  vector<vector<bool>> a(h+1, vector<bool>(w+1, 0));
  rep(i,h) rep(j,w){
    cin >> t;
    if(t == '#'){
      a.at(i).at(j) = 1;
      a.at(i).at(w) = 1;
      a.at(h).at(j) = 1;
    }    
  }
  
  rep(i,h){
    if(a.at(i).at(w)) rep(j,w){
      if(a.at(h).at(j)){
        if(a.at(i).at(j)) cout << '#';
        else cout << '.';
      }
      if(j == w-1) cout << endl;
    }
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	cout<<(N*(N-1))/2+(M*(M-1))/2<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
int main(){
  int x,y;
  cin >> x >> y;
  bool can = false;
  rep(i,x+1){
    if(i*2+(x-i)*4==y) can = true;
  }
  if(can){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3520
#!perl
use List::Util qw/sum/;
use List::Util qw/max min/;
my $a = <STDIN>;
chomp($a);
my @a = split(/ /, $a);
my $b = <STDIN>;
chomp($b);
my @b = split(/ /, $b);
my @c;

for (my $i = 0; $i < @a[1]; $i++) {
    if ($i != (@a[1]-1) ){
        @c[$i] = @b[$i+1] - @b[$i];
    }
    else{
        @c[$i] = (@a[0] - @b[$i]) + @b[0]
    }
}

print (sum(@c) - max(@c));

Measured memory_bytes: 35200
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        Arrays.sort(s);
        char[] t = sc.next().toCharArray();
        Arrays.sort(t);
        boolean ans = true;
        boolean broke = false;
        for (int i = 0; i < Math.min(s.length, t.length); i++) {
            if(t[t.length - i - 1] < s[i]){
                ans = false;
                break;
            } else if(s[i] < t[t.length - i - 1]){
                broke = true;
                break;
            }
        }
        if(ans && !broke){
            if(t.length <= s.length) ans = false;
        }
        if(ans) System.out.println("Yes");
        else System.out.println("No");
        sc.close();

    }

}


Measured memory_bytes: 22612
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
long long n,a[100010],ans,num=1e10;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n-1;i++)
		if (a[i]<0){
			a[i]*=-1;
			a[i+1]*=-1;
		}
	for (int i=0;i<n;i++) ans+=a[i];
	if (a[n-1]<0){
		ans-=a[n-1]*2;
		a[n-1]*=-1;
		for (int i=0;i<n;i++) num=min(num,a[i]);
		cout<<ans-num*2<<endl;
	}
	else
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
program name

    implicit none
    integer(8) nums(87)
    integer i,N
    nums(1) = 2
    nums(2) = 1
    do i = 3, 87, 1
        nums(i) = nums(i - 1)+nums(i - 2)
    end do
    read*, N
    print*, (nums(N + 1))

end program

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

public class P
{
    public string n { get; set; }
    public double a { get; set; }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var ps = new P[n];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var p = int.Parse(line[1]);
                var a = new int[5];
                for (int j = 0; j < 5; j++)
                    a[j] = int.Parse(line[j + 2]);
                var f = int.Parse(line[7]);
                var s = int.Parse(line[8]);
                var m = int.Parse(line[9]);
                ps[i] = new P { n = line[0], a = getData(p, a, f, s, m) };
            }
            foreach (var x in ps.OrderByDescending(y => y.a).ThenBy(y => y.n))
                Console.WriteLine(x.n);
            Console.WriteLine("#");
        }
    }
    static double getData(int p, int[] a, int f, int s, int m)
    {
        var t = a.Sum() + (a[3] + a[4]) * (m - 1);
        var ps = f * m * s - p;
        return ps / (double)t;
    }
}



Measured memory_bytes: 17292
#B
N=int(input())
L=list(map(int,input().split()))
L.sort()

ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[j]>L[i]:
            for k in range(j+1,N):
                if L[k]>L[j]:
                    if L[i]+L[j]>L[k]:
                        ans +=1
print(ans)

Measured memory_bytes: 9192
#include<iostream>
#include<stack>
using namespace std;
int main(){
    int n,space;
    stack<int> sta;
    bool check[7400000];
    for(int i=0;i<7400000;++i) {
        check[i]=true;
    }
    while(cin>>n>>space&&n!=0){
        int place=n-1;
        while(space>-1){
            if(check[++place]){
                for(int i=place*2;i<7400000;i+=place) {
                    if(check[i]){
                        sta.push(i);
                        check[i]=false;
                    }
                }
                --space;
            }
        }
        cout<<place<<endl;
        while(!sta.empty()){
            check[sta.top()]=true;sta.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 38364
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){

  
  int N;
 double ans = 0.0;
  
  cin >> N;

  for(int i=0; i < N ; i++){
    int tmp;
    cin >> tmp;
    ans += (double)1/tmp;
   
  }

 ans = 1/ans; 


 cout << ans << endl;
  return 0;
}




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

int main() {
	char a,b;
	cin >> a >> b;
	char k = 'H';
	if(a == 'H')
	{
		k = b;
	}
	else
	{
		if(b == 'H')
		{
			k = 'D';
		}
	}
    cout << k << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(void){
    string stone;
    int N;
    int r, w;
    char ch;
    int ans = 0;

    cin >> N;

    cin >> stone;

    r = N - 1;
    w = 0;

    while(r > w){
        while(stone[r] != 'R' && r != w){
            --r;
        }
        while(stone[w] != 'W' && r != w){
            ++w;
        }
        if(r == w) break;
        stone[r] = 'W';
        stone[w] = 'R';
        --r;
        ++w;
        ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3676
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()
	_, m := io.ScanInt(), io.ScanInt()
	acMap := map[int]bool{}
	waCountMap := map[int]int{}
	var acCount int
	for i := 0; i < m; i++ {
		p, r := io.ScanInt(), io.ScanString()
		if r == "AC" && !acMap[p] {
			acCount++
			acMap[p] = true
		} else {
			if !acMap[p] {
				waCountMap[p]++
			}
		}
	}
	var waCount int
	for p, count := range waCountMap {
		if acMap[p] {
			waCount += count
		}
	}
	fmt.Println(acCount, waCount)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 9472
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

pii vals[1005];
int h,n;
int memo[100000];
int solve(int x){
	if(x <= 0)return 0;
	if(memo[x] != -1){
		return memo[x];
	}
	ll ans = LLONG_MAX;
	forn(i, n){
		ans = min (ans, (ll)vals[i].se + solve(x - vals[i].fi));
	}
	memo[x] = ans;
	return memo[x];
}
int main(){
	FIO
	
	cin >> h >> n;
	forn(i, n)cin >> vals[i].fi >> vals[i].se;
	memset(memo, -1, sizeof memo);
	cout << solve(h);
	return 0;
}


Measured memory_bytes: 1152