akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			string s = Console.ReadLine();
			int n = int.Parse(s);
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//System.Diagnostics.Debug.WriteLine(n);
			long ans = 0;
			for (int i = 1; i <= n; i++) {
				if (i % 10 != 0) {
					int h = i, t = i % 10;
					while (h >= 10) {
						h /= 10;
					}
					// 1桁
					if (h == t) {
						ans++;
						//System.Diagnostics.Debug.WriteLine($"  {i},{h}");
					}
					// 2桁
					if (t * 10 + h <= n) {
						ans++;
						//System.Diagnostics.Debug.WriteLine($"  {i},{t * 10 + h}");
					}
					// 3桁～
					int k = 100;
					while (true) {
						int tmp1 = t * k + h;
						int tmp2 = t * k + k - 10 + h;
						if (tmp1 <= n) {
							if (tmp2 <= n) {
								ans += (k - 10) / 10 + 1;
								//System.Diagnostics.Debug.WriteLine($"  {i},{tmp1}-{tmp2}:{(k - 10) / 10 + 1}");
							} else {
								int x = (n % k) / 10;
								tmp2 = t * k + x * 10 + h;
								while (tmp2 > n) {
									x--;
									tmp2 = t * k + x * 10 + h;
								}
								ans += x + 1;
								//System.Diagnostics.Debug.WriteLine($"  {i},{tmp1}-{tmp2}:{x + 1}");
							}
						} else {
							break;
						}
						k *= 10;
					}
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 11092
<?php
 
$n = trim(fgets(STDIN));
 
$c = 0;
$s = trim(fgets(STDIN));
for($i=1;$i<strlen($s);$i++){
  if ($s[$i] !== $s[$i-1]){
    $c++;
  }
}
 
echo $c+1;
 
?>

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

using namespace std;

#define MAX_N 21
#define MAX_M 200001
#define INF (1<<29)
typedef long long ll;

double dp[MAX_N][MAX_M];

int main()
{
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

    fill(dp[0], dp[MAX_N], INF);
    dp[0][1] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = MAX_M-1; j >= 0; j--) {
            if (dp[i][j] == INF) continue;
            for (int k = 1; k <= MAX_M; k++) {
                ll nv = (ll)j * k; 
                if (nv >= MAX_M) break;
                dp[i+1][nv] = min(dp[i+1][nv],
                                  max(dp[i][j], abs(v[i]-nv) / v[i]));
            }

        }
    }
    double res = INF;
    for (int i = 0; i < MAX_M; i++) {
        res = min(res, dp[N][i]);
    }
    printf("%.15f\n", res);
    return 0;
}

Measured memory_bytes: 34052
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

#define pi 3.141592653589

int main(){
	int n;
	long *a;
	cin >> n;
	a = new long[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	long maxas = -1000000;
	for (int i = 0; i < n; i++){
		maxas = max(maxas, a[i]);
	}
	long minas = 1000000;
	for (int i = 0; i < n; i++){
		minas = min(minas, a[i]);
	}
	long sum = 0;
	for (int i = 0; i < n; i++){
		sum += a[i];
	}

	cout << minas << " " << maxas << " " << sum << endl;
	delete[] a;
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a[i];
  vector<vector<ll>> dp(n, vector<ll>(n));
  for(int L=n-1; L>=0; L--) {
    for(int R=L; R<n; R++) {
      if(L==R) {
        dp[L][R] = a[L];
      } else {
        dp[L][R] = max(a[L] - dp[L+1][R], a[R] - dp[L][R-1]);
      }
    }
  }
  cout << dp[0][n-1] << '\n';


  return 0;
}

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

int N;

void dfs(string s, char mx) {
  if(s.size() == N) {
    cout << s.c_str() << endl;
  } else {
    for(char c = 'a'; c <= mx; c++) {
      dfs(s+c, ((c == mx) ? (char(mx+1)) : mx));
    }
  }
}

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


Measured memory_bytes: 1536
#include <iostream>
#include <string>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <set>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define LIMIT3 1000010
#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
template<class T,class C> T max(T a,C b){ return ((a)>(T)(b) ? (a) : (T)(b)); }
template<class T,class C> T min(T a,C b){ return ((a)<(T)(b) ? (a) : (T)(b)); }
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
#define lim LIMIT3
vector<ll> check(lim+1,1);
map<ll,ll> prime;
void initialize(){
  ll slim = sqrt(lim)+1;
  ll i,j;
  check[0]=0;check[1]=0;
  for(i=2;i<=slim;i++){
    if(check[i]==1){
      for(j=i;j<lim;j+=i){
        check[j]=i;
      }
    }
  }
}
void get_fact2(ll n){
  if(n<=1) return;
  if(check[n]==1){
    prime[n]++;
    return;
  }
  prime[check[n]]++;
  get_fact2(n/check[n]);
}
void get_fact(ll n){
  prime.clear();
  get_fact2(n);
}

int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  string s;
  
  cin >> n;
  for(ll a=1;a<n;a++){
    for(ll b=1;a*b<n;b++){
      result++;
    }
  }
  
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 10980
#include<iostream>
#include<algorithm>

using namespace std;
int n ;
int a[110];
int main()
{
    cin>>n;
    int flag = 0;
    int num = 0;
    for(int i =1;i<=n;++i)
    {
        int x;
        cin>>x;
        if(!(x&1))
        {
            num++;
            if(x%3==0||x%5==0)
            {
               flag++;
            }
        }
    }
    if(flag==num)
        puts("APPROVED");
    else
    {
        puts("DENIED");
    }
    
    
    //system("pause");
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<int> in[n];
	for(int i = 0 ; i < n ; i++){
		in[i].resize(3);
		cin>>in[i][0];
		cin>>in[i][1];
		cin>>in[i][2];
	}
	
	int res[n][3];
	for(int i = 0 ; i < n ; i++){
	
	res[i][0] = in[i][0];
	res[i][1] = in[i][1];
	res[i][2] = in[i][2];
}
	for(int i = 1 ; i < n ; i++){
		res[i][0] += max(res[i-1][1] , res[i-1][2]);
		res[i][1] += max(res[i-1][0] , res[i-1][2]);
		res[i][2] += max(res[i-1][0] , res[i-1][1]);
	}
	cout<<max(res[n-1][0] , max(res[n-1][1] , res[n-1][2]));
	
	
	
}

Measured memory_bytes: 6912
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B,C=get_i
max=[A,B,C].max
sum=A+B+C
ans=0
while (sum%3).nonzero? or sum<max*3
    ans+=1
    sum+=2
end
puts ans

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

class BIT{
private:
  int bit[1<<17+1], n;
public:
  BIT(int n_){
	n = n_;
	fill(bit, bit+n+1, 0);
  }

  // 1-indeced
  int sum(int i){
	int s = 0;
	while(i > 0){
	  s += bit[i];
	  i -= i & -i;
	}
	return s;
  }

  void add(int i, int x){
	while(i <= n){
	  bit[i] += x;
	  i += i & -i;
	}
  }

  int lower_bound(int x){
	if(x <= 0) return 0;
	int i = 1;
	for(;i<=n;i<<=1);
	i >>= 1;
	int res = 0;
	for(;i>0;i>>=1){
	  if(res+i <= n && bit[res+i] < x){
		x -= bit[res+i];
		res += i;
	  }
	}
	return res+1;
  }
};

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

  LL N, K;
  cin >> N >> K;
  VL xs(N);
  REP(i,N){
	cin >> xs[i];
	xs[i] -= K;
  }
  
  VL acc(N+1);
  REP(i,N) acc[i+1] = acc[i] + xs[i];
  VL tmp = acc;
  SORT(tmp);
  UNIQ(tmp);
  map<LL,int> ids;
  REP(i,SZ(tmp)) ids[tmp[i]] = SZ(tmp) - i;

  LL ans = 0;
  BIT bit(SZ(tmp)+1);
  for(int i=N;i>=0;--i){
	ans += bit.sum(ids[acc[i]]);
	bit.add(ids[acc[i]], 1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18304
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x;
cin >> n >> x;
int dor,mini=2<<21;
for(int i=0;i<n;i++){
cin >> dor;
x-=dor;
if(dor < mini)mini=dor;
}
cout << n+(x/mini) << endl;
return 0;
} 

Measured memory_bytes: 256
from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]


def ox(s, i):
	return s[i]=="o"


def main():
	n=int(nextLine())
	if "7" in str(n):
		print("Yes")
	else:
		print("No")		
	
if __name__=="__main__":
	main()


Measured memory_bytes: 9184
from collections import defaultdict


def main():
    N = int(input())
    a_list = list(map(int, input().split()))

    ans = 10 ** 10
    for m in range(min(a_list), max(a_list) + 1):
        cost = sum((m - a) ** 2 for a in a_list)
        ans = min(ans, cost)
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
  string S; cin >> S;
  int cnt_0 = 0,cnt_1 = 0;
  for(int i = 0; i < S.size(); i++)
  {
    if(S.at(i) == '0')
    {
      cnt_0 += 1;
    }
    else
    {
      cnt_1 += 1;
    }
  }
  cout << 2*min(cnt_0,cnt_1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N;SCD(N);
	static int P[200002];
	static int Q[200002];
	
	FORq(i,1,N){
		SCD(P[i]);
		Q[P[i]] = i;
	}
	
	int nowv = Q[1];
	int maxl,count;
	maxl = 1;
	count = 1;
	
	FORq(i,2,N){
		if (nowv < Q[i]){
			nowv = Q[i];
			count++;
		}else{
			maxl = max(maxl,count);
			count = 1;
			nowv = Q[i];
		}
	}
	maxl = max(maxl,count);

	PRINTD(N-maxl);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int gcd(int m,int n){if(m%n==0)return n;else return gcd(n,m%n);}
int num(int a,int b,int c)
{
	if(a==b&&b==c)return 1;
	else if(a==b||b==c||c==a)return 3;
	else return 6;
}
int main()
{
	int k;cin>>k;
	int s=0;
	for(int a=1;a<=k;a++)for(int b=a;b<=k;b++)for(int c=b;c<=k;c++)s+=gcd(a,gcd(b,c))*num(a,b,c);
	cout<<s<<'\n';
	return 0;
}

Measured memory_bytes: 3620
n = int(input())
flag = True
a = [0] * (n+1)
d = [False] * (n+1)
for i in range(n):
    a[i+1] = int(input())
d[1] = True
i = 1
cnt = 0
while(flag):
    i = a[i]
    cnt += 1
    if(d[i] == False):
        d[i] = True
        if(i == 2):
            break
    else:
        flag = False
if(d[2]):
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 7748
#import <Foundation/Foundation.h>
#import <stdio.h>

int main(int argc, char **argv) {
  NSInteger total;
  NSInteger houses;
  scanf("%ld %ld", &total, &houses);
  NSMutableArray *distances = [[NSMutableArray alloc] initWithCapacity: houses];
  NSInteger diff = 0;
  NSInteger i = 0;
  for(i = 0; i < houses; i++) {
    NSInteger meter;
    scanf("%ld", &meter);
    [distances addObject: [NSNumber numberWithInteger: meter - diff]];
    diff += meter - diff;
  }
  diff = total - diff;
  [distances addObject: [NSNumber numberWithInteger: diff]];
  NSInteger minDistance = total;
  NSInteger firstPrev = diff + [(NSNumber *)[distances objectAtIndex: 0] integerValue];
  for(i = 0; i < houses; i++) {
    NSNumber *prev = (i == 0) ? [NSNumber numberWithInteger: firstPrev] : [distances objectAtIndex: i-1];
    NSNumber *next = [distances objectAtIndex: i+1];
    minDistance = MIN(minDistance, MIN(total - next.integerValue, total - prev.integerValue));
  }
  
  printf("%ld", minDistance);
  return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, K;
  cin >> N >> K;
  int h[N + 10];
  REP(i, N) cin >> h[i];
  int dp[N + K + 10];
  REP(i, N) dp[i] = 1e9;
  dp[0] = 0;
  REP(i, N) {
    REP1(j, K) dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
  }
  cout << dp[N - 1] << endl;
  return 0;
}

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

int pow(int x){
	int ans=1;
	for(int i=1;i<=x;i++){
		ans=ans*2;
	}
	return ans;
}

int main() {
	// your code goes here
	int n,k,i,j,max,ansm=0;
	double ans;
	cin >> n >> k;
	for(i=1;i<=n;i++){
		j=0;
		while(1){
			if(i*pow(j)>=k) break;
			else j++;
		}
		if(i==1) max=j;
		ansm+=pow(max-j);
	}
	ans=ansm;
	ans=(ans/pow(max))/n;
	printf("%.13f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

int main(){
  int k;
  cin >> k;
  ll left = 0;
  ll right = 3234566668;
  while(left < right-1){
    ll mid = (left + right)/2;
    string s = to_string(mid);
    int n = s.size();
    vector<int> digit(1,0);
    for(char c : s){
      int x = c - '0';
      digit.push_back(x);
    }
    int dp[n+1][10][2] = {0};
    rep1(j,digit[1]) dp[1][j][j<digit[1]] ++;
    rep1(i,n-1){//1-indexed
      rep(j,10){//0-indexed
        dp[i+1][j][1] += (j > 0);
        for(int k=-1;k<=1;k++){
          int m = j+k;
          if(m == -1 || m == 10) continue;
          dp[i+1][j][1] += dp[i][m][1];
          dp[i+1][j][j<digit[i+1]] += dp[i][m][0]*(j<=digit[i+1]);
        }
      }
    }
    int sum = 0;
    rep(j,10) sum += dp[n][j][0] + dp[n][j][1];
    if(sum < k) left = mid;
    if(sum >= k) right = mid;
  }
  cout << right << endl;
}


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

int main(){
    int n,k,c;
    cin >> n >> k >> c;
    deque<int> fleft,fright;
    rp(i,n){
        char s;
        cin >> s;
        if(s=='o'){
            fleft.push_back(i+1);
            fright.push_front(i+1);
        }
    }
    deque<int> left,right;
    int ok=fleft.size();
    int counter=1;
    left.push_back(fleft.at(0));
    right.push_front(fright.at(0));
    if(k==1){
        if(left.at(0)==right.at(0)){
            cout << left.at(0) << endl;
        }
        return 0;
    }
    for(int i=1; i<ok;i++){
        if(fleft.at(i)>left.back()+c){
            left.push_back(fleft.at(i));
            counter++;
        }
        if(counter==k) break;
    }
    counter=1;
    for(int i=1; i<ok; i++){
        if(fright.at(i)<right.front()-c){
            right.push_front(fright.at(i));
            counter++;
        }
        if(counter==k) break;
    }
    rp(i,k){
        if(left.at(i)==right.at(i))
        cout << left.at(i) << endl;
    }
    return 0;
}

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

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *cnt=(int *)calloc(n+1,sizeof(int));
  while(m--){
    int a,b;
    scanf("%d%d",&a,&b);
    cnt[a]++;
    cnt[b]++;
  }
  int i;
  for(i=1;i<=n;i++) if(cnt[i]&1) break;
  puts(i>n?"YES":"NO");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 100000
#define MAXK 1000
int n,k,cnt,Max;
int x[MAXN+5],y[MAXN+5],c[MAXN+5];
int y1[10*MAXK+5];
int main() {
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) {
		char ch;
		scanf("%d %d %s",&x[i],&y[i],&ch);
		x[i]=x[i]%(2*k);
		y[i]=y[i]%(2*k);
		if(ch=='W')	c[i]=1;
		else c[i]=0;
	}
	for(int i=0;i<=k;i++) {
		cnt=0;
		memset(y1,0,sizeof(y1));
		for(int j=1;j<=n;j++) {
			int p=(i<=x[j]&&x[j]<i+k);
			int q=(0<=y[j]&&y[j]<k);
			if(p^q==c[j]) {
				cnt++;
				y1[y[j]]++;
			}
			else 
				y1[y[j]]--;
		}
		for(int j=0;j<=k;j++) {
			if(cnt>Max)	Max=cnt;
			if(n-cnt>Max)	Max=n-cnt;
			if(j!=k)
				cnt=cnt-y1[j]-y1[j+k];
		}
	}
	printf("%d\n",Max);
	return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

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

	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}

	ll cnt = 0;
	rep(i, n) {
		if (a[i] < b[i]) {
			cnt += (b[i] - a[i]) / 2;
		}
		else if (a[i] > b[i]) {
			cnt -= a[i] - b[i];
		}
	}
	
	if (cnt >= 0) out("Yes");
	else out("No");

	return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
count = [0]*n
for i in a:
    count[i] += 1
    
ans = 0
if n%2 == 0:
    if all(count[2*f]==0 for f in range(n//2)) and all(count[2*k-1]==2 for k in range(1,n//2)):  
        ans = 1
else:
    if count[0] == 1 and all(count[2*f]==2 for f in range(1,n//2)) and all(count[2*k-1]==0 for k in range(1,n//2)):
        ans = 1
        
if ans == 1:
    for i in range(n//2):
        ans = (ans*2) % (1e+9+7)

print(int(ans))

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC110_B();
        }

        static void ABC110_B()
        {
            var NMXY = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = NMXY[0];
            var M = NMXY[1];
            var X = NMXY[2];
            var Y = NMXY[3];

            var xn = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ym = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var war = true;
            foreach (var z in xn.Concat(ym))
            {
                if (z > X && z <= Y && xn.All(x => x < z) && ym.All(y => y >= z))
                {
                    war = false;
                    break;
                }
            }
            Console.WriteLine(war ? "War" : "No War");
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int is(vector<int> v,vector<int> a)
{
	int n=v.size();
	int i;
	for(i=0;i<n;i++)
	{
		if(v[i]!=a[i])
		return 0;
	}
	return 1;
}
int main()
{
  int n;
  cin>>n;
  vector<int> a,b;
  int i;
  int x;
  for(i=0;i<n;i++)
  {
    cin>>x;
    a.push_back(x);
  }
  vector<int> v;
  for(i=0;i<n;i++)
  {
    cin>>x;
    b.push_back(x);
    v.push_back(x);
  }
  
  sort(v.begin(),v.end());
  
  int ano=1,bno=1;
  do{
    
    if(is(v,a))
      break;
      ano++;
  }while(next_permutation(v.begin(),v.end()));
         sort(v.begin(),v.end());
           do{
    if(is(v,b))
      break;
      bno++;
  }while(next_permutation(v.begin(),v.end()));
 // cout<<ano<<" "<<bno<<"\n";
         cout<<abs(ano-bno);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < n;i++)
using namespace std;
 
int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d.at(i);
    sort(d.begin(), d.end());
    int count = 0;
    rep(i,1000000){
        if((d.at(n/2) >= i) && (d.at(n/2 - 1) <= i)){
            count++;
        }
    }
    cout << count - 1 << endl;
}

Measured memory_bytes: 640
from collections import deque
N=int(input())
AB=[tuple(map(int, input().split())) for _ in range(N-1)]
C=sorted(map(int, input().split()))
G=[[] for _ in range(N)]
for a,b in AB:
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
deq=deque(i for i in range(N) if len(G[i])==1)
D=[len(G[i]) for i in range(N)]
X=[0]*N
for c in C:
    i=deq.popleft()
    X[i]=c
    for j in G[i]:
        D[j]-=1
        if D[j]==1:
            deq.append(j)
ans=0
for a,b in AB:
    ans+=min(X[a-1],X[b-1])
print(ans)
print(*X)

Measured memory_bytes: 7668
#include <iostream>
#include <stack>
#include <cstring>
#include <algorithm>
#include <vector> 
#include <map>
#include <string>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s; cin >> s;
	char x = s[0];
	for (int i = 1; i < s.size(); i++) {
		if (x == s[i]) {
			cout << "Bad" << '\n'; return 0;
		}
		x = s[i];
	}
	cout << "Good" << '\n';
	


}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 1
i = 0
for j in range(n):
    if a[i] == 2:
        break
    if j == n-1 and a[i] != 2 :
        cnt = -1
        break
    i = a[i]-1
    cnt += 1
print(cnt)


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

int main() {
  int a, b;
  cin >> a >> b;
  struct tm t = {};
  t.tm_year = 2018 - 1900;
  int ans = 0;
  while (++t.tm_mday) {
    mktime(&t);
    if (t.tm_mon + 1 == t.tm_mday) ans++;
    if (t.tm_mon + 1 == a && t.tm_mday == b) break;
  }
  cout << ans << "\n";
}

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

using namespace std;

int main(){
    int n, l;
    cin >> n >> l;
    vector<int> v;
    int a1 = -99999;
    int a2 = 99999;
    int sum = 0;
    for (int i = 1; i <= n; i++){
        sum += l + i - 1;
        if (l + i - 1 < 0 && l + i - 1 > a1){
            a1 = l + i - 1;
        }else if (l + i - 1 < a2 && l + i - 1 >= 0){
            a2 = l + i - 1;
        }
    }
    int diff;
    if (-a1 >= a2) diff = a2;
    else diff = a1;
    cout << sum - diff;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007

typedef pair<int, int> pii;
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s; cin>>s;
	s[2] == s[3] && s[4] == s[5] ? cout<<"Yes": cout<<"No";
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 250
int main(){
    int a[MAX];
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        printf("node %d: key = %d, ",i,a[i]);
        if(i/2>=1) printf("parent key = %d, ",a[i/2]);
        if(2*i<=n) printf("left key = %d, ",a[2*i]);
        if(2*i+1<=n) printf("right key = %d, ",a[2*i+1]);
        printf("\n");
    }    
}


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll Q;
    cin >> Q;

    set<ll> se;

    while(Q--){
        ll a, x;
        cin >> a >> x;

        if(a==0){
            // insert
            se.insert(x);
            p(se.size());
        }
        else{
            // find
            p(se.count(x));
        }
    }

    return 0;
}


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


int main() {
  int N;
  string S, a = "Yes";
  cin >> N >> S;
  if(S.size() % 2 == 0) {
    for(int i=0;i<(N/2);i++) {
      if(S.at(i) != S.at(i + N / 2)) {
        a = "No";
      }
    }
  }
  else {
    a = "No";
  }
  cout << a << endl;
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//a個口の電源タップ
		int b = sc.nextInt();//b個以上の差込口
		int n = (int) Math.ceil((double) (b - 1) / (a - 1));//電源タップの個数
		System.out.println(n);
	}
}


Measured memory_bytes: 23508
#include <iostream>

template <typename T>
T gcd(T a, T b){
   if (b > a){
      std::swap(a, b);
   }
   while (b > 0){
      T tmp = b;
      b = a % b;
      a = tmp;
   }
   return a;
}

int main(){
   long long int A, B, C, D;
   std::cin >> A >> B >> C >> D;
   std::cerr << gcd(C, D) << std::endl;
   long long int all = B-A+1;
   long long int nCmin = all/C;
   long long int nC = (C* (A/C + nCmin+1) > B)? nCmin : nCmin+1;
   long long int nDmin = all/D;
   long long int nD = (D* (A/D + nDmin+1) > B)? nDmin : nDmin+1;
   long long int lcmCD = (C/gcd(C, D))*D;
   long long int nCDmin = all/lcmCD;
   long long int nCD = (lcmCD* (A/lcmCD + nCDmin+1) > B)? nCDmin : nCDmin+1;
   std::cout << all-(nC+nD-nCD) << std::endl;
}



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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n, q;
  string s;
  cin >> n >> s >> q;
  vll vq(q);
  rep(i, q) cin >> vq[i];

  vi d, m, c;
  d.reserve(1e6 + 10);
  m.reserve(1e6 + 10);
  c.reserve(1e6 + 10);

  rep(i, n) {
    if (s[i] == 'D')
      d.push_back(i);
    else if (s[i] == 'M')
      m.push_back(i);
    else if (s[i] == 'C')
      c.push_back(i);
  }

  vll nc(n + 2);

  rep(i, n) {
    if (s[i] == 'C')
      nc[i]++;
  }

  REP(i, n) {
    nc[i] += nc[i - 1];
  }

  for (const auto k : vq) {
    ll ans = 0;

    vll imos(n + 2);
    vll dc(n + 2);

    rep(i, n) {
      if (s[i] == 'D') {
        dc[i] = nc[min(i + k - 1, n - 1)] - nc[i];
        imos[i]++;
        if (i + k < n) {
          imos[i + k]--;
        }
      }
    }

    REP(i, n) {
      imos[i] += imos[i - 1];
    }

    REP(i, n) {
      dc[i] += dc[i - 1];
      if (s[i] == 'C') {
        dc[i] -= imos[i];
      } else if (s[i] == 'M') {
        ans += dc[i];
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 31700
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
        a[i] = sc.nextInt();
    }

    int[] b = new int[n];
    for (int i = 0; i < n; i++) {
        b[i] = sc.nextInt();
    }

    int[] c = new int[n-1];
    for (int i = 0; i < n - 1; i++) {
        c[i] = sc.nextInt();
    }

    int ans = 0;
    int l = -1;
    for (int i = 0; i < n; i++) {
        ans += b[a[i]-1];

        if (i-1 >= 0) {
            if (a[i-1]+1 == a[i]) {
                ans += c[a[i-1] - 1];
            }
        }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 22996
#include<stdio.h>

int main(void) {

	int A, B, max=0;

	scanf("%d", &A);
	scanf("%d", &B);

	max = A + B;

	if ((A - B) > max)
		max = A - B;
	if ((A*B) > max)
		max = A * B;

	printf("%d", max);
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3

import sys
import math
from collections import defaultdict


def main():
    mod = 1000000007                  # 10^9+7
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def lmi(): return list(map(int, input().split()))

    class Eratos:
        def __init__(self, num):
            self.table_max = num
            # self.table[i] は i が素数かどうかを示す (bool)
            self.table = [False if i == 0 or i == 1 else True for i in range(num+1)]
            for i in range(2, int(math.sqrt(num)) + 1):
                if self.table[i]:
                    for j in range(i ** 2, num + 1, i):    # i**2 からスタートすることで定数倍高速化できる
                        self.table[j] = False
            # self.table_max 以下の素数を列挙したリスト
            self.prime_numbers = [2] if self.table_max >= 2 else []
            for i in range(3, self.table_max + 1, 2):
                if self.table[i]:
                    self.prime_numbers.append(i)
        
        def is_prime(self, num):
            if num > self.table_max:
                raise ValueError('Eratos.is_prime(): exceed table_max({}). got {}'.format(self.table_max, num))
            return self.table[num]
        
        def prime_factorize(self, num):
            if num > self.table_max:
                raise ValueError('Eratos.prime_factorize(): exceed table_max({}). got {}'.format(self.table_max, num))
            factorized_dict = defaultdict(int)    # 素因数分解の結果を記録する辞書
            candidate_prime_numbers = [i for i in range(2, int(math.sqrt(num)) + 1) if self.is_prime(i)]
            # n について、√n 以下の素数で割り続けると最後には 1 or 素数となる
            # 背理法を考えれば自明 (残された数が √n より上の素数の積であると仮定。これは自明に n を超えるため矛盾)
            for p in candidate_prime_numbers:
                # これ以上調査は無意味
                if num == 1:
                    break
                while num % p == 0:
                    num //= p
                    factorized_dict[p] += 1
            if num != 1:
                factorized_dict[num] = 1
            return factorized_dict

    # import time
    # s = time.time()

    n = ii()
    L = lmi()
    a_max = max(L)
    # O(AlglgA) で前処理
    eratos = Eratos(a_max)
    # print('preprocessed (Eratostenes)')
    # print(time.time() - s)

    # O(n) * O(√A) で LCM を素因数分解した形で保存する
    lcm_dict = eratos.prime_factorize(L[0])
    for i in range(1, n):
        d = eratos.prime_factorize(L[i])
        for k, v in d.items():
            lcm_dict[k] = max(lcm_dict[k], v)
    # print('prime factorized')
    # print(time.time() - s)
    
    # O(√A)
    lcm_mod = 1
    for k, v in lcm_dict.items():
        lcm_mod = (lcm_mod * pow(k, v, mod)) % mod
    
    # O(n)
    ans = 0
    for a in L:
        # a^p-2 ≡ 1/a
        inverse_element = pow(a, mod-2, mod)
        ans = (ans + lcm_mod * inverse_element) % mod
    
    print(ans)
    # print(time.time() - s)

    

if __name__ == "__main__":
    main()

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

public class Program
{
	public static void Main(string[] args)
	{
		var param = System.Console.ReadLine().Split(' ').Select((x) => int.Parse(x)).ToList();

		int A = param[0];
		int B = param[1];
		int C = 0;

		if (1 <= A && 20 >= A && 1 <= B && 20 >= B)
		{
			if (A <= B)
			{
				if (B % A == 0)
				{
					C = A + B;
				}
				else
				{
					C = B - A;
				}
			}
		}
		System.Console.WriteLine(C);
	}
}

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

int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  long long x=b-a;
  if(x%2==0) cout<<x/2<<endl;
  else cout<<(b-a-1)/2+min(a-1,n-b)+1<<endl;
}

Measured memory_bytes: 256
N = int(input())
vector_list = ([int(x) for x in input().split()])
cost_list = ([int(x) for x in input().split()])
ans = 0
for i in range(len(vector_list)):
  if vector_list[i]-cost_list[i]>0:
    ans += vector_list[i]-cost_list[i]
 
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
#define lli                                 long long int
#define lb                                  long double
#define pi                                  acos(-1)
#define FindDistance(ax,ay,bx,by)           sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)                            __gcd(a,b)
#define lcm(a,b)                           (a/gcd(a,b))*b
#define T                                  int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define all(v)                             v.begin(),v.end()
#define pb                                 push_back
#define inf                                999999999999999
#define mod                                1000000007
#define maxn                               100003
#define FastIO                             ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
    lli n,i,x,j,ans=0;
    string s;
    cin>>n;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]!=s[i+1])
            ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3720
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    String alp[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    for(int i = 0;i<n;i++){
      s[i] = sc.next();
    }
    String ans = "";
    for(String al:alp){
      char[] alc = al.toCharArray();
      int max = 100;
      for(int i = 0;i<n;i++){
        int count = 0;
        for(char x:s[i].toCharArray()){
          if(x == alc[0])count++;
        }
        max = Math.min(max,count);
      }
      for(int i = 0;i<max;i++){
        ans += al;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 39812
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(){
    int n;
    int a=0,b=0;
    string str1,str2;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>str1>>str2;
        if(str1==str2){
            a++;
            b++;
        }
        else if(str1<str2){
            b=b+3;
        }
        else if(str1>str2){
            a=a+3;
        }
    }
    cout<<a<<" "<<b<<endl;
return 0;
}


Measured memory_bytes: 3144
#include<stdio.h>
int main(void){
    int a,i,n,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a){
            min=a;
        }
        if(max<a){
            max=a;
        }  
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2104
from itertools import product

N, M = map(int, input().split())
kss = [list(map(int, input().split())) for _ in range(M)]
ps = list(map(int, input().split()))

answer = 0
for switches in product(range(2), repeat=N):
    for (_, *ss), p in zip(kss, ps):
        okay = True
        if sum([switches[s-1] for s in ss]) % 2 != p:
            okay = False
            break
    if okay:
        answer += 1

print(answer)


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

int n;
int cx[22];
int cy[22];
bool f[22];
double l[22][22];
int s = 0;
double d;

int kansu( int x , int y ){
	s++;
	if ( s == n + 1 ) return 1;
	d += l[x][y];
	f[y] = true;
	bool flag = true;
	for ( int i = 2; i < n + 2; i++ ) {
		if ( f[i] ) continue;
		if ( d + l[y][i] >= l[1][i] ) {
			flag = false;
			break;
		}
	}
	if ( flag ) {
		for ( int i = 2; i < n + 2; i++ ) {
			if ( f[i] ) continue;
			if ( kansu( y , i ) ) return 1;
		}
	}
	s--;
	d -= l[x][y];
	f[y] = false;
	return 0;
}

int main(){
	while(true) {
		cin >> n >> cx[0] >> cy[0] >> cx[1] >> cy[1];
		if ( n == 0 ) break;
		for ( int i = 2; i < n + 2; i++ ) {
			cin >> cx[i] >> cy[i];
			f[i] = false;
		}
		for ( int i = 0; i < n + 1; i++ ) {
			for ( int j = i + 1; j < n + 2; j++ ) {
				int x = cx[i]-cx[j];
				int y = cy[i]-cy[j];
				double z = x*x + y*y;
				l[i][j] = sqrt( z );
				l[j][i] = l[i][j];
			}
		}
		s = 0;
		d = 0.00;
		l[0][0] = 0.00;
		if ( kansu( 0 , 0 ) ) {
			cout << "YES" << endl;
		}else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

typedef long long int lli;
#define pb push_back
#define gcd __gcd
#define MOD 1000000007
#define mod2 998244353
#define PI 3.141592653589793238462643383279
#define forz(i,n) for(long long int i=0;i<n;i++)

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1,u,j;
    //cin>>t;
    for(u=1;u<=t;u++){
        lli n,m,i,j,a,b,c,d,k,n1,n2,n3,current;
        cin>>n;
        string s;
        cin>>s;
        if(s.size()<=n) cout<<s<<endl;
        else {
            for(i=0;i<n;i++)cout<<s[i];
            cout<<"..."<<endl;
        } 
    }
}

Measured memory_bytes: 3612
def main():
	N = int(input())
	A = list(map(int, input().split()))
 
	if 0 in A:
		print(0)
		return
 
	prod = 1
	for a in A:
		prod *= a
		if prod > int(10**18):
			print(-1)
			return
 
	print(prod)
 
main()

Measured memory_bytes: 21756
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++)N += s[i] != t[i];
	cout << N << endl;
}

Measured memory_bytes: 3836
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; cin>>N;
    vector<int> A(N), B(N), C(N);
    long long cnt = 0;
    REP(i, N) cin>>A[i];
    REP(i, N) cin>>B[i];
    REP(i, N) cin>>C[i];
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));
    vector<long long> CS(N);
    REP(i, N){
        CS[i] = C.end() - upper_bound(ALL(C), B[i]);
    }
    for(int i=N-2; i>=0; i--){
        CS[i] = CS[i] + CS[i+1];
    }
    
    REP(i, N){
        int idx = upper_bound(ALL(B), A[i]) - B.begin();
        cnt += CS[idx];
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 2176
S = input().strip() ;
T = input().strip() ;


c = len(T) ;
for idx in range ( len ( S ) ) :
	if idx+len(T) >len(S) : break ;
	S2 = S[idx:idx+len(T)] ;
	
	x = 0 ;
	for c1  ,c2  in zip ( S2 , T ) :
		if c1 != c2 :
			x += 1; 
	c = min ( x  ,c ) ; 
print ( c ) ;



Measured memory_bytes: 8888
value = int(input())
people = 0
while True:
	try:
		seat = input()
		if seat:
			string_seat = seat.split()
			seat_list = []
			seat_list = [int(x) for x in (string_seat)]
			people += seat_list[len(seat_list)-1] - seat_list[0]+1
	except EOFError:
		break
# while True:
# 	seat = input()
# 	if seat:
# 		string_seat = seat.split()
# 		seat_list = []
# 		seat_list = [int(x) for x in (string_seat)]
# 		people += aaa(seat_list)
# 	else:
# 		break
print(people)


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

int main() {
    
    int A,B,C,K,sum=0;
    cin >> A >> B >> C >> K;
    
    for(int i=0;i<A;i++){
        sum++;
        K--;
        if(K == 0) break;
    }
    
    if(K == 0){
        cout << sum << endl;
        return 0;
    }
    
    for(int i=0;i<B;i++){
        K--;
        if(K == 0) break;
    }
    
    if(K == 0){
        cout << sum << endl;
        return 0;
    }
    
     for(int i=0;i<C;i++){
        sum--;
        K--;
        if(K == 0) break;
    }
    
    if(K == 0){
        cout << sum << endl;
        return 0;
    }
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
        int s,w;
        cin>>s>>w;
        if(s<=w){
            cout<<"unsafe";
        }
        else cout<<"safe";

    return 0;
}


Measured memory_bytes: 3648
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn=new Scanner(System.in);
	String S=stdIn.next();
	int i=0;
	for(int j=0;j<4;j++){
	    if(S.charAt(j)=='+'){
		i++;
	    }else{
		i--;
	    }
	}
	System.out.println(i);
    }
}
		    
	    


Measured memory_bytes: 21840
#include <stdio.h>
int main(void){
    int n,m,i;
    scanf("%d%d",&n,&m);
    int s,c;
    int a[3]={-1,-1,-1};
    for(i=0;i<m;i++){
        scanf("%d%d",&s,&c);
        if(a[s-1]!=-1 && a[s-1]!=c){
            printf("-1");
            return 0;
        }
        a[s-1]=c;
    }
    if(n!=1 && a[0]==0){
        printf("-1");
        return 0;
    }
    if(n==1 && a[0]==-1) a[0]=0;
    if(n!=1 && a[0]==-1) a[0]=1;
    for(i=0;i<n;i++){
        if(a[i]==-1) printf("0");
        else printf("%d",a[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
typedef struct pair_{
    int x;
    int y;
}pair_t;

int main(){
    int n,y;scanf("%d %d",&n,&y);

    int ans=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int k=n-(i+j);
            if(!(0<=k))continue;
            int x=10000*i+5000*j+1000*k;
            if(x==y){
                printf("%d %d %d\n",i,j,k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
}

Measured memory_bytes: 128
N,K,Q = [int(x) for x in input().split()]
A = [int(input()) for x in range(Q)]
p = [K - Q for x in range(N)]

for item in A:
    p[item-1] += 1

for item in p:
    if 0 < item:
        print("Yes")
    else:
        print("No")

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

using namespace std;
int arr[100006];
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    int ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int curr = 0;
    int nr = 0;
    for(int i = 0; i < n; i++){
        int di = i;
        while(di+1 < n && arr[di] >= arr[di+1]) di++;
        int dx = i;

        while(dx+1 < n && arr[dx] <= arr[dx+1]) dx++;
        ans++;
        i = max(di,dx);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 640