akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct edge{ll to,cost;};
const ll INF = 1e16;

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;

    vector<vector<edge> > graph(n);
    REP(i,m){
        int a = in(), b = in(), c = in(), d = in();
        a--;b--;c--;
        graph[a].push_back(edge{b, d});
        graph[b].push_back(edge{a, d});
        graph[b].push_back(edge{c, d});
        graph[c].push_back(edge{b, d});
        graph[a].push_back(edge{c, d});
        graph[c].push_back(edge{a, d});
    }


    VL d(n, INF);
    d[s] = 0;
    priority_queue<PL, vector<PL>, greater<PL> > q;
    q.push(make_pair(0, s));
    while (!q.empty()){
        PL a = q.top();
        q.pop();
        int now = a.second;
        if(d[now] < a.first) continue;
        REP(i,graph[now].size()){
            edge e = graph[now][i];
            int next = e.to;
            if (d[next] > d[now] + e.cost){
                d[next] = d[now] + e.cost;
                q.push(make_pair(d[next], next));
            }
        }
    }

    cout << d[t] << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(int, char**)
{
	ll  n, m;
	ll  mx = 0, my = 100001;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		ll x, y;
		cin >> x >> y;
		mx = max(mx, x);
		my = min(my, y);
	}

	if (my >= mx)
		cout << (my - mx + 1) << endl;
	else
		cout << 0 << endl;

	return 0;
}



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

int main(){
  long long a,b,c,d,i,j;
  cin >> a >> b >> c >> d;
  vector<vector<long long>> dp(c+1,vector<long long>(d+1));
  long long p=998244353;
  
  dp.at(a).at(b)=1;
  for(i=a+1;i<=c;i++){
    dp.at(i).at(b)=(dp.at(i-1).at(b)*b)%p;
  }
  for(j=b+1;j<=d;j++){
    dp.at(a).at(j)=(dp.at(a).at(j-1)*a)%p;
  }
  
  for(i=a+1;i<=c;i++){
    for(j=b+1;j<=d;j++){
      dp.at(i).at(j)=(dp.at(i-1).at(j)*j+dp.at(i).at(j-1)*i-dp.at(i-1).at(j-1)*(i-1)*(j-1))%p;
    }
  }
  
  if(dp.at(c).at(d)<0){
    dp.at(c).at(d) += p;
  }
  
  cout << dp.at(c).at(d) << endl;
}

Measured memory_bytes: 73652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		boolean isOk = false;
		String[] divide = { "dream", "dreamer", "erase", "eraser" };
		int t = S.length();
		while (true) {
			for (String s : divide) {
				if (t - s.length() >= 0 && S.substring(t - s.length(), t).equals(s)) {
					isOk = true;
					t -= s.length();
					break;
				} else {
					isOk = false;
				}
			}
			if (!isOk || t == 0) {
				break;
			}
		}
		System.out.println(isOk ? "YES" : "NO");
		in.close();
	}
}

Measured memory_bytes: 27908
N = int(input())
T = list(map(int, input().split()))
M = int(input())
D = [list(map(int, input().split())) for _ in range(M)]

for m in range(M):
    tmp_T = T[:]
    tmp_T[D[m][0]-1] = D[m][1]
    print(sum(tmp_T))

Measured memory_bytes: 9004
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  map<ll, ll> num;
  ll t2=0;
  cin >> N;
  rep(i, N){
    ll tmp;
    cin >> tmp;
    num[tmp/400]++;
    if(tmp>=3200)t2++;
  }

  ll cnt=0;
  rep(i, 8){
    if(num[i]>0)cnt++;
  }
  
  
  cout << max(cnt, 1LL) << " " << cnt+t2;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <utility>

using namespace std;

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

    long res = 0;
    for (long d = N; d > K; d--)
        res += max(0l, N % d - K + 1) + (d - K) * (N / d);

    if (K == 0) res -= N;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
x,y = gets.chomp.split(" ").map(&:to_i)
ans = 10**10
if x*y > 0
  if x < y
    ans = y-x
  else
    ans = x-y+2
  end
elsif x*y < 0           
  ans = (x.abs-y.abs).abs+1
elsif x < y
  ans = y-x
else
  ans = x-y+1
end
puts ans

Measured memory_bytes: 1788
#include<stdio.h>
#define MOD 1000000007
#define MAX 510000

long int FAC[MAX],FINV[MAX],INVE[MAX];
long int SUM(long int a,long int b){return (a%MOD+b%MOD+MOD)%MOD;}//a+b
long int PROD(long int a,long int b){return a%MOD*(b%MOD)%MOD;}//a*b
long int POW(long int a,long int b){//a^b
  long int c=1;
  for(a%=MOD;b;a=PROD(a,a),b>>=1)if(b&1)c=PROD(a,c);
  return c;
}
long int INV(long int a){return a<MAX?INVE[a]:POW(a,MOD-2);}//a^-1
long int QUOT(long int a,long int b){return PROD(a,INV(b));}//a/b
void init_inv(long int a){//make inv list
  INVE[1]=1;
  for(long int i=2;i<=a;i++)INVE[i]=SUM(0,-PROD(INVE[MOD%i],MOD/i));
}
void init_com(long int a){//make fac and facinv list
  FAC[0]=FAC[1]=1;
  FINV[0]=FINV[1]=1;
  init_inv(a);
  for(long int i=2;i<=a;i++){
    FAC[i]=PROD(FAC[i-1],i);
    FINV[i]=PROD(FINV[i-1],INV(i));
  }
}
long int COM(long int a,long int b){return PROD(PROD(FAC[a],FINV[a-b]),FINV[b]);}

int main(){
  long int m,n;
  scanf("%ld%ld",&n,&m);
  if(m-n>1||m-n<-1){printf("0");return 0;}
  init_com(n>m?n:m);
  printf("%ld",PROD(PROD(FAC[n],FAC[m]),1+(n==m)));
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>x(n);
  
 for(int i=0;i<n;i++){
   cin>>x.at(i);
 }
  
  int a=0,b=0;
  
for(int i=0;i<n;i++){
  a=a+x.at(i)*x.at(i);
}
for(int i=0;i<n;i++){
  b=b+x.at(i);
}
if(b%n==0)cout<<a-b*b/n<<endl;
else{
  int p,q;
  p=b/n;
  q=p+1;
cout<<min(a-2*p*b+p*p*n,a-2*q*b+q*q*n)<<endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c,k,r,g;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    string s;
    for(i=1;i<n;i++)
    {
        if(arr[i]>arr[i-1]) s.pb('i');
        else if(arr[i]<arr[i-1]) s.pb('d');
        else s.pb('e');
    }
    ll ans=0;
    ll have=1000;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='i') 
        {
            ll stock=have/arr[i];
            have=have%arr[i];
            stock*=arr[i+1];
            have+=stock;
        }
    }
    cout<<have;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-9;
long double pi = acos(-1);

ll mod = 1e9+7;
template<typename T> void add(T &a,T b){a=(a+b)%mod;}
template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}


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


    int n;
    cin>>n;
    int a[n];
    map<int,int> mp;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    int cnt = 0;
    for(int i=0;i<n;i++){
        bool pos = 1;
        for(int j=1;j*j<=a[i];j++){
            if(a[i] % j == 0){
                if(j != 1){
                    if(mp.count(j) || mp.count(a[i]/j)){
                        pos = false;
                        break;
                    }
                }
                else{
                    if(a[i]==1 && mp[1] >= 2){
                        pos = false;
                        break;
                    }
                    if(a[i] != 1 && mp.count(1)){
                        pos = false;
                        break;
                    }
                    if(mp[a[i]] >= 2){
                        pos = false;
                        break;
                    }
                }
            }
        }
        if(pos)cnt++;
    }
    cout << cnt << endl;

}


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

using ll=long long;
const ll MOD=1e9+7;
ll solve(int n,vector<int> a,vector<int> b,vector<int> c){
    vector<vector<int>> dp(n+1,vector<int>(2,0));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        int lb=(i==0 ? 1 : 0);
        for(int an=lb;an<10;an++){
            if(a[i]!=-1 && an!=a[i]) continue;
            for(int bn=lb;bn<10;bn++){
                if(b[i]!=-1 && bn!=b[i]) continue;
                //cerr<<"#"<<i<<" "<<an<<" "<<bn<<endl;
                int digit=(an+bn)%10;
                int carry=(an+bn)/10;
                if(c[i]==-1 || digit==c[i]){
                    dp[i+1][0]+=dp[i][carry];
                    dp[i+1][0]%=MOD;
                }
                digit=(an+bn+1)%10;
                carry=(an+bn+1)/10;
                if(c[i]==-1 || digit==c[i]){
                    dp[i+1][1]+=dp[i][carry];
                    dp[i+1][1]%=MOD;
                }
            }
        }
    }
    return dp[n][0]%MOD;
}

int tonum(char x){
    if(isdigit(x)) return x-'0';
    else return -1;
}
int main(){
    string abuf,bbuf,cbuf;
    
    while(cin>>abuf>>bbuf>>cbuf,abuf!="0"){
        int n=abuf.size();
        vector<int> a(n),b(n),c(n);
        for(int i=0;i<n;i++){
            a[i]=tonum(abuf[i]);
            b[i]=tonum(bbuf[i]);
            c[i]=tonum(cbuf[i]);
        }
        cout<<solve(n,a,b,c)<<endl;
    }
    return 0;
}


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


int main() {
  int n;
  int a;

  cin >> n;
  
  a = n;
  while (n > 2) {
    if (a % 2 == 0) {
      a++;
      continue;
    }
    int n1 = sqrt(a);
    int flag = 0;
    for (int i = 3; i < n1; i += 2) {
      if (a % i == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      break;
    }
    a++;
  }
  cout << a << endl;
}


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

ll GCD(ll a, ll b){
  if( b == 0 ){ return a;}
  else{ return GCD(b,a%b);}
}

ll LCM(ll a, ll b){
  ll g = GCD(a,b);
  ll res = (a*b)/g;
  
  return res;
}

int main(){
  
  ll N,M; cin >> N >> M;
  
  vector<ll> A(N);
  
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  ll p = 0;
  
  for(ll i = 0; i < N; i++){
    ll res = A[i]/2;
    
    // res中に何個素因数２があるのかを確かめる
    
    ll cnt = 0;
   
   while( res % 2 == 0 ){ 
      cnt++;
      res /= 2;
    }
    
    
    if( i && p != cnt ){ cout << 0 << endl; return 0;}
    
    p = cnt;
    
  }
  
  
  vector<ll> c(N);
  
  for(ll i = 0; i < N; i++){ c[i] = A[i]/(ll)pow(2LL,p+1);}
  
  // vector c(N)の最小公倍数を求める
  
  
  ll L = 1LL;
  
  for(ll i = 0; i < N; i++){
    L = LCM(L,c[i]);
  }
  
  ll rem = (ll)pow(2,p)*L;
  
  ll ans = ( (M/rem) + 1 )/2;
  
  cout << ans << endl;
  
  return 0;
}
   

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    int r(0);
    for (int i = 0; i < (s.size() + 1) / 2; i++)
    {
        if (s.at(i) != s.at(s.size() - 1 - i))
            r++;
    }
    cout << r << endl;
    return 0;
}


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

void sieve(int n, vector<int> &primes)
{
    vector<bool> v(n / 2 + 1, true);

    // check
    for (int i = 3, end = sqrt(n); i <= end; i += 2) {
        if (!v[i / 2])
            continue;
        for (int j = i * i / 2; j <= n / 2; j += i)
            v[j] = false;
    }

    primes.push_back(2);
    for (int i = 3; i <= n; i += 2)
         if (v[i / 2])
            primes.push_back(i);
}

int main()
{
    vector<int> primes;
    vector<int> inputs;
    int count = 0;

    for (int x; cin >> x;)
        inputs.push_back(x);

    // unique inputs
    sort(inputs.begin(), inputs.end());
    auto it = unique(inputs.begin(), inputs.end());
    inputs.resize(distance(inputs.begin(), it));

    sieve(*max_element(inputs.begin(), inputs.end()), primes);

    for (int x: inputs)
        if (binary_search(primes.begin(), primes.end(), x))
            count++;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 41668
# after YouTube editorial

n = gets.strip.to_i
c = gets.strip
r = c.count('R')
w = 0
ans = r
c.each_char do |e|
  if e == 'R'
    r -= 1
  else
    w += 1
  end
  ans = [[r,w].max,ans].min
end
p ans


Measured memory_bytes: 14688
h, w = map(int, input().split())
rule = []
for _ in range(h):
    rule.append(list(input()))
mod = 10**9 + 7

graph = [[0 for _ in range(w)] for _ in range(h)]
graph[0][0] = 1

for i in range(h):
    for j in range(w):
        if j+1 < w and rule[i][j+1] == '.':
            graph[i][j+1] = (graph[i][j+1] + graph[i][j]) % mod
        if i+1 < h and rule[i+1][j] == '.':
            graph[i+1][j] = (graph[i+1][j] + graph[i][j]) % mod

#print(graph)
print(graph[-1][-1])

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

using namespace std;
int main(){
  int N;
  cin >> N;
  double X;
  string U;
  double S = 0.0;
    
 for(int i = 0; i < N; ++i){
   cin >> X >>U;
   
   if(U == "BTC") S += X*380000.0;
   if(U == "JPY") S += X; 
 }  
       cout << S << endl;
    return 0;
}


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

int maxtime(int x) {
  x = (x + 9) / 10 * 10;
  return x;
}
int wait(int x) {
  x = maxtime(x) - x;
  return x;
}
int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int ans = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e)
    - max({wait(a), wait(b), wait(c), wait(d), wait(e)});
  cout << ans << endl;
  return 0;
}

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



Measured memory_bytes: 2060
#include<iostream>
#include<iomanip>
#include<vector>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
const int MAX = 0;
const int INF = 100000000;

int main() {
	int N;
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		ans += b - a + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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 <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int digsum(int n,int b) {
    int ret=0;
    while(n) {
        ret+=n%b;
        n/=b;
    }
    return ret;
}
signed main() {
    int n,s;
    cin>>n>>s;
    if(n==s) {
        cout<<n+1<<endl;
        return 0;
    }
    REPF(b,2,sqrt(n)+1) {
        int sum=digsum(n,b);
        if(sum==s) {
            cout<<b<<endl;
            return 0;
        }
    }
    int ans=INF;
    REPF(p,1,sqrt(n)+1) {
        int b=(n-s)/p+1;
        if(b==1 || b==0) continue;
        int sum=digsum(n,b);
        if(sum==s) {
            chmin(ans,b);
        }
    }
    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int n;
  vector<int> r,f;
  cin>>n;
  r.reserve(n);
  f.reserve(n);
  for(i=0;i<n;i++)
    cin>>r[i]>>f[i];
  for(i=0;i<n;i++){
    if(r[i]<6){
      if(f[i]<r[i]){
	for(j=r[i];j>f[i];j--)
	  cout<<j<<" ";
	cout<<j<<endl;
      }else{
	for(j=r[i];j<f[i];j++)
	  cout<<j<<" ";
	cout<<j<<endl;
      }
    }else{
      if(f[i]>r[i]){
	for(j=r[i];j<f[i];j++)
	  cout<<j<<" ";
	cout<<j<<endl;
      }else{
	for(j=r[i];j<10;j++)
	  cout<<j<<" ";
	if(f[i]>5){
	  cout<<"5 4 3 2 1 0 1 2 3 4 5 ";
	  for(j=6;j<f[i];j++)
	    cout<<j<<" ";
	  cout<<j<<endl;
	}else{
	  for(j=5;j>f[i];j--)
	    cout<<j<<" ";
	  cout<<j<<endl;
	}
      }
    }
  }
  return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<long long>>ab(n, vector<long long>(2));
	for (int i = 0; i < n; i++)cin >> ab.at(i).at(0) >> ab.at(i).at(1);
	sort(ab.begin(), ab.end());
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		if (ab.at(i).at(1) <= m) {
			ans += ab.at(i).at(0) * ab.at(i).at(1);
			m -= ab.at(i).at(1);
		}
		else {
			ans += ab.at(i).at(0) * m;
			m -= m;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a < 3200){
        cout << "red" << endl;
        return 0;
    }
    else{
        cout << s << endl;
    }

}

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

int main()
{
    string str;
    cin >> str;
    int max = 0;
    int tmp = 0;

    for(int i = 0; i < str.length(); i++){
        if(str[i] == 'A' || str[i] == 'T' || str[i] == 'G' || str[i] == 'C'){
            tmp++;
        }else{
            if(tmp > max){
                max = tmp;
                tmp = 0;
            }
        }
    }
            if(tmp > max){
                max = tmp;
                tmp = 0;
            }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<algorithm>

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int a[20];
		for(int i=0;i<n;i++)	scanf("%d",a+i);

		int ans=1<<30;
		int sum=accumulate(a,a+n,0);
		for(int i=0;i<(1<<n);i++){
			int psum=0;
			for(int j=0;j<n;j++){
				if(i&(1<<j))	psum+=a[j];
			}
			ans=min(ans,abs(sum-2*psum));
		}

		printf("%d\n",ans);
	}

	return 0;
}

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

int main(){
        int k,n;
        cin >> n >> k;
        int i=0;
        int temp;
        while(true){
                temp=pow(k,i);
                if(temp>n)break;
                else i++;
        }
        cout << i;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int max=-1,maxi;
	for(int i=1;i<=n;i++){
		int temp=i;
		int sum=0;
		while(temp%2==0){
			sum++;
			temp=temp/2;
		}
		if(sum>max){
			max=sum;
			maxi=i;
		}
	}
	cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n)  for(ll i = 0; i < (n); ++i)
#define rep1(i,n)  for(ll i = 1;i <= (n); ++i)
#define pb push_back
#define M 1000000007
unordered_map<ll,ll>mp;

int main()
{
    fastIO
    double d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t)
    cout<<"Yes";
    else
    cout<<"No";
	return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, m, no;
    string judge;
    cin >> n >> m;
    vector<int> problem(n+1, 0);
    vector<int> wa_num(n+1, 0);
    int ac = 0, wa = 0;
    for(int i = 0; i < m; i++) {
        cin >> no >> judge;
        if (judge == "AC") {
            if (problem[no] == 0) {
                wa += wa_num[no];
                problem[no] = 1;
                ac += 1;
            }
        } else if (judge == "WA") {
            wa_num[no] += 1;
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}



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

lr = [[0 for i in range(n+1)] for j in range(n+1)]
#lr = [[int(i) for i in input().split()]for j in range(m)]

st = [0] * (n+1)
ed = [0] * (n+1)

for i in range(m):
    l,r = map(int,input().split())
    lr[l][r] += 1

pq = [[int(i) for i in input().split()]for j in range(q)]

dp = [[0 for i in range(n+1)] for j in range(n+1)]

#print(lr)

for i in range(1,n+1):
    #print(i)
    for j in range(i,n+1):
        #print(i,j)
        dp[i][j] = dp[i][j-1]+lr[i][j]

for i in range(q):
    st = pq[i][0]
    ed = pq[i][1]
    tmp = 0
    for j in range(ed-st+1):
        tmp += dp[st+j][ed]
    print(tmp)
#print(dp)

Measured memory_bytes: 83160
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def fibonacci(N, M):
    RA = RD = 1; RB = RC = 0
    XA = XB = XC = 1; XD = 0
    while N:
        if N & 1:
            RA, RB, RC, RD = (RA*XA + RB*XC) % M, (RA*XB + RB*XD) % M, (RC*XA + RD*XC) % M, (RC*XB + RD*XD) % M
        XA, XB, XC, XD = (XA**2 + XB*XC) % M, XB*(XA + XD) % M, XC*(XA + XD) % M, (XB*XC + XD**2) % M
        N >>= 1
    return RC

def solve():
    MOD = 10**9 + 7
    K = int(readline())
    k0 = (int((1 + 4*K)**.5) - 1) // 2
    if k0**2 + k0 == K:
        k0 -= 1
    kk = k0**2+k0
    if K - kk > k0+1:
        m0 = 2*k0+1
        b = K - kk - (k0+1) - 1
    else:
        m0 = 2*k0
        b = K - kk - 1

    if k0//2+1 > b:
        v = fibonacci(2+2*b, MOD) * fibonacci(m0+2-2*b, MOD) % MOD
    else:
        b1 = k0+1 - b-1
        v = fibonacci(3+2*b1, MOD) * fibonacci(m0+1-2*b1, MOD) % MOD
    write("%d\n" % v)
solve()



Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define lli long long int
#define pb(a) push_back(a)
#define forr(a,n) for(lli i=a;i<n;i++)
#define forrr(j,a,n) for(lli j=a;j<n;j++)
#define all(x) x.begin(),x.end()
#define pi2  1.57079632679489661923

using namespace std;
void print(lli a[],lli n){
forr(0,n){cout<<a[i]<<" ";}
cout<<"\n";
}
lli power(lli x){
lli u=0;
while(x%2==0){
    u++;
    x=x/2;
}
return u;
}

lli powM(lli x,lli y,lli m)
{
    if(m==1){return 0;}
    lli ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
int powm(lli a, lli b) {
	lli res = 1;
	while (b) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
/*
vector <lli> adj[100001];
lli vis[100001]={0};
void dfs(lli a){
    vis[a]=1;
    forr(0,adj[a].size()){
    if(vis[adj[a][i]]){continue;}
    else{
        dfs(adj[a][i]);
    }
    }
}
lli level[100001];
void bfs(lli a){
queue <lli> q;
vis[a]=1;
level[a]=0;
q.push(a);
while(!q.empty()){
    lli p=q.front();
    q.pop();
    forr(0,adj[p].size()){
    if(vis[adj[p][i]]==0){
        level[adj[p][i]]=level[p]+1;
        q.push(adj[p][i]);
        vis[adj[p][i]]=1;
    }
    }

}

}

vector <pair<lli,lli> > dj[100001];
lli dist[100001];
vector<lli> ans[100001];
void dijkstra(lli a){
dist[a]=0;
ans[a].pb(a);
multiset<pair<lli,lli> > s;
s.insert({0,a});
while(s.size()!=0){
    lli x=(*s.begin()).second;
    s.erase(s.begin());
    if(vis[x]){continue;}
    vis[x]=1;
    forr(0,dj[x].size()){
    lli e=dj[x][i].first;
    lli we=dj[x][i].second;
    if(dist[x]+we<dist[e]){
        dist[e]=dist[x]+we;
        ans[e].clear();
        ans[e].pb(x);
        s.insert({dist[e],e});
    }
    }
}

}
*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   cout.tie(0);
   //freopen("outpu.txt","w",stdout);
int t1=1;
//cin>>t1;
lli M =1e9+7;
while(t1--){
lli a,b,c,k;
cin>>a>>b>>c>>k;
while(b<=a && k>0){
    b*=2;
    k--;
}
while(c<=b && k>0){
    c*=2;
    k--;
}
if(c>b && b>a){
    cout<<"Yes\n";
}
else{
    cout<<"No\n";
}
}
     return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (ll)1000000007

int main(void){
    int N, M;
    cin >> N >> M;
    int a[M];
    for(int i=0; i<M; i++){
        cin >> a[i];
    }

    ll ana[N];
    for(int i=0; i<N; i++){
        ana[i] = 1;
    }
    for(int i=0; i<M; i++){
        ana[a[i]-1] = 0;
    }

    ll cost[N];
    cost[0] = ana[0]*1;
    cost[1] = ana[1]*(cost[0] + 1);
    
    for(int i=2; i<N; i++){
        cost[i] = (ana[i-1]*cost[i-1] + ana[i-2]*cost[i-2])%INF;
    }

    cout << ana[N-1]*cost[N-1] << endl;

    return 0;
}

Measured memory_bytes: 2176
K, N = map(int, input().split())
A = list(map(int, input().split()))

sa = [0] * (N)
for i in range(N - 1):
    sa[i] = A[i + 1] - A[i]

sa[-1] = A[0] + abs(K - A[-1])

sa.sort()

print(sum(sa[:N - 1]))

Measured memory_bytes: 26420
#include <bits/stdc++.h>
 
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  long int i,j,a[n],b[n],c[m],d[m],ans,num,min=1000000000;
  for(i=0;i<n;++i)
      scanf("%ld%ld",&a[i],&b[i]);
  
  for(i=0;i<m;++i)
       scanf("%ld%ld",&c[i],&d[i]);
  
  for(i=0;i<n;++i)
  {
     min=1000000000;
    for(j=0;j<m;++j)
    {
      ans=abs(c[j]-a[i])+abs(d[j]-b[i]);
      if(min>ans)
          { min=ans;
             num=j+1;
          }
      
    }
    printf("%ld\n",num);
  }
}

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

int dp[100][100];
int dy[100][100];
int data[10000];

int max(int a, int b);

int main(void)
{
    int i = 0, j, n, tmp, k;

    while (scanf("%d,", &data[i++]) != EOF);
    n = (-2+sqrt(4-4*(1-i)))/2;
    k = 0;
    for (i = 0; i < n; i++) {
        for (j = 0; j <= i; j++) {
            dy[i][j] = data[k++];
        }
    }
    for (i = 0; i < n+1; i++) {
        dy[n][i] = data[k++];
    }
    for (i = n+1; i < n+n+1; i++) {
        for (j = 0; j < n+n+1-i; j++) {
            dy[i][j] = data[k++];
        }
    }


    dp[0][0] = dy[0][0];
    for (i = 0; i < n; i++) {
        for (j = 0; j <= i; j++) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + dy[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + dy[i+1][j+1]);
        }
    }
    dp[n+1][0] = dp[n][0]+dy[n+1][0];
    dp[n+1][n-1] = dp[n][n]+dy[n+1][n-1];
    for (i = 1; i < n; i++) {
        dp[n+1][i] = max(dp[n+1][i], dp[n][i] + dy[n+1][i]);
        dp[n+1][i-1] = max(dp[n+1][i-1], dp[n][i] + dy[n+1][i-1]);
    }
    for (i = n+1; i < n+n+1; i++) {
        for (j = 0; j < n+n+1-i; j++) {
            if (!j) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j] + dy[i+1][j]);
            } else if (j == n+n-i) {
                dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j] + dy[i+1][j-1]);
            } else {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j] + dy[i+1][j]);
                dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j] + dy[i+1][j-1]);
            }
        }
    }
    printf("%d\n",dp[i-1][0]);

    return 0;
}

int max(int a, int b) 
{
    return a<b?b:a;
}

Measured memory_bytes: 692
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;



int main()
{
  // 整数の入力
  ll N;
  cin >> N;
  vector<ll> A(N);
  queue<ll> q;
  for (size_t i = 0; i < N; i++)
  {
      cin >> A[i];
  }
  sort(A.begin(),A.end(),greater<ll>());
  ll ans = 0;
  for(int i = 0 ;i < N;i++){
    if (i == 0){
      q.push(A[i]);
    }else{
      ll a = q.front();
      q.pop();
      ans+= a;
      q.push(A[i]);
      q.push(A[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6440
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut v = vec![0; 100003];
    for &na in &a {
        let na = na + 1;
        v[na - 1] += 1;
        v[na] += 1;
        v[na + 1] += 1;
    }
    let ans = v.iter().max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 3772
from fractions import gcd
from functools import reduce

def solve(A, M):
    A = [x // 2 for x in A]
    g = reduce(gcd, A)
    lcm = 1
    if lcm == 0:
        print(A)
    for c in A:
        j = c // g
        if j % 2 == 0:
            return 0
        k = gcd(lcm, c)
        lcm *= c // k
    return (M // lcm + 1) // 2


def main():
    N, M = map(int, input().split())
    A = map(int, input().split())
    ans = solve(A, M)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 16232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	ll N;
	cin >> N;

	ll k = sqrt(N);
	if (k * k != N) k++;

	ce(k);

	int L = 1;
	int R = k;
	while (L + 1 < R) {
		int H = (L + R) / 2;
		if ((ll)H * k >= N) R = H;
		else L = H;
	}

	ll kari = k * R;

	cosp(0);
	cosp(0);
	cosp(1);
	cosp(k);
	cosp(R);
	co(kari - N);




	Would you please return 0;
}

Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" " , n);
        int[] array = new int[n];
        
        for(int i = 0; i < n; i++){
            array[i] = Integer.parseInt(input[i]);
        }

        insertionSort(array);
    }

    static void printArray(int[] A){
    	StringBuilder sb = new StringBuilder();
        for(int k : A){
            sb.append(k + " ");
        }
        System.out.println(sb.toString().substring(0 , sb.length() - 1));
    }

    static void insertionSort(int[] A){
    	int count=0;
        for(int i=0; i<A.length; i++){
        	int min_i = i;
        	for(int j=i; j<A.length; j++){
        		if(A[j]<A[min_i]){
        			min_i = j;
        		}
        	}
        	if(min_i!=i){
        		int k = A[i];
        		A[i] = A[min_i];
        		A[min_i] = k;
        		count++;
        	}
        }
        printArray(A);
        System.out.println(count);
    }
}



Measured memory_bytes: 24384
import sys
import numpy as np
sys.setrecursionlimit(10 ** 9)

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

M1, D1 = rl()
M2, D2 = rl()
print(1 if M1 != M2 else 0)


Measured memory_bytes: 12396
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#define pi acos(-1)
using namespace std;
double aabs(double x)
{
    if(x<0)return -x;
    return x;
}
int main()
{
    double x[1007],y[1007],z[1007],d1=0,d2=0,d3=0,d4=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>x[i];
    for(int i=1;i<=n;i++)cin>>y[i];
    for(int i=1;i<=n;i++)
    {
        z[i]=aabs(x[i]-y[i]);
        d1+=z[i];
        d2+=z[i]*z[i];
        d3+=z[i]*z[i]*z[i];
        if(z[i]>d4)d4=z[i];
    }
    d2=sqrt(d2);
    d3=pow(d3,1.0/3);
    printf("%.6lf %.6lf %.6lf %.6lf\n",d1,d2,d3,d4);
    return 0;
}



Measured memory_bytes: 3420
s = gets.chomp.split("")

n = s.size
sum = Array.new(n,0)

child = Array.new(2,0)
tar = s[0]
cnt = 0
lastL = 0

for i in 1..n do
    if s[i-1] == tar
        cnt += 1
        child[cnt%2] += 1
    else
        if tar == "R"
            last = i-1
            sum[i-1] += child[0]
            sum[i-2] += child[1]
        else
            sum[last] += child[1]
            sum[last-1] += child[0]            
        end

        tar = s[i-1]
        cnt = 1
        child[0] = 0
        child[1] = 1
    end
end

sum[last] += child[1]
sum[last-1] += child[0]            

for i in 1..n do
    print sum[i-1]," "
end


Measured memory_bytes: 10492
N,M=list(map(int,input().split()))
from math import factorial as f
f_1,f_2=0,0
if N>1:
    f_1=f(N)/(f(2)*f(N-2))
if M>1:
    f_2=f(M)/(f(2)*f(M-2))
print(int(f_1+f_2))

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string S;
    cin >> S;
    auto ret = suffix_array(S);
    ll res = S.size() * (S.size() + 1) / 2;
    auto lcps = lcp_array(S, ret);
    for(auto n : lcps){ res -= n;}
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 15532
/*"-Aria on the Planets-"*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double D;
typedef pair<int,int> Pii;
#define mp(a,b) make_pair(a,b)
#define fir first
#define sec second
inline int min(int _a,int _b){return _a<_b?_a:_b;}
inline int max(int _a,int _b){return _a>_b?_a:_b;}
template<class _T>inline void rd(_T &_a){int _f=0,_ch=getchar();_a=0;while(_ch<'0'||_ch>'9'){if(_ch=='-')_f=1;_ch=getchar();}while(_ch>='0'&&_ch<='9')_a=(_a<<1)+(_a<<3)+_ch-'0',_ch=getchar();if(_f)_a=-_a;}
const int inf=0x3f3f3f3f;
const D eps=1e-8;
int main(){
	//clock_t start=clock();
	//freopen("ttt.in","r",stdin);
	//freopen("ttt.out","w",stdout);
	LL n;int x=0,f=0,a;rd(n);
	while(n){
		a=n%10;
		if(n%10!=9&&n>9)f=1;
		x++;
		n/=10;
	}
	printf("%d",a+x*9-9-f);
	//printf("\n%dms",(int)((D)(clock()-start)/CLOCKS_PER_SEC*1000));
	return 0;
}


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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int main(){
	string s,t;cin>>s>>t;
	int cnt=0;
	rep(i,3){
		if(s[i]==t[i])cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
td=sorted([list(map(int,input().split())) for i in range(n)],reverse=True,key=lambda x:x[1])

ans=0
kl=dict()
for i in range(k):
    ans+=td[i][1]
    if td[i][0] in kl:
        kl[td[i][0]]+=1
    else:
        kl[td[i][0]]=1
l=len(kl)
ans+=(l**2)
ans_=ans
now=k-1
for i in range(k,n):
    if td[i][0] not in kl:
        #最小を求めるのをもっと早く
        while now>=0:
            if kl[td[now][0]]>1:
                mi=td[now]
                kl[mi[0]]-=1
                now-=1
                break
            now-=1
        if now==-1:
            break
        else:
            ans=ans+2*l+1-mi[1]+td[i][1]
            kl[td[i][0]]=1
            ans_=max(ans,ans_)
            l+=1

print(ans_)


Measured memory_bytes: 32084
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5;
int n, diff[2], s[N], dp[N][2], f[N], reach[N][2], mx[N][2];
bool usable[N][2];
void add(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> diff[0] >> diff[1];
	fw (i, 0, n) cin >> s[i];
	//dp[i][2]: j that i -> j will all be decided if we pick s[i] to be in group 1 or group 2
	int ptr[2] = {n - 1, n - 1};
	bw (i, n, 0) {
		fw (j, 0, 2) {
			while (s[ptr[j]] - diff[j] >= s[i]) ptr[j]--;
			reach[i][j] = ptr[j];
//			cout << "reach[" << i << "][" << j << "] = " << reach[i][j] << "\n";
		}
	}
	//If i is decided to be in group j all elements from i + 1 to reach[i][j] would be in the opposite one.
	//For all k from i + 1 to reach[i][j] - 1 we must have reach[k][j ^ 1] = k.
	int mxk[2];
	memset(mxk, -1, sizeof mxk);
	memset(usable, 0, sizeof usable);
	//usable[i][j]: If putting i into group j will be valid or not.
	bw (i, n, 0) {
		fw (j, 0, 2) {
			if (i + 1 <= reach[i][j] - 1) {
				if (mxk[j ^ 1] >= reach[i][j] - 1) usable[i][j] = 1; 
			} else usable[i][j] = 1;
		}
		fw (j, 0, 2) {
			if (reach[i][j] == i) mxk[j] = max(mxk[j], i);
			else mxk[j] = -1;
		}
	}
	//mx[i][j]: The max element that putting i into group j will decide.
	memset(mx, -1, sizeof mx);
	bw (i, n, 0) {
		fw (j, 0, 2) if (usable[i][j]) {
			if (reach[i][j] == i) mx[i][j] = i;
			else mx[i][j] = mx[reach[i][j]][j ^ 1];
//			cout << "mx[" << i << "][" << j << "] = " << mx[i][j] << "\n";
		}
	}
	//f[i]: Answer for the first i elements.
	f[0] = 1;
	fw (i, 0, n) {
		fw (j, 0, 2) if (mx[i][j] != -1) {
			add(f[mx[i][j] + 1], f[i]);
		}
	}
	cout << f[n];
	return 0;
}

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

using namespace std;

int main()
{
	// 入力
	int num, sp;
	cin >> num >> sp;

	uint64_t buf[ 200000 ];

	for( int i=0 ; i<num ; i++ )
	{
		cin >> buf[i];
	}
	
	sort( buf, buf+num, greater<uint64_t>() );

	uint64_t cnt = 0;

	for( int i=sp ; i<num ; i++ )
	{
		cnt += buf[i];
	}



	// 出力
	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var s = Console.ReadLine();
    if(s.Length == 1){
       var n = s;
       if(n == "2"||n == "4"||n =="5"||n == "7"|| n == "9"){
         Console.WriteLine("hon");
       }
       else if(n =="0"||n=="1" || n =="6" || n == "8"){
         Console.WriteLine("pon");
       }
       else {
         Console.WriteLine("bon");
       }
    }
    else if(s.Length == 2){
      char n = s[1];
      if(n == '2'||n == '4'||n =='5'||n == '7'|| n == '9'){
         Console.WriteLine("hon");
       }
       else if(n =='0'||n=='1' || n =='6' || n == '8'){
         Console.WriteLine("pon");
       }
       else {
         Console.WriteLine("bon");
       }
    }else if(s.Length == 3){
        char n = s[2];
      if(n == '2'||n == '4'||n =='5'||n == '7'|| n == '9'){
         Console.WriteLine("hon");
       }
       else if(n =='0'||n=='1' || n =='6' || n == '8'){
         Console.WriteLine("pon");
       }
       else {
         Console.WriteLine("bon");
       }
    }
   
  }
}

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

int main(){
  ll n,m; cin >>n >>m;
  if(2*n>m) cout << m/2 << endl;
  else cout << n+(m-n*2)/4 << endl;
  return 0;
}


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

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;


int N;
Graph G;


vector<int> res;


void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 8960
L = input()
MOD = 10 ** 9 + 7

num = 0
res = 0
n = len(L)
for i in range(n):
    length = n - i - 1
    if L[i] == "1":
        res = (res + pow(2, num, MOD) * pow(3, length, MOD))
        num += 1

res = (res + pow(2, num, MOD)) % MOD
print(res)


Measured memory_bytes: 72972
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

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

int main() {
    string S;
    cin >> S;

    ll count=0,result=0;
    for(auto c : S){
        if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
            count++;
            result = max(result,count);
        }else{
            count=0;
        }
    }

    cout << result << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""

N=int(input())
dp=dict()
dp['a']=[0]*N
dp['b']=[0]*N
dp['c']=[0]*N

a,b,c=input().split()
dp['a'][0]=int(a)
dp['b'][0]=int(b)
dp['c'][0]=int(c)

for i in range(1,N):
    a,b,c=input().split()
    dp['a'][i]=int(a)+max(dp['b'][i-1],dp['c'][i-1])
    dp['b'][i]=int(b)+max(dp['a'][i-1],dp['c'][i-1])
    dp['c'][i]=int(c)+max(dp['a'][i-1],dp['b'][i-1])
    
print(max(dp['a'][-1],dp['b'][-1],dp['c'][-1]))

Measured memory_bytes: 14932
N, K = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)

x = 0
if K > 0
  k = Math.log2(K).floor + 1 # 最大桁数
  cnt = Array.new(k, 0)
  A.each do |a|
    k.times do |i|
      cnt[i] += (a[i] == 0) ? 1 : 0
    end
  end

  (k-1).downto(0) do |i|
    up = 2 ** i
    if cnt[i] > N / 2 && x + up <= K # 桁iの0の数が半分を超えていて、1を使えれば1を使う
      x += up
    end
  end
end

puts A.inject(0) { |sum, a| sum + (x ^ a) }

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

int main()
{
	cin.sync_with_stdio(false);
	string S;
	int val;
	priority_queue<int> pq;
	while (cin >> S, S != "end") {
		if (S == "extract") {
			printf("%d\n", pq.top());
			pq.pop();
		}
		else {
			cin >> val;
			pq.push(val);
		}
	}
	return 0;
}

Measured memory_bytes: 6964
class Node
  attr_accessor :key, :left, :right
  def initialize key
    @key = key
  end

  def inorder
    left.inorder if left
    print ' ', key
    right.inorder if right
  end

  def preorder
    print ' ', key
    left.preorder if left
    right.preorder if right
  end
end

def insert key
  z = Node.new key
  x = $root
  while x
    y = x
    x = z.key < x.key ? x.left : x.right
  end

  unless y
    $root = z
  else
    z.key < y.key ? y.left = z : y.right = z
  end
end

gets.to_i.times {
    command, key = gets.split
    if command == 'insert'
      insert key.to_i
    else
      $root.inorder
      puts
      $root.preorder
      puts
    end
}

Measured memory_bytes: 264212
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int d[15][15][15],sum[15][15];
int main()
{
	cin >>n;
	for (int i=0;i<10;i++)
	{
		d[i][1][i]=1;
		for (int j=1;j<12;j++)
		{
			for (int k=0;k<10;k++)
			{
				if (k) d[i][j+1][k-1]+=d[i][j][k];
				if (k!=9) d[i][j+1][k+1]+=d[i][j][k];
				d[i][j+1][k]+=d[i][j][k];
				sum[j][i]+=d[i][j][k];
			}
		}
	}
	int t=1,b=-1;
	bool ok=1; 
	while (t)
	{
		bool fl=0;
		//cout <<t<<" ############\n";
		for (int i=ok;i<10;i++)
		{
			if (b!=-1 && abs(b-i)>1) continue;
			//cout <<n<<" "<<sum[t][i]<<" ##\n";
			if (n>sum[t][i]) n-=sum[t][i];
			else
			{
				fl=1,t--,ok=0,b=i;
				cout <<i;
				break;
			}
		}
		if (ok) t++;
	} 
	return 0;
} 

Measured memory_bytes: 256