akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC92();
}

void ABC92(){
    int n,d,x,i,j,ans=0;
    cin>>n>>d>>x;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    for(i=0;i<d;i++){
        for(j=0;j<n;j++){
            if(i%vec[j]==0)ans++;
        }
    }
    cout<<ans+x<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int a, b; cin>>a>>b;
    if(12 < a) cout << b << endl;
    else if(5 < a) cout << b / 2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
A, B, C, D = map(int,input().split())

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

lcm = (C * D) // gcd(C, D)
Am = A - 1

min1 = Am // C
min2 = Am // D
min3 = Am // lcm

max1 = B // C
max2 = B // D
max3 = B // lcm

n = B - max1 - max2 + max3 - (Am - min1 - min2 + min3)
print(n)

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

int main() {
	int h, n;
	cin >> h >> n;
	
	int ts = 0, tmp;
	for(int i = 0; i<n; i++) {
		cin >> tmp;
		ts += tmp;
	}
	
	if((1.0*h/ts) > 1.0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , x;
int l[MAXX];
int a[MAXX];

int main()
{
    _FastIO;
    cin >> n >> x;
    int ans = 1;
    for(int i = 0; i < n; i++){
        cin >> l[i];
        a[i + 1] = a[i] + l[i];
        if(a[i + 1] <= x)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,k,p[1000],i,j,a=0,c=0,b=0;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		b+=p[i];
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(p[i]<p[j]){
				a=p[j];
				p[j]=p[i];
				p[i]=a;
			}
		}
	}
	for(i=0;i<n-k;i++){
		b-=p[i];
	}
	printf("%d\n",b);
	return 0;
}


Measured memory_bytes: 1668
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
string a,b;
int ans=INF,cnt;
int main()
{
	cin>>a>>b;
	for (int i=0;i<=a.size()-b.size();i++)
	{
		cnt=0;
		for (int j=0;j<b.size();j++)
		{
			if (a[i+j]!=b[j]) ++cnt;
			//cout<<a[i+j]<<" "<<b[j]<<endl;
		}
		//cout<<cnt<<endl;
		ans=min(ans,cnt);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	static int lcs(String left,String right){

		int left_len = left.length();
		int right_len = right.length();

		int dp[][] = new int[left_len+1][right_len+1];

		for(int i = 0; i <= left_len; i++){
			for(int k = 0; k <= right_len; k++){
				dp[i][k] = 0;
			}
		}

		for(int i = 0; i < left_len; i++){
			for(int k = 0; k < right_len; k++){
				if(left.charAt(i) == right.charAt(k)){
					dp[i+1][k+1] = dp[i][k]+1;
				}else{
					dp[i+1][k+1] = Math.max(dp[i+1][k], dp[i][k+1]);
				}
			}
		}

		return dp[left_len][right_len];
	}

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.nextLine());

		String left,right;

		for(int i = 0; i < N; i++){
			left = sc.nextLine();
			right = sc.nextLine();

			System.out.printf("%d\n", lcs(left,right));
		}
	}
}

Measured memory_bytes: 64908
#include <iostream>
#include <bits/stdc++.h>
using namespace std; 
int main () 
{
	int x,a,res;
	cin >> x;  
	a = x%1000;
	res = 1000-a; 
	if (x%1000!=0)
	{
		cout << res << endl;
	}
	else 
	{
		cout << "0" << endl; 
	}
	

}

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

using namespace std;
mt19937_64 rng(58);

/* O(sqrt(n))
   n =     100,000   cost ~  0.0sec, max prime =   1,299,709
   n =   1,000,000   cost ~  1.7sec, max prime =  15,485,867
   n =  10,000,000   cost ~ 46.1sec, max prime = 179,424,673, ram ~ 40MB
*/
void generate_primes(int n, vector<long long> &primes) {
  primes = { 2, 3, 5 };
  n -= 3;
  auto is_prime = [](long long t, vector<long long> &primes) -> bool {
    for (auto p : primes) {
      if (p * p > t) break;
      if (t % p == 0) return false;
    }
    return true;
  };
  for (long long six = 6; n > 0; six += 6) {
    if (is_prime(six + 1, primes)) primes.push_back(six + 1), n--;
    if (is_prime(six + 5, primes)) primes.push_back(six + 5), n--;
  }
}

/* return 2, 2, 2, 5, 7 for 2^3 * 5 * 7 */
vector<long long> factorize(long long x, vector<long long> &primes) {
  vector<long long> factors;
  long long bound = x;
  for (auto p : primes) {
    if (x == 1 || p * p > bound) break;
    for (; x % p == 0; x /= p) factors.push_back(p);
  }
  if (x != 1) factors.push_back(x);
  return factors;
}

template<typename T>
vector<pair<T, int>> rle_compress(vector<T> list) {
  vector<pair<T, int>> r;
  for (auto e : list) {
    if (r.empty() || e != r.back().first) r.emplace_back(e , 1);
    else (r.end() - 1)->second++;
  }
  return r;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    long long n;
    cin >> n;
    vector<long long> primes;
    generate_primes(100000, primes);
    vector<pair<long long, int>> factors = rle_compress(factorize(n, primes));
    long long ans = 0;
    for (auto f: factors) {
        int p = f.second;
        for (int n = 1; n <= p; p -= n, n++) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4944
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
#define _(i,a,n) for(int i=a;i<n;i++)
#define zero(a) a[0]=0
bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
int n,x,t;
cin>>n>>x>>t;
int z;
if(n%x==0)
    z=n/x;
else
    z=n/x+1;
cout<<z*t<<endl;
}


Measured memory_bytes: 3588
a,b=map(int,input().split())

def xorsum(x):
  if x % 4 == 1:
    return 1
  elif x % 4 == 3:
    return 0
  elif x % 4 == 0:
    return 1 ^ (x+1)
  else:
    return 0 ^ (x+1)

print(xorsum(b)^xorsum(a-1))

Measured memory_bytes: 8980
# D
n=int(input())
a=[int(i) for i in input().split()]
 
ans=0
b=0
j=0
for i in range(n):
    while j<n and b^a[j]==b+a[j]:
        b^=a[j]
        j=j+1
    ans += j-i
    b^=a[i]
print(ans)

Measured memory_bytes: 23560
N,K,Q = map(int,input().split())
lsN = [K-Q]*N
for i in range(Q) :
    p = int(input())
    lsN[p-1] = lsN[p-1]+1

for i in lsN:
    if i > 0:
        print('Yes')
    elif i <= 0:
        print('No')

Measured memory_bytes: 76544
a[5][1<<18],b[2],x,y,j,n;main(i){scanf("%d",&n);for(;++i<5;)for(j=0;j<n;++j){scanf("%d",&a[i][j]);--a[i][j];}for(j=0;j<n;++j){if(a[2][j]/3-a[3][j]/3||a[3][j]/3-a[4][j]/3||a[4][j]/3-a[2][j]/3||a[3][j]%3-1||a[3][j]/3-j&1){b[0]=1;break;}x=y=a[3][j]/3+1;for(;x;x-=x&-x)b[j&1]-=a[j&1][x]%2;b[j&1]+=j/2;for(;y<2e5;y+=y&-y)++a[j&1][y];if(a[2][j]%3)++b[1-j%2];}puts(b[0]&1|b[1]&1?"No":"Yes");}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const double PI = 3.141592653589793;

int main()
{
  i64 A, B, H, M;
  cin >> A >> B >> H >> M;
  double Ax = cos(2 * PI / 12 * H + 2 * PI / 12 / 60 * M) * A, Ay = sin(2 * PI / 12 * H + 2 * PI / 12 / 60 * M) * A;
  double Bx = cos(2 * PI / 60 * M) * B, By = sin(2 * PI / 60 * M) * B;
  cout << fixed << setprecision(10) << hypot(Ax - Bx, Ay - By) << endl;
  return 0;
}


Measured memory_bytes: 4144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int H, W;

int tate(void){
    if(W%3==0) return 0;
    else return H;
}

int yoko(void){
    if(H%3==0) return 0;
    else return W;
}

int t(void){
    int n[3];
    int ret;
    n[0]=W*(H/3);
    n[1]=(H-H/3)*(W/2);
    n[2]=H*W-n[0]-n[1];
    ret = n[1]>n[0] ? n[2]-n[0] : n[2]-n[1];
    
    int tmp;
    n[0]=W*(H/3+1);
    n[1]=(H-H/3-1)*(W/2);
    n[2]=H*W-n[0]-n[1];
    tmp = n[0]>n[2] ? n[0]-n[1] : n[2]-n[1];
    
    if(tmp<ret) ret = tmp;
    return ret;
}

int to(void){
    swap(H,W);
    return t();
}

int main(){
    cin >> H >> W;
    int res=tate();
    cerr << res << endl;
    int tmp;
    tmp=yoko();
    if(res>tmp) res=tmp;
    cerr << tmp << endl;
    tmp=t();
    if(res>tmp) res=tmp;
    cerr << tmp << endl;
    tmp=to();
    if(res>tmp) res=tmp;
    cerr << tmp << endl;
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
 
int n;
long long ans;
 
inline int getfirst(int x) {
    while (x > 9) x /= 10;
    return x;
}
 
inline int cutfirst(int x) {
    int first = getfirst(x), tmp = x;
    while (tmp > 9) tmp /= 10, first *= 10;
    return x - first;
}
 
inline int BIT(int x) {
    int ans = 0;
    while (x) x /= 10, ++ans;
    return ans;
}
 
inline int cnt(int bit) {
    if (bit < 0) return 0;
    int ans = 1;
    while (bit--) ++(ans *= 10);
    return ans;
}
 
int main() {
    scanf("%d", &n);
    if (n < 10) return printf("%d\n", n), 0;
    int first = getfirst(n);
    int middle = cutfirst(n) / 10;
    int last = n % 10;
    int bit = BIT(n);
    int a = cnt(bit - 2);
    int b = cnt(bit - 3);
    for (int i = 1; i <= n; ++i) {
        int f = getfirst(i);
        int l = i % 10;
        if (!l) continue;
        if (f == l) ++ans;
        if (l == first) ans += b + middle + 1 - (f > last);
        else if (l < first) ans += a;
        else ans += b;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

vector<vector<ll> > v(30000);

int main()
{
	ll n,k;cin >> n >> k;
	
	REP(i,n)
	{
		ll a,b;
		char c;
		cin >> a >> b >> c;
		if(c != 'W')
		{
			if(a < k)a += k;
			else a -= k;
		}
		a = a % (2LL*k);
		b = b % (2LL*k);
		v[a].PB(b);
		
	//	cout << a << ' ' << b << endl;
	}
	
	ll ans = 0;
	REP(i,k+1)
	{
		ll l = i;
		ll r = i+k-1;
		ll now = 0;
		REP(j,2*k)
		{
			if(j >= k)
			{
			//	cout << "!!" << endl;
				REP(q,v[j].size())
				{
					ll tmp = v[j][q];
					if(tmp >= l && tmp <= r)now++;
					else now--;
				}

				REP(q,v[j-k].size())
				{
					ll tmp = v[j-k][q];
					if(!(tmp >= l && tmp <= r))now++;
					else now--;
				}
			}
			else
			{
			//	cout << "!!!" << endl;
				REP(q,v[j+k].size())
				{
					ll tmp = v[j+k][q];
					if(!(tmp >= l && tmp <= r))now++;
				}
				
				REP(q,v[j].size())
				{
					ll tmp = v[j][q];
					if(tmp >= l && tmp <= r)now++;
				}
			}	
			
			ans = max(ans,now);
			if(j >= k)ans = max(ans,n-now);
			//cout << i << ' ' << j << ' '<< now << endl;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2176
n = int(input())
str_dict = {}
for _ in range(n):
	s = "".join(sorted(input()))
	if s in str_dict:
		str_dict[s] += 1
	else:
		str_dict[s] = 1
ans = 0
for v in str_dict.values():
	for i in range(1, v):
		ans += i
print(ans)

Measured memory_bytes: 17852
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;

//ABC084C
  //11:31-

int TIME(int m,int &n,vector<int> &C,vector<int> &S,vector<int> &F){
   ll time=0;
   for(int i=m;i<n;i++){
      int s=time;
      
      if(s>=S[i]){
         if(s%F[i]==0) s=time; 
         else s=time+F[i]-time%F[i];

      }else s=S[i];

       time=s+C[i];
   }
   return time;
}

int main(){
   int n; cin>>n;
   //駅iから駅i+１にC[i]秒で向かう電車がS[i]＋F[i]秒に出発する
   //駅iにいる時の駅nまでにかかる時間を関数で処理
   //まずS[i]で電車に初めて乗るのは確定

   vector<int>C (n);
   vector<int>S (n);
   vector<int>F (n);

   REP(i,n-1)cin>>C[i+1]>>S[i+1]>>F[i+1];

  REP(i,n){
    cout<<TIME(i+1,n,C,S,F)<<endl;
  }
   
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# abc149/abc149_b
import sys


def s2nn(s): return [int(c) for c in s.split(' ')]


def ss2nn(ss): return [int(s) for s in list(ss)]


def ss2nnn(ss): return [s2nn(s) for s in list(ss)]


def i2s(): return sys.stdin.readline().rstrip()


def i2n(): return int(i2s())


def i2nn(): return s2nn(i2s())


def ii2ss(n): return [i2s() for _ in range(n)]


def ii2nn(n): return ss2nn(ii2ss(n))


def ii2nnn(n): return ss2nnn(ii2ss(n))


def main():
    A, B, K = i2nn()
    if A > K:
        print(A - K, B)
    elif A + B > K:
        print(0, B + A - K)
    else:
        print(0, 0)
    return


main()


Measured memory_bytes: 3064
import Text.Printf

sum_decimal :: Int->Int->Int->Int->Int
sum_decimal a b n i 
    | i==n      = d
    | otherwise = d + (sum_decimal a' b n (i+1))
        where a' = (a*10)`mod`b
              d = (a*10)`div`b

solve :: String->IO ()
solve str = do
    let dat = map (\x->read x::Int) $ words str
    let (a, b, n) = (dat!!0, dat!!1, dat!!2)
    printf "%d\n" (sum_decimal (a`mod`b) b n 1)

main :: IO ()
main = do
    str <- getContents
    mapM_ solve $ lines str

Measured memory_bytes: 4096
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
route = {i:[] for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    route[a].append(b)
    route[b].append(a)  

ans = 0

for f, ts in  route.items():
    hi_flag = True
    for t in ts:
        if h_list[f-1] <= h_list[t-1]:
            hi_flag = False
            break
    if hi_flag:
        ans += 1
print(ans)

Measured memory_bytes: 37880
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
c = input().rstrip()
bad_white = deque()
bad_red = deque()
for i, ch in enumerate(c):
    if ch == "W":
        bad_white.append(i)
    else:
        bad_red.appendleft(i)

ans = 0
while bad_white and bad_red and bad_white[0] < bad_red[0]:
    bad_white.popleft()
    bad_red.popleft()
    ans += 1
print(ans)

Measured memory_bytes: 17364
#include<stdio.h>

int main(){
  int N, M;
  
  scanf("%d", &N);
  
  M = N/100 + (N%100)/10*10 + (N%10)*100;
  
  if(N == M){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
using Graph = vector<vector<ll>>;
int main()
{
  ll N, X, Y; cin >> N >> X >> Y;
  vector<ll> K(N, 0);
  Graph G(N + 1);
  for (ll i = 1; i < N; i++) {
  	G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[X].push_back(Y);
  G[Y].push_back(X);
  
  vector<ll> dist(N + 1, -1);
  queue<ll> que;
  
  for (int i = 1; i < N; i++) {
  	dist[i] = 0;
  	que.push(i);
    while (!que.empty()) {
  		ll v = que.front();
    	que.pop();
    
    	for (ll nv : G[v]) {
    		if (dist[nv] != -1)
    	      continue;
    	  dist[nv] = dist[v] + 1;
    	  que.push(nv);
    	}
  	}
    for (ll v = i; v <= N; v++) {
    	K[dist[v]]++;
    }
    dist = vector<ll>(N + 1, -1);
  }
  for (ll i = 1; i < N; i++) {
  	cout << K[i] << endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

char s1[4][11] = {"dream", "dreamer", "erase", "eraser"};
int l1[4] = {5, 7, 5, 6};

char s[101010];
bool f[101010];

int main()
{
	scanf("%s", s);
	int l = strlen(s);
	f[0] = 1;
	for(int i = 0; i < l; ++i)
	{
		if(f[i])
		{
//			cout<<i<<endl;
			for(int j = 0; j < 4; ++j)
			{
				bool flag = 0;
				for(int k = 0; k < l1[j]; ++k)
					if(s1[j][k] != s[i + k])
					{
						flag = 1;
						break;
					}
				if(!flag)
					f[i + l1[j]] = 1;
			}
		}
	}
	if(f[l])
		puts("YES");
	else
		puts("NO");
	
	return 0;
}


Measured memory_bytes: 384
n=int(input())
A=[1]*(n+1)
A[1]=1
for i in range(2,n+1):
    for j in range(i,n+1,i):
        A[j]+=1
A[1]=1
sum=0
for i in range(1,n+1):
    sum+=i*A[i]
print(sum)

Measured memory_bytes: 151608
inf=float("inf")
h,w=map(int,input().split())
D=[[inf]*w for _ in range(h)]
D[0][0]=0

S=[list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        for x,y in ((1,0),(0,1)):
            X,Y=i+x,j+y
            if 0<=X<h and 0<=Y<w:
                if S[i][j]=="." and S[X][Y]=="#":D[X][Y]=min(D[i][j]+1,D[X][Y])
                else:D[X][Y]=min(D[i][j],D[X][Y])

#import numpy as np
#print(np.array(D))
ans=D[h-1][w-1]
print(ans if S[0][0]!="#" else ans+1)

Measured memory_bytes: 3188
#include <iostream>
#include <string>

using namespace std;

int main(void){
  int n,ans;
  string S;
  cin >> S;
  n = S.length();
  ans = 1000;
  for(int i = 0; i <= n-3; i++){
    int a = S[i]-'0';
    int b = S[i+1] - '0';
    int c = S[i+2] - '0';
    ans = min(ans,abs(753 - (100*a + 10*b + c)));
  }
  cout << ans << endl;
  return 0;
}

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

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

    sort(vec.begin(), vec.end());
  
  
   for (int i = 0; i <N-1; i++) {
      vec.at(i+1) = (vec.at(i) + vec.at(i+1) )/2;
    }
  cout << vec.at(N-1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<iterator>

struct solver_2019_b {
    void run(std::string str) {
        // begin with keyence
        // end with keyence
        // keye .... nce
        std::string keyence = "keyence";
        int length = 7;
        int str_length = str.length();
        bool pass;
        for(int i = 0; i <= length; ++i) {
            // i chars from begin
            // 7 - i chars from end
            pass = true;
            for(int j = 0; j < i; ++j) {
                if(keyence.at(j) != str.at(j)) {
                    pass = false;
                    break;
                }
            }
            if(! pass) {
                continue;
            }
            for(int j = i; j <= i; ++j) {
                // 7 -(7-j)
                // len -(7-j)
                if(keyence.at(j) != str.at( str_length -7 + j )) {
                    pass = false;
                    break;
                }
            }
            if(pass) {
                std::cout << "YES" << std::endl;
                return;
            }
        }
        std::cout << "NO" << std::endl;
        return;
    }
};

int main(void) {
    solver_2019_b solver;

	std::string str;

	std::cin >> str;
    solver.run(str);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<cassert>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
int a[100000];
vector<int>b;
vector<H>ans;
signed main() {
	cin >> n;
	int ma = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > ma) {
			b.push_back(i);
			ma = a[i];
		}
	}
	priority_queue<int>p;
	int sum = 0;
	for (int i = n - 1; i > b[b.size() - 1]; i--) {
		p.push(a[i]);
	}
	for (int i = b.size() - 1; i > 0; i--) {
		int res = (a[b[i]] - a[b[i - 1]])*sum;
		while (!p.empty() && p.top() >= a[b[i - 1]]) {
			res += p.top() - a[b[i - 1]];
			sum++;
			p.pop();
		}
		for (int j = b[i]; j > b[i - 1]; j--) {
			if (a[j] >= a[b[i - 1]]) {
				res += a[j] - a[b[i - 1]];
				sum++;
			}
			else p.push(a[j]);
		}
		ans.push_back(H{ b[i], res });
	}
	int rep = a[0] * sum;
	p.push(a[0]);
	while (!p.empty()) {
		rep += p.top();
		p.pop();
	}
	ans.push_back(H{ 0,rep });
	for (int i = ans.size() - 1; i >= 0; i--) {
		cout << ans[i].y << endl;
		for (int j = ans[i].x + 1; j < (i == 0 ? n : ans[i - 1].x); j++) {
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 4336
#include<stdio.h>
#define ll long long
ll n;
ll a[100005],b[100005],c[100005],dp[100005][3];
ll max(ll a,ll b)
{
	return (a>b)?a:b;
}
ll solve(int i,int d)
{
	if(dp[i][d]!=-1)
		return dp[i][d];
	if(i==n)
		return dp[i][d]=0;
	dp[i][d]=0;
	if(d!=0||i==0)
		dp[i][d]=max(dp[i][d],a[i]+solve(i+1,0));	
	if(d!=1||i==0)
		dp[i][d]=max(dp[i][d],b[i]+solve(i+1,1));
	if(d!=2||i==0)
		dp[i][d]=max(dp[i][d],c[i]+solve(i+1,2));
	return dp[i][d];
}
int main()
{
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
	}
	for(int i=0;i<100005;i++)
		for(int j=0;j<3;j++)
			dp[i][j]=-1;
	ll ans=solve(0,0);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  	double a, b, ad, bd, num=0;
  	cin >> a >> b;
  	ad=a;
  	bd=b;
  
  	for(int i=1; i<b; i++){
    	ad+=a*pow(10,i);
    }
  	for(int i=1; i<a; i++){
    	bd+=b*pow(10,i);
    }
  	
  	string S[2];
  	S[0] = to_string((int)ad);
  	S[1] = to_string((int)bd);
  	sort(S, S+2);
  	cout << S[0] << endl;
	return 0;
}

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

void print20sharps()
{
    for(int i = 0; i < 20; i++) {
        cout << "#";
    }
    cout << endl;
}

int main(){
    int n, b, f, r, v;
    cin >> n;

    // ?????????
    int bldg_01[3][10], bldg_02[3][10], bldg_03[3][10], bldg_04[3][10];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 10; j++) {
            bldg_01[i][j] = 0;
            bldg_02[i][j] = 0;
            bldg_03[i][j] = 0;
            bldg_04[i][j] = 0;
        }
    }

    // ????????????????????????
    for(int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        if(b == 1) bldg_01[f-1][r-1] += v;
        if(b == 2) bldg_02[f-1][r-1] += v;
        if(b == 3) bldg_03[f-1][r-1] += v;
        if(b == 4) bldg_04[f-1][r-1] += v;
    }

    // ???????????¨?????????
    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 10; k++) {
                if(i == 0) cout << " " << bldg_01[j][k];
                if(i == 1) cout << " " << bldg_02[j][k];
                if(i == 2) cout << " " << bldg_03[j][k];
                if(i == 3) cout << " " << bldg_04[j][k];
            }
            cout << endl;
        }
        if(i == 3) break;
        print20sharps();
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(80);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a, bi;
    ld b;
    cin >> a >> b;
    bi = (ll)(b * 100 + EPS);
    // err(a, bi);
    cout << a * bi / 100 << endl;
}


Measured memory_bytes: 3716
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	int exist[16384];
	int nums[16384], ans[8192];
	int i, j, n, size, half, p;
	
	while(scanf("%d", &n), n){
		for(i=0; i<n; ++i)
			exist[i] = 0;
		for(i=1; i<n; ++i)
			exist[(i*i)%n] = 1;
		
		size = 0;
		for(i=0; i<n; ++i){
			if(exist[i])
				nums[size++] = i;
		}

		half = (n-1) / 2;
		for(i=1; i<=half; ++i)
			ans[i] = 0;

		for(i=0; i<size; ++i){
			for(j=0; j<i; ++j){
				++ans[(p=abs(nums[i]-nums[j]))>half?n-p:p];
			}
		}
		for(i=1; i<=half; ++i)
			printf("%d\n", ans[i]*2);
	}

	return 0;
}

Measured memory_bytes: 856
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
k = []
for i in range(M):
  swich = list(map(int,readline().split()))
  swich.pop(0)
  k.append(swich)
p = list(map(int,readline().split()))
count = 0
for bit in range(1 << N):
  ans = []
  for i in range(N):
    if (bit >> i) & 1:
      ans.append(i+1)
  for j in range(M):
    check = sum(1 for s in k[j] if s in ans)
    if check % 2 != p[j]:
      break
    if j == M-1:
      count+=1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  double x1, y1, x2, y2, x3, y3, x4, y4;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    if(abs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) <= 1e-10){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1224
# Problem C - Grid Repainting

# input process
H, W = map(int, input().split())
s_list = [[0]*W for i in range(H)]
for i in range(H):
    tmp = input()
    for j in range(W):
        s_list[i][j] = tmp[j]

# search process
is_ok = True
for i in range(H):
    for j in range(W):
        if s_list[i][j]==".":
            continue
        # right process
        if j+1<W:
            if s_list[i][j+1]=="#":
                continue
        # left process
        if j-1>=0:
            if s_list[i][j-1]=="#":
                continue
        # down process
        if i+1<H:
            if s_list[i+1][j]=="#":
                continue
        # up process
        if i-1>=0:
            if s_list[i-1][j]=="#":
                continue
        # stop process
        is_ok = False
        break

if is_ok:
    print("Yes")
else:
    print("No")


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

int main() {
	string s;
	cin >> s;
	int fst = -1,ed = -1;
	for(int i = 0;i < s.size();i++)
	{
		if(s.at(i) == 'A' && fst == -1)
		{
			fst = i;
		}
		if(s.at(s.size() - i - 1) == 'Z' && ed == -1)
		{
			ed = s.size() - i;
		}
		if(fst >= 0 && ed >= 0)
		{
			break;
		}
	}
    cout << ed - fst << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,k; cin >> n >> k;
    vi price(n);
    FOR(i,n) cin >> price[i];
    sort(price.begin(),price.end());
    int total = 0;
    FOR(i,k) total+=price[i];
    cout << total <<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
typedef long long ll;
 
int main() {
   int h,w;
	cin >> h >> w;
	string s;
	for(int i=0;i<h;i++){
		cin >> s;
		cout<< s << endl << s << endl;
    }
}

Measured memory_bytes: 256
s = input()
ansA, ansB = 0, 0
for i in range(len(s)):
    if(i % 2 == 0):
        if(s[i]=="1"):
            ansA += 1
        else:
            ansB += 1
    else:
        if(s[i]=="0"):
            ansA += 1
        else:
            ansB += 1
print(ansA if ansA < ansB else ansB)

Measured memory_bytes: 3188
N, Y = list(map(int, input().split()))
final_ans = None
for i in range(N + 1):
    for j in range(N + 1):
        if i + j > N:
            continue
        ans = i * 10000 + j * 5000 + (N - i - j) * 1000
        if ans == Y:
            final_ans = " ".join([str(i), str(j), str(N - i - j)])
            break

if final_ans is None:
    print('-1 -1 -1')
else:
    print(final_ans)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    ave1=sum(a)//N
    
    ans=[0,0]
    for i in range(N):
        ans[0]+=(ave1-a[i])**2
        ans[1]+=(ave1-a[i]+1)**2
    print(min(ans))
    

main()


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

int main(){
  int n;
  cin >> n;
  int d[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  sort(d,d+n);
  int now=0;
  int count=0;
  for(int i=0;i<n;i++){
    if(now<d[i]){
      now=d[i];
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::marker::Bytes;
fn main() {
    proconio::input! {
        n: usize,
        s1: Bytes,
        s2: Bytes,
    }
    let mut t = 1u64;
    let mut p = 0;
    let mut i = 0;
    while i < n {
        let c = if s1[i] == s2[i] { 1 } else { 2 };
        t *= [[3, 2, 1], [6, 2, 3]][c - 1][p];
        i += c;
        p = c;
    }
    println!("{}", t % 1000000007);
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
	ios;
	ll n,a,i,c=0,p;
	cin>>n>>a;
	p=a;
	for(i=1;i<n;i++)
	{
		cin>>a;
		if(a<p) 
		{
			c+=p-a;
		}
		else p=a;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n;
  cin >> n;
  vector<int> t=input(n);
  int m;
  cin >> m;
  vector<int> p(m);
  vector<int> x(m);
  rep(i,m){
    cin >> p[i] >> x[i];
  }
  
  int sum=0;
  rep(i,n){
    sum+=t[i];
  }
  
  rep(i,m){
    cout << sum-t[p[i]-1]+x[i] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#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 ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int A, B;

	cin >> A >>B;

	cout << (A == B?A+B:max(A,B)*2-1) << endl;



	return 0;
}

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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vl a(n + 1, 0), b(m + 1, 0);
    rep(i, n) {
        ll tt;
        cin >> tt;
        a[i + 1] = a[i] + tt;
    }
    rep(i, m) {
        ll tt;
        cin >> tt;
        b[i + 1] = b[i] + tt;
    }

    ll ans = 0;
    ll t = 0;

    rep(i, n + 1) {
        ll cnt = i;
        if (a[i] > k) break;
        ll left = k - a[i];
        auto l = upper_bound(rng(b), left);
        if (l == b.begin()) {
            umax(ans, cnt);
            continue;
        }
        cnt += (l - b.begin() - 1);
        umax(ans, cnt);
    }

    prt(ans);

    return 0;
}


Measured memory_bytes: 6396
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c) {
        cout << "Yes\n";
    }else if (a == c && a != b) {
        cout << "Yes\n";
    }else if (c == b && a != c) {
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    
}

Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = 1<<18;

int n, m, dp[N];
VII prz[N];

class treePM
{
  public:
    int w[2*N], W[2*N];

    void init()
    {
      for (int i = 0; i < 2*N; ++i)
        w[i] = W[i] = 0;
    }

    void insert(int a, int b, int v)
    {
      _insert(a, b, v, 0, N-1, 1);
    }

    int query(int a, int b)
    {
      return _query(a, b, 0, N-1, 1, 0);
    }

    void _insert(int a, int b, int v, int beg, int end, int k)
    {
      if (b < beg || a > end)
        return;
      if (a <= beg && end <= b) {
        w[k] += v;
        W[k] += v;
        return;
      }
      _insert(a, b, v, beg, (beg+end)/2, 2*k);
      _insert(a, b, v, (beg+end)/2+1, end, 2*k+1);
      W[k] = w[k] + max(W[2*k], W[2*k+1]);
    }

    int _query(int a, int b, int beg, int end, int k, int war)
    {
      if (b < beg || a > end)
        return 0;
      if (a <= beg && end <= b)
        return war + W[k];
      return max(_query(a, b, beg, (beg+end)/2, 2*k, war+w[k]), _query(a, b, (beg+end)/2+1, end, 2*k+1, war+w[k]));
    }
} drz;

signed main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int l, r, a;
    cin >> l >> r >> a;
    prz[r].PB({l, a});
  }
  for (int i = 1; i <= n; ++i)
    sort(prz[i].begin(), prz[i].end());
  for (int i = 1; i <= n; ++i) {
    dp[i] = drz.query(0, i-1);
    drz.insert(i, i, dp[i]);
    for (const auto& el: prz[i])
      drz.insert(el.ST, i, el.ND);
  }
  cout<<drz.query(1, n)<<"\n";
}

Measured memory_bytes: 21376
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
ans = 1

if D[0] != 0 or D.count(0) > 1:
    print(0)
else:
    c = Counter(D)
    for key in c:
        if key == 0:
            continue
        elif key-1 in c == False:
            ans = 0
            break
        else:
            ans = ans * c[key-1] ** c[key]
    print(ans % 998244353)

Measured memory_bytes: 19936
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

const int N = 1e5;
int a[N+5];

int cnt[2];

int main()

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

    string s;

    cin >> s;

    for (int i = 0; i < s.size(); i++) {

        a[s[i]-'0']++;
    }

    cout << min(a[0], a[1])*2;

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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


    int N, M;
    cin >> N >> M;

    rep(i, M)
    {
        int a;
        cin >> a;

        N -= a;
    }

    cout << max(N, -1) << endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
   int a,b,d,r;
   scanf("%d %d",&a,&b);
   double f;
   d = a/b;
   r = a%b;
   f = 1.0*a/b;
   
   printf("%d %d %.5lf\n",d,r,f);
    
    return(0);
    
}



Measured memory_bytes: 2104
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  int n, m;
  cin >> n >> m;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }

  vector<pii> c;
  for (int i = 0; i < n; i++) {
    c.push_back(make_pair(a[i], b[i]));
  }
  sort(c.begin(), c.end());

  priority_queue<int> pq;
  int j = 0;
  int sum = 0;
  for (int i = n; i > 0; i--) {
    while (j < n && c[j].first + i <= m + 1) {
      pq.push(c[j].second);
      ++j;
    }
    if (!pq.empty()) {
      sum += pq.top();
      pq.pop();
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 2676
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const ll MOD=1000000007;
ll powmod(ll a,ll b){
	if(b==1)return a;
	ll out=powmod(a,b/2);
	out=out*out%MOD;
	if(b%2)out=out*a%MOD;
	return out;
}
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<powmod(a,b)<<endl;
}

Measured memory_bytes: 1156
x, y = map(int,input().split())

if x >= 3 and y >= 3:
    print((x-2)*(y-2))
elif x == 2 or y == 2:
    print(0)
elif x == 1 and y == 1:
    print(1)
else:
    print(max(x,y)-2)

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

ll n, a, b;

bool f(ll t, vector<ll> v){
  ll max_attack = 0;
  for (int i = 0; i < n; i++) {
    v[i] -= b * t;
    if(v[i] > 0){
      max_attack += ceil(double(v[i]) / double((a-b)));
    }
  }
  // cout << "attack_num : " << t << endl;
  // cout << "max_attack : " << max_attack << endl;
  // print(v);

  return (max_attack <= t) ? true : false;
}


int main(){
  cin >> n >> a >> b;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  int l = -1, r = pow(10, 9) + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if(f(mid, v)) r = mid;
    else l = mid;
  }


  cout << r << endl;

}


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

using namespace std;

const int N=100010;

int a[N],n;

char ch[N];

int main()
{
	scanf("%s",ch+1);
	for(int i=1;i<=strlen(ch+1);i++)
	{
		int t=0;
		while(ch[i]=='R')
		{
			t++;
			i++;
		}
		a[i-1]+=(t-t/2);
		a[i]+=t/2;
	}
	for(int i=strlen(ch+1);i>=1;i--)
	{
		int t=0;
		while(ch[i]=='L')
		{
			t++;
			i--;
		}
		a[i+1]+=(t-t/2);
		a[i]+=t/2;
	}
	for(int i=1;i<=strlen(ch+1);i++)
		cout<<a[i]<<" ";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n,k,q;
    cin>>n>>k>>q;

    vector<long long int> v(n,0);
    long long int tmp;
    REP(i,q){
        scanf("%lld",&tmp);
        v[tmp-1]++;
    }
    long long int result=0;
    REP(i,n){
        if(v[i]>q-k){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408