akhauriyash/Code-Regression huggingface dataset:
import numpy as np

S = input()

if S[0] == S[1] and S[2] == S[3]:
    if S[0] == S[2]:
        print('No')
    else:
        print('Yes')
elif S[0] == S[2] and S[1] == S[3]:
    if S[0] == S[1]:
        print('No')
    else:
        print('Yes')
elif S[0] == S[3] and S[1] == S[2]:
    if S[0] == S[1]:
        print('No')
    else:
        print('Yes')
else:
    print('No')

Measured memory_bytes: 21756
# coding: utf-8
# Your code here!


n = [int(input()) for i in range(5)]
    
k = int(input())

ans = 0

for i in range(5):
    for j in range(5)[i+1:]:
        if n[j]-n[i]>k:
            ans+=1
            
if ans == 0:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
from sys import stdin

N, M = map(int, stdin.readline().split())
ab = [list(map(int, stdin.readline().split())) for _ in range(M)]

ab.sort()

inf = 10 ** 9

left = -inf
right = inf

ans = 1

for a, b in ab:
    if left <= a and a < right:
        left = a
        if left < b and b < right:
            right = b
    elif left < b and b < right:
        right = b
    else:
        ans += 1
        left = a
        right = b

if M == 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 27880
use std::io;

fn main() {

    let s = get_input();
    let l: i32 = s.trim().len() as i32;

    for _ in 0..l {
        print!("x");
    }
}
fn get_input() -> String {
    let mut input_str = String::new();
    io::stdin().read_line(&mut input_str)
        .expect("Failed to read line")
        ;
    input_str
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace contest19
{
    class Program
    {
        static void Main(string[] args)
        {
            var read_line_origin = Console.ReadLine();
//            string[] read_line = read_line_origin.Split();
            int n = int.Parse(read_line_origin);

            long ans = 1;

            for (int i = n; i > 0; i--)
            {
                ans *= i;
            }

            
            Console.WriteLine("{0}", ans);
            //            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 5560
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7,MAX=1e6;
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
typedef struct{int SPF[1000001];int Primes[78498];int sz;}Template;
Template P;
static inline int MPow(int a,int b){return b?1l*MPow(1l*a*a%MOD,b>>1)*(b&1?a:1)%MOD:1;}
static inline void ready(void)
{
  *P.SPF=1,*P.Primes=2,P.sz=1;
  rep(i,MAX/2)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;
  rep(i,MAX/2-1)
  {
    int x=2*(i+1)+1;if(P.SPF[x]==x){P.Primes[P.sz++]=x;}
    rep(j,P.sz){if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=MAX)P.SPF[x*P.Primes[j]]=P.Primes[j];else break;}
  }
}
int main(void)
{
  int N=IN(),A=0,factor=0,invsum=0,lcm=1,x=0,y=0,box[78498]={0};ready();
  rep(i,N)
  {
    A=IN();invsum=(invsum+1l*MPow(A,MOD-2))%MOD;
    while(A>1){rep(j,P.sz){x=0;while(A%P.Primes[j]==0){A/=P.Primes[j],x++;if(box[j]<x)box[j]=x;}}}
  }
  rep(i,P.sz){if(box[i])lcm=1l*lcm*MPow(P.Primes[i],box[i])%MOD;}
  return printf("%ld\n",1l*lcm*invsum%MOD),0;
}

Measured memory_bytes: 6192
#include<stdio.h>
int main(void){
  int a;
  scanf("%d",&a);
  int flg=0;
  if(a%10==7){
    flg=1;
  }
  a=a/10;
  if(a%10==7){
    flg=1;
  }
  a=a/10;
  if(a==7){
    flg=1;
  }
  
  if(flg==1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	
    public static void main(String[] args) throws IOException {
    	Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] input;
		int x = s.nextInt();
		out.print(x >= 30 ? "Yes" : "No");
		out.flush();
		out.close();
    }

}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   string a;
   cin>>a;
   ll sum=0;
   for (ll i = 0; i < a.size(); i++)
   {
   
       sum+=(int)(a[i] - '0');
       
   }
   if(sum%9==0)
   {
     cout<<"Yes"<<endl;
   }
   else
   {
      cout<<"No"<<endl;
   }
   
   

   
    
    
    
  }
  

  












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

int main(){

    int N;
    cin>>N;
    vector<int> T(N+1),X(N+1),Y(N+1);
    bool ans=true;
    for(int i=0;i<N;i++){
        cin>>T[i+1]>>X[i+1]>>Y[i+1];
    }
    for(int i=0;i<N;i++){
        int t=T[i+1]-T[i];
            if(abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i])>t||(abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i])-t)%2!=0) ans=false;
        }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using std::cin;
using std::ifstream;
using std::cout;
using std::vector;
using std::min;
using std::max;
using std::string;
using std::map;
using std::cerr;
using std::endl;
using std::sort;
using std::__gcd;
using std::ios_base;

#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
unsigned lcm(int a, int b) { return (a / __gcd(a, b) * b); }
#define fri(i,n) 			for(int i = 0 ; i < n;++i) 
#define jri(j,k,n) 		for(int j = k ; j >= n;j--) 
#define swapnumsxor 	a ^= b; b ^= a; a ^= b
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define inp(i) 				cin >> i 
#define inp2(i,j) 		cin >> i >> j  
#define inp3(i,j,k) 	cin >> i >> j >> k
#define oup(i) 				cout << i << "\n"
#define oup2(i,j) 		cout << i << " "<<j<< "\n"
#define oup3(i,j,k) 	cout << i << " "<< j << " "<<k<< "\n"
#define MOD 1000000007
#define rmdup 				std::sort(str.begin(), str.end());str.erase(std::unique(str.begin(), str.end()), str.end());

typedef long long int lli;
typedef unsigned long long int ulli;
#define pb 		emplace_back
#define mp 		make_pair
#define MAXN 	1000000
#define vi vector<int>
#define vlli vector<lli>
#define vulli vector<ulli>
const unsigned long long int INF = 1e18L + 5;
void max_self( lli &a ,lli b ){
  a = max(a,b);
}
void min_self( lli &a ,lli b ){
  a = min(a,b);
}

int main()
{ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
		// ifstream in("input.txt");
		lli n , W;
    inp2(n,W);
    vi weight(n) ,val(n);
    fri(i,n){
      inp2(weight[i] , val[i]);
    } 
    int sum_val = 0;
    for( int x : val  ) sum_val+= x;
    vlli dp(sum_val +1, INF);
    dp[0] = 0;

    fri(item,n){
      jri( v_a , sum_val - val[item] , 0 ){
        min_self( dp[v_a + val[item]] , dp[v_a] + weight[item] );
      }
    }
    lli ans = 0;
    for(int i = 0; i <= sum_val; ++i) {
        if(dp[i] <= W) {
         
            ans = max(ans, (lli) i); 

        }
    }
    oup(ans);
    return 0;
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector <ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<ll> x(n, 0), y(n, 0);
    for (int i = 1; i <= n; i++) {
        if (i + a[i-1] < n) x[i + a[i-1]]++;
        if (i - a[i-1] >= 0) y[i - a[i-1]]++;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += x[i] * y[i];
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7956
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int n,m;
int dp[100010];
vector<int>G[100010];
int ord[100010],len;
bool vis[100010];
void dfs(int x){
	// cout<<x<<endl;
	for(auto to:G[x])if(!vis[to]){
		vis[to]=1;
		dfs(to);
	}
	ord[++len]=x;
}
int main(){
	cin>>n>>m;
	for(int i=1,x,y;i<=m;i++){
		cin>>x>>y;
		G[x].pb(y);
	}
	for(int i=1;i<=n;i++)if(!vis[i])vis[i]=1,dfs(i);
	reverse(ord+1,ord+len+1);
	// for(int i=1;i<=n;i++)cout<<ord[i]<<' ';
	// puts("");
	for(int i=1;i<=n;i++){
		int x=ord[i];
		for(auto y:G[x]){
			dp[y]=max(dp[y],dp[x]+1);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7936
#include<iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  int count = 0;
  for(int i = 0; i<s.size(); i++){
    if(s[i]=='+'){
      count++;
    }
    else{
      count--;
    }
  }
  cout<<count<<endl;
  return 0;
}

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll MOD = 1000000007;
  ll n, a, b;
  cin >> n >> a >> b;
  ll cnt = n;
  ll n2 = 1;
  for(int i = n; i > 0; i -= 30){
    if(i >= 30){
      n2 *= 1073741824;
      n2 %= MOD;
    }
    else{
      rep(j,i){
        n2 *= 2;
        n2 %= MOD;
      }
    }
  }
  ll nca = 1, ncb = 1;
  rep(i,a){
    nca *= n-i;
    nca %= MOD;
  }
  rep(i,a){
    nca = nca * modinv(a-i,MOD)%MOD;
    nca %= MOD;
  }
  nca += MOD;
  nca %= MOD;
  rep(i,b){
    ncb *= n-i;
    ncb %= MOD;
  }
  rep(i,b){
    ncb = ncb * modinv(b-i,MOD)%MOD;
    ncb %= MOD;
  }
  ncb += MOD;
  ncb %= MOD;
  ll ans = n2 - nca - ncb + MOD*2 -1;
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3660
# AGC024A - Fairness
def main():
    # a - b repeats: a - b (when even), -a + b (odd)
    a, b, c, k = tuple(map(int, input().rstrip().split()))
    ans = a - b if k % 2 == 0 else -a + b
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
	int n; cin>>n;
	int a[100004];
	for(int i = 0;i<n;i++)	cin>>a[i];
	int cur = a[0];
	for(int i = 1;i<n;i++)
		if(cur-1 <= a[i]){
			cur = max(cur, a[i]);
			continue;
		}
		else{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
N,K=map(int,input().split())
d = input().split()
while True:
  cand = N
  candstring = str(cand)
  ng = False
  for chr in candstring:
    if chr in d:
      ng = True
      break
  if ng:
    N+=1
  else:
    print(cand)
    break

Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j, k;
	char s[302][302];
	for (i = 0; i < n; i++)
		scanf("%s", s[i]);
	int v[302][302];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			v[i][j] = 0;
			for (k = 0; k < n; k++)
				if (s[(i + k) % n][j] != s[i][(j + k) % n])
					v[i][j] = 1;
		}
	}
	int ans = 0;
	int count;
	for (i = 0; i < n; i++)
	{
		count = 0;
		for (k = 0; k < n; k++)
			count += v[k][(i + k) % n];
		if (count == 0)
			ans += n;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int num = str.length();
		boolean isWhite[] = new boolean[num];
		for(int i = 0; i < num; i ++) {
			isWhite[i] = str.charAt(i) == '1';
		}
		int min = 100100;
		for(int i = 0; i < 2; i ++) {
			int count = 0;
			for(int j = 0; j < num; j ++) {
				count += (j + i) % 2 == 1 != isWhite[j] ? 1 : 0;
			}
			min = Math.min(min, count);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 27572
//https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_b
//B - Touitsu
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
    ll N; cin>>N;
    string A,B,C; cin>>A>>B>>C;
    ll ans=0;
    FOR(i,0,N){
        auto c0=A.at(i);
        auto c1=B.at(i);
        auto c2=C.at(i);
        if(c0==c1&&c1==c2){
        }else if(c0!=c1&&c0!=c2&&c1!=c2){
            ans+=2;
        }else{
            ans+=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007
 #define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    vector<int> b;
    for(int i=0;i<n;i++){
        if(i%2!=0){
            b.insert(b.begin(),a[i]);
        }
        else{
            b.push_back(a[i]);
        }
    }
    if(n%2==0){
    rep(i,n){
        cout<<b[i]<<" ";
    }
    }
    else{
        for(int i=n-1;i>=0;i--){
            cout<<b[i]<<" ";
        }
    }
    cout<<endl;
}

Measured memory_bytes: 3828
while True :
    x,y=input().split()
    if int(x)==0 and int(y)==0 : break
    i=1
    while i<=int(x) :
        k=1
        while k<=int(y) : 
            if i==1 or i==int(x) or k==1 or k==int(y) : print("#",end="")
            else : print(".",end="")
            k=k+1
        print("")
        i=i+1
    print("")


Measured memory_bytes: 7012
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  a = A[i] - 1
  ans += B[a]
  if i > 0 and A[i] - A[i-1] == 1:
    ans += C[a-1]
print(ans)

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    vector<int> T(N);
    for(int i=0;i<N;i++)cin>>T[i];
    int M; cin>>M;
    vector<pair<int, int>> px(M);
    for(int i=0;i<M;i++){
        cin>>px[i].first>>px[i].second;
        px[i].first--;
    }

    int sum = accumulate(T.begin(), T.end(), 0);
    for(int i = 0; i < M; i++)
    {
        cout<<sum-T[px[i].first]+px[i].second<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    int n;
    while (cin >> n && n) {
        int table[21][21] = {0};
        rep(i, n) {
            int x, y; cin >> x >> y;
            table[x][y] = 1;
        }
        int m; cin >> m;
        int nx = 10, ny = 10;
        int c = 0;
        rep(i, m) {
            char d; int l; cin >> d >> l;
            string dir = "EWSN";
            int key = 0;
            rep(j, dir.size()) if (dir[j] == d) key = j;
            while (l--) {
                nx += dx[key];
                ny += dy[key];
                if (table[nx][ny] == 1) {c++; table[nx][ny]--;}
            }
        }
        if (c == n) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;
  vl x(N);
  rep(i, N) cin >> x[i];

  ll ans = 0;
  rep(i, N) ans += 2 * min(x[i], K - x[i]);

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())

abs_list = list()
sum_score = 0

for index in range(N):
    i = index + 1
    score = L + i - 1

    abs_list.append(abs(score))
    sum_score += score

low = abs_list.index(min(abs_list))

print(sum_score - (L + (low + 1) - 1))


Measured memory_bytes: 2940
n = int(input())
A = list(map(int, input().split()))
i=1
print(" ".join(list(map(str, A))))
while i < n:
    v = A[i]
    j = i-1
    while j >= 0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    print(" ".join(list(map(str,A))))
    i+=1



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

int main() {
	long long N, D[50], ANS = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> D[i];
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) ANS += D[i] * D[j];
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
h, w = gets.to_s.split.map{|t|t.to_i}

c = Array.new(10){ gets.to_s.split.map{|t|t.to_i} }.concat( [0] * 10 )
a = Array.new(h){ gets.to_s.split.map{|t|t.to_i} }.flatten
# a.default = 0

10.times do |k|
  10.times do |i|
    10.times do |j|
      c[i][j] = c[i][k] + c[k][j] if c[i][j] > c[i][k] + c[k][j]
    end
  end
end

ans = 0
a.each{|k| ans += c[k][1] }

puts ans

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

using namespace std;

// when range [l, r), has property notP~P, want first P.
// when return r, means not found.
template <typename T>
T bs_first(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = (l+r)/2;
        if (f(mid)) {
            r = mid;
        }else {
            l = mid + 1;
        }
    }
    return r;
}
using ll=long long;

void solve() {
    int n, X;
    cin >> n >> X;
    vector<int> b(n);
    vector<int> l(n);
    vector<int> r(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i] >> l[i] >> r[i];
    }
    ll B = 0;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        B += 1ll*l[i]*b[i];
        a[i] = 1ll*l[i]*b[i] + 1ll*(X-b[i])*r[i];
    }
    vector<int> id(n);
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), [&](int x, int y){
            return a[x] > a[y];
            });
    vector<long long> cum(n);
    ll tmp = 0;
    for (int i = 0; i < n; i++) {
        tmp += a[id[i]];
        cum[i] = tmp;
    }
    ll res = bs_first<ll>(0, 1ll*n*X+1, [&](ll k){
            int q = k/X, rem = k%X;
            if (rem == 0) return cum[q-1] >= B;
            ll res = 0;
            for (int i = 0; i < n; i++) {
                int j = id[i];
                ll tmp = 0;
                tmp += 1ll*l[j]*min(rem, b[j]) + 1ll*r[j]*max(0, rem-b[j]);
                if (q) {
                    if (i < q) {
                        tmp += cum[q] - a[j];
                    } else {
                        tmp += cum[q-1];
                    }
                }
                res = max(res, tmp);
            }
            return res >= B;
            });
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 3456
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int X, t;
  cin >> X >> t;
  if (X-t > 0) cout << X-t << endl;
  else cout << 0 << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

const ll mod = 1000000007LL;
const int limit = 10000;

bool ok[101][limit + 10];
ll num[101][limit + 10];
ll dp[101][limit + 10];

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

	num[n][0] = 1LL;

	rrep(i, n) {
		rep(j, limit + 1) {
			if (num[i + 1][j] == 0) continue;
			rep(a, k + 1) {
				if (i + 1 < a) {
					num[i][j] = (num[i][j] + num[i + 1][j]) % mod;
					ll cur = (dp[i + 1][j] + 1LL * num[i + 1][j] * (a + j)) % mod;
					dp[i][j] = (dp[i][j] + cur) % mod;
				} else {
					const int add = (a + j) / (i + 1);
					num[i][j + add] = (num[i][j + add] + num[i + 1][j]) % mod;
					ll cur = (dp[i + 1][j] + 1LL * num[i + 1][j] * ((a + j) % (i + 1))) % mod;
					dp[i][j + add] = (dp[i][j + add] + cur) % mod;
				}
			}
		}
	}

	ll ans = 0LL;
	rep(i, limit + 1) ans = (ans + dp[0][i]) % mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14720
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

string s;
int x;

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt*sign;
}
inline int getnum(int pos){
	int rt=0;
	rep(i,pos,pos+2)rt=(rt<<3)+(rt<<1)+(s[i]&15);
	return rt;
}
inline int mn(int x,int y){return x<y?x:y;}
int main(){
	cin>>s;
	int minn=inf;
	rep(i,0,(int)s.length()-3)x=getnum(i),minn=mn(minn,abs(x-753));
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> num(1001);
    int x, ans;  cin >> x;
    int n = 32;
    num[1] = 1;
    FOR(i, 2, 33) {
      int tmp = i * i;
      while (tmp <= 1000) {
        num[tmp] = 1;
        tmp *= i;
      }
    }
    for (int i = x; i > 0; --i) {
      if (num[i]) {
        ans = i;
        break;
      }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;

signed main() {
	int n;
	cin >> n;
	for (int i = 0; ; i++) {
		if (pow(2, i) - 1 > n) {
			cout << i - 1  << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3276
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] A = new int[M];
    int[] B = new int[M];
    for (int i = 0; i < M; i++) {
      // 0 origin
      A[i] = sc.nextInt()-1;
      B[i] = sc.nextInt()-1;
    }
    
    // union-find
    int[] par = new int[N];
    for (int i = 0; i < N; i++) {
      par[i] = i;
    }
    int[] size = new int[N];
    Arrays.fill(size, 1);
    
    long[] ans = new long[M];
    ans[M-1] = (long) N*(N-1)/2;
    for (int i = M-2; i >= 0; i--) {
      if (root(par, A[i+1]) == root(par, B[i+1])) {
        ans[i] = ans[i+1];
      } else {
        ans[i] = ans[i+1] - (long)size[root(par,A[i+1])]*size[root(par,B[i+1])];
        unite(par, size, A[i+1], B[i+1]);
      }
    }

    for (int i = 0; i < M; i++) {
      System.out.println(ans[i]);
    }
  }
  
  private static int root(int[] par, int x) {
    if (par[x] == x) {
      return x;
    }
    par[x] = root(par, par[x]);
    return par[x];
  }
  
  private static void unite(int[] par, int[] size, int x, int y) {
    x = root(par, x);
    y = root(par, y);
    if (x == y) {
      return;
    }
    par[x] = y;
    size[y] += size[x];
  }
}

Measured memory_bytes: 97476
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int N = (int)(2e6) + 7;

int n, a[N], p[N];
int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return y ? gcd(y, x % y) : x;
}

int main() {

    // freopen("in.in", "r", stdin);
    scanf("%d", &n);
    int g = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        g = gcd(a[i], g);
    }
    for (int i = 1; i <= n; ++i) {
        int t = a[i];
        for (int j = 2; 1LL * j * j <= t; ++j) {
            if (t % j) continue;
            ++p[j];
            while (t % j == 0) t /= j;
        }
        if (t > 1) {
            ++p[t];
        }
    }
    int flg = 0;
    for (int i = 2; i <= (int)(1e6); ++i) {
        if (p[i] > 1) {
            flg = 1;
            break;
        }
    }
    if (!flg) puts("pairwise coprime");
    else if (g == 1) puts("setwise coprime");
    else puts("not coprime");

    return 0;
}

Measured memory_bytes: 11408
#include <iostream>
#include <vector>
using namespace  std;
const int NIL = -1;

void fnMaxHeapifyUp(vector<int>& rvnPrtyHeap, int nx)
{
  int nParnt = nx / 2;
  int nLrge = nx;

  if (nParnt > 0  &&
      rvnPrtyHeap[nParnt] < rvnPrtyHeap[nLrge])
  {
    swap(rvnPrtyHeap[nParnt], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyUp(rvnPrtyHeap, nParnt);
  }
}

void fnMaxHeapifyDown(vector<int>& rvnPrtyHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nRigt])
    nLrge = nRigt;

  swap(rvnPrtyHeap[nx], rvnPrtyHeap[nLrge]);
  if (nx != nLrge)
    fnMaxHeapifyDown(rvnPrtyHeap, nLrge);
}

void fnPriorityQueue(vector<int>& rvnPrtyHeap)
{
  rvnPrtyHeap.push_back(NIL);
  string sCmd;
  while (cin >> sCmd && sCmd != "end")
  {
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      rvnPrtyHeap.push_back(nNo);
      int nx = rvnPrtyHeap.size() - 1;
      fnMaxHeapifyUp(rvnPrtyHeap, nx);
    }
    else if (sCmd[0] == 'e')
    {
      if (rvnPrtyHeap[1] != NIL)
        cout << rvnPrtyHeap[1] << endl;

      rvnPrtyHeap[1] = NIL;
      fnMaxHeapifyDown(rvnPrtyHeap, 1);
    }
    else;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPrtyHeap; 

  fnPriorityQueue(vnPrtyHeap);
  return 0;
}

Measured memory_bytes: 11136
while True:
    try:
        a,b,c,d,e,f = list(map(float, input().split()))
    except EOFError:
        break
    print("{0:.3f} {1:.3f}".format((c*e-b*f)/(a*e-b*d)+0., (a*f-c*d)/(a*e-b*d)+0.))

Measured memory_bytes: 7344
#include<stdio.h>
#define LEN 200001
int main() {
  char s[LEN], t[LEN];
  int i, count = 0;
  scanf("%s %s", &s, &t);
  for (i = 0; i < LEN && s[i]; i++) {
    if (s[i] != t[i]) {
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 2064
#pragma GCC optimize(2)
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#define lowbit(n) n & (-n)
#define ls x<<1
#define rs x<<1|1
#define clc(a, b) memset(a, b, sizeof(a))
#define Buff ios::sync_with_stdio(false)
#define rush() int Case = 0; int T; scanf("%d", &T);  while(T--)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define per(i, a, b) for(int i = a; i >= b; i --)
#define reps(i, a, b) for(int i = a; b; i ++)
#define read(a) scanf("%d", &a)
#define readd(a) scanf("%lf", &a)
#define readl(a) scanf("%lld", &a)
#define readc(a) scanf("%c", &a)
#define reads(a) scanf("%s", a)
#define sqr(x) x*x
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>PII;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int N = 1e6+7;
string t = {"ACL"};
int main()
{
    int k;
    cin >> k;
    rep(i, 0, k-1)  cout << t;
    puts("");
    return 0;
}


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

typedef long long ll;

const int N = 1e5 + 5;
int n;
int Arr[N];
int L[N][2], R[N][2];
ll ans;
vector <int> vec1, vec2, add;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> Arr[i];

	for (int i = 0; i < n; i++) {
		L[i][0] = L[i][1] = -1;

		while (vec2.size() && Arr[vec2.back()] < Arr[i])
			vec2.pop_back();
		if (vec2.size())
			L[i][1] = max(L[i][1], vec2.back());


		while (vec1.size() && Arr[vec1.back()] < Arr[i]) {
			add.push_back(vec1.back());
			vec1.pop_back();
		}

		while (add.size()) {
			while (vec2.size() && Arr[vec2.back()] < Arr[add.back()])
				vec2.pop_back();

			vec2.push_back(add.back());
			add.pop_back();
		}

		if (vec1.size()) {
			L[i][0] = vec1.back();
			if (1 < vec1.size())
				L[i][1] = max(L[i][1], vec1[vec1.size() - 2]);
		}
		vec1.push_back(i);
	}

	// for (int i = 0; i < n; i++)
	// 	cout << L[i][0] << " " << L[i][1] << "\n";
	vec1.clear();
	vec2.clear();
	add.clear();

	for (int i = n - 1; ~i; i--) {
		R[i][0] = R[i][1] = -1;

		while (vec2.size() && Arr[vec2.back()] < Arr[i])
			vec2.pop_back();
		if (vec2.size())
			R[i][1] = (R[i][1] == -1? vec2.back(): min(R[i][1], vec2.back()));


		while (vec1.size() && Arr[vec1.back()] < Arr[i]) {
			add.push_back(vec1.back());
			vec1.pop_back();
		}

		while (add.size()) {
			while (vec2.size() && Arr[vec2.back()] < Arr[add.back()])
				vec2.pop_back();

			vec2.push_back(add.back());
			add.pop_back();
		}

		if (vec1.size()) {
			R[i][0] = vec1.back();
			if (1 < vec1.size())
				R[i][1] = (R[i][1] == -1? vec1[vec1.size() - 2]: min(R[i][1], vec1[vec1.size() - 2]));
		}
		vec1.push_back(i);
	}

	for (int i = 0; i < n; i++) {
		ll l, r;
		if (L[i][0] != -1) {
			l = L[i][1] + 1;
			r = R[i][0] - 1;
			if (R[i][0] == -1)
				r = n - 1;

			ans += (L[i][0] - l + 1) * (r - i + 1) * Arr[i];
		}
		if (R[i][0] != -1) {
			l = L[i][0] + 1;
			r = R[i][1] - 1;
			if (R[i][1] == -1)
				r = n - 1;

			ans += (i - l + 1) * (r - R[i][0] + 1) * Arr[i];
		}
	}


	// for (int i = 0; i < n; i++) {
	// 	vector <int> vv;
	// 	vv.push_back(Arr[i]);
	// 	for (int j = i + 1; j < n; j++) {
	// 		vv.push_back(Arr[j]);
	// 		sort(vv.begin(), vv.end());
	// 		ans -= vv[vv.size() - 2];
	// 	}
	// }
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 5600
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
point = 0
s.sort() #logN
t.sort() #logM
l = list(set(s))
for i in l:
    tmp = s.count(i) - t.count(i) #N+M
    point = max(point,tmp)
#N(N+M)<=10**5
print(point)



Measured memory_bytes: 3060
import math

tax8 =0.08
tax10=0.1
# price = org * (1 + tax)
# org * tax = (price - org) = X
# org = X / tax

A,B = map(int, raw_input().split())

org_a = math.ceil(A / tax8)
org_b = math.ceil(B / tax10)

#print org_a, org_b

#print math.floor(org_a * tax8),  math.floor(org_a * tax10)
#print math.floor(org_b * tax8),  math.floor(org_b * tax10)

if math.floor(org_a * tax8) == A and  math.floor(org_a * tax10) == B:
    print int(org_a)
elif math.floor(org_b * tax8) == A and math.floor(org_b * tax10) == B:
    print int(org_b)
else:
    print -1



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

#define int long long

using namespace std;

#ifdef LOCAL 
#include "/media/brayand/BrayanD/debugger.h"
#else
template<typename... Args>
void db(Args... args){}
#endif

int qpow(int a, int b, int mod)
{
	int res = 1;
	while(b)
	{
		if(b&1)res = res*a%mod;
		a = a*a%mod;
		b /= 2;
	}
	return res;
}

int f(int x)
{
	int cont = 0;
	while(x)
	{
		cont++;
		x = x%__builtin_popcount(x);
	}
	return cont;
}

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

    int N;
    cin >> N;

    string cad;
    cin >> cad;

    int cont = 0;

    reverse(cad.begin(),cad.end());

    vector<int> res;

    for(int i = 0 ; i < N ; i++)
    {
    	if(cad[i] == '1')cont++;
    }

    int minus1 = 0, plus1 = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	if(cad[i] == '1')
    	{
    		if(cont-1 > 0)
    		{
    			minus1 = (minus1 + qpow(2,i,cont-1))%(cont-1);
    		}
    		if(cont+1 > 0)
    		{
    			plus1 = (plus1 + qpow(2,i,cont+1))%(cont+1);
    		}
    	}
    }

   	for(int i = 0 ; i < N ; i++)
   	{
   		if(cad[i] == '1' && cont-1 == 0)
   		{
   			res.push_back(-1);
   			continue;
   		}
   		if(cad[i] == '1')
   		{
   			int temp = (minus1 + (cont-1) - qpow(2,i,cont-1))%(cont-1);
   			res.push_back(f(temp));
   		}
   		else
   		{
   			int temp = (plus1 + qpow(2,i,cont+1))%(cont+1);
   			res.push_back(f(temp));
   		}
   	}

   	reverse(res.begin(),res.end());

   	for(auto x : res)
   	{
   		cout << x+1 << '\n';
   	}

    return 0;
}

Measured memory_bytes: 5512
#include<bits/stdc++.h>
#define ll long long
const int N = 1e5+1e5;
ll sum=0;
ll a[N],b[N];
int h,t;
int n;ll out;
int main(){
//	freopen("out.txt","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%lld",&a[i]);
	std::sort(a+1,a+1+n);
	
	int h=1,t=n;
	for(int i=1;i<=n;++i){
		if(!(i&1)) b[i]=a[t--];
		else b[i]=a[h++];
	}
	b[n+1]=a[1];
	ll ans=1e18;
	for(int i=1;i<=n;++i){
		sum+=1ll*abs(1ll*b[i]-b[i+1]);
		ans=std::min(ans,1ll*abs(1ll*b[i]-b[i+1]));
	}
	out=sum-ans;
	
	h=1,t=n;
	for(int i=1;i<=n;++i){
		if(i&1) b[i]=a[t--];
		else b[i]=a[h++];
	}
	b[n+1]=a[n];
	ans=1e18;sum=0;
	for(int i=1;i<=n;++i){
		sum+=1ll*abs(1ll*b[i]-b[i+1]);
		ans=std::min(ans,1ll*abs(1ll*b[i]-b[i+1]));
	}
	out=std::max(out,sum-ans);
	printf("%lld",out);
	return 0;
} 

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

ll keta(ll n) {
    ll res = 0;
    ll p = 1;
    while(n >= p) {
        p *= 10;
        res++;
    }
    return res;
}

int gcd(int p, int q) {
    while(q != 0) {
        int r = p % q;
        p = q;
        q = r;
    }
    return p;
}
int main() {
    string s;
    cin >> s;
    if(s == "ARC")
        cout << "ABC " << endl;
    else
        cout<< "ARC" << endl;
}

Measured memory_bytes: 3568
s1 = input()
s2 = input()

def splitter(type,input):
    return list(map(lambda x:type(x),input.split()))


ss1 = splitter(int,s1)

N = ss1[0]
K = ss1[1]
S = s2

d = {"M":0,"R":1,"L":-1}
def h(str):
    happy = 0

    a = "M" + str + "M"
    for i in range(len(a)):
        happy += (1 if (a[i] == a[i+d[a[i]]]) else 0)
    happy -= 2
    return happy

h0 = h(S)
print(min(h0+2*K,N-1))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

int main() {
    fastio;
    string s;
    cin >> s;
    int sum = 0;
    for (auto ch : s) {
        if (ch == '+')
            sum++;
        else
            sum--;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int X,Y,Z;
int V[4];
P mass[51];
double dp[51][5001];

int main(){
  while(cin >> X >> Y >> Z , X){
    for(int i=0;i<X;i++) cin >> V[i];
    for(int i=0;i<=Y;i++){
      mass[i] = P(0,0);
    }
    for(int i=0;i<Z;i++){
      int N,E,A;
      cin >> N >> E >> A;
      mass[N] = P(E,A);
    }
    for(int i=0;i<51;i++){
      for(int j=0;j<5001;j++){
	dp[i][j] = 0.0;
      }
    }
    dp[0][0] = 1.0;
    int limit = 0;
    for(int i=0;i<Y;i++){
      limit += 100;
      for(int j=0;j<=limit;j++){
	if(dp[i][j]){
	  for(int k=0;k<X;k++){
	    int next_p=min(i+V[k],Y),next_m=j;
	    if(mass[next_p].first == 1){
	      next_p = min(next_p+mass[next_p].second,Y);
	    } else if(mass[next_p].first == 2){
	      next_m += mass[next_p].second;
	    } else if(mass[next_p].first == 3){
	      next_m = max(0,next_m-mass[next_p].second);
	    }
	    dp[next_p][next_m] += dp[i][j] / (double)X;
	  }
	}
      }
    }
    double ans = 0.0;
    for(int i=0;i<5001;i++){
      ans += dp[Y][i]*i;
    }
    cout << (int)ans << endl;
  }
}

Measured memory_bytes: 5060
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String t=bf.readLine();
		int n,m,l;
		String[] wd = t.split(" ");
		l=wd.length;
		int[][] p = new int[l][2];
		for(int i=0;i<l;i++){p[i][0]=1;p[i][1]=wd[i].length();}
		for(int i=0;i<l;i++)for(int j=i+1;j<l;j++)	if(wd[j].equals(wd[i]))p[j][0]++;
		n=m=0;
		for(int i=0;i<l;i++){if(p[n][0]<p[i][0])n=i;if(p[m][1]<p[i][1])m=i;}
		System.out.println(wd[n]+" "+wd[m]);
	}
}

Measured memory_bytes: 9368
#include <iostream>
#include <stdio.h>
using namespace std;
long long n=1,m=1,r=1,p;
int main()
{
    int a;
    cin>>a;
    if(a==1)
    {
        printf("0");
    }
    else{
    for(int i=0; i<a; i++)
    {
        n=n*10;
        m=m*9;
        r=r*8;
        if(n>=1000000007)
        {
            n=(long long)n%1000000007;
        }
        if(m>=1000000007)
        {
            m = (long long)m%1000000007;
        }
        if(r>=1000000007)
        {
            r = (long long)r%1000000007;
        }
    }
    p = (long long)(n-2*m+r);
    if(p<0)
    {
        if((p+1000000007)<0)
        {
            cout<<(p+2000000014);
        }
        else{
            cout<<(p+1000000007);
        }
    }
    else{
        cout<<p;
    }
    }
    return 0;
}


Measured memory_bytes: 3632
N=int(input())
A=list(map(int,input().split()))
ans=0
max_ans=0
for i in range(0,N-1):
  if A[i]>=A[i+1]:
    ans+=1
  else:
    ans=0
  if max_ans<ans:
    max_ans=ans
print(max_ans)

Measured memory_bytes: 14224
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int d = stdIn.nextInt();
		int n = stdIn.nextInt();
		
		if(n==100) {
			n =101;
		}
		
		if(d==0) {
			System.out.println(n);
		}
		else if(d==1){
			System.out.println(100*n);
		}else {
			System.out.println(10000*n);
		}
		
		
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve()
{
    ll n, y;
    cin >> n >> y;

    for(ll i = 0; i <= n; i++){
        for(ll j = 0; j <= n; j++){
            ll k = (n-i-j);
            if(k < 0) continue;
            if(i*10000 + j*5000 + k*1000 == y) {
                cout << i << "  " << j << " " << k << endl; return;
            }
        }
    }
    cout << "-1 -1 -1\n";
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  int n;
  while(cin>>n,n){
    int ans=0;
    rep(i,n){
      int x,y,h,w;
      cin>>x>>y>>h>>w;
      x+=y+h;
      if(x<=60 && w<=2)ans+=600;
      else if(x<=80 && w<=5)ans+=800;
      else if(x<=100 && w<=10)ans+=1000;
      else if(x<=120 && w<=15)ans+=1200;
      else if(x<=140 && w<=20)ans+=1400;
      else if(x<=160 && w<=25)ans+=1600;
    }
    cout<<ans<<endl;
  }
}

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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N; cin >> N;
    int M;
    if(N % 2 == 0) M = N;
    else M = N-1;
    cout << N*(N-1)/2 - M/2 << endl;
    int p[M+1] = {};
    for(int i = 1; i <= M; i++) p[i] = M-i+1;
    for(int i = 1; i <= M-1; i++){
        for(int j = i+1; j <= M; j++){
            if(j != p[i]) cout << i << " " << j << endl;
        }
    }
    if(N % 2 == 1)
        for(int i = 1; i <= M; i++){
            cout << i << " " << N << endl;
        }
    return 0;
}

void solve(){}

Measured memory_bytes: 256
X = int(input())
n = 1
ans = 0
x = int(X ** 0.5)
for i in range(1,x+1):
    for j in range(2,x+1):
        if i ** j > X:
            break
        ans = max(ans, i ** j)
if X == 1:
  ans = 1
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long i64;
typedef long double ld;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)

int H, N, P, M, K;

vector<int> stick(505, -1);

vector<vector<ld>> dp(505, vector<ld>(101, 0));

int main() {
  cin >> H >> N >> P >> M >> K;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    stick[a] = b;
  }


  dp[K][P] = 1;

  for (int i = H; i >= 1; i--) {
    if (stick[i] != -1) {
      vector<vector<ld>> next(505,vector<ld>(101,0));
      rep(j, 1, N) rep(k, 0, K) {
        int st = stick[i];
        if (st == j) next[k][j + 1] += dp[k][j];
        else if (st + 1 == j)
          next[k][j - 1] += dp[k][j];
        else
          next[k][j] += dp[k][j];
      }
      swap(dp,next);
    } else {
      vector<vector<ld>> next(505,vector<ld>(101,0));
      rep(j,1,N) rep(k,0,K){
          next[k][j] += dp[k][j];
      }
      rep(j, 1, N) rep(k, 0, K) rep(st, 1, N - 1) {
        if (st == j) next[k][j + 1] += dp[k + 1][j];
        else if (st + 1 == j)
          next[k][j - 1] += dp[k + 1][j];
        else
          next[k][j] += dp[k + 1][j];
      }
      swap(dp,next);
    }
  }

  ld result = 0;
  ld sum = 0;
  for (int i = 1; i <= N; i++) {
    sum += dp[0][i];
    result = max(result, dp[0][i]);
  }


  cout << fixed << setprecision(10) << result / sum << endl;

  return 0;
}



Measured memory_bytes: 4500