akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
struct UnionFind{
    int n;
    set<int> dame;
    vi p;
    vi use;
    UnionFind(int N):n(N){
        p.resize(n);
        use.resize(n);
    	iota(all(p),0);
    	rep(i,n){
    	    int tmp;
    	    cin>>tmp;
    	    unite(i,tmp+i);
    	}
    }
    void unite(int a, int b){int c=root(a),d=root(b); if(c!=d) p[c]=d; else if(a!=b) dame.insert(root(a));}
    int root(int a){return p[a]=(p[a]==a?a:root(p[a]));}
    bool same(int a, int b){return root(a)==root(b);}
    void useable(){
        rep(i,n){
            use[i]=dame.find(root(i))==dame.end();
        }
    }
};
int main(){
	int n;
	cin>>n;
	UnionFind uf(n);
	uf.useable();
    vi turn(n,-1);
    turn[0]=0;
    queue<int> que;
    que.push(0);
    while(turn[n-1]==-1){
        int c=que.front();que.pop();
        range(d,1,7){
            if(c+d<n && uf.use[c+d] && turn[uf.p[c+d]]==-1){
                que.push(uf.p[c+d]);
                turn[uf.p[c+d]]=turn[c]+1;
            }
        }
    }
    cout<<turn[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4640
T_max = 10**5
N, C = map(int, input().split())
channel = [[] for _ in range(C)]
time = [0]*(T_max+2)
for i in range(N):
    s, t, c = map(int, input().split())
    channel[c-1].append((s, t))
for c in channel:
    c.sort()
    if len(c)==0:
        continue
    time[c[0][0]]+=1
    for i in range(1, len(c)):
        if c[i-1] [1] != c[i][0]:
            time[c[i-1][1]+1] -= 1
            time[c[i][0]]+=1
    time[c[-1][1]+1]-=1
for i in range(1, T_max+1):
    time[i] = time[i-1]+time[i]
print(max(time))

Measured memory_bytes: 54872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
ll dp_ki[200005][2],dp_gu[200005][2];
ll dp_kigu[200005][1];
ll sum[200005][2];
ll a[200005];
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	
	dp_ki[0][0] = dp_gu[0][0] = dp_kigu[0][0] = sum[0][0] = 0;
	for(int i=1;i<=n;i++){
		dp_ki[i][0] = dp_gu[i][0] = dp_kigu[i][0] = 1e18;
		for(ll ii=max(1LL,a[i]-3);ii<=a[i]+3;ii++){
			if(ii%2 == 0){
				dp_gu[i][0] = min(dp_gu[i][0],dp_gu[i-1][0]+abs(a[i]-ii));
			}
			else{
				dp_ki[i][0] = min(dp_ki[i][0],dp_ki[i-1][0]+abs(a[i]-ii));
				dp_kigu[i][0] = min(dp_kigu[i][0],dp_kigu[i-1][0]+abs(a[i]-ii));
				dp_kigu[i][0] = min(dp_kigu[i][0],dp_gu[i-1][0]+abs(a[i]-ii));
			}
		}
		sum[i][0] = sum[i-1][0]+a[i];
		dp_gu[i][0] = min(dp_gu[i][0],sum[i][0]);
		dp_ki[i][0] = min(dp_ki[i][0],sum[i][0]);
		dp_kigu[i][0] = min(dp_kigu[i][0],sum[i][0]);
	}
	
	for(int i=1;i<n+1-i;i++) swap(a[i],a[n+1-i]);
	
	dp_ki[0][1] = dp_gu[0][1] = sum[0][1] = 0;
	for(int i=1;i<=n;i++){
		dp_ki[i][1] = dp_gu[i][1] = 1e18;
		for(ll ii=max(1LL,a[i]-3);ii<=a[i]+3;ii++){
			if(ii%2 == 0){
				dp_gu[i][1] = min(dp_gu[i][1],dp_gu[i-1][1]+abs(a[i]-ii));
			}
			else{
				dp_ki[i][1] = min(dp_ki[i][1],dp_ki[i-1][1]+abs(a[i]-ii));
			}
		}
		sum[i][1] = sum[i-1][1]+a[i];
		dp_gu[i][1] = min(dp_gu[i][1],sum[i][1]);
		dp_ki[i][1] = min(dp_ki[i][1],sum[i][1]);
	}
	
	ll ans = sum[n][0];
	for(int i=1;i<=n;i++){
		ans = min(ans,dp_gu[i][0]+sum[n-i][1]);
		ans = min(ans,dp_ki[i][0]+sum[n-i][1]);
		ans = min(ans,dp_gu[i][0]+dp_ki[n-i][1]);
		ans = min(ans,dp_ki[i][0]+dp_gu[n-i][1]);
		ans = min(ans,dp_kigu[i][0]+dp_gu[n-i][1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

char is(char *s, int n){
	for(int i=0; i<n/2; i++){
		if(s[i]!=s[n-i-1]) return 0;
	}
	return 1;
}

char s[100];
int main(void){
	scanf("%s", s);
	int n=strlen(s);
	if(is(s,n)==0 || is(s,(n-1)/2)==0 || is(s+(n+1)/2,(n-1)/2)==0){
		puts("No");
	}else{
		puts("Yes");
	}
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
  public class Program
  {
    public static void Main()
    {
      int[] args = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
      if(args[0] > 12)
        Console.WriteLine(args[1]);
      else if(args[0] > 5)
        Console.WriteLine(args[1] / 2);
      else
        Console.WriteLine(0);
    }
  }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////

vector<int> places[210000];
ll dp[210000];
void add(ll &a, ll b) { a += b; if (a >= INF)a -= INF; }

int main() {
	//入力
	int N; cin >> N;
	vector<int>c(N);
	for (int i = 0; i < N; ++i)cin >> c[i];
	//places[i]:=(c[j]=iとなるようなjの集まり)
	for (int i = 0; i < 210000; ++i)places[i].clear();
	for (int i = 0; i < N; ++i)places[c[i]].push_back(i);
	//DP
	dp[0] = 1;
	for (int i = 1; i <= N; ++i) {
		//特に操作しない場合
		add(dp[i], dp[i - 1]);
		//操作する場合
		int color = c[i - 1];
		int it = lower_bound(places[color].begin(), places[color].end(), i - 1) - places[color].begin();
		//c[i]がcolor色の何番目の要素か
		if (it > 0) {
			int j = places[color][it - 1];//c[j]=c[i]となるj
			if ((i - 1) - j > 1)add(dp[i], dp[j + 1]);
		}
	}
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 13824
#include<iostream>
typedef long long ll;
using namespace std;

int main(){
    string s;
    int ans =0;
    cin >> s;
    for(int i=0; i<3; i++){
        if(s[i]=='1'){
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

int main()
{

    string s;
    int a = 0;
    cin >> a >> s;
    a = 0;
    for (auto ch : s)
    {
        if (ch == 'R'){
            a++;
        } else {
            a--;
        }
    }
    if (a > 0){
        cout << "Yes";
    } else {
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a[14];
  int b[5];
  int i,j,f;

  while(scanf("%d,%d,%d,%d,%d",&b[0],&b[1],&b[2],&b[3],&b[4])!=EOF){
    for(i=0;i<14;i++)
      a[i]=0;
    for(i=0;i<5;i++)
      a[b[i]]++;
    
    f=1;

    for(i=0;i<14;i++){
      if(a[i]>=4){
	puts("four card");
	f=0;
	break;
      }
    }
    if(f){
      for(i=1;i<14;i++){
	if(f==0)
	  break;
	if(a[i]>=3){
	  if(f){
	    for(j=1;j<14;j++){
	      if(i!=j&&a[j]>=2){
		puts("full house");
		f=0;
		break;
	      }
	    }
	  }
	}
      }
    }
    if(f){
      for(i=0;i<10;i++){
	if(a[i]&&a[i+1]&&a[i+2]&&a[i+3]&&a[i+4]){
	  puts("straight");
	  f=0;
	  break;
	}
      }
    }
    if(f){
      if(a[10]&&a[11]&&a[12]&&a[13]&&a[1]){
	puts("straight");
	f=0;
      }
    }
    if(f){
      for(i=0;i<14;i++){
	if(a[i]>=3){
	  puts("three card");
	  f=0;
	  break;
	}
      }
    }
    if(f){
      for(i=0;i<14;i++){
	if(f==0)
	  break;
	if(a[i]>=2){
	  for(j=0;j<14;j++){
	    if(i!=j&&a[j]>=2){
	      puts("two pair");
	      f=0;
	      break;
	    }
	  }
	}
      }
    }
    if(f){
      for(i=0;i<14;i++){
	if(a[i]>=2){
	  puts("one pair");
	  f=0;
	  break;
	}
      }
    }
    if(f)
      puts("null");
  }
  return 0;
}

Measured memory_bytes: 0
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */      
       int main()
       
       {
           
           
           fast
           
           
           ll n;
           cin>>n;
           
           o(n+n*n+n*n*n)
           
           
           
           
           
           
           
           
           
           
           
           
           
       
 
          re
}

Measured memory_bytes: 3636
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <array>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
#include <utility>
using namespace std;

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

    unordered_set<string> niz;
    while (n--) {
        string str;
        cin >> str;
        niz.insert(str);
    }
    cout << niz.size();
}

Measured memory_bytes: 17588
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, N) for(int i = 0; i < N; ++i)
using namespace std;

#define MOD 1000000007ULL

typedef long long ll;

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

    int x[n];
    rep(i,n)
    {
        cin >> x[i];
    }

    ll minDist = 100000000;
    for (int i = 1; i <= 100; i++)
    {
        ll sum = 0;
        for (int j = 0; j < n; j++)
        {
            sum += (x[j] - i) * (x[j] - i);
        }
        if (minDist > sum)
        {
            minDist = sum;
        }
    }
    cout << minDist << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int red = 0;
    for(char c : S) if(c == '0') red++;
    int blue = N - red;
    int cant = abs(red - blue);
    cout << N - cant << endl;
}

Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int h = sc.nextInt();
    	int n = sc.nextInt();
    	int sum = 0;
    	for(int i = 0; i < n; i++){
    		sum += sc.nextInt();
    	}
    	sc.close();
    	if(0 >= h - sum){
    		System.out.println("Yes");
    	}else{
    		System.out.println("No");
    	}
    }
}

Measured memory_bytes: 46688
import java.util.TreeSet
fun main(args: Array<String>) {
    val N = nextInt()
    val S = next().toCharArray()
    val M = Array(26) { TreeSet<Int>() }
    S.forEachIndexed { index, char -> M[char - 'a'].add(index) }
    val Q = nextInt()
    repeat(Q) {
        val q = listOfString()
        val k = q[0].toInt()
        if (k == 1) {
            val i = q[1].toInt() - 1
            val c = q[2][0]
            M[S[i] - 'a'].remove(i)
            M[c - 'a'].add(i)
            S[i] = c
        } else {
            val l = q[1].toInt() - 1
            val r = q[2].toInt()
            var ans = M.count { (it.ceiling(l) ?: N) < r }
            println(ans)
        }
    }

}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")


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

int main(){
  int n;
  cin>>n;
  int tarous=0,hanakos=0;
  for(int i=0;i<n;i++){
    string tarou,hanako;
    cin>>tarou>>hanako;
    if(tarou>hanako){
      tarous+=3;
    }else if(tarou<hanako){
      hanakos+=3;
    }else{
      tarous++;
      hanakos++;
    }
  }
  cout<<tarous<<' '<<hanakos<<endl;
  return 0;
}


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

#define rep(i, n) for (ll i=0;i<(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(x) (x).begin(),(x).end()
#define Sort(a) sort(ALL(a))
#define Rev(a) reverse(ALL(a))


using namespace std;
//using ll=long long;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
const long double PI=3.14159265358979323846;


template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}


int main(){

  ll n,a,b;
  cin>>n>>a>>b;

  string s;

  cin>>s;

  ll aa=0,bb=0;
  bool ans;
  
  rep(i,n){
    //cout<<aa<<" "<<bb<<endl;
    ans = false;
    if(s[i]=='a'){
      if(aa+bb<a+b) {
	ans=true;
	aa++;
      }
    }
    if(s[i]=='b'){
      if(aa+bb<a+b && bb<b){
	ans=true;
	bb++;
      }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
    
  
}


Measured memory_bytes: 896
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000//10^12
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007

using namespace std;

ll int mod_inverse(int a,int M){
	int x=M-2;
	ll int temp=a;
	ll int ret=1;
	//a^(MOD-1)==1(mod MOD)を利用
	//a^-1==a^(MOD-2) (mod MOD)を繰り返し二乗法で求める

	while(x!=0){
		if(x%2==1){
			ret=(ret*temp)%M;
		}
		temp=(temp*temp)%M;
		x=x/2;
	}
	return ret;
}


int main(void)
{
	//変数の宣言
	int n;
	static int a[100010];
	static ll int dp[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);


	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
//		scanf_s("%d",&a[i]);
	}

	
	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	dp[0]=0;
	for(i=1;i<=n;i++){
		dp[i]=(dp[i-1]+mod_inverse(i,MOD))%MOD;
	}

	for(i=0;i<n;i++){
		ans=(ans+a[i]*(dp[n-i]+dp[i+1]-1))%MOD;
	}

	for(i=1;i<=n;i++){
		ans=ans*i%MOD;
	}

/*	for(i=0;i<=n;i++){
		printf("dp[%d]=%d\n",i,dp[i]);
	}*/

	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 1408
import sys
#read = sys.stdin.buffer.read
#input = sys.stdin.buffer.readline
#inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
    N=int(input())
    F=[int(input().replace(" ",""),2) for _ in range(N)]
    P=[list(map(int,input().split())) for _ in range(N)]
    ans=-10**10
    for i in range(1,1<<10):
        tmp=0
        for f,p in zip(F,P):
            tmp+=p[bin(f&i).count("1")]
        ans=max(ans,tmp)
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 41452
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            int[] last = new int[20], prevLast = new int[20];
            Arrays.fill(last, -1);
            Arrays.fill(prevLast, -1);
            long result = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < 20; j++) {
                    if ((a[i] & (1 << j)) != 0) {
                        prevLast[j] = last[j];
                        last[j] = i;
                    }
                }

                int max = -1;
                for (int t = 0; t < 20; t++) {
                    max = Math.max(max, prevLast[t]);
                }
                result += i - max;
            }
            out.println(result);
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int[] nextIntArray(int n) {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }

    }
}



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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	double p[3000];
	rep(i,n) scanf("%lf",&p[i]);

	double dp[2][3001]={};
	dp[0][0]=1;
	int curr=0,next=1;
	rep(i,n){
		rep(j,n+1) dp[next][j]=0;

		rep(j,i+1){
			dp[next][j+1]+=p[i]*dp[curr][j];
			dp[next][j]+=(1-p[i])*dp[curr][j];
		}

		rep(j,n+1) dp[curr][j]=dp[next][j];
		swap(curr,next);
	}

	double ans=0;
	rep(j,n+1) if(j>n-j) ans+=dp[curr][j];
	printf("%.15f\n",ans);

	return 0;
}


Measured memory_bytes: 256
//CODEFORCES:-
//coded by AMAN BHARTI NIT PATNA
//ALL RIGHTS RESERVED
//ECE 2K18

#include<bits/stdc++.h>
using namespace std;

//#define home
#define TASK "soln"
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define pb push_back
#define ll long long int
#define br cout<<endl;
#define fo for(int i=0;i<n;i++)
#define foo for(int i=1;i<=n;i++)
#define mod 1000000007

int dp[1000000][5];

int cal(int a[][4],int n,int p){
    if(n==0)return 0;

    if(dp[n][p]!=-1)return dp[n][p];
    int ans =0;

    for(int i=1;i<=3;i++){
        if(i==p)continue;
        ans = max(ans,a[n][i]+cal(a,n-1,i));
    }

    return dp[n][p] = ans;
}

void solve(){
    memset(dp,-1,sizeof(dp));
    int n;
    cin>>n;
    int a[n+1][4];
    
    foo{
        for(int j=1;j<=3;j++){
            cin>>a[i][j];
        }
    }

    cout<<cal(a,n,0);
    br;    
}

int main(){
	#ifdef home
        assert(freopen(TASK".in","r",stdin));
        assert(freopen(TASK".out","w",stdout));
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin>>t;
    // while(t-->0)
    solve();

    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif

    return 0;
}

Measured memory_bytes: 32536
import java.math.BigDecimal;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigDecimal A = new BigDecimal(sc.next());
        BigDecimal B = new BigDecimal(sc.next());
        System.out.println(A.multiply(B).longValue());
    }
}

Measured memory_bytes: 27220
a = [5,7,5,7,7]
 
while True:
    n = int(input())
    if n == 0: break
    w = list(map(lambda x: len(input()) , range(n)))
    ans = 0
    for i in range(n):
        aa, g = 0, 0
        for j in range(i, n):
            g += w[j]
            if g == a[aa]:
                g =  0
                aa += 1
                if aa == 5:
                    ans = i+1
                    break
            elif g > a[aa]:
                break
        if ans:
            break
    print(ans)


Measured memory_bytes: 5612
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

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

    vector<string> s;
    rep(i, N) {
        string stmp; cin >> stmp; s.push_back(stmp);
    }

    int M; cin >> M;

    vector<string> t;
    rep(i, M) {
        string ttmp; cin >> ttmp; t.push_back(ttmp);
    }

    map<string, int> mp;
    // 青いカード
    rep(i, N) {
        if (mp.find(s[i]) == mp.end()) {
            mp.insert(make_pair(s[i], 1));
        } else {
            mp[s[i]]++;
        }
    }
    // 赤いカード
    rep(i, M) {
        if (mp.find(t[i]) == mp.end()) {
            mp.insert(make_pair(t[i], -1));
        } else {
            mp[t[i]]--;
        }
    }

    int ans = -100;
    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        int value = iter->second;
        if(value > ans) ans = value;
    }

    if (ans < 0) cout << 0 << endl;
    else cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iterator>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int N, T;
    scanf("%d %d", &N, &T);
    LL pre = 0, ans = 0;
    for (int i = 0; i < N; i++) {
        LL tmp;
        scanf("%lld", &tmp);
        if (!i) {
           pre = i;
           continue;
        }
        ans += tmp - max(tmp - T, pre);
        pre = tmp;
    }
    ans += T;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
//#define mod 1000000007
#define MN 606
using namespace std;
struct node{int x,y;};
int u[MN*MN],h[MN][MN],tot[5];
int n,m,A,B,cnt;
bool hv[MN][MN];
vector <node> v;

inline int read()
{
	int n=0,f=1; char c=getchar();
	while (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}
	while (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}
	return n*f;
}

bool check(int x,int y) {if (0<=x&&x<n*2&&0<=y&&y<n*2 && !hv[x][y]) return true; return false;}
void dfs(int x,int y,int col)
{
	hv[x][y]=true; h[x][y]=(h[x][y]<<1)+col;
//	printf("%d %d %d\n",x,y,col);
	for (int i=0;i<v.size();++i)
	{
		if (check(x+v[i].x,y+v[i].y))
			  dfs(x+v[i].x,y+v[i].y,col^1);
		if (check(x-v[i].x,y+v[i].y))
			  dfs(x-v[i].x,y+v[i].y,col^1);
		if (check(x+v[i].x,y-v[i].y))
			  dfs(x+v[i].x,y-v[i].y,col^1);
		if (check(x-v[i].x,y-v[i].y))
			  dfs(x-v[i].x,y-v[i].y,col^1);
	}
}
void solve(int num)
{
	register int i,j;
	v.clear();
	memset(hv,0,sizeof(hv));
	for (i=0;i*i<=num;++i)
		if (u[num-i*i]>=0) v.push_back((node){i,u[num-i*i]});
//	printf("%d\n",v.size());
	for (i=0;i<n*2;++i)
		for (j=0;j<n*2;++j)
			if (!hv[i][j]) dfs(i,j,0);
//	for (i=0;i<n*2;++i,puts(""))
//		for (j=0;j<n*2;++j)
//			printf("%d",h[i][j]);	
}

int main()
{
	register int i,j,mx;
	n=read(); A=read(); B=read();
	for (i=0;i<MN*MN;++i) u[i]=-1;
	for (i=0;i<MN;++i) u[i*i]=i;
	solve(A); solve(B);
	for (i=0;i<n*2;++i)
		for (j=0;j<n*2;++j)
			++tot[h[i][j]];
	for (mx=0,i=0;i<4;++i) if (tot[i]>tot[mx]) mx=i;
	for (cnt=0,i=0;i<n*2;++i)
		for (j=0;j<n*2;++j)
		{
			if (cnt==n*n) continue;
			if (h[i][j]==mx) printf("%d %d\n",i,j),++cnt;
		}
}

Measured memory_bytes: 20992
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int g,a,b,c,m,mg;
	while(cin >> g) {
		if (g==0) break;
		mg=9999999;
		for (a=0;a<26;a++) for (b=0;b<17;b++) for (c=0;c<51;c++) {
			if (a*200+b*300+c*500!=g) continue;
            m=(a/5)*1520+(a%5)*380+(b/4)*1870+(b%4)*550+(c/3)*2244+(c%3)*850;
			mg=(mg > m) ? m : mg;
		}
    cout << mg << endl;
	}
    return 0;
	}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

char s[10];
int n;
int ans = 0;

void dfs(int i, int sum, int now) {
	if (i == n - 1) {
		ans += sum + now;
	}
	else {
		dfs(i + 1, sum + now, s[i + 1]);
		dfs(i + 1, sum, now * 10 + s[i + 1]);
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string str; cin >> str;
	n = str.size();
	rep(i, n) {
		s[i] = str.at(i) - '0';
	}
	dfs(0, 0, s[0]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll c=0, N;
    in >> N;
    vector<ll> p(N);
    REP(i,N){
        in >> p[i];
    }

    REP_AB(i, 1, N-1){
        if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])) {
            c++;
        }
    }

    out << c << endl;
 

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    string s;
    cin >> s;
    //cout << s.length() << endl;

    int first = 0,last = 0;

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

        if(s[i] == 'A'){
            first = i+1;
            break;
        }
    }


    for(int i = s.length();i >= 0;i--){

        if(s[i] == 'Z'){
            last = i+1;
            break;
        }
    }
    //cout << first << " " << last << endl;

    cout << last-first+1 << endl;
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9)
    {
        cout << -1 << endl;
        return 0;
    }
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3636
package main

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

type entry struct {
	value uint64
	cost  uint64
}

func entryAdd(a *entry, b *entry) entry {
	return entry{
		value: a.value + b.value,
		cost:  a.cost + b.cost + a.value + b.value,
	}
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()

	n, _ := strconv.Atoi(s.Text())
	return n
}

func solve(a []int, n int) uint64 {
	dp := make([][]entry, n)

	for i := 0; i < n; i++ {
		dp[i] = make([]entry, n+1)
		dp[i][i+1].value = uint64(a[i])
	}

	for length := 2; length <= n; length++ {
		for i := 0; i < n-length+1; i++ {
			min := entry{
				value: math.MaxUint64,
				cost:  math.MaxUint64,
			}
			for j := i + 1; j < i+length; j++ {
				e := entryAdd(&dp[i][j], &dp[j][i+length])
				if e.cost < min.cost {
					min = e
				}
			}

			dp[i][i+length] = min
		}
	}

	return dp[0][n].cost
}

func main() {
	s := bufio.NewScanner(bufio.NewReader(os.Stdin))
	s.Split(bufio.ScanWords)

	n := nextInt(s)
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt(s)
	}

	fmt.Println(solve(a, n))
}


Measured memory_bytes: 3200
n=int(input())
if n<=3:
  print(1)
else:
  ans=[]
  for i in range(2,int(n**(1/2)+1)):
    e=2
    while i**e<=n:
      if i**(e+1)>n:
        ans.append(i**e)
        break
      e+=1
  print(max(ans))


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

int main() {
  string S;
  cin >> S;
  bool YYMM = true;
  bool MMYY = true;
  if ((S[2]=='0' && S[3] == '0') || (S[2] == '1' && S[3] >= '3') || (S[2] >= '2'))
  {
    YYMM = false;
  }
  if ((S[0]=='0' && S[1] == '0') || (S[0] == '1' && S[1] >= '3') || (S[0] >= '2'))
  {
    MMYY = false;
  }

  if (YYMM && MMYY)
  {
    cout << "AMBIGUOUS" << endl;
  } else if (YYMM && !MMYY)
  {
    cout << "YYMM" << endl;
  } else if (!YYMM && MMYY)
  {
    cout << "MMYY" << endl;
  } else
  {
    cout << "NA" << endl;
  }
  
  
  
  
  return 0;
}


Measured memory_bytes: 256
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex> //正規表現
using namespace std;
#define _GLIBCXX_DEBUG /GCC環境下で[]による配列要素参照のエラーを出す
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int n;
  cin>>n;
  vector<int>p(n);
  rep(i,n){
    cin>>p.at(i);
  }
  vector<int>q(n);
  rep(i,n){
    cin>>q[i];
  }
  vector<int>vec(n);
  rep(i,n){
    vec[i]=i+1;
  }
  int cnt =0;
  int pp,qq;
  pp=0;
  qq=0;
  do{
    //cout<<vec[0]<<vec[1]<<vec[2]<<endl;
    if(vec==p){
      pp=cnt;
    }
    if(vec==q){
      qq=cnt;
    }
    if(pp!=0&&qq!=0){
      break;
    }
    cnt+=1;
  }while(next_permutation(vec.begin(),vec.end()));
  //cout<<vec[0]<<vec[1]<<vec[2]<<endl;
  cout<<abs(pp-qq)<<endl;
}

  

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i=0;i<N;i++){
			cin >> a[i];
	}
	
	int count=0;
	for(int i=1;i<N;i++){
			if(a[i]==a[i-1]){
					count++;
					a[i]=0;
			}
	}
	cout << count << endl;
	return 0;
}



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

int main(){
    int N;
    cin >> N;
    multiset<int> st;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        st.insert(a);
    }
    int ans = 0;
    while(st.size()){
        auto it = prev(st.end());
        int a = *it;
        st.erase(it);
        int pw = 1;
        while(pw-a <= 0) pw *= 2;
        int b = pw-a;
        auto it2 = st.find(b);
        if(it2 != st.end()){
            ans++;
            st.erase(it2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n;
    cin>>n;
    rep(i,0,n+1){
        if((ll)(i*1.08)==n){
            cout<<i<<endl;
            exit(0);
        }
    }
    cout<<":("<<endl;
    
    
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int a,b;
    cin>>a>>b;
    if(a>=13)
        cout<<b;
    else if(a>=6)
        cout<<b/2;
    else
        cout<<0;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0 && x+r <= w && y+r <= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N;

	cin>>N;
	vector<long long> A(N,0);
	long long num=0;
	long long P;
	long long minP=1;
	int i;
	for (i=0;i<N;i++){
		cin>>A[i];
	}
	for (i=0;i<N;i++){
		if (i==0){
			num = A[i] -1;
			minP = 2;
		}else{
			if (A[i]<=minP){
				if (A[i]==minP){
					minP++;
				}
				continue;
			}
			P = minP;
			long long x=A[i]/P;
			long long y=A[i]%P;
			num += x;
			if (y==0){
				 num--;
			}
		}
	}
	cout<<num<<endl;
	return 0;
}


Measured memory_bytes: 1152
red = []
blue = []
ans = 0
n = int(input())
for _ in range(n):
    red.append(input())
m = int(input())
for _ in range(m):
    blue.append(input())

for word in set(red):
    r_num = red.count(word)
    if word in blue:
        tmp = r_num - blue.count(word)
    else:
        tmp = r_num
    if tmp > ans:
        ans = tmp
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for_each(begin(A), end(A), [](auto& x) { cin >> x; });

  ll all = accumulate(cbegin(A), cend(A), 0LL,
                      [](auto acc, auto x) { return acc ^ x; });
  for_each(begin(A), end(A), [&](auto& x) { x ^= all; });
  for (ll i = 0; i < N; i++) {
    cout << A[i];
    if (i != N - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }

  return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, o = 0, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) {
        o++;
      }
    }
    if (o == 8 && i % 2) {
      ans++;
    }
    o = 0;
  }
  cout << ans << '\n';
  return 0;
}


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

aList=list(map(int,input().split()))

s=sum(aList)
mean=s/n

ans=-1
kyori=1000
for i in range(n):
  tmpkyori=abs(aList[i]-mean)
  if kyori>tmpkyori:
    ans=i
    kyori=tmpkyori

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	Info(ll arg_base_time,ll arg_add_num,ll arg_add_right_index, ll arg_add_right_time,ll arg_rest_right_index){
		base_time = arg_base_time;
		add_num = arg_add_num;
		add_right_index = arg_add_right_index;
		add_right_time = arg_add_right_time;
		rest_right_index = arg_rest_right_index;
	}
	bool operator<(const struct Info &arg) const{
		return add_num < arg.add_num;
	}
	ll base_time,add_num,add_right_index,add_right_time,rest_right_index;

};

ll N,M,K,normal,semi,express,T;

int main(){

	scanf("%lld %lld %lld",&N,&M,&K);
	scanf("%lld %lld %lld",&normal,&express,&semi);

	scanf("%lld",&T);

	ll tmp,next_station,left_time,num,safe_num;
	ll over_left_index,rest_num,new_left_time,new_safe_num;
	ll add_num,add_right_index,add_right_time,rest_right_index;

	queue<ll> STATION;

	scanf("%lld",&tmp);

	for(int i = 1; i < M; i++){
		scanf("%lld",&tmp);
		STATION.push(tmp);
	}
	STATION.push(N+1);

	priority_queue<Info> Q;
	ll ans = 0;

	ll left = 1;

	while(!STATION.empty()){
		next_station = STATION.front();
		STATION.pop();

		left_time = express*(left-1);

		if(left_time > T){
			left = next_station;
			continue;
		}

		num = (next_station-1)-left+1;
		safe_num = (T-left_time)/normal+1;
		ans += min(safe_num,num);

		if(safe_num >= num){
			left = next_station;
			continue;
		}

		over_left_index = safe_num;
		rest_num = (num-1)-over_left_index+1;
		new_left_time = left_time+semi*safe_num;

		if(new_left_time > T){
			left = next_station;
			continue;
		}

		new_safe_num = (T-new_left_time)/normal+1;

		add_num = min(rest_num,new_safe_num);

		add_right_index = over_left_index+add_num-1;
		add_right_time = new_left_time+normal*(add_num-1);
		rest_right_index = num-1;

		Q.push(Info(left_time,add_num,add_right_index,add_right_time,rest_right_index));

		left = next_station;
	}

	int count = 0;

	while(Q.empty() == false && count < K-M){

		ans += Q.top().add_num;
		count++;

		if(Q.top().add_right_index == Q.top().rest_right_index){
			Q.pop();
			continue;
		}

		over_left_index = Q.top().add_right_index+1;
		rest_num = Q.top().rest_right_index-over_left_index+1;
		new_left_time = Q.top().base_time+semi*over_left_index;

		if(new_left_time > T){
			Q.pop();
			continue;
		}

		new_safe_num = (T-new_left_time)/normal+1;

		add_num = min(rest_num,new_safe_num);
		add_right_index = over_left_index+add_num-1;
		add_right_time = new_left_time+normal*(add_num-1);
		rest_right_index = Q.top().rest_right_index;

		Q.push(Info(Q.top().base_time,add_num,add_right_index,add_right_time,rest_right_index));

		Q.pop();
	}

	ans -= 1;

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3344
#include <cstdio>
#include <bitset>
#include <iostream>
using namespace std;

int a[10];

bool solve(){
        int num = 1024;
        while (num-- > 0){
                bitset<10> option(num);
                int left = 0;
                int right = 0;
                bool flag = true;
                for (int i = 0; i < 10; i++){
                        if (option[i]){
                                // right
                                if (right < a[i]){
                                        right = a[i];
                                }else{
                                        flag = false;
                                        break;
                                }
                        }else{
                                // left
                                if (left < a[i]){
                                        left = a[i];
                                }else{
                                        flag = false;
                                        break;
                                }
                        }
                }

                if (flag) break;
        }
        if (num >= 0) return true;
        else return false;
}

int main(){
        int n;
        scanf("%d", &n);
        while (n--){
                for (int i = 0; i < 10; i++){
                        scanf("%d", &a[i]);
                }
                bool ans = solve();
                if (ans) printf("YES\n");
                else printf("NO\n");
        }
        return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

int hani(int w,int h, int x,int y,int r) {
	int flag = 1;

	if (x < 0 || y < 0 || x > w || y > h) {
		flag = 0;
	}
	if (x + r > w) {//→
		flag = 0;
	}
	if (x - r < 0) {//←
		flag = 0;
	}
	if (y + r > h) {//↑
		flag = 0;
	}
	if (y - r < 0) {//↓
		flag = 0;
	}

	return flag;
}

int main()
{
	int w, h, x, y, r;

	scanf("%d %d %d %d %d", &w, &h, &x , &y, &r);

	if (hani(w, h, x, y, r)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	
	return 0;
}


Measured memory_bytes: 2112
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef queue< pair<int, int> > qpii;
typedef vector<int> vi;
typedef vector<int, int> vii;
typedef vector<string> vs;
typedef vector< pair<int, int> > vpii;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

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

	int k, t, a[101];
	cin >> k >> t;
	rep(i,0,t) cin >> a[i];

	if(t == 1) {
		cout << k - 1 << endl;
		return 0;
	}

	sort(a, a+t);

	int before = -1, ans = 0;
	rep(i,0,k) {
		int m = 0;
		rep(j,0,t) {
			if(a[j] != 0) {
				m = j;
				break;
			}
		}
		rep(j,0,t) {
			if(j == before) continue;
			if(a[m] < a[j]) m = j;
		}
		if(m == before) {
			ans++;
		}
		a[m]--;
		before = m;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
import sys
L,R = map(int,input().split())
if R-L >=2019:
  print(0)
elif R%2019==0 or L%2019==0:
  print(0)
else:
  ans = 2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      a = i*j%2019
      if ans>a:
        ans = a
    if ans == 0:
      print(0)
      sys.exit()
  print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,m;
	scanf("%d%d\n",&n,&m);
	string s;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		cin>>s;
		if(s=="snuke")
		{
			printf("%c%d\n",j+'A'-1,i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
S = input()
while len(S) > 0:
    if S[-5::1] == 'dream' or S[-5::1] == 'erase':
        S = S[:-5:1]
    elif S[-6::1] == 'eraser':
        S = S[:-6:1]
    elif S[-7::1] == 'dreamer':
        S = S[:-7:1]
    else:
        print('NO')
        break

if len(S) == 0:
    print('YES')




Measured memory_bytes: 3188