akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		final char EAST = 'E';
		final char WEST = 'W';

		int left = 0;	//have to change left;
		int right = 0;	//hava to change right

		int permMax = scan.nextInt();
		String perm = scan.next();

		int min = permMax;

		//count right EAST from alldata
		for(char direction : perm.toCharArray()){
			//change EAST for right
			if(direction == EAST){
				right++;
			}
		}

		//check have to change times for leader
		for(char direction : perm.toCharArray()){
			
			//for right
			if(direction == EAST){
				right--;
			}
		
			//save mincount
			if(min > right + left){
				min = right + left;
			}	

			//for left
			if(direction == WEST){
				left++;
			}
		}

		System.out.println(min);
	}
}


Measured memory_bytes: 30768
fn main() {
        let n = readln();
        let mut c:f64= 100000.0;

        for _i in 0..n {
            c=c+c*0.05;
            if c%1000.0!=0.0{
                c=(((c/1000.0) as i32) as f64)*1000.0+1000.0;
            }
        }
        println!("{:.0}",c);
}
     
    // --- template ---
    #[allow(unused_imports)]
    use std::cmp::{max, min};
    #[allow(unused_imports)]
    use std::collections::{HashMap, HashSet, VecDeque};
     
    pub trait FromLn {
        fn fromln(s: &str) -> Self;
    }
    pub fn readln<T: FromLn>() -> T {
        let mut buf = String::new();
        let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
        T::fromln(buf.trim())
    }
    pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
        let mut vs = vec![];
        for _ in 0..n {
            vs.push(readln());
        }
        vs
    }
    macro_rules! fromln_primitives {
        ($($t:ty),*) => { $(
            impl FromLn for $t {
                fn fromln(s: &str) -> $t {
                    s.parse().unwrap()
                }
            }
        )* }
    }
    fromln_primitives!(
        String,
        bool,
        f32,
        f64,
        isize,
        i8,
        i16,
        i32,
        i64,
        usize,
        u8,
        u16,
        u32,
        u64
    );
    impl<T> FromLn for Vec<T>
    where
        T: FromLn,
    {
        fn fromln(s: &str) -> Vec<T> {
            s.split_whitespace().map(T::fromln).collect()
        }
    }
    impl FromLn for Vec<char> {
        fn fromln(s: &str) -> Vec<char> {
            s.chars().collect()
        }
    }
    macro_rules! fromln_tuple {
        ($($t:ident),*) => {
            impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
                fn fromln(s: &str) -> ($($t),*) {
                    let mut it = s.split_whitespace();
                    let t = ($($t::fromln(it.next().unwrap())),*);
                    assert_eq!(it.next(), None);
                    t
                }
            }
        }
    }
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);




Measured memory_bytes: 5132
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int imos[30][100001];
int main(void){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--,c--;
        imos[c][a]++;
        imos[c][b]--;
    }
    
    for(int i=0;i<m;i++){
        for(int j=0;j<1e5-1;j++){
            imos[i][j+1]+=imos[i][j];
            //if(imos[i][j])imos[i][j]++;
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<1e5;j++){
           if(imos[i][j])imos[i][j]=1;
        }
    }
    /*for(int i=0;i<5;i++){
        for(int j=0;j<15;j++){
            cout<<imos[i][j];
        }
        cout<<endl;
    }*/
    
    int rans=0;
    for(int i=0;i<1e5;i++){
        int ans=0;
        for(int j=0;j<m;j++){
            //cout<<imos[1][i]<<endl;
            ans+=imos[j][i];
        }
        //cout<<ans<<endl;
        rans=max(ans,rans);
    }
    cout<<rans<<endl;
}


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

int main(){
    string s;
    cin>>s;
    int f=0;
    if(s[0]==s[1]){
    	if(s[2]==s[3]&&s[0]!=s[2]){
    		f=1;
    	}
    }
    else{
    	if(s[0]==s[2]&&s[1]==s[3]){
    		f=1;
    	}
    	else if(s[0]==s[3]&&s[1]==s[2]){
    		f=1;
    	}
    	
    }
    if(f==1){
    		cout<<"Yes"<<endl;
    	}
    	else{
    		cout<<"No"<<endl;
    	}
   return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  cout << vec.at(n-1)-vec.at(0) << endl;
}

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

typedef long long int ll;
typedef long int l;
typedef long double ld;

const double pi = acos(-1);
const long long mod = 1e9 + 7;

#define loop(a,n) for(int i=a;i<n;i++)
#define fe(arr) for(int x : arr)
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define sqr(x) x*x

//<scanf>
#define sf scanf

#define tc() int t; scanf("%d",&t); while(t--)

#define i1(x) int x; scanf("%d",&x)
#define i2(x,y) int x,y; scanf("%d %d",&x,&y)
#define i3(x,y,z) int x,y,z; scanf("%d %d %d",&x,&y,&z)

#define ll1(x) long long int x; scanf("%lld",&x)
#define ll2(x,y) long long int x,y; scanf("%lld %lld",&x,&y)
#define ll3(x,y,z) long long int x,y,z; scanf("%lld %lld %lld",&x,&y,&z)
//</scanf>

//<printf>
#define pf printf

#define pi1(x) printf("%d\n",x)
#define pi2(x,y) printf("%d %d\n",x,y)
#define pi3(x,y,z) printf("%d %d %d\n",x,y,z)

#define pll1(x) printf("%lld\n",x)
#define pll2(x,y) printf("%lld %lld\n",x,y)
#define pll3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
//</printf>

using namespace std;

bool prime(ll n){
	for(ll i=2;i<=pow(n,0.5);i++){
		if(n%i==0){
			return false;
		}
	}
	return true;
}

void solve(){
	i1(n);
	pi1((n==1)?0:1);
}

int main(){
	solve();
	return 0;
}



Measured memory_bytes: 3776
n=int(input())
s=input()
from collections import Counter
l=Counter()
l["R"]=[]
l["G"]=[]
l["B"]=[]
for j,i in enumerate(s):
    if l[i]==0:
        l[i]=[]
    l[i].append(j)
ans=0
import bisect
import itertools
ll=Counter()
ll["R"]=len(l["R"])
ll["G"]=len(l["G"])
ll["B"]=len(l["B"])
for i,j in itertools.combinations(range(n),2):
    if s[i]!=s[j]:
        c="RGB".replace(s[i],"").replace(s[j],"")
        idx=bisect.bisect_left(l[c],j)
        ans+=ll[c]-idx
        if 2*j-i<n:
            if s[2*j-i]==c:
                ans-=1
print(ans)




Measured memory_bytes: 69652
N,M = map(int,input().split())
lis = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    lis[a].append(i+1)
    lis[b].append(-(i+1))
for i in range(N):
    lis[i].sort()

ans = 0
d = set()
for i in range(N):
    for j in range(len(lis[i])):
        if lis[i][j] < 0:
            if -lis[i][j] in d:
                d = set()
                ans += 1
        else:
            d.add(lis[i][j])
print(ans)


Measured memory_bytes: 95328
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int w, a, b;
    cin >> w >> a >> b;

    int ans;
    if(a + w < b)
        ans = b - (a + w);
    else if(b + w < a)
        ans = a - (b + w);
    else
        ans = 0;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

const int N = 1e5 + 10;

vector<pair<int,int>> adj[N];
int ans[N];
int total = 0;
int n;

int search(int u, int p, int c) {
  int x = 1;
  for (auto e : adj[u]) {
    int v = e.first, idx = e.second;
    if (v == p) continue;
    if (x == c) ++x;
    ans[idx] = x;
    total = max(total, ans[idx]);
    search(v, u, x);
    ++x;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i+1 < n; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
  }

  search(1, -1, -1);
  cout << total << "\n";
  for (int i = 0; i+1 < n; ++i) {
    cout << ans[i] << "\n";
  }

  return 0;
}


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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>
#define mod 998244353

int lowbit(int x) {return x&(-x);}

int n;
double p[3010];
double f[3010][3010];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) cin>>p[i];
	f[1][0]=1.0-p[1],f[1][1]=p[1];
	double ans=0.0;
	for (int i=2;i<=n;i++) {
		for (int j=0;j<=i;j++) {
			f[i][j]=f[i-1][j]*double(1.0-p[i]);
			if (j) f[i][j]+=f[i-1][j-1]*p[i];
		}
	}
	for (int i=n;i>n-i;i--) ans+=f[n][i];
	printf("%.11f",ans);
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
ll mo=1000000007;
ll pat[55][55][5050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>N>>K;
	
	pat[0][0][0]=1;
	for(i=1;i<=N;i++) {
		FOR(x,i) FOR(y,N*N) if(pat[i-1][x][y]) {
			ll v=pat[i-1][x][y];
			// close
			if(x) (pat[i][x-1][y+2*x]+=v*(x*x))%=mo;
			// open
			(pat[i][x+1][y+2*x]+=v)%=mo;
			// concat+self
			(pat[i][x][y+2*x]+=v*(2*x+1))%=mo;
		}
		
	}
	cout<<pat[N][0][K]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 108800
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, W: "List[int]"):
    Wacc = list(accumulate(W))
    m = INF
    for i in range(N):
        buf = abs(Wacc[i]-(Wacc[N-1]-Wacc[i]))
        if m > buf:
            m = buf
    print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, W)


if __name__ == '__main__':
    main()


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N,K;
    cin >> N >> K;

    vector<int> A(N);
    rep(i,0,N) cin >> A[i];

    if(N==K){
        cout << 1 << endl;
        return;
    }

    int ans=1;
    vector<bool> b(N);
    rep(i,0,K) b[i]=true;
    rep(i,0,N){
        if(i+1<N and !b[i+1]){
            ++ans;
            rep(j,i,i+K){
                if(j>=N) break;
                b[j]=true;
            }
        }
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 640
# include "iostream"
# include "algorithm"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;

int A,B,Ans;
int Num1[maxm],Num2[maxm],Top;

bool Check(int now){
	register int i;Top=0;
	while(now){
		Num1[++Top]=now%10;
		Num2[Top]=Num1[Top];
		now/=10;
	}
	reverse(Num2+1,Num2+1+Top);
	for(i=1;i<=Top;i++) if(Num1[i]!=Num2[i]) return false;
	return true;
}

int main(){
	register int i;
	scanf("%d%d",&A,&B);
	for(i=A;i<=B;i++) Ans+=Check(i);
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
ll a[100][100],b[100][100],c[100][100];
int main(){
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            scanf("%lld",&b[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j] += a[i][k]*b[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j==l-1) printf("%lld\n",c[i][j]);
            else printf("%lld ",c[i][j]);
        }
    }
}


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

int main(){
  int a,b;
  cin >> a>>b;
  if(a>=10){
    cout << -1 << endl;
  }else if (b>=10){
    cout << -1 << endl;
  }else{
    cout << a*b << endl;
  }
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;
 
template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    
 
    bool operator!() const{return !x;}
 
    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }
 
    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }
 
    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }
 
    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }
 
    modint operator-() const{ return modint(-x); }
 
    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }
 
 
    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }
 
    modint inv() const{
        return this->pow(MOD-2);
    }
 
    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }
 
    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

mint fact[200000];

mint combination(ll n, ll k){
    return fact[n]/fact[k]/fact[n-k];
}

int main(){
    fact[0] = 1; fact[1] = 1;
    rep(i,2,200000){
        fact[i] = (mint)i*fact[i-1];
    }

    ll n,m,k;
    cin >> n >> m >> k;

    mint memo1 = 0,memo2 = 0;

    rep(i,1,m){
        memo1 += i*(m - i)*n*n;
    }    
    memo1 *= combination(n*m-2,k-2);

    rep(i,1,n){
        memo2 += i*(n - i)*m*m;
    }    
    memo2 *= combination(n*m-2,k-2);

    mint ans = memo1 + memo2;

    cout << ans << endl;

}


Measured memory_bytes: 5188
import math


if __name__ == '__main__':
    a, b = list(map(int, input().split(" ")))
    for i in range(1, 1500):
        # print(i)
        if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
            print(i)
            exit()
    print(-1)

Measured memory_bytes: 3064
n = int(input())
data = list(map(int, input().split()))
line = list(range(1, n+1))

cnt = 0
not_matches = []
for i, j in zip(data, line):
  if i != j:
    cnt += 1
  if cnt >= 3:
    print('NO')
    break
else:
  print('YES')


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9 + 7;
i64 n, k, dp[51][51][3001];
int main() {
  cin >> n >> k;
  dp[0][0][0] = 1;
  for (i64 i = 0; i < n; ++i) {
    for (i64 j = 0; j <= i; ++j) {
      for (i64 k = 0; k < n * n; ++k) {
        // .  .
        (dp[i + 1][j + 1][k + 2 * j] += dp[i][j][k]) %= mod;

        // .__.
        (dp[i + 1][j][k + 2 * j] += dp[i][j][k]) %= mod;

        if (j >= 1) {
          // ./\.
          (dp[i + 1][j - 1][k + 2 * j] += j * j * dp[i][j][k]) %= mod;

          // ./ .
          // . \.
          (dp[i + 1][j][k + 2 * j] += 2 * j * dp[i][j][k]) %= mod;
        }
      }
    }
  }
  cout << dp[n][0][k] << endl;
  return 0;
}


Measured memory_bytes: 59264
#include <cstdio>
#include <iostream>

using namespace std;
     
const int MAX_N = 100001;
     
int N, Q;
long long int ans;
char Ope[MAX_N];
int Openum[MAX_N];
int par[MAX_N];
bool marked[MAX_N];

void init() {
  for (int i = 0; i <= N; i++) {
    par[i] = i;
  }
}

int search(int x) {
  // int a = par[x];
  if (marked[x]) return x;
  else return search(par[x]);
}

// int find(int x) {
//   if (par[x] == x) return x;
//   else return par[x] = find(par[x]);
// }

// void unite(int x, int y) {
//   par[find(x)] = find(y);
// }

// bool same(int x, int y) {
//   return find(x) == find(y);
// }

void solve() {
  ans = 0;
  for (int i = 0; i < Q; i++) {
    char ope = Ope[i];
    int num = Openum[i];
    
    if (ope == 'M') {
      marked[num] = true;
    }
    
    else if(ope == 'Q'){
      ans += search(num);
    }
  }
  printf("%lld\n", ans);
}
  
int main()
{
  marked[1] = true;
  int num;
  while(1){
    scanf("%d %d", &N, &Q);
    if(N == 0 && Q == 0) break;
    init();
    
    for(int i = 2; i <= N; i++){
      scanf("%d", &num);
      //unite(num,i);
      par[i] = num;
      marked[i] = false;
    }
    for(int i = 0; i < Q; i++){
      scanf("  %c", &Ope[i]);
      scanf("%d", &Openum[i]);
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int ans = 0;
    rep(i,sz(s))if(s[i] != t[i])ans++;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    int sum = n + pow(n,2) + pow(n,3);
    cout<<sum;


    return 0;
}

Measured memory_bytes: 4108
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=split(readline())
    if a[end]==b[1] && b[end]==c[1]
        println("YES")
    else
        println("NO")
    end
end
main()

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

int main() {
	int i=0,a5=0,a7=0;
	int a[3];
	for(i=0;i<3;i++){
		cin >> a[i];
		if (a[i]==5)
			a5++;
		else if(a[i]==7)
			a7++;
	}

	if(a5==2&&a7==1)
		cout << "YES" << "\n";
	else
		cout << "NO" << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n,m;cin>>n>>m;
	ll sum = 0;
	for(int i=0;i<m;i++){
		ll a;cin>>a;
		sum += a;
	}
	if(sum>n){
		cout<<-1<<endl;
	}
	else{
		cout<<n-sum<<endl;
	}
}


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

int main() {
    vector<int> x(6);
    int ans = 0;
    for(int i = 0; i < 6; ++i) {
        cin >> x[i];
        ans += x[i];
    }
    ans -= min({x[0], x[1], x[2], x[3]}) + min(x[4], x[5]);
    cout << ans << endl;
}



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

int main() {
	long long int n,x,a,b,t;
	lldiv_t d;
	cin >> n >> x;
	a = n;
	b = x;
	while(b){
		d = lldiv(a,b);
		a = b;
		b = d.rem;
	}
	cout << 3 * a * (n / a - 1) << endl;
	return 0;
}

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

int prime(int x){
	
	if(x==2)return 1;
	
	if(x<2||x%2==0)return 0;
	
	int i=3;
	while(i<=sqrt(x)){
		if(x%i==0)return 0;
		i=i+2;
	}
	return 1;
}

int main(void){

	int n;
	int* a=(int*)malloc(sizeof(int)*n);
	int b=0;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(int i=0;i<n;i++){
		if(prime(a[i])==1)++b;
	}
	
	printf("%d\n",b);
	
}


Measured memory_bytes: 2044
using System;

namespace abc142
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] r1 = Console.ReadLine().Split(' ');
            int N = int.Parse(r1[0]);
            int K = int.Parse(r1[1]);
            string[] r2 = Console.ReadLine().Split(' ');
            int ans = 0;
            for(int i=0;i<N;i++){
                if(int.Parse(r2[i])>=K){
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 17632
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
using namespace std;
int a,b;
string x[110];
int k;
int main()
{
	cin>>a>>b;
	a--;
	b--;
	for (int i=0;i<99;i++)
		x[k]+='#';
  	k=2;
	while (a>0)
	{
		for (int i=0;i<33;i++)
		{
			x[k]+="###";
			if (a>0)
			{
				a--;
				x[k-1]+="#.#";
			}
			else
				x[k-1]+="###";
		}
		k+=2;
	}
	k--;
	for (int i=0;i<99;i++)
		x[k]+='.';
	k+=2;
	while (b>0)
	{
		for (int i=0;i<33;i++)
		{
			x[k]+="...";
			if (b>0)
			{
				b--;
				x[k-1]+=".#.";
			}
			else
				x[k-1]+="...";
		}
		k+=2;
	}
	cout<<k-1<<" "<<"99"<<endl;
	for (int i=0;i<k-1;i++)
		cout<<x[i]<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

//long longのシフト演算には気をつけよう

int main(){
    int N; cin >> N;
    vector<string> s(N);
    string ans = "";
    for(int i=0; i<N; i++) cin >> s[i];

    for(char c='a'; c<='z'; c++){
        int v = 100;
        for(int i=0; i<N; i++){
            v = min(v, (int)count(s[i].begin(), s[i].end(), c));
        }

        for(int i=0; i<v; i++) ans += c;
    }

    cout << ans << endl;
}

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


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

int main() {
	int h , n;

	cin >> h >> n;
	
	int total = 0;
	rep(i , n) {
		int tmp;
		cin >> tmp;
		total += tmp;
	} 
	if (h - total <= 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 888
N = int(input())
S = input()
s = [S[i: i + 1] for i in range(N)]
bcount = 0
wcount = 0
for word in s:
    if word == '.':
        wcount += 1
ans = wcount
preans = ans
for word in s:
    if word == '#':
        preans += 1
    else:
        preans -= 1
    ans = min(ans, preans)
print(ans)


Measured memory_bytes: 5096
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//







int main()
{



      int n, l;
      cin >> n >> l;

      int ans = 1e9;

      int tmp = 0;
      for(int i = 0; i < n; i++){
              tmp += l+i;
      }

      int sa = 1e9;
      for(int i = 0; i < n; i++){
              int cnt = 0;
              for(int j = 0; j < n; j++){
                      if(i == j) continue;
                      cnt += l + j;
              }
              if(abs(tmp-cnt) < sa){
                      ans = cnt;
                      sa = abs(tmp-cnt);
              }
      } 

      cout << ans << endl;
      return 0;







}

















Measured memory_bytes: 256
l,r = map(int,input().split())

if r-l >= 2018:
    print(0)
else:
    cand = []
    ans = float("inf")
    for i in range(l,r+1):
        cand.append(i%2019)
    cand = sorted(cand)
    for i in range(len(cand)):
        for j in range(i+1,len(cand)):
            ans = min(ans,cand[i]*cand[j]%2019)
    print(ans)


Measured memory_bytes: 3064
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll a, b, c; a = 0; b = 0; c = 0;
    rep(i, n){
        ll buf; cin >> buf;
        if(buf % 4 == 0) b++;
        else if(buf % 2 == 0) a++;
        else c++;
    }
    if(a == 1) c++;
    if(a >= 2) c++;
    if(b >= c - 1) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
// author-Shivam gupta

#include <bits/stdc++.h>


using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))

#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define IN(A, B, C) assert( B <= A && A <= C)

#define MP make_pair
#define FOR(i,a) for(int i=0;i<a;i++)

#define FOR1(i,j,a) for(int i=j;i<a;i++)

#define EB emplace_back

#define INF (int)1e9

#define EPS 1e-9

#define PI 3.1415926535897932384626433832795

#define MOD 1000000007

#define read(type) readInt<type>()
#define max1 100001
#define out(x) cout<<x<<'\n'
#define out1(x) cout<<x<<" "
#define END cout<<'\n'
#define int long long
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}


signed main(){

int n,m;
cin>>n>>m;
int cnt=0;
int x,y;
int a,b;
FOR(i,n){
cin>>x>>y;
a=x*x+y*y;
b=sqrt(a);
if(b*b==a){
    if(b<=m){cnt++;}
}
else{
    if(b<m){cnt++;}
}

}
out(cnt);
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
using namespace std;
int main(){
	string a,b,c;
	int sma;
	string d="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
	while(getline(cin,a)){
		b="";
		c="";
		for(int i=0;i<a.size();i++){
			if(a[i]==' ')b+="101";
			else if(a[i]==39)b+="000000";
			else if(a[i]==',')b+="000011";
			else if(a[i]=='-')b+="10010001";
			else if(a[i]=='.')b+="010001";
			else if(a[i]=='?')b+="000001";
			else if(a[i]=='A')b+="100101";
			else if(a[i]=='B')b+="10011010";
			else if(a[i]=='C')b+="0101";
			else if(a[i]=='D')b+="0001";
			else if(a[i]=='E')b+="110";
			else if(a[i]=='F')b+="01001";
			else if(a[i]=='G')b+="10011011";
			else if(a[i]=='H')b+="010000";
			else if(a[i]=='I')b+="0111";
			else if(a[i]=='J')b+="10011000";
			else if(a[i]=='K')b+="0110";
			else if(a[i]=='L')b+="00100";
			else if(a[i]=='M')b+="10011001";
			else if(a[i]=='N')b+="10011110";
			else if(a[i]=='O')b+="00101";
			else if(a[i]=='P')b+="111";
			else if(a[i]=='Q')b+="10011111";
			else if(a[i]=='R')b+="1000";
			else if(a[i]=='S')b+="00110";
			else if(a[i]=='T')b+="00111";
			else if(a[i]=='U')b+="10011100";
			else if(a[i]=='V')b+="10011101";
			else if(a[i]=='W')b+="000010";
			else if(a[i]=='X')b+="10010010";
			else if(a[i]=='Y')b+="10010011";
			else if(a[i]=='Z')b+="10010000";
		}
		while(b.size()%5!=0)b+='0';
		for(int i=0;i<b.size();i+=5){
			sma=(16*(b[i]-'0'))+(8*(b[i+1]-'0'))+(4*(b[i+2]-'0'))+(2*(b[i+3]-'0'))+(1*(b[i+4]-'0'));
			c+=d[sma];
			
		}
		cout<<c<<endl;
		
	}
	
	return 0;
}


Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
  string s,t;
  cin>>s>>t;
  bool f=1;
  rep(i,0,3) if(s[i]!=t[2-i]) f=0;
  if(f) cout<<"YES";
  else cout<<"NO";
}


Measured memory_bytes: 256
/**
 *		author:  zvm
 *		created: 27.09.2020 18:36:26
**/

#include <bits/stdc++.h>

using namespace std ;

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

	string s, t ;
	cin >> s >> t ;

	sort(s.begin(),s.end());
	sort(t.rbegin(),t.rend());

	cout << ( s < t ? "Yes" : "No" ) << endl ;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    if (N % 2) {
        cout << 0 << '\n';
    } else {
        ll x = 2;
        ll ans = 0;
        rep(i, 27) {
            x *= 5;
            ans += N / x;
        }
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main()
{
	int a;
	cin>>a;
	int x=a;
	int sum=0;
	while(x)
	{
		sum+=x%10;
		x/=10;
	}
	if(a%sum==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
def solve(sx, sy, tx, ty):

    dx = abs(tx-sx)
    dy = abs(ty-sy)

    ans = "U"*dy + "R"*dx + "D"*dy + "L"*dx
    dx += 1
    dy += 1
    ans += "L" + "U"*dy + "R"*dx + "D"
    ans += "R" + "D"*dy + "L"*dx + "U"

    return ans

if __name__ == "__main__":
    sx,sy,tx,ty = [int(i) for i in input().split()]
    print(solve(sx, sy, tx, ty))


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

using std::vector;
using std::pair;

pair<int, int> get_bracket(const std::string& s) {
  int r_bracket = 0, l_bracket = 0;
  for (const auto& c : s) {
    if (c == '(') {
      ++l_bracket;
    } else {
      if (l_bracket > 0) --l_bracket;
      else ++r_bracket;
    }
  }
  return std::make_pair(l_bracket, r_bracket);
}

bool solve(vector<pair<int, int>>& ge_0, vector<pair<int, int>>& l_0) {
  std::sort(ge_0.begin(), ge_0.end(), [](const auto& x, const auto& y) {
    return x.second < y.second; 
  });
  std::sort(l_0.begin(), l_0.end(), [](const auto& x, const auto& y) {
    return x.first > y.first;
  });
  int pre_sum = 0;
  for (const auto& [l, r] : ge_0) {
    pre_sum -= r;
    if (pre_sum < 0) return false;
    pre_sum += l;
  }
  for (const auto& [l, r] : l_0) {
    pre_sum -= r;
    if (pre_sum < 0) return false;
    pre_sum += l;
  }
  return pre_sum == 0;
}

int main() {
  int n;
  std::cin >> n;
  vector<pair<int, int>> ge_0, l_0;
  for (int i = 0; i < n; ++i) {
    std::string s;
    std::cin >> s;
    auto p = get_bracket(s);
    if (p.first >= p.second) ge_0.emplace_back(p);
    else l_0.emplace_back(p);
  }
  if (solve(ge_0, l_0)) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 11224
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
#define N 600005
#define P 1000000007
int n, m, l, r, fac[N], inv[N];
void inc(int &a, int b){ (a += b) >= P ? a -= P : 0; }
void dec(int &a, int b){ (a -= b) < 0 ? a += P : 0; }
int plus(int a, int b){ return (a += b) >= P ? a - P : a; }
int minus(int a, int b){ return (a -= b) < 0 ? a + P : a; }
int qpow(int a, int b = P - 2){
	int s = 1;
	for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) s = 1ll * s * a % P;
	return s;
}
void init(int n){
	fac[0] = 1;
	for (register int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = qpow(fac[n]);
	for (register int i = n; i; --i) inv[i - 1] = 1ll * inv[i] * i % P;
}
int C(int n, int m){
	if (n < m) return 0;
	return 1ll * fac[n] * inv[m] % P * inv[n - m] % P;
}
int get(int S, int r){
	if (S < 0) return 0;
	int res = 0;
	for (register int i = 0, t = 0; i <= n - m && t <= S; t += r, ++i){
		int s = 1ll * C(n - m, i) * C(S - t + n, n) % P;
		if (i & 1) dec(res, s); else inc(res, s);
	}
	return 1ll * res * C(n, m) % P;
}
int solve(int S){
	int res = C(S + n, n);
	for (register int i = 1; i * m <= S; ++i)
		dec(res, minus(get(S - i * m, i), get(S - (i + 1) * m, i)));
	return res;
}
int main(){
	n = read(), m = read(), l = read(), r = read();
	init(n + r);
	printf("%d\n", minus(solve(r), solve(l - 1)));
}


Measured memory_bytes: 4864
#include <stdio.h>

int abs(int a) {
  return a > 0 ? a : -a;
}

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

int main(void) {
  int i, j, k, w, h, n, ans = 0, nowa, nowb;
  scanf("%d%d%d", &w, &h, &n);
  for(i = 0; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    if(i) {
      if((nowa - a) * (nowb - b) > 0) ans += max(abs(nowa - a), abs(nowb - b));
      else ans += abs(nowa - a) + abs(nowb - b);
    }
    nowa = a, nowb = b;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
const int Mod = 1000000007;
int n;
int dp[26];
signed main() {
	string s, t;
	cin >> n >> s >> t;
	dp[(int)(s[0] - 'a')]++;
	for (int i = 1; i < n; i++) {
		int res = dp[(int)(t[i] - 'a')];
		if (i < n - 1) {
			(dp[(int)(s[i] - 'a')] += res) %= Mod;
		}
	}
	cout << dp[(int)(t[n - 1] - 'a')] % Mod << endl;
}


Measured memory_bytes: 3272
def b_magic2():
    A, B, C = [int(i) for i in input().split()]
    K = int(input())

    for j in range(K + 1):
        for k in range(K + 1):
            if j + k > K:
                break
            if A < B * (2**j) < C * (2**k):
                return 'Yes'
    return 'No'

print(b_magic2())

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

int main() {
  string N;
  cin >> N;
  
  int ramen = 700;
  
  if(N[0] == 'o'){
    ramen += 100;
  }
  
  if(N[1] == 'o'){
    ramen += 100;
  }
  
  if(N[2] == 'o'){
    ramen += 100;
  }
  
  cout << ramen <<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

int K, A, B;

int main() {
	cin >> K >> A >> B;
	ll ans = 1;
	if (B - A <= 2) {
		ans += K;
	}
	else {
		K -= A - 1;
		if (K <= 0) {
			ans += K;
		}
		else {
			ans += A - 1;
			const int s = B - A;
			ans += (ll)K / 2 * s;
			K %= 2;
			if (K == 1) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef double ld;
typedef long long ll;
typedef pair<int,int> P;
ld n,A[100],B[100],C[100],R[100],ra[101],fa[101],ans;
vector<pair<ld,P>> v;

ll find(ll x){
    if(x==fa[x])return x;
    return fa[x]=find(fa[x]);
}
void uni(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return ;
    if(ra[x]<ra[y])swap(x,y);
    fa[y]=x;
    if(ra[x]==ra[y])ra[x]++;
    return ;
}

int main(void){
    while(1){
    cin>>n;
    if(n==0)return 0;
    v={};
    ans=0;
    for(int i=0;i<101;i++)fa[i]=i;
    for(int i=0;i<n;i++){
        cin>>A[i]>>B[i]>>C[i]>>R[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ld L=(A[i]-A[j])*(A[i]-A[j])+(B[i]-B[j])*(B[i]-B[j])+(C[i]-C[j])*(C[i]-C[j]);
            L=pow(L,0.5);
            L-=R[i]+R[j];
            if(L<0)L=0;
            v.push_back({L,{i,j}});
        }
    }
    sort(v.begin(),v.end());
    for(auto x:v){
        if(find(x.S.F)!=find(x.S.S))ans+=x.F;
        uni(x.S.F,x.S.S);
    }
    //cout<<ans<<endl;
    //cout<<setprecision(10)<<ans<<endl;
    printf("%.3f\n",ans);
    }
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    string a;
    cin >> a;
    ll n = a.size();
    if (a[n - 1] == 's')
    {
        cout << a << "es" << endl;
    }
    else
    {
        cout << a << "s" << endl;
    }
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int is_prime(int t){
    int f = 1;

    for(int i = 2; i <= (int)sqrt(t); i++){
        if(t % i == 0){
            f = 0;
            break;
        }
    }

    return f;
}

int main(void){

    int N;

    scanf("%d", &N);

    int c = 0;
    int t = 11;

    int a[N];

    while(1){
        if(c == N){
            break;
        }else if(is_prime(t) == 1){
            a[c] = t;
            c++;
        }
        t += 5;
    }

    for(int i = 0; i < N-1; i++){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[N-1]);

    return 0;
}

Measured memory_bytes: 2116
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    sp = [input().split() + [i+1] for i in range(n)]
    sp = sorted(sp, key=lambda x: (x[0], -int(x[1])))
    for _, _, i in sp:
        print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<LL>>g;
vector<edge>edges;
vector<Pll>v;
map<Pll, Pll>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[1000][1000], b[210000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
int main() {
	cin >> n;
	for (int i = 1; i < log2(n)+1; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (j % (1 << i) >= (1 << (i - 1)) && k % (1 << i) < (1 << (i - 1)))
					a[min(j, k)][max(j, k)] = i;
				if (j % (1 << i) < (1 << (i - 1)) && k % (1 << i) >= (1 << (i - 1)))
					a[min(j, k)][max(j, k)] = i;
			}
		}
	}
	rep(i, n - 1) {
		for (int j = i + 1; j < n; j++) {
			if (j != i + 1)cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi
#define se second
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0) 
 
using namespace std;

int main()
{
	lli n;
	cin >> n;
	ldb out = n/3.000, vol;
	vol = out*out*out;
	printf("%0.12Lf" , vol);

	return 0;
}


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

#define MAX_A 1000000

int main(){
    int N; cin >> N;
    vector<int> count(MAX_A + 1, 0); //大きさMAX A＋1で初期値0のvector
    vector<int> state(MAX_A + 1, true);
    for (int i=0; i<N; i++){
        int a;cin >>a;
        count[a]++;
    }
    for(int i=1; i <= MAX_A; i++){
        if(count[i] > 0 && state[i]){
            int k =2;
            while(i*k <= MAX_A){
                state[i*k] =false;
                k++;
            }
        }
    }
    int ans=0;
    for(int i=1; i<= MAX_A; i++){
        if(count[i] == 1 && state[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11156
#include <bits/stdc++.h>
using namespace std;
long long ans;
long long a;
vector<long long>vec;
long long n;
long long sum;
long long solve(vector<long long> tmp_vec) {
    for(int i = 0; i < n; i++) {
       sum += abs(tmp_vec.at(i) - tmp_vec.at(n/2)); 
    }
    return sum;
}
int main(int argc, char* argv[]) {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &a);
        vec.push_back(a - (i + 1));
    }
    sort(vec.begin(), vec.end());
    ans = solve(vec);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3440
#import <Foundation/Foundation.h>
typedef long long INT;
#define M 1000000007
INT getBinomial(NSArray *binomials, INT index){
    if (index < 0 || index >= [binomials count]) {
        return 0;
    }
    return [[binomials objectAtIndex:index] longLongValue];
}
int main(){
    @autoreleasepool {
        INT n,k;
        scanf("%lld %lld",&n,&k);
        NSMutableArray *binomials = [NSMutableArray arrayWithObject:@[@1]];
        NSMutableArray *previousBinomials = [NSMutableArray arrayWithObject:@1];
        for(INT m=1;m<=MAX(n-k+1,k-1);m++){
            NSMutableArray *currentBinomials = [NSMutableArray array];
            for(INT j=0;j<=m;j++){
                INT b = (getBinomial(previousBinomials, j) + getBinomial(previousBinomials, j-1)) % M;
                [currentBinomials addObject:@(b)];
            }
            [binomials addObject:currentBinomials];
            previousBinomials = currentBinomials;
        }
        for(INT i=1;i<=k;i++){
            if(i>n-k+1) {
                puts("0");
                continue;
            }
            printf("%lld\n", [[[binomials objectAtIndex:n-k+1] objectAtIndex:i] longLongValue] * [[[binomials objectAtIndex:k-1] objectAtIndex:i-1] longLongValue] % M);
        }
    }
}


Measured memory_bytes: 99812