akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    init_fact(1000000);
    int ans=kaijo[m]*invkaijo[m-n]%mod;
    int res=0;
    for(int i=0;i<=n;i++){
        int c=comb(n,i);
        c*=kaijo[m-i]*invkaijo[m-n]%mod;
        c%=mod;
        if(i%2==0)res+=c;
        else res-=c;
        res+=mod;
        res%=mod;
    }
    cout<<ans*res%mod<<endl;
    return 0;
}

Measured memory_bytes: 18768
using System;
public class Hello{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int sum = 0;
        int num = N;
        
        if(N % func(N) == 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
        
    　　
    }
    
    public static int func(int x)
    {
        if(x < 10)
        {
            return x;
        }
        else
        {
            return x % 10 + func(x / 10);
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

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

        int n  = sc.nextInt();
        double[] x = new double[n];
        String[] u = new String[n];

        double total = 0;

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextDouble();
            u[i] = sc.next();
            if (u[i].equals("JPY")) {
                total += x[i];
            } else {
                total += 380000.0 * x[i];
            }
        }
        System.out.println(total);
    }
}


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

using namespace std;

int main() {
    unsigned int n;
    cin >>n;
    unsigned int x[n],y[2];
    cin >>x[0];
    y[0]=x[0];
    if(n>1) {for(int i=1;i<n;i++){cin >>x[i]; if(x[i]>=y[0]){y[1]=y[0];y[0]=x[i];}else if(x[i]>y[1]){y[1]=x[i];}}}


    for(int i=0;i<n;i++){
        (x[i]!=y[0])? std::printf("%d\n",y[0]) : std::printf("%d\n",y[1]);
    }
    

    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define nl '\n'
#define dbg(a) cout<<#a<<"="<<a<<nl
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ll long long
#define vl vector<ll>
#define pll pair<ll, ll>
#define ii pair<int,int>
#define vi vector<int>
#define md 998244353

using namespace std;

int solve()
{

    ll n;
    cin>>n;
    ll x=0;
    for(ll i=1;i<=n;i++)
    {
        x+=i*(n-i+1);
    }
    ll y=0;
    for(int i=1;i<n;i++)
    {
        ll a, b;
        cin>>a>>b;
        if(a>b) swap(a, b);
        y+=a*(n-b+1);
    }
    cout<<x-y<<endl;

    return 0;
}

int main()
{
    fast;
    solve();

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
vector<int>v[100010];
bool vi[100010];
void dfs(int n){
    if(vi[n])return;
    vi[n] = true;
    for(int i=0;i<v[n].size();i++){
        dfs(v[n][i]);
    }
    return;
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    while(m--){
        int n1,n2;
        scanf("%d %d",&n1,&n2);
        v[n1].push_back(n2);
        v[n2].push_back(n1);
    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(!vi[i]){dfs(i);cnt++;}
    }
    printf("%d\n",--cnt);
    return 0;
}

Measured memory_bytes: 9816
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
 
using namespace std;
long long abs(long long x, long long y){
    long long tmp;
    if(y>x){
        tmp=y;
        y=x;
        x=tmp;
    }
    return (x-y);
}

int main() {
    long long a, b, n;
       cin >> a >> b >> n;
    
    if(n < b){
        a=a*n;
        a/=b;
    }
    else {
        a*=(b-1);
        a/=b;
    }
    cout << a << endl;
    return 0;
 }


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int i,N,a;
  cin >> N;
  vector<int> A(N+1);
  for(i=0;i<=N;i++)A.at(i)=0;
  
  for(i=0;i<N-1;i++){
    cin >> a;
    A.at(a)+=1;
    
  }
  for(i=1;i<=N;i++)
    cout << A.at(i) << " "<< endl;
    
  
return 0;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;


long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int main()
{

	ll n;
	cin >> n;
	if(n%2){
		cout << 0 <<"\n";
		return 0;
	}n/=2;
	ll ans  = 0;
	while(n){
		ans += (n/5);
		n/=5;
	}
	cout  << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		for (int i=0; i<c.length; i++) {
			if (c[i] == '9') {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21332
fun main(args:Array<String>) {
    val inpt = readLine()!!.split(" ").map { it.toInt() }
    val prc = Proc(inpt[0], inpt[1], inpt[2], inpt[3], inpt[4])
    println(prc.proc())
}


class Proc(val a:Int, val b:Int, val c:Int, val x:Int, val y:Int) {
    fun proc():Int {
        val maxAB = Math.max(x,y) * 2
        var ans = getCost(0)
        for(i in (0..maxAB).filter { it%2==0 }) {
            ans = Math.min(ans, getCost(i))
        }
        return ans
    }

    fun getCost(mixCount:Int):Int {
        var ret = mixCount*c
        ret += Math.max(x - (mixCount/2), 0)*a
        ret += Math.max(y - (mixCount/2), 0)*b
        return ret
    }

}


Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

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

  vector<ll> a(n), b(n);
  vector<ll> c(m), d(m);

  for(ll i = 0; i < n; i++) cin >> a[i] >> b[i];
  for(ll i = 0; i < m; i++) cin >> c[i] >> d[i];

  for(ll i = 0; i < n; i++){
    ll dis = 1000000007;
    ll ans = 0;
    for(ll j = 0; j < m; j++){
      if(abs(a[i]-c[j]) + abs(b[i]-d[j]) < dis){
        ans = j+1;
        dis = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl; 


ll max_ll(ll a,ll b,ll c){
	return max(a,max(b,c));
}

ll min_ll(ll a,ll b,ll c){
	return min(a,min(b,c));
}


bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second==b.second)
		return a.first<b.first;
    return (a.second < b.second); 
}

long long binexpmod(long long a, long long b){
    long long res =1;
    while(b>0){
        if(b&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b>>=1;
    }
    return(res);
}
const int nix = 100005;
vi edges[nix];
vi in_degree(nix);
vi vis(nix);
vi dist(nix,0);


void dfs(ll i){
    assert(!vis[i]);
    vis[i] = 1;
    for(auto e:edges[i]){
        dist[e] = max(dist[e],dist[i]+1);
        in_degree[e]--;
        if(in_degree[e]==0){
            dfs(e);
        } 
    }
    return;
}
ll lcm(ll a,ll b){
	ll x=__gcd(a,b);
	a/=x;
	b/=x;
	ll sum=a*b*x;
	return sum;
}
void solve(){
    ll n,m,res=0;
	cin>>n>>m;
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        edges[x].push_back(y);
        in_degree[y]++;
    }
    rep1(i,n){
        if(!vis[i] && in_degree[i]==0){
            dfs(i);
        }
    }
    for(ll i:dist){
        res=max(res,i);
    }
	cout<<res<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 11264
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int M=1e5+7;
int read(){
    int ans=0,f=1,c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
    return ans*f;
}
int ans[M],T[M];
struct pos{int T,s;}e[M];
int x,k=1,n,m,sgn=-1;
void calc(LL &k){if(k<0) k=0; if(k>x) k=x;}
int main(){
    x=read();
    n=read(); for(int i=1;i<=n;i++) T[i]=read();
    m=read(); for(int i=1;i<=m;i++) e[i].T=read(),e[i].s=read();
    LL h=0,mx=x,mn=0;
    for(int i=1;i<=m;i++){
        while(k<=n&&T[k]<=e[i].T){
            LL v=(T[k]-T[k-1])*sgn;
            mx+=v; mn+=v; h+=v;
            calc(mx); calc(mn);
            k++;sgn*=-1; 
        }
        LL now=e[i].s+h,nowh=(e[i].T-T[k-1])*sgn;
        if(now<mn) now=mn;
        if(now>mx) now=mx;
        now+=nowh; calc(now);
        printf("%lld\n",now);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B, std::vector<long long> C) {
    vector<pair<ll, ll> > ops;
    for (int i = 0; i < M; i++) {
        ops.push_back({C[i], B[i]});
    }
    sort(ops.rbegin(), ops.rend());
    vector<ll> vs;

    for (int i = 0; i < ops.size(); i++) {
        for (int j = 0; j < ops[i].second && vs.size() < N; j++) {
            vs.push_back(ops[i].first);
        }
    }
    while (vs.size() < N) vs.push_back(0);
    sort(A.begin(), A.end());

    ll ans = 0;
    for (int i = 0; i < A.size(); i++) {
        ans += max(A[i], vs[i]);
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &B[i]);
        scanf("%lld", &C[i]);
    }
    solve(N, M, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
bool isprime(ll x){
	if(x<=1)return false;
	if(x==2)return true;
	if(x%2==0)return false;
	for(auto i=3;i<=sqrt(x);i+=2){
		if(x%i==0)return false;
	}
	return true;
}
int main(){
	fast;
	ll x; cin>>x;
	for(auto i=x;;++i){
		if(isprime(i)){
			cout<<i<<'\n';
			break;
		}
	}
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

#define ll long long
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, int, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;



void solve()
{
    cin>>n>>m;
    vpt v(n);
    ll su=0;
    F(i,n){
        cin>>t1>>t2;
        v[i]={t1,t2};
        su+=t2;
    }

    setmtsize(n+1,su+1,LLONG_MAX);
    for(i=0;i<=n;i++)mt[i][0]=0;

    for(i=1;i<=n;i++){
        pr cr=v[i-1];
        ll wt=cr.first;
        ll vl=cr.second;
        for(j=1;j<=su;j++){
            if((j-vl)<0)mt[i][j]=mt[i-1][j];
            else{
                if(mt[i-1][j-vl]==LLONG_MAX)mt[i][j]=mt[i-1][j];
                else mt[i][j]=min(mt[i-1][j],mt[i-1][j-vl]+wt);
            }
        }
    }
    ll ind=0;
    for(i=1;i<=su;i++)if(mt[n][i]<=m)ind=i;
    prn(ind);
    // prmt(mt);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    // stress();
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 83064
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,sum;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(a<0){
		sum=a*-1*c;
		sum+=d;
		sum+=e*b;
	}
	else{
		sum=(b-a)*e;
	}
	printf("%d\n",sum);
	return 0;
}

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

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

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

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int temp1 = min(a*x + b*y, max(x, y)*c*2);
	int temp2 = c*min(x, y)*2 + a*(x-min(x, y)) + b*(y-min(x, y));
//	cout << temp1 << " " << temp2 << endl;
	cout << min(temp1, temp2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

vector<int> get_dis(vector<vector<int>> &E,int start){
	vector<int> dis(E.size(),Inf);
	dis[start] = 0;
	queue<int> Q;
	Q.push(start);
	
	while(Q.size()!=0){
		int from = Q.front();
		Q.pop();
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i];
			if(dis[to]!=Inf)continue;
			dis[to] = dis[from] + 1;
			Q.push(to);
		}
	}
	
	return dis;
}


int main(){
	
	int N;
	cin>>N;
	
	int u,v;
	cin>>u>>v;
	
	u--;v--;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	vector<int> dis_u = get_dis(E,u),dis_v = get_dis(E,v);
	int ans = 0;
	for(int i=0;i<N;i++){
		if(dis_u[i] >= dis_v[i])continue;
		ans = max(ans,dis_v[i]-1);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6656
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int  num=10001;
        int a[]=new int[num];
        for(int i=2;i<num;i++){
            a[i]=1;
        }
        for(int i=2;i<Math.sqrt(num);i++){
            if(a[i]==1){
                for(int j=0;i*(j+2)<num;j++){
                    a[i*(j+2)]=0;
                }
            }
        }
        while(true){
            int n=sc.nextInt();
            if(n==0){
                break;
            }
            for(int i=n;i>=5;i--){
                if(a[i]==1&&a[i-2]==1){
                    System.out.println((i-2)+" "+i);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 45636
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)

int main(){
    string o,e;
    cin >> o >> e;
    for (int i = 0; i < e.length(); i++){
        cout << o[i] << e[i];
    }
    if (e.length() < o.length()) cout << o[o.length()-1] << endl;
    return 0;
}






Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();
    ArrayList<Integer>ans  = new ArrayList<>();
    
    int a = 0;
    for(int i=0; i<S.length()-2; i++) {
    	a = 753 - ((ss[i]-48)*100 + (ss[i+1]-48)*10 + (ss[i+2]-48));
    	a = Math.abs(a);
    	ans.add(a);
    }
    Collections.sort(ans);
    	System.out.println(ans.get(0));
    }
}


Measured memory_bytes: 35592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		String v = "aiueo";
		System.out.println(v.contains(c) ? "vowel" : "consonant");
		sc.close();
	}
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, a, b;
  cin >> n >> a >> b;
  
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    int sum = 0;
    for (auto c : s) {
      sum += c - '0';
    }
    
    if (a <= sum && sum <= b) {
      ans += i;
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 3640
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
v1=[]
v2=[]
for i in range(n):
    if i%2==0:
        v1.append(v[i])
    else:
        v2.append(v[i])

v1c=Counter(v1).most_common()
v2c=Counter(v2).most_common()
v1c.append((0,0))
v2c.append((0,0))
#print(v1c[0])
if v1c[0][0]==v2c[0][0]:
    print(min(n-v1c[0][1]-v2c[1][1],n-v1c[1][1]-v2c[0][1]))
else:
    print(n-v1c[0][1]-v2c[0][1])


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

typedef long long ll;

int main(){
	ll a;
	ll b;
	cin >> a >> b;
	char c;
	int d;
	cin >> c >> d;
	int t = b*100+d;
	ll ans = a * t / 100;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }
const int maxn = 2e5 + 1;
int a[maxn];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k, n;
  cin >> k >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> ccw(n + 1, 0);
  for (int i = n-1; i >= 0; i--) {
    ccw[i] = k - a[i];
  }
  int res = a[n-1] - a[0];
  for (int i = 0; i + 1 < n; i++){
    res = min(res, a[i] + ccw[i + 1]);
  }
  cout << res << endl;

}


Measured memory_bytes: 1792
n = int(input())
goukei = n * (n + 1) // 2
bai3 = n // 3
bai5 = n // 5
bai15 = n // 15
gou3 = (3 + bai3 * 3) * bai3 // 2
gou5 = (5 + bai5 * 5) * bai5 // 2
gou15 = (15 + bai15 * 15) * bai15 // 2
ans = goukei - gou3 - gou5 + gou15
print(ans)


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

typedef long long ll;

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

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

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

ll min(ll a, ll b) { return (a < b) ? a : b; }

ll asc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

ll dsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

bool flag;

int main() {
	ll n, a[100000], p[100000], q[100001];
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	p[0] = 0, q[n] = 0;
	for (int i = 0; i < n; i++) {
		p[i + 1] = gcd(p[i], a[i]), q[n - i - 1] = gcd(q[n - i], a[n - i - 1]);
	}
	ll ans = 0,r;
	for (int i = 0; i < n; i++){
		r = gcd(p[i], q[i + 1]);
		ans = max(ans, r);
	}
	printf("%lld", ans);
	
	return 0;
}

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

int main(void) {
	int cuisine[5];
	for (int i = 0; i < 5; i++){
		cin >> cuisine[i];
	}

	int tmp[5], tmp_min_index=0;
	for (int i = 0; i < 5; i++){
		tmp[i] = cuisine[i] % 10;
		if (0 < tmp[i] && tmp[i] < tmp[tmp_min_index])
			tmp_min_index = i;
	}

	int ret=0;
	for (int i = 0; i < 5; i++){
		if (i != tmp_min_index) {
			if(tmp[i] >0)
				ret += cuisine[i] + (10 - tmp[i]);
			else {
				ret += cuisine[i];
			}
		}
		else {
			ret += cuisine[i];
		}
	}
	cout << ret << endl;
	return 0;
}

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

int gcd(int a,int b){
	int r;
	do{
		r=a%b;
		a=b;
		b=r;
	}while(b!=0);
	return a;
}

int main(){
	long min,max,div1,div2,lcm;
	cin>>min>>max>>div1>>div2;
	min--;lcm=div1/gcd(div1,div2)*div2;
	long maxNum,minNum;
	maxNum=max-(max/div1+max/div2-max/lcm);
	minNum=min-(min/div1+min/div2-min/lcm);
	cout<<maxNum-minNum<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
/*
  sum of subarr % K == num of elements
  
*/
const int N = 2e5 + 10;
int n, m;
string s;
int a[N],r,trace[N];

int main() {
	cin >> n >> m >> s;
	fill(a, a + n + 1, (int)1e9);
	a[0] = 0; r = 1;
	for (int i = 0; i < n; ++i) if (s[i]=='0') {
		while (r <= i + m && r<=n) {
			if (s[r] == '0') {
				if (a[i] + 1 < a[r]) {
					a[r] = a[i] + 1;
					trace[r] = i;
				}
			}
			r++;
		}
	}
	if (a[n] == 1e9) {
		cout << -1 << endl;
	}
	else {
		vector<int> v;
		for (int i = n; i > 0; i = trace[i]) {
			v.push_back(i - trace[i]);
		}
		reverse(v.begin(), v.end());
		for (int x : v) cout << x << " ";
		cout << endl;
	}
}

Measured memory_bytes: 1912
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = numeric_limits<int>::infinity();
const int E = numeric_limits<int>::min();

int main(void)
{
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int wakeup = H1 * 60 + M1;
    int gotobed = H2 * 60 + M2;

    int elapsed = gotobed - wakeup - K;

    cout << elapsed << endl;

    return 0;
}

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

using ll = long long;

const int MAX_N = 200010;
int par[MAX_N];
int rnk[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

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

void solve() {
    int N, x[100001], y[100001];
    set<int> xs[100001], ys[100001];
    rep(i, 100001) {
        xs[i] = {};
        ys[i] = {};
    }
    cin >> N;
    rep(i, N) {
        cin >> x[i] >> y[i];
        xs[x[i]].insert(y[i]);
        ys[y[i]].insert(x[i]);
    }
    set<pair<int, int>> ans{};
    rep(i, N) {
        if (xs[x[i]].size() > 1 && ys[y[i]].size() > 1) {
            for (auto j = xs[x[i]].begin(); j != xs[x[i]].end(); ++j) {
                for (auto k = ys[y[i]].begin(); k != ys[y[i]].end(); ++k) {
                    ans.insert(make_pair(*j, *k));
                }
            }
        }
    }
    rep(i, N) auto c = ans.erase(make_pair(x[i], y[i]));
    cout << ans.size() << endl;
}

int main() {
    init(200000);
    int N, x, y;
    cin >> N;
    rep(i, N) {
        cin >> x >> y;
        unite(x - 1, 99999 + y);
    }
    vector<ll> sx(200000, 0), sy(200000, 0);
    rep(i, 100000) {
        sx[find(i)]++;
        sy[find(i + 100000)]++;
    }
    ll ans = 0;
    rep(i, 200001) ans += sx[i] * sy[i];
    cout << ans - N << endl;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(void)
{
	int i,min=2000,sum;
	int n=0, m=0, k;
	char s[1001], t[1001];

	scanf("%s", &s);
	scanf("%s",&t);

for(int i=0;s[i]!='\0';i++)
n++;
for(int i=0;t[i]!='\0';i++)
m++;

for(int i=0;i<n-m+1;i++){

	sum=0;
	for(int j=0;j<m;j++){
		if(s[i+j]!=t[j]){
			sum++;
		}
	}
	if(sum<min)
	min=sum;
}
printf("%d",min);

	return 0;
}

Measured memory_bytes: 1736
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
//このひとのお決まりはここまで。たぶん使い慣れたライブラリだけ入れて、つかいやすい方だけ用意している。
int N;
ivec L;
int s=0;

int main()
{
	cin >> N;
	for (int i=0; i < 2*N; i++){
		int l;
		cin >> l;
		L.push_back(l);
	}
	sort(L.begin(), L.end());

	for (int i=0; i < N; i++){
		s = s + L[i*2];
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int masu,a,b,cnt,i,j,x[1001],y[1001];
	while(1){
		masu=1;
		scanf("%d%d",&a,&b);
		if(a==0 && b==0)break;
		for(i=1;i<=a;i++)scanf("%d",&x[i]);
		for(i=1;i<=b;i++)scanf("%d",&y[i]);
		for(i=1;;i++){
			masu=masu+y[i];
			if(masu>=a)break;
			masu=masu+x[masu];
			if(masu>=a)break;
		}
		printf("%d\n",i);
	}
	return 0;
}


Measured memory_bytes: 2056
H,W,K=map(int,input().split())
mod=10**9+7
fib=[1,1,2,3,5,8,13,21]

from functools import lru_cache

@lru_cache(maxsize=None)
def dfs(cur,now):
    if cur==H:
        if now==K:
            return 1
        else:
            return 0
    elif now==1:
        if W==1:
            return dfs(cur+1,1)%mod
        else:
            return (fib[W-1]*dfs(cur+1,1)+fib[W-2]*dfs(cur+1,2))%mod
    elif now==W:
        return (fib[W-2]*dfs(cur+1,W-1)+fib[W-1]*dfs(cur+1,W))%mod
    else:
        return (fib[W-now]*fib[now-2]*dfs(cur+1,now-1)+fib[W-now]*fib[now-1]*dfs(cur+1,now)+fib[W-now-1]*fib[now-1]*dfs(cur+1,now+1))%mod
    
print(dfs(0,1))

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

int main() {
    int N;
    cin >> N;
    vector<int> X(N), Y(N), H(N);
    int h_i = 0;
    for (int i = 0; i < N; i++) {
        int x, y, h;
        cin >> x >> y >> h;
        if (h > 0) h_i = i;
        X[i] = x;
        Y[i] = y;
        H[i] = h;
    }

    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
            int h = H[h_i] + abs(X[h_i] - x) + abs(Y[h_i] - y);

            bool flag = true;
            for (int i = 0; i < N; i++) {
                if (max(h - abs(X[i] - x) - abs(Y[i] - y), 0) != H[i]) {
                    flag = false;
                    break;
                }
            }

            if (flag) {
                cout << x << " " << y << " " << h << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MAX_N 100000
#define INF (MAX_N * 10000)
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> H(N + 1);
  rep(i, N) { cin >> H[i]; }
  H[N] = INF;

  vector<ll> dp(MAX_N + 1, INF);
  dp[0] = 0;
  rep(i, N - 1) {
    for (int j = 1; j <= K; j++) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(H[i] - H[i + j]));
    }
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define ull unsigned long long int
#define T int test; scanf("%d",&test); while(test--)
#define pb push_back
#define in insert
#define PI acos(-1)
#define sc(n) scanf("%d",&n)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define lsc(n) scanf("%lld",&n)
#define lsc2(a,b) scanf("%lld%lld",&a,&b)
#define rep(i,n) for(i=0;i<n;i++)
#define fr(i,a,b) for(i=a;i<b;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
using namespace std;



int main()
{
	double r,c=0;
	cin >> r;
	c=2*PI*r;
	cout << c << endl;
    return 0;
}


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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	char yes[5] = "Yes";
	char No[5] = "No";
	if( (a <= c && b >= c) || (b <= c && a >= c)){
		cout << yes << endl;
	}else{
		cout << No << endl;
	}
	return 0;
}


Measured memory_bytes: 256
a, b ,c= map(int, input().split())
k = int(input())
w = 0
if a >=b:
  while a >=b:
    b = b*2
    w+=1
if b >=c:
  while b >=c:
    c = c*2
    w+=1
if w<=k:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 61632
// A.

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
	int x, a, b;
	cin >> x >> a >> b;
	bool ans = abs(x - a) < abs(x - b);
	cout << (ans ? "A" : "B") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int arr[100100][4];
int dp[100100][4];
signed main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	}
	for (int i = 0; i < 3; i++){
		dp[0][i] = arr[0][i];
	}
	for (int i = 1; i < n; i++){
		dp[i][0] = max(dp[i-1][1]+arr[i][0], dp[i-1][2]+arr[i][0]);
		dp[i][1] = max(dp[i-1][0]+arr[i][1], dp[i-1][2]+arr[i][1]);
		dp[i][2] = max(dp[i-1][0]+arr[i][2], dp[i-1][1]+arr[i][2]);
	}
	cout << max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]) << "\n";
} 

Measured memory_bytes: 6528
while True:
    H,W = [int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            if (h+w) % 2 == 0:
                print('#',end='')
            else:
                print('.',end='')

        print()
    print()

Measured memory_bytes: 9052
#include<stdio.h>
int main(){

    char s[100000];
    int n,a,b;

    scanf("%d %d %d",&n,&a,&b);
    scanf("%s",s);

    int i=0;
    int countA=0;
    int countB=0;

    for(i=0;i<n;i++){
        if(s[i]=='a' && (countA+countB)<(a+b)){
                printf("Yes\n");
                countA++;
        }
        else if(s[i]=='b' && (countA+countB)<(a+b) && countB<b){
                printf("Yes\n");
                countB++;
        }
        else
            printf("No\n");
    }

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
    string s; cin >> s;
    long long ans=0;
    for(int i=0; i<1<<(s.size()-1); ++i){
        long long sum=0;
        int b=0, l=1;
        for(int j=0; j<s.size()-1; ++j){
            if((1<<j) & i){
                sum+=atol(s.substr(b, l).c_str());
                b+=l;
                l=1;
            } else{
                ++l;
            }
        }
        sum+=atol(s.substr(b, l).c_str());
        ans+=sum;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = 100000000;
    REP(i,100){
        int now = 0;
        rep(j,n){
            now+=pow((i-x[j]),2);
        }
        ans = min(ans,now);
    }
    cout << ans << endl;
}

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

int main() {
	vector<vector<int>> data(3, vector<int>(3));
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> data[i][j];
		}
	}
	
	for (int i = 1; i < 3; ++i) {
		int num = data[i][0] - data[i-1][0];
		for (int j = 0; j < 3; ++j) {
			if (num != data[i][j] - data[i - 1][j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String t = scan.nextLine();
		scan.close();
		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if(!(s.substring(i,i+1).equals(t.substring(i,i+1)))){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 56144
/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	double man = 0;
	double yu2 = 0;
	double yu3 = 0;
	double tye = 0;
	double N;
	double num;
	cin >> N;
	vector<double> A;
	vector<double> B;

	// ??\???
	for (size_t i = 0; i < N; i++)
	{
		cin >> num;
		A.push_back(num);
	}
	for (size_t i = 0; i < N; i++)
	{
		cin >> num;
		B.push_back(num);
	}

	// ???????????????????????¢
	for (size_t i = 0; i < A.size(); i++)
	{
		man += abs(A[i] - B[i]);
	}

	// ???????????????????????¢(2)
	for (size_t i = 0; i < A.size(); i++)
	{
		yu2 += pow(abs(A[i] - B[i]), 2.0);
	}
	yu2 = sqrt(yu2);

	// ???????????????????????¢(3)
	for (size_t i = 0; i < A.size(); i++)
	{
		yu3 += pow(abs(A[i] - B[i]), 3.0);
	}
	yu3 = pow(yu3, 1.0/3.0);

	// ?????§????????§????????¢
	for (size_t i = 0; i < A.size(); i++)
	{
		double tmp = abs(A[i] - B[i]);
		tye = std::max(tye, tmp);
	}
	
	cout << fixed << setprecision(10) << man << endl;
	cout << fixed << setprecision(10) << yu2 << endl;
	cout << fixed << setprecision(10) << yu3 << endl;
	cout << fixed << setprecision(10) << tye << endl;

	return 0;
}

Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
#define ROF(i, b, a) for (int i=(b); i>(a); --i)
#define CASET int _T; cin >> _T; FOR(caset, 0, _T)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 1e9+7;
 
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> &pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

int f(int a, int b) {
    int res = a-1;
    a -= res;
    b -= res;
    ++res;
    --b;
    res += (b-a) / 2;
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, a, b;
    cin >> n >> a >> b;

    if (a > b) swap(a, b);

    if (a%2 == b%2) {
        cout << (b-a) / 2;
        return 0;
    }
    
    int res = f(a, b);
    a = n+1 - a;
    b = n+1 - b;
    swap(a, b);
    res = min(res, f(a, b));
    cout << res;
}

Measured memory_bytes: 256
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())-1])

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	vector<ll> c(26, 1);
	rep(i, n){
		c[(int)(s[i] - 'a')]++;
	}
	
	ll ans = 1;
	rep(i, 26){
		ans = ans * c[i] % MOD;
	}
	ans--;
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a,b;
        String op;
        while(true){
            a = input.nextInt();
            op = input.next();
            b = input.nextInt();
            if (op.equals("?")){
                break;
            } else if (op.equals("+")){
                System.out.println(a+b);
            } else if (op.equals("-")){
                System.out.println(a-b);
            } else if (op.equals("*")){
                System.out.println(a*b);
            } else if (op.equals("/")){
                System.out.println(a/b);
            }
        }
    }
}


Measured memory_bytes: 26200
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;


int main() {
	unsigned long long int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (a > b) {
		if (a > c) {
			for (unsigned long long int i = 0; i < k; ++i) {
				a *= 2;
			}
		}
		else {
			for (unsigned long long int i = 0; i < k; ++i) {
				c *= 2;
			}
		}
	}
	else {
		if (b > c) {
			for (unsigned long long int i = 0; i < k; ++i) {
				b *= 2;
			}
		}
		else {
			for (unsigned long long int i = 0; i < k; ++i) {
				c *= 2;
			}
		}
	}
	cout << a + b + c << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = list(input())

if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
else:
  S[K-1] = 'c'
  
ans = ''
for i in range(len(S)):
  ans += S[i]
  
print(ans)

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

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0;i < n;i++)cin >> a[i];
	int num[n] = {};
	for (int i = 0;i < n;i++)num[a[i]-1]++;
	sort(num, num + n);
	reverse(num, num + n);
	int ans = 0;
	for (int i = 0;i < k;i++)ans += num[i];
	cout << n - ans << endl;
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef pair<int, int> ii;

const int N = 5e3 + 5;
int n, sum;
vector< pair<int, ii> > vec;
priority_queue<int> pq;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int h, p; cin >> h >> p;
        vec.pb( { h + p, { h, p } } );
    }
    sort(vec.begin(), vec.end() );
    for (auto i : vec) {
        if(sum <= i.se.fi) {
            pq.push(i.se.se);
            sum += i.se.se;
        }
        else {
            if(i.se.se < pq.top() ) {
                sum -= pq.top(); pq.pop();
                sum += i.se.se; pq.push(i.se.se);
            }
        }
    }

    cout << pq.size();

    return 0;
}


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

using namespace std;

int h,w,lim;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
char g[11][11];
string s="RGB";

void rev(int x,int y,vector<int>&p,char ch){
  char tmp=g[y][x];
  g[y][x]=ch;
  p.push_back(y*w+x);

  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx<0 || ny<0 || w<=nx || h<=ny || g[ny][nx]!=tmp)continue;
    rev(nx,ny,p,ch);
  }
}

bool dfs(int d){

  bool fg=true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      fg&=(g[i][j]==g[0][0]);
    }
  }

  if(fg)return true;

  if(d>=lim)return false;

  for(int i=0;i<3;i++){
    if(g[0][0]==s[i])continue;
    char tmp=g[0][0];
    vector<int> p;
    rev(0,0,p,s[i]);
    if(dfs(d+1))return true;
    for(int j=0;j<p.size();j++){
      g[p[j]/w][p[j]%w]=tmp;
    }
  }
  return false;
}

int main(void){

  while(cin >> w >> h,w|h){

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> g[i][j];
      }
    }

    for(lim=0;;lim++){
      if(dfs(0))break;
    }

    cout << lim << endl;

  }
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    int i,num=0;
    cin >> a >> b >> c;
    for(i=a; i<=b; i++){
       if(c%i == 0 ){  
           num++;
       }
    }
    cout << num;
    cout << endl;
} 


Measured memory_bytes: 3084
#include<stdio.h>

int main(){
  int N,M;
  char str[100005];
  int map[100005];
  int i,g,lg;
  scanf("%d%d",&N,&M);
  scanf("%s",&str);
  g = N;  
  lg = -1;
  for(i=N-1;i>=0;i--){
    if(str[i] == '0'){
      map[i] = g-i;
      lg = i;
    }
    if( g-i == M){
      if(lg == -1){
        printf("-1");
        return 0;
      }
      g = lg;
      lg = -1;
    }
  }
  for(i=0;i<N;){
    printf("%d\n",map[i]);
    i = i + map[i];
  }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  bool judge = true;
  vector<int> smap(26);
  vector<int> tmap(26);
  for(int i = 0;i < 26;i++){
    smap[i] = -1;
    tmap[i] = -1;
  }
  vector<int> s(S.size());
  vector<int> t(S.size());
  for(int i = 0;i < S.size();i++){
    s[i] = S[i]-'a';
    t[i] = T[i]-'a';
  }
  for(int i = 0;i < S.size();i++){
    if(smap[s[i]] == -1)smap[s[i]] = t[i];
    if(smap[s[i]] == t[i]){
    }else if(smap[s[i]] != t[i]){
      judge = false;
      break;
    }
  }
  for(int i = 0;i < S.size();i++){
    if(tmap[t[i]] == -1)tmap[t[i]] = s[i];
    if(tmap[t[i]] == s[i]){
    }else if(tmap[t[i]] != s[i]){
      judge = false;
      break;
    }
  }
  if(judge == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 2312
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int k;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root, *NIL;

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);
struct Node * find(struct Node *, int);

int main(){
  int i,n,value,findnum;
  char A[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",A);

    if(strcmp(A,"insert")==0){
     scanf("%d",&value);
      insert(value);
    }
    else if(strcmp(A,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(A,"find") == 0){
      scanf("%d",&findnum);
      struct Node *F = find(root,findnum);
      if(F != NIL) printf("yes\n");
      else printf("no\n");
    }
  }

    return 0;
}

void insert(int n){
struct  Node *p = root;
struct  Node *q = NIL;
struct  Node *r;

r = (struct Node *)malloc(sizeof(struct Node));
r -> k = n;
r -> left = NIL;
r -> right = NIL;

while(p != NIL){
   q = p;
   if(r->k < p->k){
     p = p -> left;
   }
   else{
     p = p -> right;
   }
}

r -> parent = q;
  if(q == NIL){
    root = r;
  }
  else{
    if(r->k < q->k){
      q -> left = r;
    }
    else{
      q -> right = r;
    }
  }
}

void inorder(struct Node *x){
  if(x == NIL) return;
  inorder(x -> left);
  printf(" %d",x -> k);
  inorder(x -> right);
}

void preorder(struct Node *x){
  if(x == NIL) return;
  printf(" %d",x -> k);
  preorder(x -> left);
  preorder(x -> right);
}

struct Node * find(struct Node *x, int n){
  while(x != NIL && n != x -> k){
    if(n < x -> k ) x = x -> left;
    else x = x -> right;
  }
  return x;
}



Measured memory_bytes: 25212