akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int mod = 1000000007;
const ll inf = 1e18;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

struct edge{
    ll to, cost;
};

vector<vector<edge>> ed;
vector<ll> dis;

int main(){
    ll n;
    cin >> n;
    ed.resize(n);
    rep(i,n-1){
        ll a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        edge e = {b, c};
        edge f = {a, c};
        ed[a].push_back(e);
        ed[b].push_back(f);
    }
    ll Q, k;
    cin >> Q >> k;
    k--;
    dis.resize(n);
    fill(dis.begin(), dis.end(), inf);
    dis[k] = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, k));
    while(!q.empty()){
        P p = q.top();
        q.pop();
        ll s = p.second;
        if(dis[s] < p.first) continue;
        
        for(int i = 0; i < ed[s].size(); i++){
            edge e = ed[s][i];
            if(dis[e.to] > dis[s] + e.cost){
                dis[e.to] = dis[s] + e.cost;
                q.push(P(dis[e.to], e.to));
            }
        }
    }
    while(Q--){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        cout << dis[a] + dis[b] << endl;
    }
}

Measured memory_bytes: 10992
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[])
{
  const int INF= 1000000000;
  int n;
  long long int a[100000];
  scanf("%d",&n);
  for (int i = 0; i < n; i++) {
    scanf("%ld",&a[i]);
  }
  //1桁目が正
  long long int ans = INF;
  long long int sum =0;
  long long int ansp=0;
  long long int ansm=0;
  for (int i = 0; i < n; i++) {
    if(i%2==0){
      if(sum+a[i]>0){
	sum+=a[i];continue;
      }	
      else{
	ansp+=abs(1-a[i]-sum);
	sum=1;
      }
    }else{
      if(sum+a[i]<0){
	sum+=a[i];continue;
      }	
      else{
	ansp+=abs(-1-a[i]-sum);
	sum=-1;
      }      
    }
  }
  sum=0;
  for (int i = 0; i < n; i++) {
    if(i%2==1){
      if(sum+a[i]>0){
	sum+=a[i];continue;
      }	
      else{
	ansm+=abs(1-a[i]-sum);
	sum=1;
      }
    }else{
      if(sum+a[i]<0){
	sum+=a[i];continue;
      }	
      else{
	ansm+=abs(-1-a[i]-sum);
	sum=-1;
      }      
    }
  }
  printf("%lld\n",min(ansp,ansm));
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int n;
    cin >> n;
    int sum=0, smin=inf;
    for(int i=0; i<n; i++){
        int s;
        cin >> s;
        sum += s;
        if(s%10!=0) smin = min(smin, s);
    }
    if(sum%10==0){
        cout << max(0, sum-smin) << endl;
    }else{
        cout << sum << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

string s;
ll c[26];

int main(){
    cin >> s;
    for(auto &e : s) c[e-'a']++;
    ll ans = s.size() * (s.size()-1) / 2;
    for(int i=0;i<26;i++){
        ans -= c[i] * (c[i]-1) / 2;
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 640
# 2019-11-14 17:27:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    W, H, x, y = [int(i) for i in sys.stdin.readline().split()]

    # どこに座標をとっても必ず中心を通る直線で半分になる
    # 座標が中心の場合のみ、長方形を半分に分断する直線が無数に存在する
    area = W * H / 2
    if W == x * 2 and H == y * 2:
        sign = '1'
    else:
        sign = '0'
    print(area, sign)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
h,w,a,b=map(int,input().split())

U = 2*10**5
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
 
for i in range(U,0,-1):
	fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def comb(n,k):
  if k < 0 or k > n:
    return 0
  x = fact[n]
  x *= fact_inv[k]
  x %= MOD
  x *= fact_inv[n-k]
  x %= MOD
  return x
ans=0
mod=10**9+7
for i in range(1,h-a+1):
    ans+=(comb(i+b-2,min(i-1,b-1))*comb(h-i+w-b-1,min(h-i,w-b-1)))%mod
    ans=ans%mod
print(ans)




Measured memory_bytes: 18932
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	fmt.Println(nextInt() / 3)
}


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

int main() {
  
  int N, M;
  cin >> N >> M;
  int sum = 0;
  
  vector<int> bipa(N);
  
  for (int i = 0; i < N; i++) {
    cin >> bipa.at(i);
    sum += bipa.at(i);
  }
  
  sort (bipa.begin(), bipa.end());
  reverse (bipa.begin(), bipa.end());
  
  int hantei = 0;
  
  for (int i = 0; i < M; i++) {
    if (bipa.at(i) * 4 * M >= sum) {
      hantei += 1;
    }    
  }
  
  if (hantei == M) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main() {
  int N, max = 0, b = 0;
  long long inf = 1000000001;
  cin >> N;
  vector<long long>H(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  H.at(N) = inf; 
  for (int i = 0; i < N; i++) {
    if (H.at(i) >= H.at(i + 1)) {
      b++;
    }
    else {
      if (b > max) {
        max = b;
      }
      b = 0;
    }
  }
  cout << max;
}

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

int main(){
    long long N, Y;
    cin >> N >> Y;
    for(int i=0; i<= N; i++){
        for(int j=0; j<= N-i; j++){
            if(10000*i+5000*j > Y){
                continue;
            }
            int k = (Y-10000*i-5000*j)/1000;
            if(i+j+k == N){
                cout << i << " " << j << " " << k;
                return EXIT_SUCCESS;
            }
        }
    }
    cout << "-1 -1 -1";
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in [0]*N]
n = {c:0 for c in "MARCH"}
for c in S:
    if c[0] in "MARCH":
        n[c[0]] += 1
march = list(n.values())
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += march[i]*march[j]*march[k]
print(ans)

Measured memory_bytes: 10520
#include <iostream>

using namespace std;

int cnt[26];

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < 4; i++){
        cnt[S[i]-'A']++;    
    }
    int cnt2 = 0;
    for(int i = 0; i < 26; i++){
        if(cnt[i] == 2) cnt2++;
    }
    if(cnt2 == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
a = [int(item) for item in input().split()]

for a1, a2 in zip(a, a[k:]):
    if a1 < a2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 92256
#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<string>
#include<vector>
using namespace std;
int k;
string s;
set<string> v;
int main()
{
	cin>>s>>k;
	for (int i=0;i<s.size();i++){
		string t="";
		for (int j=1;i+j-1<s.size();j++){
			t+=s[i+j-1];
			v.insert(t);
			if (v.size()>k) v.erase(--v.end());
		}
	}
	cout<<*(--v.end());
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  string s,t; cin >> s >> t;
  if(s == t){
    cout << "Yes";
    exit(0);
  } 
  int len = s.length();
  for(int i=1;i<=len;i++){
  string last = s.substr(len-1);
  s.erase(len-1);
  s.insert(0,last);
  if(s == t){
    cout << "Yes";
    exit(0);
  } 
  }
  cout << "No";    
 
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,w=0;
    int b[100],c[100],d=0,e=0;
    int f=1,g=1;
    itn num[100]={};
    int num2[100]={};
    cin>>a;
    for(int i=0;i<a;i++){
	cin>>b[i];
	num[b[i]]++;
	num2[b[i]]++;
    }
    for(int i=0;i<a;i++){
	cin>>c[i];
    }
    for(int i=a-1;i>=0;i--){
	d+=(b[i]*f);
	f*=10;
    }
    for(int i=a-1;i>=0;i--){
	e+=(c[i]*g);
	g*=10;
    }
    f=0,g=0;
    for(itn i=min(d,e);i<=max(e,d);i++){
	f=i;
	g=0;
	while(true){
	    if(f==0) break;
	    if(num[f%10]>=1){
		num[f%10]--;
	    }
	    else{
		g=1;
		break;
	    }
	    f/=10;
	}
	if(g==0){
	    w++;
	}
	for(int i=0;i<10;i++){
	    num[i]=num2[i];
	}
    }
    cout<<w-1<<"\n";
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    ll h, w;
    cin >> h >> w;
    if(h == 1 && w == 1){
        cout << 1 << endl;
    }else if(h == 1){
        cout << w - 2 << endl;
    }else if(w == 1){
        cout << h - 2 << endl;
    }else{
        cout << (h - 2) * (w - 2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n, a, cnt;
int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(a % 2 > 0){
			cnt++;
		}
	}
	if(cnt % 2 > 0){
		cout << "NO";
	}else{
		cout << "YES";
	}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long a[100005];
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	long long flag=0;
	long long c=0,b=0;
	for(int i=n-1;i>=0;i--)
	{    
         if(flag==0)
         {
         	if(a[i]==a[i-1])
         	{
	         	c=a[i];
	         	flag++;
            }
         }
         else if(flag==1)
         {
         	if(a[i]==a[i-1]&&a[i]!=c)
         	{
	         	b=a[i];
	         	flag++;
            }
         }
         else
         break;		
	}
	for(int i=n-1;i>=0;i--)
	{
		if(a[i]==a[i-1]&&a[i-1]==a[i-2]&&a[i-2]==a[i-3])
		{   
		    if(a[i]*a[i]>b*c)
		    {
    			printf("%lld\n",a[i]*a[i]);
				return 0;
    		}
			
		} 
	}
	printf("%lld\n",b*c);
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
   ll a,b;
   cin>>a>>b;
   ll curr=1,j=1;
   while(1)
   {
   	 if(curr>=b) break;
   	 curr=j*a-j+1;
   	 j++;
   }
   cout<<j-1;
	
 return 0;
}

Measured memory_bytes: 256
#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 pb(a) push_back(a)
    #define INF 999999999999
    #define MOD 1000000007
    using namespace std;
    typedef long long LL;
    typedef pair<int, int> P;
    typedef pair<LL, LL> LP;
    typedef pair<int, P> PP;
    typedef pair<LL, LP> LPP;
    typedef vector<LL> LV;

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


    LL gcd(LL a, LL b){    return b != 0 ? gcd(b, a % b) : a;} 

    LL lcm(LL number1,LL number2){	return number1 * number2 / gcd(number1,number2);}

    int f(){
        int n;
        cin >> n;
        if(n==0) return 0;
        int ans = 1e9;
        vector<int> x(n);
        REP(i,n){
            cin >> x[i];
        }
        sort(x.begin(),x.end());
        REP(i,n-1){
            ans = min(abs(x[i+1]-x[i]),ans);
        }
        cout << ans << endl;

        return 1;

    }

    int main(){
        while(f());

        return 0;
    }


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

int main(){
  string S; cin >> S;
  ll N = S.size();
  ll ans = 0;
  char prv = ' ';
  for(ll i = 0; i < N; i++){
    if(S[i] == prv){
      if(i < N-1){
        prv = ' ';
        i++;
      }else{
        break;
      }
    }else{
      prv = S[i];
    }
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
N=int(input())
A_list=list(map(int,input().split()))

#print(N)
#print(A_list)

Flag = True
for i in range(N):
    if A_list[i] % 2 == 0:
        if A_list[i] % 3 == 0 or A_list[i] % 5 == 0:
            continue
        else:
            Flag = False
            break

if Flag:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int d[n+1];
    for(int i=0;i<n;++i) cin>>d[i]>>d[i+1];
    int a[n][n];
    fill(a[0],a[n],1<<28);
    for(int i=0;i<n;++i) a[i][i]=0;
    for(int l=1;l<n;++l)
        for(int i=0;i<n-l;++i){
            int j=i+l;
            for(int k=i;k<j;++k)
                a[i][j]=min(a[i][j],a[i][k]+a[k+1][j]+d[i]*d[k+1]*d[j+1]);
        }
    cout<<a[0][n-1]<<endl;
}

Measured memory_bytes: 3152
#include <iostream>
//#include <string>
#include <vector>
//#include <cmath>

using namespace std;
int main()
{
	int N, M, i, j, k, count = 0;
	string str;

	cin >> N;
	vector<int> A(N - 1), B(N);
	for (i = 0;i < N - 1;++i)
		cin >> A[i];
	for (i = 0;i < N - 1;++i)//zenninn
		++B[A[i] - 1];
	for (j = 0;j < N;++j)
		cout << B[j] << "\n";
	return 0;
}

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

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

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

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

    bool ok = false;
    for (ll i = 1; i <= B; i++) {
        if (A * i % B == C) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "YES\n" : "NO\n");

    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,M=nm()
A=nl()
A.sort()
A.reverse()
th=sum(A)/M/4
flag=True
for i in range(M):
    if(A[i]<th):
        flag=False

print('Yes' if flag==True else 'No' )


Measured memory_bytes: 3060
### main

while true
  n = gets.strip.to_i
  break if n == 0

  y = gets.strip.to_i

  max_or = 0.0
  max_b = nil

  n.times do
    b, r, t = gets.strip.split(' ').map{|s| s.to_i}

    if t == 1
      orr = 1 + y * r * 0.01
    else
      orr = (1 + r * 0.01) ** y
    end

    if max_or < orr
      max_or = orr
      max_b = b
    end
  end

  puts max_b
end

Measured memory_bytes: 6212
#include <cstdio>
#pragma warning(disable : 4996)
int n, g[1009][1009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == 0 || j == 0 || i == n - 1 || j == n - 1 || (i + j) % 2 == 0) g[i][j] = 1;
			else g[i][j] == 0;
		}
	}
	for (int i = 1; i <= 10; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (((j + k) & ((2 << i) - 1)) == (1 << i) - 1 && !(~k & ((1 << i) - 1))) g[j][k] = 1;
			}
		}
	}
	int c = 0;
	for (int i = 0; i < n; i++) {
		for (int j = (i & 1) ^ 1; j < n; j += 2) {
			c += g[i][j];
		}
	}
	printf("%d\n", c);
	for (int i = 0; i < n; i++) {
		for (int j = (i & 1) ^ 1; j < n; j += 2) {
			if (g[i][j]) printf("%d %d\n", i, j);
		}
	}
	return 0;
}

Measured memory_bytes: 5376
X,Y = list(map(int,input().split()))

flag = 0

for x in range(0,X+1):
    if 4 * X - 2 * x == Y:
        flag = 1
        break

if X == 1 and Y == 2:
    flag = 1
if X == 1 and Y == 4:
    flag = 1

if flag == 1:
    print('Yes')
else:
    print('No')

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

int main(void) {
	int  N,P;
	int  j=0,cnt=0,i;

	scanf("%d",&N);
	scanf("%d",&j);cnt++;

	for(i=1;i<N;i++) {
	    scanf("%d",&P);
	    if(j<P) continue;
	    j=P; cnt++;
	}
    printf("%d",cnt);
    return 0;
}

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

namespace AGC37
{
    class Program
    {
        static void Main()
        {
            var S = Console.ReadLine();

            var ans = 0;
            var before = string.Empty;
            var str = string.Empty;
            for (int i = 0; i < S.Length; i++)
            {
                str += S[i];
                if (str == before) continue;

                before = str;
                str = string.Empty;
                ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;

typedef long long ll;

const ll M = 2510;

ll dp[M + M];

int main() {
    int n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        int y;
        cin >> y;
        a[i] = y - x;
    }

    dp[M] = 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] >= 0) {
            for (int j = M + M - 1; j - a[i] >= 0; --j) {
                dp[j] += dp[j - a[i]];
            }
        } else {
            for (int j = 0; j - a[i] < M + M; ++j) {
                dp[j] += dp[j - a[i]];
            }
        }
    }

    cout << dp[M] - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 3e3 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll dp[N][N][4], n, m, k, a[N][N];
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
    	cin >> n >> m >> k;
    	for (int i = 1; i <= k; i ++) {
    		ll x, y, v;
    		cin >> x >> y >> v;
    		a[x][y] += v;
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; j ++) {
			for (int x = 0; x <= 3; x ++) {
				
					ll res = 0;
					for (int y = 0; y <= 3; y ++) {
						res = max(res, dp[i - 1][j][y]);
					}
					res = max(res, dp[i][j - 1][x]);
					dp[i][j][x] = res;
					
				
				if (!x) continue;
				res = 0;
				for (int y = 0; y <= 3; y ++) res = max(res, dp[i - 1][j][y]);
				res  = max(res, dp[i][j - 1][x - 1]);
				dp[i][j][x] = max(res + a[i][j], dp[i][j][x]);
			}
		}
	}
	cout << max({dp[n][m][1], dp[n][m][3], dp[n][m][2], dp[n][m][0]});
}

Measured memory_bytes: 358352
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;
   string s;
   cin >> s;

   if (n % 2){
      cout<<"No";
      exit(0);
   }
   
   string another = s.substr(n/2);
   string ok = s.substr(0, n/2);

   if (another == ok){
      cout<<"Yes";
   }
   else{
      cout<<"No";
   }

   return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

sm = a[0]


def f(sm):
    ret = 0
    for e in a[1:]:
        if sm * (sm + e) < 0:
            sm += e
            continue

        else:
            if sm > 0:
                a_mx = -sm - 1
                ret += e - a_mx
                sm += a_mx
            else:
                a_mn = -sm + 1
                ret += a_mn - e
                sm += a_mn

    return ret


if sm > 0:
    ans = min(f(sm), f(-1) + sm + 1)
elif sm < 0:
    ans = min(f(sm), f(1) - sm + 1)
else:
    ans = min(f(1), f(-1)) + 1

print(ans)


Measured memory_bytes: 14468
def main():
    n= int(input())
    s= input()

    r = s.count("R")
    g = s.count("G")
    b = s.count("B")

    ans = r * g * b
    snum = tuple(s[:])
    for i in range(1,n-1):
        for j in range(i,n):
            k = j * 2 - i
            if k > n:
                break

            if snum[i-1] != snum[j-1] and snum[i-1] != snum[k-1] and snum[j-1] != snum[k-1]:
                ans -= 1

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 68400
#include <iostream>
#define MAX(a,b) ((a>b)?(a):(b))
using namespace std;

int main(void){
	int a,b;
	int n;
	int k[10];
	int i;
	cin>>n;
	while(n--){
		a=b=-1;
		for(i=0;i<10;i++) cin>>k[i];
		for(i=0;i<10;i++){
			if(a>k[i]&&b>k[i])break;
			if(k[i]>a&&k[i]>b){
				if(a>b)a=k[i];
				else b=k[i];
			}else if(k[i]>a)a=k[i];
			else if(k[i]>b)b=k[i];
		}
		if(i==10)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	string s, t; cin >> s >> t;
	int a, b; cin >> a >> b;
	string u; cin >> u;
	if (s == u)cout << a - 1 << ' ' << b;
	else if (t == u)cout << a << ' ' << b - 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define finn {cout<<"No"<<endl;return 0;}
#define finy {cout<<"Yes"<<endl;return 0;}
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  map<int,int> m;
  for(int i=0;i<N;i++)m[v[i]]++;
  if(m.size()>3)finn;
  if(m.size()==1){
    if(v[0]==0)finy
    else finn;
  }
  std::vector<int> w(3);
  int cnt=0;
  for(auto p:m)w[cnt++]=p.first;
  if(m.size()==3){
    if((w[0]^w[1])!=w[2])finn;
    for(auto p:m)if(p.second*3!=N)finn;
    finy;
  }
  if(v[0]!=0)finn;
  if(m[0]*3!=N)finn;
  finy;
}


Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
};
int N,Q;
long M;
vector<pair<int,int> >G;
main()
{
	cin>>N>>M>>Q;
	UF uf(N);
	for(int i=0;i<Q;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		if(c==0)uf.unite(a,b);
		else
		{
			G.push_back(make_pair(a,b));
		}
	}
	for(pair<int,int>&p:G)
	{
		if(uf.same(p.first,p.second))
		{
			cout<<"No"<<endl;
			return 0;
		}
		p.first=uf.find(p.first);
		p.second=uf.find(p.second);
	}
	long cnt=0;
	for(int i=0;i<N;i++)
	{
		cnt+=i==uf.find(i);
		if(i==uf.find(i))
		{
			M-=uf.rank[i]-1;
		}
	}
	long lower=0,upper=cnt*(cnt-1)/2;
	if(G.size()>0)
	{
		if(cnt<3)
		{
			cout<<"No"<<endl;
			return 0;
		}
		bool ap[1<<17]={};
		long Gcnt=0;
		for(pair<int,int>p:G)
		{
			if(!ap[p.first])
			{
				ap[p.first]=true;
				Gcnt++;
			}
			if(!ap[p.second])
			{
				ap[p.second]=true;
				Gcnt++;
			}
		}
		lower=max(Gcnt,3L);
	}
	cout<<(lower<=M&&M<=upper?"Yes":"No")<<endl;
}


Measured memory_bytes: 2168
#coding: UTF-8

#a~b??????????´???°????????°

l = map(int, raw_input().split())
a = l[0]
b = l[1]
c = l[2]

ans = 0
x = a

while x <= b:
	y = c % x
	x += 1
	if y == 0:
		ans += 1

print "%d" %ans

Measured memory_bytes: 6440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll mod = 1e9 + 7;


int main(){
	int n;
	cin>>n;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j<= 9; j++){
			if(i * j == n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;


	return 0;
}






Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a<b && b<c){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	
	
	return 0;
}

Measured memory_bytes: 580
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
using namespace std;

int sum(int v[]) {
	int temp = 0;

	for (int i = 0; i < 3; i++) {
		temp += v[i];
	}

	return temp;
}

int main() {
	int a[10], b[10];

	for (int i = 0; i < 10; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < 10; i++) {
		scanf("%d", &b[i]);
	}

	sort(a, a + 10, greater<int>());
	sort(b, b + 10, greater<int>());

	printf("%d %d\n", sum(a), sum(b));

	return 0;
}

Measured memory_bytes: 1040
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <climits>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(var) var.begin(), var.end()
#define input freopen("input", "r", stdin)
#define output freopen("output", "w", stdout)
#define Fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    Fast;
    ull LIMIT = 1000000000000000000;
    int n; cin >> n;
    ull arr[n];
    bool flag = false;
    double digit = 0.0;
    for(ull &i: arr) {
        cin >> i;
        if(i == 0) 
            flag = true;
        digit += log10(i);
    }
    if(flag || digit+1 > 19){
        cout << (flag ? 0 : -1) << endl;
        return 0;
    }
    ull prod = 1;
    for(int i = 0; i < n; i++){
        if(prod * arr[i] > LIMIT){
            cout << -1 << endl;
            return 0;
        }
        else prod *= arr[i];

    }
    cout << prod << endl;
}


Measured memory_bytes: 4776
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

ll n,m,q;
vector<ll> a,b,c,d;

ll score(const vec<ll> &A){
    ll res=0;
    rep(i,q) if(A[b[i]]-A[a[i]]==c[i]) res+=d[i];
    return res;
}

ll dfs(vector<ll> &A){
    if(A.size()==n) return score(A);
    ll res=0;
    ll prev=(A.empty() ? 0:A.back());
    for(ll i=prev;i<m;i++){
        A.pb(i);
        res=max(res,dfs(A));
        A.pop_back();
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m>>q;
    a.resize(q); b.resize(q); c.resize(q); d.resize(q);
    
    rep(i,q) {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--; b[i]--;
    }
    vector<ll> A;
    cout<<dfs(A)<<endl;
    
    
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> v(n), c(n);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  for (int i = 0; i < n; i++){
    cin >> c[i];
  }
  ll ans = 0;

  for (int i = 0; i < n; ++i) {
    if (v[i] > c[i])
      ans += v[i] - c[i];
  }

  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,W;
	char S[301][301];
	int chebi[601][601]={};
	int yokoruiseki[601][601]={};
	int tateruiseki[601][601]={};
	vpint zahyo;
	ll ans=0;
	scan(H);scan(W);
	rep(i,H){
		scan(S[i]);
		rep(j,W){
			if(S[i][j]=='#'){
				zahyo.push_back(mp(W+i-j,i+j));
				chebi[W+i-j][i+j]=1;
				yokoruiseki[W+i-j][i+j+1]=1;
				tateruiseki[W+i-j+1][i+j]=1;
			}
		}
	}
	/*rep(i,H+W){
		rep(j,H+W){
			printf("%c",(chebi[i][j] ? '#' : '.'));
		}
		kaigyo;
	}*/
	rep(i,H+W){
		rep(j,H+W){
			yokoruiseki[i][j+1]+=yokoruiseki[i][j];
		}
	}
	rep(j,H+W){
		rep(i,H+W){
			tateruiseki[i+1][j]+=tateruiseki[i][j];
		}
	}
	/*rep(i,H+W){
		rep(j,H+W+1){
			printf("%d",yokoruiseki[i][j]);
		}
		kaigyo;
	}
	kaigyo;
	rep(i,H+W+1){
		rep(j,H+W){
			printf("%d",tateruiseki[i][j]);
		}
		kaigyo;
	}
	kaigyo;*/
	rep(i,H+W){
		rep(j,H+W){
			if(chebi[i][j]){
				for(int k=j+1;k<H+W;k++){
					if(chebi[i][k]){
						int d=k-j;
						if(i-d>=0) ans+=yokoruiseki[i-d][k+1]-yokoruiseki[i-d][j];
						if(i+d<H+W) ans+=yokoruiseki[i+d][k+1]-yokoruiseki[i+d][j];
					}
				}
				for(int l=i+1;l<H+W;l++){
					if(chebi[l][j]){
						int d=l-i;
						if(j-d>=0) ans+=tateruiseki[l][j-d]-tateruiseki[i+1][j-d];
						if(j+d<H+W) ans+=tateruiseki[l][j+d]-tateruiseki[i+1][j+d];
					}
				}
				//printf("i:%d j:%d ans:%lld\n",i,j,ans);
			}
		}
	}
	prin(ans);
	return 0;
}


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

int N;
string S;
string ans;

bool chk_anim(void) {
	bool ret = true;
	for (int i = 2; i < N; ++i) {
		if (S[i - 1] == 'o' && ans[i - 1] == 'S')
			ans[i] = (ans[i - 2] == 'S') ? 'S' : 'W';
		else if (S[i - 1] == 'o' && ans[i - 1] == 'W')
			ans[i] = (ans[i - 2] == 'S') ? 'W' : 'S';
		else if (S[i - 1] == 'x' && ans[i - 1] == 'S')
			ans[i] = (ans[i - 2] == 'S') ? 'W' : 'S';
		else if (S[i - 1] == 'x' && ans[i - 1] == 'W')
			ans[i] = (ans[i - 2] == 'S') ? 'S' : 'W';
		else {
			ret = false;
			return ret;
		}
	}

	if (S[N - 1] == 'o' && ans[N - 1] == 'S') {
		if (ans[0] != ans[N - 2])
			ret = false;
	}
	else if (S[N - 1] == 'o' && ans[N - 1] == 'W') {
		if (ans[0] == ans[N - 2])
			ret = false;
	}
	else if (S[N - 1] == 'x' && ans[N - 1] == 'S') {
		if (ans[0] == ans[N - 2])
			ret = false;
	}
	else if (S[N - 1] == 'x' && ans[N - 1] == 'W') {
		if (ans[0] != ans[N - 2])
			ret = false;
	}
	else
		ret = false;

	if (S[0] == 'o' && ans[0] == 'S') {
		if (ans[1] != ans[N - 1])
			ret = false;
	}
	else if (S[0] == 'o' && ans[0] == 'W') {
		if (ans[1] == ans[N - 1])
			ret = false;
	}
	else if (S[0] == 'x' && ans[0] == 'S') {
		if (ans[1] == ans[N - 1])
			ret = false;
	}
	else if (S[0] == 'x' && ans[0] == 'W') {
		if (ans[1] != ans[N - 1])
			ret = false;
	}
	else
		ret = false;

	return ret;
}

int main(void) {
	cin >> N;
	cin >> S;

	ans.resize(N, ' ');
	ans[0] = 'S';	ans[1] = 'S';
	bool flag = chk_anim();
	if (!flag) {
		ans[0] = 'S';	ans[1] = 'W';
		flag = chk_anim();
	}
	if (!flag) {
		ans[0] = 'W';	ans[1] = 'S';
		flag = chk_anim();
	}
	if (!flag) {
		ans[0] = 'W';	ans[1] = 'W';
		flag = chk_anim();
	}

	if (flag)
		cout << ans << '\n';
	else
		cout << "-1" << '\n';
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int h,H;
	int k,K;
	int a=0,b=0,c=0,d=0;
	int e=0,f=0,g=0,n=0;
	int i,j;
	scanf("%d%d",&h,&H);
	scanf("%d%d",&k,&K);
	scanf("%d%d%d%d",&a,&b,&c,&d);
	e=h/10*c;
	f=H/20*d;
	g=k/10*c;
	n=K/20*d;
	i=a*h+b*H+e+f;
	j=a*k+b*K+g+n;
	if(i>j)printf("hiroshi\n");
	else if(i==j)printf("even\n");
	else if(i<j)printf("kenjiro\n");
	return 0;
}


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

int main(){
    long long x;
    cin >> x;

    if(x%11==0){
        cout << x/11*2 << endl;
    }else{
        if( (x%11)-6 <=0 ){
            cout << x/11*2+1 << endl;
        }else{
            cout << x/11*2+2 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int main(){
	vll A, B;
	ll N;
	cin >> N;
	for (int i = 0; i < N; i++){
		ll a, b;
		cin >> a >> b;
		A.push_back(a);
		B.push_back(b);
	}
	ll m = INF;
	ll sum = 0;
	for (int i = 0; i < N; i++){
		sum += A[i];
		if (A[i] > B[i]){
			m = min(m, B[i]);
		}
	}
	if (m == INF){
		cout << 0 << endl;
	}
	else{
		cout << sum - m << endl;
	}
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int field[15][15] = {};
int x,y,n;


int main() {
  while(cin >> n,n) {
    int field[15][15] = {};
    x = (n-1)/2;
    y = (n-1)/2 + 1;
    field[y][x] = 1;
    x++;
    y++;

    for(int i=1;i<n * n;i++) {
    onemore:
      if(y<n && x<n) {
      }
      else if(x == n && y == n) {
        x = 0;
        y = 0;
      }
      else if(x == n) { //migi
        x = 0;
      }
      else if(y == n) {
        y = 0;
      }

      if(field[y][x] != 0) {
        x -= 1;
        y += 1;
        if(x == -1) x = n-1;
        goto onemore;
      }
      else {
        field[y][x] = i+1;
        x++;
        y++;
      }
    }

    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
        printf("%4d",field[i][j]);
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 0
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>

using namespace std;

int main() {
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;

    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        X=max(x,X);

    }
    for(int i=0;i<M;i++){
        int y;
        cin>>y;
        Y=min(y,Y);

    }
    if(X<Y){
        cout<<"No War"<<endl;
    }
    else{
        cout<<"War"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,s,v) for(int i=(int)s;i<(int)v;++i)
#define rf(i,s,v) for(int i=(int)s-1;i>(int)v;--i)
#define pb push_back
#define all(v) ((v.begin()),(v.end()))
#define memset(c, value) memset(c, (int)value, sizeof(c))
using namespace std;
typedef long long ll;
const int oo = 1e9;
const ll MOD =1e9+7;
void fast(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n;
int a[100002], b[100002], c[100002];
bool valid (int r,int c){
    return (r < n && r >= 0 && c >= 0 && c < n);
}
int row[] = {0 , 1 , 0, -1};
int column[] = {1 , 0, -1, 0};
int vis[100002][4];
int cnt = 0;

int dp(int i  ,int last){
    if(i == n)
        return 0;
    int &ret = vis[i][last];
    if(ret != -1)
        return ret;

    int path1 = 0, path2 = 0, path3 = 0;
    if(last != 1)
        path1 = a[i] + dp(i+1, 1);
    if(last != 2)
        path2 = b[i] + dp(i+1, 2);
    if(last != 3)
        path3 = c[i] + dp(i+1, 3);

    return ret = max(path1, max(path2, path3));
}

int main()
{
    fast();
    memset(vis, -1);
    cin>>n;
    f(i,0,n)
        cin>>a[i]>>b[i]>>c[i];
    cout<<dp(0,0)<<'\n';
    return 0;
}


Measured memory_bytes: 12436
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

constexpr ll MOD = 998244353;

ll MODpow(ll n, ll m) {
    ll result = 1;
    while (m) {
        if (m % 2 == 1) {
            result *= n;
            result %= MOD;
        }

        m /= 2;
        n *= n;
        n %= MOD;
    }

    return result;
}

class Combination {
public:
    Combination(ll max_num, ll mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (ll i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    ll operator()(ll n, ll m) const {
        if (m < 0 || m > n) return 0;
        return fact_.at(n) * inv_fact_.at(n - m) % mod_ * inv_fact_.at(m) % mod_;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:
    vector<ll> fact_, inv_fact_;
    ll mod_;
};

int main() {
    ll K, N;
    cin >> K >> N;

    vector<ll> pow2(N + 1);
    pow2[0] = 1;
    for (ll i = 1; i <= N; i++) {
        pow2[i] = pow2[i - 1] * 2 % MOD;
    }

    Combination comb(K * 2 + N * 2, MOD);

    auto H = [&](ll n, ll m) {
        return (n == 0 && m == 0 ? 1 : comb(n + m - 1, m));
    };

    for (ll i = 2; i <= 2 * K; i++) {
        ll p = 0;
        for (ll j = 1; j <= K; j++) {
            if (j < i - j && i - j <= K) {
                p++;
            }
        }

        ll ans = 0;
        for (ll q = 0; q <= min(p, N); q++) {
            //pペアのうちq個については必ずどちらか一方が1回以上出現するとする

            //iが偶数だとペアに数えていないもので1回は使えるものがある
            ll h = (i % 2 == 0 ? H(K - 2 * p + q - 1, N - q) + H(K - 2 * p + q - 1, N - q - 1)
                : H(K - 2 * p + q, N - q));
            ans += pow2[q] * comb(p, q) % MOD * h % MOD;
            ans %= MOD;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_K=1e4;
vector<int> vec[MAX_K];
int main(){
	int N;
	cin>>N;
	int ans;
	bool flg=false;
	FOR(k,1,1e4+1){
		if (k*(k-1)==2*N){
			flg=true;
			ans=k;
			int cnt=1;
			REP(i,k){
				FOR(j,i+1,k){
					vec[i].push_back(cnt);
					vec[j].push_back(cnt);
					cnt++;
				}
			}
			break;
		}
	}
	if (flg){
		cout<<"Yes"<<endl<<ans<<endl;
		REP(i,ans){
			cout<<vec[i].size();
			for(auto ite:vec[i]){
				cout<<" "<<ite;
			}
			cout<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    if(n == 1){
        cout << "Hello World";
    }else{
        int a,b; cin >> a >> b;
        cout << a + b;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int maxn = 2e5 + 5;
int mx[maxn];
int n, a[maxn];

void upd(int x, int v) {
	for (; x < maxn; x += x & -x) mx[x] = max(mx[x], v);
}

int qry(int x) {
	int ans = 0;
	for (; x; x -= x & -x) ans = max(ans, mx[x]);
	return ans;
}

struct T {
	int val, fix;
	T *ls, *rs;
	T(int v) {val = v, fix = rand(), ls = rs = NULL;}
};

void split(T *x, int v, T *&a, T *&b) {
	if (!x) {a = b = NULL; return ;}
	if (x->val <= v) a = x, split(x->rs, v, a->rs, b);
	else b = x, split(x->ls, v, a, b->ls);
}

T *merge(T *a, T *b) {
	if (!a || !b) return a ? a : b;
	if (a->fix < b->fix) {a->rs = merge(a->rs, b); return a;}
	else {b->ls = merge(a, b->ls); return b;}
}

int mxv(T *x) {while (x && x->rs) x = x->rs; return x ? x->val : 0;}
void prt(T *x) {if (x) prt(x->ls), printf("%d ", x->val), prt(x->rs);}

T *rt[maxn * 2];
vector <int> lst;
int f[maxn];

int main() {
	srand(19260817);
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
	for (int i = 0; i < n; ++ i) {
		int v = qry(n - a[i] + 1);
		rt[v] = merge(rt[v], new T(a[i]));
		f[a[i]] = v;
		upd(n - a[i] + 1, v + 1);
	}
	lst.resize(qry(n));
	for (int i = 0; i < lst.size(); ++ i) lst[i] = mxv(rt[i]);
	for (int i = 0; i < lst.size() - 1; ++ i) {
		while (rt[i]) {
			int x = mxv(rt[i]);
			int lb = i + 1, rb = lst.size();
			while (lb < rb) {
				int md = (lb + rb) >> 1;
				if (lst[md] > x) lb = md + 1;
				else rb = md;
			}
			if (lb == lst.size()) lst.pb(0);
			T *a, *b;
			split(rt[i], lst[lb], a, b);
			rt[i] = a; rt[lb] = merge(rt[lb], b);
			lst[i] = mxv(a); lst[lb] = mxv(rt[lb]);
		}
	}
	printf("%d\n", int(lst.size()) - 1);
	return 0;
}

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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define v(t) vector<t>
#define vv(t) vector<vector<t>>
#define vn(t,n,val) vector<t>(n,val)
#define vvn(t,r,c,val) vector<vector<t>>(r, vector<t>(c,val))
#define vvv(t) vector<vector<vector<t>>>
#define vvvn(t,l,b,h,val) vector<vector<vector<t>>>(l,vector<vector<t>>(b,vector<t>(h)))

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("../../input.txt", "r", stdin);
	// freopen("../../output.txt", "w", stdout);
	///////////////////////////////////////


	int n,m;
	cin>>n>>m;
	vector<long long> a(n);
	for(auto& x: a) cin>>x;
	nth_element(a.begin(), a.begin()+m-1, a.end(), greater<int>());

	// for(auto& x: a) cout<<x<<" ";

	// cout<<"\n";

	long long sum = accumulate(a.begin(), a.end(), 0ll);

	if(a[m-1]*4*m >= sum) cout<<"Yes";
	else cout<<"No";

	// int count = 0;
	// double limit = sum/(4.0*m);
	// for(auto& x: a){
	// 	if(x < limit) count++;
	// } 

	// if(n-count >= m) cout<<"Yes";
	// else cout<<"No"; 

  	return 0;
}

Measured memory_bytes: 256