akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <complex>
#define LL long long
using namespace std;
const int M = 1e3 + 5, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double PI = acos(-1);
const LL MAX=1e16+1000;
LL A[M];
int main() {
    LL n;
    while(cin>>n){
        for(int j=1;j<=n;j++){
            scanf("%lld",&A[j]);
        }
        LL ans=0;
        while(1){
            pair<LL,int> maxx={0LL,0};
            for(int j=1;j<=n;j++){
                pair<LL,int> now={A[j],j};
                maxx=max(maxx,now);
            }
            if(maxx.first<n) break;
            for(int j=1;j<=n;j++){
                if(j!=maxx.second) A[j]+=maxx.first/n;
                else A[j]=maxx.first%n;
            }
            ans+=maxx.first/n;

        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int A = 0, B = 0, C = 0; 
	for(int i = 0; i < N; i++){
		int a; 
		cin >> a; 
		if(a % 2 == 1){A ++;}
		else if(a % 4 == 2){B ++;}
		else{C ++;}
	}
	int D = A + min(B, 1); 
	if(C >= D - 1){cout << "Yes" << endl;}
	else{cout << "No" << endl;}
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int q = ri();
	
	int64_t kai3[31];
	kai3[0] = 1;
	for (int i = 0; i < 30; i++) kai3[i + 1] = kai3[i] * 3;
	for (int i = 0; i < q; i++) {
		int64_t x0, y0, x1, y1;
		std::cin >> x0 >> y0 >> x1 >> y1;
		x0--;
		y0--;
		x1--;
		y1--;
		int64_t x0_bak = x0;
		int64_t y0_bak = y0;
		int64_t x1_bak = x1;
		int64_t y1_bak = y1;
		
		int xlevel = -1;
		int64_t xcost = 0;
		for (int j = 29; j >= 0; j--) {
			bool intersect = false;
			if (x0 / kai3[j + 1] == x1 / kai3[j + 1]) {
				if (x0 % kai3[j + 1] / kai3[j] == 1 &&
					x1 % kai3[j + 1] / kai3[j] == 1) {
						int64_t y_block0 = y0 / kai3[j];
						int64_t y_block1 = y1 / kai3[j];
						if (y_block0 > y_block1) std::swap(y_block0, y_block1);
						int64_t next = y_block0 / 3 * 3 + 1;
						if (next <= y_block0) next += 3;
						if (next < y_block1) {
							intersect = true;
							xcost = std::min((x0 % kai3[j + 1] - kai3[j] + 1) + (x1 % kai3[j + 1] - kai3[j] + 1),
											(kai3[j] * 2 - x0 % kai3[j + 1]) + (kai3[j] * 2 - x1 % kai3[j + 1]));
						}
					}
			}
			if (intersect) {
				xlevel = j;
				break;
			}
		}
		
		x0 = x0_bak;
		y0 = y0_bak;
		x1 = x1_bak;
		y1 = y1_bak;
		
		int ylevel = -1;
		int64_t ycost = 0;
		for (int j = 29; j >= 0; j--) {
			bool intersect = false;
			if (y0 / kai3[j + 1] == y1 / kai3[j + 1]) {
				if (y0 % kai3[j + 1] / kai3[j] == 1 &&
					y1 % kai3[j + 1] / kai3[j] == 1) {
						int64_t x_block0 = x0 / kai3[j];
						int64_t x_block1 = x1 / kai3[j];
						if (x_block0 > x_block1) std::swap(x_block0, x_block1);
						int64_t next = x_block0 / 3 * 3 + 1;
						if (next <= x_block0) next += 3;
						if (next < x_block1) {
							intersect = true;
							ycost = std::min((y0 % kai3[j + 1] - kai3[j] + 1) + (y1 % kai3[j + 1] - kai3[j] + 1),
											(kai3[j] * 2 - y0 % kai3[j + 1]) + (kai3[j] * 2 - y1 % kai3[j + 1]));
						}
					}
			}
			if (intersect) {
				ylevel = j;
				break;
			}
		}
		x0 = x0_bak;
		y0 = y0_bak;
		x1 = x1_bak;
		y1 = y1_bak;
		int64_t res;
		if (xlevel > ylevel) {
			res = xcost + std::abs(y0 - y1);
		} else if (ylevel > xlevel) {
			res = ycost + std::abs(x0 - x1);
		} else res = std::abs(x0 - x1) + std::abs(y0 - y1);
		printf("%" PRId64 "\n", res);
	}
	return 0;
}




Measured memory_bytes: 384
n = int(input())

person = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for _ in range(n):
    b, f, r, v = map(int, input().split())
    person[b - 1][f - 1][r - 1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" %d" % (person[i][j][k]), end="")
        print("")
    if i != 3:
        print("####################")



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    string s;
    cin >> s;
    int k;
    scanf("%d", &k);

    vector<string> vec;
    
    // 辞書順 K 番目の文字列の長さが K を超えることはない
    rep(i, s.size()) {
        for (int j = 1; j <= k; j++)
        {
            string temp = s.substr(i, j); //i番目以降の文字列をj文字だけ取り出す。iは0スタート、jは1スタート。
            vec.push_back(temp);
        }
    }

    // 昇順
    sort(vec.begin(), vec.end());

    // 重複削除
    vec.erase(unique(vec.begin(), vec.end()), vec.end());

    cout << vec[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 4404
#include<iostream>
#define COST 800
#define DISCOUNT_PAR 15
#define DISCOUNT 200
using namespace std;

int main(int argc, char const *argv[]) {
  /* code */
  int N;
  int cash;

  cin >> N;
  cash = N/DISCOUNT_PAR;
  cout << (COST*N) - (DISCOUNT*cash) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
char s[200002];
int nr0_pref[200002],nr1_pref[200002],nr0_suf[200002],nr1_suf[200002];
int main()
{
    int i,n,j,nr;
    ///freopen(".in","r",stdin);
    ///freopen(".out","w",stdout);
    scanf("%d\n%s",&n,s+1);
    for(i=1; i<=n; i++)
    {
        nr0_pref[i]=nr0_pref[i-1]+(s[i]=='#');
        nr1_pref[i]=nr1_pref[i-1]+(s[i]=='.');
    }
    for(i=n; i>=1; i--)
    {
        nr0_suf[i]=nr0_suf[i+1]+(s[i]=='#');
        nr1_suf[i]=nr1_suf[i+1]+(s[i]=='.');
    }
    nr=n+1;
    for(i=0; i<=n; i++)
    {
        nr=min(nr,nr0_pref[i]+nr1_suf[i+1]);
    }
    printf("%d",nr);

    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>

int main(void)
{
  int A, B;

  scanf("%d %d", &A, &B);
  if(A == 1) {
    A = 14;
  }
  if(B == 1) {
    B = 14;
  }
  if(A < B) {
    printf("Bob\n");
  } else if(A==B) {
    printf("Draw\n");
  } else {
    printf("Alice\n");
  }

  return 0;
}


Measured memory_bytes: 128
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

def prime_factorize(n):
    prime_fact = []
    while n%2 == 0:
        prime_fact.append(2)
        n//=2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime_fact.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime_fact.append(n)
    return prime_fact

n = int(input())
a = 1
ans = 0
for i in range(1,n+1):
    a *= i
c = prime_factorize(a)
d = collections.Counter(c)
ans = 1
for value in d.values():
    ans *= (value+1)
    ans %= MOD
print(ans)

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    queue<pair<int, int>> q;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
        for (int j = 0; j < w; ++j) if (grid[i][j] == '#') {
            q.push(make_pair(i, j));
            dist[i][j] = 0;
        }
    }
    vector<int> dx = {-1, 0, 1, 0};
    vector<int> dy = {0, 1, 0, -1};
    while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        int x = p.first;
        int y = p.second;
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (dist[nx][ny] != -1) continue;
            dist[nx][ny] = dist[x][y] + 1;
            q.push(make_pair(nx, ny));
        }
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
//#define int long long
const int INF = 1 << 30;

signed main(){

  int D; cin >> D;
  vector<int> C(26);
  for(int i = 0; i < 26; i++){
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> S[i][j];
    }
  }

  int t; cin >> t;
  for(int i = 0; i < t; i++){
    cin >> t;
  }
  int m; cin >> m;
  for(int i = 0; i < m; i++){
    int d, q; cin >> d >> q;
  }

  random_device seed_gen;
  mt19937_64 rnd(seed_gen());
  uniform_int_distribution<int> dist_T(1, 26);
  clock_t start = clock();

  int score = -INF;
  vector<int> ans(D);
  while(true){
    int res = 0;
    vector<int> L(26, -1);
    vector<int> dp(D);
    for(int i = 0; i < D; i++){
      int T = dist_T(rnd);
      res += S[i][T-1];
      L[T-1] = i;
      for(int j = 0; j < 26; j++){
        if(L[j] == -1) continue;
        res -= i - L[j];
      }
      dp[i] = T;
    }
    if(score < res){
      score = res;
      ans = dp;
    }

    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
    if(time >= 1900) break;
    //cout << dp << " " << res << endl;
  }

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}

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

int main() {
	ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = a * c;
    ans = max(ans, b * d);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    cout << ans << endl;
}


Measured memory_bytes: 3640
n = int(input())
li = list(map(int, input().split()))

count = 0
for i in range(len(li)-2):
  if min(li[i], li[i+1], li[i+2]) != li[i+1] and max(li[i], li[i+1], li[i+2]) != li[i+1]:
    count += 1
  elif max(li[i], li[i+1], li[i+2]) == li[i+1] and (li[i] != li[i+2] and li[i] == max(li[i], li[i+1], li[i+2]) or li[i+2] == max(li[i], li[i+1], li[i+2])):
    count += 1  
    
print(count)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var abcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = new List<long> { abcd[0], abcd[1] };
        if (abcd[0] <= 0 && 0 <= abcd[1])
            a.Add(0);
        var b = new List<long> { abcd[2], abcd[3] };
        if (abcd[2] <= 0 && 0 <= abcd[3])
            b.Add(0);
        Console.WriteLine(a.SelectMany(x => b.Select(y => x * y)).Max());
    }
}


Measured memory_bytes: 28396
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//



     signed main(){
  int h,w,ans=0;
  cin>>h>>w;
  string c[h];
  for(int i=0;i<h;i++)cin>>c[i];
  for(int i=1;i<w;i++){
    int dp[h+1][h+1];
    for(int p=h;p>=0;p--)for(int q=h;q>=0;q--){
      if(p==h||q==h)dp[p][q]=0;
      else dp[p][q]=dp[p+1][q+1]+(c[h-1-p][i-1]==c[h-1-q][i]);
      
    }
    for(int q=1;q<=h;q++)dp[0][q]+=dp[0][q-1];
    for(int p=1;p<=h;p++){
      dp[p][0]+=dp[p-1][0];
      for(int q=1;q<=h;q++)dp[p][q]+=min(dp[p-1][q],dp[p][q-1]);
    }
    ans+=dp[h][h];
  //  cerr<<dp[h][h]<<' ';
  }
  cout<<ans<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 4496
//
//  main.cpp
//  ProblemSolving
//
//  Created by Mac mini on 1/7/20.
//  Copyright © 2020 Mac mini. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
using namespace std;
long long int  dp[51][51][1000];
int x[52], n, a;

long long int call(int idx, int cnt, int amount) {
	if(idx >= n) {
		if((double)amount / cnt == a)
			return 1;
		return 0;
	}

	if(dp[idx][cnt][amount] != -1) return dp[idx][cnt][amount];

	long long int  ret1 = 0, ret2 = 0;

	ret1 = call(idx + 1, cnt + 1, amount + x[idx]);
	ret2 = call(idx + 1, cnt, amount);

	dp[idx][cnt][amount] = ret1 + ret2;

	return dp[idx][cnt][amount];
}

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

	for(int i = 0; i < n; i++){
		cin >> x[i];
	}

	memset(dp, -1, sizeof(dp));

	cout << call(0, 0, 0) << "\n";

}


Measured memory_bytes: 23960
#include<iostream>
using namespace std;
int main()
{
  double d;
  int a[12];
  int i;
  while(cin>>d,d>=0){
    if(d>=256.0){
      puts("NA");
      continue;
    }
    for(i=0;i<7;i++)d/=2.0;
    for(i=0;i<12;i++){
      a[i]=0;
      if(d>=1){a[i]++;d--;}
      d*=2;
    }
    if(d){
      puts("NA");
    }else{
      for(i=0;i<12;i++){
	if(i==8)cout<<".";
	cout<<a[i];
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
*/

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

void solve(int n,int w,int d){
  int p,s;
  vector<pair<int,int> > data;
  data.push_back(mp(w,d));
  
  for(int i=0;i<n;i++){
    cin>>p>>s;p--;
    
    pair<int,int> x=data[p], y;
    data.erase(data.begin()+p);
    
    bool cnt=true;
    while(1){
      if(cnt&&s-x.first>0) s-=x.first;
      else if(!cnt&&s-x.second>0) s-=x.second;
      else break;  
      cnt=!cnt;
    }
    
    if(cnt){
      y=mp(s,x.second);
      x.first=abs(x.first-s);
    }else{
      y=mp(x.first,s);
      x.second=abs(x.second-s);
    }
    if(x.first*x.second<y.first*y.second){
      data.pb(x);
      data.pb(y);
    }else{
      data.pb(y);
      data.pb(x);
    }
  }

  vi ans;
  for(auto o : data)ans.pb(o.first*o.second);
  sort(all(ans));
  for(int i=0;i<ans.size();i++){
    if(i==0)cout<<ans[i];
    else cout<<" "<<ans[i];
  }
  cout<<endl;
}

int main(){
  int n,w,d;
  while(cin>>n>>w>>d&&n|w|d){
    solve(n,w,d);
  }
  return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  map<char,ll> mp;
  ll ans=0;
  for(ll i=0;i<s.size();i++){
    ans+=i-mp[s[i]];
    mp[s[i]]++;
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

char s[20];
int main(){
  scanf("%s",s);
  int len=strlen(s);

  vector<char> vec;
  rep(i,len){
    if(s[i]=='0') vec.push_back('0');
    if(s[i]=='1') vec.push_back('1');
    if(s[i]=='B' && (vec.size() !=0)) vec.erase(vec.begin()+vec.size()-1);
  }

  rep(i,vec.size()) printf("%c",vec[i]);
  printf("\n");

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
typedef long long ll;
using namespace std;



int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	ll cr = 0;
	ll cb = 0;
	ll cg = 0;
	ll ans = 1;
	ll m = 1000000007;
	for (int i = 0; i < n; ++i){
		int t = (cr == a[i]) + (cb == a[i]) + (cg == a[i]);
		ans = (ans*t) % m;
		if (cr == a[i]) cr++;
		else if (cb == a[i]) cb++;
		else if (cg == a[i]) cg++;
	}
	cout << ans%m << endl;
}




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

using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[n];
  for(int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  
  deque<int> b;
  for(int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      b.push_back(arr[i]);
    }
    else {
      b.push_front(arr[i]);
    }
  }
  
  if(n % 2 == 1) {
    reverse(b.begin(), b.end());
  }
  
  for(auto i : b) {
    cout << i << ' ';
  }
  return 0;
}

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

Measured memory_bytes: 256
import bisect
def main():
    n=int(input())
    a=list(map(int,input().split((' '))))
    two=0
    four=0
    for i in a:
        if i%4==0:
            four += 1
        elif i%2==0:
            two += 1
    if n-(two//2)*2 <=2*four +1:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()


Measured memory_bytes: 14480
S = gets.chomp

ab =S.slice(0..1).to_i
cd =S.slice(2..3).to_i

if  0 < ab && ab < 13
    if 0 < cd && cd < 13
        puts 'AMBIGUOUS'
    else
        puts 'MMYY'
    end
else
    if 0 < cd && cd < 13
        puts 'YYMM'
    else
        puts 'NA'
    end
end



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

using namespace std;

int main()
{
    int n,m;
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin>>n>>m)
    {
        vector<int> v(n+1),w(n+1),dp(m+1);
        for(int i=0;i<n;i++)
        {
            cin>>v[i]>>w[i];
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<=m;j++)
            {
                if(j-w[i]>=0)
                {
                    dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
                }
            }
        }
        cout<<dp[m]<<endl;
    }

    return 0;
}



Measured memory_bytes: 3224
#include<stdio.h>

int main() {
  int i,n,x;
  int sosu=0;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) {
    scanf("%d",&x);

    if(isPrime(x)) 
      sosu++;
  }
  printf("%d\n",sosu);
  return 0;
}
    
int isPrime(int x) {
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;

  if(x % 2 == 0) return 0;
  for(i = 3 ; i * i <= x ; i+=2) {
    if(x % i == 0) return 0;
  }
  return 1;      
}
  



Measured memory_bytes: 2124
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int cmp(string a,string b)
{
    return a.compare(b)<0;
}
int main(){
    int n,l;
    string a[105];
    scanf("%d%d",&n,&l);

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a, a+n, cmp);
    for(int i=0;i<n;i++){
        cout<<a[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k,temp,cnt =0;
    cin >> n >> k;
    for(int i =0; i <n; ++i){
        cin >> temp;
        if(temp >= k ){
            ++cnt;
        }
    }
    cout<< cnt;
    return 0;
}



Measured memory_bytes: 256
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let mut n = input!(i32);
    while 0 <= n {
        if n % 4 == 0 {
            println!("Yes");
            return;
        }
        n -= 7;
    }
    println!("No");
}


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

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

typedef long long ll;

int main(int argc, char const *argv[])
{
    ll N, K; cin >> N >> K;
    ll res = 0;
    if (K % 2 == 0) {
        res += (N/(K/2) - N/K) * (N/(K/2) - N/K) * (N/(K/2) - N/K); 
    }
    res += (N/K) * (N/K) * (N/K);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N, C = map(int, input().split())
x = [None] * N
v = [None] * N
for i in range(N):
    x[i], v[i] = map(int, input().split())

a0 = [None] * N
a = v[0] - x[0]
a0[0] = max(0, a)
for i in range(1, N):
    a += v[i] - (x[i] - x[i - 1])
    a0[i] = max(a, a0[i - 1])

a1 = [None] * N
a = v[N - 1] - (C - x[N - 1])
a1[0] = max(0, a)
for i in range(1, N):
    a += v[N - 1 - i] - ((C - x[N - 1 - i]) - (C - x[N - 1 - (i - 1)]))
    a1[i] = max(a, a1[i - 1])

#print(a0)
#print(a1)
result = -1
if a0[N - 1] > result:
    #print("go a0[N-1]")
    result = a0[N - 1]
if a1[N - 1] > result:
    #print("go a1[N-1]")
    result = a1[N - 1]
for i in range(N - 1):
    t = a0[i] - x[i] + a1[N - 1 - (i + 1)]
    if t > result:
       #print("go a0[%d] and go a1[%d]: %d" % (i, N - 1 - (i + 1), t))
       result = t
for i in range(N - 1):
    t = a1[i] - (C - x[N - 1 - i]) + a0[N - 1 - (i + 1)]
    if t > result:
       #print("go a1[%d] and go a0[%d]: %d" % (i, N - 1 - (i + 1), t))
       result = t
print(result)


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

int main(){
    int n; cin >> n;
    vector<int> p(n+1);
    int counter = 0;
    for(int i = 1 ; i <= n ; ++i) cin >> p[i];
    int min = p[1];
    for(int i = 1 ; i <= n ; ++i){
        if(p[i] < min) min = p[i];
        if(p[i] == min ) ++counter;
    }
    cout << counter << endl;
}

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

int main(){
  long long N;
  cin>>N;
  long long h,n,w;
  for(h=N/4+1;h<=3500;h++){
    for(n=h;n<=3500;n++){
      for(w=n;w<=3500;w++){
        if(4*h*n*w==N*(n*w+h*w+h*n)){
          cout<<h<<" "<<n<<" "<<w<<endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

      
    

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<sstream>

using namespace std;

int alfadata[26];//

int main(){
	string str;
	//int str;
	cin>>str;

int n = str.size();
for(int64_t i=0;i < n; i++){
//for(int i=0;i<strlen(str);i++){
	int index = str.at(i)-'a'; //今見ている文字列をアルファベット昇順の順番の数に変換する
	alfadata[index]++; //カウンタを増やす
}

int flag=0; //数え上げたアルファベットの数を確認する

for(int i=0;i<26;i++){
	if(alfadata[i]%2==1)flag=1;
}

	if(flag==0)cout<< "Yes"<<endl;
	else cout<< "No"<<endl;
	
	return 0;

	}


Measured memory_bytes: 3556
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  string ans = S.substr(0, S.size() - 8);
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
t = [[] for i in range(N)]
ans = []
for i in range(M): 
    p,y = map(int,input().split())
    t[p-1].append([y,i])
    ans.append('')
for i in range(N):
    t[i].sort(key=lambda x:x[0])
    for j in range(len(t[i])):
        ans[t[i][j][1]] = '0'*(6-(len(str(i+1))))+str(i+1)+'0'*(6-(len(str(j+1))))+str(j+1)
for i in range(M):
    print(ans[i])


Measured memory_bytes: 84128
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int> acc(n + 1, 0);
    acc[0] = 0;
    for(int i = 1; i < n; i++){
        if(s[i - 1] == 'A' && s[i] == 'C') acc[i + 1] = 1;
    }
    for(int i = 1; i <= n; i++) acc[i] += acc[i - 1];
    for(int i = 0; i < q; i++){
        int l, r; cin >> l >> r;
        cout << acc[r] - acc[l] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
w = input()
n = len(w)
alpha = [chr(i) for i in range(ord('a'), ord('z')+1)]

all_even = True
for i in range(26):
    cnt = 0
    for j in range(n):
        if alpha[i] == w[j]:
            cnt += 1
    if cnt % 2 != 0:
        all_even = False

if all_even:
    print('Yes')
else:
    print('No')


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

using namespace std;

int mod(int a,int b){
	
	if(a>b){
		return a-b;
	}
	return b-a;
	
}

int main(){
	
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	int dp1[n]={0};
	int dp2[n]={0};
	dp1[0]=0;
	//dp2[0]=0;
	dp1[1]=mod(a[1],a[0]);
	//dp2[1]=a[1]-a[0];
	for (int i=2;i<n;i++){
		dp1[i]=min(dp1[i-1]+mod(a[i],a[i-1]),dp1[i-2]+mod(a[i],a[i-2]));
		//cout<<dp1[i]<<" ";
	}
	cout<<dp1[n-1];
	
}

Measured memory_bytes: 4804
use std::io;

fn main(){
    let mut buf1 = String::new();
    io::stdin().read_line(&mut buf1).ok();
    let n: usize = buf1.trim().parse().unwrap();

    let mut buf2 = String::new();
    io::stdin().read_line(&mut buf2).ok();
    let mut v: Vec<usize> = buf2.split_whitespace().map(|s| s.parse().unwrap()).collect();
    
    v.sort();

    let mut ans: usize = 0;
    for i in 0..n {
        for j in 0..i {
            for k in 0..j {
                if v[i] != v[j] && v[i] != v[k] && v[j] != v[k] && v[k] + v[j] > v[i] {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2120
n = int(input())
l = map(int,input().split())

isDenyed = False

for x in l :
   if x % 2 == 0 :
       if (x % 3 == 0) or (x % 5 == 0) :
           continue
       else :
           isDenyed = True
           break

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


Measured memory_bytes: 2940
from collections import Counter

N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

d = Counter(D)
t = Counter(T)

for k, v in t.items():
    if d[k] < v:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 56928
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  vector<double>dp(n+1);
  dp[0]=1;
  for(int coins=0 ; coins<n ; coins++){
    double x;
    cin>>x;
    for(int i = coins+1 ; i>=0 ; i--){
      dp[i]=(i==0 ? 0 : dp[i-1])*x + dp[i]*(1-x);
    }
  }
  double sum = 0;
  for(int i=n;i>=(n+1)/2;i--){
    sum = sum + dp[i];
  }
  printf("%.10lf",sum);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct UnionFind {
    vector<int> node;

    UnionFind() = default;
    UnionFind(int x) {init(x);}

    void init(int x) {
        node.assign(x,-1);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (node[x] > node[y]) swap(x,y);
        node[x] += node[y];
        node[y] = x;
        return true; 
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int root(int x) {
        if (node[x] < 0) return x;
        return node[x] = root(node[x]);
    }

    int size(int x) {
        return -node[root(x)];
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,M; cin >> N >> M;
    UnionFind uf(2*N);
    rep(i,M) {
        int u,v; cin >> u >> v;
        --u; --v;
        uf.merge(u,v+N);
        uf.merge(v,u+N);
    }
    ll a = 0, b = 0, c = 0;
    vector<bool> check(2*N);
    rep(i,N) {
        if (check[uf.root(i)]) continue;
        if (uf.size(i)==1) c++;
        else if (uf.same(i,i+N)) b++;
        else a++;
        check[uf.root(i)] = check[uf.root(i+N)] = 1;
    }
    ll ans = 0;
    ans += N*N - (N-c)*(N-c);
    ans += a*a*2;
    ans += b*b;
    ans += a*b*2;
    cout << ans << ln;
}

Measured memory_bytes: 1152
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[]
for i in range(m):
    ab.append(list(map(int,input().split())))
count=[1]*n
for i in range(m):
    if h[ab[i][0]-1]<h[ab[i][1]-1]:
        count[ab[i][0]-1]=0
    elif h[ab[i][0]-1]>h[ab[i][1]-1]:
        count[ab[i][1]-1]=0
    else:
        count[ab[i][0]-1]=0
        count[ab[i][1]-1]=0
print(count.count(1))

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

int main() {
  string s;
  cin >> s;
  if(s == "SUN")
    cout << 7;
  if(s == "MON")
    cout << 6;
  if(s == "TUE")
    cout << 5;
  if(s == "WED")
    cout << 4;
  if(s == "THU")
    cout << 3;
  if(s == "FRI")
    cout << 2;
  if(s == "SAT")
    cout << 1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[1001];
char a[1001];
int i,ls,ans;
int main()
{
	gets(s);
	ls=strlen(s);
	ans=0;
	for(i=0;i<ls;i++)
	{
		if(s[i]=='0' || s[i]=='1')
		{
			ans++;
			a[ans]=s[i];
		}
		else if(s[i]=='B')
		{
			if(ans>=1)
			ans--;
		}
	}
	for(i=1;i<=ans;i++)
	printf("%c",a[i]);
	printf("\n");
	return 0;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int M = 998244353;

int add(int a, int b) {
  a += b;
  if (a >= M) {
    return a - M;
  }
  if (a < 0) {
    return a + M;
  }
  return a;
}

int mul(int a, int b) {
  return a * (ll) b % M;
}

int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) {
      r = mul(r, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return r;
}

int dv(int a, int b) {
  return mul(a, pw(b, M - 2));
}

const int N = 3000 + 7;
int n, s, dp[N][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    for (int j = 0; j <= s; j++) {
      dp[i][j] = mul(2, dp[i - 1][j]);
      if (j >= x) {
        dp[i][j] = add(dp[i][j], dp[i - 1][j - x]);
      }
    }
  }
  cout << dp[n][s] << "\n";
  return 0;
}


Measured memory_bytes: 38872
n,m = map(int,input().split())

x = [0] * n

for i in range(m):
    a,b = map(int,input().split())
    x[a-1] = (x[a-1]+1)% 2
    x[b-1] = (x[b-1] + 1)%2

c = 0
for i in range(n):
    if x[i] == 0:
        c += 1

if c == n:
    print('YES')
else:
    print('NO')

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

int main() {
    int64_t N, L;
    cin >> N >> L;
    vector<int64_t> a(N);
    for (int64_t& A : a) {
        cin >> A;
    }

    for (int64_t i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] < L) {
            continue;
        }

        cout << "Possible" << endl;
        for (int64_t j = 0; j < i; j++) {
            cout << j + 1 << endl;
        }
        for (int64_t j = N - 2; j >= i; j--) {
            cout << j + 1 << endl;
        }
        return 0;
    }

    cout << "Impossible" << endl;
}

Measured memory_bytes: 1664
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, Z: int, W: int, a: "List[int]"):
    dp = [(0, 0)] * N
    if N == 1:
        dp[N - 1] = (abs(a[N - 1] - W), abs(Z - a[N - 1]))
    else:
        dp[N - 1] = (abs(a[N - 1] - a[N - 2]), abs(a[N - 2] - a[N - 1]))
    for i in reversed(range(N - 1)):
        v1 = max(dp[j][1] for j in range(i + 1, N))
        if i == 0:
            v1 = max(v1, abs(a[N - 1] - W))
        else:
            v1 = max(v1, abs(a[N - 1] - a[i - 1]))
        v2 = min(dp[j][0] for j in range(i + 1, N))
        if i == 0:
            v2 = min(v2, abs(Z - a[N - 1]))
        else:
            v2 = min(v2, abs(a[i - 1] - a[N - 1]))
        dp[i] = (v1, v2)
    print(dp[0][0])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, Z, W, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	map<int, int> mp;
	rep(i, n) {
		mp[a[i]]++;
		mp[a[i] + 1]++;
		mp[a[i] - 1]++;
	}
	int ans = 0;
	for (auto& c : mp) {
		ans = max(ans, c.second);
	}
	dunk(ans);
	return 0;
}

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

int main()
{
	int N; cin >> N;
	
	vector<int> p(N), q(N);
		
	for (int i = 0; i < N; i++) cin >> p.at(i);
	for (int i = 0; i < N; i++) cin >> q.at(i);

	vector<int> vec(N);
	for (int i = 0; i < N; i++){ vec.at(i) = i + 1; }

	int p_order, q_order, count = 1;

	do { 
		if (vec == p) p_order = count;
		if (vec == q)  q_order = count;
		
		count++;

	} while (next_permutation(vec.begin(), vec.end()));

	cout << abs(p_order-q_order) << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);

int dp[3005][3005];

int main() {
    int n, t;
    cin >> n >> t;
    vector<P> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;
    sort(p.begin(),p.end());
    int ans = 0;
    rep(i,n) {
        rep(j,t) {
            chmax(dp[i+1][j], dp[i][j]);
            int nj = j + p[i].first;
            if (nj < t) chmax(dp[i+1][nj], dp[i][j]+p[i].second);
        }
        int now = dp[i][t-1] + p[i].second;
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 38828
#include <stdio.h>
int main(void){
  int a,b;
  scanf("%d %d\n", &a, &b);

  if(-1000<=a && b <= 1000){
    if(a < b) printf("a < b\n");
    else if(a > b) printf("a > b\n");
    else if(a == b) printf("a == b\n");
  }

  return 0;
}

Measured memory_bytes: 584
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        ll N;
        cin >> N;

        set<ll> v;

        for (ll i = 1; i * i <= N; ++i) {
            if (N % i == 0) {
                v.insert((i - 1));
                v.insert((N / i - 1));
            }
        }
        ll ans = 0;
        for (auto e : v) {
            if (e > 0 && N % e == N / e) {
                ans += e;
            }
        }
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


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

int32_t main(){
	int n,k;
	cin>>n>>k;

	long long res = 0;
	vector<long long> arr(n);
	for(int i = 0; i < n; i++) cin>>arr[i];
	for(int i = 40;i>=0;i--){
		int cnt = 0;
		for(int j = 0; j < n; j++){
			if((arr[j]>>i)&1){
				cnt++;
			}
		}
		if(cnt*2<n && (res+(1LL<<i))<=k){
			res+=(1LL<<i);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans+=(res^arr[i]);
	}
	cout<<ans;
}

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

int main(){
    string s;
    set<char> c;
    cin>>s;
    for(int i=0;i<(int)s.length();i++) c.insert(s[i]);

    for(char i='a';i<='z';i++){
        if(c.find(i)==c.end()){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}

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

const double EPS = 1e-8;

int main() {
	ios::sync_with_stdio(false);
	
	int a,b;
	cin >> a >> b;
	for (int i = 1; i <= 1265; i++) {
		if ((0.08*i>a-EPS) && (0.08*i<a+1-EPS) &&
			(0.1*i>b-EPS) && (0.1*i<b+1-EPS)) {
			cout << i << "\n";
			return 0;
		}
	}
	cout << -1 << "\n";
}

Measured memory_bytes: 256
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans = -INF;
    chmax(ans ,a * d);
    chmax(ans ,b * d);
    chmax(ans ,a * c);
    chmax(ans ,b * c);
    out(ans);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


Measured memory_bytes: 3628
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [None]*M
y = [None]*M
c = [None]*M
for i in range(M):
  x[i],y[i],c[i] = map(int, input().split())
#print(x,y,c)
ans = min(a)+min(b)
for i in range(M):
  tmp = a[x[i]-1]+b[y[i]-1]-c[i]
  if tmp < ans:
    ans = tmp
print(ans)

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    ll d,g; cin >> d >> g;
    vector<ll> p(d);
    vector<ll> c(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
    }

    ll ans = LONG_MAX;

    // 全完する得点の問題を決めてbit全探索
    for (int bit = 0; bit <= (1<<d); bit++) {
        // 合計点
        ll sum = 0;
        // 解いた問題数
        ll count = 0;
        rep(i, d) {
            if(bit & (1<<i)) {
                sum += c[i] + p[i] * 100 * (i+1);
                count += p[i];
            }
        }

        // 既に目標点を超えてる場合
        if(sum >= g) chmin(ans, count);
        else {
            // 超えていない場合は、残っている問題の中で一番配点が高いのを解く

            // デクリメントするforで配点が大きい順に見ていく
            for(int i=d-1; i >= 0; i--) {
                // 既に全完している問題は飛ばす
                if(bit & (1<<i)) continue;
                rep(j, p[i]) {
                    if(sum >= g) break;
                    sum += 100 * (i+1);
                    count++;
                }
                // 中途半端に解くのは1つだけなのでbreakする
                break;
            }
            if(sum >= g) chmin(ans, count);
        }
    }

    cout << ans << endl;

    return 0;



}



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

int main()
{
 int a, b, c, d, n1, n2;
 scanf("%d", &a);   scanf("%d", &b);    scanf("%d", &c);    scanf("%d", &d);
 if (abs(a - c) <= d || abs(a - b) <= d && abs(b - c) <= d)
    puts("Yes");
 else 
    puts("No");
 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

int main() {
  ll N;
  for (auto i = 0;i < 5;i ++) {
    cin >> N;
    if (N == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int main(void) {
    int N;
    cin >> N;
    cout << N / 3 << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; cin>>s;
    ll ans=s.length();
    rep(i,s.length()-1){
        if(s[i]!=s[i+1]){
            ll x=max((ll)i+1,(ll)s.length()-(ll)i-1);
            chmin(ans,x);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
sm=0
for i in range(n+1):
  sm+=abs(a[i+1]-a[i])

for i in range(n):
  print(sm-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]))


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C;
  if(A>B){
    swap(A,B);
  }
  if(B>C){
    swap(B,C);
  }
  if(A>B){
    swap(A,B);
  }
  int count=0;
  D=0;
  while(C-1>A){
    A+=2;
    count++;
  }
  while(C-1>B){
    B+=2;
    count++;
  }
  if(A==C){
    D++;
  }
  if(B==C){
    D++;
  }
  if(D==2){
    cout << count << endl;
  }
  else if(D==1){
    cout << count+2 << endl;
  }
  else{
    cout << count+1 << endl;
  }
}
    
  

Measured memory_bytes: 256
S = str(input())
N = len(S)

alpha2num = lambda c: ord(c) - ord('a') + 1
#print(alpha2num("a"))
#print(alpha2num("Z"))
p = 0
s = 0
for i in range(N):
  if i == 0:
    if S[i] != "A":
      p = 1
  elif 2 <= i <= N - 2:
    if S[i] == "C":
      s += 1
    else:
      if alpha2num(S[i]) < 0:
        p = 1
  else:
    if alpha2num(S[i]) < 0:
      p = 1 
      

  
  
if (p == 0) and (s == 1):
  print("AC")
else:
  print("WA")


Measured memory_bytes: 9040
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
int N,M,Q;



int main() {
	cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A[i];
	cin >> M;
	vector<int> B(M);
	rep(i, M) cin >> B[i];
	cout << lexicographical_compare(A.begin(),A.end(),B.begin(),B.end()) << endl;
	return 0;
}





Measured memory_bytes: 3104